summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--ChangeLog706
-rw-r--r--LICENSE34
-rw-r--r--Makefile.am1
-rw-r--r--Makefile.nmake4
-rw-r--r--README12
-rw-r--r--ReleaseNotes975
-rw-r--r--acinclude.m42
-rw-r--r--changes/122074
-rw-r--r--changes/bufferevent_compilation6
-rw-r--r--changes/bug113024
-rw-r--r--changes/bug116838
-rw-r--r--changes/bug122023
-rw-r--r--changes/bug125033
-rw-r--r--changes/bug125735
-rw-r--r--changes/bug126025
-rw-r--r--changes/bug132147
-rw-r--r--changes/bug133155
-rw-r--r--changes/bug1339912
-rw-r--r--changes/bug13399_part13
-rw-r--r--changes/bug838711
-rw-r--r--changes/bug98015
-rw-r--r--changes/coverage-html5
-rw-r--r--changes/feature55832
-rw-r--r--changes/further-12184-diagnostic2
-rw-r--r--changes/geoip-july20143
-rw-r--r--changes/geoip6-july20142
-rw-r--r--changes/no-wince4
-rw-r--r--changes/spurious-clang-warnings10
-rw-r--r--changes/threads-required12
-rw-r--r--configure.ac223
-rw-r--r--contrib/dist/tor.service.in10
-rw-r--r--contrib/win32build/tor-mingw.nsi.in2
-rw-r--r--doc/HACKING33
-rw-r--r--doc/TUNING47
-rw-r--r--doc/building-tor-msvc.txt122
-rw-r--r--doc/tor.1.txt130
-rw-r--r--scripts/README5
-rw-r--r--scripts/coccinelle/calloc.cocci23
-rw-r--r--scripts/coccinelle/malloc_cast.cocci38
-rw-r--r--scripts/coccinelle/uncalloc.cocci13
-rw-r--r--scripts/codegen/makedesc.py218
-rwxr-xr-xscripts/codegen/run_trunnel.sh11
-rwxr-xr-xscripts/maint/checkSpace.pl30
-rwxr-xr-xscripts/maint/format_changelog.py296
-rwxr-xr-xscripts/test/cov-diff4
-rw-r--r--src/common/Makefile.nmake9
-rw-r--r--src/common/address.c25
-rw-r--r--src/common/address.h15
-rw-r--r--src/common/aes.c2
-rw-r--r--src/common/aes.h2
-rw-r--r--src/common/backtrace.c2
-rw-r--r--src/common/backtrace.h2
-rw-r--r--src/common/compat.c62
-rw-r--r--src/common/compat.h11
-rw-r--r--src/common/compat_libevent.c5
-rw-r--r--src/common/compat_libevent.h2
-rw-r--r--src/common/container.c704
-rw-r--r--src/common/container.h32
-rw-r--r--src/common/crypto.c58
-rw-r--r--src/common/crypto.h8
-rw-r--r--src/common/crypto_curve25519.c178
-rw-r--r--src/common/crypto_curve25519.h18
-rw-r--r--src/common/crypto_ed25519.c353
-rw-r--r--src/common/crypto_ed25519.h113
-rw-r--r--src/common/crypto_format.c24
-rw-r--r--src/common/crypto_pwbox.c187
-rw-r--r--src/common/crypto_pwbox.h20
-rw-r--r--src/common/crypto_s2k.c460
-rw-r--r--src/common/crypto_s2k.h73
-rw-r--r--src/common/di_ops.c4
-rw-r--r--src/common/di_ops.h2
-rw-r--r--src/common/include.am16
-rw-r--r--src/common/log.c255
-rw-r--r--src/common/memarea.c2
-rw-r--r--src/common/memarea.h2
-rw-r--r--src/common/mempool.c2
-rw-r--r--src/common/mempool.h2
-rw-r--r--src/common/procmon.c2
-rw-r--r--src/common/procmon.h2
-rw-r--r--src/common/sandbox.c193
-rw-r--r--src/common/sandbox.h40
-rw-r--r--src/common/testsupport.h2
-rw-r--r--src/common/torgzip.c72
-rw-r--r--src/common/torgzip.h5
-rw-r--r--src/common/torint.h22
-rw-r--r--src/common/torlog.h5
-rw-r--r--src/common/tortls.c74
-rw-r--r--src/common/tortls.h2
-rw-r--r--src/common/util.c269
-rw-r--r--src/common/util.h8
-rw-r--r--src/common/util_process.c6
-rw-r--r--src/common/util_process.h2
-rw-r--r--src/config/geoip5217
-rw-r--r--src/config/geoip62012
-rw-r--r--src/config/include.am2
-rw-r--r--src/config/torrc.minimal.in192
-rw-r--r--src/config/torrc.minimal.in-staging193
-rw-r--r--src/config/torrc.sample.in17
-rw-r--r--src/ext/Makefile.nmake12
-rw-r--r--src/ext/OpenBSD_malloc_Linux.c12
-rw-r--r--src/ext/README12
-rw-r--r--src/ext/csiphash.c2
-rw-r--r--src/ext/curve25519_donna/curve25519-donna.c292
-rw-r--r--src/ext/ed25519/ref10/Makefile41
-rw-r--r--src/ext/ed25519/ref10/README.tor23
-rw-r--r--src/ext/ed25519/ref10/api.h4
-rw-r--r--src/ext/ed25519/ref10/base.h1344
-rw-r--r--src/ext/ed25519/ref10/base.py65
-rw-r--r--src/ext/ed25519/ref10/base2.h40
-rw-r--r--src/ext/ed25519/ref10/base2.py60
-rw-r--r--src/ext/ed25519/ref10/blinding.c76
-rw-r--r--src/ext/ed25519/ref10/crypto_hash_sha512.h30
-rw-r--r--src/ext/ed25519/ref10/crypto_int32.h25
-rw-r--r--src/ext/ed25519/ref10/crypto_int64.h23
-rw-r--r--src/ext/ed25519/ref10/crypto_sign.h9
-rw-r--r--src/ext/ed25519/ref10/crypto_uint32.h3
-rw-r--r--src/ext/ed25519/ref10/crypto_uint64.h3
-rw-r--r--src/ext/ed25519/ref10/crypto_verify_32.h5
-rw-r--r--src/ext/ed25519/ref10/d.h1
-rw-r--r--src/ext/ed25519/ref10/d.py28
-rw-r--r--src/ext/ed25519/ref10/d2.h1
-rw-r--r--src/ext/ed25519/ref10/d2.py28
-rw-r--r--src/ext/ed25519/ref10/ed25519_ref10.h30
-rw-r--r--src/ext/ed25519/ref10/fe.h56
-rw-r--r--src/ext/ed25519/ref10/fe_0.c19
-rw-r--r--src/ext/ed25519/ref10/fe_1.c19
-rw-r--r--src/ext/ed25519/ref10/fe_add.c57
-rw-r--r--src/ext/ed25519/ref10/fe_cmov.c63
-rw-r--r--src/ext/ed25519/ref10/fe_copy.c29
-rw-r--r--src/ext/ed25519/ref10/fe_frombytes.c73
-rw-r--r--src/ext/ed25519/ref10/fe_invert.c14
-rw-r--r--src/ext/ed25519/ref10/fe_isnegative.c16
-rw-r--r--src/ext/ed25519/ref10/fe_isnonzero.c19
-rw-r--r--src/ext/ed25519/ref10/fe_mul.c253
-rw-r--r--src/ext/ed25519/ref10/fe_neg.c45
-rw-r--r--src/ext/ed25519/ref10/fe_pow22523.c13
-rw-r--r--src/ext/ed25519/ref10/fe_sq.c149
-rw-r--r--src/ext/ed25519/ref10/fe_sq2.c160
-rw-r--r--src/ext/ed25519/ref10/fe_sub.c57
-rw-r--r--src/ext/ed25519/ref10/fe_tobytes.c119
-rw-r--r--src/ext/ed25519/ref10/ge.h95
-rw-r--r--src/ext/ed25519/ref10/ge_add.c11
-rw-r--r--src/ext/ed25519/ref10/ge_add.h97
-rw-r--r--src/ext/ed25519/ref10/ge_add.q49
-rw-r--r--src/ext/ed25519/ref10/ge_double_scalarmult.c96
-rw-r--r--src/ext/ed25519/ref10/ge_frombytes.c50
-rw-r--r--src/ext/ed25519/ref10/ge_madd.c11
-rw-r--r--src/ext/ed25519/ref10/ge_madd.h88
-rw-r--r--src/ext/ed25519/ref10/ge_madd.q46
-rw-r--r--src/ext/ed25519/ref10/ge_msub.c11
-rw-r--r--src/ext/ed25519/ref10/ge_msub.h88
-rw-r--r--src/ext/ed25519/ref10/ge_msub.q46
-rw-r--r--src/ext/ed25519/ref10/ge_p1p1_to_p2.c12
-rw-r--r--src/ext/ed25519/ref10/ge_p1p1_to_p3.c13
-rw-r--r--src/ext/ed25519/ref10/ge_p2_0.c8
-rw-r--r--src/ext/ed25519/ref10/ge_p2_dbl.c11
-rw-r--r--src/ext/ed25519/ref10/ge_p2_dbl.h73
-rw-r--r--src/ext/ed25519/ref10/ge_p2_dbl.q41
-rw-r--r--src/ext/ed25519/ref10/ge_p3_0.c9
-rw-r--r--src/ext/ed25519/ref10/ge_p3_dbl.c12
-rw-r--r--src/ext/ed25519/ref10/ge_p3_to_cached.c17
-rw-r--r--src/ext/ed25519/ref10/ge_p3_to_p2.c12
-rw-r--r--src/ext/ed25519/ref10/ge_p3_tobytes.c14
-rw-r--r--src/ext/ed25519/ref10/ge_precomp_0.c8
-rw-r--r--src/ext/ed25519/ref10/ge_scalarmult_base.c109
-rw-r--r--src/ext/ed25519/ref10/ge_sub.c11
-rw-r--r--src/ext/ed25519/ref10/ge_sub.h97
-rw-r--r--src/ext/ed25519/ref10/ge_sub.q49
-rw-r--r--src/ext/ed25519/ref10/ge_tobytes.c14
-rw-r--r--src/ext/ed25519/ref10/keyconv.c37
-rw-r--r--src/ext/ed25519/ref10/keypair.c51
-rw-r--r--src/ext/ed25519/ref10/open.c42
-rw-r--r--src/ext/ed25519/ref10/pow22523.h161
-rw-r--r--src/ext/ed25519/ref10/pow22523.q61
-rw-r--r--src/ext/ed25519/ref10/pow225521.h161
-rw-r--r--src/ext/ed25519/ref10/pow225521.q61
-rwxr-xr-xsrc/ext/ed25519/ref10/q2h.sh4
-rw-r--r--src/ext/ed25519/ref10/randombytes.h4
-rw-r--r--src/ext/ed25519/ref10/sc.h15
-rw-r--r--src/ext/ed25519/ref10/sc_muladd.c368
-rw-r--r--src/ext/ed25519/ref10/sc_reduce.c275
-rw-r--r--src/ext/ed25519/ref10/sign.c29
-rw-r--r--src/ext/ed25519/ref10/sqrtm1.h1
-rw-r--r--src/ext/ed25519/ref10/sqrtm1.py28
-rw-r--r--src/ext/ht.h28
-rw-r--r--src/ext/include.am76
-rw-r--r--src/ext/tor_queue.h23
-rw-r--r--src/ext/trunnel/trunnel-impl.h310
-rw-r--r--src/ext/trunnel/trunnel.c247
-rw-r--r--src/ext/trunnel/trunnel.h64
-rw-r--r--src/include.am2
-rw-r--r--src/or/Makefile.nmake8
-rw-r--r--src/or/addressmap.c2
-rw-r--r--src/or/addressmap.h2
-rw-r--r--src/or/buffers.c49
-rw-r--r--src/or/buffers.h2
-rw-r--r--src/or/channel.c33
-rw-r--r--src/or/channel.h3
-rw-r--r--src/or/channeltls.c70
-rw-r--r--src/or/channeltls.h3
-rw-r--r--src/or/circpathbias.c6
-rw-r--r--src/or/circpathbias.h2
-rw-r--r--src/or/circuitbuild.c36
-rw-r--r--src/or/circuitbuild.h2
-rw-r--r--src/or/circuitlist.c256
-rw-r--r--src/or/circuitlist.h6
-rw-r--r--src/or/circuitmux.c16
-rw-r--r--src/or/circuitmux.h2
-rw-r--r--src/or/circuitmux_ewma.c6
-rw-r--r--src/or/circuitmux_ewma.h2
-rw-r--r--src/or/circuitstats.c32
-rw-r--r--src/or/circuitstats.h2
-rw-r--r--src/or/circuituse.c84
-rw-r--r--src/or/circuituse.h2
-rw-r--r--src/or/command.c22
-rw-r--r--src/or/command.h2
-rw-r--r--src/or/config.c190
-rw-r--r--src/or/config.h5
-rw-r--r--src/or/confparse.c2
-rw-r--r--src/or/confparse.h2
-rw-r--r--src/or/connection.c55
-rw-r--r--src/or/connection.h5
-rw-r--r--src/or/connection_edge.c6
-rw-r--r--src/or/connection_edge.h2
-rw-r--r--src/or/connection_or.c28
-rw-r--r--src/or/connection_or.h2
-rw-r--r--src/or/control.c69
-rw-r--r--src/or/control.h6
-rw-r--r--src/or/cpuworker.c4
-rw-r--r--src/or/cpuworker.h2
-rw-r--r--src/or/directory.c34
-rw-r--r--src/or/directory.h2
-rw-r--r--src/or/dirserv.c452
-rw-r--r--src/or/dirserv.h5
-rw-r--r--src/or/dirvote.c454
-rw-r--r--src/or/dirvote.h28
-rw-r--r--src/or/dns.c6
-rw-r--r--src/or/dns.h2
-rw-r--r--src/or/dnsserv.c2
-rw-r--r--src/or/dnsserv.h2
-rw-r--r--src/or/entrynodes.c84
-rw-r--r--src/or/entrynodes.h5
-rw-r--r--src/or/eventdns_tor.h2
-rw-r--r--src/or/ext_orport.c1
-rw-r--r--src/or/ext_orport.h2
-rw-r--r--src/or/fp_pair.c8
-rw-r--r--src/or/fp_pair.h2
-rw-r--r--src/or/geoip.c30
-rw-r--r--src/or/geoip.h10
-rw-r--r--src/or/hibernate.c53
-rw-r--r--src/or/hibernate.h3
-rw-r--r--src/or/include.am8
-rw-r--r--src/or/main.c176
-rw-r--r--src/or/main.h2
-rw-r--r--src/or/microdesc.c81
-rw-r--r--src/or/microdesc.h4
-rw-r--r--src/or/networkstatus.c45
-rw-r--r--src/or/networkstatus.h19
-rw-r--r--src/or/nodelist.c39
-rw-r--r--src/or/nodelist.h7
-rw-r--r--src/or/ntmain.c2
-rw-r--r--src/or/ntmain.h2
-rw-r--r--src/or/onion.c24
-rw-r--r--src/or/onion.h4
-rw-r--r--src/or/onion_fast.c2
-rw-r--r--src/or/onion_fast.h2
-rw-r--r--src/or/onion_ntor.c2
-rw-r--r--src/or/onion_ntor.h5
-rw-r--r--src/or/onion_tap.c7
-rw-r--r--src/or/onion_tap.h2
-rw-r--r--src/or/or.h66
-rw-r--r--src/or/policies.c126
-rw-r--r--src/or/policies.h21
-rw-r--r--src/or/reasons.c6
-rw-r--r--src/or/reasons.h2
-rw-r--r--src/or/relay.c17
-rw-r--r--src/or/relay.h2
-rw-r--r--src/or/rendclient.c8
-rw-r--r--src/or/rendclient.h2
-rw-r--r--src/or/rendcommon.c27
-rw-r--r--src/or/rendcommon.h3
-rw-r--r--src/or/rendmid.c17
-rw-r--r--src/or/rendmid.h2
-rw-r--r--src/or/rendservice.c50
-rw-r--r--src/or/rendservice.h2
-rw-r--r--src/or/rephist.c23
-rw-r--r--src/or/rephist.h2
-rw-r--r--src/or/replaycache.c2
-rw-r--r--src/or/replaycache.h2
-rw-r--r--src/or/router.c78
-rw-r--r--src/or/router.h4
-rw-r--r--src/or/routerlist.c166
-rw-r--r--src/or/routerlist.h22
-rw-r--r--src/or/routerparse.c112
-rw-r--r--src/or/routerparse.h18
-rw-r--r--src/or/routerset.c41
-rw-r--r--src/or/routerset.h42
-rw-r--r--src/or/statefile.c2
-rw-r--r--src/or/statefile.h2
-rw-r--r--src/or/status.c16
-rw-r--r--src/or/status.h2
-rw-r--r--src/or/tor_main.c2
-rw-r--r--src/or/transports.c115
-rw-r--r--src/or/transports.h8
-rw-r--r--src/test/bench.c73
-rw-r--r--src/test/ed25519_exts_ref.py234
-rw-r--r--src/test/ed25519_vectors.inc150
-rw-r--r--src/test/example_extrainfo.inc192
-rw-r--r--src/test/failing_routerdescs.inc668
-rw-r--r--src/test/include.am15
-rw-r--r--src/test/slow_ed25519.py115
-rw-r--r--src/test/test-child.c2
-rwxr-xr-xsrc/test/test-network.sh17
-rw-r--r--src/test/test.c319
-rw-r--r--src/test/test.h28
-rw-r--r--src/test/test_accounting.c76
-rw-r--r--src/test/test_addr.c426
-rw-r--r--src/test/test_bt_cl.c9
-rw-r--r--src/test/test_buffers.c115
-rw-r--r--src/test/test_cell_formats.c82
-rw-r--r--src/test/test_cell_queue.c10
-rw-r--r--src/test/test_circuitlist.c20
-rw-r--r--src/test/test_circuitmux.c4
-rw-r--r--src/test/test_config.c218
-rw-r--r--src/test/test_containers.c600
-rw-r--r--src/test/test_controller_events.c2
-rw-r--r--src/test/test_crypto.c1071
-rw-r--r--src/test/test_data.c2
-rw-r--r--src/test/test_dir.c1481
-rw-r--r--src/test/test_entrynodes.c109
-rw-r--r--src/test/test_extorport.c38
-rw-r--r--src/test/test_hs.c18
-rw-r--r--src/test/test_introduce.c78
-rw-r--r--src/test/test_logging.c6
-rw-r--r--src/test/test_microdesc.c361
-rw-r--r--src/test/test_nodelist.c8
-rw-r--r--src/test/test_ntor_cl.c6
-rw-r--r--src/test/test_options.c2
-rw-r--r--src/test/test_policy.c128
-rw-r--r--src/test/test_pt.c160
-rw-r--r--src/test/test_replay.c121
-rw-r--r--src/test/test_routerkeys.c2
-rw-r--r--src/test/test_routerset.c2122
-rw-r--r--src/test/test_socks.c393
-rw-r--r--src/test/test_status.c28
-rw-r--r--src/test/test_util.c2812
-rw-r--r--src/tools/tor-checkkey.c4
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper-natpmp.c2
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper-natpmp.h2
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper-upnp.c2
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper-upnp.h2
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper.c2
-rw-r--r--src/tools/tor-fw-helper/tor-fw-helper.h2
-rw-r--r--src/tools/tor-gencert.c16
-rw-r--r--src/tools/tor-resolve.c6
-rw-r--r--src/trunnel/include.am29
-rw-r--r--src/trunnel/pwbox.c515
-rw-r--r--src/trunnel/pwbox.h173
-rw-r--r--src/trunnel/pwbox.trunnel14
-rw-r--r--src/trunnel/trunnel-local.h18
-rw-r--r--src/win32/orconfig.h11
362 files changed, 28761 insertions, 8651 deletions
diff --git a/.gitignore b/.gitignore
index de1eb04694..9ddd0c5385 100644
--- a/.gitignore
+++ b/.gitignore
@@ -23,6 +23,8 @@
# Python droppings
*.pyc
*.pyo
+# Cscope
+cscope.*
# /
/Makefile
@@ -55,6 +57,7 @@
/mkinstalldirs
/Tor*Bundle.dmg
/tor-*-win32.exe
+/coverage_html/
# /contrib/
/contrib/dist/tor.sh
@@ -133,6 +136,11 @@
/src/config/sample-server-torrc
/src/config/torrc
/src/config/torrc.sample
+/src/config/torrc.minimal
+
+# /src/ext/
+/src/ext/ed25519/ref10/libed25519_ref10.a
+/src/ext/ed25519/ref10/libed25519_ref10.lib
# /src/or/
/src/or/Makefile
@@ -170,6 +178,10 @@
/src/tools/Makefile
/src/tools/Makefile.in
+# /src/trunnel/
+/src/trunnel/libor-trunnel-testing.a
+/src/trunnel/libor-trunnel.a
+
# /src/tools/tor-fw-helper/
/src/tools/tor-fw-helper/tor-fw-helper
/src/tools/tor-fw-helper/tor-fw-helper.exe
diff --git a/ChangeLog b/ChangeLog
index fc8348d51a..f40feedb84 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,708 @@
-Changes in version 0.2.6.1-alpha - 2014-??-??
+Changes in version 0.2.6.2-alpha - 2014-1?-??
+
+
+Changes in version 0.2.6.1-alpha - 2014-10-30
+ Tor 0.2.6.1-alpha is the first release in the Tor 0.2.6.x series. It
+ includes numerous code cleanups and new tests, and fixes a large
+ number of annoying bugs. Out-of-memory conditions are handled better
+ than in 0.2.5, pluggable transports have improved proxy support, and
+ clients now use optimistic data for contacting hidden services. Also,
+ we are now more robust to changes in what we consider a parseable
+ directory object, so that tightening restrictions does not have a risk
+ of introducing infinite download loops.
+
+ This is the first alpha release in a new series, so expect there to be
+ bugs. Users who would rather test out a more stable branch should stay
+ with 0.2.5.x for now.
+
+ o New compiler and system requirements:
+ - Tor 0.2.6.x requires that your compiler support more of the C99
+ language standard than before. The 'configure' script now detects
+ whether your compiler supports C99 mid-block declarations and
+ designated initializers. If it does not, Tor will not compile.
+
+ We may revisit this requirement if it turns out that a significant
+ number of people need to build Tor with compilers that don't
+ bother implementing a 15-year-old standard. Closes ticket 13233.
+ - Tor no longer supports systems without threading support. When we
+ began working on Tor, there were several systems that didn't have
+ threads, or where the thread support wasn't able to run the
+ threads of a single process on multiple CPUs. That no longer
+ holds: every system where Tor needs to run well now has threading
+ support. Resolves ticket 12439.
+
+ o Removed platform support:
+ - We no longer include special code to build on Windows CE; as far
+ as we know, nobody has used Tor on Windows CE in a very long time.
+ Closes ticket 11446.
+
+ o Major features (bridges):
+ - Expose the outgoing upstream HTTP/SOCKS proxy to pluggable
+ transports if they are configured via the "TOR_PT_PROXY"
+ environment variable. Implements proposal 232. Resolves
+ ticket 8402.
+
+ o Major features (client performance, hidden services):
+ - Allow clients to use optimistic data when connecting to a hidden
+ service, which should remove a round-trip from hidden service
+ initialization. See proposal 181 for details. Implements
+ ticket 13211.
+
+ o Major features (directory system):
+ - Upon receiving an unparseable directory object, if its digest
+ matches what we expected, then don't try to download it again.
+ Previously, when we got a descriptor we didn't like, we would keep
+ trying to download it over and over. Closes ticket 11243.
+
+ o Major features (sample torrc):
+ - Add a new, infrequently-changed "torrc.minimal". This file is
+ similar to torrc.sample, but it will change as infrequently as
+ possible, for the benefit of users whose systems prompt them for
+ intervention whenever a default configuration file is changed.
+ Making this change allows us to update torrc.sample to be a more
+ generally useful "sample torrc".
+
+ o Major bugfixes (directory authorities):
+ - Do not assign the HSDir flag to relays if they are not Valid, or
+ currently hibernating. Fixes #12573. Bugfix on tor-0.2.0.10-alpha
+
+ o Major bugfixes (directory bandwidth performance):
+ - Don't flush the zlib buffer aggressively when compressing
+ directory information for clients. This should save about 7% of
+ the bandwidth currently used for compressed descriptors and
+ microdescriptors. Fixes bug 11787; bugfix on 0.1.1.23.
+
+ o Minor features (security, memory wiping):
+ - Ensure we securely wipe keys from memory after
+ crypto_digest_get_digest and init_curve25519_keypair_from_file
+ have finished using them. Resolves ticket 13477.
+
+ o Minor features (security, out-of-memory handling):
+ - When handling an out-of-memory condition, allocate less memory for
+ temporary data structures. Fixes issue 10115.
+ - When handling an out-of-memory condition, consider more types of
+ buffers, including those on directory connections, and zlib
+ buffers. Resolves ticket 11792.
+
+ o Minor features:
+ - When identity keypair is generated for first time, log a
+ congratulatory message that links to the new relay lifecycle
+ document. Implements feature 10427.
+
+ o Minor features (client):
+ - Clients are now willing to send optimistic data (before they
+ receive a 'connected' cell) to relays of any version. (Relays
+ without support for optimistic data are no longer supported on the
+ Tor network.) Resolves ticket 13153.
+
+ o Minor features (directory authorities):
+ - Don't list relays with a bandwidth estimate of 0 in the consensus.
+ Implements a feature proposed during discussion of bug 13000.
+ - In tor-gencert, report an error if the user provides the same
+ argument more than once.
+ - If a directory authority can't find a best consensus method in the
+ votes that it holds, it now falls back to its favorite consensus
+ method. Previously, it fell back to method 1. Neither of these is
+ likely to get enough signatures, but "fall back to favorite"
+ doesn't require us to maintain support an obsolete consensus
+ method. Implements part of proposal 215.
+
+ o Minor features (logging):
+ - On Unix-like systems, you can now use named pipes as the target of
+ the Log option, and other options that try to append to files.
+ Closes ticket 12061. Patch from "carlo von lynX".
+ - When opening a log file at startup, send it every log message that
+ we generated between startup and opening it. Previously, log
+ messages that were generated before opening the log file were only
+ logged to stdout. Closes ticket 6938.
+ - Add a TruncateLogFile option to overwrite logs instead of
+ appending to them. Closes ticket #5583.
+
+ o Minor features (portability, Solaris):
+ - Threads are no longer disabled by default on Solaris; we believe
+ that the versions of Solaris with broken threading support are all
+ obsolete by now. Resolves ticket 9495.
+
+ o Minor features (relay):
+ - Re-check our address after we detect a changed IP address from
+ getsockname(). This ensures that the controller command "GETINFO
+ address" will report the correct value. Resolves ticket 11582.
+ Patch from "ra".
+ - A new AccountingRule option lets Relays set whether they'd like
+ AccountingMax to be applied separately to inbound and outbound
+ traffic, or applied to the sum of inbound and outbound traffic.
+ Resolves ticket 961. Patch by "chobe".
+
+ o Minor features (testing networks):
+ - Add the TestingDirAuthVoteExit option, which lists nodes to assign
+ the "Exit" flag regardless of their uptime, bandwidth, or exit
+ policy. TestingTorNetwork must be set for this option to have any
+ effect. Previously, authorities would take up to 35 minutes to
+ give nodes the Exit flag in a test network. Partially implements
+ ticket 13161.
+
+ o Minor features (validation):
+ - Check all date/time values passed to tor_timegm and
+ parse_rfc1123_time for validity, taking leap years into account.
+ Improves HTTP header validation. Implemented with bug 13476.
+ - In correct_tm(), limit the range of values returned by system
+ localtime(_r) and gmtime(_r) to be between the years 1 and 8099.
+ This means we don't have to deal with negative or too large dates,
+ even if a clock is wrong. Otherwise we might fail to read a file
+ written by us which includes such a date. Fixes bug 13476.
+
+ o Minor bugfixes (bridge clients):
+ - When configured to use a bridge without an identity digest (not
+ recommended), avoid launching an extra channel to it when
+ bootstrapping. Fixes bug 7733; bugfix on 0.2.4.4-alpha.
+
+ o Minor bugfixes (bridges):
+ - When DisableNetwork is set, do not launch pluggable transport
+ plugins, and if any are running, terminate them. Fixes bug 13213;
+ bugfix on 0.2.3.6-alpha.
+
+ o Minor bugfixes (C correctness):
+ - Fix several instances of possible integer overflow/underflow/NaN.
+ Fixes bug 13104; bugfix on 0.2.3.1-alpha and later. Patches
+ from "teor".
+ - In circuit_build_times_calculate_timeout() in circuitstats.c,
+ avoid dividing by zero in the pareto calculations. This traps
+ under clang's "undefined-trap" sanitizer. Fixes bug 13290; bugfix
+ on tor-0.2.2.2-alpha.
+ - Fix an integer overflow in format_time_interval(). Fixes bug
+ 13393; bugfix on 0.2.0.10-alpha.
+ - Set the correct day of year value when the system's localtime(_r)
+ or gmtime(_r) functions fail to set struct tm. Not externally
+ visible. Fixes bug 13476; bugfix on 0.0.2pre14.
+ - Avoid unlikely signed integer overflow in tor_timegm on systems
+ with 32-bit time_t. Fixes bug 13476; bugfix on 0.0.2pre14.
+
+ o Minor bugfixes (client):
+ - Fix smartlist_choose_node_by_bandwidth() so that relays with the
+ BadExit flag are not considered worthy candidates. Fixes bug
+ 13066; bugfix on 0.1.2.3-alpha.
+ - Use the consensus schedule for downloading consensuses, and not
+ the generic schedule. Fixes bug 11679; bugfix on 0.2.2.6-alpha.
+ - Handle unsupported or malformed SOCKS5 requests properly by
+ responding with the appropriate error message before closing the
+ connection. Fixes bugs 12971 and 13314; bugfix on 0.0.2pre13.
+
+ o Minor bugfixes (client, torrc):
+ - Stop modifying the value of our DirReqStatistics torrc option just
+ because we're not a bridge or relay. This bug was causing Tor
+ Browser users to write "DirReqStatistics 0" in their torrc files
+ as if they had chosen to change the config. Fixes bug 4244; bugfix
+ on 0.2.3.1-alpha.
+ - When GeoIPExcludeUnkonwn is enabled, do not incorrectly decide
+ that our options have changed every time we SIGHUP. Fixes bug
+ 9801; bugfix on 0.2.4.10-alpha. Patch from "qwerty1".
+
+ o Minor bugfixes (controller):
+ - Return an error when the second or later arguments of the
+ "setevents" controller command are invalid events. Previously we
+ would return success while silently skipping invalid events. Fixes
+ bug 13205; bugfix on 0.2.3.2-alpha. Reported by "fpxnns".
+
+ o Minor bugfixes (directory system):
+ - Always believe that v3 directory authorities serve extra-info
+ documents, whether they advertise "caches-extra-info" or not.
+ Fixes part of bug 11683; bugfix on 0.2.0.1-alpha.
+ - When running as a v3 directory authority, advertise that you serve
+ extra-info documents so that clients who want them can find them
+ from you too. Fixes part of bug 11683; bugfix on 0.2.0.1-alpha.
+ - Check the BRIDGE_DIRINFO flag bitwise rather than using equality.
+ Previously, directories offering BRIDGE_DIRINFO and some other
+ flag (i.e. microdescriptors or extrainfo) would be ignored when
+ looking for bridges. Partially fixes bug 13163; bugfix
+ on 0.2.0.7-alpha.
+
+ o Minor bugfixes (networking):
+ - Check for orconns and use connection_or_close_for_error() rather
+ than connection_mark_for_close() directly in the getsockopt()
+ failure case of connection_handle_write_impl(). Fixes bug 11302;
+ bugfix on 0.2.4.4-alpha.
+
+ o Minor bugfixes (relay):
+ - When generating our family list, remove spaces from around the
+ entries. Fixes bug 12728; bugfix on 0.2.1.7-alpha.
+ - If our previous bandwidth estimate was 0 bytes, allow publishing a
+ new relay descriptor immediately. Fixes bug 13000; bugfix
+ on 0.1.1.6-alpha.
+
+ o Minor bugfixes (testing networks):
+ - Fix TestingDirAuthVoteGuard to properly give out Guard flags in a
+ testing network. Fixes bug 13064; bugfix on 0.2.5.2-alpha.
+ - Stop using the default authorities in networks which provide both
+ AlternateDirAuthority and AlternateBridgeAuthority. Partially
+ fixes bug 13163; bugfix on 0.2.0.13-alpha.
+
+ o Minor bugfixes (testing):
+ - Stop spawn test failures due to a race condition between the
+ SIGCHLD handler updating the process status, and the test reading
+ it. Fixes bug 13291; bugfix on 0.2.3.3-alpha.
+
+ o Minor bugfixes (testing, Windows):
+ - Avoid passing an extra backslash when creating a temporary
+ directory for running the unit tests on Windows. Fixes bug 12392;
+ bugfix on 0.2.2.25-alpha. Patch from Gisle Vanem.
+
+ o Minor bugfixes (windows):
+ - Remove code to special-case handling of NTE_BAD_KEYSET when
+ acquiring windows CryptoAPI context. This error can't actually
+ occur for the parameters we're providing. Fixes bug 10816; bugfix
+ on 0.0.2pre26.
+
+ o Minor bugfixes (zlib):
+ - Avoid truncating a zlib stream when trying to finalize it with an
+ empty output buffer. Fixes bug 11824; bugfix on 0.1.1.23.
+
+ o Build fixes:
+ - Allow our configure script to build correctly with autoconf 2.62
+ again. Fixes bug 12693; bugfix on 0.2.5.2-alpha.
+ - Improve the error message from ./configure to make it clear that
+ when asciidoc has not been found, the user will have to either add
+ --disable-asciidoc argument or install asciidoc. Resolves
+ ticket 13228.
+
+ o Code simplification and refactoring:
+ - Change the entry_is_live() function to take named bitfield
+ elements instead of an unnamed list of booleans. Closes
+ ticket 12202.
+ - Refactor and unit-test entry_is_time_to_retry() in entrynodes.c.
+ Resolves ticket 12205.
+ - Use calloc and reallocarray functions in preference to multiply-
+ then-malloc. This makes it less likely for us to fall victim to an
+ integer overflow attack when allocating. Resolves ticket 12855.
+ - Use the standard macro name SIZE_MAX, instead of our
+ own SIZE_T_MAX.
+ - Document usage of the NO_DIRINFO and ALL_DIRINFO flags clearly in
+ functions which take them as arguments. Replace 0 with NO_DIRINFO
+ in a function call for clarity. Seeks to prevent future issues
+ like 13163.
+ - Avoid 4 null pointer errors under clang shallow analysis by using
+ tor_assert() to prove that the pointers aren't null. Fixes
+ bug 13284.
+ - Rework the API of policies_parse_exit_policy() to use a bitmask to
+ represent parsing options, instead of a confusing mess of
+ booleans. Resolves ticket 8197.
+ - Introduce a helper function to parse ExitPolicy in
+ or_options_t structure.
+
+ o Documentation:
+ - Add a doc/TUNING document with tips for handling large numbers of
+ TCP connections when running busy Tor relay. Update the warning
+ message to point to this file when running out of sockets
+ operating system is allowing to use simultaneously. Resolves
+ ticket 9708.
+
+ o Removed code:
+ - We no longer remind the user about configuration options that have
+ been obsolete since 0.2.3.x or earlier. Patch by Adrien Bak.
+
+ o Removed features:
+ - Remove the --disable-curve25519 configure option. Relays and
+ clients now are required to support curve25519 and the
+ ntor handshake.
+ - The old "StrictEntryNodes" and "StrictExitNodes" options, which
+ used to be deprecated synonyms for "StrictNodes", are now marked
+ obsolete. Resolves ticket 12226.
+ - The "AuthDirRejectUnlisted" option no longer has any effect, as
+ the fingerprints file (approved-routers) has been deprecated.
+ - Directory authorities do not support being Naming dirauths anymore.
+ The "NamingAuthoritativeDir" config option is now obsolete.
+ - Directory authorities do not support giving out the BadDirectory
+ flag anymore.
+ - Clients don't understand the BadDirectory flag in the consensus
+ anymore, and ignore it.
+
+ o Testing:
+ - Refactor the function that chooses guard nodes so that it can more
+ easily be tested; write some tests for it.
+ - Fix and re-enable the fgets_eagain unit test. Fixes bug 12503;
+ bugfix on 0.2.3.1-alpha. Patch from "cypherpunks."
+ - Create unit tests for format_time_interval(). With bug 13393.
+ - Add unit tests for tor_timegm signed overflow, tor_timegm and
+ parse_rfc1123_time validity checks, correct_tm year clamping. Unit
+ tests (visible) fixes in bug 13476.
+ - Add a "coverage-html" make target to generate HTML-visualized
+ coverage results when building with --enable-coverage. (Requires
+ lcov.) Patch from Kevin Murray.
+ - Enable the backtrace handler (where supported) when running the
+ unit tests.
+ - Revise all unit tests that used the legacy test_* macros to
+ instead use the recommended tt_* macros. This patch was generated
+ with coccinelle, to avoid manual errors. Closes ticket 13119.
+
+ o Distribution (systemd):
+ - systemd unit file: only allow tor to write to /var/lib/tor and
+ /var/log/tor. The rest of the filesystem is accessible for reading
+ only. Patch by intrigeri; resolves ticket 12751.
+ - systemd unit file: ensure that the process and all its children
+ can never gain new privileges. Patch by intrigeri; resolves
+ ticket 12939.
+ - systemd unit file: set up /var/run/tor as writable for the Tor
+ service. Patch by intrigeri; resolves ticket 13196.
+
+ o Removed features (directory authorities):
+ - Remove code that prevented authorities from listing Tor relays
+ affected by CVE-2011-2769 as guards. These relays are already
+ rejected altogether due to the minimum version requirement of
+ 0.2.3.16-alpha. Closes ticket 13152.
+ - Directory authorities no longer advertise or support consensus
+ methods 1 through 12 inclusive. These consensus methods were
+ obsolete and/or insecure: maintaining the ability to support them
+ served no good purpose. Implements part of proposal 215; closes
+ ticket 10163.
+
+ o Testing (test-network.sh):
+ - Stop using "echo -n", as some shells' built-in echo doesn't
+ support "-n". Instead, use "/bin/echo -n". Partially fixes
+ bug 13161.
+ - Stop an apparent test-network hang when used with make -j2. Fixes
+ bug 13331.
+ - Add a --delay option to test-network.sh, which configures the
+ delay before the chutney network tests for data transmission.
+ Partially implements ticket 13161.
+
+
+Changes in version 0.2.5.10 - 2014-10-24
+ Tor 0.2.5.10 is the first stable release in the 0.2.5 series.
+
+ It adds several new security features, including improved
+ denial-of-service resistance for relays, new compiler hardening
+ options, and a system-call sandbox for hardened installations on Linux
+ (requires seccomp2). The controller protocol has several new features,
+ resolving IPv6 addresses should work better than before, and relays
+ should be a little more CPU-efficient. We've added support for more
+ OpenBSD and FreeBSD transparent proxy types. We've improved the build
+ system and testing infrastructure to allow unit testing of more parts
+ of the Tor codebase. Finally, we've addressed several nagging pluggable
+ transport usability issues, and included numerous other small bugfixes
+ and features mentioned below.
+
+ This release marks end-of-life for Tor 0.2.3.x; those Tor versions
+ have accumulated many known flaws; everyone should upgrade.
+
+ o Deprecated versions:
+ - Tor 0.2.3.x has reached end-of-life; it has received no patches or
+ attention for some while.
+
+
+Changes in version 0.2.5.9-rc - 2014-10-20
+ Tor 0.2.5.9-rc is the third release candidate for the Tor 0.2.5.x
+ series. It disables SSL3 in response to the recent "POODLE" attack
+ (even though POODLE does not affect Tor). It also works around a crash
+ bug caused by some operating systems' response to the "POODLE" attack
+ (which does affect Tor). It also contains a few miscellaneous fixes.
+
+ o Major security fixes:
+ - Disable support for SSLv3. All versions of OpenSSL in use with Tor
+ today support TLS 1.0 or later, so we can safely turn off support
+ for this old (and insecure) protocol. Fixes bug 13426.
+
+ o Major bugfixes (openssl bug workaround):
+ - Avoid crashing when using OpenSSL version 0.9.8zc, 1.0.0o, or
+ 1.0.1j, built with the 'no-ssl3' configuration option. Fixes bug
+ 13471. This is a workaround for an OpenSSL bug.
+
+ o Minor bugfixes:
+ - Disable the sandbox name resolver cache when running tor-resolve:
+ tor-resolve doesn't use the sandbox code, and turning it on was
+ breaking attempts to do tor-resolve on a non-default server on
+ Linux. Fixes bug 13295; bugfix on 0.2.5.3-alpha.
+
+ o Compilation fixes:
+ - Build and run correctly on systems like OpenBSD-current that have
+ patched OpenSSL to remove get_cipher_by_char and/or its
+ implementations. Fixes issue 13325.
+
+ o Downgraded warnings:
+ - Downgrade the severity of the 'unexpected sendme cell from client'
+ from 'warn' to 'protocol warning'. Closes ticket 8093.
+
+
+Changes in version 0.2.4.25 - 2014-10-20
+ Tor 0.2.4.25 disables SSL3 in response to the recent "POODLE" attack
+ (even though POODLE does not affect Tor). It also works around a crash
+ bug caused by some operating systems' response to the "POODLE" attack
+ (which does affect Tor).
+
+ o Major security fixes (also in 0.2.5.9-rc):
+ - Disable support for SSLv3. All versions of OpenSSL in use with Tor
+ today support TLS 1.0 or later, so we can safely turn off support
+ for this old (and insecure) protocol. Fixes bug 13426.
+
+ o Major bugfixes (openssl bug workaround, also in 0.2.5.9-rc):
+ - Avoid crashing when using OpenSSL version 0.9.8zc, 1.0.0o, or
+ 1.0.1j, built with the 'no-ssl3' configuration option. Fixes bug
+ 13471. This is a workaround for an OpenSSL bug.
+
+
+Changes in version 0.2.5.8-rc - 2014-09-22
+ Tor 0.2.5.8-rc is the second release candidate for the Tor 0.2.5.x
+ series. It fixes a bug that affects consistency and speed when
+ connecting to hidden services, and it updates the location of one of
+ the directory authorities.
+
+ o Major bugfixes:
+ - Clients now send the correct address for their chosen rendezvous
+ point when trying to access a hidden service. They used to send
+ the wrong address, which would still work some of the time because
+ they also sent the identity digest of the rendezvous point, and if
+ the hidden service happened to try connecting to the rendezvous
+ point from a relay that already had a connection open to it,
+ the relay would reuse that connection. Now connections to hidden
+ services should be more robust and faster. Also, this bug meant
+ that clients were leaking to the hidden service whether they were
+ on a little-endian (common) or big-endian (rare) system, which for
+ some users might have reduced their anonymity. Fixes bug 13151;
+ bugfix on 0.2.1.5-alpha.
+
+ o Directory authority changes:
+ - Change IP address for gabelmoo (v3 directory authority).
+
+
+Changes in version 0.2.4.24 - 2014-09-22
+ Tor 0.2.4.24 fixes a bug that affects consistency and speed when
+ connecting to hidden services, and it updates the location of one of
+ the directory authorities.
+
+ o Major bugfixes:
+ - Clients now send the correct address for their chosen rendezvous
+ point when trying to access a hidden service. They used to send
+ the wrong address, which would still work some of the time because
+ they also sent the identity digest of the rendezvous point, and if
+ the hidden service happened to try connecting to the rendezvous
+ point from a relay that already had a connection open to it,
+ the relay would reuse that connection. Now connections to hidden
+ services should be more robust and faster. Also, this bug meant
+ that clients were leaking to the hidden service whether they were
+ on a little-endian (common) or big-endian (rare) system, which for
+ some users might have reduced their anonymity. Fixes bug 13151;
+ bugfix on 0.2.1.5-alpha.
+
+ o Directory authority changes:
+ - Change IP address for gabelmoo (v3 directory authority).
+
+ o Minor features (geoip):
+ - Update geoip and geoip6 to the August 7 2014 Maxmind GeoLite2
+ Country database.
+
+
+Changes in version 0.2.5.7-rc - 2014-09-11
+ Tor 0.2.5.7-rc fixes several regressions from earlier in the 0.2.5.x
+ release series, and some long-standing bugs related to ORPort reachability
+ testing and failure to send CREATE cells. It is the first release
+ candidate for the Tor 0.2.5.x series.
+
+ o Major bugfixes (client, startup):
+ - Start making circuits as soon as DisabledNetwork is turned off.
+ When Tor started with DisabledNetwork set, it would correctly
+ conclude that it shouldn't build circuits, but it would mistakenly
+ cache this conclusion, and continue believing it even when
+ DisableNetwork is set to 0. Fixes the bug introduced by the fix
+ for bug 11200; bugfix on 0.2.5.4-alpha.
+ - Resume expanding abbreviations for command-line options. The fix
+ for bug 4647 accidentally removed our hack from bug 586 that
+ rewrote HashedControlPassword to __HashedControlSessionPassword
+ when it appears on the commandline (which allowed the user to set
+ her own HashedControlPassword in the torrc file while the
+ controller generates a fresh session password for each run). Fixes
+ bug 12948; bugfix on 0.2.5.1-alpha.
+ - Warn about attempts to run hidden services and relays in the same
+ process: that's probably not a good idea. Closes ticket 12908.
+
+ o Major bugfixes (relay):
+ - Avoid queuing or sending destroy cells for circuit ID zero when we
+ fail to send a CREATE cell. Fixes bug 12848; bugfix on 0.0.8pre1.
+ Found and fixed by "cypherpunks".
+ - Fix ORPort reachability detection on relays running behind a
+ proxy, by correctly updating the "local" mark on the controlling
+ channel when changing the address of an or_connection_t after the
+ handshake. Fixes bug 12160; bugfix on 0.2.4.4-alpha.
+
+ o Minor features (bridge):
+ - Add an ExtORPortCookieAuthFileGroupReadable option to make the
+ cookie file for the ExtORPort g+r by default.
+
+ o Minor features (geoip):
+ - Update geoip and geoip6 to the August 7 2014 Maxmind GeoLite2
+ Country database.
+
+ o Minor bugfixes (logging):
+ - Reduce the log severity of the "Pluggable transport proxy does not
+ provide any needed transports and will not be launched." message,
+ since Tor Browser includes several ClientTransportPlugin lines in
+ its torrc-defaults file, leading every Tor Browser user who looks
+ at her logs to see these notices and wonder if they're dangerous.
+ Resolves bug 13124; bugfix on 0.2.5.3-alpha.
+ - Downgrade "Unexpected onionskin length after decryption" warning
+ to a protocol-warn, since there's nothing relay operators can do
+ about a client that sends them a malformed create cell. Resolves
+ bug 12996; bugfix on 0.0.6rc1.
+ - Log more specific warnings when we get an ESTABLISH_RENDEZVOUS
+ cell on a cannibalized or non-OR circuit. Resolves ticket 12997.
+ - When logging information about an EXTEND2 or EXTENDED2 cell, log
+ their names correctly. Fixes part of bug 12700; bugfix
+ on 0.2.4.8-alpha.
+ - When logging information about a relay cell whose command we don't
+ recognize, log its command as an integer. Fixes part of bug 12700;
+ bugfix on 0.2.1.10-alpha.
+ - Escape all strings from the directory connection before logging
+ them. Fixes bug 13071; bugfix on 0.1.1.15. Patch from "teor".
+
+ o Minor bugfixes (controller):
+ - Restore the functionality of CookieAuthFileGroupReadable. Fixes
+ bug 12864; bugfix on 0.2.5.1-alpha.
+ - Actually send TRANSPORT_LAUNCHED and HS_DESC events to
+ controllers. Fixes bug 13085; bugfix on 0.2.5.1-alpha. Patch
+ by "teor".
+
+ o Minor bugfixes (compilation):
+ - Fix compilation of test.h with MSVC. Patch from Gisle Vanem;
+ bugfix on 0.2.5.5-alpha.
+ - Make the nmake make files work again. Fixes bug 13081. Bugfix on
+ 0.2.5.1-alpha. Patch from "NewEraCracker".
+ - In routerlist_assert_ok(), don't take the address of a
+ routerinfo's cache_info member unless that routerinfo is non-NULL.
+ Fixes bug 13096; bugfix on 0.1.1.9-alpha. Patch by "teor".
+ - Fix a large number of false positive warnings from the clang
+ analyzer static analysis tool. This should make real warnings
+ easier for clang analyzer to find. Patch from "teor". Closes
+ ticket 13036.
+
+ o Distribution (systemd):
+ - Verify configuration file via ExecStartPre in the systemd unit
+ file. Patch from intrigeri; resolves ticket 12730.
+ - Explicitly disable RunAsDaemon in the systemd unit file. Our
+ current systemd unit uses "Type = simple", so systemd does not
+ expect tor to fork. If the user has "RunAsDaemon 1" in their
+ torrc, then things won't work as expected. This is e.g. the case
+ on Debian (and derivatives), since there we pass "--defaults-torrc
+ /usr/share/tor/tor-service-defaults-torrc" (that contains
+ "RunAsDaemon 1") by default. Patch by intrigeri; resolves
+ ticket 12731.
+
+ o Documentation:
+ - Adjust the URLs in the README to refer to the new locations of
+ several documents on the website. Fixes bug 12830. Patch from
+ Matt Pagan.
+ - Document 'reject6' and 'accept6' ExitPolicy entries. Resolves
+ ticket 12878.
+
+
+Changes in version 0.2.5.6-alpha - 2014-07-28
+ Tor 0.2.5.6-alpha brings us a big step closer to slowing down the
+ risk from guard rotation, and fixes a variety of other issues to get
+ us closer to a release candidate.
+
+ o Major features (also in 0.2.4.23):
+ - Make the number of entry guards configurable via a new
+ NumEntryGuards consensus parameter, and the number of directory
+ guards configurable via a new NumDirectoryGuards consensus
+ parameter. Implements ticket 12688.
+
+ o Major bugfixes (also in 0.2.4.23):
+ - Fix a bug in the bounds-checking in the 32-bit curve25519-donna
+ implementation that caused incorrect results on 32-bit
+ implementations when certain malformed inputs were used along with
+ a small class of private ntor keys. This bug does not currently
+ appear to allow an attacker to learn private keys or impersonate a
+ Tor server, but it could provide a means to distinguish 32-bit Tor
+ implementations from 64-bit Tor implementations. Fixes bug 12694;
+ bugfix on 0.2.4.8-alpha. Bug found by Robert Ransom; fix from
+ Adam Langley.
+
+ o Major bugfixes:
+ - Perform circuit cleanup operations even when circuit
+ construction operations are disabled (because the network is
+ disabled, or because there isn't enough directory information).
+ Previously, when we were not building predictive circuits, we
+ were not closing expired circuits either. Fixes bug 8387; bugfix on
+ 0.1.1.11-alpha. This bug became visible in 0.2.4.10-alpha when we
+ became more strict about when we have "enough directory information
+ to build circuits".
+
+ o Minor features:
+ - Authorities now assign the Guard flag to the fastest 25% of the
+ network (it used to be the fastest 50%). Also raise the consensus
+ weight that guarantees the Guard flag from 250 to 2000. For the
+ current network, this results in about 1100 guards, down from 2500.
+ This step paves the way for moving the number of entry guards
+ down to 1 (proposal 236) while still providing reasonable expected
+ performance for most users. Implements ticket 12690.
+ - Update geoip and geoip6 to the July 10 2014 Maxmind GeoLite2
+ Country database.
+ - Slightly enhance the diagnostic message for bug 12184.
+
+ o Minor bugfixes (also in 0.2.4.23):
+ - Warn and drop the circuit if we receive an inbound 'relay early'
+ cell. Those used to be normal to receive on hidden service circuits
+ due to bug 1038, but the buggy Tor versions are long gone from
+ the network so we can afford to resume watching for them. Resolves
+ the rest of bug 1038; bugfix on 0.2.1.19.
+ - Correct a confusing error message when trying to extend a circuit
+ via the control protocol but we don't know a descriptor or
+ microdescriptor for one of the specified relays. Fixes bug 12718;
+ bugfix on 0.2.3.1-alpha.
+
+ o Minor bugfixes:
+ - Fix compilation when building with bufferevents enabled. (This
+ configuration is still not expected to work, however.)
+ Fixes bugs 12438, 12474, 11578; bugfixes on 0.2.5.1-alpha and
+ 0.2.5.3-alpha. Patches from Anthony G. Basile and Sathyanarayanan
+ Gunasekaran.
+ - Compile correctly with builds and forks of OpenSSL (such as
+ LibreSSL) that disable compression. Fixes bug 12602; bugfix on
+ 0.2.1.1-alpha. Patch from "dhill".
+
+
+Changes in version 0.2.4.23 - 2014-07-28
+ Tor 0.2.4.23 brings us a big step closer to slowing down the risk from
+ guard rotation, and also backports several important fixes from the
+ Tor 0.2.5 alpha release series.
+
+ o Major features:
+ - Clients now look at the "usecreatefast" consensus parameter to
+ decide whether to use CREATE_FAST or CREATE cells for the first hop
+ of their circuit. This approach can improve security on connections
+ where Tor's circuit handshake is stronger than the available TLS
+ connection security levels, but the tradeoff is more computational
+ load on guard relays. Implements proposal 221. Resolves ticket 9386.
+ - Make the number of entry guards configurable via a new
+ NumEntryGuards consensus parameter, and the number of directory
+ guards configurable via a new NumDirectoryGuards consensus
+ parameter. Implements ticket 12688.
+
+ o Major bugfixes:
+ - Fix a bug in the bounds-checking in the 32-bit curve25519-donna
+ implementation that caused incorrect results on 32-bit
+ implementations when certain malformed inputs were used along with
+ a small class of private ntor keys. This bug does not currently
+ appear to allow an attacker to learn private keys or impersonate a
+ Tor server, but it could provide a means to distinguish 32-bit Tor
+ implementations from 64-bit Tor implementations. Fixes bug 12694;
+ bugfix on 0.2.4.8-alpha. Bug found by Robert Ransom; fix from
+ Adam Langley.
+
+ o Minor bugfixes:
+ - Warn and drop the circuit if we receive an inbound 'relay early'
+ cell. Those used to be normal to receive on hidden service circuits
+ due to bug 1038, but the buggy Tor versions are long gone from
+ the network so we can afford to resume watching for them. Resolves
+ the rest of bug 1038; bugfix on 0.2.1.19.
+ - Correct a confusing error message when trying to extend a circuit
+ via the control protocol but we don't know a descriptor or
+ microdescriptor for one of the specified relays. Fixes bug 12718;
+ bugfix on 0.2.3.1-alpha.
+ - Avoid an illegal read from stack when initializing the TLS
+ module using a version of OpenSSL without all of the ciphers
+ used by the v2 link handshake. Fixes bug 12227; bugfix on
+ 0.2.4.8-alpha. Found by "starlight".
+
+ o Minor features:
+ - Update geoip and geoip6 to the July 10 2014 Maxmind GeoLite2
+ Country database.
Changes in version 0.2.5.5-alpha - 2014-06-18
diff --git a/LICENSE b/LICENSE
index 4ebab1823f..7e5094742a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -13,7 +13,7 @@ Tor is distributed under this license:
Copyright (c) 2001-2004, Roger Dingledine
Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
-Copyright (c) 2007-2013, The Tor Project, Inc.
+Copyright (c) 2007-2014, The Tor Project, Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -122,6 +122,38 @@ src/ext/csiphash.c is licensed under the following license:
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
+===============================================================================
+Trunnel is distributed under this license:
+
+Copyright 2014 The Tor Project, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+ * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
===============================================================================
src/config/geoip is licensed under the following license:
diff --git a/Makefile.am b/Makefile.am
index 910cb12005..7125c7701c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,6 @@ include src/include.am
include doc/include.am
include contrib/include.am
-
EXTRA_DIST+= \
ChangeLog \
INSTALL \
diff --git a/Makefile.nmake b/Makefile.nmake
index a0a11ebdb9..32401b50b7 100644
--- a/Makefile.nmake
+++ b/Makefile.nmake
@@ -1,6 +1,8 @@
all:
cd src/common
$(MAKE) /F Makefile.nmake
+ cd ../../src/ext
+ $(MAKE) /F Makefile.nmake
cd ../../src/or
$(MAKE) /F Makefile.nmake
cd ../../src/test
@@ -9,6 +11,8 @@ all:
clean:
cd src/common
$(MAKE) /F Makefile.nmake clean
+ cd ../../src/ext
+ $(MAKE) /F Makefile.nmake clean
cd ../../src/or
$(MAKE) /F Makefile.nmake clean
cd ../../src/test
diff --git a/README b/README
index b2a391aa61..342376faf4 100644
--- a/README
+++ b/README
@@ -6,21 +6,23 @@ configure it properly.
To build Tor from source:
./configure && make && make install
+To build Tor from a just-cloned git repository:
+ sh autogen.sh && ./configure && make && make install
+
Home page:
https://www.torproject.org/
Download new versions:
- https://www.torproject.org/download.html
+ https://www.torproject.org/download/download.html
Documentation, including links to installation and setup instructions:
- https://www.torproject.org/documentation.html
+ https://www.torproject.org/docs/documentation.html
Making applications work with Tor:
- https://wiki.torproject.org/noreply/TheOnionRouter/TorifyHOWTO
+ https://wiki.torproject.org/projects/tor/wiki/doc/TorifyHOWTO
Frequently Asked Questions:
- https://www.torproject.org/faq.html
- https://wiki.torproject.org/noreply/TheOnionRouter/TorFAQ
+ https://www.torproject.org/docs/faq.html
To get started working on Tor development:
diff --git a/ReleaseNotes b/ReleaseNotes
index 19185a2968..9d5b8ae88f 100644
--- a/ReleaseNotes
+++ b/ReleaseNotes
@@ -3,6 +3,981 @@ This document summarizes new features and bugfixes in each stable release
of Tor. If you want to see more detailed descriptions of the changes in
each development snapshot, see the ChangeLog file.
+Changes in version 0.2.5.10 - 2014-10-24
+ Tor 0.2.5.10 is the first stable release in the 0.2.5 series.
+
+ It adds several new security features, including improved
+ denial-of-service resistance for relays, new compiler hardening
+ options, and a system-call sandbox for hardened installations on Linux
+ (requires seccomp2). The controller protocol has several new features,
+ resolving IPv6 addresses should work better than before, and relays
+ should be a little more CPU-efficient. We've added support for more
+ OpenBSD and FreeBSD transparent proxy types. We've improved the build
+ system and testing infrastructure to allow unit testing of more parts
+ of the Tor codebase. Finally, we've addressed several nagging pluggable
+ transport usability issues, and included numerous other small bugfixes
+ and features mentioned below.
+
+ This release marks end-of-life for Tor 0.2.3.x; those Tor versions
+ have accumulated many known flaws; everyone should upgrade.
+
+ o Major features (security):
+ - The ntor handshake is now on-by-default, no matter what the
+ directory authorities recommend. Implements ticket 8561.
+ - Make the "tor-gencert" tool used by directory authority operators
+ create 2048-bit signing keys by default (rather than 1024-bit, since
+ 1024-bit is uncomfortably small these days). Addresses ticket 10324.
+ - Warn about attempts to run hidden services and relays in the same
+ process: that's probably not a good idea. Closes ticket 12908.
+ - Disable support for SSLv3. All versions of OpenSSL in use with Tor
+ today support TLS 1.0 or later, so we can safely turn off support
+ for this old (and insecure) protocol. Fixes bug 13426.
+
+ o Major features (relay security, DoS-resistance):
+ - When deciding whether we have run out of memory and we need to
+ close circuits, also consider memory allocated in buffers for
+ streams attached to each circuit.
+
+ This change, which extends an anti-DoS feature introduced in
+ 0.2.4.13-alpha and improved in 0.2.4.14-alpha, lets Tor exit relays
+ better resist more memory-based DoS attacks than before. Since the
+ MaxMemInCellQueues option now applies to all queues, it is renamed
+ to MaxMemInQueues. This feature fixes bug 10169.
+ - Avoid hash-flooding denial-of-service attacks by using the secure
+ SipHash-2-4 hash function for our hashtables. Without this
+ feature, an attacker could degrade performance of a targeted
+ client or server by flooding their data structures with a large
+ number of entries to be stored at the same hash table position,
+ thereby slowing down the Tor instance. With this feature, hash
+ table positions are derived from a randomized cryptographic key,
+ and an attacker cannot predict which entries will collide. Closes
+ ticket 4900.
+ - If you don't specify MaxMemInQueues yourself, Tor now tries to
+ pick a good value based on your total system memory. Previously,
+ the default was always 8 GB. You can still override the default by
+ setting MaxMemInQueues yourself. Resolves ticket 11396.
+
+ o Major features (bridges and pluggable transports):
+ - Add support for passing arguments to managed pluggable transport
+ proxies. Implements ticket 3594.
+ - Bridges now track GeoIP information and the number of their users
+ even when pluggable transports are in use, and report usage
+ statistics in their extra-info descriptors. Resolves tickets 4773
+ and 5040.
+ - Don't launch pluggable transport proxies if we don't have any
+ bridges configured that would use them. Now we can list many
+ pluggable transports, and Tor will dynamically start one when it
+ hears a bridge address that needs it. Resolves ticket 5018.
+ - The bridge directory authority now assigns status flags (Stable,
+ Guard, etc) to bridges based on thresholds calculated over all
+ Running bridges. Now bridgedb can finally make use of its features
+ to e.g. include at least one Stable bridge in its answers. Fixes
+ bug 9859.
+
+ o Major features (controller):
+ - Extend ORCONN controller event to include an "ID" parameter,
+ and add four new controller event types CONN_BW, CIRC_BW,
+ CELL_STATS, and TB_EMPTY that show connection and circuit usage.
+ The new events are emitted in private Tor networks only, with the
+ goal of being able to better track performance and load during
+ full-network simulations. Implements proposal 218 and ticket 7359.
+
+ o Major features (relay performance):
+ - Speed up server-side lookups of rendezvous and introduction point
+ circuits by using hashtables instead of linear searches. These
+ functions previously accounted between 3 and 7% of CPU usage on
+ some busy relays. Resolves ticket 9841.
+ - Avoid wasting CPU when extending a circuit over a channel that is
+ nearly out of circuit IDs. Previously, we would do a linear scan
+ over possible circuit IDs before finding one or deciding that we
+ had exhausted our possibilities. Now, we try at most 64 random
+ circuit IDs before deciding that we probably won't succeed. Fixes
+ a possible root cause of ticket 11553.
+
+ o Major features (seccomp2 sandbox, Linux only):
+ - Use the seccomp2 syscall filtering facility on Linux to limit
+ which system calls Tor can invoke. This is an experimental,
+ Linux-only feature to provide defense-in-depth against unknown
+ attacks. To try turning it on, set "Sandbox 1" in your torrc
+ file. Please be ready to report bugs. We hope to add support
+ for better sandboxing in the future, including more fine-grained
+ filters, better division of responsibility, and support for more
+ platforms. This work has been done by Cristian-Matei Toader for
+ Google Summer of Code. Resolves tickets 11351 and 11465.
+
+ o Major features (testing networks):
+ - Make testing Tor networks bootstrap better: lower directory fetch
+ retry schedules and maximum interval without directory requests,
+ and raise maximum download tries. Implements ticket 6752.
+ - Add make target 'test-network' to run tests on a Chutney network.
+ Implements ticket 8530.
+
+ o Major features (other):
+ - On some platforms (currently: recent OSX versions, glibc-based
+ platforms that support the ELF format, and a few other
+ Unix-like operating systems), Tor can now dump stack traces
+ when a crash occurs or an assertion fails. By default, traces
+ are dumped to stderr (if possible) and to any logs that are
+ reporting errors. Implements ticket 9299.
+
+ o Deprecated versions:
+ - Tor 0.2.3.x has reached end-of-life; it has received no patches or
+ attention for some while.
+
+ o Major bugfixes (security, directory authorities):
+ - Directory authorities now include a digest of each relay's
+ identity key as a part of its microdescriptor.
+
+ This is a workaround for bug 11743 (reported by "cypherpunks"),
+ where Tor clients do not support receiving multiple
+ microdescriptors with the same SHA256 digest in the same
+ consensus. When clients receive a consensus like this, they only
+ use one of the relays. Without this fix, a hostile relay could
+ selectively disable some client use of target relays by
+ constructing a router descriptor with a different identity and the
+ same microdescriptor parameters and getting the authorities to
+ list it in a microdescriptor consensus. This fix prevents an
+ attacker from causing a microdescriptor collision, because the
+ router's identity is not forgeable.
+
+ o Major bugfixes (openssl bug workaround):
+ - Avoid crashing when using OpenSSL version 0.9.8zc, 1.0.0o, or
+ 1.0.1j, built with the 'no-ssl3' configuration option. Fixes
+ bug 13471. This is a workaround for an OpenSSL bug.
+
+ o Major bugfixes (client):
+ - Perform circuit cleanup operations even when circuit
+ construction operations are disabled (because the network is
+ disabled, or because there isn't enough directory information).
+ Previously, when we were not building predictive circuits, we
+ were not closing expired circuits either. Fixes bug 8387; bugfix on
+ 0.1.1.11-alpha. This bug became visible in 0.2.4.10-alpha when we
+ became more strict about when we have "enough directory information
+ to build circuits".
+
+ o Major bugfixes (client, pluggable transports):
+ - When managing pluggable transports, use OS notification facilities
+ to learn if they have crashed, and don't attempt to kill any
+ process that has already exited. Fixes bug 8746; bugfix
+ on 0.2.3.6-alpha.
+
+ o Major bugfixes (relay denial of service):
+ - Instead of writing destroy cells directly to outgoing connection
+ buffers, queue them and intersperse them with other outgoing cells.
+ This can prevent a set of resource starvation conditions where too
+ many pending destroy cells prevent data cells from actually getting
+ delivered. Reported by "oftc_must_be_destroyed". Fixes bug 7912;
+ bugfix on 0.2.0.1-alpha.
+
+ o Major bugfixes (relay):
+ - Avoid queuing or sending destroy cells for circuit ID zero when we
+ fail to send a CREATE cell. Fixes bug 12848; bugfix on 0.0.8pre1.
+ Found and fixed by "cypherpunks".
+ - Fix ORPort reachability detection on relays running behind a
+ proxy, by correctly updating the "local" mark on the controlling
+ channel when changing the address of an or_connection_t after the
+ handshake. Fixes bug 12160; bugfix on 0.2.4.4-alpha.
+ - Use a direct dirport connection when uploading non-anonymous
+ descriptors to the directory authorities. Previously, relays would
+ incorrectly use tunnel connections under a fairly wide variety of
+ circumstances. Fixes bug 11469; bugfix on 0.2.4.3-alpha.
+ - When a circuit accidentally has the same circuit ID for its
+ forward and reverse direction, correctly detect the direction of
+ cells using that circuit. Previously, this bug made roughly one
+ circuit in a million non-functional. Fixes bug 12195; this is a
+ bugfix on every version of Tor.
+
+ o Minor features (security):
+ - New --enable-expensive-hardening option to enable security
+ hardening options that consume nontrivial amounts of CPU and
+ memory. Right now, this includes AddressSanitizer and UbSan, which
+ are supported in newer versions of GCC and Clang. Closes ticket
+ 11477.
+ - Authorities now assign the Guard flag to the fastest 25% of the
+ network (it used to be the fastest 50%). Also raise the consensus
+ weight that guarantees the Guard flag from 250 to 2000. For the
+ current network, this results in about 1100 guards, down from 2500.
+ This step paves the way for moving the number of entry guards
+ down to 1 (proposal 236) while still providing reasonable expected
+ performance for most users. Implements ticket 12690.
+
+ o Minor features (security, memory management):
+ - Memory allocation tricks (mempools and buffer freelists) are now
+ disabled by default. You can turn them back on with
+ --enable-mempools and --enable-buf-freelists respectively. We're
+ disabling these features because malloc performance is good enough
+ on most platforms, and a similar feature in OpenSSL exacerbated
+ exploitation of the Heartbleed attack. Resolves ticket 11476.
+
+ o Minor features (bridge client):
+ - Report a more useful failure message when we can't connect to a
+ bridge because we don't have the right pluggable transport
+ configured. Resolves ticket 9665. Patch from Fábio J. Bertinatto.
+
+ o Minor features (bridge):
+ - Add an ExtORPortCookieAuthFileGroupReadable option to make the
+ cookie file for the ExtORPort g+r by default.
+
+ o Minor features (bridges, pluggable transports):
+ - Bridges now write the SHA1 digest of their identity key
+ fingerprint (that is, a hash of a hash of their public key) to
+ notice-level logs, and to a new hashed-fingerprint file. This
+ information will help bridge operators look up their bridge in
+ Globe and similar tools. Resolves ticket 10884.
+ - Improve the message that Tor displays when running as a bridge
+ using pluggable transports without an Extended ORPort listener.
+ Also, log the message in the log file too. Resolves ticket 11043.
+ - Add threshold cutoffs to the networkstatus document created by
+ the Bridge Authority. Fixes bug 1117.
+ - On Windows, spawn background processes using the CREATE_NO_WINDOW
+ flag. Now Tor Browser Bundle 3.5 with pluggable transports enabled
+ doesn't pop up a blank console window. (In Tor Browser Bundle 2.x,
+ Vidalia set this option for us.) Implements ticket 10297.
+
+ o Minor features (build):
+ - The configure script has a --disable-seccomp option to turn off
+ support for libseccomp on systems that have it, in case it (or
+ Tor's use of it) is broken. Resolves ticket 11628.
+ - Assume that a user using ./configure --host wants to cross-compile,
+ and give an error if we cannot find a properly named
+ tool-chain. Add a --disable-tool-name-check option to proceed
+ nevertheless. Addresses ticket 9869. Patch by Benedikt Gollatz.
+ - If we run ./configure and the compiler recognizes -fstack-protector
+ but the linker rejects it, warn the user about a potentially missing
+ libssp package. Addresses ticket 9948. Patch from Benedikt Gollatz.
+ - Add support for `--library-versions` flag. Implements ticket 6384.
+ - Return the "unexpected sendme" warnings to a warn severity, but make
+ them rate limited, to help diagnose ticket 8093.
+ - Detect a missing asciidoc, and warn the user about it, during
+ configure rather than at build time. Fixes issue 6506. Patch from
+ Arlo Breault.
+
+ o Minor features (client):
+ - Add a new option, PredictedPortsRelevanceTime, to control how long
+ after having received a request to connect to a given port Tor
+ will try to keep circuits ready in anticipation of future requests
+ for that port. Patch from "unixninja92"; implements ticket 9176.
+
+ o Minor features (config options and command line):
+ - Add an --allow-missing-torrc commandline option that tells Tor to
+ run even if the configuration file specified by -f is not available.
+ Implements ticket 10060.
+ - Add support for the TPROXY transparent proxying facility on Linux.
+ See documentation for the new TransProxyType option for more
+ details. Implementation by "thomo". Closes ticket 10582.
+
+ o Minor features (config options):
+ - Config (torrc) lines now handle fingerprints which are missing
+ their initial '$'. Resolves ticket 4341; improvement over 0.0.9pre5.
+ - Support a --dump-config option to print some or all of the
+ configured options. Mainly useful for debugging the command-line
+ option parsing code. Helps resolve ticket 4647.
+ - Raise awareness of safer logging: notify user of potentially
+ unsafe config options, like logging more verbosely than severity
+ "notice" or setting SafeLogging to 0. Resolves ticket 5584.
+ - Add a new configuration option TestingV3AuthVotingStartOffset
+ that bootstraps a network faster by changing the timing for
+ consensus votes. Addresses ticket 8532.
+ - Add a new torrc option "ServerTransportOptions" that allows
+ bridge operators to pass configuration parameters to their
+ pluggable transports. Resolves ticket 8929.
+ - The config (torrc) file now accepts bandwidth and space limits in
+ bits as well as bytes. (Anywhere that you can say "2 Kilobytes",
+ you can now say "16 kilobits", and so on.) Resolves ticket 9214.
+ Patch by CharlieB.
+
+ o Minor features (controller):
+ - Make the entire exit policy available from the control port via
+ GETINFO exit-policy/*. Implements enhancement 7952. Patch from
+ "rl1987".
+ - Because of the fix for ticket 11396, the real limit for memory
+ usage may no longer match the configured MaxMemInQueues value. The
+ real limit is now exposed via GETINFO limits/max-mem-in-queues.
+ - Add a new "HS_DESC" controller event that reports activities
+ related to hidden service descriptors. Resolves ticket 8510.
+ - New "DROPGUARDS" controller command to forget all current entry
+ guards. Not recommended for ordinary use, since replacing guards
+ too frequently makes several attacks easier. Resolves ticket 9934;
+ patch from "ra".
+ - Implement the TRANSPORT_LAUNCHED control port event that
+ notifies controllers about new launched pluggable
+ transports. Resolves ticket 5609.
+
+ o Minor features (diagnostic):
+ - When logging a warning because of bug 7164, additionally check the
+ hash table for consistency (as proposed on ticket 11737). This may
+ help diagnose bug 7164.
+ - When we log a heartbeat, log how many one-hop circuits we have
+ that are at least 30 minutes old, and log status information about
+ a few of them. This is an attempt to track down bug 8387.
+ - When encountering an unexpected CR while writing text to a file on
+ Windows, log the name of the file. Should help diagnosing
+ bug 11233.
+ - Give more specific warnings when a client notices that an onion
+ handshake has failed. Fixes ticket 9635.
+ - Add significant new logging code to attempt to diagnose bug 12184,
+ where relays seem to run out of available circuit IDs.
+ - Improve the diagnostic log message for bug 8387 even further to
+ try to improve our odds of figuring out why one-hop directory
+ circuits sometimes do not get closed.
+ - Add more log messages to diagnose bug 7164, which causes
+ intermittent "microdesc_free() called but md was still referenced"
+ warnings. We now include more information, to figure out why we
+ might be cleaning a microdescriptor for being too old if it's
+ still referenced by a live node_t object.
+ - Log current accounting state (bytes sent and received + remaining
+ time for the current accounting period) in the relay's heartbeat
+ message. Implements ticket 5526; patch from Peter Retzlaff.
+
+ o Minor features (geoip):
+ - Update geoip and geoip6 to the August 7 2014 Maxmind GeoLite2
+ Country database.
+
+ o Minor features (interface):
+ - Generate a warning if any ports are listed in the SocksPolicy,
+ DirPolicy, AuthDirReject, AuthDirInvalid, AuthDirBadDir, or
+ AuthDirBadExit options. (These options only support address
+ ranges.) Fixes part of ticket 11108.
+
+ o Minor features (kernel API usage):
+ - Use the SOCK_NONBLOCK socket type, if supported, to open nonblocking
+ sockets in a single system call. Implements ticket 5129.
+
+ o Minor features (log messages):
+ - When ServerTransportPlugin is set on a bridge, Tor can write more
+ useful statistics about bridge use in its extrainfo descriptors,
+ but only if the Extended ORPort ("ExtORPort") is set too. Add a
+ log message to inform the user in this case. Resolves ticket 9651.
+ - When receiving a new controller connection, log the origin address.
+ Resolves ticket 9698; patch from "sigpipe".
+ - When logging OpenSSL engine status at startup, log the status of
+ more engines. Fixes ticket 10043; patch from Joshua Datko.
+
+ o Minor features (log verbosity):
+ - Demote the message that we give when a flushing connection times
+ out for too long from NOTICE to INFO. It was usually meaningless.
+ Resolves ticket 5286.
+ - Don't log so many notice-level bootstrapping messages at startup
+ about downloading descriptors. Previously, we'd log a notice
+ whenever we learned about more routers. Now, we only log a notice
+ at every 5% of progress. Fixes bug 9963.
+ - Warn less verbosely when receiving a malformed
+ ESTABLISH_RENDEZVOUS cell. Fixes ticket 11279.
+
+ o Minor features (performance):
+ - If we're using the pure-C 32-bit curve25519_donna implementation
+ of curve25519, build it with the -fomit-frame-pointer option to
+ make it go faster on register-starved hosts. This improves our
+ handshake performance by about 6% on i386 hosts without nacl.
+ Closes ticket 8109.
+
+ o Minor features (relay):
+ - If a circuit timed out for at least 3 minutes, check if we have a
+ new external IP address, and publish a new descriptor with the new
+ IP address if it changed. Resolves ticket 2454.
+
+ o Minor features (testing):
+ - If Python is installed, "make check" now runs extra tests beyond
+ the unit test scripts.
+ - When bootstrapping a test network, sometimes very few relays get
+ the Guard flag. Now a new option "TestingDirAuthVoteGuard" can
+ specify a set of relays which should be voted Guard regardless of
+ their uptime or bandwidth. Addresses ticket 9206.
+
+ o Minor features (transparent proxy, *BSD):
+ - Support FreeBSD's ipfw firewall interface for TransPort ports on
+ FreeBSD. To enable it, set "TransProxyType ipfw". Resolves ticket
+ 10267; patch from "yurivict".
+ - Support OpenBSD's divert-to rules with the pf firewall for
+ transparent proxy ports. To enable it, set "TransProxyType
+ pf-divert". This allows Tor to run a TransPort transparent proxy
+ port on OpenBSD 4.4 or later without root privileges. See the
+ pf.conf(5) manual page for information on configuring pf to use
+ divert-to rules. Closes ticket 10896; patch from Dana Koch.
+
+ o Minor bugfixes (bridge client):
+ - Stop accepting bridge lines containing hostnames. Doing so would
+ cause clients to perform DNS requests on the hostnames, which was
+ not sensible behavior. Fixes bug 10801; bugfix on 0.2.0.1-alpha.
+
+ o Minor bugfixes (bridges):
+ - Avoid potential crashes or bad behavior when launching a
+ server-side managed proxy with ORPort or ExtORPort temporarily
+ disabled. Fixes bug 9650; bugfix on 0.2.3.16-alpha.
+ - Fix a bug where the first connection works to a bridge that uses a
+ pluggable transport with client-side parameters, but we don't send
+ the client-side parameters on subsequent connections. (We don't
+ use any pluggable transports with client-side parameters yet,
+ but ScrambleSuit will soon become the first one.) Fixes bug 9162;
+ bugfix on 0.2.0.3-alpha. Based on a patch from "rl1987".
+
+ o Minor bugfixes (build, auxiliary programs):
+ - Stop preprocessing the "torify" script with autoconf, since
+ it no longer refers to LOCALSTATEDIR. Fixes bug 5505; patch
+ from Guilhem.
+ - The tor-fw-helper program now follows the standard convention and
+ exits with status code "0" on success. Fixes bug 9030; bugfix on
+ 0.2.3.1-alpha. Patch by Arlo Breault.
+ - Corrected ./configure advice for what openssl dev package you should
+ install on Debian. Fixes bug 9207; bugfix on 0.2.0.1-alpha.
+
+ o Minor bugfixes (client):
+ - Avoid "Tried to open a socket with DisableNetwork set" warnings
+ when starting a client with bridges configured and DisableNetwork
+ set. (Tor launcher starts Tor with DisableNetwork set the first
+ time it runs.) Fixes bug 10405; bugfix on 0.2.3.9-alpha.
+ - Improve the log message when we can't connect to a hidden service
+ because all of the hidden service directory nodes hosting its
+ descriptor are excluded. Improves on our fix for bug 10722, which
+ was a bugfix on 0.2.0.10-alpha.
+ - Raise a control port warning when we fail to connect to all of
+ our bridges. Previously, we didn't inform the controller, and
+ the bootstrap process would stall. Fixes bug 11069; bugfix on
+ 0.2.1.2-alpha.
+ - Exit immediately when a process-owning controller exits.
+ Previously, tor relays would wait for a little while after their
+ controller exited, as if they had gotten an INT signal -- but this
+ was problematic, since there was no feedback for the user. To do a
+ clean shutdown, controllers should send an INT signal and give Tor
+ a chance to clean up. Fixes bug 10449; bugfix on 0.2.2.28-beta.
+ - Stop attempting to connect to bridges before our pluggable
+ transports are configured (harmless but resulted in some erroneous
+ log messages). Fixes bug 11156; bugfix on 0.2.3.2-alpha.
+ - Fix connections to IPv6 addresses over SOCKS5. Previously, we were
+ generating incorrect SOCKS5 responses, and confusing client
+ applications. Fixes bug 10987; bugfix on 0.2.4.7-alpha.
+
+ o Minor bugfixes (client, DNSPort):
+ - When using DNSPort, try to respond to AAAA requests with AAAA
+ answers. Previously, we hadn't looked at the request type when
+ deciding which answer type to prefer. Fixes bug 10468; bugfix on
+ 0.2.4.7-alpha.
+ - When receiving a DNS query for an unsupported record type, reply
+ with no answer rather than with a NOTIMPL error. This behavior
+ isn't correct either, but it will break fewer client programs, we
+ hope. Fixes bug 10268; bugfix on 0.2.0.1-alpha. Original patch
+ from "epoch".
+
+ o Minor bugfixes (client, logging during bootstrap):
+ - Only report the first fatal bootstrap error on a given OR
+ connection. This stops us from telling the controller bogus error
+ messages like "DONE". Fixes bug 10431; bugfix on 0.2.1.1-alpha.
+ - Avoid generating spurious warnings when starting with
+ DisableNetwork enabled. Fixes bug 11200 and bug 10405; bugfix on
+ 0.2.3.9-alpha.
+
+ o Minor bugfixes (closing OR connections):
+ - If write_to_buf() in connection_write_to_buf_impl_() ever fails,
+ check if it's an or_connection_t and correctly call
+ connection_or_close_for_error() rather than
+ connection_mark_for_close() directly. Fixes bug 11304; bugfix on
+ 0.2.4.4-alpha.
+ - When closing all connections on setting DisableNetwork to 1, use
+ connection_or_close_normally() rather than closing OR connections
+ out from under the channel layer. Fixes bug 11306; bugfix on
+ 0.2.4.4-alpha.
+
+ o Minor bugfixes (code correctness):
+ - Previously we used two temporary files when writing descriptors to
+ disk; now we only use one. Fixes bug 1376.
+ - Remove an erroneous (but impossible and thus harmless) pointer
+ comparison that would have allowed compilers to skip a bounds
+ check in channeltls.c. Fixes bugs 10313 and 9980; bugfix on
+ 0.2.0.10-alpha. Noticed by Jared L Wong and David Fifield.
+ - Fix an always-true assertion in pluggable transports code so it
+ actually checks what it was trying to check. Fixes bug 10046;
+ bugfix on 0.2.3.9-alpha. Found by "dcb".
+
+ o Minor bugfixes (command line):
+ - Use a single command-line parser for parsing torrc options on the
+ command line and for finding special command-line options to avoid
+ inconsistent behavior for torrc option arguments that have the same
+ names as command-line options. Fixes bugs 4647 and 9578; bugfix on
+ 0.0.9pre5.
+ - No longer allow 'tor --hash-password' with no arguments. Fixes bug
+ 9573; bugfix on 0.0.9pre5.
+
+ o Minor bugfixes (compilation):
+ - Compile correctly with builds and forks of OpenSSL (such as
+ LibreSSL) that disable compression. Fixes bug 12602; bugfix on
+ 0.2.1.1-alpha. Patch from "dhill".
+ - Restore the ability to compile Tor with V2_HANDSHAKE_SERVER
+ turned off (that is, without support for v2 link handshakes). Fixes
+ bug 4677; bugfix on 0.2.3.2-alpha. Patch from "piet".
+ - In routerlist_assert_ok(), don't take the address of a
+ routerinfo's cache_info member unless that routerinfo is non-NULL.
+ Fixes bug 13096; bugfix on 0.1.1.9-alpha. Patch by "teor".
+ - Fix a large number of false positive warnings from the clang
+ analyzer static analysis tool. This should make real warnings
+ easier for clang analyzer to find. Patch from "teor". Closes
+ ticket 13036.
+ - Resolve GCC complaints on OpenBSD about discarding constness in
+ TO_{ORIGIN,OR}_CIRCUIT functions. Fixes part of bug 11633; bugfix
+ on 0.1.1.23. Patch from Dana Koch.
+ - Resolve clang complaints on OpenBSD with -Wshorten-64-to-32 due to
+ treatment of long and time_t as comparable types. Fixes part of
+ bug 11633. Patch from Dana Koch.
+ - When deciding whether to build the 64-bit curve25519
+ implementation, detect platforms where we can compile 128-bit
+ arithmetic but cannot link it. Fixes bug 11729; bugfix on
+ 0.2.4.8-alpha. Patch from "conradev".
+ - Fix compilation when DNS_CACHE_DEBUG is enabled. Fixes bug 11761;
+ bugfix on 0.2.3.13-alpha. Found by "cypherpunks".
+ - Fix compilation with dmalloc. Fixes bug 11605; bugfix
+ on 0.2.4.10-alpha.
+ - Build and run correctly on systems like OpenBSD-current that have
+ patched OpenSSL to remove get_cipher_by_char and/or its
+ implementations. Fixes issue 13325.
+
+ o Minor bugfixes (controller and command-line):
+ - If changing a config option via "setconf" fails in a recoverable
+ way, we used to nonetheless write our new control ports to the
+ file described by the "ControlPortWriteToFile" option. Now we only
+ write out that file if we successfully switch to the new config
+ option. Fixes bug 5605; bugfix on 0.2.2.26-beta. Patch from "Ryman".
+
+ o Minor bugfixes (directory server):
+ - No longer accept malformed http headers when parsing urls from
+ headers. Now we reply with Bad Request ("400"). Fixes bug 2767;
+ bugfix on 0.0.6pre1.
+ - When sending a compressed set of descriptors or microdescriptors,
+ make sure to finalize the zlib stream. Previously, we would write
+ all the compressed data, but if the last descriptor we wanted to
+ send was missing or too old, we would not mark the stream as
+ finished. This caused problems for decompression tools. Fixes bug
+ 11648; bugfix on 0.1.1.23.
+
+ o Minor bugfixes (hidden service):
+ - Only retry attempts to connect to a chosen rendezvous point 8
+ times, not 30. Fixes bug 4241; bugfix on 0.1.0.1-rc.
+
+ o Minor bugfixes (interface):
+ - Reject relative control socket paths and emit a warning. Previously,
+ single-component control socket paths would be rejected, but Tor
+ would not log why it could not validate the config. Fixes bug 9258;
+ bugfix on 0.2.3.16-alpha.
+
+ o Minor bugfixes (log messages):
+ - Fix a bug where clients using bridges would report themselves
+ as 50% bootstrapped even without a live consensus document.
+ Fixes bug 9922; bugfix on 0.2.1.1-alpha.
+ - Suppress a warning where, if there's only one directory authority
+ in the network, we would complain that votes and signatures cannot
+ be uploaded to other directory authorities. Fixes bug 10842;
+ bugfix on 0.2.2.26-beta.
+ - Report bootstrapping progress correctly when we're downloading
+ microdescriptors. We had updated our "do we have enough microdescs
+ to begin building circuits?" logic most recently in 0.2.4.10-alpha
+ (see bug 5956), but we left the bootstrap status event logic at
+ "how far through getting 1/4 of them are we?" Fixes bug 9958;
+ bugfix on 0.2.2.36, which is where they diverged (see bug 5343).
+
+ o Minor bugfixes (logging):
+ - Downgrade "Unexpected onionskin length after decryption" warning
+ to a protocol-warn, since there's nothing relay operators can do
+ about a client that sends them a malformed create cell. Resolves
+ bug 12996; bugfix on 0.0.6rc1.
+ - Log more specific warnings when we get an ESTABLISH_RENDEZVOUS
+ cell on a cannibalized or non-OR circuit. Resolves ticket 12997.
+ - When logging information about an EXTEND2 or EXTENDED2 cell, log
+ their names correctly. Fixes part of bug 12700; bugfix
+ on 0.2.4.8-alpha.
+ - When logging information about a relay cell whose command we don't
+ recognize, log its command as an integer. Fixes part of bug 12700;
+ bugfix on 0.2.1.10-alpha.
+ - Escape all strings from the directory connection before logging
+ them. Fixes bug 13071; bugfix on 0.1.1.15. Patch from "teor".
+ - Squelch a spurious LD_BUG message "No origin circuit for
+ successful SOCKS stream" in certain hidden service failure cases;
+ fixes bug 10616.
+ - Downgrade the severity of the 'unexpected sendme cell from client'
+ from 'warn' to 'protocol warning'. Closes ticket 8093.
+
+ o Minor bugfixes (misc code correctness):
+ - In munge_extrainfo_into_routerinfo(), check the return value of
+ memchr(). This would have been a serious issue if we ever passed
+ it a non-extrainfo. Fixes bug 8791; bugfix on 0.2.0.6-alpha. Patch
+ from Arlo Breault.
+ - On the chance that somebody manages to build Tor on a
+ platform where time_t is unsigned, correct the way that
+ microdesc_add_to_cache() handles negative time arguments.
+ Fixes bug 8042; bugfix on 0.2.3.1-alpha.
+ - Fix various instances of undefined behavior in channeltls.c,
+ tor_memmem(), and eventdns.c that would cause us to construct
+ pointers to memory outside an allocated object. (These invalid
+ pointers were not accessed, but C does not even allow them to
+ exist.) Fixes bug 10363; bugfixes on 0.1.1.1-alpha, 0.1.2.1-alpha,
+ 0.2.0.10-alpha, and 0.2.3.6-alpha. Reported by "bobnomnom".
+ - Use the AddressSanitizer and Ubsan sanitizers (in clang-3.4) to
+ fix some miscellaneous errors in our tests and codebase. Fixes bug
+ 11232. Bugfixes on versions back as far as 0.2.1.11-alpha.
+ - Always check return values for unlink, munmap, UnmapViewOfFile;
+ check strftime return values more often. In some cases all we can
+ do is report a warning, but this may help prevent deeper bugs from
+ going unnoticed. Closes ticket 8787; bugfixes on many, many tor
+ versions.
+ - Fix numerous warnings from the clang "scan-build" static analyzer.
+ Some of these are programming style issues; some of them are false
+ positives that indicated awkward code; some are undefined behavior
+ cases related to constructing (but not using) invalid pointers;
+ some are assumptions about API behavior; some are (harmlessly)
+ logging sizeof(ptr) bytes from a token when sizeof(*ptr) would be
+ correct; and one or two are genuine bugs that weren't reachable
+ from the rest of the program. Fixes bug 8793; bugfixes on many,
+ many tor versions.
+
+ o Minor bugfixes (node selection):
+ - If ExcludeNodes is set, consider non-excluded hidden service
+ directory servers before excluded ones. Do not consider excluded
+ hidden service directory servers at all if StrictNodes is
+ set. (Previously, we would sometimes decide to connect to those
+ servers, and then realize before we initiated a connection that
+ we had excluded them.) Fixes bug 10722; bugfix on 0.2.0.10-alpha.
+ Reported by "mr-4".
+ - If we set the ExitNodes option but it doesn't include any nodes
+ that have the Exit flag, we would choose not to bootstrap. Now we
+ bootstrap so long as ExitNodes includes nodes which can exit to
+ some port. Fixes bug 10543; bugfix on 0.2.4.10-alpha.
+
+ o Minor bugfixes (performance):
+ - Avoid a bug where every successful connection made us recompute
+ the flag telling us whether we have sufficient information to
+ build circuits. Previously, we would forget our cached value
+ whenever we successfully opened a channel (or marked a router as
+ running or not running for any other reason), regardless of
+ whether we had previously believed the router to be running. This
+ forced us to run an expensive update operation far too often.
+ Fixes bug 12170; bugfix on 0.1.2.1-alpha.
+ - Avoid using tor_memeq() for checking relay cell integrity. This
+ removes a possible performance bottleneck. Fixes part of bug
+ 12169; bugfix on 0.2.1.31.
+
+ o Minor bugfixes (platform-specific):
+ - When dumping a malformed directory object to disk, save it in
+ binary mode on Windows, not text mode. Fixes bug 11342; bugfix on
+ 0.2.2.1-alpha.
+ - Don't report failures from make_socket_reuseable() on incoming
+ sockets on OSX: this can happen when incoming connections close
+ early. Fixes bug 10081.
+
+ o Minor bugfixes (pluggable transports):
+ - Avoid another 60-second delay when starting Tor in a pluggable-
+ transport-using configuration when we already have cached
+ descriptors for our bridges. Fixes bug 11965; bugfix
+ on 0.2.3.6-alpha.
+
+ o Minor bugfixes (protocol correctness):
+ - When receiving a VERSIONS cell with an odd number of bytes, close
+ the connection immediately since the cell is malformed. Fixes bug
+ 10365; bugfix on 0.2.0.10-alpha. Spotted by "bobnomnom"; fix by
+ "rl1987".
+
+ o Minor bugfixes (relay, other):
+ - We now drop CREATE cells for already-existent circuit IDs and for
+ zero-valued circuit IDs, regardless of other factors that might
+ otherwise have called for DESTROY cells. Fixes bug 12191; bugfix
+ on 0.0.8pre1.
+ - When rejecting DATA cells for stream_id zero, still count them
+ against the circuit's deliver window so that we don't fail to send
+ a SENDME. Fixes bug 11246; bugfix on 0.2.4.10-alpha.
+
+ o Minor bugfixes (relay, threading):
+ - Check return code on spawn_func() in cpuworker code, so that we
+ don't think we've spawned a nonworking cpuworker and write junk to
+ it forever. Fix related to bug 4345; bugfix on all released Tor
+ versions. Found by "skruffy".
+ - Use a pthread_attr to make sure that spawn_func() cannot return an
+ error while at the same time launching a thread. Fix related to
+ bug 4345; bugfix on all released Tor versions. Reported
+ by "cypherpunks".
+
+ o Minor bugfixes (relays and bridges):
+ - Avoid crashing on a malformed resolv.conf file when running a
+ relay using Libevent 1. Fixes bug 8788; bugfix on 0.1.1.23.
+ - Non-exit relays no longer launch mock DNS requests to check for
+ DNS hijacking. This has been unnecessary since 0.2.1.7-alpha, when
+ non-exit relays stopped servicing DNS requests. Fixes bug 965;
+ bugfix on 0.2.1.7-alpha. Patch from Matt Pagan.
+ - Bridges now report complete directory request statistics. Related
+ to bug 5824; bugfix on 0.2.2.1-alpha.
+ - Bridges now never collect statistics that were designed for
+ relays. Fixes bug 5824; bugfix on 0.2.3.8-alpha.
+
+ o Minor bugfixes (testing):
+ - Fix all valgrind warnings produced by the unit tests. There were
+ over a thousand memory leak warnings previously, mostly produced
+ by forgetting to free things in the unit test code. Fixes bug
+ 11618, bugfixes on many versions of Tor.
+
+ o Minor bugfixes (tor-fw-helper):
+ - Give a correct log message when tor-fw-helper fails to launch.
+ (Previously, we would say something like "tor-fw-helper sent us a
+ string we could not parse".) Fixes bug 9781; bugfix
+ on 0.2.4.2-alpha.
+
+ o Minor bugfixes (trivial memory leaks):
+ - Fix a small memory leak when signing a directory object. Fixes bug
+ 11275; bugfix on 0.2.4.13-alpha.
+ - Resolve some memory leaks found by coverity in the unit tests, on
+ exit in tor-gencert, and on a failure to compute digests for our
+ own keys when generating a v3 networkstatus vote. These leaks
+ should never have affected anyone in practice.
+
+ o Code simplification and refactoring:
+ - Remove some old fallback code designed to keep Tor clients working
+ in a network with only two working relays. Elsewhere in the code we
+ have long since stopped supporting such networks, so there wasn't
+ much point in keeping it around. Addresses ticket 9926.
+ - Reject 0-length EXTEND2 cells more explicitly. Fixes bug 10536;
+ bugfix on 0.2.4.8-alpha. Reported by "cypherpunks".
+ - Extract the common duplicated code for creating a subdirectory
+ of the data directory and writing to a file in it. Fixes ticket
+ 4282; patch from Peter Retzlaff.
+ - Since OpenSSL 0.9.7, the i2d_*() functions support allocating output
+ buffer. Avoid calling twice: i2d_RSAPublicKey(), i2d_DHparams(),
+ i2d_X509(), and i2d_PublicKey(). Resolves ticket 5170.
+ - Add a set of accessor functions for the circuit timeout data
+ structure. Fixes ticket 6153; patch from "piet".
+ - Clean up exit paths from connection_listener_new(). Closes ticket
+ 8789. Patch from Arlo Breault.
+ - Since we rely on OpenSSL 0.9.8 now, we can use EVP_PKEY_cmp()
+ and drop our own custom pkey_eq() implementation. Fixes bug 9043.
+ - Use a doubly-linked list to implement the global circuit list.
+ Resolves ticket 9108. Patch from Marek Majkowski.
+ - Remove contrib/id_to_fp.c since it wasn't used anywhere.
+ - Remove constants and tests for PKCS1 padding; it's insecure and
+ shouldn't be used for anything new. Fixes bug 8792; patch
+ from Arlo Breault.
+ - Remove instances of strcpy() from the unit tests. They weren't
+ hurting anything, since they were only in the unit tests, but it's
+ embarassing to have strcpy() in the code at all, and some analysis
+ tools don't like it. Fixes bug 8790; bugfix on 0.2.3.6-alpha and
+ 0.2.3.8-alpha. Patch from Arlo Breault.
+ - Remove is_internal_IP() function. Resolves ticket 4645.
+ - Remove unused function circuit_dump_by_chan from circuitlist.c.
+ Closes issue 9107; patch from "marek".
+ - Change our use of the ENUM_BF macro to avoid declarations that
+ confuse Doxygen.
+ - Get rid of router->address, since in all cases it was just the
+ string representation of router->addr. Resolves ticket 5528.
+
+ o Documentation:
+ - Adjust the URLs in the README to refer to the new locations of
+ several documents on the website. Fixes bug 12830. Patch from
+ Matt Pagan.
+ - Document 'reject6' and 'accept6' ExitPolicy entries. Resolves
+ ticket 12878.
+ - Update manpage to describe some of the files you can expect to
+ find in Tor's DataDirectory. Addresses ticket 9839.
+ - Clean up several option names in the manpage to match their real
+ names, add the missing documentation for a couple of testing and
+ directory authority options, remove the documentation for a
+ V2-directory fetching option that no longer exists. Resolves
+ ticket 11634.
+ - Correct the documenation so that it lists the correct directory
+ for the stats files. (They are in a subdirectory called "stats",
+ not "status".)
+ - In the manpage, move more authority-only options into the
+ directory authority section so that operators of regular directory
+ caches don't get confused.
+ - Fix the layout of the SOCKSPort flags in the manpage. Fixes bug
+ 11061; bugfix on 0.2.4.7-alpha.
+ - Resolve warnings from Doxygen.
+ - Document in the manpage that "KBytes" may also be written as
+ "kilobytes" or "KB", that "Kbits" may also be written as
+ "kilobits", and so forth. Closes ticket 9222.
+ - Document that the ClientOnly config option overrides ORPort.
+ Our old explanation made ClientOnly sound as though it did
+ nothing at all. Resolves bug 9059.
+ - Explain that SocksPolicy, DirPolicy, and similar options don't
+ take port arguments. Fixes the other part of ticket 11108.
+ - Fix a comment about the rend_server_descriptor_t.protocols field
+ to more accurately describe its range. Also, make that field
+ unsigned, to more accurately reflect its usage. Fixes bug 9099;
+ bugfix on 0.2.1.5-alpha.
+ - Fix the manpage's description of HiddenServiceAuthorizeClient:
+ the maximum client name length is 16, not 19. Fixes bug 11118;
+ bugfix on 0.2.1.6-alpha.
+
+ o Package cleanup:
+ - The contrib directory has been sorted and tidied. Before, it was
+ an unsorted dumping ground for useful and not-so-useful things.
+ Now, it is divided based on functionality, and the items which
+ seemed to be nonfunctional or useless have been removed. Resolves
+ ticket 8966; based on patches from "rl1987".
+
+ o Removed code and features:
+ - Clients now reject any directory authority certificates lacking
+ a dir-key-crosscert element. These have been included since
+ 0.2.1.9-alpha, so there's no real reason for them to be optional
+ any longer. Completes proposal 157. Resolves ticket 10162.
+ - Remove all code that existed to support the v2 directory system,
+ since there are no longer any v2 directory authorities. Resolves
+ ticket 10758.
+ - Remove the HSAuthoritativeDir and AlternateHSAuthority torrc
+ options, which were used for designating authorities as "Hidden
+ service authorities". There has been no use of hidden service
+ authorities since 0.2.2.1-alpha, when we stopped uploading or
+ downloading v0 hidden service descriptors. Fixes bug 10881; also
+ part of a fix for bug 10841.
+ - Remove /tor/dbg-stability.txt URL that was meant to help debug WFU
+ and MTBF calculations, but that nobody was using. Fixes bug 11742.
+ - The TunnelDirConns and PreferTunnelledDirConns options no longer
+ exist; tunneled directory connections have been available since
+ 0.1.2.5-alpha, and turning them off is not a good idea. This is a
+ brute-force fix for 10849, where "TunnelDirConns 0" would break
+ hidden services.
+ - Remove all code for the long unused v1 directory protocol.
+ Resolves ticket 11070.
+ - Remove all remaining code related to version-0 hidden service
+ descriptors: they have not been in use since 0.2.2.1-alpha. Fixes
+ the rest of bug 10841.
+ - Remove migration code from when we renamed the "cached-routers"
+ file to "cached-descriptors" back in 0.2.0.8-alpha. This
+ incidentally resolves ticket 6502 by cleaning up the related code
+ a bit. Patch from Akshay Hebbar.
+
+ o Test infrastructure:
+ - Tor now builds each source file in two modes: a mode that avoids
+ exposing identifiers needlessly, and another mode that exposes
+ more identifiers for testing. This lets the compiler do better at
+ optimizing the production code, while enabling us to take more
+ radical measures to let the unit tests test things.
+ - The production builds no longer include functions used only in
+ the unit tests; all functions exposed from a module only for
+ unit-testing are now static in production builds.
+ - Add an --enable-coverage configuration option to make the unit
+ tests (and a new src/or/tor-cov target) to build with gcov test
+ coverage support.
+ - Update to the latest version of tinytest.
+ - Improve the tinytest implementation of string operation tests so
+ that comparisons with NULL strings no longer crash the tests; they
+ now just fail, normally. Fixes bug 9004; bugfix on 0.2.2.4-alpha.
+ - New macros in test.h to simplify writing mock-functions for unit
+ tests. Part of ticket 11507. Patch from Dana Koch.
+ - We now have rudimentary function mocking support that our unit
+ tests can use to test functions in isolation. Function mocking
+ lets the tests temporarily replace a function's dependencies with
+ stub functions, so that the tests can check the function without
+ invoking the other functions it calls.
+
+ o Testing:
+ - Complete tests for the status.c module. Resolves ticket 11507.
+ Patch from Dana Koch.
+ - Add more unit tests for the <circid,channel>->circuit map, and
+ the destroy-cell-tracking code to fix bug 7912.
+ - Unit tests for failing cases of the TAP onion handshake.
+ - More unit tests for address-manipulation functions.
+
+ o Distribution (systemd):
+ - Include a tor.service file in contrib/dist for use with systemd.
+ Some distributions will be able to use this file unmodified;
+ others will need to tweak it, or write their own. Patch from Jamie
+ Nguyen; resolves ticket 8368.
+ - Verify configuration file via ExecStartPre in the systemd unit
+ file. Patch from intrigeri; resolves ticket 12730.
+ - Explicitly disable RunAsDaemon in the systemd unit file. Our
+ current systemd unit uses "Type = simple", so systemd does not
+ expect tor to fork. If the user has "RunAsDaemon 1" in their
+ torrc, then things won't work as expected. This is e.g. the case
+ on Debian (and derivatives), since there we pass "--defaults-torrc
+ /usr/share/tor/tor-service-defaults-torrc" (that contains
+ "RunAsDaemon 1") by default. Patch by intrigeri; resolves
+ ticket 12731.
+
+
+Changes in version 0.2.4.25 - 2014-10-20
+ Tor 0.2.4.25 disables SSL3 in response to the recent "POODLE" attack
+ (even though POODLE does not affect Tor). It also works around a crash
+ bug caused by some operating systems' response to the "POODLE" attack
+ (which does affect Tor).
+
+ o Major security fixes (also in 0.2.5.9-rc):
+ - Disable support for SSLv3. All versions of OpenSSL in use with Tor
+ today support TLS 1.0 or later, so we can safely turn off support
+ for this old (and insecure) protocol. Fixes bug 13426.
+
+ o Major bugfixes (openssl bug workaround, also in 0.2.5.9-rc):
+ - Avoid crashing when using OpenSSL version 0.9.8zc, 1.0.0o, or
+ 1.0.1j, built with the 'no-ssl3' configuration option. Fixes bug
+ 13471. This is a workaround for an OpenSSL bug.
+
+
+Changes in version 0.2.4.24 - 2014-09-22
+ Tor 0.2.4.24 fixes a bug that affects consistency and speed when
+ connecting to hidden services, and it updates the location of one of
+ the directory authorities.
+
+ o Major bugfixes:
+ - Clients now send the correct address for their chosen rendezvous
+ point when trying to access a hidden service. They used to send
+ the wrong address, which would still work some of the time because
+ they also sent the identity digest of the rendezvous point, and if
+ the hidden service happened to try connecting to the rendezvous
+ point from a relay that already had a connection open to it,
+ the relay would reuse that connection. Now connections to hidden
+ services should be more robust and faster. Also, this bug meant
+ that clients were leaking to the hidden service whether they were
+ on a little-endian (common) or big-endian (rare) system, which for
+ some users might have reduced their anonymity. Fixes bug 13151;
+ bugfix on 0.2.1.5-alpha.
+
+ o Directory authority changes:
+ - Change IP address for gabelmoo (v3 directory authority).
+
+ o Minor features (geoip):
+ - Update geoip and geoip6 to the August 7 2014 Maxmind GeoLite2
+ Country database.
+
+
+Changes in version 0.2.4.23 - 2014-07-28
+ Tor 0.2.4.23 brings us a big step closer to slowing down the risk from
+ guard rotation, and also backports several important fixes from the
+ Tor 0.2.5 alpha release series.
+
+ o Major features:
+ - Clients now look at the "usecreatefast" consensus parameter to
+ decide whether to use CREATE_FAST or CREATE cells for the first hop
+ of their circuit. This approach can improve security on connections
+ where Tor's circuit handshake is stronger than the available TLS
+ connection security levels, but the tradeoff is more computational
+ load on guard relays. Implements proposal 221. Resolves ticket 9386.
+ - Make the number of entry guards configurable via a new
+ NumEntryGuards consensus parameter, and the number of directory
+ guards configurable via a new NumDirectoryGuards consensus
+ parameter. Implements ticket 12688.
+
+ o Major bugfixes:
+ - Fix a bug in the bounds-checking in the 32-bit curve25519-donna
+ implementation that caused incorrect results on 32-bit
+ implementations when certain malformed inputs were used along with
+ a small class of private ntor keys. This bug does not currently
+ appear to allow an attacker to learn private keys or impersonate a
+ Tor server, but it could provide a means to distinguish 32-bit Tor
+ implementations from 64-bit Tor implementations. Fixes bug 12694;
+ bugfix on 0.2.4.8-alpha. Bug found by Robert Ransom; fix from
+ Adam Langley.
+
+ o Minor bugfixes:
+ - Warn and drop the circuit if we receive an inbound 'relay early'
+ cell. Those used to be normal to receive on hidden service circuits
+ due to bug 1038, but the buggy Tor versions are long gone from
+ the network so we can afford to resume watching for them. Resolves
+ the rest of bug 1038; bugfix on 0.2.1.19.
+ - Correct a confusing error message when trying to extend a circuit
+ via the control protocol but we don't know a descriptor or
+ microdescriptor for one of the specified relays. Fixes bug 12718;
+ bugfix on 0.2.3.1-alpha.
+ - Avoid an illegal read from stack when initializing the TLS
+ module using a version of OpenSSL without all of the ciphers
+ used by the v2 link handshake. Fixes bug 12227; bugfix on
+ 0.2.4.8-alpha. Found by "starlight".
+
+ o Minor features:
+ - Update geoip and geoip6 to the July 10 2014 Maxmind GeoLite2
+ Country database.
+
+
Changes in version 0.2.4.22 - 2014-05-16
Tor 0.2.4.22 backports numerous high-priority fixes from the Tor 0.2.5
alpha release series. These include blocking all authority signing
diff --git a/acinclude.m4 b/acinclude.m4
index 7401e0b242..06f4b19e54 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -2,7 +2,7 @@ dnl Helper macros for Tor configure.ac
dnl Copyright (c) 2001-2004, Roger Dingledine
dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
dnl Copyright (c) 2007-2008, Roger Dingledine, Nick Mathewson
-dnl Copyright (c) 2007-2013, The Tor Project, Inc.
+dnl Copyright (c) 2007-2014, The Tor Project, Inc.
dnl See LICENSE for licensing information
AC_DEFUN([TOR_EXTEND_CODEPATH],
diff --git a/changes/12207 b/changes/12207
deleted file mode 100644
index 53c14a4ffd..0000000000
--- a/changes/12207
+++ /dev/null
@@ -1,4 +0,0 @@
- - Testing:
- - Refactor the function that chooses guard nodes so that it can
- more easily be tested; write some tests for it.
-
diff --git a/changes/bufferevent_compilation b/changes/bufferevent_compilation
deleted file mode 100644
index 3a328731fe..0000000000
--- a/changes/bufferevent_compilation
+++ /dev/null
@@ -1,6 +0,0 @@
- o Minor bugfixes:
- - Fix compilation when building with bufferevents enabled. (This
- configuration is still not expected to work, however.)
- Fixes bugs 12438, 12474, 11578; bugfixes on 0.2.5.1-alpha and
- 0.2.5.3-alpha. Patches from Anthony G. Basile and Sathyanarayanan
- Gunasekaran.
diff --git a/changes/bug11302 b/changes/bug11302
deleted file mode 100644
index 7416c69be6..0000000000
--- a/changes/bug11302
+++ /dev/null
@@ -1,4 +0,0 @@
- o Bugfixes:
- - Check for orconns and use connection_or_close_for_error() rather than
- connection_mark_for_close() directly in the getsockopt() failure case
- of connection_handle_write_impl(). Fixes bug #11302.
diff --git a/changes/bug11683 b/changes/bug11683
deleted file mode 100644
index ccbd2a5233..0000000000
--- a/changes/bug11683
+++ /dev/null
@@ -1,8 +0,0 @@
- o Minor bugfixes:
- - Always believe that v3 directory authorities serve extra-info
- documents, regardless of whether their server descriptor contains a
- "caches-extra-info" line or not. Fixes part of #11683. Bugfix on
- 0.2.0.1-alpha.
- - When running as a v3 directory authority, advertise that you serve
- extra-info documents so that clients who want them can find them from
- you too. Fixes part of bug #11683. Bugfix on 0.2.0.1-alpha.
diff --git a/changes/bug12202 b/changes/bug12202
deleted file mode 100644
index 566d37efda..0000000000
--- a/changes/bug12202
+++ /dev/null
@@ -1,3 +0,0 @@
- o Code simplification and refactoring:
- - Change the entry_is_live() function to take named bitfield elements
- instead of an unnamed list of booleans. Closes ticket 12202.
diff --git a/changes/bug12503 b/changes/bug12503
deleted file mode 100644
index ff96fa2cf5..0000000000
--- a/changes/bug12503
+++ /dev/null
@@ -1,3 +0,0 @@
- o Testing:
- - Fix and re-enable the fgets_eagain unit test. Fixes bug 12503;
- bugfix on 0.2.3.1-alpha. Patch from "cypherpunks."
diff --git a/changes/bug12573 b/changes/bug12573
deleted file mode 100644
index 46e3ee2fa0..0000000000
--- a/changes/bug12573
+++ /dev/null
@@ -1,5 +0,0 @@
- o Major bugfixes:
- - Relays should not be assigned the HSDir flag if they are
- considered invalid. Also, do not assign the HSDir flag to relays
- that are currently hibernating. Fixes #12573. Bugfix on
- tor-0.2.0.10-alpha
diff --git a/changes/bug12602 b/changes/bug12602
deleted file mode 100644
index 29fa49ac45..0000000000
--- a/changes/bug12602
+++ /dev/null
@@ -1,5 +0,0 @@
- o Minor bugfixes (portability):
- - Compile correctly with builds and forks of OpenSSL (such as
- LibreSSL) that disable compression. Fixes bug 12602; bugfix on
- 0.2.1.1-alpha. Patch from "dhill".
-
diff --git a/changes/bug13214 b/changes/bug13214
new file mode 100644
index 0000000000..5b9758b388
--- /dev/null
+++ b/changes/bug13214
@@ -0,0 +1,7 @@
+ o Minor bugfixes (hidden services):
+ - When fetching hidden service descriptors, check not only for
+ whether we got the hidden service we had in mind, but also
+ whether we got the particular descriptors we wanted. This
+ prevents a class of inefficient but annoying DoS attacks by
+ hidden service directories. Fixes bug 13214; bugfix on
+ 0.2.1.6-alpha. Reported by "special".
diff --git a/changes/bug13315 b/changes/bug13315
new file mode 100644
index 0000000000..c2ae5ff1f8
--- /dev/null
+++ b/changes/bug13315
@@ -0,0 +1,5 @@
+ o Minor features:
+ - Validate hostnames in SOCKS5 requests more strictly. If SafeSocks
+ is enabled, reject requests with IP addresses as hostnames. Resolves
+ ticket 13315.
+
diff --git a/changes/bug13399 b/changes/bug13399
new file mode 100644
index 0000000000..fcaf58a53c
--- /dev/null
+++ b/changes/bug13399
@@ -0,0 +1,12 @@
+ o Minor bugfixes:
+ - Use a full 256 bits of the SHA256 digest of a microdescriptor when
+ computing which microdescriptors to download. This keeps us from
+ erroneous download behavior if two microdescriptor digests ever have
+ the same first 160 bits. Fixes part of bug 13399; bugfix on
+ 0.2.3.1-alpha.
+
+ - Reset a router's status if its microdescriptor digest changes,
+ even if the first 160 bits remain the same. Fixes part of bug
+ 13399; bugfix on 0.2.3.1-alpha.
+
+
diff --git a/changes/bug13399_part1 b/changes/bug13399_part1
new file mode 100644
index 0000000000..2ad3f8d77e
--- /dev/null
+++ b/changes/bug13399_part1
@@ -0,0 +1,3 @@
+ o Code simplifications and refactoring:
+ - Refactor our generic strmap and digestmap types into a single
+ implementation, so that we can add a new digest256map type trivially.
diff --git a/changes/bug8387 b/changes/bug8387
deleted file mode 100644
index 2ec0487bf8..0000000000
--- a/changes/bug8387
+++ /dev/null
@@ -1,11 +0,0 @@
- o Major bugfixes (client):
-
- - Perform circuit cleanup operations even when circuit
- construction operations are disabled (because the network is
- disabled, or because there isn't enough directory information).
- Previously, when we were not building predictive circuits, we
- were not closing expired circuits either.
-
- Fixes bug 8387; bugfix on 0.1.1.11-alpha. This bug became visible
- in 0.2.4.10-alpha when we became more strict about when we have
- "enough directory information to build circuits".
diff --git a/changes/bug9801 b/changes/bug9801
deleted file mode 100644
index 6b23b71806..0000000000
--- a/changes/bug9801
+++ /dev/null
@@ -1,5 +0,0 @@
- o Minor bugfixes:
- - When GeoIPExcludeUnkonwn is enabled, do not incorrectly decide
- that our options have changed every time we SIGHUP. Fixes bug
- 9801; bugfix on 0.2.4.10-alpha. Patch from "qwerty1".
-
diff --git a/changes/coverage-html b/changes/coverage-html
deleted file mode 100644
index 1c38c76fa6..0000000000
--- a/changes/coverage-html
+++ /dev/null
@@ -1,5 +0,0 @@
- o Minor features (testing):
-
- - Add a "coverage-html" make target to generate HTML-visualized
- coverage results when building with --enable-coverage. (Requires lcov.)
- Patch from Kevin Murray.
diff --git a/changes/feature5583 b/changes/feature5583
deleted file mode 100644
index cd5eb69281..0000000000
--- a/changes/feature5583
+++ /dev/null
@@ -1,2 +0,0 @@
- o Minor features:
- - Add an option to overwrite logs (TruncateLogFile). Closes ticket #5583.
diff --git a/changes/further-12184-diagnostic b/changes/further-12184-diagnostic
deleted file mode 100644
index 89e9f4612f..0000000000
--- a/changes/further-12184-diagnostic
+++ /dev/null
@@ -1,2 +0,0 @@
- o Minor features (diagnostic):
- - Slightly enhance the diagnostic message for bug 12184.
diff --git a/changes/geoip-july2014 b/changes/geoip-july2014
deleted file mode 100644
index a0523ecac9..0000000000
--- a/changes/geoip-july2014
+++ /dev/null
@@ -1,3 +0,0 @@
- o Minor features:
- - Update geoip to the July 10 2014 Maxmind GeoLite2 Country database.
-
diff --git a/changes/geoip6-july2014 b/changes/geoip6-july2014
deleted file mode 100644
index 155788ef88..0000000000
--- a/changes/geoip6-july2014
+++ /dev/null
@@ -1,2 +0,0 @@
- o Minor features:
- - Update geoip6 to the July 10 2014 Maxmind GeoLite2 Country database.
diff --git a/changes/no-wince b/changes/no-wince
deleted file mode 100644
index 833bf46630..0000000000
--- a/changes/no-wince
+++ /dev/null
@@ -1,4 +0,0 @@
- o Removed platform support:
- - We no longer include special code to build on Windows CE; as far
- as we know, nobody has used Tor on Windows CE in a very long
- time. Closes ticket 11446.
diff --git a/changes/spurious-clang-warnings b/changes/spurious-clang-warnings
new file mode 100644
index 0000000000..d039920476
--- /dev/null
+++ b/changes/spurious-clang-warnings
@@ -0,0 +1,10 @@
+ o Minor bugfixes:
+ - Silence clang warnings under --enable-expensive-hardening, including:
+ + implicit truncation of 64 bit values to 32 bit;
+ + const char assignment to self;
+ + tautological compare; and
+ + additional parentheses around equality tests. (gcc uses these to
+ silence assignment, so clang warns when they're present in an
+ equality test. But we need to use extra parentheses in macros to
+ isolate them from other code).
+ Fixes bug 13577.
diff --git a/changes/threads-required b/changes/threads-required
deleted file mode 100644
index a56cfe345b..0000000000
--- a/changes/threads-required
+++ /dev/null
@@ -1,12 +0,0 @@
- o Removed features:
- - Tor no longer supports systems without threading support.
- When we began working on Tor, there were several systems that didn't
- have threads, or where the thread support wasn't able to run the
- threads of a single process on multiple CPUs. That no longer holds:
- every system where Tor needs to run well now has threading support.
- Resolves ticket 12439.
-
- o Minor features:
- - Threads are no longer disabled by default on Solaris; we believe that
- the versions of Solaris with broken threading support are all obsolete
- by now. Resolves ticket 9495.
diff --git a/configure.ac b/configure.ac
index 414c72a42c..e7560b2bfc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,9 +1,9 @@
dnl Copyright (c) 2001-2004, Roger Dingledine
dnl Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
-dnl Copyright (c) 2007-2013, The Tor Project, Inc.
+dnl Copyright (c) 2007-2014, The Tor Project, Inc.
dnl See LICENSE for licensing information
-AC_INIT([tor],[0.2.6.0-alpha-dev])
+AC_INIT([tor],[0.2.6.1-alpha-dev])
AC_CONFIG_SRCDIR([src/or/main.c])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE
@@ -39,8 +39,6 @@ AC_ARG_ENABLE(static-zlib,
AS_HELP_STRING(--enable-static-zlib, Link against a static zlib library. Requires --with-zlib-dir))
AC_ARG_ENABLE(static-tor,
AS_HELP_STRING(--enable-static-tor, Create an entirely static Tor binary. Requires --with-openssl-dir and --with-libevent-dir and --with-zlib-dir))
-AC_ARG_ENABLE(curve25519,
- AS_HELP_STRING(--disable-curve25519, Build Tor with no curve25519 elliptic-curve crypto support))
AC_ARG_ENABLE(unittests,
AS_HELP_STRING(--disable-unittests, [Don't build unit tests for Tor. Risky!]))
AC_ARG_ENABLE(coverage,
@@ -153,6 +151,9 @@ AC_ARG_ENABLE(tool-name-check,
AC_ARG_ENABLE(seccomp,
AS_HELP_STRING(--disable-seccomp, do not attempt to use libseccomp))
+AC_ARG_ENABLE(libscrypt,
+ AS_HELP_STRING(--disable-libscrypt, do not attempt to use libscrypt))
+
dnl check for the correct "ar" when cross-compiling
AN_MAKEVAR([AR], [AC_PROG_AR])
AN_PROGRAM([ar], [AC_PROG_AR])
@@ -191,6 +192,7 @@ AM_CONDITIONAL(USE_FW_HELPER, test x$natpmp = xtrue || test x$upnp = xtrue)
AM_CONDITIONAL(NAT_PMP, test x$natpmp = xtrue)
AM_CONDITIONAL(MINIUPNPC, test x$upnp = xtrue)
AM_PROG_CC_C_O
+AC_PROG_CC_C99
AC_ARG_VAR(PYTHON)
AC_CHECK_PROGS(PYTHON, [python python2 python2.7 python3 python3.3])
@@ -221,6 +223,28 @@ AC_C_FLEXIBLE_ARRAY_MEMBER
fi
])
+AC_CACHE_CHECK([for working C99 mid-block declaration syntax],
+ tor_cv_c_c99_decl,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([], [int x; x = 3; int y; y = 4 + x;])],
+ [tor_cv_c_c99_decl=yes],
+ [tor_cv_c_c99_decl=no] )])
+if test "$tor_cv_c_c99_decl" != "yes"; then
+ AC_MSG_ERROR([Your compiler doesn't support c99 mid-block declarations. This is required as of Tor 0.2.6.x])
+fi
+
+AC_CACHE_CHECK([for working C99 designated initializers],
+ tor_cv_c_c99_designated_init,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([struct s { int a; int b; };],
+ [[ struct s ss = { .b = 5, .a = 6 }; ]])],
+ [tor_cv_c_c99_designated_init=yes],
+ [tor_cv_c_c99_designated_init=no] )])
+
+if test "$tor_cv_c_c99_designated_init" != "yes"; then
+ AC_MSG_ERROR([Your compiler doesn't support c99 designated initializers. This is required as of Tor 0.2.6.x])
+fi
+
AC_PATH_PROG([SHA1SUM], [sha1sum], none)
AC_PATH_PROG([OPENSSL], [openssl], none)
@@ -339,6 +363,7 @@ AC_CHECK_FUNCS(
socketpair \
strlcat \
strlcpy \
+ strnlen \
strptime \
strtok_r \
strtoull \
@@ -556,6 +581,10 @@ else
fi
AC_SUBST(TOR_OPENSSL_LIBS)
+AC_CHECK_MEMBERS([struct ssl_method_st.get_cipher_by_char], , ,
+[#include <openssl/ssl.h>
+])
+
dnl ------------------------------------------------------
dnl Where do you live, zlib? And how do we call you?
@@ -604,11 +633,12 @@ if test x$enable_gcc_hardening != xno; then
TOR_CHECK_CFLAGS(-fstack-protector-all, also_link)
AS_VAR_PUSHDEF([can_compile], [tor_cv_cflags_-fstack-protector-all])
AS_VAR_PUSHDEF([can_link], [tor_can_link_-fstack-protector-all])
+m4_ifdef([AS_VAR_IF],[
AS_VAR_IF(can_compile, [yes],
AS_VAR_IF(can_link, [yes],
[],
AC_MSG_ERROR([We tried to build with stack protection; it looks like your compiler supports it but your libc does not provide it. Are you missing libssp? (You can --disable-gcc-hardening to ignore this error.)]))
- )
+ )])
AS_VAR_POPDEF([can_link])
AS_VAR_POPDEF([can_compile])
TOR_CHECK_CFLAGS(-Wstack-protector)
@@ -722,104 +752,103 @@ if test "x$enable_seccomp" != "xno"; then
fi
dnl ============================================================
+dnl Check for libscrypt
+
+if test "x$enable_libscrypt" != "xno"; then
+ AC_CHECK_HEADERS([libscrypt.h])
+ AC_SEARCH_LIBS(libscrypt_scrypt, [scrypt])
+fi
+
+dnl ============================================================
dnl We need an implementation of curve25519.
dnl set these defaults.
-have_a_curve25519=no
build_curve25519_donna=no
build_curve25519_donna_c64=no
use_curve25519_donna=no
use_curve25519_nacl=no
CURVE25519_LIBS=
-if test x$enable_curve25519 != xno; then
-
- dnl The best choice is using curve25519-donna-c64, but that requires
- dnl that we
- AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
- tor_cv_can_use_curve25519_donna_c64,
- [AC_RUN_IFELSE(
- [AC_LANG_PROGRAM([dnl
- #include <stdint.h>
- typedef unsigned uint128_t __attribute__((mode(TI)));
- int func(uint64_t a, uint64_t b) {
- uint128_t c = ((uint128_t)a) * b;
- int ok = ((uint64_t)(c>>96)) == 522859 &&
- (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
- (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
- (((uint64_t)(c))&0xffffffffL) == 0;
- return ok;
- }
- ], [dnl
- int ok = func( ((uint64_t)2000000000) * 1000000000,
- ((uint64_t)1234567890) << 24);
- return !ok;
- ])],
- [tor_cv_can_use_curve25519_donna_c64=yes],
- [tor_cv_can_use_curve25519_donna_c64=no],
- [AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([dnl
- #include <stdint.h>
- typedef unsigned uint128_t __attribute__((mode(TI)));
- int func(uint64_t a, uint64_t b) {
- uint128_t c = ((uint128_t)a) * b;
- int ok = ((uint64_t)(c>>96)) == 522859 &&
- (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
- (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
- (((uint64_t)(c))&0xffffffffL) == 0;
- return ok;
- }
- ], [dnl
- int ok = func( ((uint64_t)2000000000) * 1000000000,
- ((uint64_t)1234567890) << 24);
- return !ok;
- ])],
- [tor_cv_can_use_curve25519_donna_c64=cross],
- [tor_cv_can_use_curve25519_donna_c64=no])])])
-
- AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
- nacl/crypto_scalarmult_curve25519.h])
-
- AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
- tor_cv_can_use_curve25519_nacl,
- [tor_saved_LIBS="$LIBS"
- LIBS="$LIBS -lnacl"
- AC_LINK_IFELSE(
- [AC_LANG_PROGRAM([dnl
- #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
- #include <crypto_scalarmult_curve25519.h>
- #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
- #include <nacl/crypto_scalarmult_curve25519.h>
- #endif
- #ifdef crypto_scalarmult_curve25519_ref_BYTES
- #error Hey, this is the reference implementation! That's not fast.
- #endif
- ], [
- unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
- ])], [tor_cv_can_use_curve25519_nacl=yes],
- [tor_cv_can_use_curve25519_nacl=no])
- LIBS="$tor_saved_LIBS" ])
-
- dnl Okay, now we need to figure out which one to actually use. Fall back
- dnl to curve25519-donna.c
-
- if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
- build_curve25519_donna_c64=yes
- use_curve25519_donna=yes
- elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
- use_curve25519_nacl=yes
- CURVE25519_LIBS=-lnacl
- else
- build_curve25519_donna=yes
- use_curve25519_donna=yes
- fi
- have_a_curve25519=yes
-fi
+dnl The best choice is using curve25519-donna-c64, but that requires
+dnl that we
+AC_CACHE_CHECK([whether we can use curve25519-donna-c64],
+ tor_cv_can_use_curve25519_donna_c64,
+ [AC_RUN_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #include <stdint.h>
+ typedef unsigned uint128_t __attribute__((mode(TI)));
+ int func(uint64_t a, uint64_t b) {
+ uint128_t c = ((uint128_t)a) * b;
+ int ok = ((uint64_t)(c>>96)) == 522859 &&
+ (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
+ (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
+ (((uint64_t)(c))&0xffffffffL) == 0;
+ return ok;
+ }
+ ], [dnl
+ int ok = func( ((uint64_t)2000000000) * 1000000000,
+ ((uint64_t)1234567890) << 24);
+ return !ok;
+ ])],
+ [tor_cv_can_use_curve25519_donna_c64=yes],
+ [tor_cv_can_use_curve25519_donna_c64=no],
+ [AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #include <stdint.h>
+ typedef unsigned uint128_t __attribute__((mode(TI)));
+ int func(uint64_t a, uint64_t b) {
+ uint128_t c = ((uint128_t)a) * b;
+ int ok = ((uint64_t)(c>>96)) == 522859 &&
+ (((uint64_t)(c>>64))&0xffffffffL) == 3604448702L &&
+ (((uint64_t)(c>>32))&0xffffffffL) == 2351960064L &&
+ (((uint64_t)(c))&0xffffffffL) == 0;
+ return ok;
+ }
+ ], [dnl
+ int ok = func( ((uint64_t)2000000000) * 1000000000,
+ ((uint64_t)1234567890) << 24);
+ return !ok;
+ ])],
+ [tor_cv_can_use_curve25519_donna_c64=cross],
+ [tor_cv_can_use_curve25519_donna_c64=no])])])
+
+AC_CHECK_HEADERS([crypto_scalarmult_curve25519.h \
+ nacl/crypto_scalarmult_curve25519.h])
+
+AC_CACHE_CHECK([for nacl compiled with a fast curve25519 implementation],
+ tor_cv_can_use_curve25519_nacl,
+ [tor_saved_LIBS="$LIBS"
+ LIBS="$LIBS -lnacl"
+ AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM([dnl
+ #ifdef HAVE_CRYPTO_SCALARMULT_CURVE25519_H
+ #include <crypto_scalarmult_curve25519.h>
+ #elif defined(HAVE_NACL_CRYPTO_SCALARMULT_CURVE25519_H)
+ #include <nacl/crypto_scalarmult_curve25519.h>
+ #endif
+ #ifdef crypto_scalarmult_curve25519_ref_BYTES
+ #error Hey, this is the reference implementation! That's not fast.
+ #endif
+ ], [
+ unsigned char *a, *b, *c; crypto_scalarmult_curve25519(a,b,c);
+ ])], [tor_cv_can_use_curve25519_nacl=yes],
+ [tor_cv_can_use_curve25519_nacl=no])
+ LIBS="$tor_saved_LIBS" ])
+
+ dnl Okay, now we need to figure out which one to actually use. Fall back
+ dnl to curve25519-donna.c
+
+ if test x$tor_cv_can_use_curve25519_donna_c64 != xno; then
+ build_curve25519_donna_c64=yes
+ use_curve25519_donna=yes
+ elif test x$tor_cv_can_use_curve25519_nacl = xyes; then
+ use_curve25519_nacl=yes
+ CURVE25519_LIBS=-lnacl
+ else
+ build_curve25519_donna=yes
+ use_curve25519_donna=yes
+ fi
-if test x$have_a_curve25519 = xyes; then
- AC_DEFINE(CURVE25519_ENABLED, 1,
- [Defined if we have a curve25519 implementation])
-fi
if test x$use_curve25519_donna = xyes; then
AC_DEFINE(USE_CURVE25519_DONNA, 1,
[Defined if we should use an internal curve25519_donna{,_c64} implementation])
@@ -830,7 +859,6 @@ if test x$use_curve25519_nacl = xyes; then
fi
AM_CONDITIONAL(BUILD_CURVE25519_DONNA, test x$build_curve25519_donna = xyes)
AM_CONDITIONAL(BUILD_CURVE25519_DONNA_C64, test x$build_curve25519_donna_c64 = xyes)
-AM_CONDITIONAL(CURVE25519_ENABLED, test x$have_a_curve25519 = xyes)
AC_SUBST(CURVE25519_LIBS)
dnl Make sure to enable support for large off_t if available.
@@ -1499,7 +1527,7 @@ if test x$enable_gcc_warnings = xyes || test x$enable_gcc_warnings_advisory = xy
if test x$have_gcc4 = xyes ; then
# These warnings break gcc 3.3.5 and work on gcc 4.0.2
- CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement -Wold-style-definition"
+ CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wold-style-definition"
fi
if test x$have_gcc42 = xyes ; then
@@ -1555,6 +1583,7 @@ AC_CONFIG_FILES([
contrib/dist/torctl
contrib/dist/tor.service
src/config/torrc.sample
+ src/config/torrc.minimal
])
if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
@@ -1563,7 +1592,9 @@ if test x$asciidoc = xtrue && test "$ASCIIDOC" = "none" ; then
if ! [[ -f "$srcdir/$file.1.in" ]] || ! [[ -f "$srcdir/$file.html.in" ]] ; then
echo "==================================";
echo;
- echo "You need asciidoc installed to be able to build the manpage.";
+ echo "Building Tor has failed since manpages cannot be built.";
+ echo;
+ echo "You need asciidoc installed to be able to build the manpages.";
echo "To build without manpages, use the --disable-asciidoc argument";
echo "when calling configure.";
echo;
diff --git a/contrib/dist/tor.service.in b/contrib/dist/tor.service.in
index 5d7670281b..57409a7b0a 100644
--- a/contrib/dist/tor.service.in
+++ b/contrib/dist/tor.service.in
@@ -4,7 +4,10 @@ After = syslog.target network.target nss-lookup.target
[Service]
Type = simple
-ExecStart = @BINDIR@/tor -f @CONFDIR@/torrc
+ExecStartPre = @BINDIR@/tor -f @CONFDIR@/torrc --verify-config
+# A torrc that has "RunAsDaemon 1" won't work with the "simple" service type;
+# let's explicitly override it.
+ExecStart = @BINDIR@/tor -f @CONFDIR@/torrc --RunAsDaemon 0
ExecReload = /bin/kill -HUP ${MAINPID}
KillSignal = SIGINT
TimeoutSec = 30
@@ -16,6 +19,11 @@ PrivateTmp = yes
DeviceAllow = /dev/null rw
DeviceAllow = /dev/urandom r
InaccessibleDirectories = /home
+ReadOnlyDirectories = /
+ReadWriteDirectories = @LOCALSTATEDIR@/lib/tor
+ReadWriteDirectories = @LOCALSTATEDIR@/log/tor
+ReadWriteDirectories = @LOCALSTATEDIR@/run/tor
+NoNewPrivileges = yes
[Install]
WantedBy = multi-user.target
diff --git a/contrib/win32build/tor-mingw.nsi.in b/contrib/win32build/tor-mingw.nsi.in
index f5c02dbb84..d675c2cc09 100644
--- a/contrib/win32build/tor-mingw.nsi.in
+++ b/contrib/win32build/tor-mingw.nsi.in
@@ -8,7 +8,7 @@
!include "LogicLib.nsh"
!include "FileFunc.nsh"
!insertmacro GetParameters
-!define VERSION "0.2.6.0-alpha-dev"
+!define VERSION "0.2.6.1-alpha-dev"
!define INSTALLER "tor-${VERSION}-win32.exe"
!define WEBSITE "https://www.torproject.org/"
!define LICENSE "LICENSE"
diff --git a/doc/HACKING b/doc/HACKING
index 6b21426497..5c71b74bd1 100644
--- a/doc/HACKING
+++ b/doc/HACKING
@@ -134,6 +134,27 @@ output directory, use `make coverage-html HTML_COVER_DIR=./funky_new_cov_dir`.
Coverage diffs using lcov are not currently implemented, but are being
investigated (as of July 2014).
+Running the unit tests
+~~~~~~~~~~~~~~~~~~~~~~
+
+To quickly run all tests:
+-----
+ make check
+-----
+
+To run unit tests only:
+-----
+ make test
+-----
+
+To selectively run just some tests (the following can be combined
+arbitrarily):
+-----
+ ./src/test/test <name_of_test> [<name of test 2>] ...
+ ./src/test/test <prefix_of_name_of_test>.. [<prefix_of_name_of_test2>..] ...
+ ./src/test/test :<name_of_excluded_test> [:<name_of_excluded_test2]...
+-----
+
Running gcov for unit test coverage
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -512,7 +533,7 @@ interesting and understandable.
2.6) Clean everything one last time.
- 2.7) Run it through fmt to make it pretty.
+ 2.7) Run ./scripts/maint/format_changelog.py to make it prettier.
3) Compose a short release blurb to highlight the user-facing
changes. Insert said release blurb into the ChangeLog stanza. If it's
@@ -534,10 +555,12 @@ in their approved versions list.
git tag -u <keyid> tor-0.2.x.y-status
git push origin tag tor-0.2.x.y-status
-8) scp the tarball and its sig to the website in the dist/ directory
-(i.e. /srv/www-master.torproject.org/htdocs/dist/ on vescum). Edit
-"include/versions.wmi" and "Makefile" to note the new version. From your
-website checkout, run ./publish to build and publish the website.
+8a) scp the tarball and its sig to the dist website, i.e.
+/srv/dist-master.torproject.org/htdocs/ on dist-master. When you want
+it to go live, you run "static-update-component dist.torproject.org"
+on dist-master.
+
+8b) Edit "include/versions.wmi" and "Makefile" to note the new version.
9) Email the packagers (cc'ing tor-assistants) that a new tarball is up.
diff --git a/doc/TUNING b/doc/TUNING
new file mode 100644
index 0000000000..a4bf386dd6
--- /dev/null
+++ b/doc/TUNING
@@ -0,0 +1,47 @@
+Most operating systems limit an amount of TCP sockets that can be used
+simultaneously. It is possible for a busy Tor relay to run into these
+limits, thus being unable to fully utilize the bandwidth resources it
+has at its disposal. Following system-specific tips might be helpful
+to alleviate the aforementioned problem.
+
+Linux
+-----
+
+Use 'ulimit -n' to raise an allowed number of file descriptors to be
+opened on your host at the same time.
+
+FreeBSD
+-------
+
+Tune the followind sysctl(8) variables:
+ * kern.maxfiles - maximum allowed file descriptors (for entire system)
+ * kern.maxfilesperproc - maximum file descriptors one process is allowed
+ to use
+ * kern.ipc.maxsockets - overall maximum numbers of sockets for entire
+ system
+ * kern.ipc.somaxconn - size of listen queue for incoming TCP connections
+ for entire system
+
+See also:
+ * https://www.freebsd.org/doc/handbook/configtuning-kernel-limits.html
+ * https://wiki.freebsd.org/NetworkPerformanceTuning
+
+Mac OS X
+--------
+
+Since Mac OS X is BSD-based system, most of the above hold for OS X as well.
+However, launchd(8) is known to modify kern.maxfiles and kern.maxfilesperproc
+when it launches tor service (see launchd.plist(5) manpage). Also,
+kern.ipc.maxsockets is determined dynamically by the system and thus is
+read-only on OS X.
+
+Disclaimer
+----------
+
+Do note that this document is a draft and above information may be
+technically incorrect and/or incomplete. If so, please open a ticket
+on https://trac.torproject.org or post to tor-relays mailing list.
+
+Are you running a busy Tor relay? Let us know how you are solving
+the out-of-sockets problem on your system.
+
diff --git a/doc/building-tor-msvc.txt b/doc/building-tor-msvc.txt
new file mode 100644
index 0000000000..3d3eced8af
--- /dev/null
+++ b/doc/building-tor-msvc.txt
@@ -0,0 +1,122 @@
+Building Tor with MSVC.
+=======================
+
+NOTE: This is not the preferred method for building Tor on windows: we use
+mingw for our packages.
+
+Last updated 9 September 2014.
+
+
+Requirements:
+-------------
+
+ * Visual Studio 2010
+ http://go.microsoft.com/fwlink/?LinkId=323467
+ * CMake 2.8.12.2
+ http://www.cmake.org/download/
+ * Perl 5.16
+ http://www.activestate.com/activeperl/downloads
+ * Latest stable OpenSSL tarball
+ https://www.openssl.org/source/
+ * Latest stable zlib tarball
+ http://zlib.net/
+ * Latest stable libevent Libevent tarball
+ https://github.com/libevent/libevent/releases
+
+Make sure you check signatures for all these packages.
+
+Steps:
+------
+
+Building OpenSSL from source as a shared library:
+
+ cd <openssl source dir>
+ perl Configure VC-WIN32
+ perl util\mkfiles.pl >MINFO
+ perl util\mk1mf.pl no-asm dll VC-WIN32 >32dll.mak
+ perl util\mkdef.pl 32 libeay > ms\libeay32.def
+ perl util\mkdef.pl 32 ssleay > ms\ssleay32.def
+ nmake -f 32dll.mak
+
+Making OpenSSL final package:
+
+ Create <openssl final package dir>, I'd recommend using a name like <openssl
+ source dir>-vc10.
+
+ Copy the following directories and files to their respective locations
+ <openssl source dir>\inc32\openssl => <openssl final package dir>\include\openssl
+ <openssl source dir>\out32dll\libeay32.lib => <openssl final package dir>\lib\libeay32.lib
+ <openssl source dir>\out32dll\ssleay32.lib => <openssl final package dir>\lib\ssleay32.lib
+ <openssl source dir>\out32dll\libeay32.dll => <openssl final package dir>\bin\libeay32.dll
+ <openssl source dir>\out32dll\openssl.exe => <openssl final package dir>\bin\openssl.exe
+ <openssl source dir>\out32dll\ssleay32.dll => <openssl final package dir>\bin\ssleay32.dll
+
+Building Zlib from source:
+
+ cd <zlib source dir>
+ nmake -f win32/Makefile.msc
+
+Building libevent:
+
+ cd <libevent source dir>
+ mkdir build && cd build
+ SET OPENSSL_ROOT_DIR=<openssl final package dir>
+ cmake -G "NMake Makefiles" .. -DCMAKE_BUILD_TYPE:STRING=RelWithDebInfo -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="/MT /Zi /O2 /Ob1 /D NDEBUG" -DZLIB_LIBRARY:FILEPATH="<zlib source dir>\zdll.lib" -DZLIB_INCLUDE_DIR:PATH="<zlib source dir>"
+ nmake event
+
+Building Tor:
+
+ Create a dir above tor source dir named build-alpha and two subdirs include
+ and lib.
+
+ Your build tree should now be similar to this one:
+ * build-alpha
+ - include
+ - lib
+ * <libevent source dir>
+ - build
+ - cmake
+ - ...
+ * <openssl source dir>
+ - ...
+ - ms
+ - util
+ - ...
+ * <openssl final package dir>
+ - bin
+ - include
+ - lib
+ * <tor source dir>
+ - ...
+ - src
+ - ...
+ * <zlib source dir>
+ - ...
+ - win32
+ - ...
+
+ Copy the following dirs and files to the following locations:
+ <openssl final package dir>\include\openssl => build-alpha\include\openssl
+ <libevent source dir>\include => build-alpha\include
+ <libevent source dir>\WIN32-Code\nmake\event2 => build-alpha\include\event2
+ <zlib source dir>\z*.h => build-alpha\include\z*.h
+
+ Now copy the following files to the following locations and rename them
+ according new names:
+
+ <libevent source dir>\build\lib\event.lib => build-alpha\lib\libevent.lib
+ <openssl final package dir>\lib\libeay32.lib => build-alpha\lib\libcrypto.lib
+ <openssl final package dir>\lib\ssleay32.lib => build-alpha\lib\libssl.lib
+ <zlib source dir>\zdll.lib => build-alpha\lib\libz.lib
+
+ And we are now ready for the build process:
+
+ cd <tor source dir>
+ nmake -f Makefile.nmake
+
+ After the above process is completed there should be a tor.exe in <tor
+ source dir>\src\or
+
+ Copy tor.exe to desired location and also copy zlib1.dll, libeay32.dll and
+ ssleay32.dll from built zlib and openssl packages
+
diff --git a/doc/tor.1.txt b/doc/tor.1.txt
index ca6ac7b997..f625c45161 100644
--- a/doc/tor.1.txt
+++ b/doc/tor.1.txt
@@ -72,7 +72,7 @@ COMMAND-LINE OPTIONS
[[opt-serviceinstall]] **--service install** [**--options** __command-line options__]::
Install an instance of Tor as a Windows service, with the provided
command-line options. Current instructions can be found at
- https://trac.torproject.org/projects/tor/wiki/doc/TorFAQ#HowdoIrunmyTorrelayasanNTservice
+ https://www.torproject.org/docs/faq#NTService
[[opt-service]] **--service** **remove**|**start**|**stop**::
Remove, start, or stop a configured Tor Windows service.
@@ -224,6 +224,13 @@ GENERAL OPTIONS
for the Extended ORPort's cookie file -- the cookie file is needed
for pluggable transports to communicate through the Extended ORPort.
+[[ExtORPortCookieAuthFileGroupReadable]] **ExtORPortCookieAuthFileGroupReadable** **0**|**1**::
+ If this option is set to 0, don't allow the filesystem group to read the
+ Extended OR Port cookie file. If the option is set to 1, make the cookie
+ file readable by the default GID. [Making the file readable by other
+ groups is not yet implemented; let us know if you need this for some
+ reason.] (Default: 0)
+
[[ConnLimit]] **ConnLimit** __NUM__::
The minimum number of file descriptors that must be available to the Tor
process before it will start. Tor will ask the OS for as many file
@@ -312,7 +319,7 @@ GENERAL OPTIONS
If set, this option overrides the default location and file name
for Tor's cookie file. (See CookieAuthentication above.)
-[[CookieAuthFileGroupReadable]] **CookieAuthFileGroupReadable** **0**|**1**|__Groupname__::
+[[CookieAuthFileGroupReadable]] **CookieAuthFileGroupReadable** **0**|**1**::
If this option is set to 0, don't allow the filesystem group to read the
cookie file. If the option is set to 1, make the cookie file readable by
the default GID. [Making the file readable by other groups is not yet
@@ -957,10 +964,10 @@ The following options are useful only for clients (that is, if
(SOCKS 4, SOCKS 5, TransPort connections, NATDPort connections,
and DNSPort requests are all considered to be different protocols.)
**IsolateDestPort**;;
- Don't share circuits with streams targetting a different
+ Don't share circuits with streams targeting a different
destination port.
**IsolateDestAddr**;;
- Don't share circuits with streams targetting a different
+ Don't share circuits with streams targeting a different
destination address.
**SessionGroup=**__INT__;;
If no other isolation rules would prevent it, allow streams
@@ -1011,7 +1018,7 @@ The following options are useful only for clients (that is, if
requests via this connection.
**PreferIPv6Automap**;;
When serving a hostname lookup request on this port that
- should get automapped (according to AutomapHostsOnResove),
+ should get automapped (according to AutomapHostsOnResolve),
if we could return either an IPv4 or an IPv6 answer, prefer
an IPv6 answer. (On by default.)
**PreferSOCKSNoAuth**;;
@@ -1096,12 +1103,16 @@ The following options are useful only for clients (that is, if
[[NumEntryGuards]] **NumEntryGuards** __NUM__::
If UseEntryGuards is set to 1, we will try to pick a total of NUM routers
- as long-term entries for our circuits. (Default: 3)
+ as long-term entries for our circuits. If NUM is 0, we try to learn
+ the number from the NumEntryGuards consensus parameter, and default
+ to 3 if the consensus parameter isn't set. (Default: 0)
[[NumDirectoryGuards]] **NumDirectoryGuards** __NUM__::
If UseEntryGuardsAsDirectoryGuards is enabled, we try to make sure we
have at least NUM routers to use as directory guards. If this option
- is set to 0, use the value from NumEntryGuards. (Default: 0)
+ is set to 0, use the value from the NumDirectoryGuards consensus
+ parameter, falling back to the value from NumEntryGuards if the
+ consensus parameter is 0 or isn't set. (Default: 0)
[[GuardLifetime]] **GuardLifetime** __N__ **days**|**weeks**|**months**::
If nonzero, and UseEntryGuards is set, minimum time to keep a guard before
@@ -1414,7 +1425,7 @@ The following options are useful only for clients (that is, if
whose view of the current time is skewed. If this option is set to 0, we
do not send this timestamp, and hidden services on obsolete Tor versions
will not work. If this option is set to 1, we send the timestamp. If
- this optoin is "auto", we take a recommendation from the latest consensus
+ this option is "auto", we take a recommendation from the latest consensus
document. (Default: auto)
@@ -1486,6 +1497,11 @@ is non-zero):
public (external) IP address. See RFC 1918 and RFC 3330 for more details
about internal and reserved IP address space. +
+
+ Tor also allow IPv6 exit policy entries. For instance, "reject6 [FC00::]/7:*"
+ rejects all destinations that share 7 most significant bit prefix with
+ address FC00::. Respectively, "accept6 [C000::]/3:*" accepts all destinations
+ that share 3 most significant bit prefix with address C000::. +
+ +
This directive can be specified multiple times so you don't have to put it
all on one line. +
+
@@ -1619,19 +1635,31 @@ is non-zero):
to 0 will disable the heartbeat. (Default: 6 hours)
[[AccountingMax]] **AccountingMax** __N__ **bytes**|**KBytes**|**MBytes**|**GBytes**|**KBits**|**MBits**|**GBits**|**TBytes**::
- Never send more than the specified number of bytes in a given accounting
- period, or receive more than that number in the period. For example, with
- AccountingMax set to 1 GByte, a server could send 900 MBytes and
- receive 800 MBytes and continue running. It will only hibernate once
- one of the two reaches 1 GByte. When the number of bytes gets low,
- Tor will stop accepting new connections and circuits. When the
- number of bytes is exhausted, Tor will hibernate until some
- time in the next accounting period. To prevent all servers from waking at
- the same time, Tor will also wait until a random point in each period
- before waking up. If you have bandwidth cost issues, enabling hibernation
- is preferable to setting a low bandwidth, since it provides users with a
- collection of fast servers that are up some of the time, which is more
- useful than a set of slow servers that are always "available".
+ Limits the max number of bytes sent and received within a set time period
+ using a given calculation rule (see: AccountingStart, AccountingRule).
+ Useful if you need to stay under a specific bandwidth. By default, the
+ number used for calculation is the max of either the bytes sent or
+ received. For example, with AccountingMax set to 1 GByte, a server
+ could send 900 MBytes and receive 800 MBytes and continue running.
+ It will only hibernate once one of the two reaches 1 GByte. This can
+ be changed to use the sum of the both bytes received and sent by setting
+ the AccountingRule option to "sum" (total bandwidth in/out). When the
+ number of bytes remaining gets low, Tor will stop accepting new connections
+ and circuits. When the number of bytes is exhausted, Tor will hibernate
+ until some time in the next accounting period. To prevent all servers
+ from waking at the same time, Tor will also wait until a random point
+ in each period before waking up. If you have bandwidth cost issues,
+ enabling hibernation is preferable to setting a low bandwidth, since
+ it provides users with a collection of fast servers that are up some
+ of the time, which is more useful than a set of slow servers that are
+ always "available".
+
+[[AccountingRule]] **AccountingRule** **sum**|**max**::
+ How we determine when our AccountingMax has been reached (when we
+ should hibernate) during a time interval. Set to "max" to calculate
+ using the higher of either the sent or received bytes (this is the
+ default functionality). Set to "sum" to calculate using the sent
+ plus received bytes. (Default: max)
[[AccountingStart]] **AccountingStart** **day**|**week**|**month** [__day__] __HH:MM__::
Specify how long accounting periods last. If **month** is given, each
@@ -1694,7 +1722,7 @@ is non-zero):
[[BridgeRecordUsageByCountry]] **BridgeRecordUsageByCountry** **0**|**1**::
When this option is enabled and BridgeRelay is also enabled, and we have
- GeoIP data, Tor keeps a keep a per-country count of how many client
+ GeoIP data, Tor keeps a per-country count of how many client
addresses have contacted it so that it can help the bridge authority guess
which countries have blocked access to it. (Default: 1)
@@ -1829,15 +1857,6 @@ on the public Tor network.
authorities provide this service optionally. See **RecommendedVersions**,
**RecommendedClientVersions**, and **RecommendedServerVersions**.
-[[NamingAuthoritativeDirectory]] **NamingAuthoritativeDirectory** **0**|**1**::
- When this option is set to 1, then the server advertises that it has
- opinions about nickname-to-fingerprint bindings. It will include these
- opinions in its published network-status pages, by listing servers with
- the flag "Named" if a correct binding between that nickname and fingerprint
- has been registered with the dirserver. Naming dirservers will refuse to
- accept or publish descriptors that contradict a registered binding. See
- **approved-routers** in the **FILES** section below.
-
[[RecommendedVersions]] **RecommendedVersions** __STRING__::
STRING is a comma-separated list of Tor versions currently believed to be
safe. The list is included in each directory, and nodes which pull down the
@@ -1877,20 +1896,15 @@ on the public Tor network.
elements. Otherwise, if the address is not an IP address or is a private IP
address, it will reject the router descriptor. (Default: 0)
-[[AuthDirBadDir]] **AuthDirBadDir** __AddressPattern...__::
+[[AuthDirBadExit]] **AuthDirBadExit** __AddressPattern...__::
Authoritative directories only. A set of address patterns for servers that
- will be listed as bad directories in any network status document this
- authority publishes, if **AuthDirListBadDirs** is set. +
+ will be listed as bad exits in any network status document this authority
+ publishes, if **AuthDirListBadExits** is set.
+
(The address pattern syntax here and in the options below
is the same as for exit policies, except that you don't need to say
"accept" or "reject", and ports are not needed.)
-[[AuthDirBadExit]] **AuthDirBadExit** __AddressPattern...__::
- Authoritative directories only. A set of address patterns for servers that
- will be listed as bad exits in any network status document this authority
- publishes, if **AuthDirListBadExits** is set.
-
[[AuthDirInvalid]] **AuthDirInvalid** __AddressPattern...__::
Authoritative directories only. A set of address patterns for servers that
will never be listed as "valid" in any network status document that this
@@ -1902,8 +1916,6 @@ on the public Tor network.
authority publishes, or accepted as an OR address in any descriptor
submitted for publication by this authority.
-[[AuthDirBadDirCCs]] **AuthDirBadDirCCs** __CC__,... +
-
[[AuthDirBadExitCCs]] **AuthDirBadExitCCs** __CC__,... +
[[AuthDirInvalidCCs]] **AuthDirInvalidCCs** __CC__,... +
@@ -1911,28 +1923,15 @@ on the public Tor network.
[[AuthDirRejectCCs]] **AuthDirRejectCCs** __CC__,...::
Authoritative directories only. These options contain a comma-separated
list of country codes such that any server in one of those country codes
- will be marked as a bad directory/bad exit/invalid for use, or rejected
+ will be marked as a bad exit/invalid for use, or rejected
entirely.
-[[AuthDirListBadDirs]] **AuthDirListBadDirs** **0**|**1**::
- Authoritative directories only. If set to 1, this directory has some
- opinion about which nodes are unsuitable as directory caches. (Do not set
- this to 1 unless you plan to list non-functioning directories as bad;
- otherwise, you are effectively voting in favor of every declared
- directory.)
-
[[AuthDirListBadExits]] **AuthDirListBadExits** **0**|**1**::
Authoritative directories only. If set to 1, this directory has some
opinion about which nodes are unsuitable as exit nodes. (Do not set this to
1 unless you plan to list non-functioning exits as bad; otherwise, you are
effectively voting in favor of every declared exit as an exit.)
-[[AuthDirRejectUnlisted]] **AuthDirRejectUnlisted** **0**|**1**::
- Authoritative directories only. If set to 1, the directory server rejects
- all uploaded server descriptors that aren't explicitly listed in the
- fingerprints file. This acts as a "panic button" if we get hit with a Sybil
- attack. (Default: 0)
-
[[AuthDirMaxServersPerAddr]] **AuthDirMaxServersPerAddr** __NUM__::
Authoritative directories only. The maximum number of servers that we will
list as acceptable on a single IP address. Set this to "0" for "no limit".
@@ -2033,7 +2032,7 @@ The following options are used to configure a hidden service.
[[HiddenServicePort]] **HiddenServicePort** __VIRTPORT__ [__TARGET__]::
Configure a virtual port VIRTPORT for a hidden service. You may use this
option multiple times; each time applies to the service using the most
- recent hiddenservicedir. By default, this option maps the virtual port to
+ recent HiddenServiceDir. By default, this option maps the virtual port to
the same port on 127.0.0.1 over TCP. You may override the target port,
address, or both by specifying a target of addr, port, or addr:port.
You may also have multiple lines with the same VIRTPORT: when a user
@@ -2198,6 +2197,15 @@ The following options are used for running a testing Tor network.
Try this often to download a v3 authority certificate before giving up.
Changing this requires that **TestingTorNetwork** is set. (Default: 8)
+[[TestingDirAuthVoteExit]] **TestingDirAuthVoteExit** __node__,__node__,__...__::
+ A list of identity fingerprints, nicknames, country codes and
+ address patterns of nodes to vote Exit for regardless of their
+ uptime, bandwidth, or exit policy. See the **ExcludeNodes**
+ option for more information on how to specify nodes.
+ +
+ In order for this option to have any effect, **TestingTorNetwork**
+ has to be set.
+
[[TestingDirAuthVoteGuard]] **TestingDirAuthVoteGuard** __node__,__node__,__...__::
A list of identity fingerprints, nicknames, country codes and
address patterns of nodes to vote Guard for regardless of their
@@ -2340,16 +2348,6 @@ __DataDirectory__**/hashed-fingerprint**::
Only used by bridges. Holds the hashed fingerprint of the bridge's
identity key. (That is, the hash of the hash of the identity key.)
-__DataDirectory__**/approved-routers**::
- Only for naming authoritative directory servers (see
- **NamingAuthoritativeDirectory**). This file lists nickname to identity
- bindings. Each line lists a nickname and a fingerprint separated by
- whitespace. See your **fingerprint** file in the __DataDirectory__ for an
- example line. If the nickname is **!reject** then descriptors from the
- given identity (fingerprint) are rejected by this server. If it is
- **!invalid** then descriptors are accepted but marked in the directory as
- not valid, that is, not recommended.
-
__DataDirectory__**/v3-status-votes**::
Only for authoritative directory servers. This file contains status votes
from all the authoritative directory servers and is used to generate the
diff --git a/scripts/README b/scripts/README
index 70c763923c..02faabe06b 100644
--- a/scripts/README
+++ b/scripts/README
@@ -56,3 +56,8 @@ for servers to choose from.
codegen/get_mozilla_ciphers.py -- Generate a list of TLS ciphersuites for
clients to use in order to look like Firefox.
+Code transformation scripts
+---------------------------
+
+coccinelle/calloc.cocci -- Transform code to replace variants of
+malloc(a*b) with calloc(a,b)
diff --git a/scripts/coccinelle/calloc.cocci b/scripts/coccinelle/calloc.cocci
new file mode 100644
index 0000000000..fbda88e538
--- /dev/null
+++ b/scripts/coccinelle/calloc.cocci
@@ -0,0 +1,23 @@
+// Use calloc or realloc as appropriate instead of multiply-and-alloc
+
+@malloc_to_calloc@
+identifier f =~ "(tor_malloc|tor_malloc_zero)";
+expression a;
+constant b;
+@@
+- f(a * b)
++ tor_calloc(a, b)
+
+@calloc_arg_order@
+expression a;
+type t;
+@@
+- tor_calloc(sizeof(t), a)
++ tor_calloc(a, sizeof(t))
+
+@realloc_to_reallocarray@
+expression a, b;
+expression p;
+@@
+- tor_realloc(p, a * b)
++ tor_reallocarray(p, a, b)
diff --git a/scripts/coccinelle/malloc_cast.cocci b/scripts/coccinelle/malloc_cast.cocci
new file mode 100644
index 0000000000..20321d4fd0
--- /dev/null
+++ b/scripts/coccinelle/malloc_cast.cocci
@@ -0,0 +1,38 @@
+@cast_malloc@
+expression e;
+type T;
+@@
+- (T *)tor_malloc(e)
++ tor_malloc(e)
+
+@cast_malloc_zero@
+expression e;
+type T;
+identifier func;
+@@
+- (T *)tor_malloc_zero(e)
++ tor_malloc_zero(e)
+
+@cast_calloc@
+expression a, b;
+type T;
+identifier func;
+@@
+- (T *)tor_calloc(a, b)
++ tor_calloc(a, b)
+
+@cast_realloc@
+expression e;
+expression p;
+type T;
+@@
+- (T *)tor_realloc(p, e)
++ tor_realloc(p, e)
+
+@cast_reallocarray@
+expression a,b;
+expression p;
+type T;
+@@
+- (T *)tor_reallocarray(p, a, b)
++ tor_reallocarray(p, a, b)
diff --git a/scripts/coccinelle/uncalloc.cocci b/scripts/coccinelle/uncalloc.cocci
new file mode 100644
index 0000000000..bf3f74165a
--- /dev/null
+++ b/scripts/coccinelle/uncalloc.cocci
@@ -0,0 +1,13 @@
+
+@@
+expression a;
+@@
+- tor_calloc(1, a)
++ tor_malloc_zero(a)
+
+@@
+expression a;
+@@
+- tor_calloc(a, 1)
++ tor_malloc_zero(a)
+
diff --git a/scripts/codegen/makedesc.py b/scripts/codegen/makedesc.py
new file mode 100644
index 0000000000..e0b2aed3f4
--- /dev/null
+++ b/scripts/codegen/makedesc.py
@@ -0,0 +1,218 @@
+#!/usr/bin/python
+# Copyright 2014, The Tor Project, Inc.
+# See LICENSE for license information
+
+# This is a kludgey python script that uses ctypes and openssl to sign
+# router descriptors and extrainfo documents and put all the keys in
+# the right places. There are examples at the end of the file.
+
+# I've used this to make inputs for unit tests. I wouldn't suggest
+# using it for anything else.
+
+import base64
+import binascii
+import ctypes
+import ctypes.util
+import hashlib
+
+crypt = ctypes.CDLL(ctypes.util.find_library('crypto'))
+BIO_s_mem = crypt.BIO_s_mem
+BIO_s_mem.argtypes = []
+BIO_s_mem.restype = ctypes.c_void_p
+
+BIO_new = crypt.BIO_new
+BIO_new.argtypes = [ctypes.c_void_p]
+BIO_new.restype = ctypes.c_void_p
+
+RSA_generate_key = crypt.RSA_generate_key
+RSA_generate_key.argtypes = [ctypes.c_int, ctypes.c_ulong, ctypes.c_void_p, ctypes.c_void_p]
+RSA_generate_key.restype = ctypes.c_void_p
+
+RSA_private_encrypt = crypt.RSA_private_encrypt
+RSA_private_encrypt.argtypes = [
+ ctypes.c_int, ctypes.c_char_p, ctypes.c_void_p, ctypes.c_void_p, ctypes.c_int ]
+RSA_private_encrypt.restype = ctypes.c_int
+
+i2d_RSAPublicKey = crypt.i2d_RSAPublicKey
+i2d_RSAPublicKey.argtypes = [
+ ctypes.c_void_p, ctypes.POINTER(ctypes.c_char_p)
+]
+i2d_RSAPublicKey.restype = ctypes.c_int
+
+def b64(x):
+ x = base64.b64encode(x)
+ res = []
+ for i in xrange(0, len(x), 64):
+ res.append(x[i:i+64]+"\n")
+ return "".join(res)
+
+def bio_extract(bio):
+ buf = ctypes.c_char_p()
+ length = crypt.BIO_ctrl(bio, 3, 0, ctypes.byref(buf))
+ return ctypes.string_at(buf, length)
+
+def make_key(e=65537):
+ rsa = crypt.RSA_generate_key(1024, e, None, None)
+ bio = BIO_new(BIO_s_mem())
+ crypt.PEM_write_bio_RSAPublicKey(bio, rsa)
+ pem = bio_extract(bio).rstrip()
+ crypt.BIO_free(bio)
+
+ buf = ctypes.create_string_buffer(1024)
+ pBuf = ctypes.c_char_p(ctypes.addressof(buf))
+ n = crypt.i2d_RSAPublicKey(rsa, ctypes.byref(pBuf))
+ s = buf.raw[:n]
+ digest = hashlib.sha1(s).digest()
+
+ return (rsa,pem,digest)
+
+def signdesc(body, args_out=None):
+ rsa, ident_pem, id_digest = make_key()
+ _, onion_pem, _ = make_key()
+
+ hexdigest = binascii.b2a_hex(id_digest).upper()
+ fingerprint = " ".join(hexdigest[i:i+4] for i in range(0,len(hexdigest),4))
+
+ MAGIC = "<<<<<<MAGIC>>>>>>"
+ args = {
+ "RSA-IDENTITY" : ident_pem,
+ "ONION-KEY" : onion_pem,
+ "FINGERPRINT" : fingerprint,
+ "FINGERPRINT-NOSPACE" : hexdigest,
+ "RSA-SIGNATURE" : MAGIC
+ }
+ if args_out:
+ args_out.update(args)
+ body = body.format(**args)
+
+ idx = body.rindex("\nrouter-signature")
+ end_of_sig = body.index("\n", idx+1)
+
+ signed_part = body[:end_of_sig+1]
+
+ digest = hashlib.sha1(signed_part).digest()
+ assert len(digest) == 20
+
+ buf = ctypes.create_string_buffer(1024)
+ n = RSA_private_encrypt(20, digest, buf, rsa, 1)
+ sig = buf.raw[:n]
+
+ sig = """-----BEGIN SIGNATURE-----
+%s
+-----END SIGNATURE-----""" % b64(sig).rstrip()
+ body = body.replace(MAGIC, sig)
+
+ return body.rstrip()
+
+def emit_ri(name, body, args_out=None):
+ print "const char %s[] ="%name
+ body = "\n".join(line.rstrip() for line in body.split("\n"))+"\n"
+ b = signdesc(body, args_out)
+ for line in b.split("\n"):
+ print ' "%s\\n"'%line
+ print " ;"
+
+def emit_ei(name, body):
+ args = { 'NAME' : name }
+ emit_ri(name, body, args)
+ args['key'] = "\n".join(
+ ' "%s\\n"'%line for line in args['RSA-IDENTITY'].split("\n"))
+ print """
+const char {NAME}_fp[] = "{FINGERPRINT-NOSPACE}";
+const char {NAME}_key[] =
+{key};""".format(**args)
+
+if 0:
+ emit_ri("minimal",
+ """\
+router fred 127.0.0.1 9001 0 9002
+signing-key
+{RSA-IDENTITY}
+onion-key
+{ONION-KEY}
+published 2014-10-05 12:00:00
+bandwidth 1000 1000 1000
+reject *:*
+router-signature
+{RSA-SIGNATURE}
+""")
+
+if 0:
+ emit_ri("maximal",
+ """\
+router fred 127.0.0.1 9001 0 9002
+signing-key
+{RSA-IDENTITY}
+onion-key
+{ONION-KEY}
+published 2014-10-05 12:00:00
+bandwidth 1000 1000 1000
+reject 127.0.0.1:*
+accept *:80
+reject *:*
+ipv6-policy accept 80,100,101
+ntor-onion-key s7rSohmz9SXn8WWh1EefTHIsWePthsEntQi0WL+ScVw
+uptime 1000
+hibernating 0
+unrecognized-keywords are just dandy in this format
+platform Tor 0.2.4.23 on a Banana PC Jr 6000 Series
+contact O.W.Jones
+fingerprint {FINGERPRINT}
+read-history 900 1,2,3,4
+write-history 900 1,2,3,4
+extra-info-digest AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+hidden-service-dir
+allow-single-hop-exits
+family $AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA $BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+caches-extra-info
+or-address [::1:2:3:4]:9999
+or-address 127.0.0.99:10000
+opt fred is a fine router
+router-signature
+{RSA-SIGNATURE}
+""")
+
+if 0:
+ emit_ei("maximal",
+"""\
+extra-info bob {FINGERPRINT-NOSPACE}
+published 2014-10-05 20:07:00
+opt foobarbaz
+read-history 900 1,2,3
+write-history 900 1,2,3
+dirreq-v2-ips 1
+dirreq-v3-ips 100
+dirreq-v3-reqs blahblah
+dirreq-v2-share blahblah
+dirreq-v3-share blahblah
+dirreq-v2-resp djfkdj
+dirreq-v3-resp djfkdj
+dirreq-v2-direct-dl djfkdj
+dirreq-v3-direct-dl djfkdj
+dirreq-v2-tunneled-dl djfkdj
+dirreq-v3-tunneled-dl djfkdj
+dirreq-stats-end foobar
+entry-ips jfsdfds
+entry-stats-end ksdflkjfdkf
+cell-stats-end FOO
+cell-processed-cells FOO
+cell-queued-cells FOO
+cell-time-in-queue FOO
+cell-circuits-per-decile FOO
+exit-stats-end FOO
+exit-kibibytes-written FOO
+exit-kibibytes-read FOO
+exit-streams-opened FOO
+router-signature
+{RSA-SIGNATURE}
+""")
+
+if 0:
+ emit_ei("minimal",
+"""\
+extra-info bob {FINGERPRINT-NOSPACE}
+published 2014-10-05 20:07:00
+router-signature
+{RSA-SIGNATURE}
+""")
+
diff --git a/scripts/codegen/run_trunnel.sh b/scripts/codegen/run_trunnel.sh
new file mode 100755
index 0000000000..5f694ce6c9
--- /dev/null
+++ b/scripts/codegen/run_trunnel.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+if test "x$TRUNNEL_PATH" != "x"; then
+ PYTHONPATH="${TRUNNEL_PATH}:${PYTHONPATH}"
+ export PYTHONPATH
+fi
+
+python -m trunnel --require-version=1.2 ./src/trunnel/*.trunnel
+
+python -m trunnel --require-version=1.2 --write-c-files --target-dir=./src/ext/trunnel/
+
diff --git a/scripts/maint/checkSpace.pl b/scripts/maint/checkSpace.pl
index 682dbced00..b529103367 100755
--- a/scripts/maint/checkSpace.pl
+++ b/scripts/maint/checkSpace.pl
@@ -13,30 +13,45 @@ for $fn (@ARGV) {
$incomment = 0;
while (<F>) {
## Warn about windows-style newlines.
+ # (We insist on lines that end with a single LF character, not
+ # CR LF.)
if (/\r/) {
print " CR:$fn:$.\n";
}
## Warn about tabs.
+ # (We only use spaces)
if (/\t/) {
print " TAB:$fn:$.\n";
}
- ## Warn about markers that don't have a space in front of them
+ ## Warn about labels that don't have a space in front of them
+ # (We indent every label at least one space)
if (/^[a-zA-Z_][a-zA-Z_0-9]*:/) {
print "nosplabel:$fn:$.\n";
}
## Warn about trailing whitespace.
+ # (We don't allow whitespace at the end of the line; make your
+ # editor highlight it for you so you can stop adding it in.)
if (/ +$/) {
print "Space\@EOL:$fn:$.\n";
}
## Warn about control keywords without following space.
+ # (We put a space after every 'if', 'while', 'for', 'switch', etc)
if ($C && /\s(?:if|while|for|switch)\(/) {
print " KW(:$fn:$.\n";
}
## Warn about #else #if instead of #elif.
+ # (We only allow #elif)
if (($lastline =~ /^\# *else/) and ($_ =~ /^\# *if/)) {
print " #else#if:$fn:$.\n";
}
## Warn about some K&R violations
+ # (We use K&R-style C, where open braces go on the same line as
+ # the statement that introduces them. In other words:
+ # if (a) {
+ # stuff;
+ # } else {
+ # other stuff;
+ # }
if (/^\s+\{/ and $lastline =~ /^\s*(if|while|for|else if)/ and
$lastline !~ /\{$/) {
print "non-K&R {:$fn:$.\n";
@@ -46,10 +61,13 @@ for $fn (@ARGV) {
}
$lastline = $_;
## Warn about unnecessary empty lines.
+ # (Don't put an empty line before a line that contains nothing
+ # but a closing brace.)
if ($lastnil && /^\s*}\n/) {
print " UnnecNL:$fn:$.\n";
}
## Warn about multiple empty lines.
+ # (At most one blank line in a row.)
if ($lastnil && /^$/) {
print " DoubleNL:$fn:$.\n";
} elsif (/^$/) {
@@ -59,6 +77,7 @@ for $fn (@ARGV) {
}
## Terminals are still 80 columns wide in my world. I refuse to
## accept double-line lines.
+ # (Don't make lines wider than 80 characters, including newline.)
if (/^.{80}/) {
print " Wide:$fn:$.\n";
}
@@ -83,11 +102,13 @@ for $fn (@ARGV) {
s!"(?:[^\"]+|\\.)*"!"X"!g;
next if /^\#/;
## Warn about C++-style comments.
+ # (Use C style comments only.)
if (m!//!) {
# print " //:$fn:$.\n";
s!//.*!!;
}
## Warn about unquoted braces preceded by non-space.
+ # (No character except a space should come before a {)
if (/([^\s'])\{/) {
print " $1\{:$fn:$.\n";
}
@@ -101,6 +122,8 @@ for $fn (@ARGV) {
# print " {X:$fn:$.\n";
#}
## Warn about function calls with space before parens.
+ # (Don't put a space between the name of a function and its
+ # arguments.)
if (/(\w+)\s\(([A-Z]*)/) {
if ($1 ne "if" and $1 ne "while" and $1 ne "for" and
$1 ne "switch" and $1 ne "return" and $1 ne "int" and
@@ -110,6 +133,9 @@ for $fn (@ARGV) {
}
}
## Warn about functions not declared at start of line.
+ # (When you're declaring functions, put "static" and "const"
+ # and the return type on one line, and the function name at
+ # the start of a new line.)
if ($in_func_head ||
($fn !~ /\.h$/ && /^[a-zA-Z0-9_]/ &&
! /^(?:const |static )*(?:typedef|struct|union)[^\(]*$/ &&
@@ -130,6 +156,8 @@ for $fn (@ARGV) {
}
}
}
+ ## Warn if the file doesn't end with a blank line.
+ # (End each file with a single blank line.)
if (! $lastnil) {
print " EOL\@EOF:$fn:$.\n";
}
diff --git a/scripts/maint/format_changelog.py b/scripts/maint/format_changelog.py
index f67e89b602..3fe5161433 100755
--- a/scripts/maint/format_changelog.py
+++ b/scripts/maint/format_changelog.py
@@ -12,6 +12,7 @@
import os
import re
import sys
+import optparse
# ==============================
# Oh, look! It's a cruddy approximation to Knuth's elegant text wrapping
@@ -33,6 +34,9 @@ import sys
NO_HYPHENATE=set("""
pf-divert
+tor-resolve
+tor-gencert
+tor-fw-helper
""".split())
LASTLINE_UNDERFLOW_EXPONENT = 1
@@ -115,7 +119,10 @@ def wrap_graf(words, prefix_len1=0, prefix_len2=0, width=72):
return lines
-def hyphenateable(word):
+def hyphenatable(word):
+ if "--" in word:
+ return False
+
if re.match(r'^[^\d\-]\D*-', word):
stripped = re.sub(r'^\W+','',word)
stripped = re.sub(r'\W+$','',word)
@@ -128,7 +135,7 @@ def split_paragraph(s):
r = []
for word in s.split():
- if hyphenateable(word):
+ if hyphenatable(word):
while "-" in word:
a,word = word.split("-",1)
r.append(a+"\xff")
@@ -156,10 +163,13 @@ TP_SECHEAD = 3
TP_ITEMFIRST = 4
TP_ITEMBODY = 5
TP_END = 6
+TP_PREHEAD = 7
def head_parser(line):
- if re.match(r'^[A-Z]', line):
+ if re.match(r'^Changes in', line):
return TP_MAINHEAD
+ elif re.match(r'^[A-Za-z]', line):
+ return TP_PREHEAD
elif re.match(r'^ o ', line):
return TP_SECHEAD
elif re.match(r'^\s*$', line):
@@ -178,17 +188,67 @@ def body_parser(line):
return TP_BLANK
elif re.match(r'^Changes in', line):
return TP_END
+ elif re.match(r'^\s+\S', line):
+ return TP_HEADTEXT
else:
print "Weird line %r"%line
+def clean_head(head):
+ return head
+
+def head_score(s):
+ m = re.match(r'^ +o (.*)', s)
+ if not m:
+ print >>sys.stderr, "Can't score %r"%s
+ return 99999
+ lw = m.group(1).lower()
+ if lw.startswith("security") and "feature" not in lw:
+ score = -300
+ elif lw.startswith("deprecated version"):
+ score = -200
+ elif (('new' in lw and 'requirement' in lw) or
+ ('new' in lw and 'dependenc' in lw) or
+ ('build' in lw and 'requirement' in lw) or
+ ('removed' in lw and 'platform' in lw)):
+ score = -100
+ elif lw.startswith("major feature"):
+ score = 00
+ elif lw.startswith("major bug"):
+ score = 50
+ elif lw.startswith("major"):
+ score = 70
+ elif lw.startswith("minor feature"):
+ score = 200
+ elif lw.startswith("minor bug"):
+ score = 250
+ elif lw.startswith("minor"):
+ score = 270
+ else:
+ score = 1000
+
+ if 'secur' in lw:
+ score -= 2
+
+ if "(other)" in lw:
+ score += 2
+
+ if '(' not in lw:
+ score -= 1
+
+ return score
+
class ChangeLog(object):
- def __init__(self):
+ def __init__(self, wrapText=True, blogOrder=True, drupalBreak=False):
+ self.prehead = []
self.mainhead = None
self.headtext = []
self.curgraf = None
self.sections = []
self.cursection = None
self.lineno = 0
+ self.wrapText = wrapText
+ self.blogOrder = blogOrder
+ self.drupalBreak = drupalBreak
def addLine(self, tp, line):
self.lineno += 1
@@ -197,6 +257,9 @@ class ChangeLog(object):
assert not self.mainhead
self.mainhead = line
+ elif tp == TP_PREHEAD:
+ self.prehead.append(line)
+
elif tp == TP_HEADTEXT:
if self.curgraf is None:
self.curgraf = []
@@ -240,6 +303,11 @@ class ChangeLog(object):
self.lint_item(item_line, grafs, head_type)
def dumpGraf(self,par,indent1,indent2=-1):
+ if not self.wrapText:
+ for line in par:
+ print line
+ return
+
if indent2 == -1:
indent2 = indent1
text = " ".join(re.sub(r'\s+', ' ', line.strip()) for line in par)
@@ -249,38 +317,210 @@ class ChangeLog(object):
initial_indent=" "*indent1,
subsequent_indent=" "*indent2))
+ def dumpPreheader(self, graf):
+ self.dumpGraf(graf, 0)
+ print
+
+ def dumpMainhead(self, head):
+ print head
+
+ def dumpHeadGraf(self, graf):
+ self.dumpGraf(graf, 2)
+ print
+
+ def dumpSectionHeader(self, header):
+ print header
+
+ def dumpStartOfSections(self):
+ pass
+
+ def dumpEndOfSections(self):
+ pass
+
+ def dumpEndOfSection(self):
+ print
+
+ def dumpEndOfChangelog(self):
+ print
+
+ def dumpDrupalBreak(self):
+ pass
+
+ def dumpItem(self, grafs):
+ self.dumpGraf(grafs[0],4,6)
+ for par in grafs[1:]:
+ print
+ self.dumpGraf(par,6,6)
+
+ def collateAndSortSections(self):
+ heads = []
+ sectionsByHead = { }
+ for _, head, items in self.sections:
+ head = clean_head(head)
+ try:
+ s = sectionsByHead[head]
+ except KeyError:
+ s = sectionsByHead[head] = []
+ heads.append( (head_score(head), head.lower(), head, s) )
+
+ s.extend(items)
+
+ heads.sort()
+ self.sections = [ (0, head, items) for _1,_2,head,items in heads ]
+
def dump(self):
- print self.mainhead
+ if self.prehead:
+ self.dumpPreheader(self.prehead)
+
+ if not self.blogOrder:
+ self.dumpMainhead(self.mainhead)
+
for par in self.headtext:
- self.dumpGraf(par, 2)
- print
+ self.dumpHeadGraf(par)
+
+ if self.blogOrder:
+ self.dumpMainhead(self.mainhead)
+
+ drupalBreakAfter = None
+ if self.drupalBreak and len(self.sections) > 4:
+ drupalBreakAfter = self.sections[1][2]
+
+ self.dumpStartOfSections()
for _,head,items in self.sections:
if not head.endswith(':'):
print >>sys.stderr, "adding : to %r"%head
head = head + ":"
- print head
+ self.dumpSectionHeader(head)
for _,grafs in items:
- self.dumpGraf(grafs[0],4,6)
- for par in grafs[1:]:
- print
- self.dumpGraf(par,6,6)
- print
- print
+ self.dumpItem(grafs)
+ self.dumpEndOfSection()
+ if items is drupalBreakAfter:
+ self.dumpDrupalBreak()
+ self.dumpEndOfSections()
+ self.dumpEndOfChangelog()
+
+class HTMLChangeLog(ChangeLog):
+ def __init__(self, *args, **kwargs):
+ ChangeLog.__init__(self, *args, **kwargs)
+
+ def htmlText(self, graf):
+ for line in graf:
+ line = line.rstrip().replace("&","&amp;")
+ line = line.rstrip().replace("<","&lt;").replace(">","&gt;")
+ sys.stdout.write(line.strip())
+ sys.stdout.write(" ")
+
+ def htmlPar(self, graf):
+ sys.stdout.write("<p>")
+ self.htmlText(graf)
+ sys.stdout.write("</p>\n")
+
+ def dumpPreheader(self, graf):
+ self.htmlPar(graf)
+
+ def dumpMainhead(self, head):
+ sys.stdout.write("<h2>%s</h2>"%head)
+
+ def dumpHeadGraf(self, graf):
+ self.htmlPar(graf)
+
+ def dumpSectionHeader(self, header):
+ header = header.replace(" o ", "", 1).lstrip()
+ sys.stdout.write(" <li>%s\n"%header)
+ sys.stdout.write(" <ul>\n")
+
+ def dumpEndOfSection(self):
+ sys.stdout.write(" </ul>\n\n")
+
+ def dumpEndOfChangelog(self):
+ pass
-CL = ChangeLog()
-parser = head_parser
+ def dumpStartOfSections(self):
+ print "<ul>\n"
+
+ def dumpEndOfSections(self):
+ print "</ul>\n"
-if len(sys.argv) == 1:
+ def dumpDrupalBreak(self):
+ print "\n</ul>\n"
+ print "<p>&nbsp;</p>"
+ print "\n<!--break-->\n\n"
+ print "<ul>"
+
+ def dumpItem(self, grafs):
+ grafs[0][0] = grafs[0][0].replace(" - ", "", 1).lstrip()
+ sys.stdout.write(" <li>")
+ if len(grafs) > 1:
+ for par in grafs:
+ self.htmlPar(par)
+ else:
+ self.htmlText(grafs[0])
+ print
+
+op = optparse.OptionParser(usage="usage: %prog [options] [filename]")
+op.add_option('-W', '--no-wrap', action='store_false',
+ dest='wrapText', default=True,
+ help='Do not re-wrap paragraphs')
+op.add_option('-S', '--no-sort', action='store_false',
+ dest='sort', default=True,
+ help='Do not sort or collate sections')
+op.add_option('-o', '--output', dest='output',
+ default='-', metavar='FILE', help="write output to FILE")
+op.add_option('-H', '--html', action='store_true',
+ dest='html', default=False,
+ help="generate an HTML fragment")
+op.add_option('-1', '--first', action='store_true',
+ dest='firstOnly', default=False,
+ help="write only the first section")
+op.add_option('-b', '--blog-header', action='store_true',
+ dest='blogOrder', default=False,
+ help="Write the header in blog order")
+op.add_option('-B', '--blog', action='store_true',
+ dest='blogFormat', default=False,
+ help="Set all other options as appropriate for a blog post")
+op.add_option('--inplace', action='store_true',
+ dest='inplace', default=False,
+ help="Alter the ChangeLog in place")
+op.add_option('--drupal-break', action='store_true',
+ dest='drupalBreak', default=False,
+ help='Insert a drupal-friendly <!--break--> as needed')
+
+options,args = op.parse_args()
+
+if options.blogFormat:
+ options.blogOrder = True
+ options.html = True
+ options.sort = False
+ options.wrapText = False
+ options.firstOnly = True
+ options.drupalBreak = True
+
+if len(args) > 1:
+ op.error("Too many arguments")
+elif len(args) == 0:
fname = 'ChangeLog'
else:
- fname = sys.argv[1]
+ fname = args[0]
-fname_new = fname+".new"
+if options.inplace:
+ assert options.output == '-'
+ options.output = fname
-sys.stdin = open(fname, 'r')
+if fname != '-':
+ sys.stdin = open(fname, 'r')
nextline = None
+if options.html:
+ ChangeLogClass = HTMLChangeLog
+else:
+ ChangeLogClass = ChangeLog
+
+CL = ChangeLogClass(wrapText=options.wrapText,
+ blogOrder=options.blogOrder,
+ drupalBreak=options.drupalBreak)
+parser = head_parser
+
for line in sys.stdin:
line = line.rstrip()
tp = parser(line)
@@ -295,14 +535,26 @@ for line in sys.stdin:
CL.lint()
-sys.stdout = open(fname_new, 'w')
+if options.output != '-':
+ fname_new = options.output+".new"
+ fname_out = options.output
+ sys.stdout = open(fname_new, 'w')
+else:
+ fname_new = fname_out = None
+
+if options.sort:
+ CL.collateAndSortSections()
CL.dump()
+if options.firstOnly:
+ sys.exit(0)
+
if nextline is not None:
print nextline
for line in sys.stdin:
sys.stdout.write(line)
-os.rename(fname_new, fname)
+if fname_new is not None:
+ os.rename(fname_new, fname_out)
diff --git a/scripts/test/cov-diff b/scripts/test/cov-diff
index 33a54802b6..48dbec9d54 100755
--- a/scripts/test/cov-diff
+++ b/scripts/test/cov-diff
@@ -9,8 +9,8 @@ DIRB="$2"
for A in $DIRA/*; do
B=$DIRB/`basename $A`
- perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$A" > "$A.tmp"
- perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/;' "$B" > "$B.tmp"
+ perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/; s/^ *-:(Runs|Programs):.*//;' "$A" > "$A.tmp"
+ perl -pe 's/^\s*\d+:/ 1:/; s/^([^:]+:)[\d\s]+:/$1/; s/^ *-:(Runs|Programs):.*//;' "$B" > "$B.tmp"
diff -u "$A.tmp" "$B.tmp"
rm "$A.tmp" "$B.tmp"
done
diff --git a/src/common/Makefile.nmake b/src/common/Makefile.nmake
index 0ebeaaaf71..b8c5dd4fea 100644
--- a/src/common/Makefile.nmake
+++ b/src/common/Makefile.nmake
@@ -1,12 +1,13 @@
all: libor.lib libor-crypto.lib libor-event.lib
-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\ext
+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
+ /I ..\ext
-LIBOR_OBJECTS = address.obj compat.obj container.obj di_ops.obj \
- log.obj memarea.obj mempool.obj procmon.obj util.obj \
+LIBOR_OBJECTS = address.obj backtrace.obj compat.obj container.obj di_ops.obj \
+ log.obj memarea.obj mempool.obj procmon.obj sandbox.obj util.obj \
util_codedigest.obj
-LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj torgzip.obj tortls.obj \
+LIBOR_CRYPTO_OBJECTS = aes.obj crypto.obj crypto_format.obj torgzip.obj tortls.obj \
crypto_curve25519.obj curve25519-donna.obj
LIBOR_EVENT_OBJECTS = compat_libevent.obj
diff --git a/src/common/address.c b/src/common/address.c
index 29d4c0447e..de5d3a6ff7 100644
--- a/src/common/address.c
+++ b/src/common/address.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -323,15 +323,23 @@ tor_addr_is_internal_(const tor_addr_t *addr, int for_listening,
{
uint32_t iph4 = 0;
uint32_t iph6[4];
- sa_family_t v_family;
- v_family = tor_addr_family(addr);
+
+ tor_assert(addr);
+ sa_family_t v_family = tor_addr_family(addr);
if (v_family == AF_INET) {
iph4 = tor_addr_to_ipv4h(addr);
} else if (v_family == AF_INET6) {
if (tor_addr_is_v4(addr)) { /* v4-mapped */
+ uint32_t *addr32 = NULL;
v_family = AF_INET;
- iph4 = ntohl(tor_addr_to_in6_addr32(addr)[3]);
+ // Work around an incorrect NULL pointer dereference warning in
+ // "clang --analyze" due to limited analysis depth
+ addr32 = tor_addr_to_in6_addr32(addr);
+ // To improve performance, wrap this assertion in:
+ // #if !defined(__clang_analyzer__) || PARANOIA
+ tor_assert(addr32);
+ iph4 = ntohl(addr32[3]);
}
}
@@ -463,7 +471,6 @@ tor_addr_parse_PTR_name(tor_addr_t *result, const char *address,
if (!strcasecmpend(address, ".ip6.arpa")) {
const char *cp;
- int i;
int n0, n1;
struct in6_addr in6;
@@ -471,7 +478,7 @@ tor_addr_parse_PTR_name(tor_addr_t *result, const char *address,
return -1;
cp = address;
- for (i = 0; i < 16; ++i) {
+ for (int i = 0; i < 16; ++i) {
n0 = hex_decode_digit(*cp++); /* The low-order nybble appears first. */
if (*cp++ != '.') return -1; /* Then a dot. */
n1 = hex_decode_digit(*cp++); /* The high-order nybble appears first. */
@@ -596,7 +603,7 @@ tor_addr_parse_mask_ports(const char *s,
int any_flag=0, v4map=0;
sa_family_t family;
struct in6_addr in6_tmp;
- struct in_addr in_tmp;
+ struct in_addr in_tmp = { .s_addr = 0 };
tor_assert(s);
tor_assert(addr_out);
@@ -657,7 +664,7 @@ tor_addr_parse_mask_ports(const char *s,
tor_addr_from_ipv4h(addr_out, 0);
any_flag = 1;
} else if (!strcmp(address, "*6") && (flags & TAPMP_EXTENDED_STAR)) {
- static char nil_bytes[16] = { 0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
+ static char nil_bytes[16] = { [0]=0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0 };
family = AF_INET6;
tor_addr_from_ipv6_bytes(addr_out, nil_bytes);
any_flag = 1;
@@ -876,7 +883,7 @@ tor_addr_copy(tor_addr_t *dest, const tor_addr_t *src)
memcpy(dest, src, sizeof(tor_addr_t));
}
-/** Copy a tor_addr_t from <b>src</b> to <b>dest</b>, taking extra case to
+/** Copy a tor_addr_t from <b>src</b> to <b>dest</b>, taking extra care to
* copy only the well-defined portions. Used for computing hashes of
* addresses.
*/
diff --git a/src/common/address.h b/src/common/address.h
index 8dc63b71c1..e8bab223a7 100644
--- a/src/common/address.h
+++ b/src/common/address.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -103,7 +103,18 @@ tor_addr_to_ipv4h(const tor_addr_t *a)
static INLINE uint32_t
tor_addr_to_mapped_ipv4h(const tor_addr_t *a)
{
- return a->family == AF_INET6 ? ntohl(tor_addr_to_in6_addr32(a)[3]) : 0;
+ if (a->family == AF_INET6) {
+ uint32_t *addr32 = NULL;
+ // Work around an incorrect NULL pointer dereference warning in
+ // "clang --analyze" due to limited analysis depth
+ addr32 = tor_addr_to_in6_addr32(a);
+ // To improve performance, wrap this assertion in:
+ // #if !defined(__clang_analyzer__) || PARANOIA
+ tor_assert(addr32);
+ return ntohl(addr32[3]);
+ } else {
+ return 0;
+ }
}
/** Return the address family of <b>a</b>. Possible values are:
* AF_INET6, AF_INET, AF_UNSPEC. */
diff --git a/src/common/aes.c b/src/common/aes.c
index f454a7f7b2..877dce625c 100644
--- a/src/common/aes.c
+++ b/src/common/aes.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/common/aes.h b/src/common/aes.h
index 8ff28a7622..f014e3a424 100644
--- a/src/common/aes.h
+++ b/src/common/aes.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Implements a minimal interface to counter-mode AES. */
diff --git a/src/common/backtrace.c b/src/common/backtrace.c
index 3a073a8ff5..e6fb8938ac 100644
--- a/src/common/backtrace.c
+++ b/src/common/backtrace.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define __USE_GNU
diff --git a/src/common/backtrace.h b/src/common/backtrace.h
index 1f4d73339f..4938745b3d 100644
--- a/src/common/backtrace.h
+++ b/src/common/backtrace.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_BACKTRACE_H
diff --git a/src/common/compat.c b/src/common/compat.c
index dcdf78d49f..8574bd04c9 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -77,6 +77,7 @@
/* Includes for the process attaching prevention */
#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__)
+/* Only use the linux prctl; the IRIX prctl is totally different */
#include <sys/prctl.h>
#elif defined(__APPLE__)
#include <sys/types.h>
@@ -110,10 +111,6 @@
#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
#endif
-#if defined(HAVE_SYS_PRCTL_H) && defined(__linux__)
-/* Only use the linux prctl; the IRIX prctl is totally different */
-#include <sys/prctl.h>
-#endif
#ifdef TOR_UNIT_TESTS
#if !defined(HAVE_USLEEP) && defined(HAVE_SYS_SELECT_H)
/* as fallback implementation for tor_sleep_msec */
@@ -141,9 +138,10 @@ int
tor_open_cloexec(const char *path, int flags, unsigned mode)
{
int fd;
+ const char *p = path;
#ifdef O_CLOEXEC
- path = sandbox_intern_string(path);
- fd = open(path, flags|O_CLOEXEC, mode);
+ p = sandbox_intern_string(path);
+ fd = open(p, flags|O_CLOEXEC, mode);
if (fd >= 0)
return fd;
/* If we got an error, see if it is EINVAL. EINVAL might indicate that,
@@ -153,8 +151,8 @@ tor_open_cloexec(const char *path, int flags, unsigned mode)
return -1;
#endif
- log_debug(LD_FS, "Opening %s with flags %x", path, flags);
- fd = open(path, flags, mode);
+ log_debug(LD_FS, "Opening %s with flags %x", p, flags);
+ fd = open(p, flags, mode);
#ifdef FD_CLOEXEC
if (fd >= 0) {
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
@@ -981,14 +979,23 @@ tor_fd_getpos(int fd)
#endif
}
-/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success. */
+/** Move <b>fd</b> to the end of the file. Return -1 on error, 0 on success.
+ * If the file is a pipe, do nothing and succeed.
+ **/
int
tor_fd_seekend(int fd)
{
#ifdef _WIN32
return _lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
#else
- return lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+ off_t rc = lseek(fd, 0, SEEK_END) < 0 ? -1 : 0;
+#ifdef ESPIPE
+ /* If we get an error and ESPIPE, then it's a pipe or a socket of a fifo:
+ * no need to worry. */
+ if (rc < 0 && errno == ESPIPE)
+ rc = 0;
+#endif
+ return (rc < 0) ? -1 : 0;
#endif
}
@@ -1426,6 +1433,9 @@ tor_ersatz_socketpair(int family, int type, int protocol, tor_socket_t fd[2])
socklen_t size;
int saved_errno = -1;
+ memset(&connect_addr, 0, sizeof(connect_addr));
+ memset(&listen_addr, 0, sizeof(listen_addr));
+
if (protocol
#ifdef AF_UNIX
|| family != AF_UNIX
@@ -1687,12 +1697,12 @@ log_credential_status(void)
/* log supplementary groups */
sup_gids_size = 64;
- sup_gids = tor_malloc(sizeof(gid_t) * 64);
+ sup_gids = tor_calloc(64, sizeof(gid_t));
while ((ngids = getgroups(sup_gids_size, sup_gids)) < 0 &&
errno == EINVAL &&
sup_gids_size < NGROUPS_MAX) {
sup_gids_size *= 2;
- sup_gids = tor_realloc(sup_gids, sizeof(gid_t) * sup_gids_size);
+ sup_gids = tor_reallocarray(sup_gids, sizeof(gid_t), sup_gids_size);
}
if (ngids < 0) {
@@ -2758,14 +2768,24 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
const char *outcome;
if (PREDICT_LIKELY(r)) {
- if (r->tm_year > 8099) { /* We can't strftime dates after 9999 CE. */
+ /* We can't strftime dates after 9999 CE, and we want to avoid dates
+ * before 1 CE (avoiding the year 0 issue and negative years). */
+ if (r->tm_year > 8099) {
r->tm_year = 8099;
r->tm_mon = 11;
r->tm_mday = 31;
- r->tm_yday = 365;
+ r->tm_yday = 364;
r->tm_hour = 23;
r->tm_min = 59;
r->tm_sec = 59;
+ } else if (r->tm_year < (1-1900)) {
+ r->tm_year = (1-1900);
+ r->tm_mon = 0;
+ r->tm_mday = 1;
+ r->tm_yday = 0;
+ r->tm_hour = 0;
+ r->tm_min = 0;
+ r->tm_sec = 0;
}
return r;
}
@@ -2779,7 +2799,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
r->tm_year = 70; /* 1970 CE */
r->tm_mon = 0;
r->tm_mday = 1;
- r->tm_yday = 1;
+ r->tm_yday = 0;
r->tm_hour = 0;
r->tm_min = 0 ;
r->tm_sec = 0;
@@ -2792,7 +2812,7 @@ correct_tm(int islocal, const time_t *timep, struct tm *resultbuf,
r->tm_year = 137; /* 2037 CE */
r->tm_mon = 11;
r->tm_mday = 31;
- r->tm_yday = 365;
+ r->tm_yday = 364;
r->tm_hour = 23;
r->tm_min = 59;
r->tm_sec = 59;
@@ -2861,7 +2881,7 @@ tor_localtime_r(const time_t *timep, struct tm *result)
/** @} */
/** @{ */
-/** As gmtimee_r, but defined for platforms that don't have it:
+/** As gmtime_r, but defined for platforms that don't have it:
*
* Convert *<b>timep</b> to a struct tm in UTC, and store the value in
* *<b>result</b>. Return the result on success, or NULL on failure.
@@ -3554,12 +3574,12 @@ get_total_system_memory(size_t *mem_out)
return 0;
}
-#if SIZE_T_MAX != UINT64_MAX
- if (m > SIZE_T_MAX) {
+#if SIZE_MAX != UINT64_MAX
+ if (m > SIZE_MAX) {
/* I think this could happen if we're a 32-bit Tor running on a 64-bit
* system: we could have more system memory than would fit in a
* size_t. */
- m = SIZE_T_MAX;
+ m = SIZE_MAX;
}
#endif
diff --git a/src/common/compat.h b/src/common/compat.h
index 852a432187..f2eef5b6e7 100644
--- a/src/common/compat.h
+++ b/src/common/compat.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_COMPAT_H
@@ -562,17 +562,18 @@ const char *tor_socket_strerror(int e);
#else
#define SOCK_ERRNO(e) e
#if EAGAIN == EWOULDBLOCK
-#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN)
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || 0)
#else
#define ERRNO_IS_EAGAIN(e) ((e) == EAGAIN || (e) == EWOULDBLOCK)
#endif
-#define ERRNO_IS_EINPROGRESS(e) ((e) == EINPROGRESS)
-#define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS)
+#define ERRNO_IS_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
+#define ERRNO_IS_CONN_EINPROGRESS(e) ((e) == EINPROGRESS || 0)
#define ERRNO_IS_ACCEPT_EAGAIN(e) \
(ERRNO_IS_EAGAIN(e) || (e) == ECONNABORTED)
#define ERRNO_IS_ACCEPT_RESOURCE_LIMIT(e) \
((e) == EMFILE || (e) == ENFILE || (e) == ENOBUFS || (e) == ENOMEM)
-#define ERRNO_IS_EADDRINUSE(e) ((e) == EADDRINUSE)
+#define ERRNO_IS_EADDRINUSE(e) (((e) == EADDRINUSE) || 0)
#define tor_socket_errno(sock) (errno)
#define tor_socket_strerror(e) strerror(e)
#endif
diff --git a/src/common/compat_libevent.c b/src/common/compat_libevent.c
index 74b54bb855..33672f07d8 100644
--- a/src/common/compat_libevent.c
+++ b/src/common/compat_libevent.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013, The Tor Project, Inc. */
+/* Copyright (c) 2009-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -210,6 +210,9 @@ tor_libevent_initialize(tor_libevent_cfg *torcfg)
} else {
using_iocp_bufferevents = 0;
}
+#elif defined(__COVERITY__)
+ /* Avoid a 'dead code' warning below. */
+ using_threads = ! torcfg->disable_iocp;
#endif
if (!using_threads) {
diff --git a/src/common/compat_libevent.h b/src/common/compat_libevent.h
index 9ee7b49cfb..c5c78b822d 100644
--- a/src/common/compat_libevent.h
+++ b/src/common/compat_libevent.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013, The Tor Project, Inc. */
+/* Copyright (c) 2009-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_COMPAT_LIBEVENT_H
diff --git a/src/common/container.c b/src/common/container.c
index b937d544fc..ab4e22de52 100644
--- a/src/common/container.c
+++ b/src/common/container.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -28,21 +28,21 @@
/** Allocate and return an empty smartlist.
*/
-smartlist_t *
-smartlist_new(void)
+MOCK_IMPL(smartlist_t *,
+smartlist_new,(void))
{
smartlist_t *sl = tor_malloc(sizeof(smartlist_t));
sl->num_used = 0;
sl->capacity = SMARTLIST_DEFAULT_CAPACITY;
- sl->list = tor_malloc(sizeof(void *) * sl->capacity);
+ sl->list = tor_calloc(sizeof(void *), sl->capacity);
return sl;
}
/** Deallocate a smartlist. Does not release storage associated with the
* list's elements.
*/
-void
-smartlist_free(smartlist_t *sl)
+MOCK_IMPL(void,
+smartlist_free,(smartlist_t *sl))
{
if (!sl)
return;
@@ -66,19 +66,28 @@ smartlist_ensure_capacity(smartlist_t *sl, int size)
#define MAX_CAPACITY (INT_MAX)
#else
#define MAX_CAPACITY (int)((SIZE_MAX / (sizeof(void*))))
+#define ASSERT_CAPACITY
#endif
if (size > sl->capacity) {
int higher = sl->capacity;
if (PREDICT_UNLIKELY(size > MAX_CAPACITY/2)) {
+#ifdef ASSERT_CAPACITY
+ /* We don't include this assertion when MAX_CAPACITY == INT_MAX,
+ * since int size; (size <= INT_MAX) makes analysis tools think we're
+ * doing something stupid. */
tor_assert(size <= MAX_CAPACITY);
+#endif
higher = MAX_CAPACITY;
} else {
while (size > higher)
higher *= 2;
}
sl->capacity = higher;
- sl->list = tor_realloc(sl->list, sizeof(void*)*((size_t)sl->capacity));
+ sl->list = tor_reallocarray(sl->list, sizeof(void *),
+ ((size_t)sl->capacity));
}
+#undef ASSERT_CAPACITY
+#undef MAX_CAPACITY
}
/** Append element to the end of the list. */
@@ -1012,6 +1021,7 @@ smartlist_uniq_digests256(smartlist_t *sl)
DEFINE_MAP_STRUCTS(strmap_t, char *key, strmap_);
DEFINE_MAP_STRUCTS(digestmap_t, char key[DIGEST_LEN], digestmap_);
+DEFINE_MAP_STRUCTS(digest256map_t, uint8_t key[DIGEST256_LEN], digest256map_);
/** Helper: compare strmap_entry_t objects by key value. */
static INLINE int
@@ -1041,204 +1051,303 @@ digestmap_entry_hash(const digestmap_entry_t *a)
return (unsigned) siphash24g(a->key, DIGEST_LEN);
}
+/** Helper: compare digestmap_entry_t objects by key value. */
+static INLINE int
+digest256map_entries_eq(const digest256map_entry_t *a,
+ const digest256map_entry_t *b)
+{
+ return tor_memeq(a->key, b->key, DIGEST256_LEN);
+}
+
+/** Helper: return a hash value for a digest_map_t. */
+static INLINE unsigned int
+digest256map_entry_hash(const digest256map_entry_t *a)
+{
+ return (unsigned) siphash24g(a->key, DIGEST256_LEN);
+}
+
HT_PROTOTYPE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
strmap_entries_eq)
-HT_GENERATE(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
- strmap_entries_eq, 0.6, malloc, realloc, free)
+HT_GENERATE2(strmap_impl, strmap_entry_t, node, strmap_entry_hash,
+ strmap_entries_eq, 0.6, tor_reallocarray_, tor_free_)
HT_PROTOTYPE(digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash,
digestmap_entries_eq)
-HT_GENERATE(digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash,
- digestmap_entries_eq, 0.6, malloc, realloc, free)
+HT_GENERATE2(digestmap_impl, digestmap_entry_t, node, digestmap_entry_hash,
+ digestmap_entries_eq, 0.6, tor_reallocarray_, tor_free_)
-/** Constructor to create a new empty map from strings to void*'s.
- */
-strmap_t *
-strmap_new(void)
+HT_PROTOTYPE(digest256map_impl, digest256map_entry_t, node,
+ digest256map_entry_hash,
+ digest256map_entries_eq)
+HT_GENERATE2(digest256map_impl, digest256map_entry_t, node,
+ digest256map_entry_hash,
+ digest256map_entries_eq, 0.6, tor_reallocarray_, tor_free_)
+
+static INLINE void
+strmap_entry_free(strmap_entry_t *ent)
{
- strmap_t *result;
- result = tor_malloc(sizeof(strmap_t));
- HT_INIT(strmap_impl, &result->head);
- return result;
+ tor_free(ent->key);
+ tor_free(ent);
}
-
-/** Constructor to create a new empty map from digests to void*'s.
- */
-digestmap_t *
-digestmap_new(void)
+static INLINE void
+digestmap_entry_free(digestmap_entry_t *ent)
{
- digestmap_t *result;
- result = tor_malloc(sizeof(digestmap_t));
- HT_INIT(digestmap_impl, &result->head);
- return result;
+ tor_free(ent);
}
-
-/** Set the current value for <b>key</b> to <b>val</b>. Returns the previous
- * value for <b>key</b> if one was set, or NULL if one was not.
- *
- * This function makes a copy of <b>key</b> if necessary, but not of
- * <b>val</b>.
- */
-void *
-strmap_set(strmap_t *map, const char *key, void *val)
-{
- strmap_entry_t *resolve;
- strmap_entry_t search;
- void *oldval;
- tor_assert(map);
- tor_assert(key);
- tor_assert(val);
- search.key = (char*)key;
- resolve = HT_FIND(strmap_impl, &map->head, &search);
- if (resolve) {
- oldval = resolve->val;
- resolve->val = val;
- return oldval;
- } else {
- resolve = tor_malloc_zero(sizeof(strmap_entry_t));
- resolve->key = tor_strdup(key);
- resolve->val = val;
- tor_assert(!HT_FIND(strmap_impl, &map->head, resolve));
- HT_INSERT(strmap_impl, &map->head, resolve);
- return NULL;
- }
+static INLINE void
+digest256map_entry_free(digest256map_entry_t *ent)
+{
+ tor_free(ent);
}
-#define OPTIMIZED_DIGESTMAP_SET
-
-/** Like strmap_set() above but for digestmaps. */
-void *
-digestmap_set(digestmap_t *map, const char *key, void *val)
+static INLINE void
+strmap_assign_tmp_key(strmap_entry_t *ent, const char *key)
{
-#ifndef OPTIMIZED_DIGESTMAP_SET
- digestmap_entry_t *resolve;
-#endif
- digestmap_entry_t search;
- void *oldval;
- tor_assert(map);
- tor_assert(key);
- tor_assert(val);
- memcpy(&search.key, key, DIGEST_LEN);
-#ifndef OPTIMIZED_DIGESTMAP_SET
- resolve = HT_FIND(digestmap_impl, &map->head, &search);
- if (resolve) {
- oldval = resolve->val;
- resolve->val = val;
- return oldval;
- } else {
- resolve = tor_malloc_zero(sizeof(digestmap_entry_t));
- memcpy(resolve->key, key, DIGEST_LEN);
- resolve->val = val;
- HT_INSERT(digestmap_impl, &map->head, resolve);
- return NULL;
- }
-#else
- /* We spend up to 5% of our time in this function, so the code below is
- * meant to optimize the check/alloc/set cycle by avoiding the two trips to
- * the hash table that we do in the unoptimized code above. (Each of
- * HT_INSERT and HT_FIND calls HT_SET_HASH and HT_FIND_P.)
- */
- HT_FIND_OR_INSERT_(digestmap_impl, node, digestmap_entry_hash, &(map->head),
- digestmap_entry_t, &search, ptr,
- {
- /* we found an entry. */
- oldval = (*ptr)->val;
- (*ptr)->val = val;
- return oldval;
- },
- {
- /* We didn't find the entry. */
- digestmap_entry_t *newent =
- tor_malloc_zero(sizeof(digestmap_entry_t));
- memcpy(newent->key, key, DIGEST_LEN);
- newent->val = val;
- HT_FOI_INSERT_(node, &(map->head), &search, newent, ptr);
- return NULL;
- });
-#endif
+ ent->key = (char*)key;
}
-
-/** Return the current value associated with <b>key</b>, or NULL if no
- * value is set.
- */
-void *
-strmap_get(const strmap_t *map, const char *key)
-{
- strmap_entry_t *resolve;
- strmap_entry_t search;
- tor_assert(map);
- tor_assert(key);
- search.key = (char*)key;
- resolve = HT_FIND(strmap_impl, &map->head, &search);
- if (resolve) {
- return resolve->val;
- } else {
- return NULL;
- }
+static INLINE void
+digestmap_assign_tmp_key(digestmap_entry_t *ent, const char *key)
+{
+ memcpy(ent->key, key, DIGEST_LEN);
}
-
-/** Like strmap_get() above but for digestmaps. */
-void *
-digestmap_get(const digestmap_t *map, const char *key)
-{
- digestmap_entry_t *resolve;
- digestmap_entry_t search;
- tor_assert(map);
- tor_assert(key);
- memcpy(&search.key, key, DIGEST_LEN);
- resolve = HT_FIND(digestmap_impl, &map->head, &search);
- if (resolve) {
- return resolve->val;
- } else {
- return NULL;
- }
+static INLINE void
+digest256map_assign_tmp_key(digest256map_entry_t *ent, const uint8_t *key)
+{
+ memcpy(ent->key, key, DIGEST256_LEN);
+}
+static INLINE void
+strmap_assign_key(strmap_entry_t *ent, const char *key)
+{
+ ent->key = tor_strdup(key);
+}
+static INLINE void
+digestmap_assign_key(digestmap_entry_t *ent, const char *key)
+{
+ memcpy(ent->key, key, DIGEST_LEN);
+}
+static INLINE void
+digest256map_assign_key(digest256map_entry_t *ent, const uint8_t *key)
+{
+ memcpy(ent->key, key, DIGEST256_LEN);
}
-/** Remove the value currently associated with <b>key</b> from the map.
- * Return the value if one was set, or NULL if there was no entry for
- * <b>key</b>.
- *
- * Note: you must free any storage associated with the returned value.
+/**
+ * Macro: implement all the functions for a map that are declared in
+ * container.h by the DECLARE_MAP_FNS() macro. You must additionally define a
+ * prefix_entry_free_() function to free entries (and their keys), a
+ * prefix_assign_tmp_key() function to temporarily set a stack-allocated
+ * entry to hold a key, and a prefix_assign_key() function to set a
+ * heap-allocated entry to hold a key.
*/
-void *
-strmap_remove(strmap_t *map, const char *key)
-{
- strmap_entry_t *resolve;
- strmap_entry_t search;
- void *oldval;
- tor_assert(map);
- tor_assert(key);
- search.key = (char*)key;
- resolve = HT_REMOVE(strmap_impl, &map->head, &search);
- if (resolve) {
- oldval = resolve->val;
- tor_free(resolve->key);
- tor_free(resolve);
- return oldval;
- } else {
- return NULL;
+#define IMPLEMENT_MAP_FNS(maptype, keytype, prefix) \
+ /** Create and return a new empty map. */ \
+ MOCK_IMPL(maptype *, \
+ prefix##_new,(void)) \
+ { \
+ maptype *result; \
+ result = tor_malloc(sizeof(maptype)); \
+ HT_INIT(prefix##_impl, &result->head); \
+ return result; \
+ } \
+ \
+ /** Return the item from <b>map</b> whose key matches <b>key</b>, or \
+ * NULL if no such value exists. */ \
+ void * \
+ prefix##_get(const maptype *map, const keytype key) \
+ { \
+ prefix ##_entry_t *resolve; \
+ prefix ##_entry_t search; \
+ tor_assert(map); \
+ tor_assert(key); \
+ prefix ##_assign_tmp_key(&search, key); \
+ resolve = HT_FIND(prefix ##_impl, &map->head, &search); \
+ if (resolve) { \
+ return resolve->val; \
+ } else { \
+ return NULL; \
+ } \
+ } \
+ \
+ /** Add an entry to <b>map</b> mapping <b>key</b> to <b>val</b>; \
+ * return the previous value, or NULL if no such value existed. */ \
+ void * \
+ prefix##_set(maptype *map, const keytype key, void *val) \
+ { \
+ prefix##_entry_t search; \
+ void *oldval; \
+ tor_assert(map); \
+ tor_assert(key); \
+ tor_assert(val); \
+ prefix##_assign_tmp_key(&search, key); \
+ /* We a lot of our time in this function, so the code below is */ \
+ /* meant to optimize the check/alloc/set cycle by avoiding the two */\
+ /* trips to the hash table that we would do in the unoptimized */ \
+ /* version of this code. (Each of HT_INSERT and HT_FIND calls */ \
+ /* HT_SET_HASH and HT_FIND_P.) */ \
+ HT_FIND_OR_INSERT_(prefix##_impl, node, prefix##_entry_hash, \
+ &(map->head), \
+ prefix##_entry_t, &search, ptr, \
+ { \
+ /* we found an entry. */ \
+ oldval = (*ptr)->val; \
+ (*ptr)->val = val; \
+ return oldval; \
+ }, \
+ { \
+ /* We didn't find the entry. */ \
+ prefix##_entry_t *newent = \
+ tor_malloc_zero(sizeof(prefix##_entry_t)); \
+ prefix##_assign_key(newent, key); \
+ newent->val = val; \
+ HT_FOI_INSERT_(node, &(map->head), \
+ &search, newent, ptr); \
+ return NULL; \
+ }); \
+ } \
+ \
+ /** Remove the value currently associated with <b>key</b> from the map. \
+ * Return the value if one was set, or NULL if there was no entry for \
+ * <b>key</b>. \
+ * \
+ * Note: you must free any storage associated with the returned value. \
+ */ \
+ void * \
+ prefix##_remove(maptype *map, const keytype key) \
+ { \
+ prefix##_entry_t *resolve; \
+ prefix##_entry_t search; \
+ void *oldval; \
+ tor_assert(map); \
+ tor_assert(key); \
+ prefix##_assign_tmp_key(&search, key); \
+ resolve = HT_REMOVE(prefix##_impl, &map->head, &search); \
+ if (resolve) { \
+ oldval = resolve->val; \
+ prefix##_entry_free(resolve); \
+ return oldval; \
+ } else { \
+ return NULL; \
+ } \
+ } \
+ \
+ /** Return the number of elements in <b>map</b>. */ \
+ int \
+ prefix##_size(const maptype *map) \
+ { \
+ return HT_SIZE(&map->head); \
+ } \
+ \
+ /** Return true iff <b>map</b> has no entries. */ \
+ int \
+ prefix##_isempty(const maptype *map) \
+ { \
+ return HT_EMPTY(&map->head); \
+ } \
+ \
+ /** Assert that <b>map</b> is not corrupt. */ \
+ void \
+ prefix##_assert_ok(const maptype *map) \
+ { \
+ tor_assert(!prefix##_impl_HT_REP_IS_BAD_(&map->head)); \
+ } \
+ \
+ /** Remove all entries from <b>map</b>, and deallocate storage for \
+ * those entries. If free_val is provided, invoked it every value in \
+ * <b>map</b>. */ \
+ MOCK_IMPL(void, \
+ prefix##_free, (maptype *map, void (*free_val)(void*))) \
+ { \
+ prefix##_entry_t **ent, **next, *this; \
+ if (!map) \
+ return; \
+ for (ent = HT_START(prefix##_impl, &map->head); ent != NULL; \
+ ent = next) { \
+ this = *ent; \
+ next = HT_NEXT_RMV(prefix##_impl, &map->head, ent); \
+ if (free_val) \
+ free_val(this->val); \
+ prefix##_entry_free(this); \
+ } \
+ tor_assert(HT_EMPTY(&map->head)); \
+ HT_CLEAR(prefix##_impl, &map->head); \
+ tor_free(map); \
+ } \
+ \
+ /** return an <b>iterator</b> pointer to the front of a map. \
+ * \
+ * Iterator example: \
+ * \
+ * \code \
+ * // uppercase values in "map", removing empty values. \
+ * \
+ * strmap_iter_t *iter; \
+ * const char *key; \
+ * void *val; \
+ * char *cp; \
+ * \
+ * for (iter = strmap_iter_init(map); !strmap_iter_done(iter); ) { \
+ * strmap_iter_get(iter, &key, &val); \
+ * cp = (char*)val; \
+ * if (!*cp) { \
+ * iter = strmap_iter_next_rmv(map,iter); \
+ * free(val); \
+ * } else { \
+ * for (;*cp;cp++) *cp = TOR_TOUPPER(*cp); \
+ */ \
+ prefix##_iter_t * \
+ prefix##_iter_init(maptype *map) \
+ { \
+ tor_assert(map); \
+ return HT_START(prefix##_impl, &map->head); \
+ } \
+ \
+ /** Advance <b>iter</b> a single step to the next entry, and return \
+ * its new value. */ \
+ prefix##_iter_t * \
+ prefix##_iter_next(maptype *map, prefix##_iter_t *iter) \
+ { \
+ tor_assert(map); \
+ tor_assert(iter); \
+ return HT_NEXT(prefix##_impl, &map->head, iter); \
+ } \
+ /** Advance <b>iter</b> a single step to the next entry, removing the \
+ * current entry, and return its new value. */ \
+ prefix##_iter_t * \
+ prefix##_iter_next_rmv(maptype *map, prefix##_iter_t *iter) \
+ { \
+ prefix##_entry_t *rmv; \
+ tor_assert(map); \
+ tor_assert(iter); \
+ tor_assert(*iter); \
+ rmv = *iter; \
+ iter = HT_NEXT_RMV(prefix##_impl, &map->head, iter); \
+ prefix##_entry_free(rmv); \
+ return iter; \
+ } \
+ /** Set *<b>keyp</b> and *<b>valp</b> to the current entry pointed \
+ * to by iter. */ \
+ void \
+ prefix##_iter_get(prefix##_iter_t *iter, const keytype *keyp, \
+ void **valp) \
+ { \
+ tor_assert(iter); \
+ tor_assert(*iter); \
+ tor_assert(keyp); \
+ tor_assert(valp); \
+ *keyp = (*iter)->key; \
+ *valp = (*iter)->val; \
+ } \
+ /** Return true iff <b>iter</b> has advanced past the last entry of \
+ * <b>map</b>. */ \
+ int \
+ prefix##_iter_done(prefix##_iter_t *iter) \
+ { \
+ return iter == NULL; \
}
-}
-/** Like strmap_remove() above but for digestmaps. */
-void *
-digestmap_remove(digestmap_t *map, const char *key)
-{
- digestmap_entry_t *resolve;
- digestmap_entry_t search;
- void *oldval;
- tor_assert(map);
- tor_assert(key);
- memcpy(&search.key, key, DIGEST_LEN);
- resolve = HT_REMOVE(digestmap_impl, &map->head, &search);
- if (resolve) {
- oldval = resolve->val;
- tor_free(resolve);
- return oldval;
- } else {
- return NULL;
- }
-}
+IMPLEMENT_MAP_FNS(strmap_t, char *, strmap)
+IMPLEMENT_MAP_FNS(digestmap_t, char *, digestmap)
+IMPLEMENT_MAP_FNS(digest256map_t, uint8_t *, digest256map)
/** Same as strmap_set, but first converts <b>key</b> to lowercase. */
void *
@@ -1278,231 +1387,6 @@ strmap_remove_lc(strmap_t *map, const char *key)
return v;
}
-/** return an <b>iterator</b> pointer to the front of a map.
- *
- * Iterator example:
- *
- * \code
- * // uppercase values in "map", removing empty values.
- *
- * strmap_iter_t *iter;
- * const char *key;
- * void *val;
- * char *cp;
- *
- * for (iter = strmap_iter_init(map); !strmap_iter_done(iter); ) {
- * strmap_iter_get(iter, &key, &val);
- * cp = (char*)val;
- * if (!*cp) {
- * iter = strmap_iter_next_rmv(map,iter);
- * free(val);
- * } else {
- * for (;*cp;cp++) *cp = TOR_TOUPPER(*cp);
- * iter = strmap_iter_next(map,iter);
- * }
- * }
- * \endcode
- *
- */
-strmap_iter_t *
-strmap_iter_init(strmap_t *map)
-{
- tor_assert(map);
- return HT_START(strmap_impl, &map->head);
-}
-
-/** Start iterating through <b>map</b>. See strmap_iter_init() for example. */
-digestmap_iter_t *
-digestmap_iter_init(digestmap_t *map)
-{
- tor_assert(map);
- return HT_START(digestmap_impl, &map->head);
-}
-
-/** Advance the iterator <b>iter</b> for <b>map</b> a single step to the next
- * entry, and return its new value. */
-strmap_iter_t *
-strmap_iter_next(strmap_t *map, strmap_iter_t *iter)
-{
- tor_assert(map);
- tor_assert(iter);
- return HT_NEXT(strmap_impl, &map->head, iter);
-}
-
-/** Advance the iterator <b>iter</b> for map a single step to the next entry,
- * and return its new value. */
-digestmap_iter_t *
-digestmap_iter_next(digestmap_t *map, digestmap_iter_t *iter)
-{
- tor_assert(map);
- tor_assert(iter);
- return HT_NEXT(digestmap_impl, &map->head, iter);
-}
-
-/** Advance the iterator <b>iter</b> a single step to the next entry, removing
- * the current entry, and return its new value.
- */
-strmap_iter_t *
-strmap_iter_next_rmv(strmap_t *map, strmap_iter_t *iter)
-{
- strmap_entry_t *rmv;
- tor_assert(map);
- tor_assert(iter);
- tor_assert(*iter);
- rmv = *iter;
- iter = HT_NEXT_RMV(strmap_impl, &map->head, iter);
- tor_free(rmv->key);
- tor_free(rmv);
- return iter;
-}
-
-/** Advance the iterator <b>iter</b> a single step to the next entry, removing
- * the current entry, and return its new value.
- */
-digestmap_iter_t *
-digestmap_iter_next_rmv(digestmap_t *map, digestmap_iter_t *iter)
-{
- digestmap_entry_t *rmv;
- tor_assert(map);
- tor_assert(iter);
- tor_assert(*iter);
- rmv = *iter;
- iter = HT_NEXT_RMV(digestmap_impl, &map->head, iter);
- tor_free(rmv);
- return iter;
-}
-
-/** Set *<b>keyp</b> and *<b>valp</b> to the current entry pointed to by
- * iter. */
-void
-strmap_iter_get(strmap_iter_t *iter, const char **keyp, void **valp)
-{
- tor_assert(iter);
- tor_assert(*iter);
- tor_assert(keyp);
- tor_assert(valp);
- *keyp = (*iter)->key;
- *valp = (*iter)->val;
-}
-
-/** Set *<b>keyp</b> and *<b>valp</b> to the current entry pointed to by
- * iter. */
-void
-digestmap_iter_get(digestmap_iter_t *iter, const char **keyp, void **valp)
-{
- tor_assert(iter);
- tor_assert(*iter);
- tor_assert(keyp);
- tor_assert(valp);
- *keyp = (*iter)->key;
- *valp = (*iter)->val;
-}
-
-/** Return true iff <b>iter</b> has advanced past the last entry of
- * <b>map</b>. */
-int
-strmap_iter_done(strmap_iter_t *iter)
-{
- return iter == NULL;
-}
-
-/** Return true iff <b>iter</b> has advanced past the last entry of
- * <b>map</b>. */
-int
-digestmap_iter_done(digestmap_iter_t *iter)
-{
- return iter == NULL;
-}
-
-/** Remove all entries from <b>map</b>, and deallocate storage for those
- * entries. If free_val is provided, it is invoked on every value in
- * <b>map</b>.
- */
-void
-strmap_free(strmap_t *map, void (*free_val)(void*))
-{
- strmap_entry_t **ent, **next, *this;
- if (!map)
- return;
-
- for (ent = HT_START(strmap_impl, &map->head); ent != NULL; ent = next) {
- this = *ent;
- next = HT_NEXT_RMV(strmap_impl, &map->head, ent);
- tor_free(this->key);
- if (free_val)
- free_val(this->val);
- tor_free(this);
- }
- tor_assert(HT_EMPTY(&map->head));
- HT_CLEAR(strmap_impl, &map->head);
- tor_free(map);
-}
-
-/** Remove all entries from <b>map</b>, and deallocate storage for those
- * entries. If free_val is provided, it is invoked on every value in
- * <b>map</b>.
- */
-void
-digestmap_free(digestmap_t *map, void (*free_val)(void*))
-{
- digestmap_entry_t **ent, **next, *this;
- if (!map)
- return;
- for (ent = HT_START(digestmap_impl, &map->head); ent != NULL; ent = next) {
- this = *ent;
- next = HT_NEXT_RMV(digestmap_impl, &map->head, ent);
- if (free_val)
- free_val(this->val);
- tor_free(this);
- }
- tor_assert(HT_EMPTY(&map->head));
- HT_CLEAR(digestmap_impl, &map->head);
- tor_free(map);
-}
-
-/** Fail with an assertion error if anything has gone wrong with the internal
- * representation of <b>map</b>. */
-void
-strmap_assert_ok(const strmap_t *map)
-{
- tor_assert(!strmap_impl_HT_REP_IS_BAD_(&map->head));
-}
-/** Fail with an assertion error if anything has gone wrong with the internal
- * representation of <b>map</b>. */
-void
-digestmap_assert_ok(const digestmap_t *map)
-{
- tor_assert(!digestmap_impl_HT_REP_IS_BAD_(&map->head));
-}
-
-/** Return true iff <b>map</b> has no entries. */
-int
-strmap_isempty(const strmap_t *map)
-{
- return HT_EMPTY(&map->head);
-}
-
-/** Return true iff <b>map</b> has no entries. */
-int
-digestmap_isempty(const digestmap_t *map)
-{
- return HT_EMPTY(&map->head);
-}
-
-/** Return the number of items in <b>map</b>. */
-int
-strmap_size(const strmap_t *map)
-{
- return HT_SIZE(&map->head);
-}
-
-/** Return the number of items in <b>map</b>. */
-int
-digestmap_size(const digestmap_t *map)
-{
- return HT_SIZE(&map->head);
-}
-
/** Declare a function called <b>funcname</b> that acts as a find_nth_FOO
* function for an array of type <b>elt_t</b>*.
*
diff --git a/src/common/container.h b/src/common/container.h
index 0d31f2093b..d3d20af5b2 100644
--- a/src/common/container.h
+++ b/src/common/container.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_CONTAINER_H
@@ -27,8 +27,8 @@ typedef struct smartlist_t {
/** @} */
} smartlist_t;
-smartlist_t *smartlist_new(void);
-void smartlist_free(smartlist_t *sl);
+MOCK_DECL(smartlist_t *, smartlist_new, (void));
+MOCK_DECL(void, smartlist_free, (smartlist_t *sl));
void smartlist_clear(smartlist_t *sl);
void smartlist_add(smartlist_t *sl, void *element);
void smartlist_add_all(smartlist_t *sl, const smartlist_t *s2);
@@ -328,11 +328,11 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
#define DECLARE_MAP_FNS(maptype, keytype, prefix) \
typedef struct maptype maptype; \
typedef struct prefix##entry_t *prefix##iter_t; \
- maptype* prefix##new(void); \
+ MOCK_DECL(maptype*, prefix##new, (void)); \
void* prefix##set(maptype *map, keytype key, void *val); \
void* prefix##get(const maptype *map, keytype key); \
void* prefix##remove(maptype *map, keytype key); \
- void prefix##free(maptype *map, void (*free_val)(void*)); \
+ MOCK_DECL(void, prefix##free, (maptype *map, void (*free_val)(void*))); \
int prefix##isempty(const maptype *map); \
int prefix##size(const maptype *map); \
prefix##iter_t *prefix##iter_init(maptype *map); \
@@ -346,6 +346,9 @@ char *smartlist_join_strings2(smartlist_t *sl, const char *join,
DECLARE_MAP_FNS(strmap_t, const char *, strmap_);
/* Map from const char[DIGEST_LEN] to void *. Implemented with a hash table. */
DECLARE_MAP_FNS(digestmap_t, const char *, digestmap_);
+/* Map from const uint8_t[DIGEST_LEN] to void *. Implemented with a hash
+ * table. */
+DECLARE_MAP_FNS(digest256map_t, const uint8_t *, digest256map_);
#undef DECLARE_MAP_FNS
@@ -461,6 +464,13 @@ DECLARE_MAP_FNS(digestmap_t, const char *, digestmap_);
/** Used to end a DIGESTMAP_FOREACH() block. */
#define DIGESTMAP_FOREACH_END MAP_FOREACH_END
+#define DIGEST256MAP_FOREACH(map, keyvar, valtype, valvar) \
+ MAP_FOREACH(digest256map_, map, const uint8_t *, keyvar, valtype, valvar)
+#define DIGEST256MAP_FOREACH_MODIFY(map, keyvar, valtype, valvar) \
+ MAP_FOREACH_MODIFY(digest256map_, map, const uint8_t *, \
+ keyvar, valtype, valvar)
+#define DIGEST256MAP_FOREACH_END MAP_FOREACH_END
+
#define STRMAP_FOREACH(map, keyvar, valtype, valvar) \
MAP_FOREACH(strmap_, map, const char *, keyvar, valtype, valvar)
#define STRMAP_FOREACH_MODIFY(map, keyvar, valtype, valvar) \
@@ -473,7 +483,7 @@ void* strmap_remove_lc(strmap_t *map, const char *key);
#define DECLARE_TYPED_DIGESTMAP_FNS(prefix, maptype, valtype) \
typedef struct maptype maptype; \
- typedef struct prefix##iter_t prefix##iter_t; \
+ typedef struct prefix##iter_t *prefix##iter_t; \
ATTR_UNUSED static INLINE maptype* \
prefix##new(void) \
{ \
@@ -563,7 +573,7 @@ bitarray_init_zero(unsigned int n_bits)
{
/* round up to the next int. */
size_t sz = (n_bits+BITARRAY_MASK) >> BITARRAY_SHIFT;
- return tor_malloc_zero(sz*sizeof(unsigned int));
+ return tor_calloc(sz, sizeof(unsigned int));
}
/** Expand <b>ba</b> from holding <b>n_bits_old</b> to <b>n_bits_new</b>,
* clearing all new bits. Returns a possibly changed pointer to the
@@ -577,7 +587,7 @@ bitarray_expand(bitarray_t *ba,
char *ptr;
if (sz_new <= sz_old)
return ba;
- ptr = tor_realloc(ba, sz_new*sizeof(unsigned int));
+ ptr = tor_reallocarray(ba, sz_new, sizeof(unsigned int));
/* This memset does nothing to the older excess bytes. But they were
* already set to 0 by bitarry_init_zero. */
memset(ptr+sz_old*sizeof(unsigned int), 0,
@@ -689,5 +699,11 @@ median_int32(int32_t *array, int n_elements)
return find_nth_int32(array, n_elements, (n_elements-1)/2);
}
+static INLINE uint32_t
+third_quartile_uint32(uint32_t *array, int n_elements)
+{
+ return find_nth_uint32(array, n_elements, (n_elements*3)/4);
+}
+
#endif
diff --git a/src/common/crypto.c b/src/common/crypto.c
index 16292455b5..90a16fab1a 100644
--- a/src/common/crypto.c
+++ b/src/common/crypto.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -1684,7 +1684,7 @@ crypto_digest_get_digest(crypto_digest_t *digest,
log_warn(LD_BUG, "Called with unknown algorithm %d", digest->algorithm);
/* If fragile_assert is not enabled, then we should at least not
* leak anything. */
- memset(r, 0xff, sizeof(r));
+ memwipe(r, 0xff, sizeof(r));
tor_fragile_assert();
break;
}
@@ -1838,7 +1838,7 @@ crypto_store_dynamic_dh_modulus(const char *fname)
goto done;
}
- base64_encoded_dh = tor_malloc_zero(len * 2); /* should be enough */
+ base64_encoded_dh = tor_calloc(len, 2); /* should be enough */
new_len = base64_encode(base64_encoded_dh, len * 2,
(char *)dh_string_repr, len);
if (new_len < 0) {
@@ -2454,10 +2454,8 @@ crypto_strongest_rand(uint8_t *out, size_t out_len)
if (!provider_set) {
if (!CryptAcquireContext(&provider, NULL, NULL, PROV_RSA_FULL,
CRYPT_VERIFYCONTEXT)) {
- if ((unsigned long)GetLastError() != (unsigned long)NTE_BAD_KEYSET) {
- log_warn(LD_CRYPTO, "Can't get CryptoAPI provider [1]");
- return -1;
- }
+ log_warn(LD_CRYPTO, "Can't get CryptoAPI provider [1]");
+ return -1;
}
provider_set = 1;
}
@@ -3001,50 +2999,6 @@ base32_decode(char *dest, size_t destlen, const char *src, size_t srclen)
return 0;
}
-/** Implement RFC2440-style iterated-salted S2K conversion: convert the
- * <b>secret_len</b>-byte <b>secret</b> into a <b>key_out_len</b> byte
- * <b>key_out</b>. As in RFC2440, the first 8 bytes of s2k_specifier
- * are a salt; the 9th byte describes how much iteration to do.
- * Does not support <b>key_out_len</b> &gt; DIGEST_LEN.
- */
-void
-secret_to_key(char *key_out, size_t key_out_len, const char *secret,
- size_t secret_len, const char *s2k_specifier)
-{
- crypto_digest_t *d;
- uint8_t c;
- size_t count, tmplen;
- char *tmp;
- tor_assert(key_out_len < SIZE_T_CEILING);
-
-#define EXPBIAS 6
- c = s2k_specifier[8];
- count = ((uint32_t)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
-#undef EXPBIAS
-
- tor_assert(key_out_len <= DIGEST_LEN);
-
- d = crypto_digest_new();
- tmplen = 8+secret_len;
- tmp = tor_malloc(tmplen);
- memcpy(tmp,s2k_specifier,8);
- memcpy(tmp+8,secret,secret_len);
- secret_len += 8;
- while (count) {
- if (count >= secret_len) {
- crypto_digest_add_bytes(d, tmp, secret_len);
- count -= secret_len;
- } else {
- crypto_digest_add_bytes(d, tmp, count);
- count = 0;
- }
- }
- crypto_digest_get_digest(d, key_out, key_out_len);
- memwipe(tmp, 0, tmplen);
- tor_free(tmp);
- crypto_digest_free(d);
-}
-
/**
* Destroy the <b>sz</b> bytes of data stored at <b>mem</b>, setting them to
* the value <b>byte</b>.
@@ -3164,7 +3118,7 @@ setup_openssl_threading(void)
int i;
int n = CRYPTO_num_locks();
n_openssl_mutexes_ = n;
- openssl_mutexes_ = tor_malloc(n*sizeof(tor_mutex_t *));
+ openssl_mutexes_ = tor_calloc(n, sizeof(tor_mutex_t *));
for (i=0; i < n; ++i)
openssl_mutexes_[i] = tor_mutex_new();
CRYPTO_set_locking_callback(openssl_locking_cb_);
diff --git a/src/common/crypto.h b/src/common/crypto.h
index aa4271aa33..d496521849 100644
--- a/src/common/crypto.h
+++ b/src/common/crypto.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -280,12 +280,6 @@ int digest_from_base64(char *digest, const char *d64);
int digest256_to_base64(char *d64, const char *digest);
int digest256_from_base64(char *digest, const char *d64);
-/** Length of RFC2440-style S2K specifier: the first 8 bytes are a salt, the
- * 9th describes how much iteration to do. */
-#define S2K_SPECIFIER_LEN 9
-void secret_to_key(char *key_out, size_t key_out_len, const char *secret,
- size_t secret_len, const char *s2k_specifier);
-
/** OpenSSL-based utility functions. */
void memwipe(void *mem, uint8_t byte, size_t sz);
diff --git a/src/common/crypto_curve25519.c b/src/common/crypto_curve25519.c
index 9e83440e16..c04b715abd 100644
--- a/src/common/crypto_curve25519.c
+++ b/src/common/crypto_curve25519.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Wrapper code for a curve25519 implementation. */
@@ -8,6 +8,7 @@
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
+#include "container.h"
#include "crypto.h"
#include "crypto_curve25519.h"
#include "util.h"
@@ -63,26 +64,44 @@ curve25519_public_key_is_ok(const curve25519_public_key_t *key)
return !safe_mem_is_zero(key->public_key, CURVE25519_PUBKEY_LEN);
}
-/** Generate a new keypair and return the secret key. If <b>extra_strong</b>
- * is true, this key is possibly going to get used more than once, so
- * use a better-than-usual RNG. Return 0 on success, -1 on failure. */
+/**
+ * Generate CURVE25519_SECKEY_LEN random bytes in <b>out</b>. If
+ * <b>extra_strong</b> is true, this key is possibly going to get used more
+ * than once, so use a better-than-usual RNG. Return 0 on success, -1 on
+ * failure.
+ *
+ * This function does not adjust the output of the RNG at all; the will caller
+ * will need to clear or set the appropriate bits to make curve25519 work.
+ */
int
-curve25519_secret_key_generate(curve25519_secret_key_t *key_out,
- int extra_strong)
+curve25519_rand_seckey_bytes(uint8_t *out, int extra_strong)
{
uint8_t k_tmp[CURVE25519_SECKEY_LEN];
- if (crypto_rand((char*)key_out->secret_key, CURVE25519_SECKEY_LEN) < 0)
+ if (crypto_rand((char*)out, CURVE25519_SECKEY_LEN) < 0)
return -1;
if (extra_strong && !crypto_strongest_rand(k_tmp, CURVE25519_SECKEY_LEN)) {
/* If they asked for extra-strong entropy and we have some, use it as an
* HMAC key to improve not-so-good entropy rather than using it directly,
* just in case the extra-strong entropy is less amazing than we hoped. */
- crypto_hmac_sha256((char *)key_out->secret_key,
- (const char *)k_tmp, sizeof(k_tmp),
- (const char *)key_out->secret_key, CURVE25519_SECKEY_LEN);
+ crypto_hmac_sha256((char*) out,
+ (const char *)k_tmp, sizeof(k_tmp),
+ (const char *)out, CURVE25519_SECKEY_LEN);
}
memwipe(k_tmp, 0, sizeof(k_tmp));
+ return 0;
+}
+
+/** Generate a new keypair and return the secret key. If <b>extra_strong</b>
+ * is true, this key is possibly going to get used more than once, so
+ * use a better-than-usual RNG. Return 0 on success, -1 on failure. */
+int
+curve25519_secret_key_generate(curve25519_secret_key_t *key_out,
+ int extra_strong)
+{
+ if (curve25519_rand_seckey_bytes(key_out->secret_key, extra_strong) < 0)
+ return -1;
+
key_out->secret_key[0] &= 248;
key_out->secret_key[31] &= 127;
key_out->secret_key[31] |= 64;
@@ -109,69 +128,144 @@ curve25519_keypair_generate(curve25519_keypair_t *keypair_out,
return 0;
}
+/** Write the <b>datalen</b> bytes from <b>data</b> to the file named
+ * <b>fname</b> in the tagged-data format. This format contains a
+ * 32-byte header, followed by the data itself. The header is the
+ * NUL-padded string "== <b>typestring</b>: <b>tag</b> ==". The length
+ * of <b>typestring</b> and <b>tag</b> must therefore be no more than
+ * 24.
+ **/
int
-curve25519_keypair_write_to_file(const curve25519_keypair_t *keypair,
- const char *fname,
- const char *tag)
+crypto_write_tagged_contents_to_file(const char *fname,
+ const char *typestring,
+ const char *tag,
+ const uint8_t *data,
+ size_t datalen)
{
- char contents[32 + CURVE25519_SECKEY_LEN + CURVE25519_PUBKEY_LEN];
- int r;
+ char header[32];
+ smartlist_t *chunks = smartlist_new();
+ sized_chunk_t ch0, ch1;
+ int r = -1;
- memset(contents, 0, sizeof(contents));
- tor_snprintf(contents, sizeof(contents), "== c25519v1: %s ==", tag);
- tor_assert(strlen(contents) <= 32);
- memcpy(contents+32, keypair->seckey.secret_key, CURVE25519_SECKEY_LEN);
- memcpy(contents+32+CURVE25519_SECKEY_LEN,
- keypair->pubkey.public_key, CURVE25519_PUBKEY_LEN);
+ memset(header, 0, sizeof(header));
+ if (tor_snprintf(header, sizeof(header),
+ "== %s: %s ==", typestring, tag) < 0)
+ goto end;
+ ch0.bytes = header;
+ ch0.len = 32;
+ ch1.bytes = (const char*) data;
+ ch1.len = datalen;
+ smartlist_add(chunks, &ch0);
+ smartlist_add(chunks, &ch1);
- r = write_bytes_to_file(fname, contents, sizeof(contents), 1);
+ r = write_chunks_to_file(fname, chunks, 1, 0);
- memwipe(contents, 0, sizeof(contents));
+ end:
+ smartlist_free(chunks);
return r;
}
-int
-curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out,
- char **tag_out,
- const char *fname)
+/** Read a tagged-data file from <b>fname</b> into the
+ * <b>data_out_len</b>-byte buffer in <b>data_out</b>. Check that the
+ * typestring matches <b>typestring</b>; store the tag into a newly allocated
+ * string in <b>tag_out</b>. Return -1 on failure, and the number of bytes of
+ * data on success. */
+ssize_t
+crypto_read_tagged_contents_from_file(const char *fname,
+ const char *typestring,
+ char **tag_out,
+ uint8_t *data_out,
+ ssize_t data_out_len)
{
char prefix[33];
- char *content;
+ char *content = NULL;
struct stat st;
- int r = -1;
+ ssize_t r = -1;
+ size_t st_size = 0;
*tag_out = NULL;
-
st.st_size = 0;
content = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
if (! content)
goto end;
- if (st.st_size != 32 + CURVE25519_SECKEY_LEN + CURVE25519_PUBKEY_LEN)
+ if (st.st_size < 32 || st.st_size > 32 + data_out_len)
goto end;
+ st_size = (size_t)st.st_size;
memcpy(prefix, content, 32);
- prefix[32] = '\0';
- if (strcmpstart(prefix, "== c25519v1: ") ||
- strcmpend(prefix, " =="))
+ prefix[32] = 0;
+ /* Check type, extract tag. */
+ if (strcmpstart(prefix, "== ") || strcmpend(prefix, " ==") ||
+ ! tor_mem_is_zero(prefix+strlen(prefix), 32-strlen(prefix)))
+ goto end;
+
+ if (strcmpstart(prefix+3, typestring) ||
+ 3+strlen(typestring) >= 32 ||
+ strcmpstart(prefix+3+strlen(typestring), ": "))
goto end;
- *tag_out = tor_strndup(prefix+strlen("== c25519v1: "),
- strlen(prefix) - strlen("== c25519v1: =="));
+ *tag_out = tor_strndup(prefix+5+strlen(typestring),
+ strlen(prefix)-8-strlen(typestring));
+
+ memcpy(data_out, content+32, st_size-32);
+ r = st_size - 32;
+
+ end:
+ if (content)
+ memwipe(content, 0, st_size);
+ tor_free(content);
+ return r;
+}
+
+/** DOCDOC */
+int
+curve25519_keypair_write_to_file(const curve25519_keypair_t *keypair,
+ const char *fname,
+ const char *tag)
+{
+ uint8_t contents[CURVE25519_SECKEY_LEN + CURVE25519_PUBKEY_LEN];
+ int r;
+
+ memcpy(contents, keypair->seckey.secret_key, CURVE25519_SECKEY_LEN);
+ memcpy(contents+CURVE25519_SECKEY_LEN,
+ keypair->pubkey.public_key, CURVE25519_PUBKEY_LEN);
+
+ r = crypto_write_tagged_contents_to_file(fname,
+ "c25519v1",
+ tag,
+ contents,
+ sizeof(contents));
+
+ memwipe(contents, 0, sizeof(contents));
+ return r;
+}
+
+/** DOCDOC */
+int
+curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out,
+ char **tag_out,
+ const char *fname)
+{
+ uint8_t content[CURVE25519_SECKEY_LEN + CURVE25519_PUBKEY_LEN];
+ ssize_t len;
+ int r = -1;
+
+ len = crypto_read_tagged_contents_from_file(fname, "c25519v1", tag_out,
+ content, sizeof(content));
+ if (len != sizeof(content))
+ goto end;
- memcpy(keypair_out->seckey.secret_key, content+32, CURVE25519_SECKEY_LEN);
+ memcpy(keypair_out->seckey.secret_key, content, CURVE25519_SECKEY_LEN);
curve25519_public_key_generate(&keypair_out->pubkey, &keypair_out->seckey);
if (tor_memneq(keypair_out->pubkey.public_key,
- content + 32 + CURVE25519_SECKEY_LEN,
+ content + CURVE25519_SECKEY_LEN,
CURVE25519_PUBKEY_LEN))
goto end;
r = 0;
end:
- if (content) {
- memwipe(content, 0, (size_t) st.st_size);
- tor_free(content);
- }
+ memwipe(content, 0, sizeof(content));
if (r != 0) {
memset(keypair_out, 0, sizeof(*keypair_out));
tor_free(*tag_out);
diff --git a/src/common/crypto_curve25519.h b/src/common/crypto_curve25519.h
index 57018ac2f5..e8f885227e 100644
--- a/src/common/crypto_curve25519.h
+++ b/src/common/crypto_curve25519.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_CRYPTO_CURVE25519_H
@@ -30,7 +30,6 @@ typedef struct curve25519_keypair_t {
curve25519_secret_key_t seckey;
} curve25519_keypair_t;
-#ifdef CURVE25519_ENABLED
/* These functions require that we actually know how to use curve25519 keys.
* The other data structures and functions in this header let us parse them,
* store them, and move them around.
@@ -57,11 +56,12 @@ int curve25519_keypair_read_from_file(curve25519_keypair_t *keypair_out,
char **tag_out,
const char *fname);
+int curve25519_rand_seckey_bytes(uint8_t *out, int extra_strong);
+
#ifdef CRYPTO_CURVE25519_PRIVATE
STATIC int curve25519_impl(uint8_t *output, const uint8_t *secret,
const uint8_t *basepoint);
#endif
-#endif
#define CURVE25519_BASE64_PADDED_LEN 44
@@ -70,5 +70,17 @@ int curve25519_public_from_base64(curve25519_public_key_t *pkey,
int curve25519_public_to_base64(char *output,
const curve25519_public_key_t *pkey);
+int crypto_write_tagged_contents_to_file(const char *fname,
+ const char *typestring,
+ const char *tag,
+ const uint8_t *data,
+ size_t datalen);
+
+ssize_t crypto_read_tagged_contents_from_file(const char *fname,
+ const char *typestring,
+ char **tag_out,
+ uint8_t *data_out,
+ ssize_t data_out_len);
+
#endif
diff --git a/src/common/crypto_ed25519.c b/src/common/crypto_ed25519.c
new file mode 100644
index 0000000000..340fb4956f
--- /dev/null
+++ b/src/common/crypto_ed25519.c
@@ -0,0 +1,353 @@
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+/* Wrapper code for an ed25519 implementation. */
+
+#include "orconfig.h"
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#include "crypto.h"
+
+#include "crypto_curve25519.h"
+#include "crypto_ed25519.h"
+#include "torlog.h"
+#include "util.h"
+
+#include "ed25519/ref10/ed25519_ref10.h"
+
+#include <openssl/sha.h>
+
+/**
+ * Initialize a new ed25519 secret key in <b>seckey_out</b>. If
+ * <b>extra_strong</b>, take the RNG inputs directly from the operating
+ * system. Return 0 on success, -1 on failure.
+ */
+int
+ed25519_secret_key_generate(ed25519_secret_key_t *seckey_out,
+ int extra_strong)
+{
+ int r;
+ uint8_t seed[32];
+ if (! extra_strong || crypto_strongest_rand(seed, sizeof(seed)) < 0)
+ crypto_rand((char*)seed, sizeof(seed));
+
+ r = ed25519_ref10_seckey_expand(seckey_out->seckey, seed);
+ memwipe(seed, 0, sizeof(seed));
+
+ return r < 0 ? -1 : 0;
+}
+
+/**
+ * Given a 32-byte random seed in <b>seed</b>, expand it into an ed25519
+ * secret key in <b>seckey_out</b>. Return 0 on success, -1 on failure.
+ */
+int
+ed25519_secret_key_from_seed(ed25519_secret_key_t *seckey_out,
+ const uint8_t *seed)
+{
+ if (ed25519_ref10_seckey_expand(seckey_out->seckey, seed) < 0)
+ return -1;
+ return 0;
+}
+
+/**
+ * Given a secret key in <b>seckey</b>, expand it into an
+ * ed25519 public key. Return 0 on success, -1 on failure.
+ */
+int
+ed25519_public_key_generate(ed25519_public_key_t *pubkey_out,
+ const ed25519_secret_key_t *seckey)
+{
+ if (ed25519_ref10_pubkey(pubkey_out->pubkey, seckey->seckey) < 0)
+ return -1;
+ return 0;
+}
+
+/** Generate a new ed25519 keypair in <b>keypair_out</b>. If
+ * <b>extra_strong</b> is set, try to mix some system entropy into the key
+ * generation process. Return 0 on success, -1 on failure. */
+int
+ed25519_keypair_generate(ed25519_keypair_t *keypair_out, int extra_strong)
+{
+ if (ed25519_secret_key_generate(&keypair_out->seckey, extra_strong) < 0)
+ return -1;
+ if (ed25519_public_key_generate(&keypair_out->pubkey,
+ &keypair_out->seckey)<0)
+ return -1;
+ return 0;
+}
+
+/**
+ * Set <b>signature_out</b> to a signature of the <b>len</b>-byte message
+ * <b>msg</b>, using the secret and public key in <b>keypair</b>.
+ */
+int
+ed25519_sign(ed25519_signature_t *signature_out,
+ const uint8_t *msg, size_t len,
+ const ed25519_keypair_t *keypair)
+{
+
+ if (ed25519_ref10_sign(signature_out->sig, msg, len,
+ keypair->seckey.seckey,
+ keypair->pubkey.pubkey) < 0) {
+ return -1;
+ }
+
+ return 0;
+}
+
+/**
+ * Check whether if <b>signature</b> is a valid signature for the
+ * <b>len</b>-byte message in <b>msg</b> made with the key <b>pubkey</b>.
+ *
+ * Return 0 if the signature is valid; -1 if it isn't.
+ */
+int
+ed25519_checksig(const ed25519_signature_t *signature,
+ const uint8_t *msg, size_t len,
+ const ed25519_public_key_t *pubkey)
+{
+ return
+ ed25519_ref10_open(signature->sig, msg, len, pubkey->pubkey) < 0 ? -1 : 0;
+}
+
+/** Validate every signature among those in <b>checkable</b>, which contains
+ * exactly <b>n_checkable</b> elements. If <b>okay_out</b> is non-NULL, set
+ * the i'th element of <b>okay_out</b> to 1 if the i'th element of
+ * <b>checkable</b> is valid, and to 0 otherwise. Return 0 if every signature
+ * was valid. Otherwise return -N, where N is the number of invalid
+ * signatures.
+ */
+int
+ed25519_checksig_batch(int *okay_out,
+ const ed25519_checkable_t *checkable,
+ int n_checkable)
+{
+ int res, i;
+
+ res = 0;
+ for (i = 0; i < n_checkable; ++i) {
+ const ed25519_checkable_t *ch = &checkable[i];
+ int r = ed25519_checksig(&ch->signature, ch->msg, ch->len, ch->pubkey);
+ if (r < 0)
+ --res;
+ if (okay_out)
+ okay_out[i] = (r == 0);
+ }
+
+#if 0
+ /* This is how we'd do it if we were using ed25519_donna. I'll keep this
+ * code around here in case we ever do that. */
+ const uint8_t **ms;
+ size_t *lens;
+ const uint8_t **pks;
+ const uint8_t **sigs;
+ int *oks;
+
+ ms = tor_malloc(sizeof(uint8_t*)*n_checkable);
+ lens = tor_malloc(sizeof(size_t)*n_checkable);
+ pks = tor_malloc(sizeof(uint8_t*)*n_checkable);
+ sigs = tor_malloc(sizeof(uint8_t*)*n_checkable);
+ oks = okay_out ? okay_out : tor_malloc(sizeof(int)*n_checkable);
+
+ for (i = 0; i < n_checkable; ++i) {
+ ms[i] = checkable[i].msg;
+ lens[i] = checkable[i].len;
+ pks[i] = checkable[i].pubkey->pubkey;
+ sigs[i] = checkable[i].signature.sig;
+ oks[i] = 0;
+ }
+
+ ed25519_sign_open_batch_donna_fb(ms, lens, pks, sigs, n_checkable, oks);
+
+ res = 0;
+ for (i = 0; i < n_checkable; ++i) {
+ if (!oks[i])
+ --res;
+ }
+
+ tor_free(ms);
+ tor_free(lens);
+ tor_free(pks);
+ if (! okay_out)
+ tor_free(oks);
+#endif
+
+ return res;
+}
+
+/**
+ * Given a curve25519 keypair in <b>inp</b>, generate a corresponding
+ * ed25519 keypair in <b>out</b>, and set <b>signbit_out</b> to the
+ * sign bit of the X coordinate of the ed25519 key.
+ *
+ * NOTE THAT IT IS PROBABLY NOT SAFE TO USE THE GENERATED KEY FOR ANYTHING
+ * OUTSIDE OF WHAT'S PRESENTED IN PROPOSAL 228. In particular, it's probably
+ * not a great idea to use it to sign attacker-supplied anything.
+ */
+int
+ed25519_keypair_from_curve25519_keypair(ed25519_keypair_t *out,
+ int *signbit_out,
+ const curve25519_keypair_t *inp)
+{
+ const char string[] = "Derive high part of ed25519 key from curve25519 key";
+ ed25519_public_key_t pubkey_check;
+ SHA512_CTX ctx;
+ uint8_t sha512_output[64];
+
+ memcpy(out->seckey.seckey, inp->seckey.secret_key, 32);
+ SHA512_Init(&ctx);
+ SHA512_Update(&ctx, out->seckey.seckey, 32);
+ SHA512_Update(&ctx, string, sizeof(string));
+ SHA512_Final(sha512_output, &ctx);
+ memcpy(out->seckey.seckey + 32, sha512_output, 32);
+
+ ed25519_public_key_generate(&out->pubkey, &out->seckey);
+
+ *signbit_out = out->pubkey.pubkey[31] >> 7;
+
+ ed25519_public_key_from_curve25519_public_key(&pubkey_check, &inp->pubkey,
+ *signbit_out);
+
+ tor_assert(fast_memeq(pubkey_check.pubkey, out->pubkey.pubkey, 32));
+
+ memwipe(&pubkey_check, 0, sizeof(pubkey_check));
+ memwipe(&ctx, 0, sizeof(ctx));
+ memwipe(sha512_output, 0, sizeof(sha512_output));
+
+ return 0;
+}
+
+/**
+ * Given a curve25519 public key and sign bit of X coordinate of the ed25519
+ * public key, generate the corresponding ed25519 public key.
+ */
+int
+ed25519_public_key_from_curve25519_public_key(ed25519_public_key_t *pubkey,
+ const curve25519_public_key_t *pubkey_in,
+ int signbit)
+{
+ return ed25519_ref10_pubkey_from_curve25519_pubkey(pubkey->pubkey,
+ pubkey_in->public_key,
+ signbit);
+}
+
+/**
+ * Given an ed25519 keypair in <b>inp</b>, generate a corresponding
+ * ed25519 keypair in <b>out</b>, blinded by the corresponding 32-byte input
+ * in 'param'.
+ *
+ * Tor uses key blinding for the "next-generation" hidden services design:
+ * service descriptors are encrypted with a key derived from the service's
+ * long-term public key, and then signed with (and stored at a position
+ * indexed by) a short-term key derived by blinding the long-term keys.
+ */
+int
+ed25519_keypair_blind(ed25519_keypair_t *out,
+ const ed25519_keypair_t *inp,
+ const uint8_t *param)
+{
+ ed25519_public_key_t pubkey_check;
+
+ ed25519_ref10_blind_secret_key(out->seckey.seckey,
+ inp->seckey.seckey, param);
+
+ ed25519_public_blind(&pubkey_check, &inp->pubkey, param);
+ ed25519_public_key_generate(&out->pubkey, &out->seckey);
+
+ tor_assert(fast_memeq(pubkey_check.pubkey, out->pubkey.pubkey, 32));
+
+ memwipe(&pubkey_check, 0, sizeof(pubkey_check));
+
+ return 0;
+}
+
+/**
+ * Given an ed25519 public key in <b>inp</b>, generate a corresponding blinded
+ * public key in <b>out</b>, blinded with the 32-byte parameter in
+ * <b>param</b>. Return 0 on sucess, -1 on railure.
+ */
+int
+ed25519_public_blind(ed25519_public_key_t *out,
+ const ed25519_public_key_t *inp,
+ const uint8_t *param)
+{
+ ed25519_ref10_blind_public_key(out->pubkey, inp->pubkey, param);
+ return 0;
+}
+
+/**
+ * Store seckey unencrypted to <b>filename</b>, marking it with <b>tag</b>.
+ * Return 0 on success, -1 on failure.
+ */
+int
+ed25519_seckey_write_to_file(const ed25519_secret_key_t *seckey,
+ const char *filename,
+ const char *tag)
+{
+ return crypto_write_tagged_contents_to_file(filename,
+ "ed25519v1-secret",
+ tag,
+ seckey->seckey,
+ sizeof(seckey->seckey));
+}
+
+/**
+ * Read seckey unencrypted from <b>filename</b>, storing it into
+ * <b>seckey_out</b>. Set *<b>tag_out</> to the tag it was marked with.
+ * Return 0 on success, -1 on failure.
+ */
+int
+ed25519_seckey_read_from_file(ed25519_secret_key_t *seckey_out,
+ char **tag_out,
+ const char *filename)
+{
+ ssize_t len;
+
+ len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-secret",
+ tag_out, seckey_out->seckey,
+ sizeof(seckey_out->seckey));
+ if (len != sizeof(seckey_out->seckey))
+ return -1;
+
+ return 0;
+}
+
+/**
+ * Store pubkey unencrypted to <b>filename</b>, marking it with <b>tag</b>.
+ * Return 0 on success, -1 on failure.
+ */
+int
+ed25519_pubkey_write_to_file(const ed25519_public_key_t *pubkey,
+ const char *filename,
+ const char *tag)
+{
+ return crypto_write_tagged_contents_to_file(filename,
+ "ed25519v1-public",
+ tag,
+ pubkey->pubkey,
+ sizeof(pubkey->pubkey));
+}
+
+/**
+ * Store pubkey unencrypted to <b>filename</b>, marking it with <b>tag</b>.
+ * Return 0 on success, -1 on failure.
+ */
+int
+ed25519_pubkey_read_from_file(ed25519_public_key_t *pubkey_out,
+ char **tag_out,
+ const char *filename)
+{
+ ssize_t len;
+
+ len = crypto_read_tagged_contents_from_file(filename, "ed25519v1-public",
+ tag_out, pubkey_out->pubkey,
+ sizeof(pubkey_out->pubkey));
+ if (len != sizeof(pubkey_out->pubkey))
+ return -1;
+
+ return 0;
+}
+
diff --git a/src/common/crypto_ed25519.h b/src/common/crypto_ed25519.h
new file mode 100644
index 0000000000..8c3663e0dd
--- /dev/null
+++ b/src/common/crypto_ed25519.h
@@ -0,0 +1,113 @@
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_CRYPTO_ED25519_H
+#define TOR_CRYPTO_ED25519_H
+
+#include "testsupport.h"
+#include "torint.h"
+
+#define ED25519_PUBKEY_LEN 32
+#define ED25519_SECKEY_LEN 64
+#define ED25519_SECKEY_SEED_LEN 32
+#define ED25519_SIG_LEN 64
+
+/** An Ed25519 signature. */
+typedef struct {
+ uint8_t sig[ED25519_SIG_LEN];
+} ed25519_signature_t;
+
+/** An Ed25519 public key */
+typedef struct {
+ uint8_t pubkey[ED25519_PUBKEY_LEN];
+} ed25519_public_key_t;
+
+/** An Ed25519 secret key */
+typedef struct {
+ /** Note that we store secret keys in an expanded format that doesn't match
+ * the format from standard ed25519. Ed25519 stores a 32-byte value k and
+ * expands it into a 64-byte H(k), using the first 32 bytes for a multiplier
+ * of the base point, and second 32 bytes as an input to a hash function
+ * for deriving r. But because we implement key blinding, we need to store
+ * keys in the 64-byte expanded form. */
+ uint8_t seckey[ED25519_SECKEY_LEN];
+} ed25519_secret_key_t;
+
+/** An Ed25519 keypair. */
+typedef struct {
+ ed25519_public_key_t pubkey;
+ ed25519_secret_key_t seckey;
+} ed25519_keypair_t;
+
+int ed25519_secret_key_generate(ed25519_secret_key_t *seckey_out,
+ int extra_strong);
+int ed25519_secret_key_from_seed(ed25519_secret_key_t *seckey_out,
+ const uint8_t *seed);
+
+int ed25519_public_key_generate(ed25519_public_key_t *pubkey_out,
+ const ed25519_secret_key_t *seckey);
+int ed25519_keypair_generate(ed25519_keypair_t *keypair_out, int extra_strong);
+int ed25519_sign(ed25519_signature_t *signature_out,
+ const uint8_t *msg, size_t len,
+ const ed25519_keypair_t *key);
+int ed25519_checksig(const ed25519_signature_t *signature,
+ const uint8_t *msg, size_t len,
+ const ed25519_public_key_t *pubkey);
+
+/**
+ * A collection of information necessary to check an Ed25519 signature. Used
+ * for batch verification.
+ */
+typedef struct {
+ /** The public key that supposedly generated the signature. */
+ ed25519_public_key_t *pubkey;
+ /** The signature to check. */
+ ed25519_signature_t signature;
+ /** The message that the signature is supposed to have been applied to. */
+ const uint8_t *msg;
+ /** The length of the message. */
+ size_t len;
+} ed25519_checkable_t;
+
+int ed25519_checksig_batch(int *okay_out,
+ const ed25519_checkable_t *checkable,
+ int n_checkable);
+
+int ed25519_keypair_from_curve25519_keypair(ed25519_keypair_t *out,
+ int *signbit_out,
+ const curve25519_keypair_t *inp);
+
+int ed25519_public_key_from_curve25519_public_key(ed25519_public_key_t *pubkey,
+ const curve25519_public_key_t *pubkey_in,
+ int signbit);
+int ed25519_keypair_blind(ed25519_keypair_t *out,
+ const ed25519_keypair_t *inp,
+ const uint8_t *param);
+int ed25519_public_blind(ed25519_public_key_t *out,
+ const ed25519_public_key_t *inp,
+ const uint8_t *param);
+
+#define ED25519_BASE64_LEN 43
+
+int ed25519_public_from_base64(ed25519_public_key_t *pkey,
+ const char *input);
+int ed25519_public_to_base64(char *output,
+ const ed25519_public_key_t *pkey);
+
+/* XXXX read encrypted, write encrypted. */
+
+int ed25519_seckey_write_to_file(const ed25519_secret_key_t *seckey,
+ const char *filename,
+ const char *tag);
+int ed25519_seckey_read_from_file(ed25519_secret_key_t *seckey_out,
+ char **tag_out,
+ const char *filename);
+int ed25519_pubkey_write_to_file(const ed25519_public_key_t *pubkey,
+ const char *filename,
+ const char *tag);
+int ed25519_pubkey_read_from_file(ed25519_public_key_t *pubkey_out,
+ char **tag_out,
+ const char *filename);
+
+#endif
+
diff --git a/src/common/crypto_format.c b/src/common/crypto_format.c
index be669c8d2b..63dd391914 100644
--- a/src/common/crypto_format.c
+++ b/src/common/crypto_format.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Formatting and parsing code for crypto-related data structures. */
@@ -9,6 +9,7 @@
#endif
#include "crypto.h"
#include "crypto_curve25519.h"
+#include "crypto_ed25519.h"
#include "util.h"
#include "torlog.h"
@@ -43,3 +44,24 @@ curve25519_public_from_base64(curve25519_public_key_t *pkey,
}
}
+/** Try to decode the string <b>input</b> into an ed25519 public key. On
+ * success, store the value in <b>pkey</b> and return 0. Otherwise return
+ * -1. */
+int
+ed25519_public_from_base64(ed25519_public_key_t *pkey,
+ const char *input)
+{
+ return digest256_from_base64((char*)pkey->pubkey, input);
+}
+
+/** Encode the public key <b>pkey</b> into the buffer at <b>output</b>,
+ * which must have space for ED25519_BASE64_LEN bytes of encoded key,
+ * plus one byte for a terminating NUL. Return 0 on success, -1 on failure.
+ */
+int
+ed25519_public_to_base64(char *output,
+ const ed25519_public_key_t *pkey)
+{
+ return digest256_to_base64(output, (const char *)pkey->pubkey);
+}
+
diff --git a/src/common/crypto_pwbox.c b/src/common/crypto_pwbox.c
new file mode 100644
index 0000000000..b866c7ef39
--- /dev/null
+++ b/src/common/crypto_pwbox.c
@@ -0,0 +1,187 @@
+
+#include "crypto.h"
+#include "crypto_s2k.h"
+#include "crypto_pwbox.h"
+#include "di_ops.h"
+#include "util.h"
+#include "pwbox.h"
+
+/* 8 bytes "TORBOX00"
+ 1 byte: header len (H)
+ H bytes: header, denoting secret key algorithm.
+ 16 bytes: IV
+ Round up to multiple of 128 bytes, then encrypt:
+ 4 bytes: data len
+ data
+ zeros
+ 32 bytes: HMAC-SHA256 of all previous bytes.
+*/
+
+#define MAX_OVERHEAD (S2K_MAXLEN + 8 + 1 + 32 + CIPHER_IV_LEN)
+
+/**
+ * Make an authenticated passphrase-encrypted blob to encode the
+ * <b>input_len</b> bytes in <b>input</b> using the passphrase
+ * <b>secret</b> of <b>secret_len</b> bytes. Allocate a new chunk of memory
+ * to hold the encrypted data, and store a pointer to that memory in
+ * *<b>out</b>, and its size in <b>outlen_out</b>. Use <b>s2k_flags</b> as an
+ * argument to the passphrase-hashing function.
+ */
+int
+crypto_pwbox(uint8_t **out, size_t *outlen_out,
+ const uint8_t *input, size_t input_len,
+ const char *secret, size_t secret_len,
+ unsigned s2k_flags)
+{
+ uint8_t *result = NULL, *encrypted_portion;
+ size_t encrypted_len = 128 * CEIL_DIV(input_len+4, 128);
+ ssize_t result_len;
+ int spec_len;
+ uint8_t keys[CIPHER_KEY_LEN + DIGEST256_LEN];
+ pwbox_encoded_t *enc = NULL;
+ ssize_t enc_len;
+
+ crypto_cipher_t *cipher;
+ int rv;
+
+ enc = pwbox_encoded_new();
+
+ pwbox_encoded_setlen_skey_header(enc, S2K_MAXLEN);
+
+ spec_len = secret_to_key_make_specifier(
+ pwbox_encoded_getarray_skey_header(enc),
+ S2K_MAXLEN,
+ s2k_flags);
+ if (spec_len < 0 || spec_len > S2K_MAXLEN)
+ goto err;
+ pwbox_encoded_setlen_skey_header(enc, spec_len);
+ enc->header_len = spec_len;
+
+ crypto_rand((char*)enc->iv, sizeof(enc->iv));
+
+ pwbox_encoded_setlen_data(enc, encrypted_len);
+ encrypted_portion = pwbox_encoded_getarray_data(enc);
+
+ set_uint32(encrypted_portion, htonl((uint32_t)input_len));
+ memcpy(encrypted_portion+4, input, input_len);
+
+ /* Now that all the data is in position, derive some keys, encrypt, and
+ * digest */
+ if (secret_to_key_derivekey(keys, sizeof(keys),
+ pwbox_encoded_getarray_skey_header(enc),
+ spec_len,
+ secret, secret_len) < 0)
+ goto err;
+
+ cipher = crypto_cipher_new_with_iv((char*)keys, (char*)enc->iv);
+ crypto_cipher_crypt_inplace(cipher, (char*)encrypted_portion, encrypted_len);
+ crypto_cipher_free(cipher);
+
+ result_len = pwbox_encoded_encoded_len(enc);
+ if (result_len < 0)
+ goto err;
+ result = tor_malloc(result_len);
+ enc_len = pwbox_encoded_encode(result, result_len, enc);
+ if (enc_len < 0)
+ goto err;
+ tor_assert(enc_len == result_len);
+
+ crypto_hmac_sha256((char*) result + result_len - 32,
+ (const char*)keys + CIPHER_KEY_LEN,
+ DIGEST256_LEN,
+ (const char*)result,
+ result_len - 32);
+
+ *out = result;
+ *outlen_out = result_len;
+ rv = 0;
+ goto out;
+
+ err:
+ tor_free(result);
+ rv = -1;
+
+ out:
+ pwbox_encoded_free(enc);
+ memwipe(keys, 0, sizeof(keys));
+ return rv;
+}
+
+/**
+ * Try to decrypt the passphrase-encrypted blob of <b>input_len</b> bytes in
+ * <b>input</b> using the passphrase <b>secret</b> of <b>secret_len</b> bytes.
+ * On success, return 0 and allocate a new chunk of memory to hold the
+ * decrypted data, and store a pointer to that memory in *<b>out</b>, and its
+ * size in <b>outlen_out</b>. On failure, return UNPWBOX_BAD_SECRET if
+ * the passphrase might have been wrong, and UNPWBOX_CORRUPT if the object is
+ * definitely corrupt.
+ */
+int
+crypto_unpwbox(uint8_t **out, size_t *outlen_out,
+ const uint8_t *inp, size_t input_len,
+ const char *secret, size_t secret_len)
+{
+ uint8_t *result = NULL;
+ const uint8_t *encrypted;
+ uint8_t keys[CIPHER_KEY_LEN + DIGEST256_LEN];
+ uint8_t hmac[DIGEST256_LEN];
+ uint32_t result_len;
+ size_t encrypted_len;
+ crypto_cipher_t *cipher = NULL;
+ int rv = UNPWBOX_CORRUPTED;
+ ssize_t got_len;
+
+ pwbox_encoded_t *enc = NULL;
+
+ got_len = pwbox_encoded_parse(&enc, inp, input_len);
+ if (got_len < 0 || (size_t)got_len != input_len)
+ goto err;
+
+ /* Now derive the keys and check the hmac. */
+ if (secret_to_key_derivekey(keys, sizeof(keys),
+ pwbox_encoded_getarray_skey_header(enc),
+ pwbox_encoded_getlen_skey_header(enc),
+ secret, secret_len) < 0)
+ goto err;
+
+ crypto_hmac_sha256((char *)hmac,
+ (const char*)keys + CIPHER_KEY_LEN, DIGEST256_LEN,
+ (const char*)inp, input_len - DIGEST256_LEN);
+
+ if (tor_memneq(hmac, enc->hmac, DIGEST256_LEN)) {
+ rv = UNPWBOX_BAD_SECRET;
+ goto err;
+ }
+
+ /* How long is the plaintext? */
+ encrypted = pwbox_encoded_getarray_data(enc);
+ encrypted_len = pwbox_encoded_getlen_data(enc);
+ if (encrypted_len < 4)
+ goto err;
+
+ cipher = crypto_cipher_new_with_iv((char*)keys, (char*)enc->iv);
+ crypto_cipher_decrypt(cipher, (char*)&result_len, (char*)encrypted, 4);
+ result_len = ntohl(result_len);
+ if (encrypted_len < result_len + 4)
+ goto err;
+
+ /* Allocate a buffer and decrypt */
+ result = tor_malloc_zero(result_len);
+ crypto_cipher_decrypt(cipher, (char*)result, (char*)encrypted+4, result_len);
+
+ *out = result;
+ *outlen_out = result_len;
+
+ rv = UNPWBOX_OKAY;
+ goto out;
+
+ err:
+ tor_free(result);
+
+ out:
+ crypto_cipher_free(cipher);
+ pwbox_encoded_free(enc);
+ memwipe(keys, 0, sizeof(keys));
+ return rv;
+}
+
diff --git a/src/common/crypto_pwbox.h b/src/common/crypto_pwbox.h
new file mode 100644
index 0000000000..aadd477078
--- /dev/null
+++ b/src/common/crypto_pwbox.h
@@ -0,0 +1,20 @@
+#ifndef CRYPTO_PWBOX_H_INCLUDED_
+#define CRYPTO_PWBOX_H_INCLUDED_
+
+#include "torint.h"
+
+#define UNPWBOX_OKAY 0
+#define UNPWBOX_BAD_SECRET -1
+#define UNPWBOX_CORRUPTED -2
+
+int crypto_pwbox(uint8_t **out, size_t *outlen_out,
+ const uint8_t *inp, size_t input_len,
+ const char *secret, size_t secret_len,
+ unsigned s2k_flags);
+
+int crypto_unpwbox(uint8_t **out, size_t *outlen_out,
+ const uint8_t *inp, size_t input_len,
+ const char *secret, size_t secret_len);
+
+#endif
+
diff --git a/src/common/crypto_s2k.c b/src/common/crypto_s2k.c
new file mode 100644
index 0000000000..6d9ee497ab
--- /dev/null
+++ b/src/common/crypto_s2k.c
@@ -0,0 +1,460 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#define CRYPTO_S2K_PRIVATE
+
+#include "crypto.h"
+#include "util.h"
+#include "compat.h"
+#include "crypto_s2k.h"
+
+#include <openssl/evp.h>
+
+#ifdef HAVE_LIBSCRYPT_H
+#define HAVE_SCRYPT
+#include <libscrypt.h>
+#endif
+
+/* Encoded secrets take the form:
+
+ u8 type;
+ u8 salt_and_parameters[depends on type];
+ u8 key[depends on type];
+
+ As a special case, if the encoded secret is exactly 29 bytes long,
+ type 0 is understood.
+
+ Recognized types are:
+ 00 -- RFC2440. salt_and_parameters is 9 bytes. key is 20 bytes.
+ salt_and_parameters is 8 bytes random salt,
+ 1 byte iteration info.
+ 01 -- PKBDF2_SHA1. salt_and_parameters is 17 bytes. key is 20 bytes.
+ salt_and_parameters is 16 bytes random salt,
+ 1 byte iteration info.
+ 02 -- SCRYPT_SALSA208_SHA256. salt_and_parameters is 18 bytes. key is
+ 32 bytes.
+ salt_and_parameters is 18 bytes random salt, 2 bytes iteration
+ info.
+*/
+
+#define S2K_TYPE_RFC2440 0
+#define S2K_TYPE_PBKDF2 1
+#define S2K_TYPE_SCRYPT 2
+
+#define PBKDF2_SPEC_LEN 17
+#define PBKDF2_KEY_LEN 20
+
+#define SCRYPT_SPEC_LEN 18
+#define SCRYPT_KEY_LEN 32
+
+/** Given an algorithm ID (one of S2K_TYPE_*), return the length of the
+ * specifier part of it, without the prefix type byte. */
+static int
+secret_to_key_spec_len(uint8_t type)
+{
+ switch (type) {
+ case S2K_TYPE_RFC2440:
+ return S2K_RFC2440_SPECIFIER_LEN;
+ case S2K_TYPE_PBKDF2:
+ return PBKDF2_SPEC_LEN;
+ case S2K_TYPE_SCRYPT:
+ return SCRYPT_SPEC_LEN;
+ default:
+ return -1;
+ }
+}
+
+/** Given an algorithm ID (one of S2K_TYPE_*), return the length of the
+ * its preferred output. */
+static int
+secret_to_key_key_len(uint8_t type)
+{
+ switch (type) {
+ case S2K_TYPE_RFC2440:
+ return DIGEST_LEN;
+ case S2K_TYPE_PBKDF2:
+ return DIGEST_LEN;
+ case S2K_TYPE_SCRYPT:
+ return DIGEST256_LEN;
+ default:
+ return -1;
+ }
+}
+
+/** Given a specifier in <b>spec_and_key</b> of length
+ * <b>spec_and_key_len</b>, along with its prefix algorithm ID byte, and along
+ * with a key if <b>key_included</b> is true, check whether the whole
+ * specifier-and-key is of valid length, and return the algorithm type if it
+ * is. Set *<b>legacy_out</b> to 1 iff this is a legacy password hash or
+ * legacy specifier. Return an error code on failure.
+ */
+static int
+secret_to_key_get_type(const uint8_t *spec_and_key, size_t spec_and_key_len,
+ int key_included, int *legacy_out)
+{
+ size_t legacy_len = S2K_RFC2440_SPECIFIER_LEN;
+ uint8_t type;
+ int total_len;
+
+ if (key_included)
+ legacy_len += DIGEST_LEN;
+
+ if (spec_and_key_len == legacy_len) {
+ *legacy_out = 1;
+ return S2K_TYPE_RFC2440;
+ }
+
+ *legacy_out = 0;
+ if (spec_and_key_len == 0)
+ return S2K_BAD_LEN;
+
+ type = spec_and_key[0];
+ total_len = secret_to_key_spec_len(type);
+ if (total_len < 0)
+ return S2K_BAD_ALGORITHM;
+ if (key_included) {
+ int keylen = secret_to_key_key_len(type);
+ if (keylen < 0)
+ return S2K_BAD_ALGORITHM;
+ total_len += keylen;
+ }
+
+ if ((size_t)total_len + 1 == spec_and_key_len)
+ return type;
+ else
+ return S2K_BAD_LEN;
+}
+
+/**
+ * Write a new random s2k specifier of type <b>type</b>, without prefixing
+ * type byte, to <b>spec_out</b>, which must have enough room. May adjust
+ * parameter choice based on <b>flags</b>.
+ */
+static int
+make_specifier(uint8_t *spec_out, uint8_t type, unsigned flags)
+{
+ int speclen = secret_to_key_spec_len(type);
+ if (speclen < 0)
+ return S2K_BAD_ALGORITHM;
+
+ crypto_rand((char*)spec_out, speclen);
+ switch (type) {
+ case S2K_TYPE_RFC2440:
+ /* Hash 64 k of data. */
+ spec_out[S2K_RFC2440_SPECIFIER_LEN-1] = 96;
+ break;
+ case S2K_TYPE_PBKDF2:
+ /* 131 K iterations */
+ spec_out[PBKDF2_SPEC_LEN-1] = 17;
+ break;
+ case S2K_TYPE_SCRYPT:
+ if (flags & S2K_FLAG_LOW_MEM) {
+ /* N = 1<<12 */
+ spec_out[SCRYPT_SPEC_LEN-2] = 12;
+ } else {
+ /* N = 1<<15 */
+ spec_out[SCRYPT_SPEC_LEN-2] = 15;
+ }
+ /* r = 8; p = 2. */
+ spec_out[SCRYPT_SPEC_LEN-1] = (3u << 4) | (1u << 0);
+ break;
+ default:
+ tor_fragile_assert();
+ return S2K_BAD_ALGORITHM;
+ }
+
+ return speclen;
+}
+
+/** Implement RFC2440-style iterated-salted S2K conversion: convert the
+ * <b>secret_len</b>-byte <b>secret</b> into a <b>key_out_len</b> byte
+ * <b>key_out</b>. As in RFC2440, the first 8 bytes of s2k_specifier
+ * are a salt; the 9th byte describes how much iteration to do.
+ * If <b>key_out_len</b> &gt; DIGEST_LEN, use HDKF to expand the result.
+ */
+void
+secret_to_key_rfc2440(char *key_out, size_t key_out_len, const char *secret,
+ size_t secret_len, const char *s2k_specifier)
+{
+ crypto_digest_t *d;
+ uint8_t c;
+ size_t count, tmplen;
+ char *tmp;
+ uint8_t buf[DIGEST_LEN];
+ tor_assert(key_out_len < SIZE_T_CEILING);
+
+#define EXPBIAS 6
+ c = s2k_specifier[8];
+ count = ((uint32_t)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
+#undef EXPBIAS
+
+ d = crypto_digest_new();
+ tmplen = 8+secret_len;
+ tmp = tor_malloc(tmplen);
+ memcpy(tmp,s2k_specifier,8);
+ memcpy(tmp+8,secret,secret_len);
+ secret_len += 8;
+ while (count) {
+ if (count >= secret_len) {
+ crypto_digest_add_bytes(d, tmp, secret_len);
+ count -= secret_len;
+ } else {
+ crypto_digest_add_bytes(d, tmp, count);
+ count = 0;
+ }
+ }
+ crypto_digest_get_digest(d, (char*)buf, sizeof(buf));
+
+ if (key_out_len <= sizeof(buf)) {
+ memcpy(key_out, buf, key_out_len);
+ } else {
+ crypto_expand_key_material_rfc5869_sha256(buf, DIGEST_LEN,
+ (const uint8_t*)s2k_specifier, 8,
+ (const uint8_t*)"EXPAND", 6,
+ (uint8_t*)key_out, key_out_len);
+ }
+ memwipe(tmp, 0, tmplen);
+ memwipe(buf, 0, sizeof(buf));
+ tor_free(tmp);
+ crypto_digest_free(d);
+}
+
+/**
+ * Helper: given a valid specifier without prefix type byte in <b>spec</b>,
+ * whose length must be correct, and given a secret passphrase <b>secret</b>
+ * of length <b>secret_len</b>, compute the key and store it into
+ * <b>key_out</b>, which must have enough room for secret_to_key_key_len(type)
+ * bytes. Return the number of bytes written on success and an error code
+ * on failure.
+ */
+STATIC int
+secret_to_key_compute_key(uint8_t *key_out, size_t key_out_len,
+ const uint8_t *spec, size_t spec_len,
+ const char *secret, size_t secret_len,
+ int type)
+{
+ int rv;
+ if (key_out_len > INT_MAX)
+ return S2K_BAD_LEN;
+
+ switch (type) {
+ case S2K_TYPE_RFC2440:
+ secret_to_key_rfc2440((char*)key_out, key_out_len, secret, secret_len,
+ (const char*)spec);
+ return (int)key_out_len;
+
+ case S2K_TYPE_PBKDF2: {
+ uint8_t log_iters;
+ if (spec_len < 1 || secret_len > INT_MAX || spec_len > INT_MAX)
+ return S2K_BAD_LEN;
+ log_iters = spec[spec_len-1];
+ if (log_iters > 31)
+ return S2K_BAD_PARAMS;
+ rv = PKCS5_PBKDF2_HMAC_SHA1(secret, (int)secret_len,
+ spec, (int)spec_len-1,
+ (1<<log_iters),
+ (int)key_out_len, key_out);
+ if (rv < 0)
+ return S2K_FAILED;
+ return (int)key_out_len;
+ }
+
+ case S2K_TYPE_SCRYPT: {
+#ifdef HAVE_SCRYPT
+ uint8_t log_N, log_r, log_p;
+ uint64_t N;
+ uint32_t r, p;
+ if (spec_len < 2)
+ return S2K_BAD_LEN;
+ log_N = spec[spec_len-2];
+ log_r = (spec[spec_len-1]) >> 4;
+ log_p = (spec[spec_len-1]) & 15;
+ if (log_N > 63)
+ return S2K_BAD_PARAMS;
+ N = ((uint64_t)1) << log_N;
+ r = 1u << log_r;
+ p = 1u << log_p;
+ rv = libscrypt_scrypt((const uint8_t*)secret, secret_len,
+ spec, spec_len-2, N, r, p, key_out, key_out_len);
+ if (rv != 0)
+ return S2K_FAILED;
+ return (int)key_out_len;
+#else
+ return S2K_NO_SCRYPT_SUPPORT;
+#endif
+ }
+ default:
+ return S2K_BAD_ALGORITHM;
+ }
+}
+
+/**
+ * Given a specifier previously constructed with secret_to_key_make_specifier
+ * in <b>spec</b> of length <b>spec_len</b>, and a secret password in
+ * <b>secret</b> of length <b>secret_len</b>, generate <b>key_out_len</b>
+ * bytes of cryptographic material in <b>key_out</b>. The native output of
+ * the secret-to-key function will be truncated if key_out_len is short, and
+ * expanded with HKDF if key_out_len is long. Returns S2K_OKAY on success,
+ * and an error code on failure.
+ */
+int
+secret_to_key_derivekey(uint8_t *key_out, size_t key_out_len,
+ const uint8_t *spec, size_t spec_len,
+ const char *secret, size_t secret_len)
+{
+ int legacy_format = 0;
+ int type = secret_to_key_get_type(spec, spec_len, 0, &legacy_format);
+ int r;
+
+ if (type < 0)
+ return type;
+#ifndef HAVE_SCRYPT
+ if (type == S2K_TYPE_SCRYPT)
+ return S2K_NO_SCRYPT_SUPPORT;
+ #endif
+
+ if (! legacy_format) {
+ ++spec;
+ --spec_len;
+ }
+
+ r = secret_to_key_compute_key(key_out, key_out_len, spec, spec_len,
+ secret, secret_len, type);
+ if (r < 0)
+ return r;
+ else
+ return S2K_OKAY;
+}
+
+/**
+ * Construct a new s2k algorithm specifier and salt in <b>buf</b>, according
+ * to the bitwise-or of some S2K_FLAG_* options in <b>flags</b>. Up to
+ * <b>buf_len</b> bytes of storage may be used in <b>buf</b>. Return the
+ * number of bytes used on success and an error code on failure.
+ */
+int
+secret_to_key_make_specifier(uint8_t *buf, size_t buf_len, unsigned flags)
+{
+ int rv;
+ int spec_len;
+#ifdef HAVE_SCRYPT
+ uint8_t type = S2K_TYPE_SCRYPT;
+#else
+ uint8_t type = S2K_TYPE_RFC2440;
+#endif
+
+ if (flags & S2K_FLAG_NO_SCRYPT)
+ type = S2K_TYPE_RFC2440;
+ if (flags & S2K_FLAG_USE_PBKDF2)
+ type = S2K_TYPE_PBKDF2;
+
+ spec_len = secret_to_key_spec_len(type);
+
+ if ((int)buf_len < spec_len + 1)
+ return S2K_TRUNCATED;
+
+ buf[0] = type;
+ rv = make_specifier(buf+1, type, flags);
+ if (rv < 0)
+ return rv;
+ else
+ return rv + 1;
+}
+
+/**
+ * Hash a passphrase from <b>secret</b> of length <b>secret_len</b>, according
+ * to the bitwise-or of some S2K_FLAG_* options in <b>flags</b>, and store the
+ * hash along with salt and hashing parameters into <b>buf</b>. Up to
+ * <b>buf_len</b> bytes of storage may be used in <b>buf</b>. Set
+ * *<b>len_out</b> to the number of bytes used and return S2K_OKAY on success;
+ * and return an error code on failure.
+ */
+int
+secret_to_key_new(uint8_t *buf,
+ size_t buf_len,
+ size_t *len_out,
+ const char *secret, size_t secret_len,
+ unsigned flags)
+{
+ int key_len;
+ int spec_len;
+ int type;
+ int rv;
+
+ spec_len = secret_to_key_make_specifier(buf, buf_len, flags);
+
+ if (spec_len < 0)
+ return spec_len;
+
+ type = buf[0];
+ key_len = secret_to_key_key_len(type);
+
+ if (key_len < 0)
+ return key_len;
+
+ if ((int)buf_len < key_len + spec_len)
+ return S2K_TRUNCATED;
+
+ rv = secret_to_key_compute_key(buf + spec_len, key_len,
+ buf + 1, spec_len-1,
+ secret, secret_len, type);
+ if (rv < 0)
+ return rv;
+
+ *len_out = spec_len + key_len;
+
+ return S2K_OKAY;
+}
+
+/**
+ * Given a hashed passphrase in <b>spec_and_key</b> of length
+ * <b>spec_and_key_len</b> as generated by secret_to_key_new(), verify whether
+ * it is a hash of the passphrase <b>secret</b> of length <b>secret_len</b>.
+ * Return S2K_OKAY on a match, S2K_BAD_SECRET on a well-formed hash that
+ * doesn't match this secret, and another error code on other errors.
+ */
+int
+secret_to_key_check(const uint8_t *spec_and_key, size_t spec_and_key_len,
+ const char *secret, size_t secret_len)
+{
+ int is_legacy = 0;
+ int type = secret_to_key_get_type(spec_and_key, spec_and_key_len,
+ 1, &is_legacy);
+ uint8_t buf[32];
+ int spec_len;
+ int key_len;
+ int rv;
+
+ if (type < 0)
+ return type;
+
+ if (! is_legacy) {
+ spec_and_key++;
+ spec_and_key_len--;
+ }
+
+ spec_len = secret_to_key_spec_len(type);
+ key_len = secret_to_key_key_len(type);
+ tor_assert(spec_len > 0);
+ tor_assert(key_len > 0);
+ tor_assert(key_len <= (int) sizeof(buf));
+ tor_assert((int)spec_and_key_len == spec_len + key_len);
+ rv = secret_to_key_compute_key(buf, key_len,
+ spec_and_key, spec_len,
+ secret, secret_len, type);
+ if (rv < 0)
+ goto done;
+
+ if (tor_memeq(buf, spec_and_key + spec_len, key_len))
+ rv = S2K_OKAY;
+ else
+ rv = S2K_BAD_SECRET;
+
+ done:
+ memwipe(buf, 0, sizeof(buf));
+ return rv;
+}
+
diff --git a/src/common/crypto_s2k.h b/src/common/crypto_s2k.h
new file mode 100644
index 0000000000..a33dc96e46
--- /dev/null
+++ b/src/common/crypto_s2k.h
@@ -0,0 +1,73 @@
+/* Copyright (c) 2001, Matej Pfajfar.
+ * Copyright (c) 2001-2004, Roger Dingledine.
+ * Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
+/* See LICENSE for licensing information */
+
+#ifndef TOR_CRYPTO_S2K_H_INCLUDED
+#define TOR_CRYPTO_S2K_H_INCLUDED
+
+#include <stdio.h>
+#include "torint.h"
+
+/** Length of RFC2440-style S2K specifier: the first 8 bytes are a salt, the
+ * 9th describes how much iteration to do. */
+#define S2K_RFC2440_SPECIFIER_LEN 9
+void secret_to_key_rfc2440(
+ char *key_out, size_t key_out_len, const char *secret,
+ size_t secret_len, const char *s2k_specifier);
+
+/** Flag for secret-to-key function: do not use scrypt. */
+#define S2K_FLAG_NO_SCRYPT (1u<<0)
+/** Flag for secret-to-key functions: if using a memory-tuned s2k function,
+ * assume that we have limited memory. */
+#define S2K_FLAG_LOW_MEM (1u<<1)
+/** Flag for secret-to-key functions: force use of pbkdf2. Without this, we
+ * default to scrypt, then RFC2440. */
+#define S2K_FLAG_USE_PBKDF2 (1u<<2)
+
+/** Maximum possible output length from secret_to_key_new. */
+#define S2K_MAXLEN 64
+
+/** Error code from secret-to-key functions: all is well */
+#define S2K_OKAY 0
+/** Error code from secret-to-key functions: generic failure */
+#define S2K_FAILED -1
+/** Error code from secret-to-key functions: provided secret didn't match */
+#define S2K_BAD_SECRET -2
+/** Error code from secret-to-key functions: didn't recognize the algorithm */
+#define S2K_BAD_ALGORITHM -3
+/** Error code from secret-to-key functions: specifier wasn't valid */
+#define S2K_BAD_PARAMS -4
+/** Error code from secret-to-key functions: compiled without scrypt */
+#define S2K_NO_SCRYPT_SUPPORT -5
+/** Error code from secret-to-key functions: not enough space to write output.
+ */
+#define S2K_TRUNCATED -6
+/** Error code from secret-to-key functions: Wrong length for specifier. */
+#define S2K_BAD_LEN -7
+
+int secret_to_key_new(uint8_t *buf,
+ size_t buf_len,
+ size_t *len_out,
+ const char *secret, size_t secret_len,
+ unsigned flags);
+
+int secret_to_key_make_specifier(uint8_t *buf, size_t buf_len, unsigned flags);
+
+int secret_to_key_check(const uint8_t *spec_and_key, size_t spec_and_key_len,
+ const char *secret, size_t secret_len);
+
+int secret_to_key_derivekey(uint8_t *key_out, size_t key_out_len,
+ const uint8_t *spec, size_t spec_len,
+ const char *secret, size_t secret_len);
+
+#ifdef CRYPTO_S2K_PRIVATE
+STATIC int secret_to_key_compute_key(uint8_t *key_out, size_t key_out_len,
+ const uint8_t *spec, size_t spec_len,
+ const char *secret, size_t secret_len,
+ int type);
+#endif
+
+#endif
+
diff --git a/src/common/di_ops.c b/src/common/di_ops.c
index 14a1443400..0dcd6924e7 100644
--- a/src/common/di_ops.c
+++ b/src/common/di_ops.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -130,6 +130,7 @@ tor_memeq(const void *a, const void *b, size_t sz)
* 1 & ((any_difference - 1) >> 8) == 0
*/
+ /*coverity[overflow]*/
return 1 & ((any_difference - 1) >> 8);
}
@@ -217,6 +218,7 @@ safe_mem_is_zero(const void *mem, size_t sz)
total |= *ptr++;
}
+ /*coverity[overflow]*/
return 1 & ((total - 1) >> 8);
}
diff --git a/src/common/di_ops.h b/src/common/di_ops.h
index d93534b69b..935f93fc1a 100644
--- a/src/common/di_ops.h
+++ b/src/common/di_ops.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/common/include.am b/src/common/include.am
index 68e0110c26..6441596199 100644
--- a/src/common/include.am
+++ b/src/common/include.am
@@ -16,7 +16,7 @@ EXTRA_DIST+= \
src/common/Makefile.nmake
#CFLAGS = -Wall -Wpointer-arith -O2
-AM_CPPFLAGS += -I$(srcdir)/src/common -Isrc/common
+AM_CPPFLAGS += -I$(srcdir)/src/common -Isrc/common -I$(srcdir)/src/ext/trunnel -I$(srcdir)/src/trunnel
if USE_OPENBSD_MALLOC
libor_extra_source=src/ext/OpenBSD_malloc_Linux.c
@@ -52,9 +52,7 @@ LIBDONNA=
endif
endif
-if CURVE25519_ENABLED
-libcrypto_extra_source=src/common/crypto_curve25519.c
-endif
+LIBDONNA += $(LIBED25519_REF10)
LIBOR_A_SOURCES = \
src/common/address.c \
@@ -69,16 +67,21 @@ LIBOR_A_SOURCES = \
src/common/util_process.c \
src/common/sandbox.c \
src/ext/csiphash.c \
+ src/ext/trunnel/trunnel.c \
$(libor_extra_source) \
$(libor_mempool_source)
LIBOR_CRYPTO_A_SOURCES = \
src/common/aes.c \
src/common/crypto.c \
+ src/common/crypto_pwbox.c \
+ src/common/crypto_s2k.c \
src/common/crypto_format.c \
src/common/torgzip.c \
src/common/tortls.c \
- $(libcrypto_extra_source)
+ src/trunnel/pwbox.c \
+ src/common/crypto_curve25519.c \
+ src/common/crypto_ed25519.c
LIBOR_EVENT_A_SOURCES = \
src/common/compat_libevent.c \
@@ -110,6 +113,9 @@ COMMONHEADERS = \
src/common/container.h \
src/common/crypto.h \
src/common/crypto_curve25519.h \
+ src/common/crypto_ed25519.h \
+ src/common/crypto_pwbox.h \
+ src/common/crypto_s2k.h \
src/common/di_ops.h \
src/common/memarea.h \
src/common/linux_syscalls.inc \
diff --git a/src/common/log.c b/src/common/log.c
index 2e51e5c578..ad0da7da6b 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -117,15 +117,33 @@ static int syslog_count = 0;
/** Represents a log message that we are going to send to callback-driven
* loggers once we can do so in a non-reentrant way. */
-typedef struct pending_cb_message_t {
+typedef struct pending_log_message_t {
int severity; /**< The severity of the message */
log_domain_mask_t domain; /**< The domain of the message */
+ char *fullmsg; /**< The message, with all decorations */
char *msg; /**< The content of the message */
-} pending_cb_message_t;
+} pending_log_message_t;
/** Log messages waiting to be replayed onto callback-based logs */
static smartlist_t *pending_cb_messages = NULL;
+/** Log messages waiting to be replayed once the logging system is initialized.
+ */
+static smartlist_t *pending_startup_messages = NULL;
+
+/** Number of bytes of messages queued in pending_startup_messages. (This is
+ * the length of the messages, not the number of bytes used to store
+ * them.) */
+static size_t pending_startup_messages_len;
+
+/** True iff we should store messages while waiting for the logs to get
+ * configured. */
+static int queue_startup_messages = 1;
+
+/** Don't store more than this many bytes of messages while waiting for the
+ * logs to get configured. */
+#define MAX_STARTUP_MSG_LEN (1<<16)
+
/** Lock the log_mutex to prevent others from changing the logfile_t list */
#define LOCK_LOGS() STMT_BEGIN \
tor_mutex_acquire(&log_mutex); \
@@ -329,6 +347,102 @@ format_msg(char *buf, size_t buf_len,
return end_of_prefix;
}
+/* Create a new pending_log_message_t with appropriate values */
+static pending_log_message_t *
+pending_log_message_new(int severity, log_domain_mask_t domain,
+ const char *fullmsg, const char *shortmsg)
+{
+ pending_log_message_t *m = tor_malloc(sizeof(pending_log_message_t));
+ m->severity = severity;
+ m->domain = domain;
+ m->fullmsg = fullmsg ? tor_strdup(fullmsg) : NULL;
+ m->msg = tor_strdup(shortmsg);
+ return m;
+}
+
+/** Release all storage held by <b>msg</b>. */
+static void
+pending_log_message_free(pending_log_message_t *msg)
+{
+ if (!msg)
+ return;
+ tor_free(msg->msg);
+ tor_free(msg->fullmsg);
+ tor_free(msg);
+}
+
+/** Return true iff <b>lf</b> would like to receive a message with the
+ * specified <b>severity</b> in the specified <b>domain</b>.
+ */
+static INLINE int
+logfile_wants_message(const logfile_t *lf, int severity,
+ log_domain_mask_t domain)
+{
+ if (! (lf->severities->masks[SEVERITY_MASK_IDX(severity)] & domain)) {
+ return 0;
+ }
+ if (! (lf->fd >= 0 || lf->is_syslog || lf->callback)) {
+ return 0;
+ }
+ if (lf->seems_dead) {
+ return 0;
+ }
+
+ return 1;
+}
+
+/** Send a message to <b>lf</b>. The full message, with time prefix and
+ * severity, is in <b>buf</b>. The message itself is in
+ * <b>msg_after_prefix</b>. If <b>callbacks_deferred</b> points to true, then
+ * we already deferred this message for pending callbacks and don't need to do
+ * it again. Otherwise, if we need to do it, do it, and set
+ * <b>callbacks_deferred</b> to 1. */
+static INLINE void
+logfile_deliver(logfile_t *lf, const char *buf, size_t msg_len,
+ const char *msg_after_prefix, log_domain_mask_t domain,
+ int severity, int *callbacks_deferred)
+{
+
+ if (lf->is_syslog) {
+#ifdef HAVE_SYSLOG_H
+#ifdef MAXLINE
+ /* Some syslog implementations have limits on the length of what you can
+ * pass them, and some very old ones do not detect overflow so well.
+ * Regrettably, they call their maximum line length MAXLINE. */
+#if MAXLINE < 64
+#warn "MAXLINE is a very low number; it might not be from syslog.h after all"
+#endif
+ char *m = msg_after_prefix;
+ if (msg_len >= MAXLINE)
+ m = tor_strndup(msg_after_prefix, MAXLINE-1);
+ syslog(severity, "%s", m);
+ if (m != msg_after_prefix) {
+ tor_free(m);
+ }
+#else
+ /* We have syslog but not MAXLINE. That's promising! */
+ syslog(severity, "%s", msg_after_prefix);
+#endif
+#endif
+ } else if (lf->callback) {
+ if (domain & LD_NOCB) {
+ if (!*callbacks_deferred && pending_cb_messages) {
+ smartlist_add(pending_cb_messages,
+ pending_log_message_new(severity,domain,NULL,msg_after_prefix));
+ *callbacks_deferred = 1;
+ }
+ } else {
+ lf->callback(severity, domain, msg_after_prefix);
+ }
+ } else {
+ if (write_all(lf->fd, buf, msg_len, 0) < 0) { /* error */
+ /* don't log the error! mark this log entry to be blown away, and
+ * continue. */
+ lf->seems_dead = 1;
+ }
+ }
+}
+
/** Helper: sends a message to the appropriate logfiles, at loglevel
* <b>severity</b>. If provided, <b>funcname</b> is prepended to the
* message. The actual message is derived as from tor_snprintf(format,ap).
@@ -354,20 +468,21 @@ logv,(int severity, log_domain_mask_t domain, const char *funcname,
if ((! (domain & LD_NOCB)) && smartlist_len(pending_cb_messages))
flush_pending_log_callbacks();
- lf = logfiles;
- while (lf) {
- if (! (lf->severities->masks[SEVERITY_MASK_IDX(severity)] & domain)) {
- lf = lf->next;
- continue;
- }
- if (! (lf->fd >= 0 || lf->is_syslog || lf->callback)) {
- lf = lf->next;
- continue;
- }
- if (lf->seems_dead) {
- lf = lf->next;
+ if (queue_startup_messages &&
+ pending_startup_messages_len < MAX_STARTUP_MSG_LEN) {
+ end_of_prefix =
+ format_msg(buf, sizeof(buf), domain, severity, funcname, suffix,
+ format, ap, &msg_len);
+ formatted = 1;
+
+ smartlist_add(pending_startup_messages,
+ pending_log_message_new(severity,domain,buf,end_of_prefix));
+ pending_startup_messages_len += msg_len;
+ }
+
+ for (lf = logfiles; lf; lf = lf->next) {
+ if (! logfile_wants_message(lf, severity, domain))
continue;
- }
if (!formatted) {
end_of_prefix =
@@ -376,51 +491,8 @@ logv,(int severity, log_domain_mask_t domain, const char *funcname,
formatted = 1;
}
- if (lf->is_syslog) {
-#ifdef HAVE_SYSLOG_H
- char *m = end_of_prefix;
-#ifdef MAXLINE
- /* Some syslog implementations have limits on the length of what you can
- * pass them, and some very old ones do not detect overflow so well.
- * Regrettably, they call their maximum line length MAXLINE. */
-#if MAXLINE < 64
-#warn "MAXLINE is a very low number; it might not be from syslog.h after all"
-#endif
- if (msg_len >= MAXLINE)
- m = tor_strndup(end_of_prefix, MAXLINE-1);
-#endif
- syslog(severity, "%s", m);
-#ifdef MAXLINE
- if (m != end_of_prefix) {
- tor_free(m);
- }
-#endif
-#endif
- lf = lf->next;
- continue;
- } else if (lf->callback) {
- if (domain & LD_NOCB) {
- if (!callbacks_deferred && pending_cb_messages) {
- pending_cb_message_t *msg = tor_malloc(sizeof(pending_cb_message_t));
- msg->severity = severity;
- msg->domain = domain;
- msg->msg = tor_strdup(end_of_prefix);
- smartlist_add(pending_cb_messages, msg);
-
- callbacks_deferred = 1;
- }
- } else {
- lf->callback(severity, domain, end_of_prefix);
- }
- lf = lf->next;
- continue;
- }
- if (write_all(lf->fd, buf, msg_len, 0) < 0) { /* error */
- /* don't log the error! mark this log entry to be blown away, and
- * continue. */
- lf->seems_dead = 1;
- }
- lf = lf->next;
+ logfile_deliver(lf, buf, msg_len, end_of_prefix, domain, severity,
+ &callbacks_deferred);
}
UNLOCK_LOGS();
}
@@ -724,12 +796,14 @@ void
logs_free_all(void)
{
logfile_t *victim, *next;
- smartlist_t *messages;
+ smartlist_t *messages, *messages2;
LOCK_LOGS();
next = logfiles;
logfiles = NULL;
messages = pending_cb_messages;
pending_cb_messages = NULL;
+ messages2 = pending_startup_messages;
+ pending_startup_messages = NULL;
UNLOCK_LOGS();
while (next) {
victim = next;
@@ -739,12 +813,18 @@ logs_free_all(void)
}
tor_free(appname);
- SMARTLIST_FOREACH(messages, pending_cb_message_t *, msg, {
- tor_free(msg->msg);
- tor_free(msg);
+ SMARTLIST_FOREACH(messages, pending_log_message_t *, msg, {
+ pending_log_message_free(msg);
});
smartlist_free(messages);
+ if (messages2) {
+ SMARTLIST_FOREACH(messages2, pending_log_message_t *, msg, {
+ pending_log_message_free(msg);
+ });
+ smartlist_free(messages2);
+ }
+
/* We _could_ destroy the log mutex here, but that would screw up any logs
* that happened between here and the end of execution. */
}
@@ -839,7 +919,7 @@ add_stream_log(const log_severity_list_t *severity, const char *name, int fd)
/** Initialize the global logging facility */
void
-init_logging(void)
+init_logging(int disable_startup_queue)
{
if (!log_mutex_initialized) {
tor_mutex_init(&log_mutex);
@@ -847,6 +927,11 @@ init_logging(void)
}
if (pending_cb_messages == NULL)
pending_cb_messages = smartlist_new();
+ if (disable_startup_queue)
+ queue_startup_messages = 0;
+ if (pending_startup_messages == NULL && queue_startup_messages) {
+ pending_startup_messages = smartlist_new();
+ }
}
/** Set whether we report logging domains as a part of our log messages.
@@ -932,7 +1017,7 @@ flush_pending_log_callbacks(void)
messages = pending_cb_messages;
pending_cb_messages = smartlist_new();
do {
- SMARTLIST_FOREACH_BEGIN(messages, pending_cb_message_t *, msg) {
+ SMARTLIST_FOREACH_BEGIN(messages, pending_log_message_t *, msg) {
const int severity = msg->severity;
const int domain = msg->domain;
for (lf = logfiles; lf; lf = lf->next) {
@@ -942,8 +1027,7 @@ flush_pending_log_callbacks(void)
}
lf->callback(severity, domain, msg->msg);
}
- tor_free(msg->msg);
- tor_free(msg);
+ pending_log_message_free(msg);
} SMARTLIST_FOREACH_END(msg);
smartlist_clear(messages);
@@ -957,6 +1041,39 @@ flush_pending_log_callbacks(void)
UNLOCK_LOGS();
}
+/** Flush all the messages we stored from startup while waiting for log
+ * initialization.
+ */
+void
+flush_log_messages_from_startup(void)
+{
+ logfile_t *lf;
+
+ LOCK_LOGS();
+ queue_startup_messages = 0;
+ pending_startup_messages_len = 0;
+ if (! pending_startup_messages)
+ goto out;
+
+ SMARTLIST_FOREACH_BEGIN(pending_startup_messages, pending_log_message_t *,
+ msg) {
+ int callbacks_deferred = 0;
+ for (lf = logfiles; lf; lf = lf->next) {
+ if (! logfile_wants_message(lf, msg->severity, msg->domain))
+ continue;
+
+ logfile_deliver(lf, msg->fullmsg, strlen(msg->fullmsg), msg->msg,
+ msg->domain, msg->severity, &callbacks_deferred);
+ }
+ pending_log_message_free(msg);
+ } SMARTLIST_FOREACH_END(msg);
+ smartlist_free(pending_startup_messages);
+ pending_startup_messages = NULL;
+
+ out:
+ UNLOCK_LOGS();
+}
+
/** Close any log handlers added by add_temp_log() or marked by
* mark_logs_temp(). */
void
diff --git a/src/common/memarea.c b/src/common/memarea.c
index bcaea0949e..40c09bd0e6 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2013, The Tor Project, Inc. */
+/* Copyright (c) 2008-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/** \file memarea.c
diff --git a/src/common/memarea.h b/src/common/memarea.h
index 8b88585d35..fb261d11fa 100644
--- a/src/common/memarea.h
+++ b/src/common/memarea.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2013, The Tor Project, Inc. */
+/* Copyright (c) 2008-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Tor dependencies */
diff --git a/src/common/mempool.c b/src/common/mempool.c
index 4389888760..695a110d3d 100644
--- a/src/common/mempool.c
+++ b/src/common/mempool.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#if 1
/* Tor dependencies */
diff --git a/src/common/mempool.h b/src/common/mempool.h
index 0fc1e4c676..1e7a3121de 100644
--- a/src/common/mempool.h
+++ b/src/common/mempool.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/common/procmon.c b/src/common/procmon.c
index 7c9b7c3c88..ee27e97f79 100644
--- a/src/common/procmon.c
+++ b/src/common/procmon.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/common/procmon.h b/src/common/procmon.h
index b9388e2e90..6c487648bb 100644
--- a/src/common/procmon.h
+++ b/src/common/procmon.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/common/sandbox.c b/src/common/sandbox.c
index 05b91be7be..ece56df81f 100644
--- a/src/common/sandbox.c
+++ b/src/common/sandbox.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -98,6 +98,8 @@ static sandbox_cfg_t *filter_dynamic = NULL;
#undef SCMP_CMP
#define SCMP_CMP(a,b,c) ((struct scmp_arg_cmp){(a),(b),(c),0})
+#define SCMP_CMP_STR(a,b,c) \
+ ((struct scmp_arg_cmp) {(a),(b),(intptr_t)(void*)(c),0})
#define SCMP_CMP4(a,b,c,d) ((struct scmp_arg_cmp){(a),(b),(c),(d)})
/* We use a wrapper here because these masked comparisons seem to be pretty
* verbose. Also, it's important to cast to scmp_datum_t before negating the
@@ -252,7 +254,7 @@ sb_execve(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
if (param != NULL && param->prot == 1 && param->syscall
== SCMP_SYS(execve)) {
rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(execve),
- SCMP_CMP(0, SCMP_CMP_EQ, param->value));
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value));
if (rc != 0) {
log_err(LD_BUG,"(Sandbox) failed to add execve syscall, received "
"libseccomp error %d", rc);
@@ -389,7 +391,7 @@ sb_open(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
if (param != NULL && param->prot == 1 && param->syscall
== SCMP_SYS(open)) {
rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(open),
- SCMP_CMP(0, SCMP_CMP_EQ, param->value));
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value));
if (rc != 0) {
log_err(LD_BUG,"(Sandbox) failed to add open syscall, received "
"libseccomp error %d", rc);
@@ -444,8 +446,8 @@ sb_rename(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
param->syscall == SCMP_SYS(rename)) {
rc = seccomp_rule_add_2(ctx, SCMP_ACT_ALLOW, SCMP_SYS(rename),
- SCMP_CMP(0, SCMP_CMP_EQ, param->value),
- SCMP_CMP(1, SCMP_CMP_EQ, param->value2));
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value),
+ SCMP_CMP_STR(1, SCMP_CMP_EQ, param->value2));
if (rc != 0) {
log_err(LD_BUG,"(Sandbox) failed to add rename syscall, received "
"libseccomp error %d", rc);
@@ -475,7 +477,7 @@ sb_openat(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
== SCMP_SYS(openat)) {
rc = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(openat),
SCMP_CMP(0, SCMP_CMP_EQ, AT_FDCWD),
- SCMP_CMP(1, SCMP_CMP_EQ, param->value),
+ SCMP_CMP_STR(1, SCMP_CMP_EQ, param->value),
SCMP_CMP(2, SCMP_CMP_EQ, O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY|
O_CLOEXEC));
if (rc != 0) {
@@ -884,7 +886,7 @@ sb_stat64(scmp_filter_ctx ctx, sandbox_cfg_t *filter)
if (param != NULL && param->prot == 1 && (param->syscall == SCMP_SYS(open)
|| param->syscall == SCMP_SYS(stat64))) {
rc = seccomp_rule_add_1(ctx, SCMP_ACT_ALLOW, SCMP_SYS(stat64),
- SCMP_CMP(0, SCMP_CMP_EQ, param->value));
+ SCMP_CMP_STR(0, SCMP_CMP_EQ, param->value));
if (rc != 0) {
log_err(LD_BUG,"(Sandbox) failed to add open syscall, received "
"libseccomp error %d", rc);
@@ -967,7 +969,7 @@ static int
prot_strings_helper(strmap_t *locations,
char **pr_mem_next_p,
size_t *pr_mem_left_p,
- intptr_t *value_p)
+ char **value_p)
{
char *param_val;
size_t param_size;
@@ -983,7 +985,7 @@ prot_strings_helper(strmap_t *locations,
if (location) {
// We already interned this string.
tor_free(param_val);
- *value_p = (intptr_t) location;
+ *value_p = location;
return 0;
} else if (*pr_mem_left_p >= param_size) {
// copy to protected
@@ -992,7 +994,7 @@ prot_strings_helper(strmap_t *locations,
// re-point el parameter to protected
tor_free(param_val);
- *value_p = (intptr_t) location;
+ *value_p = location;
strmap_set(locations, location, location); /* good real estate advice */
@@ -1074,7 +1076,7 @@ prot_strings(scmp_filter_ctx ctx, sandbox_cfg_t* cfg)
SCMP_CMP(0, SCMP_CMP_EQ, (intptr_t) pr_mem_base));
if (ret) {
log_err(LD_BUG,"(Sandbox) mremap protected memory filter fail!");
- return ret;
+ goto out;
}
// no munmap of the protected base address
@@ -1082,7 +1084,7 @@ prot_strings(scmp_filter_ctx ctx, sandbox_cfg_t* cfg)
SCMP_CMP(0, SCMP_CMP_EQ, (intptr_t) pr_mem_base));
if (ret) {
log_err(LD_BUG,"(Sandbox) munmap protected memory filter fail!");
- return ret;
+ goto out;
}
/*
@@ -1101,7 +1103,7 @@ prot_strings(scmp_filter_ctx ctx, sandbox_cfg_t* cfg)
SCMP_CMP(2, SCMP_CMP_EQ, PROT_READ|PROT_WRITE));
if (ret) {
log_err(LD_BUG,"(Sandbox) mprotect protected memory filter fail (LT)!");
- return ret;
+ goto out;
}
ret = seccomp_rule_add_3(ctx, SCMP_ACT_ALLOW, SCMP_SYS(mprotect),
@@ -1111,7 +1113,7 @@ prot_strings(scmp_filter_ctx ctx, sandbox_cfg_t* cfg)
SCMP_CMP(2, SCMP_CMP_EQ, PROT_READ|PROT_WRITE));
if (ret) {
log_err(LD_BUG,"(Sandbox) mprotect protected memory filter fail (GT)!");
- return ret;
+ goto out;
}
out:
@@ -1126,7 +1128,7 @@ prot_strings(scmp_filter_ctx ctx, sandbox_cfg_t* cfg)
* point.
*/
static sandbox_cfg_t*
-new_element2(int syscall, intptr_t value, intptr_t value2)
+new_element2(int syscall, char *value, char *value2)
{
smp_param_t *param = NULL;
@@ -1142,9 +1144,9 @@ new_element2(int syscall, intptr_t value, intptr_t value2)
}
static sandbox_cfg_t*
-new_element(int syscall, intptr_t value)
+new_element(int syscall, char *value)
{
- return new_element2(syscall, value, 0);
+ return new_element2(syscall, value, NULL);
}
#ifdef __NR_stat64
@@ -1158,7 +1160,7 @@ sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file)
{
sandbox_cfg_t *elem = NULL;
- elem = new_element(SCMP_stat, (intptr_t)(void*) file);
+ elem = new_element(SCMP_stat, file);
if (!elem) {
log_err(LD_BUG,"(Sandbox) failed to register parameter!");
return -1;
@@ -1171,33 +1173,11 @@ sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file)
}
int
-sandbox_cfg_allow_stat_filename_array(sandbox_cfg_t **cfg, ...)
-{
- int rc = 0;
- char *fn = NULL;
-
- va_list ap;
- va_start(ap, cfg);
-
- while ((fn = va_arg(ap, char*)) != NULL) {
- rc = sandbox_cfg_allow_stat_filename(cfg, fn);
- if (rc) {
- log_err(LD_BUG,"(Sandbox) sandbox_cfg_allow_stat_filename_array fail");
- goto end;
- }
- }
-
- end:
- va_end(ap);
- return 0;
-}
-
-int
sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
{
sandbox_cfg_t *elem = NULL;
- elem = new_element(SCMP_SYS(open), (intptr_t)(void *) file);
+ elem = new_element(SCMP_SYS(open), file);
if (!elem) {
log_err(LD_BUG,"(Sandbox) failed to register parameter!");
return -1;
@@ -1214,9 +1194,7 @@ sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2)
{
sandbox_cfg_t *elem = NULL;
- elem = new_element2(SCMP_SYS(rename),
- (intptr_t)(void *) file1,
- (intptr_t)(void *) file2);
+ elem = new_element2(SCMP_SYS(rename), file1, file2);
if (!elem) {
log_err(LD_BUG,"(Sandbox) failed to register parameter!");
@@ -1230,33 +1208,11 @@ sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2)
}
int
-sandbox_cfg_allow_open_filename_array(sandbox_cfg_t **cfg, ...)
-{
- int rc = 0;
- char *fn = NULL;
-
- va_list ap;
- va_start(ap, cfg);
-
- while ((fn = va_arg(ap, char*)) != NULL) {
- rc = sandbox_cfg_allow_open_filename(cfg, fn);
- if (rc) {
- log_err(LD_BUG,"(Sandbox) sandbox_cfg_allow_open_filename_array fail");
- goto end;
- }
- }
-
- end:
- va_end(ap);
- return 0;
-}
-
-int
sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file)
{
sandbox_cfg_t *elem = NULL;
- elem = new_element(SCMP_SYS(openat), (intptr_t)(void *) file);
+ elem = new_element(SCMP_SYS(openat), file);
if (!elem) {
log_err(LD_BUG,"(Sandbox) failed to register parameter!");
return -1;
@@ -1268,35 +1224,13 @@ sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file)
return 0;
}
-int
-sandbox_cfg_allow_openat_filename_array(sandbox_cfg_t **cfg, ...)
-{
- int rc = 0;
- char *fn = NULL;
-
- va_list ap;
- va_start(ap, cfg);
-
- while ((fn = va_arg(ap, char*)) != NULL) {
- rc = sandbox_cfg_allow_openat_filename(cfg, fn);
- if (rc) {
- log_err(LD_BUG,"(Sandbox) sandbox_cfg_allow_openat_filename_array fail");
- goto end;
- }
- }
-
- end:
- va_end(ap);
- return 0;
-}
-
#if 0
int
sandbox_cfg_allow_execve(sandbox_cfg_t **cfg, const char *com)
{
sandbox_cfg_t *elem = NULL;
- elem = new_element(SCMP_SYS(execve), (intptr_t)(void *) com);
+ elem = new_element(SCMP_SYS(execve), com);
if (!elem) {
log_err(LD_BUG,"(Sandbox) failed to register parameter!");
return -1;
@@ -1308,28 +1242,6 @@ sandbox_cfg_allow_execve(sandbox_cfg_t **cfg, const char *com)
return 0;
}
-int
-sandbox_cfg_allow_execve_array(sandbox_cfg_t **cfg, ...)
-{
- int rc = 0;
- char *fn = NULL;
-
- va_list ap;
- va_start(ap, cfg);
-
- while ((fn = va_arg(ap, char*)) != NULL) {
-
- rc = sandbox_cfg_allow_execve(cfg, fn);
- if (rc) {
- log_err(LD_BUG,"(Sandbox) sandbox_cfg_allow_execve_array failed");
- goto end;
- }
- }
-
- end:
- va_end(ap);
- return 0;
-}
#endif
/** Cache entry for getaddrinfo results; used when sandboxing is implemented
@@ -1380,10 +1292,22 @@ static HT_HEAD(getaddrinfo_cache, cached_getaddrinfo_item_t)
HT_PROTOTYPE(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
cached_getaddrinfo_item_hash,
cached_getaddrinfo_items_eq);
-HT_GENERATE(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
- cached_getaddrinfo_item_hash,
- cached_getaddrinfo_items_eq,
- 0.6, tor_malloc_, tor_realloc_, tor_free_);
+HT_GENERATE2(getaddrinfo_cache, cached_getaddrinfo_item_t, node,
+ cached_getaddrinfo_item_hash,
+ cached_getaddrinfo_items_eq,
+ 0.6, tor_reallocarray_, tor_free_)
+
+/** If true, don't try to cache getaddrinfo results. */
+static int sandbox_getaddrinfo_cache_disabled = 0;
+
+/** Tell the sandbox layer not to try to cache getaddrinfo results. Used as in
+ * tor-resolve, when we have no intention of initializing crypto or of
+ * installing the sandbox.*/
+void
+sandbox_disable_getaddrinfo_cache(void)
+{
+ sandbox_getaddrinfo_cache_disabled = 1;
+}
int
sandbox_getaddrinfo(const char *name, const char *servname,
@@ -1393,6 +1317,10 @@ sandbox_getaddrinfo(const char *name, const char *servname,
int err;
struct cached_getaddrinfo_item_t search, *item;
+ if (sandbox_getaddrinfo_cache_disabled) {
+ return getaddrinfo(name, NULL, hints, res);
+ }
+
if (servname != NULL) {
log_warn(LD_BUG, "called with non-NULL servname");
return EAI_NONAME;
@@ -1772,26 +1700,12 @@ sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file)
}
int
-sandbox_cfg_allow_open_filename_array(sandbox_cfg_t **cfg, ...)
-{
- (void)cfg;
- return 0;
-}
-
-int
sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file)
{
(void)cfg; (void)file;
return 0;
}
-int
-sandbox_cfg_allow_openat_filename_array(sandbox_cfg_t **cfg, ...)
-{
- (void)cfg;
- return 0;
-}
-
#if 0
int
sandbox_cfg_allow_execve(sandbox_cfg_t **cfg, const char *com)
@@ -1799,13 +1713,6 @@ sandbox_cfg_allow_execve(sandbox_cfg_t **cfg, const char *com)
(void)cfg; (void)com;
return 0;
}
-
-int
-sandbox_cfg_allow_execve_array(sandbox_cfg_t **cfg, ...)
-{
- (void)cfg;
- return 0;
-}
#endif
int
@@ -1816,13 +1723,6 @@ sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file)
}
int
-sandbox_cfg_allow_stat_filename_array(sandbox_cfg_t **cfg, ...)
-{
- (void)cfg;
- return 0;
-}
-
-int
sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2)
{
(void)cfg; (void)file1; (void)file2;
@@ -1834,5 +1734,10 @@ sandbox_is_active(void)
{
return 0;
}
+
+void
+sandbox_disable_getaddrinfo_cache(void)
+{
+}
#endif
diff --git a/src/common/sandbox.h b/src/common/sandbox.h
index 20d5d5080c..ad001865a7 100644
--- a/src/common/sandbox.h
+++ b/src/common/sandbox.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -66,9 +66,9 @@ typedef struct smp_param {
int syscall;
/** parameter value. */
- intptr_t value;
+ char *value;
/** parameter value, second argument. */
- intptr_t value2;
+ char *value2;
/** parameter flag (0 = not protected, 1 = protected). */
int prot;
@@ -149,14 +149,6 @@ int sandbox_cfg_allow_open_filename(sandbox_cfg_t **cfg, char *file);
/**DOCDOC*/
int sandbox_cfg_allow_rename(sandbox_cfg_t **cfg, char *file1, char *file2);
-/** Function used to add a series of open allowed filenames to a supplied
- * configuration.
- * @param cfg sandbox configuration.
- * @param ... a list of stealable pointers to permitted files. The last
- * one must be NULL.
-*/
-int sandbox_cfg_allow_open_filename_array(sandbox_cfg_t **cfg, ...);
-
/**
* Function used to add a openat allowed filename to a supplied configuration.
* The (char*) specifies the path to the allowed file; we steal the pointer to
@@ -164,28 +156,12 @@ int sandbox_cfg_allow_open_filename_array(sandbox_cfg_t **cfg, ...);
*/
int sandbox_cfg_allow_openat_filename(sandbox_cfg_t **cfg, char *file);
-/** Function used to add a series of openat allowed filenames to a supplied
- * configuration.
- * @param cfg sandbox configuration.
- * @param ... a list of stealable pointers to permitted files. The last
- * one must be NULL.
- */
-int sandbox_cfg_allow_openat_filename_array(sandbox_cfg_t **cfg, ...);
-
#if 0
/**
* Function used to add a execve allowed filename to a supplied configuration.
* The (char*) specifies the path to the allowed file; that pointer is stolen.
*/
int sandbox_cfg_allow_execve(sandbox_cfg_t **cfg, const char *com);
-
-/** Function used to add a series of execve allowed filenames to a supplied
- * configuration.
- * @param cfg sandbox configuration.
- * @param ... an array of stealable pointers to permitted files. The last
- * one must be NULL.
- */
-int sandbox_cfg_allow_execve_array(sandbox_cfg_t **cfg, ...);
#endif
/**
@@ -194,19 +170,13 @@ int sandbox_cfg_allow_execve_array(sandbox_cfg_t **cfg, ...);
*/
int sandbox_cfg_allow_stat_filename(sandbox_cfg_t **cfg, char *file);
-/** Function used to add a series of stat64 allowed filenames to a supplied
- * configuration.
- * @param cfg sandbox configuration.
- * @param ... an array of stealable pointers to permitted files. The last
- * one must be NULL.
- */
-int sandbox_cfg_allow_stat_filename_array(sandbox_cfg_t **cfg, ...);
-
/** Function used to initialise a sandbox configuration.*/
int sandbox_init(sandbox_cfg_t* cfg);
/** Return true iff the sandbox is turned on. */
int sandbox_is_active(void);
+void sandbox_disable_getaddrinfo_cache(void);
+
#endif /* SANDBOX_H_ */
diff --git a/src/common/testsupport.h b/src/common/testsupport.h
index 4a4f50b69b..2610086700 100644
--- a/src/common/testsupport.h
+++ b/src/common/testsupport.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_TESTSUPPORT_H
diff --git a/src/common/torgzip.c b/src/common/torgzip.c
index 15451ee30d..4480e4b747 100644
--- a/src/common/torgzip.c
+++ b/src/common/torgzip.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -46,6 +46,12 @@
#include <zlib.h>
+static size_t tor_zlib_state_size_precalc(int inflate,
+ int windowbits, int memlevel);
+
+/** Total number of bytes allocated for zlib state */
+static size_t total_zlib_allocation = 0;
+
/** Set to 1 if zlib is a version that supports gzip; set to 0 if it doesn't;
* set to -1 if we haven't checked yet. */
static int gzip_is_supported = -1;
@@ -411,6 +417,9 @@ struct tor_zlib_state_t {
size_t input_so_far;
/** Number of bytes written so far. Used to detect zlib bombs. */
size_t output_so_far;
+
+ /** Approximate number of bytes allocated for this object. */
+ size_t allocation;
};
/** Construct and return a tor_zlib_state_t object using <b>method</b>. If
@@ -420,6 +429,7 @@ tor_zlib_state_t *
tor_zlib_new(int compress, compress_method_t method)
{
tor_zlib_state_t *out;
+ int bits;
if (method == GZIP_METHOD && !is_gzip_supported()) {
/* Old zlib version don't support gzip in inflateInit2 */
@@ -432,14 +442,19 @@ tor_zlib_new(int compress, compress_method_t method)
out->stream.zfree = Z_NULL;
out->stream.opaque = NULL;
out->compress = compress;
+ bits = method_bits(method);
if (compress) {
if (deflateInit2(&out->stream, Z_BEST_COMPRESSION, Z_DEFLATED,
- method_bits(method), 8, Z_DEFAULT_STRATEGY) != Z_OK)
+ bits, 8, Z_DEFAULT_STRATEGY) != Z_OK)
goto err;
} else {
- if (inflateInit2(&out->stream, method_bits(method)) != Z_OK)
+ if (inflateInit2(&out->stream, bits) != Z_OK)
goto err;
}
+ out->allocation = tor_zlib_state_size_precalc(!compress, bits, 8);
+
+ total_zlib_allocation += out->allocation;
+
return out;
err:
@@ -472,7 +487,7 @@ tor_zlib_process(tor_zlib_state_t *state,
state->stream.avail_out = (unsigned int)*out_len;
if (state->compress) {
- err = deflate(&state->stream, finish ? Z_FINISH : Z_SYNC_FLUSH);
+ err = deflate(&state->stream, finish ? Z_FINISH : Z_NO_FLUSH);
} else {
err = inflate(&state->stream, finish ? Z_FINISH : Z_SYNC_FLUSH);
}
@@ -496,7 +511,7 @@ tor_zlib_process(tor_zlib_state_t *state,
case Z_STREAM_END:
return TOR_ZLIB_DONE;
case Z_BUF_ERROR:
- if (state->stream.avail_in == 0)
+ if (state->stream.avail_in == 0 && !finish)
return TOR_ZLIB_OK;
return TOR_ZLIB_BUF_FULL;
case Z_OK:
@@ -517,6 +532,8 @@ tor_zlib_free(tor_zlib_state_t *state)
if (!state)
return;
+ total_zlib_allocation -= state->allocation;
+
if (state->compress)
deflateEnd(&state->stream);
else
@@ -525,3 +542,48 @@ tor_zlib_free(tor_zlib_state_t *state)
tor_free(state);
}
+/** Return an approximate number of bytes used in RAM to hold a state with
+ * window bits <b>windowBits</b> and compression level 'memlevel' */
+static size_t
+tor_zlib_state_size_precalc(int inflate, int windowbits, int memlevel)
+{
+ windowbits &= 15;
+
+#define A_FEW_KILOBYTES 2048
+
+ if (inflate) {
+ /* From zconf.h:
+
+ "The memory requirements for inflate are (in bytes) 1 << windowBits
+ that is, 32K for windowBits=15 (default value) plus a few kilobytes
+ for small objects."
+ */
+ return sizeof(tor_zlib_state_t) + sizeof(struct z_stream_s) +
+ (1 << 15) + A_FEW_KILOBYTES;
+ } else {
+ /* Also from zconf.h:
+
+ "The memory requirements for deflate are (in bytes):
+ (1 << (windowBits+2)) + (1 << (memLevel+9))
+ ... plus a few kilobytes for small objects."
+ */
+ return sizeof(tor_zlib_state_t) + sizeof(struct z_stream_s) +
+ (1 << (windowbits + 2)) + (1 << (memlevel + 9)) + A_FEW_KILOBYTES;
+ }
+#undef A_FEW_KILOBYTES
+}
+
+/** Return the approximate number of bytes allocated for <b>state</b>. */
+size_t
+tor_zlib_state_size(const tor_zlib_state_t *state)
+{
+ return state->allocation;
+}
+
+/** Return the approximate number of bytes allocated for all zlib states. */
+size_t
+tor_zlib_get_total_allocation(void)
+{
+ return total_zlib_allocation;
+}
+
diff --git a/src/common/torgzip.h b/src/common/torgzip.h
index 5db03fe6e0..1378d55b76 100644
--- a/src/common/torgzip.h
+++ b/src/common/torgzip.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -55,5 +55,8 @@ tor_zlib_output_t tor_zlib_process(tor_zlib_state_t *state,
int finish);
void tor_zlib_free(tor_zlib_state_t *state);
+size_t tor_zlib_state_size(const tor_zlib_state_t *state);
+size_t tor_zlib_get_total_allocation(void);
+
#endif
diff --git a/src/common/torint.h b/src/common/torint.h
index a993d7649a..d0b0ac14a0 100644
--- a/src/common/torint.h
+++ b/src/common/torint.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -332,30 +332,30 @@ typedef uint32_t uintptr_t;
#endif /* time_t_is_signed */
#endif /* ifndef(TIME_MAX) */
-#ifndef SIZE_T_MAX
+#ifndef SIZE_MAX
#if (SIZEOF_SIZE_T == 4)
-#define SIZE_T_MAX UINT32_MAX
+#define SIZE_MAX UINT32_MAX
#elif (SIZEOF_SIZE_T == 8)
-#define SIZE_T_MAX UINT64_MAX
+#define SIZE_MAX UINT64_MAX
#else
-#error "Can't define SIZE_T_MAX"
+#error "Can't define SIZE_MAX"
#endif
#endif
-#ifndef SSIZE_T_MAX
+#ifndef SSIZE_MAX
#if (SIZEOF_SIZE_T == 4)
-#define SSIZE_T_MAX INT32_MAX
+#define SSIZE_MAX INT32_MAX
#elif (SIZEOF_SIZE_T == 8)
-#define SSIZE_T_MAX INT64_MAX
+#define SSIZE_MAX INT64_MAX
#else
-#error "Can't define SSIZE_T_MAX"
+#error "Can't define SSIZE_MAX"
#endif
#endif
/** Any ssize_t larger than this amount is likely to be an underflow. */
-#define SSIZE_T_CEILING ((ssize_t)(SSIZE_T_MAX-16))
+#define SSIZE_T_CEILING ((ssize_t)(SSIZE_MAX-16))
/** Any size_t larger than this amount is likely to be an underflow. */
-#define SIZE_T_CEILING ((size_t)(SSIZE_T_MAX-16))
+#define SIZE_T_CEILING ((size_t)(SSIZE_MAX-16))
#endif /* __TORINT_H */
diff --git a/src/common/torlog.h b/src/common/torlog.h
index 34e39b4b94..fa7266c199 100644
--- a/src/common/torlog.h
+++ b/src/common/torlog.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001, Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -121,7 +121,7 @@ typedef struct log_severity_list_t {
/** Callback type used for add_callback_log. */
typedef void (*log_callback)(int severity, uint32_t domain, const char *msg);
-void init_logging(void);
+void init_logging(int disable_startup_queue);
int parse_log_level(const char *level);
const char *log_level_to_string(int level);
int parse_log_severity_config(const char **cfg,
@@ -147,6 +147,7 @@ void mark_logs_temp(void);
void change_callback_log_severity(int loglevelMin, int loglevelMax,
log_callback cb);
void flush_pending_log_callbacks(void);
+void flush_log_messages_from_startup(void);
void log_set_application_name(const char *name);
void set_log_time_granularity(int granularity_msec);
void truncate_logs(void);
diff --git a/src/common/tortls.c b/src/common/tortls.c
index 0f989684cf..cca2d420b6 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -782,8 +782,7 @@ static const cipher_info_t CLIENT_CIPHER_INFO_LIST[] = {
};
/** The length of CLIENT_CIPHER_INFO_LIST and CLIENT_CIPHER_DUMMIES. */
-static const int N_CLIENT_CIPHERS =
- sizeof(CLIENT_CIPHER_INFO_LIST)/sizeof(CLIENT_CIPHER_INFO_LIST[0]);
+static const int N_CLIENT_CIPHERS = ARRAY_LENGTH(CLIENT_CIPHER_INFO_LIST);
#endif
#ifndef V2_HANDSHAKE_CLIENT
@@ -1171,6 +1170,9 @@ tor_tls_context_init_one(tor_tls_context_t **ppcontext,
return ((new_ctx != NULL) ? 0 : -1);
}
+/** The group we should use for ecdhe when none was selected. */
+#define NID_tor_default_ecdhe_group NID_X9_62_prime256v1
+
/** Create a new TLS context for use with Tor TLS handshakes.
* <b>identity</b> should be set to the identity key used to sign the
* certificate.
@@ -1241,10 +1243,11 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
goto error;
#endif
- /* Tell OpenSSL to use SSL3 or TLS1 but not SSL2. */
+ /* Tell OpenSSL to use TLS 1.0 or later but not SSL2 or SSL3. */
if (!(result->ctx = SSL_CTX_new(SSLv23_method())))
goto error;
SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv2);
+ SSL_CTX_set_options(result->ctx, SSL_OP_NO_SSLv3);
/* Prefer the server's ordering of ciphers: the client's ordering has
* historically been chosen for fingerprinting resistance. */
@@ -1283,6 +1286,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
}
#endif
+ /* XXX This block is now obsolete. */
if (
#ifdef DISABLE_SSL3_HANDSHAKE
1 ||
@@ -1364,7 +1368,7 @@ tor_tls_context_new(crypto_pk_t *identity, unsigned int key_lifetime,
else if (flags & TOR_TLS_CTX_USE_ECDHE_P256)
nid = NID_X9_62_prime256v1;
else
- nid = NID_X9_62_prime256v1;
+ nid = NID_tor_default_ecdhe_group;
/* Use P-256 for ECDHE. */
ec_key = EC_KEY_new_by_curve_name(nid);
if (ec_key != NULL) /*XXXX Handle errors? */
@@ -1464,6 +1468,43 @@ static uint16_t v2_cipher_list[] = {
/** Have we removed the unrecognized ciphers from v2_cipher_list yet? */
static int v2_cipher_list_pruned = 0;
+/** Return 0 if <b>m</b> does not support the cipher with ID <b>cipher</b>;
+ * return 1 if it does support it, or if we have no way to tell. */
+static int
+find_cipher_by_id(const SSL_METHOD *m, uint16_t cipher)
+{
+ const SSL_CIPHER *c;
+#ifdef HAVE_STRUCT_SSL_METHOD_ST_GET_CIPHER_BY_CHAR
+ if (m && m->get_cipher_by_char) {
+ unsigned char cipherid[3];
+ set_uint16(cipherid, htons(cipher));
+ cipherid[2] = 0; /* If ssl23_get_cipher_by_char finds no cipher starting
+ * with a two-byte 'cipherid', it may look for a v2
+ * cipher with the appropriate 3 bytes. */
+ c = m->get_cipher_by_char(cipherid);
+ if (c)
+ tor_assert((c->id & 0xffff) == cipher);
+ return c != NULL;
+ } else
+#endif
+ if (m && m->get_cipher && m->num_ciphers) {
+ /* It would seem that some of the "let's-clean-up-openssl" forks have
+ * removed the get_cipher_by_char function. Okay, so now you get a
+ * quadratic search.
+ */
+ int i;
+ for (i = 0; i < m->num_ciphers(); ++i) {
+ c = m->get_cipher(i);
+ if (c && (c->id & 0xffff) == cipher) {
+ return 1;
+ }
+ }
+ return 0;
+ } else {
+ return 1; /* No way to search */
+ }
+}
+
/** Remove from v2_cipher_list every cipher that we don't support, so that
* comparing v2_cipher_list to a client's cipher list will give a sensible
* result. */
@@ -1475,16 +1516,7 @@ prune_v2_cipher_list(void)
inp = outp = v2_cipher_list;
while (*inp) {
- unsigned char cipherid[3];
- const SSL_CIPHER *cipher;
- /* Is there no better way to do this? */
- set_uint16(cipherid, htons(*inp));
- cipherid[2] = 0; /* If ssl23_get_cipher_by_char finds no cipher starting
- * with a two-byte 'cipherid', it may look for a v2
- * cipher with the appropriate 3 bytes. */
- cipher = m->get_cipher_by_char(cipherid);
- if (cipher) {
- tor_assert((cipher->id & 0xffff) == *inp);
+ if (find_cipher_by_id(m, *inp)) {
*outp++ = *inp++;
} else {
inp++;
@@ -2611,16 +2643,20 @@ check_no_tls_errors_(const char *fname, int line)
int
tor_tls_used_v1_handshake(tor_tls_t *tls)
{
+#if defined(V2_HANDSHAKE_SERVER) && defined(V2_HANDSHAKE_CLIENT)
+ return ! tls->wasV2Handshake;
+#else
if (tls->isServer) {
-#ifdef V2_HANDSHAKE_SERVER
+# ifdef V2_HANDSHAKE_SERVER
return ! tls->wasV2Handshake;
-#endif
+# endif
} else {
-#ifdef V2_HANDSHAKE_CLIENT
+# ifdef V2_HANDSHAKE_CLIENT
return ! tls->wasV2Handshake;
-#endif
+# endif
}
return 1;
+#endif
}
/** Return true iff <b>name</b> is a DN of a kind that could only
diff --git a/src/common/tortls.h b/src/common/tortls.h
index a76ba3bc7a..235d801202 100644
--- a/src/common/tortls.h
+++ b/src/common/tortls.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_TORTLS_H
diff --git a/src/common/util.c b/src/common/util.c
index 8589344dbe..1359776b21 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -96,6 +96,10 @@
#include <sys/wait.h>
#endif
+#ifdef __clang_analyzer__
+#undef MALLOC_ZERO_WORKS
+#endif
+
/* =====
* Assertion helper.
* ===== */
@@ -191,33 +195,40 @@ tor_malloc_zero_(size_t size DMALLOC_PARAMS)
return result;
}
+/* The square root of SIZE_MAX + 1. If a is less than this, and b is less
+ * than this, then a*b is less than SIZE_MAX. (For example, if size_t is
+ * 32 bits, then SIZE_MAX is 0xffffffff and this value is 0x10000. If a and
+ * b are less than this, then their product is at most (65535*65535) ==
+ * 0xfffe0001. */
+#define SQRT_SIZE_MAX_P1 (((size_t)1) << (sizeof(size_t)*4))
+
+/** Return non-zero if and only if the product of the arguments is exact. */
+static INLINE int
+size_mul_check(const size_t x, const size_t y)
+{
+ /* This first check is equivalent to
+ (x < SQRT_SIZE_MAX_P1 && y < SQRT_SIZE_MAX_P1)
+
+ Rationale: if either one of x or y is >= SQRT_SIZE_MAX_P1, then it
+ will have some bit set in its most significant half.
+ */
+ return ((x|y) < SQRT_SIZE_MAX_P1 ||
+ y == 0 ||
+ x <= SIZE_MAX / y);
+}
+
/** Allocate a chunk of <b>nmemb</b>*<b>size</b> bytes of memory, fill
* the memory with zero bytes, and return a pointer to the result.
* Log and terminate the process on error. (Same as
* calloc(<b>nmemb</b>,<b>size</b>), but never returns NULL.)
- *
- * XXXX This implementation probably asserts in cases where it could
- * work, because it only tries dividing SIZE_MAX by size (according to
- * the calloc(3) man page, the size of an element of the nmemb-element
- * array to be allocated), not by nmemb (which could in theory be
- * smaller than size). Don't do that then.
+ * The second argument (<b>size</b>) should preferably be non-zero
+ * and a compile-time constant.
*/
void *
tor_calloc_(size_t nmemb, size_t size DMALLOC_PARAMS)
{
- /* You may ask yourself, "wouldn't it be smart to use calloc instead of
- * malloc+memset? Perhaps libc's calloc knows some nifty optimization trick
- * we don't!" Indeed it does, but its optimizations are only a big win when
- * we're allocating something very big (it knows if it just got the memory
- * from the OS in a pre-zeroed state). We don't want to use tor_malloc_zero
- * for big stuff, so we don't bother with calloc. */
- void *result;
- size_t max_nmemb = (size == 0) ? SIZE_MAX : SIZE_MAX/size;
-
- tor_assert(nmemb < max_nmemb);
-
- result = tor_malloc_zero_((nmemb * size) DMALLOC_FN_ARGS);
- return result;
+ tor_assert(size_mul_check(nmemb, size));
+ return tor_malloc_zero_((nmemb * size) DMALLOC_FN_ARGS);
}
/** Change the size of the memory block pointed to by <b>ptr</b> to <b>size</b>
@@ -231,6 +242,13 @@ tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS)
tor_assert(size < SIZE_T_CEILING);
+#ifndef MALLOC_ZERO_WORKS
+ /* Some libc mallocs don't work when size==0. Override them. */
+ if (size==0) {
+ size=1;
+ }
+#endif
+
#ifdef USE_DMALLOC
result = dmalloc_realloc(file, line, ptr, size, DMALLOC_FUNC_REALLOC, 0);
#else
@@ -244,6 +262,20 @@ tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS)
return result;
}
+/**
+ * Try to realloc <b>ptr</b> so that it takes up sz1 * sz2 bytes. Check for
+ * overflow. Unlike other allocation functions, return NULL on overflow.
+ */
+void *
+tor_reallocarray_(void *ptr, size_t sz1, size_t sz2 DMALLOC_PARAMS)
+{
+ /* XXXX we can make this return 0, but we would need to check all the
+ * reallocarray users. */
+ tor_assert(size_mul_check(sz1, sz2));
+
+ return tor_realloc(ptr, (sz1 * sz2) DMALLOC_FN_ARGS);
+}
+
/** Return a newly allocated copy of the NUL-terminated string s. On
* error, log and terminate. (Like strdup(s), but never returns
* NULL.)
@@ -932,6 +964,68 @@ string_is_key_value(int severity, const char *string)
return 1;
}
+/** Return true if <b>string</b> represents a valid IPv4 adddress in
+ * 'a.b.c.d' form.
+ */
+int
+string_is_valid_ipv4_address(const char *string)
+{
+ struct in_addr addr;
+
+ return (tor_inet_pton(AF_INET,string,&addr) == 1);
+}
+
+/** Return true if <b>string</b> represents a valid IPv6 address in
+ * a form that inet_pton() can parse.
+ */
+int
+string_is_valid_ipv6_address(const char *string)
+{
+ struct in6_addr addr;
+
+ return (tor_inet_pton(AF_INET6,string,&addr) == 1);
+}
+
+/** Return true iff <b>string</b> matches a pattern of DNS names
+ * that we allow Tor clients to connect to.
+ */
+int
+string_is_valid_hostname(const char *string)
+{
+ int result = 1;
+ smartlist_t *components;
+
+ components = smartlist_new();
+
+ smartlist_split_string(components,string,".",0,0);
+
+ SMARTLIST_FOREACH_BEGIN(components, char *, c) {
+ if (c[0] == '-') {
+ result = 0;
+ break;
+ }
+
+ do {
+ if ((*c >= 'a' && *c <= 'z') ||
+ (*c >= 'A' && *c <= 'Z') ||
+ (*c >= '0' && *c <= '9') ||
+ (*c == '-'))
+ c++;
+ else
+ result = 0;
+ } while (result && *c);
+
+ } SMARTLIST_FOREACH_END(c);
+
+ SMARTLIST_FOREACH_BEGIN(components, char *, c) {
+ tor_free(c);
+ } SMARTLIST_FOREACH_END(c);
+
+ smartlist_free(components);
+
+ return result;
+}
+
/** Return true iff the DIGEST256_LEN bytes in digest are all zero. */
int
tor_digest256_is_zero(const char *digest)
@@ -1183,9 +1277,14 @@ esc_for_log(const char *s)
}
}
+ tor_assert(len <= SSIZE_MAX);
+
result = outp = tor_malloc(len);
*outp++ = '\"';
for (cp = s; *cp; ++cp) {
+ /* This assertion should always succeed, since we will write at least
+ * one char here, and two chars for closing quote and nul later */
+ tor_assert((outp-result) < (ssize_t)len-2);
switch (*cp) {
case '\\':
case '\"':
@@ -1209,6 +1308,7 @@ esc_for_log(const char *s)
if (TOR_ISPRINT(*cp) && ((uint8_t)*cp)<127) {
*outp++ = *cp;
} else {
+ tor_assert((outp-result) < (ssize_t)len-4);
tor_snprintf(outp, 5, "\\%03o", (int)(uint8_t) *cp);
outp += 4;
}
@@ -1216,6 +1316,7 @@ esc_for_log(const char *s)
}
}
+ tor_assert((outp-result) <= (ssize_t)len-2);
*outp++ = '\"';
*outp++ = 0;
@@ -1344,7 +1445,8 @@ n_leapdays(int y1, int y2)
--y2;
return (y2/4 - y1/4) - (y2/100 - y1/100) + (y2/400 - y1/400);
}
-/** Number of days per month in non-leap year; used by tor_timegm. */
+/** Number of days per month in non-leap year; used by tor_timegm and
+ * parse_rfc1123_time. */
static const int days_per_month[] =
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@@ -1358,10 +1460,32 @@ tor_timegm(const struct tm *tm, time_t *time_out)
* It's way more brute-force than fiddling with tzset().
*/
time_t year, days, hours, minutes, seconds;
- int i;
- year = tm->tm_year + 1900;
- if (year < 1970 || tm->tm_mon < 0 || tm->tm_mon > 11 ||
- tm->tm_year >= INT32_MAX-1900) {
+ int i, invalid_year, dpm;
+ /* avoid int overflow on addition */
+ if (tm->tm_year < INT32_MAX-1900) {
+ year = tm->tm_year + 1900;
+ } else {
+ /* clamp year */
+ year = INT32_MAX;
+ }
+ invalid_year = (year < 1970 || tm->tm_year >= INT32_MAX-1900);
+
+ if (tm->tm_mon >= 0 && tm->tm_mon <= 11) {
+ dpm = days_per_month[tm->tm_mon];
+ if (tm->tm_mon == 1 && !invalid_year && IS_LEAPYEAR(tm->tm_year)) {
+ dpm = 29;
+ }
+ } else {
+ /* invalid month - default to 0 days per month */
+ dpm = 0;
+ }
+
+ if (invalid_year ||
+ tm->tm_mon < 0 || tm->tm_mon > 11 ||
+ tm->tm_mday < 1 || tm->tm_mday > dpm ||
+ tm->tm_hour < 0 || tm->tm_hour > 23 ||
+ tm->tm_min < 0 || tm->tm_min > 59 ||
+ tm->tm_sec < 0 || tm->tm_sec > 60) {
log_warn(LD_BUG, "Out-of-range argument to tor_timegm");
return -1;
}
@@ -1425,8 +1549,9 @@ parse_rfc1123_time(const char *buf, time_t *t)
struct tm tm;
char month[4];
char weekday[4];
- int i, m;
+ int i, m, invalid_year;
unsigned tm_mday, tm_year, tm_hour, tm_min, tm_sec;
+ unsigned dpm;
if (strlen(buf) != RFC1123_TIME_LEN)
return -1;
@@ -1439,18 +1564,6 @@ parse_rfc1123_time(const char *buf, time_t *t)
tor_free(esc);
return -1;
}
- if (tm_mday < 1 || tm_mday > 31 || tm_hour > 23 || tm_min > 59 ||
- tm_sec > 60 || tm_year >= INT32_MAX || tm_year < 1970) {
- char *esc = esc_for_log(buf);
- log_warn(LD_GENERAL, "Got invalid RFC1123 time %s", esc);
- tor_free(esc);
- return -1;
- }
- tm.tm_mday = (int)tm_mday;
- tm.tm_year = (int)tm_year;
- tm.tm_hour = (int)tm_hour;
- tm.tm_min = (int)tm_min;
- tm.tm_sec = (int)tm_sec;
m = -1;
for (i = 0; i < 12; ++i) {
@@ -1467,6 +1580,26 @@ parse_rfc1123_time(const char *buf, time_t *t)
}
tm.tm_mon = m;
+ invalid_year = (tm_year >= INT32_MAX || tm_year < 1970);
+ tor_assert(m >= 0 && m <= 11);
+ dpm = days_per_month[m];
+ if (m == 1 && !invalid_year && IS_LEAPYEAR(tm_year)) {
+ dpm = 29;
+ }
+
+ if (invalid_year || tm_mday < 1 || tm_mday > dpm ||
+ tm_hour > 23 || tm_min > 59 || tm_sec > 60) {
+ char *esc = esc_for_log(buf);
+ log_warn(LD_GENERAL, "Got invalid RFC1123 time %s", esc);
+ tor_free(esc);
+ return -1;
+ }
+ tm.tm_mday = (int)tm_mday;
+ tm.tm_year = (int)tm_year;
+ tm.tm_hour = (int)tm_hour;
+ tm.tm_min = (int)tm_min;
+ tm.tm_sec = (int)tm_sec;
+
if (tm.tm_year < 1970) {
char *esc = esc_for_log(buf);
log_warn(LD_GENERAL,
@@ -1638,7 +1771,11 @@ format_time_interval(char *out, size_t out_len, long interval)
{
/* We only report seconds if there's no hours. */
long sec = 0, min = 0, hour = 0, day = 0;
- if (interval < 0)
+
+ /* -LONG_MIN is LONG_MAX + 1, which causes signed overflow */
+ if (interval < -LONG_MAX)
+ interval = LONG_MAX;
+ else if (interval < 0)
interval = -interval;
if (interval >= 86400) {
@@ -1754,7 +1891,7 @@ write_all(tor_socket_t fd, const char *buf, size_t count, int isSocket)
{
size_t written = 0;
ssize_t result;
- tor_assert(count < SSIZE_T_MAX);
+ tor_assert(count < SSIZE_MAX);
while (written != count) {
if (isSocket)
@@ -1779,7 +1916,7 @@ read_all(tor_socket_t fd, char *buf, size_t count, int isSocket)
size_t numread = 0;
ssize_t result;
- if (count > SIZE_T_CEILING || count > SSIZE_T_MAX)
+ if (count > SIZE_T_CEILING || count > SSIZE_MAX)
return -1;
while (numread != count) {
@@ -2332,6 +2469,7 @@ read_file_to_str_until_eof(int fd, size_t max_bytes_to_read, size_t *sz_out)
pos += r;
} while (r > 0 && pos < max_bytes_to_read);
+ tor_assert(pos < string_max);
*sz_out = pos;
string[pos] = '\0';
return string;
@@ -2804,10 +2942,14 @@ scan_unsigned(const char **bufp, unsigned long *out, int width, int base)
while (**bufp && (hex?TOR_ISXDIGIT(**bufp):TOR_ISDIGIT(**bufp))
&& scanned_so_far < width) {
int digit = hex?hex_decode_digit(*(*bufp)++):digit_to_num(*(*bufp)++);
- unsigned long new_result = result * base + digit;
- if (new_result < result)
- return -1; /* over/underflow. */
- result = new_result;
+ // Check for overflow beforehand, without actually causing any overflow
+ // This preserves functionality on compilers that don't wrap overflow
+ // (i.e. that trap or optimise away overflow)
+ // result * base + digit > ULONG_MAX
+ // result * base > ULONG_MAX - digit
+ if (result > (ULONG_MAX - digit)/base)
+ return -1; /* Processing this digit would overflow */
+ result = result * base + digit;
++scanned_so_far;
}
@@ -2842,10 +2984,17 @@ scan_signed(const char **bufp, long *out, int width)
if (scan_unsigned(bufp, &result, width, 10) < 0)
return -1;
- if (neg) {
+ if (neg && result > 0) {
if (result > ((unsigned long)LONG_MAX) + 1)
return -1; /* Underflow */
- *out = -(long)result;
+ // Avoid overflow on the cast to signed long when result is LONG_MIN
+ // by subtracting 1 from the unsigned long positive value,
+ // then, after it has been cast to signed and negated,
+ // subtracting the original 1 (the double-subtraction is intentional).
+ // Otherwise, the cast to signed could cause a temporary long
+ // to equal LONG_MAX + 1, which is undefined.
+ // We avoid underflow on the subtraction by treating -0 as positive.
+ *out = (-(long)(result - 1)) - 1;
} else {
if (result > LONG_MAX)
return -1; /* Overflow */
@@ -3378,8 +3527,9 @@ format_win_cmdline_argument(const char *arg)
smartlist_add(arg_chars, (void*)&backslash);
/* Allocate space for argument, quotes (if needed), and terminator */
- formatted_arg = tor_malloc(sizeof(char) *
- (smartlist_len(arg_chars) + (need_quotes?2:0) + 1));
+ const size_t formatted_arg_len = smartlist_len(arg_chars) +
+ (need_quotes ? 2 : 0) + 1;
+ formatted_arg = tor_malloc_zero(formatted_arg_len);
/* Add leading quote */
i=0;
@@ -3544,7 +3694,13 @@ format_helper_exit_status(unsigned char child_state, int saved_errno,
/* Convert errno to be unsigned for hex conversion */
if (saved_errno < 0) {
- unsigned_errno = (unsigned int) -saved_errno;
+ // Avoid overflow on the cast to unsigned int when result is INT_MIN
+ // by adding 1 to the signed int negative value,
+ // then, after it has been negated and cast to unsigned,
+ // adding the original 1 back (the double-addition is intentional).
+ // Otherwise, the cast to signed could cause a temporary int
+ // to equal INT_MAX + 1, which is undefined.
+ unsigned_errno = ((unsigned int) -(saved_errno + 1)) + 1;
} else {
unsigned_errno = (unsigned int) saved_errno;
}
@@ -4038,8 +4194,11 @@ tor_spawn_background(const char *const filename, const char **argv,
status = process_handle->status = PROCESS_STATUS_RUNNING;
/* Set stdout/stderr pipes to be non-blocking */
- fcntl(process_handle->stdout_pipe, F_SETFL, O_NONBLOCK);
- fcntl(process_handle->stderr_pipe, F_SETFL, O_NONBLOCK);
+ if (fcntl(process_handle->stdout_pipe, F_SETFL, O_NONBLOCK) < 0 ||
+ fcntl(process_handle->stderr_pipe, F_SETFL, O_NONBLOCK) < 0) {
+ log_warn(LD_GENERAL, "Failed to set stderror/stdout pipes nonblocking "
+ "in parent process: %s", strerror(errno));
+ }
/* Open the buffered IO streams */
process_handle->stdout_handle = fdopen(process_handle->stdout_pipe, "r");
process_handle->stderr_handle = fdopen(process_handle->stderr_pipe, "r");
@@ -4373,7 +4532,7 @@ tor_read_all_handle(HANDLE h, char *buf, size_t count,
DWORD byte_count;
BOOL process_exited = FALSE;
- if (count > SIZE_T_CEILING || count > SSIZE_T_MAX)
+ if (count > SIZE_T_CEILING || count > SSIZE_MAX)
return -1;
while (numread != count) {
@@ -4439,7 +4598,7 @@ tor_read_all_handle(FILE *h, char *buf, size_t count,
if (eof)
*eof = 0;
- if (count > SIZE_T_CEILING || count > SSIZE_T_MAX)
+ if (count > SIZE_T_CEILING || count > SSIZE_MAX)
return -1;
while (numread != count) {
@@ -5008,7 +5167,7 @@ tor_check_port_forwarding(const char *filename,
for each smartlist element (one for "-p" and one for the
ports), and one for the final NULL. */
args_n = 1 + 2*smartlist_len(ports_to_forward) + 1;
- argv = tor_malloc_zero(sizeof(char*)*args_n);
+ argv = tor_calloc(args_n, sizeof(char *));
argv[argv_index++] = filename;
SMARTLIST_FOREACH_BEGIN(ports_to_forward, const char *, port) {
diff --git a/src/common/util.h b/src/common/util.h
index 97367a9a7b..9886b2db6a 100644
--- a/src/common/util.h
+++ b/src/common/util.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -79,6 +79,7 @@ void *tor_malloc_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
void *tor_malloc_zero_(size_t size DMALLOC_PARAMS) ATTR_MALLOC;
void *tor_calloc_(size_t nmemb, size_t size DMALLOC_PARAMS) ATTR_MALLOC;
void *tor_realloc_(void *ptr, size_t size DMALLOC_PARAMS);
+void *tor_reallocarray_(void *ptr, size_t size1, size_t size2 DMALLOC_PARAMS);
char *tor_strdup_(const char *s DMALLOC_PARAMS) ATTR_MALLOC ATTR_NONNULL((1));
char *tor_strndup_(const char *s, size_t n DMALLOC_PARAMS)
ATTR_MALLOC ATTR_NONNULL((1));
@@ -116,6 +117,8 @@ extern int dmalloc_free(const char *file, const int line, void *pnt,
#define tor_malloc_zero(size) tor_malloc_zero_(size DMALLOC_ARGS)
#define tor_calloc(nmemb,size) tor_calloc_(nmemb, size DMALLOC_ARGS)
#define tor_realloc(ptr, size) tor_realloc_(ptr, size DMALLOC_ARGS)
+#define tor_reallocarray(ptr, sz1, sz2) \
+ tor_reallocarray_((ptr), (sz1), (sz2) DMALLOC_ARGS)
#define tor_strdup(s) tor_strdup_(s DMALLOC_ARGS)
#define tor_strndup(s, n) tor_strndup_(s, n DMALLOC_ARGS)
#define tor_memdup(s, n) tor_memdup_(s, n DMALLOC_ARGS)
@@ -224,6 +227,9 @@ const char *find_str_at_start_of_line(const char *haystack,
const char *needle);
int string_is_C_identifier(const char *string);
int string_is_key_value(int severity, const char *string);
+int string_is_valid_hostname(const char *string);
+int string_is_valid_ipv4_address(const char *string);
+int string_is_valid_ipv6_address(const char *string);
int tor_mem_is_zero(const char *mem, size_t len);
int tor_digest_is_zero(const char *digest);
diff --git a/src/common/util_process.c b/src/common/util_process.c
index d6ef590162..1924c19509 100644
--- a/src/common/util_process.c
+++ b/src/common/util_process.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -62,8 +62,8 @@ static HT_HEAD(process_map, waitpid_callback_t) process_map = HT_INITIALIZER();
HT_PROTOTYPE(process_map, waitpid_callback_t, node, process_map_entry_hash_,
process_map_entries_eq_);
-HT_GENERATE(process_map, waitpid_callback_t, node, process_map_entry_hash_,
- process_map_entries_eq_, 0.6, malloc, realloc, free);
+HT_GENERATE2(process_map, waitpid_callback_t, node, process_map_entry_hash_,
+ process_map_entries_eq_, 0.6, tor_reallocarray_, tor_free_);
/**
* Begin monitoring the child pid <b>pid</b> to see if we get a SIGCHLD for
diff --git a/src/common/util_process.h b/src/common/util_process.h
index 0b268b85d3..e7c55ed33d 100644
--- a/src/common/util_process.h
+++ b/src/common/util_process.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/config/geoip b/src/config/geoip
index bec1f0954b..28cb59ecb7 100644
--- a/src/config/geoip
+++ b/src/config/geoip
@@ -1,4 +1,4 @@
-# Last updated based on July 10 2014 Maxmind GeoLite2 Country
+# Last updated based on August 7 2014 Maxmind GeoLite2 Country
# wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz
# gunzip GeoLite2-Country.mmdb.gz
# python mmdb-convert.py GeoLite2-Country.mmdb
@@ -38,7 +38,8 @@
18153472,18219007,JP
18219008,18350079,IN
18350080,18874367,CN
-18874368,18939903,HK
+18874368,18907135,MY
+18907136,18939903,HK
18939904,19005439,JP
19005440,19136511,TW
19136512,19202047,HK
@@ -76,6 +77,7 @@
34612224,34612735,IL
34620416,34620927,SE
34620928,34621439,IT
+34621952,34622463,NL
34636800,34637311,DE
34646528,34647551,DE
34648576,34649087,GR
@@ -221,7 +223,9 @@
84049920,84082687,RO
84082688,84148223,RU
84148224,84410367,DE
-84410368,84434943,RU
+84410368,84418559,RU
+84418560,84420607,GB
+84420608,84434943,RU
84434944,84443135,IT
84443136,84451327,LB
84451328,84457471,RU
@@ -235,18 +239,22 @@
84551680,84557823,DE
84557824,84557824,NL
84557825,84557825,US
-84557826,84560635,NL
+84557826,84558063,NL
+84558064,84558071,US
+84558072,84558879,NL
+84558880,84558887,US
+84558888,84560635,NL
84560636,84560639,US
-84560640,84561215,NL
+84560640,84561063,NL
+84561064,84561071,US
+84561072,84561215,NL
84561216,84561247,US
84561248,84561351,NL
84561352,84561359,MY
84561360,84561639,NL
84561640,84561647,ES
84561648,84561655,AF
-84561656,84561687,NL
-84561688,84561695,US
-84561696,84561727,NL
+84561656,84561727,NL
84561728,84561791,US
84561792,84562383,NL
84562384,84562391,US
@@ -271,8 +279,59 @@
84565664,84566303,NL
84566304,84566319,US
84566320,84566383,NL
-84566384,84566399,US
-84566400,84574207,NL
+84566384,84566415,US
+84566416,84566420,NL
+84566421,84566421,US
+84566422,84566495,NL
+84566496,84566527,US
+84566528,84566567,NL
+84566568,84566583,US
+84566584,84566591,NL
+84566592,84566687,US
+84566688,84566719,NL
+84566720,84566743,US
+84566744,84567039,NL
+84567040,84567055,US
+84567056,84567071,NL
+84567072,84567103,US
+84567104,84567119,NL
+84567120,84567135,US
+84567136,84567199,NL
+84567200,84567231,US
+84567232,84567375,NL
+84567376,84567391,US
+84567392,84567535,NL
+84567536,84567551,US
+84567552,84567599,NL
+84567600,84567615,US
+84567616,84567647,NL
+84567648,84567679,US
+84567680,84567903,NL
+84567904,84567919,US
+84567920,84567999,NL
+84568000,84568015,US
+84568016,84568223,NL
+84568224,84568239,US
+84568240,84568255,GB
+84568256,84568287,NL
+84568288,84568303,US
+84568304,84568351,NL
+84568352,84568399,US
+84568400,84568591,NL
+84568592,84568607,GB
+84568608,84568847,NL
+84568848,84568863,US
+84568864,84568927,NL
+84568928,84568943,GB
+84568944,84568991,NL
+84568992,84569023,GB
+84569024,84569119,NL
+84569120,84569135,US
+84569136,84569183,NL
+84569184,84569199,US
+84569200,84570127,NL
+84570128,84570143,US
+84570144,84574207,NL
84574208,84576255,FR
84576256,84582399,GB
84582400,84590591,DE
@@ -333,7 +392,8 @@
85733376,85737471,GB
85737472,85753855,DE
85753856,85770239,IL
-85770240,85786623,DE
+85770240,85778431,MD
+85778432,85786623,DE
85786624,85852159,IL
85852160,86015999,AE
86016000,86018047,BG
@@ -413,7 +473,9 @@
86444840,86444843,ES
86444844,86444879,FR
86444880,86444883,NL
-86444884,86445059,FR
+86444884,86444895,FR
+86444896,86444903,NL
+86444904,86445059,FR
86445060,86445063,NL
86445064,86445111,FR
86445112,86445115,NL
@@ -431,7 +493,11 @@
86446620,86446620,DE
86446621,86446679,FR
86446680,86446683,ES
-86446684,86447095,FR
+86446684,86446719,FR
+86446720,86446727,NL
+86446728,86446983,FR
+86446984,86446991,IT
+86446992,86447095,FR
86447096,86447103,ES
86447104,86447255,FR
86447256,86447263,PL
@@ -452,7 +518,9 @@
86449884,86449884,DE
86449885,86450235,FR
86450236,86450239,GB
-86450240,86452067,FR
+86450240,86451167,FR
+86451168,86451175,NL
+86451176,86452067,FR
86452068,86452071,ES
86452072,86452299,FR
86452300,86452303,IT
@@ -466,11 +534,16 @@
86453837,86453838,PT
86453839,86454187,FR
86454188,86454191,IT
-86454192,86454335,FR
+86454192,86454279,FR
+86454280,86454287,ES
+86454288,86454295,IT
+86454296,86454335,FR
86454336,86454343,DE
86454344,86454615,FR
86454616,86454619,ES
-86454620,86455623,FR
+86454620,86454823,FR
+86454824,86454831,ES
+86454832,86455623,FR
86455624,86455624,DE
86455625,86456195,FR
86456196,86456211,DE
@@ -492,7 +565,9 @@
86457456,86457456,DE
86457457,86457799,FR
86457800,86457803,ES
-86457804,86467320,FR
+86457804,86466839,FR
+86466840,86466847,NL
+86466848,86467320,FR
86467321,86467321,FI
86467322,86467999,FR
86468000,86468003,PL
@@ -767,7 +842,8 @@
90540032,90544127,GB
90544128,90546175,RU
90546176,90548223,DE
-90548224,90570751,RU
+90548224,90550271,GB
+90550272,90570751,RU
90570752,90578943,IT
90578944,90583039,IR
90583040,90587135,CZ
@@ -869,9 +945,13 @@
92736000,92736255,GB
92736256,92736479,FR
92736480,92736480,DE
-92736481,92738719,FR
+92736481,92738663,FR
+92738664,92738679,ES
+92738680,92738719,FR
92738720,92738727,GB
-92738728,92741203,FR
+92738728,92740447,FR
+92740448,92740455,IT
+92740456,92741203,FR
92741204,92741207,IT
92741208,92741387,FR
92741388,92741395,IT
@@ -907,7 +987,9 @@
92744556,92744559,IT
92744560,92747711,FR
92747712,92747775,GB
-92747776,92749067,FR
+92747776,92748773,FR
+92748774,92748774,PT
+92748775,92749067,FR
92749068,92749071,GB
92749072,92749747,FR
92749748,92749751,ES
@@ -1010,9 +1092,7 @@
93914320,93914323,AZ
93914324,93914357,NL
93914358,93914358,GB
-93914359,93914671,NL
-93914672,93914679,US
-93914680,93914710,NL
+93914359,93914710,NL
93914711,93914711,GB
93914712,93914951,NL
93914952,93914959,US
@@ -1051,11 +1131,15 @@
93920060,93920063,US
93920064,93920163,NL
93920164,93920167,US
-93920168,93920575,NL
+93920168,93920223,NL
+93920224,93920231,US
+93920232,93920575,NL
93920576,93920639,US
93920640,93920855,NL
93920856,93920863,US
-93920864,93921055,NL
+93920864,93920967,NL
+93920968,93920975,US
+93920976,93921055,NL
93921056,93921059,US
93921060,93921063,NL
93921064,93921071,GB
@@ -1069,9 +1153,7 @@
93924408,93924415,JP
93924416,93924591,NL
93924592,93924599,US
-93924600,93924927,NL
-93924928,93924935,ES
-93924936,93925807,NL
+93924600,93925807,NL
93925808,93925815,KE
93925816,93927143,NL
93927144,93927151,JP
@@ -1199,12 +1281,15 @@
95401472,95401727,GB
95401728,95401903,DE
95401904,95401911,AT
-95401912,95402111,DE
+95401912,95401983,DE
+95401984,95402111,GB
95402112,95402239,KW
-95402240,95402623,DE
+95402240,95402495,DE
+95402496,95402623,GB
95402624,95402695,US
95402696,95402703,HR
-95402704,95402751,US
+95402704,95402719,DE
+95402720,95402751,US
95402752,95403183,DE
95403184,95403191,BE
95403192,95403519,DE
@@ -1254,7 +1339,8 @@
95666176,95668223,FR
95668224,95682559,DE
95944704,96075775,PL
-96075776,96143359,DE
+96075776,96141311,DK
+96141312,96143359,DE
96143360,96145407,GE
96145408,96149503,GB
96149504,96151551,ES
@@ -1331,7 +1417,9 @@
98734080,98736127,CH
98736128,98738175,RU
98738176,98740223,NO
-98740224,98742271,DE
+98740224,98741503,DE
+98741504,98741759,US
+98741760,98742271,DE
98742272,98744319,GB
98744320,98746367,ES
98746368,98762751,TR
@@ -1499,9 +1587,7 @@
212788480,212788735,VI
212788736,212788863,US
212788864,212788991,PR
-212788992,212789087,US
-212789088,212789095,VI
-212789096,212791831,US
+212788992,212791831,US
212791832,212791839,VI
212791840,212791935,US
212791936,212792063,VI
@@ -1509,9 +1595,7 @@
212793088,212793343,PR
212793344,212794575,US
212794576,212794583,VI
-212794584,214237247,US
-214237248,214237311,PR
-214237312,214698239,US
+212794584,214698239,US
214698240,214698255,VI
214698256,214698303,US
214698304,214698311,VI
@@ -1520,9 +1604,7 @@
214699648,214699775,VI
214699776,214778367,US
214778368,214778623,PR
-214778624,216417663,US
-216417664,216417727,PR
-216417728,217709055,US
+214778624,217709055,US
217709056,217709311,PR
217709312,219512063,US
219512064,219512319,GB
@@ -1586,8 +1668,7 @@
247488512,247496703,JP
247496704,247504895,PK
247504896,247508991,AU
-247508992,247509247,US
-247509248,247513087,AU
+247508992,247513087,US
247513088,247529471,MY
247529472,247595007,JP
247595008,247726079,IN
@@ -1973,9 +2054,27 @@
391897088,391905279,CA
391905280,391938047,US
391938048,391946239,CA
-391946240,392765439,US
+391946240,392429567,US
+392429568,392433663,NL
+392433664,392441855,US
+392441856,392445951,IE
+392445952,392452095,US
+392452096,392454143,HK
+392454144,392458239,JP
+392458240,392460287,SG
+392460288,392495103,US
+392495104,392499199,HK
+392499200,392503295,SG
+392503296,392507391,US
+392507392,392511487,IE
+392511488,392515583,NL
+392515584,392523775,JP
+392523776,392548351,US
+392548352,392556543,AU
+392556544,392765439,US
392765440,392765695,GB
392765696,394264575,US
+394264576,394264831,CA
398458880,398635007,US
398635008,398643199,NL
398643200,398647295,US
@@ -1990,7 +2089,9 @@
398856192,398876671,NL
398876672,398970879,US
398970880,398974975,NL
-398974976,399007743,US
+398974976,399004671,US
+399004672,399006207,FR
+399006208,399007743,US
399007744,399011839,NL
399011840,399020031,US
399020032,399028223,NL
@@ -2129,6 +2230,7 @@
406003712,406011903,US
406011904,406028287,BS
406028288,406052863,US
+406052864,406061055,CA
406061056,406110207,US
406110208,406142975,CA
406142976,406147071,US
@@ -2168,6 +2270,7 @@
409337856,409354239,CA
409354240,409509887,US
409518080,409550847,US
+409550848,409567231,CA
409567232,409731071,US
409731072,409862143,CA
409862144,410124287,US
@@ -2192,7 +2295,7 @@
411770880,411779071,US
411779072,411828223,PR
411828224,411885567,US
-411893760,411975679,CA
+411885568,411975679,CA
411975680,411979775,US
411979776,411983871,CA
411983872,411988991,US
@@ -2242,7 +2345,7 @@
417775616,417796095,CA
417796096,417800191,US
417800192,417808383,BS
-417808384,417820671,CA
+417808384,417816575,CA
417820672,417832191,US
417832192,417832447,VI
417832448,417857535,US
@@ -2305,7 +2408,6 @@
456542208,456544255,CN
456544256,456548351,AU
456548352,456553471,JP
-456553472,456554495,MY
456554496,456555519,PK
456555520,456556543,JP
456556544,456560639,AU
@@ -2334,7 +2436,9 @@
459538432,459539455,AU
459540480,459541503,JP
459541504,459542527,IN
-459542528,459544575,HK
+459542528,459543295,HK
+459543296,459543551,TW
+459543552,459544575,HK
459545600,459547647,JP
459548672,459550719,TH
459550720,459554815,JP
@@ -2421,8 +2525,7 @@
460931072,460933119,AU
460933120,460935167,CN
460935168,460937215,ID
-460937216,460937727,NZ
-460937728,460938239,AU
+460937216,460938239,AU
460938240,460939263,JP
460939264,460940287,NZ
460940288,460941311,IN
@@ -2446,8 +2549,10 @@
461047808,461049855,JP
461049856,461050879,TH
461050880,461051903,NZ
-461051904,461053951,AU
-461053952,461062143,HK
+461051904,461054975,AU
+461054976,461055999,HK
+461056000,461058047,AU
+461058048,461062143,HK
461062144,461078527,IN
461078528,461078783,FJ
461078784,461079039,AU
@@ -2477,7 +2582,11 @@
461281280,461282303,PH
461282304,461283327,MY
461283328,461287423,JP
-461287424,461307903,HK
+461287424,461294591,HK
+461294592,461298687,US
+461298688,461301759,HK
+461301760,461302527,US
+461302528,461307903,HK
461307904,461357055,JP
461357056,461369343,AU
461369344,461373439,JP
@@ -2541,7 +2650,7 @@
520339456,520343551,UA
520343552,520355839,GB
520355840,520421375,ES
-520421376,520486911,AT
+520421376,520486911,BE
520486912,520488959,NL
520488960,520489983,IT
520489984,520490495,RU
@@ -2952,9 +3061,11 @@
529596416,529661951,TR
529661952,529727487,GE
529727488,529793023,HR
-529793024,529793535,CZ
-529793536,529794047,RU
-529794048,529818623,CZ
+529793024,529793337,CZ
+529793338,529793338,RU
+529793339,529793535,CZ
+529793536,529794303,RU
+529794304,529818623,CZ
529818624,529826303,RU
529826304,529826815,CZ
529826816,529827839,RU
@@ -3023,7 +3134,9 @@
531263488,531265535,RU
531265536,531267583,GB
531267584,531275775,UA
-531275776,531277823,US
+531275776,531276799,US
+531276800,531277311,GB
+531277312,531277823,US
531277824,531279871,RU
531279872,531281919,CZ
531281920,531283967,RU
@@ -3070,11 +3183,11 @@
531429136,531429143,IT
531429144,531429167,GB
531429168,531429175,IT
-531429176,531429239,GB
+531429176,531429207,GB
+531429208,531429215,IT
+531429216,531429239,GB
531429240,531429247,IT
-531429248,531429335,GB
-531429336,531429343,IT
-531429344,531429391,GB
+531429248,531429391,GB
531429392,531429399,IT
531429400,531429407,GB
531429408,531429415,IT
@@ -3086,7 +3199,9 @@
531430824,531430831,IT
531430832,531430847,GB
531430848,531430855,IT
-531430856,531431423,GB
+531430856,531430927,GB
+531430928,531430935,IT
+531430936,531431423,GB
531431424,531496959,RO
531496960,531628031,PL
531628032,531660799,TR
@@ -3326,7 +3441,8 @@
534513408,534513663,SE
534513664,534515455,US
534515456,534515711,DE
-534515712,534517759,US
+534515712,534515967,GB
+534515968,534517759,US
534517760,534518783,NL
534518784,534519039,DE
534519040,534519167,NL
@@ -3350,9 +3466,7 @@
534523136,534523391,NL
534523392,534523903,DE
534523904,534530047,US
-534530048,534541311,DE
-534541312,534543359,US
-534543360,534544383,DE
+534530048,534544383,DE
534544384,534546431,RO
534546432,534548479,DE
534548480,534550527,PL
@@ -3813,7 +3927,9 @@
623801600,623801855,SE
623801856,623802367,NL
623802368,623802879,SE
-623802880,623804415,NL
+623802880,623804148,NL
+623804149,623804159,SE
+623804160,623804415,NL
623804416,623806463,RU
623806464,623808511,NL
623808512,623810559,RU
@@ -3861,7 +3977,11 @@
624575400,624575403,US
624575404,624575679,NL
624575680,624575743,US
-624575744,624576127,NL
+624575744,624575871,NL
+624575872,624575879,US
+624575880,624576031,NL
+624576032,624576039,US
+624576040,624576127,NL
624576128,624576131,US
624576132,624576471,NL
624576472,624576479,US
@@ -3875,7 +3995,11 @@
624577308,624577311,US
624577312,624577483,NL
624577484,624577487,US
-624577488,624578719,NL
+624577488,624577863,NL
+624577864,624577871,DK
+624577872,624578415,NL
+624578416,624578423,US
+624578424,624578719,NL
624578720,624578723,GB
624578724,624578887,NL
624578888,624578895,US
@@ -3911,9 +4035,7 @@
624582288,624582295,US
624582296,624582399,NL
624582400,624582403,US
-624582404,624583455,NL
-624583456,624583463,US
-624583464,624584111,NL
+624582404,624584111,NL
624584112,624584119,US
624584120,624584159,NL
624584160,624584175,US
@@ -3921,28 +4043,33 @@
624584384,624584391,US
624584392,624584415,NL
624584416,624584423,US
-624584424,624585359,NL
-624585360,624585367,US
-624585368,624587583,NL
+624584424,624586279,NL
+624586280,624586287,US
+624586288,624587583,NL
624587584,624587599,US
-624587600,624587751,NL
-624587752,624587759,US
-624587760,624587871,NL
+624587600,624587871,NL
624587872,624587903,US
-624587904,624588391,NL
+624587904,624588383,NL
+624588384,624588391,US
624588392,624588399,GB
-624588400,624589159,NL
+624588400,624588927,NL
+624588928,624588943,GB
+624588944,624589159,NL
624589160,624589167,IT
624589168,624589199,NL
624589200,624589215,KE
-624589216,624589967,NL
+624589216,624589223,NL
+624589224,624589231,US
+624589232,624589719,NL
+624589720,624589727,US
+624589728,624589967,NL
624589968,624589975,US
-624589976,624590743,NL
-624590744,624590751,US
-624590752,624590815,NL
-624590816,624590823,US
-624590824,624590847,NL
-624590848,624640951,FR
+624589976,624590847,NL
+624590848,624640527,FR
+624640528,624640543,GB
+624640544,624640759,FR
+624640760,624640767,NL
+624640768,624640951,FR
624640952,624640959,PT
624640960,624643019,FR
624643020,624643023,IT
@@ -3950,9 +4077,11 @@
624645148,624645151,IT
624645152,624646343,FR
624646344,624646347,NL
-624646348,624647171,FR
-624647172,624647175,ES
-624647176,624648139,FR
+624646348,624646583,FR
+624646584,624646591,NL
+624646592,624647171,FR
+624647172,624647183,ES
+624647184,624648139,FR
624648140,624648143,ES
624648144,624657711,FR
624657712,624657715,ES
@@ -3962,7 +4091,9 @@
624658324,624658327,IE
624658328,624658479,FR
624658480,624658483,DE
-624658484,624660827,FR
+624658484,624659031,FR
+624659032,624659039,IT
+624659040,624660827,FR
624660828,624660831,ES
624660832,624661247,FR
624661248,624661251,ES
@@ -4004,7 +4135,9 @@
624673452,624673455,ES
624673456,624673535,FR
624673536,624673791,ES
-624673792,624673903,FR
+624673792,624673803,FR
+624673804,624673807,NL
+624673808,624673903,FR
624673904,624673919,ES
624673920,624675691,FR
624675692,624675695,ES
@@ -4020,13 +4153,25 @@
624677464,624677467,ES
624677468,624677683,FR
624677684,624677687,NL
-624677688,624679199,FR
+624677688,624677767,FR
+624677768,624677775,NL
+624677776,624678391,FR
+624678392,624678399,NL
+624678400,624678487,FR
+624678488,624678495,NL
+624678496,624679175,FR
+624679176,624679183,NL
+624679184,624679199,FR
624679200,624679203,ES
-624679204,624679843,FR
+624679204,624679679,FR
+624679680,624679687,NL
+624679688,624679843,FR
624679844,624679847,ES
624679848,624680931,FR
624680932,624680935,NL
-624680936,624681807,FR
+624680936,624681351,FR
+624681352,624681359,NL
+624681360,624681807,FR
624681808,624681823,BE
624681824,624683775,FR
624683776,624683779,DE
@@ -4034,7 +4179,9 @@
624683784,624683787,DE
624683788,624683975,FR
624683976,624683983,GB
-624683984,624684199,FR
+624683984,624684183,FR
+624684184,624684191,IT
+624684192,624684199,FR
624684200,624684203,IT
624684204,624684207,FR
624684208,624684211,ES
@@ -4059,7 +4206,9 @@
624687347,624687347,ES
624687348,624687827,FR
624687828,624687831,ES
-624687832,624688307,FR
+624687832,624688007,FR
+624688008,624688015,ES
+624688016,624688307,FR
624688308,624688311,ES
624688312,624688487,FR
624688488,624688491,ES
@@ -4135,7 +4284,9 @@
625524480,625524735,SE
625524736,625541119,FR
625541120,625606655,UA
-625606656,625672191,NL
+625606656,625621667,NL
+625621668,625621671,DE
+625621672,625672191,NL
625672192,625674239,RU
625674240,625676287,TR
625676288,625680383,MD
@@ -4561,8 +4712,8 @@
635191296,635195391,RS
635195392,635197439,RU
635197440,635199591,GB
-635199592,635199607,IT
-635199608,635199647,GB
+635199592,635199599,IT
+635199600,635199647,GB
635199648,635199655,IT
635199656,635199775,GB
635199776,635199783,IT
@@ -4607,7 +4758,9 @@
635240448,635256831,IR
635273216,635281407,UA
635281408,635283455,RO
-635283456,635284479,DE
+635283456,635283967,DE
+635283968,635284223,RO
+635284224,635284479,DE
635284480,635284991,RO
635284992,635285503,US
635285504,635287551,ME
@@ -4939,7 +5092,9 @@
645873664,645874175,CA
645874176,645875711,US
645875712,645876735,CA
-645876736,654311423,US
+645876736,645989450,US
+645989451,645989451,CA
+645989452,654311423,US
654311424,654311679,CN
654311680,654311935,AU
654311936,654376959,CN
@@ -5572,7 +5727,6 @@
702447616,702449663,EG
702449664,702451711,ZA
702451712,702453759,NG
-702453760,702455807,TZ
702455808,702457855,KE
702457856,702459903,EG
702459904,702461951,TZ
@@ -5777,7 +5931,9 @@
703753216,703753471,ZA
703753472,703754239,MG
703754240,703755263,GH
-703755264,703757311,ZA
+703755264,703755899,ZA
+703755900,703755900,YT
+703755901,703757311,ZA
703757312,703758335,RE
703758336,703759359,CD
703759360,703760383,ZA
@@ -5980,11 +6136,25 @@
737514496,737515519,IN
737515520,737516543,JP
737516544,737517567,IN
-737517568,737529855,JP
+737517568,737526783,JP
+737526784,737527295,US
+737527296,737529855,JP
737529856,737530879,IN
737530880,737941503,JP
737941504,737944575,IN
-737944576,738197503,JP
+737944576,737950719,JP
+737950720,737951743,IN
+737951744,737958911,JP
+737958912,737959935,IN
+737959936,737965055,JP
+737965056,737966079,IN
+737966080,737967103,JP
+737967104,737967359,AU
+737967360,737991679,JP
+737991680,737992191,IN
+737992192,737999320,JP
+737999321,737999321,IN
+737999322,738197503,JP
738197504,746717183,US
746717184,746782719,DE
746782720,755105791,US
@@ -6086,7 +6256,9 @@
772841472,772843519,GB
772843520,772845567,IT
772845568,772847615,RU
-772847616,772848191,NL
+772847616,772848103,NL
+772848104,772848111,US
+772848112,772848191,NL
772848192,772848223,US
772848224,772848871,NL
772848872,772848879,US
@@ -6115,7 +6287,7 @@
772884480,772886527,LB
772886528,772888575,FR
772888576,772890623,GB
-772890624,772892671,RU
+772890624,772892671,NL
772892672,772894719,GB
772894720,772896767,PL
772896768,772898815,RS
@@ -6889,7 +7061,9 @@
778247936,778248191,RS
778248192,778249727,AL
778249728,778249983,RS
-778249984,778305535,AL
+778249984,778304305,AL
+778304306,778304306,SI
+778304307,778305535,AL
778305536,778371071,IR
778371072,778436607,RU
778436608,778476031,RO
@@ -6913,7 +7087,9 @@
778668864,778668895,DE
778668896,778670975,FR
778670976,778670976,DE
-778670977,778673187,FR
+778670977,778671201,FR
+778671202,778671202,ES
+778671203,778673187,FR
778673188,778673191,ES
778673192,778673207,FR
778673208,778673211,ES
@@ -6943,7 +7119,9 @@
778680228,778680231,IE
778680232,778680683,FR
778680684,778680687,ES
-778680688,778681503,FR
+778680688,778681487,FR
+778681488,778681495,NL
+778681496,778681503,FR
778681504,778681507,DE
778681508,778681519,FR
778681520,778681523,ES
@@ -7118,7 +7296,9 @@
782663680,782667519,NL
782667520,782667775,LU
782667776,782671871,NL
-782671872,782675967,LT
+782671872,782672871,LT
+782672872,782672879,IL
+782672880,782675967,LT
782675968,782680063,NL
782680064,782696447,RU
782696448,782712831,DE
@@ -7430,7 +7610,9 @@
786920840,786920847,IT
786920848,786920855,GB
786920856,786920863,IT
-786920864,786921455,GB
+786920864,786921303,GB
+786921304,786921311,IT
+786921312,786921455,GB
786921456,786921463,IT
786921464,786921471,GB
786921472,786923519,ES
@@ -7579,7 +7761,8 @@
787703808,787705855,AT
787705856,787707903,RO
787707904,787709951,DE
-787709952,787724287,RU
+787709952,787718143,NL
+787718144,787724287,RU
787724288,787726335,UA
787726336,787742719,RU
787742720,787759103,NL
@@ -7619,7 +7802,9 @@
788070400,788078591,RU
788078592,788086783,NL
788086784,788094975,BG
-788094976,788103167,IR
+788094976,788100095,IR
+788100096,788101119,BG
+788101120,788103167,IR
788103168,788111359,HU
788111360,788119551,LT
788119552,788127743,GB
@@ -7802,7 +7987,8 @@
830475264,830476287,AU
830476288,830480383,JP
830480384,830488575,SG
-830488576,830496767,TW
+830488576,830492671,HK
+830492672,830496767,TW
830496768,830498815,JP
830498816,830499839,GU
830499840,830500863,IN
@@ -8245,7 +8431,10 @@
977764352,977797119,MY
977797120,978321407,KR
978321408,978452479,JP
-978452480,978583551,CN
+978452480,978485247,CN
+978485248,978501631,TH
+978501632,978518015,SG
+978518016,978583551,CN
978599936,978640895,AU
978640896,978644991,NZ
978644992,978714623,JP
@@ -8338,7 +8527,8 @@
999751680,999784447,CN
999784448,999800831,JP
999800832,999817215,KR
-999817216,999849983,BD
+999817216,999821311,BD
+999839744,999845887,BD
999849984,999866367,KR
999866368,999873919,HK
999873920,999873941,VN
@@ -8441,20 +8631,28 @@
1024352256,1024360447,AU
1024360448,1024361167,JP
1024361168,1024361183,HK
-1024361184,1024363263,JP
+1024361184,1024362911,JP
+1024362912,1024362943,SG
+1024362944,1024363263,JP
1024363264,1024363519,SG
1024363520,1024363775,JP
1024363776,1024364031,AU
-1024364032,1024365727,JP
+1024364032,1024364063,JP
+1024364064,1024364079,AU
+1024364080,1024365727,JP
1024365728,1024365759,SG
-1024365760,1024372543,JP
+1024365760,1024368639,JP
+1024368640,1024369407,MY
+1024369408,1024371199,JP
+1024371200,1024371455,PH
+1024371456,1024372543,JP
1024372544,1024372607,HK
1024372608,1024373263,JP
1024373264,1024373279,HK
1024373280,1024375295,JP
1024375296,1024375551,AU
1024375552,1024376831,JP
-1024376832,1024393215,PH
+1024376832,1024378879,PH
1024393216,1024458751,HK
1024458752,1024491519,SG
1024491520,1024589823,IN
@@ -8506,8 +8704,10 @@
1027866624,1027997695,AU
1027997696,1028128767,TW
1028128768,1029046271,KR
-1029046272,1029144575,JP
-1029144576,1029160959,SG
+1029046272,1029148671,JP
+1029148672,1029152767,HK
+1029152768,1029156863,SG
+1029156864,1029160959,AU
1029160960,1029177343,CN
1029177344,1029242879,AU
1029242880,1029308415,JP
@@ -8619,7 +8819,9 @@
1041710672,1041710687,FR
1041710688,1041711551,GB
1041711552,1041711559,FR
-1041711560,1041712631,GB
+1041711560,1041711943,GB
+1041711944,1041711951,FR
+1041711952,1041712631,GB
1041712632,1041712639,FR
1041712640,1041715071,GB
1041715072,1041715079,FR
@@ -8750,7 +8952,13 @@
1043103744,1043120127,DK
1043120128,1043136511,FI
1043136512,1043202047,NL
-1043202048,1043333119,AT
+1043202048,1043249919,AT
+1043249920,1043250175,HU
+1043250176,1043257087,AT
+1043257088,1043257343,DE
+1043257344,1043281151,AT
+1043281152,1043281407,DE
+1043281408,1043333119,AT
1043333120,1043341311,CH
1043341312,1043349503,IT
1043349504,1043357695,DE
@@ -8896,7 +9104,9 @@
1045158307,1045158307,SG
1045158308,1045159711,DE
1045159712,1045159712,EG
-1045159713,1045168127,DE
+1045159713,1045163508,DE
+1045163509,1045163511,SG
+1045163512,1045168127,DE
1045168128,1045233663,RU
1045233664,1045241855,GB
1045241856,1045250047,IT
@@ -8988,7 +9198,9 @@
1046488320,1046488575,DE
1046488576,1046489087,GB
1046489088,1046489119,DE
-1046489120,1046489391,GB
+1046489120,1046489311,GB
+1046489312,1046489327,ES
+1046489328,1046489391,GB
1046489392,1046489407,IT
1046489408,1046489471,GB
1046489472,1046489487,ES
@@ -9137,7 +9349,9 @@
1047658496,1047724031,EG
1047728128,1047732223,SE
1047787520,1047787775,ES
-1047789568,1047822335,AT
+1047789568,1047805439,AT
+1047805440,1047805695,DE
+1047805696,1047822335,AT
1047822336,1047838719,DE
1047838720,1047846911,DK
1047846912,1047855103,SE
@@ -9202,7 +9416,6 @@
1048707072,1048772607,GB
1048772608,1048903679,NL
1048903680,1048911871,GB
-1048911872,1048920063,IT
1048920064,1048936447,NL
1048936448,1048944639,PL
1048944640,1048952831,RU
@@ -9329,12 +9542,7 @@
1051803648,1051820031,CZ
1051820032,1051852799,NL
1051852800,1051918335,AT
-1051918336,1051918591,PL
-1051918592,1051919359,AT
-1051919360,1051920383,PL
-1051920384,1051920895,AT
-1051920896,1051921919,PL
-1051921920,1051922431,AT
+1051918336,1051922431,PL
1051922432,1051924479,CH
1051924480,1051948031,AT
1051948032,1051949055,CH
@@ -9488,7 +9696,9 @@
1053663232,1053671423,RU
1053671424,1053687807,LV
1053687808,1053753343,DE
-1053753344,1053818879,NL
+1053753344,1053788687,NL
+1053788688,1053788695,DE
+1053788696,1053818879,NL
1053818880,1053819391,DE
1053819424,1053819439,DE
1053819520,1053819563,DE
@@ -9548,7 +9758,8 @@
1053867976,1053867983,DE
1053867992,1053867999,DE
1053868008,1053868015,DE
-1053868032,1053868447,ES
+1053868032,1053868351,ES
+1053868416,1053868447,ES
1053868448,1053868455,GB
1053868456,1053868463,ES
1053868480,1053868543,FR
@@ -9718,7 +9929,8 @@
1056473088,1056505855,FI
1056505856,1056514047,PT
1056514048,1056522239,IT
-1056522240,1056538623,AT
+1056522240,1056523007,DE
+1056523008,1056538623,AT
1056538624,1056546815,RU
1056546816,1056555007,NO
1056555008,1056571391,GB
@@ -9765,9 +9977,7 @@
1063305728,1063305983,CA
1063305984,1063568895,US
1063568896,1063569151,TZ
-1063569152,1063727615,US
-1063727616,1063728127,GU
-1063728128,1063748607,US
+1063569152,1063748607,US
1063748608,1063749119,GH
1063749120,1063749631,US
1063749632,1063749887,LR
@@ -10025,13 +10235,17 @@
1071954304,1071954319,GB
1071954320,1071954391,US
1071954392,1071954399,GB
-1071954400,1072157631,US
+1071954400,1071998999,US
+1071999000,1071999003,GB
+1071999004,1072157631,US
1072157632,1072157663,DE
1072157664,1072228863,US
1072228864,1072229375,CA
1072229376,1072360703,US
1072360704,1072360959,HK
-1072360960,1072707327,US
+1072360960,1072361471,US
+1072361472,1072361727,GB
+1072361728,1072707327,US
1072707328,1072707583,IN
1072707584,1072923135,US
1072923136,1072923391,CA
@@ -10437,7 +10651,9 @@
1078280192,1078280447,CA
1078280448,1078280575,US
1078280576,1078280583,CA
-1078280584,1078281300,US
+1078280584,1078281071,US
+1078281072,1078281079,CA
+1078281080,1078281300,US
1078281301,1078281301,CA
1078281302,1078281511,US
1078281512,1078281519,CA
@@ -10447,9 +10663,11 @@
1078281728,1078281735,CA
1078281736,1078282239,US
1078282240,1078283015,CA
-1078283016,1078284031,US
-1078284032,1078284159,CA
-1078284160,1078284479,US
+1078283016,1078283831,US
+1078283832,1078283839,CA
+1078283840,1078284031,US
+1078284032,1078284287,CA
+1078284288,1078284479,US
1078284480,1078284543,CA
1078284544,1078284703,US
1078284704,1078284719,CA
@@ -10542,109 +10760,66 @@
1079377920,1079378943,CA
1079378944,1079379199,US
1079379200,1079379455,CA
-1079379456,1079379711,US
-1079379712,1079380927,CA
-1079380928,1079380991,US
-1079380992,1079381759,CA
-1079381760,1079382271,US
-1079382272,1079382527,CA
-1079382528,1079383039,US
+1079379456,1079383039,US
1079383040,1079383295,VG
-1079383296,1079383551,CA
-1079383552,1079383807,US
+1079383296,1079383807,US
1079383808,1079384063,MH
1079384064,1079384319,LR
1079384320,1079384575,CA
1079384576,1079385087,ZW
-1079385088,1079385343,US
-1079385344,1079385471,CA
-1079385472,1079385479,US
-1079385480,1079386623,CA
+1079385088,1079385599,US
+1079385600,1079386623,CA
1079386624,1079386879,SG
1079386880,1079387135,EG
1079387136,1079387903,US
1079387904,1079388159,PH
-1079388160,1079389695,CA
-1079389696,1079389951,US
-1079389952,1079390975,CA
-1079390976,1079391487,US
-1079391488,1079391743,CA
+1079388160,1079389183,CA
+1079389184,1079389951,US
+1079389952,1079390207,CA
+1079390208,1079391743,US
1079391744,1079392255,HT
1079392256,1079393791,CA
-1079393792,1079394047,US
-1079394048,1079394303,CA
+1079393792,1079394303,US
1079394304,1079395327,EC
1079395328,1079396095,US
1079396096,1079396351,CA
1079396352,1079397375,MP
1079397376,1079397631,MH
-1079397632,1079397887,CA
-1079397888,1079398399,US
-1079398400,1079399935,CA
-1079399936,1079400447,US
-1079400448,1079401215,CA
-1079401216,1079401471,US
-1079401472,1079403263,CA
+1079397632,1079400959,US
+1079400960,1079401215,CA
+1079401216,1079402495,US
+1079402496,1079403263,CA
1079403264,1079403519,US
1079403520,1079403775,CA
-1079403776,1079403807,US
-1079403808,1079403903,CA
-1079403904,1079403935,US
-1079403936,1079403999,CA
-1079404000,1079404031,US
-1079404032,1079404543,CA
-1079404544,1079404799,US
-1079404800,1079404959,CA
-1079404960,1079404991,US
-1079404992,1079405023,CA
-1079405024,1079405055,US
-1079405056,1079407103,CA
-1079407104,1079407359,US
-1079407360,1079407615,CA
-1079407616,1079408127,US
-1079408128,1079408639,CA
-1079408640,1079408895,US
+1079403776,1079405567,US
+1079405568,1079406079,CA
+1079406080,1079408895,US
1079408896,1079409407,PK
1079409408,1079409919,US
-1079409920,1079410687,CA
-1079410688,1079410943,US
-1079410944,1079411199,CA
-1079411200,1079411455,US
+1079409920,1079410175,CA
+1079410176,1079411455,US
1079411456,1079411711,PK
-1079411712,1079411743,US
-1079411744,1079412735,CA
-1079412736,1079413247,US
-1079413248,1079413311,CA
-1079413312,1079413343,US
-1079413344,1079414271,CA
+1079411712,1079413759,US
+1079413760,1079414271,CA
1079414272,1079415039,US
1079415040,1079415295,HN
-1079415296,1079415871,US
-1079415872,1079415879,CA
-1079415880,1079415887,US
-1079415888,1079421951,CA
-1079421952,1079422207,US
-1079422208,1079425023,CA
-1079425024,1079425279,US
-1079425280,1079427583,CA
+1079415296,1079416831,US
+1079416832,1079418879,CA
+1079418880,1079422975,US
+1079422976,1079423999,CA
+1079424000,1079425791,US
+1079425792,1079426047,CA
+1079426048,1079427327,US
+1079427328,1079427583,CA
1079427584,1079428095,PW
-1079428096,1079429263,CA
-1079429264,1079429295,US
-1079429296,1079429375,CA
-1079429376,1079429631,US
-1079429632,1079431679,CA
+1079428096,1079431679,US
1079431680,1079432191,ZM
-1079432192,1079432703,CA
-1079432704,1079432959,US
+1079432192,1079432959,US
1079432960,1079433215,CA
1079433216,1079435263,CR
1079435264,1079435775,CO
-1079435776,1079437311,CA
-1079437312,1079439359,US
-1079439360,1079442431,CA
-1079442432,1079442687,US
-1079442688,1079443455,CA
-1079443456,1079459839,US
+1079435776,1079436031,CA
+1079436032,1079459839,US
1079459840,1079508991,CA
1079508992,1079566847,US
1079566848,1079567103,GB
@@ -10795,9 +10970,7 @@
1082952704,1082952959,CA
1082952960,1082982399,US
1082982400,1083015167,CA
-1083015168,1083265023,US
-1083265024,1083265279,CA
-1083265280,1083396095,US
+1083015168,1083396095,US
1083396096,1083400191,BM
1083400192,1083437055,US
1083437056,1083441151,CA
@@ -10823,7 +10996,7 @@
1085849600,1085857791,CA
1085857792,1085915135,US
1085915136,1085923327,PR
-1085927424,1085997055,US
+1085923328,1085997055,US
1085997056,1086013439,CA
1086013440,1086042111,US
1086042112,1086046207,CA
@@ -11200,9 +11373,7 @@
1101304064,1101304319,EC
1101304320,1101304831,US
1101304832,1101305855,HN
-1101305856,1101306047,US
-1101306048,1101306079,PR
-1101306080,1101352959,US
+1101305856,1101352959,US
1101352960,1101355007,HN
1101355008,1101402031,US
1101402032,1101402047,PR
@@ -11533,7 +11704,9 @@
1114507264,1114511871,US
1114511872,1114512127,CA
1114512128,1114513407,US
-1114513408,1114515455,SA
+1114513408,1114513471,SA
+1114513472,1114513535,US
+1114513536,1114515455,SA
1114515456,1114517503,US
1114517504,1114518015,CA
1114518016,1114520063,US
@@ -11758,9 +11931,7 @@
1119558144,1119558655,PR
1119558656,1119568383,US
1119568384,1119568639,GB
-1119568640,1119568767,US
-1119568768,1119568895,GB
-1119568896,1119570175,US
+1119568640,1119570175,US
1119570176,1119570303,GB
1119570304,1119571967,US
1119571968,1119576063,CA
@@ -12028,6 +12199,7 @@
1125478400,1125481215,US
1125481216,1125481727,CA
1125481728,1125489151,US
+1125489152,1125490687,CA
1125490688,1125498879,US
1125498880,1125501439,CA
1125501440,1125501695,US
@@ -12157,7 +12329,8 @@
1138184192,1138184447,SG
1138184448,1138184959,US
1138184960,1138185215,AU
-1138185216,1138188287,US
+1138185216,1138185727,CA
+1138185728,1138188287,US
1138188288,1138192383,PR
1138192384,1138196479,US
1138196480,1138204671,CA
@@ -12251,7 +12424,9 @@
1145430016,1145475071,US
1145475072,1145479167,CA
1145479168,1145503743,US
-1145503744,1145520127,CA
+1145503744,1145506815,CA
+1145506816,1145507071,US
+1145507072,1145520127,CA
1145520128,1145552895,US
1145552896,1145556991,CA
1145556992,1150043135,US
@@ -12512,9 +12687,7 @@
1161627704,1161627711,DE
1161627712,1161631623,US
1161631624,1161631631,KW
-1161631632,1161634079,US
-1161634080,1161634087,AF
-1161634088,1161649407,US
+1161631632,1161649407,US
1161649408,1161649663,AR
1161649664,1161764863,US
1161764864,1161773055,CA
@@ -12984,7 +13157,9 @@
1208935984,1208935991,IN
1208935992,1208935999,JP
1208936000,1208936003,HK
-1208936004,1208936191,US
+1208936004,1208936031,US
+1208936032,1208936039,IN
+1208936040,1208936191,US
1208936192,1208936199,AU
1208936200,1208936207,SG
1208936208,1208936215,HK
@@ -13020,7 +13195,12 @@
1209729024,1209786367,JM
1209786368,1209810943,US
1209810944,1209819135,CA
-1209819136,1209824511,US
+1209819136,1209823487,US
+1209823488,1209823519,GB
+1209823520,1209823543,US
+1209823544,1209823551,GB
+1209823552,1209824447,US
+1209824448,1209824511,GB
1209824512,1209824767,CN
1209824768,1209861119,US
1209861120,1209861375,CA
@@ -13070,7 +13250,9 @@
1211308168,1211308175,CA
1211308176,1211308287,US
1211308288,1211308543,CA
-1211308544,1211308799,US
+1211308544,1211308719,US
+1211308720,1211308727,CA
+1211308728,1211308799,US
1211308800,1211310079,CA
1211310080,1211316479,US
1211316480,1211316991,CA
@@ -13659,7 +13841,8 @@
1296250496,1296250527,FR
1296250528,1296250559,DK
1296250560,1296250623,FR
-1296250624,1296250879,BE
+1296250624,1296250847,BE
+1296250848,1296250879,GB
1296250880,1296251199,FR
1296251200,1296251231,NL
1296251232,1296251391,FR
@@ -14163,8 +14346,7 @@
1307636992,1307637247,LV
1307637248,1307637503,EE
1307637504,1307637759,LV
-1307637760,1307639551,EE
-1307639552,1307639807,LT
+1307637760,1307639807,LT
1307639808,1307643903,IT
1307643904,1307652095,RU
1307652096,1307656191,ES
@@ -14210,6 +14392,7 @@
1307817984,1307818048,GB
1307818049,1307818049,BE
1307818050,1307818239,GB
+1307819008,1307819263,GB
1307819520,1307819775,GB
1307820032,1307824127,ES
1307824128,1307828223,HU
@@ -14240,8 +14423,7 @@
1307926528,1307930623,KZ
1307930624,1307934719,RU
1307934720,1307938815,FR
-1307938816,1307941119,US
-1307941120,1307942911,TR
+1307938816,1307942911,US
1307942912,1307947007,RU
1307947008,1307951103,CH
1307951104,1307959295,RU
@@ -14617,7 +14799,7 @@
1317928960,1317945343,BG
1317945344,1317978111,AT
1317978112,1317994495,RU
-1317994496,1318010879,NL
+1317994496,1318010879,DE
1318010880,1318027263,DK
1318027264,1318043647,IE
1318043648,1318584319,GB
@@ -14779,7 +14961,6 @@
1332609024,1332613119,PL
1332613120,1332617215,UA
1332617216,1332621311,CZ
-1332621312,1332625407,UA
1332625408,1332629503,RU
1332629504,1332633599,DE
1332633600,1332637695,UA
@@ -15179,7 +15360,6 @@
1346412544,1346416639,RU
1346416640,1346420735,DE
1346420736,1346424831,NO
-1346424832,1346428927,JO
1346428928,1346433023,FR
1346433024,1346439167,NL
1346439168,1346441215,ES
@@ -15602,9 +15782,6 @@
1347305472,1347309567,AL
1347309568,1347313663,DE
1347313664,1347321855,RU
-1347321856,1347322111,KW
-1347322112,1347322367,US
-1347322368,1347325951,KW
1347325952,1347327743,CZ
1347327744,1347327999,SK
1347328000,1347330047,CZ
@@ -15865,7 +16042,8 @@
1348419584,1348427775,HU
1348427776,1348435967,CZ
1348435968,1348440063,FI
-1348440064,1348448255,NL
+1348440064,1348444159,DE
+1348444160,1348448255,NL
1348448256,1348456447,GB
1348456448,1348460543,BH
1348460544,1348464639,SI
@@ -15878,20 +16056,42 @@
1348861952,1348993023,ES
1348993024,1349124095,IT
1349124096,1349255167,GR
-1349255168,1349451775,AT
+1349255168,1349400575,AT
+1349400576,1349401087,DE
+1349401088,1349451775,AT
1349451776,1349517311,IE
1349517312,1349763071,NL
1349763072,1349771263,RU
1349771264,1349779455,NL
1349779456,1349910527,IT
1349910528,1350041599,FR
-1350041600,1350215679,AT
+1350041600,1350067575,AT
+1350067576,1350067579,CH
+1350067580,1350110335,AT
+1350110336,1350110463,DE
+1350110464,1350140927,AT
+1350140928,1350141055,CH
+1350141056,1350166015,AT
+1350166016,1350166271,SK
+1350166272,1350188543,AT
+1350188544,1350188799,DE
+1350188800,1350195231,AT
+1350195232,1350195235,DE
+1350195236,1350215679,AT
1350215680,1350215935,IQ
1350215936,1350216959,AT
1350216960,1350217215,IQ
1350217216,1350217471,AT
1350217472,1350217727,IQ
-1350217728,1350303743,AT
+1350217728,1350230015,AT
+1350230016,1350230271,DE
+1350230272,1350251007,AT
+1350251008,1350251263,HU
+1350251264,1350259447,AT
+1350259448,1350259451,CZ
+1350259452,1350290223,AT
+1350290224,1350290227,CH
+1350290228,1350303743,AT
1350303744,1350434815,FR
1350434816,1350565887,NL
1350565888,1352299775,DE
@@ -15996,6 +16196,7 @@
1357347456,1357347583,FR
1357347616,1357347647,FR
1357347840,1357348095,PL
+1357348384,1357348415,ES
1357351168,1357351423,PL
1357359872,1357360383,GB
1357361152,1357363199,GB
@@ -16817,7 +17018,9 @@
1365219168,1365219168,GB
1365219169,1365219391,NL
1365219392,1365219407,MY
-1365219408,1365220231,NL
+1365219408,1365219703,NL
+1365219704,1365219711,US
+1365219712,1365220231,NL
1365220232,1365220239,IE
1365220240,1365221239,NL
1365221240,1365221247,US
@@ -17351,7 +17554,11 @@
1385496576,1385504767,SI
1385504768,1385512959,IT
1385512960,1385521151,DE
-1385521152,1385529343,AT
+1385521152,1385523711,AT
+1385523712,1385523967,HU
+1385523968,1385524479,AT
+1385524480,1385524735,HU
+1385524736,1385529343,AT
1385529344,1385537535,RU
1385537536,1385545727,DE
1385545728,1385553919,RU
@@ -17589,7 +17796,9 @@
1389871104,1389887487,FI
1389887488,1389953023,FR
1389953024,1390018559,NL
-1390018560,1390084095,AT
+1390018560,1390074879,AT
+1390074880,1390075135,HU
+1390075136,1390084095,AT
1390084096,1390149631,GB
1390149632,1390215167,CH
1390215168,1390280703,IS
@@ -17903,9 +18112,7 @@
1403781120,1403797503,RU
1403797504,1403813887,SE
1403813888,1403830271,NL
-1403830272,1403838719,CH
-1403838720,1403838975,RU
-1403838976,1403846655,CH
+1403830272,1403846655,CH
1403846656,1403863039,IS
1403863040,1403879423,FR
1403879424,1403895807,ES
@@ -18103,7 +18310,21 @@
1404887040,1404927999,NL
1404928000,1404944383,SE
1404944384,1404960767,LT
-1404960768,1405026303,SE
+1404960768,1405009919,SE
+1405009920,1405010687,LT
+1405010688,1405010943,SE
+1405010944,1405011199,LT
+1405011200,1405011711,SE
+1405011712,1405013759,LT
+1405013760,1405014015,SE
+1405014016,1405020159,LT
+1405020160,1405020415,SE
+1405020416,1405020927,LT
+1405020928,1405021183,SE
+1405021184,1405021439,LT
+1405021440,1405021951,SE
+1405021952,1405022207,LT
+1405022208,1405026303,SE
1405026304,1405042687,NO
1405042688,1405048831,SE
1405048832,1405050879,HR
@@ -18396,7 +18617,15 @@
1410834432,1410842623,PL
1410842624,1410850815,PT
1410850816,1410859007,DE
-1410859008,1411383295,NL
+1410859008,1410972159,NL
+1410972160,1410972415,DE
+1410972416,1410972671,NL
+1410972672,1410972927,DE
+1410972928,1410973439,NL
+1410973440,1410973695,DE
+1410973696,1410975487,NL
+1410975488,1410975743,DE
+1410975744,1411383295,NL
1411383296,1411448831,LT
1411448832,1411449727,IT
1411449728,1411449791,DE
@@ -18518,7 +18747,9 @@
1415577600,1416101887,FR
1416101888,1416364031,NL
1416364032,1416626175,IL
-1416626176,1416941567,AT
+1416626176,1416876287,AT
+1416876288,1416876543,CH
+1416876544,1416941567,AT
1416941568,1416943615,CH
1416943616,1416944639,AT
1416944640,1416945663,CZ
@@ -18527,11 +18758,67 @@
1417019392,1417150463,DE
1417150464,1417674751,ES
1417674752,1421869055,DE
-1421869056,1422393343,BE
+1421869056,1421886975,BE
+1421886976,1421887743,NL
+1421887744,1421888511,BE
+1421888512,1421888767,NL
+1421888768,1421889279,BE
+1421889280,1421889791,NL
+1421889792,1421890047,BE
+1421890048,1421890303,NL
+1421890304,1421893119,BE
+1421893120,1421893631,NL
+1421893632,1421894143,BE
+1421894144,1421894399,NL
+1421894400,1421894783,BE
+1421894784,1421894911,NL
+1421894912,1421896063,BE
+1421896064,1421896703,NL
+1421896704,1421896831,BE
+1421896832,1421896959,NL
+1421896960,1421897727,BE
+1421897728,1421898239,NL
+1421898240,1421899263,BE
+1421899264,1421899519,NL
+1421899520,1421900543,BE
+1421900544,1421900799,NL
+1421900800,1421959679,BE
+1421959680,1421959807,NL
+1421959808,1421959935,BE
+1421959936,1421960191,NL
+1421960192,1422022143,BE
+1422022144,1422022399,NL
+1422022400,1422082559,BE
+1422082560,1422083071,NL
+1422083072,1422084223,BE
+1422084224,1422084351,NL
+1422084352,1422085119,BE
+1422085120,1422085375,NL
+1422085376,1422085887,BE
+1422085888,1422086143,NL
+1422086144,1422087679,BE
+1422087680,1422088191,NL
+1422088192,1422088447,BE
+1422088448,1422088703,NL
+1422088704,1422088959,BE
+1422088960,1422089215,NL
+1422089216,1422089471,BE
+1422089472,1422089727,NL
+1422089728,1422095743,BE
+1422095744,1422095871,NL
+1422095872,1422128639,BE
+1422128640,1422129151,NL
+1422129152,1422132479,BE
+1422132480,1422132735,NL
+1422132736,1422289663,BE
+1422289664,1422289791,NL
+1422289792,1422393343,BE
1422393344,1422413567,DE
1422413568,1422413695,AT
1422413696,1422413727,US
-1422413728,1422491647,DE
+1422413728,1422463231,DE
+1422463232,1422463743,NL
+1422463744,1422491647,DE
1422491648,1422495615,RU
1422495616,1422495679,NL
1422495680,1422508031,RU
@@ -18561,7 +18848,9 @@
1423966208,1424097279,HU
1424097280,1424228351,CH
1424228352,1424286719,IL
-1424286720,1424287743,BG
+1424286720,1424286938,BG
+1424286939,1424286939,IL
+1424286940,1424287743,BG
1424287744,1424359423,IL
1424359424,1424490495,FI
1424490496,1424503711,ES
@@ -18579,7 +18868,9 @@
1424600576,1424600831,FR
1424600832,1424602879,GB
1424602880,1424603135,US
-1424603136,1424607743,GB
+1424603136,1424604975,GB
+1424604976,1424604983,NL
+1424604984,1424607743,GB
1424607744,1424607775,DE
1424607776,1424617215,GB
1424617216,1424617231,IT
@@ -18672,7 +18963,9 @@
1425485312,1425489407,RO
1425489408,1425489663,NL
1425489664,1425506303,RO
-1425506304,1425522687,NO
+1425506304,1425518847,NO
+1425518848,1425518975,RU
+1425518976,1425522687,NO
1425522688,1425539071,IT
1425539072,1425801215,FI
1425801216,1425813759,BG
@@ -19166,7 +19459,9 @@
1439156107,1439156108,LB
1439156109,1439170559,GB
1439170560,1439236095,NO
-1439236096,1439301631,BE
+1439236096,1439261439,BE
+1439261440,1439261695,FR
+1439261696,1439301631,BE
1439301632,1439305727,RU
1439305728,1439309823,DK
1439309824,1439318015,PL
@@ -19237,8 +19532,8 @@
1440645120,1440669695,RS
1440669696,1440671743,NL
1440671744,1440672767,EE
-1440672768,1440677887,RS
-1440677888,1440710655,NL
+1440672768,1440673791,RS
+1440673792,1440710655,NL
1440710656,1440743423,UA
1440743424,1441267711,SE
1441267712,1441275903,DE
@@ -19342,7 +19637,11 @@
1442832384,1442836479,GB
1442836480,1442840575,PL
1442840576,1444937727,GB
-1444937728,1445068799,AT
+1444937728,1444985599,AT
+1444985600,1444985855,DE
+1444985856,1445061631,AT
+1445061632,1445061887,DE
+1445061888,1445068799,AT
1445068800,1445199871,RO
1445199872,1445330943,QA
1445330944,1445396479,LT
@@ -19402,7 +19701,9 @@
1449840640,1449852927,MD
1449852928,1449869311,RO
1449869312,1449870335,MD
-1449870336,1449893887,RO
+1449870336,1449883647,RO
+1449883648,1449885695,BE
+1449885696,1449893887,RO
1449893888,1449895935,MD
1449895936,1449918463,RO
1449918464,1449951231,JO
@@ -19476,7 +19777,9 @@
1466104468,1466104468,GB
1466104469,1466104942,FR
1466104943,1466104943,BE
-1466104944,1466105343,FR
+1466104944,1466105173,FR
+1466105174,1466105174,BE
+1466105175,1466105343,FR
1466105344,1466105599,GB
1466105600,1466105855,FR
1466105856,1466122239,PL
@@ -19643,7 +19946,9 @@
1475211264,1475213311,DE
1475213312,1475215359,FR
1475215360,1475223551,IT
-1475223552,1475226495,SE
+1475223552,1475226239,SE
+1475226240,1475226367,NO
+1475226368,1475226495,SE
1475226496,1475227647,NO
1475227648,1475231743,SE
1475231744,1475233791,NO
@@ -19939,7 +20244,19 @@
1482948608,1483210751,CZ
1483210752,1483735039,GB
1483735040,1483997183,FI
-1483997184,1484128255,AT
+1483997184,1484044287,AT
+1484044288,1484044543,DE
+1484044544,1484049911,AT
+1484049912,1484049915,DE
+1484049916,1484049921,AT
+1484049922,1484049922,DE
+1484049923,1484084607,AT
+1484084608,1484084735,DE
+1484084736,1484084991,AT
+1484084992,1484085119,DE
+1484085120,1484088831,AT
+1484088832,1484089087,DE
+1484089088,1484128255,AT
1484128256,1484259327,LT
1484259328,1484783615,FR
1484783616,1484849151,DE
@@ -20265,7 +20582,6 @@
1495203840,1495205887,DE
1495205888,1495207935,CZ
1495207936,1495209983,RU
-1495209984,1495212031,KZ
1495212032,1495214079,RU
1495214080,1495216127,CZ
1495216128,1495220223,IT
@@ -20319,7 +20635,9 @@
1495468032,1495470079,MD
1495470080,1495476223,RO
1495476224,1495478271,MD
-1495478272,1495492607,RO
+1495478272,1495487487,RO
+1495487488,1495488511,MD
+1495488512,1495492607,RO
1495492608,1495494655,MD
1495494656,1495508991,RO
1495508992,1495510015,MD
@@ -20329,7 +20647,9 @@
1495571456,1495572479,MD
1495572480,1495608319,RO
1495608320,1495609343,MD
-1495609344,1495670783,RO
+1495609344,1495623679,RO
+1495623680,1495623935,MD
+1495623936,1495670783,RO
1495670784,1495671807,MD
1495671808,1495678975,RO
1495678976,1495679999,MD
@@ -20337,7 +20657,9 @@
1495682048,1495683071,MD
1495683072,1495747583,RO
1495747584,1495748607,MD
-1495748608,1495749631,RO
+1495748608,1495748863,RO
+1495748864,1495749119,GB
+1495749120,1495749631,RO
1495749632,1495750655,MD
1495750656,1495752703,RO
1495752704,1495755775,MD
@@ -20347,11 +20669,15 @@
1495759872,1495760127,MD
1495760128,1495762943,RO
1495762944,1495764991,MD
-1495764992,1495790079,RO
+1495764992,1495782655,RO
+1495782656,1495782911,GB
+1495782912,1495790079,RO
1495790080,1495790335,MD
1495790336,1495793663,RO
1495793664,1495795711,MD
-1495795712,1495852031,RO
+1495795712,1495845631,RO
+1495845632,1495845887,GB
+1495845888,1495852031,RO
1495852032,1495853055,MD
1495853056,1495875583,RO
1495875584,1495891967,MD
@@ -20410,7 +20736,13 @@
1499594752,1499725823,NL
1499725824,1499856895,IE
1499856896,1499987967,CZ
-1499987968,1499996159,AT
+1499987968,1499989247,AT
+1499989248,1499989503,HU
+1499989504,1499990911,AT
+1499990912,1499991039,HU
+1499991040,1499992575,AT
+1499992576,1499992831,HU
+1499992832,1499996159,AT
1499996160,1500004351,GB
1500004352,1500020735,RU
1500020736,1500028927,IS
@@ -20486,7 +20818,11 @@
1500479488,1500495871,RU
1500495872,1500512255,BA
1500512256,1500643327,RU
-1500643328,1500774399,RO
+1500643328,1500661247,PT
+1500661248,1500661503,RO
+1500661504,1500667647,PT
+1500667648,1500667903,RO
+1500667904,1500774399,PT
1500774400,1500905471,LT
1500905472,1501036543,IT
1501036544,1501298687,RO
@@ -20635,9 +20971,7 @@
1503898808,1503898815,PL
1503898816,1503898831,GB
1503898832,1503898839,RO
-1503898840,1503898847,DE
-1503898848,1503898855,MX
-1503898856,1503898887,DE
+1503898840,1503898887,DE
1503898888,1503898895,IT
1503898896,1503898927,DE
1503898928,1503898935,RO
@@ -20882,7 +21216,9 @@
1506445168,1506445183,DE
1506445184,1506446823,GB
1506446824,1506446831,NL
-1506446832,1506450047,GB
+1506446832,1506448319,GB
+1506448320,1506448383,IT
+1506448384,1506450047,GB
1506450048,1506450111,CH
1506450112,1506450863,GB
1506450864,1506450879,CZ
@@ -20894,7 +21230,9 @@
1506458245,1506458245,CH
1506458246,1506460151,GB
1506460152,1506460159,FR
-1506460160,1506463679,GB
+1506460160,1506462719,GB
+1506462720,1506462975,IT
+1506462976,1506463679,GB
1506463680,1506463695,DE
1506463696,1506464895,GB
1506464896,1506464911,NL
@@ -20929,7 +21267,6 @@
1506705408,1506727935,GB
1506727936,1506728959,FR
1506728960,1506740223,GB
-1506740224,1506742271,FI
1506742272,1506744319,SE
1506744320,1506746367,NL
1506746368,1506750463,RU
@@ -21367,20 +21704,7 @@
1518407936,1518408191,SE
1518408192,1518409727,NL
1518409728,1518436351,SE
-1518436352,1518439679,NO
-1518439680,1518439935,SE
-1518439936,1518441471,NO
-1518441472,1518441727,SE
-1518441728,1518444031,NO
-1518444032,1518444287,SE
-1518444288,1518444543,NO
-1518444544,1518444799,SE
-1518444800,1518445823,NO
-1518445824,1518446335,SE
-1518446336,1518448383,NO
-1518448384,1518448895,SE
-1518448896,1518452223,NO
-1518452224,1518452735,SE
+1518436352,1518452735,NO
1518452736,1518460927,AT
1518460928,1518470143,NL
1518470144,1518472191,SE
@@ -21472,7 +21796,15 @@
1518993408,1519190015,RU
1519190016,1519206399,SE
1519206400,1519208447,LV
-1519208448,1519259647,SE
+1519208448,1519214591,SE
+1519214592,1519214847,LV
+1519214848,1519215359,SE
+1519215360,1519215615,LV
+1519215616,1519215871,SE
+1519215872,1519219455,LV
+1519219456,1519219711,SE
+1519219712,1519222783,LV
+1519222784,1519259647,SE
1519259648,1519260671,NL
1519260672,1519263743,SE
1519263744,1519289343,NL
@@ -21535,7 +21867,9 @@
1520271360,1520304127,SI
1520304128,1520435199,TR
1520435200,1521483775,ES
-1521483776,1522008063,CZ
+1521483776,1521531391,CZ
+1521531392,1521531647,PL
+1521531648,1522008063,CZ
1522008064,1522139135,DK
1522139136,1522270207,DE
1522270208,1522401279,RU
@@ -21556,7 +21890,9 @@
1532199936,1532200959,RS
1532200960,1532231679,HU
1532231680,1532362751,GB
-1532362752,1532493823,BE
+1532362752,1532408063,BE
+1532408064,1532408319,DE
+1532408320,1532493823,BE
1532493824,1532559359,FR
1532559360,1532624895,DE
1532624896,1532626943,ES
@@ -21701,7 +22037,29 @@
1533929472,1533932799,GB
1533932800,1533933055,DE
1533933056,1534066687,GB
-1534066688,1534328831,AT
+1534066688,1534135295,AT
+1534135296,1534135423,HU
+1534135424,1534145279,AT
+1534145280,1534145407,DE
+1534145408,1534147711,AT
+1534147712,1534147839,CZ
+1534147840,1534156543,AT
+1534156544,1534156671,SK
+1534156672,1534241535,AT
+1534241536,1534241663,DE
+1534241664,1534268671,AT
+1534268672,1534268927,HU
+1534268928,1534279423,AT
+1534279424,1534279551,SK
+1534279552,1534298751,AT
+1534298752,1534298879,HU
+1534298880,1534299903,AT
+1534299904,1534300159,HU
+1534300160,1534302975,AT
+1534302976,1534303231,HU
+1534303232,1534303999,AT
+1534304000,1534304255,SK
+1534304256,1534328831,AT
1534328832,1534459903,ES
1534459904,1534590975,AT
1534590976,1534656511,HU
@@ -21767,7 +22125,9 @@
1534984192,1534985215,NO
1534985216,1535049727,ES
1535049728,1535115263,SK
-1535115264,1535197183,AT
+1535115264,1535146495,AT
+1535146496,1535146751,CH
+1535146752,1535197183,AT
1535197184,1535203071,EE
1535203072,1535246335,SE
1535246336,1535311871,AT
@@ -21777,7 +22137,8 @@
1535352832,1535361023,EE
1535361024,1535377407,NL
1535377408,1535442943,GR
-1535442944,1535451135,FI
+1535442944,1535450879,RU
+1535450880,1535451135,FI
1535451136,1535459327,DK
1535459328,1535475711,AT
1535475712,1535508479,IR
@@ -21795,7 +22156,9 @@
1535602688,1535606783,HU
1535606784,1535610879,NO
1535610880,1535614975,RU
-1535614976,1535619071,AT
+1535614976,1535618559,AT
+1535618560,1535618815,DE
+1535618816,1535619071,AT
1535619072,1535623167,FR
1535623168,1535627263,KZ
1535627264,1535631359,RU
@@ -21810,7 +22173,9 @@
1535717376,1535721471,CH
1535721472,1535721727,DE
1535721728,1535737855,CH
-1535737856,1535770623,HU
+1535737856,1535746815,HU
+1535746816,1535747071,RS
+1535747072,1535770623,HU
1535770624,1535803391,CH
1535803392,1535836159,GR
1535836160,1535868927,CZ
@@ -21912,7 +22277,9 @@
1536684032,1536688127,GB
1536688128,1537212415,FI
1537212416,1538260991,FR
-1538260992,1538785279,BE
+1538260992,1538628607,BE
+1538628608,1538629119,FR
+1538629120,1538785279,BE
1538785280,1538793471,NL
1538793472,1538797567,DE
1538797568,1538801663,NL
@@ -22946,7 +23313,6 @@
1539927040,1539928063,UA
1539928064,1539930111,RU
1539930112,1539931135,PL
-1539931136,1539932159,UA
1539932160,1539933183,DE
1539933184,1539934207,ES
1539934208,1539935231,RS
@@ -23398,8 +23764,7 @@
1540361472,1540361727,DE
1540361728,1540361983,IT
1540361984,1540362239,EE
-1540362240,1540362495,RU
-1540362496,1540363007,DE
+1540362240,1540363263,DE
1540363264,1540363519,RU
1540363776,1540364031,IS
1540364032,1540364287,RU
@@ -25027,7 +25392,7 @@
1541163520,1541163775,DE
1541163776,1541164031,RO
1541164032,1541164287,RU
-1541164288,1541164543,HR
+1541164288,1541164543,CH
1541164544,1541164799,SI
1541164800,1541165055,IR
1541165056,1541165311,UA
@@ -26030,7 +26395,7 @@
1541707520,1541707775,NL
1541707776,1541708799,DE
1541708800,1541709823,PL
-1541709824,1541710335,RU
+1541710080,1541710335,RU
1541710336,1541710847,IL
1541710848,1541711871,SK
1541711872,1541712127,FR
@@ -26269,7 +26634,7 @@
1541836288,1541836543,AT
1541836800,1541837055,CZ
1541837056,1541837311,IT
-1541837312,1541837823,RU
+1541837312,1541837567,RU
1541837824,1541838079,PL
1541838080,1541839871,RU
1541839872,1541840383,PL
@@ -26514,7 +26879,6 @@
1541981952,1541982207,UA
1541982208,1541982719,RS
1541982720,1541984255,RU
-1541984256,1541984511,UA
1541984512,1541984767,BG
1541984768,1541985279,RO
1541985280,1541986303,CZ
@@ -26538,7 +26902,6 @@
1541994496,1541995519,PL
1541995520,1541996031,RU
1541996032,1541996287,RO
-1541996288,1541996543,RU
1541996544,1541997567,RO
1541997568,1541997823,RU
1541997824,1541998079,GB
@@ -27693,7 +28056,7 @@
1546088448,1546092543,GB
1546092544,1546096639,RU
1546096640,1546100735,IT
-1546100736,1546104831,AT
+1546100736,1546104831,DE
1546104832,1546108927,IE
1546108928,1546113023,IM
1546113024,1546121215,RU
@@ -27853,7 +28216,9 @@
1547565312,1547565823,US
1547565824,1547567103,NL
1547567104,1547571199,GB
-1547571200,1547575295,AT
+1547571200,1547572991,AT
+1547572992,1547573247,HU
+1547573248,1547575295,AT
1547575296,1547579391,NO
1547579392,1547583487,RU
1547583488,1547587583,KG
@@ -27915,7 +28280,9 @@
1547685888,1547689983,AT
1547689984,1547694079,IT
1547694080,1547698175,HU
-1547698176,1548130303,NL
+1547698176,1547925783,NL
+1547925784,1547925791,DE
+1547925792,1548130303,NL
1548130304,1548130559,BE
1548130560,1548158599,NL
1548158600,1548158607,GB
@@ -28068,7 +28435,9 @@
1554054656,1556086783,FR
1556086784,1557921791,DE
1557921792,1558052863,NO
-1558052864,1558118399,FR
+1558052864,1558054399,FR
+1558054400,1558054655,DE
+1558054656,1558118399,FR
1558118400,1558119423,DE
1558119424,1558122495,RU
1558122496,1558151167,AT
@@ -28147,7 +28516,10 @@
1560051712,1560084479,RU
1560084480,1560117247,JO
1560117248,1560133631,CZ
-1560133632,1560137727,RU
+1560133632,1560135679,RU
+1560135680,1560135807,UA
+1560135808,1560135935,CZ
+1560135936,1560137727,RU
1560137728,1560150015,CZ
1560150016,1560182783,NL
1560182784,1560215551,SE
@@ -28156,7 +28528,17 @@
1562378240,1564999679,IT
1564999680,1565523967,UA
1565523968,1565655039,RU
-1565655040,1565786111,AT
+1565655040,1565673215,AT
+1565673216,1565673471,DE
+1565673472,1565675263,AT
+1565675264,1565675391,DE
+1565675392,1565713295,AT
+1565713296,1565713299,CH
+1565713300,1565718919,AT
+1565718920,1565718927,DE
+1565718928,1565723135,AT
+1565723136,1565723391,HU
+1565723392,1565786111,AT
1565786112,1565917183,BY
1565917184,1566048255,RS
1566048256,1566056447,RU
@@ -28375,7 +28757,9 @@
1567713280,1567714303,MD
1567714304,1567715327,RO
1567715328,1567717375,MD
-1567717376,1567742975,RO
+1567717376,1567727359,RO
+1567727360,1567727615,GB
+1567727616,1567742975,RO
1567742976,1567743487,MD
1567743488,1567749119,RO
1567749120,1567750143,MD
@@ -28403,9 +28787,12 @@
1567984640,1567987711,MD
1567987712,1567988735,RO
1567988736,1567992831,MD
-1567992832,1567997951,RO
+1567992832,1567993343,RO
+1567993344,1567993599,GB
+1567993600,1567997951,RO
1567997952,1568014335,NL
-1568014336,1568026623,RO
+1568014336,1568022527,DE
+1568022528,1568026623,RO
1568026624,1568030719,MD
1568030720,1568059391,RO
1568059392,1568063487,MD
@@ -28593,7 +28980,8 @@
1571436288,1571436543,UA
1571436544,1571438591,RU
1571438592,1571440639,UA
-1571440640,1571441407,CZ
+1571440640,1571440895,RU
+1571440896,1571441407,CZ
1571441408,1571441663,UA
1571441664,1571441919,RU
1571441920,1571442175,CZ
@@ -28613,8 +29001,8 @@
1571448832,1571449343,NL
1571449344,1571449855,CZ
1571449856,1571450879,RU
-1571450880,1571451903,UA
-1571451904,1571453951,CZ
+1571450880,1571452927,UA
+1571452928,1571453951,CZ
1571453952,1571455999,RU
1571456000,1571456511,UA
1571456512,1571456767,CZ
@@ -28630,8 +29018,8 @@
1571471104,1571471359,CZ
1571471360,1571475455,RU
1571475456,1571476479,CZ
-1571476480,1571477503,RU
-1571477504,1571487743,CZ
+1571476480,1571478527,RU
+1571478528,1571487743,CZ
1571487744,1571495935,SK
1571495936,1571504127,CZ
1571504128,1571508223,UA
@@ -28647,8 +29035,7 @@
1571529728,1571530239,RU
1571530240,1571531263,CZ
1571531264,1571531775,UA
-1571531776,1571532799,RU
-1571532800,1571534079,CZ
+1571531776,1571534079,CZ
1571534080,1571534847,RU
1571534848,1571535103,LV
1571535104,1571535617,CZ
@@ -28658,7 +29045,9 @@
1571538944,1571540991,CZ
1571540992,1571541247,RU
1571541248,1571541503,UA
-1571541504,1571543039,CZ
+1571541504,1571542527,CZ
+1571542528,1571542783,SK
+1571542784,1571543039,CZ
1571543040,1571543551,NL
1571543552,1571543807,UA
1571543808,1571544063,CZ
@@ -29011,7 +29400,9 @@
1578500096,1578565631,FI
1578565632,1578582015,FR
1578582016,1578584063,IT
-1578584064,1578585087,FR
+1578584064,1578584355,FR
+1578584356,1578584356,IT
+1578584357,1578585087,FR
1578585088,1578586111,PT
1578586112,1578588159,ES
1578588160,1578590207,PL
@@ -29030,11 +29421,15 @@
1578592184,1578592191,PT
1578592192,1578592199,BE
1578592200,1578592207,CH
-1578592208,1578593023,FR
+1578592208,1578592295,FR
+1578592296,1578592303,NL
+1578592304,1578593023,FR
1578593024,1578593279,DE
1578593280,1578593439,FR
1578593440,1578593443,ES
-1578593444,1578593955,FR
+1578593444,1578593551,FR
+1578593552,1578593559,NL
+1578593560,1578593955,FR
1578593956,1578593959,ES
1578593960,1578595367,FR
1578595368,1578595371,IT
@@ -29090,7 +29485,19 @@
1580466176,1580597247,RO
1580597248,1580728319,TR
1580728320,1580990463,AE
-1580990464,1581252607,RO
+1580990464,1580999679,PT
+1580999680,1580999935,RO
+1580999936,1581001215,PT
+1581001216,1581001471,RO
+1581001472,1581118463,PT
+1581118464,1581118719,RO
+1581118720,1581126655,PT
+1581126656,1581127167,RO
+1581127168,1581132031,PT
+1581132032,1581132287,RO
+1581132288,1581208575,PT
+1581208576,1581208831,RO
+1581208832,1581252607,PT
1581252608,1581776895,GR
1581776896,1581793279,RU
1581793280,1581809663,PL
@@ -29176,9 +29583,7 @@
1583767552,1583771647,AT
1583771648,1583775743,RU
1583775744,1583779839,IT
-1583779840,1583779847,GB
-1583779848,1583779855,IT
-1583779856,1583780263,GB
+1583779840,1583780263,GB
1583780264,1583780271,IT
1583780272,1583780335,GB
1583780336,1583780343,IT
@@ -29386,7 +29791,9 @@
1586151424,1586159615,TR
1586159616,1586167807,MT
1586167808,1586175999,DE
-1586176000,1586184191,BE
+1586176000,1586177151,BE
+1586177152,1586177279,DE
+1586177280,1586184191,BE
1586184192,1586192383,NO
1586192384,1586200575,RU
1586200576,1586208767,MD
@@ -29483,7 +29890,6 @@
1587449856,1587453951,UA
1587453952,1587470335,RU
1587470336,1587474431,PL
-1587474432,1587478527,UA
1587478528,1587511295,RU
1587511296,1587544063,IL
1587544064,1588068351,IT
@@ -29554,8 +29960,8 @@
1590073344,1590075391,NL
1590075392,1590077439,BE
1590077440,1590079487,GB
-1590079488,1590079743,GP
-1590079744,1590081535,FR
+1590079488,1590080511,GP
+1590080512,1590081535,MQ
1590081536,1590083583,GB
1590083584,1590085631,RU
1590085632,1590087679,FR
@@ -29595,7 +30001,9 @@
1590165504,1590689791,AE
1590689792,1591214079,NL
1591214080,1591738367,DE
-1591738368,1592000511,BE
+1591738368,1591977471,BE
+1591977472,1591977599,NL
+1591977600,1592000511,BE
1592000512,1592004607,ES
1592004608,1592008703,AM
1592008704,1592012799,GB
@@ -29795,7 +30203,9 @@
1596890624,1596891135,CZ
1596891136,1596900351,RU
1596900352,1596907519,BY
-1596907520,1596915711,RU
+1596907520,1596909567,RU
+1596909568,1596911615,KZ
+1596911616,1596915711,RU
1596915712,1596925951,CZ
1596925952,1596932095,RU
1596932096,1596940543,CZ
@@ -29812,7 +30222,8 @@
1596948480,1596950527,BY
1596950528,1596950783,UA
1596950784,1596951551,CZ
-1596951552,1596952063,NL
+1596951552,1596951807,RU
+1596951808,1596952063,NL
1596952064,1596952575,UA
1596952576,1596952831,RU
1596952832,1596953599,CZ
@@ -29880,7 +30291,9 @@
1599127552,1599143935,CZ
1599143936,1599160319,UA
1599160320,1599176703,IR
-1599176704,1599193087,FR
+1599176704,1599188991,FR
+1599188992,1599189503,DE
+1599189504,1599193087,FR
1599193088,1599209471,RU
1599209472,1599242239,IR
1599242240,1599258623,CZ
@@ -30056,7 +30469,8 @@
1602781184,1602813951,FR
1602813952,1602846719,RU
1602846720,1602879487,GE
-1602879488,1602879743,RE
+1602879488,1602879488,MQ
+1602879489,1602879743,RE
1602879744,1602882303,MQ
1602882304,1602882559,RE
1602882560,1602885631,MQ
@@ -30168,7 +30582,11 @@
1603252224,1603256319,RU
1603256320,1603260415,SE
1603260416,1603264511,RU
-1603264512,1603268607,AT
+1603264512,1603266559,AT
+1603266560,1603266815,HU
+1603266816,1603267711,AT
+1603267712,1603267839,SK
+1603267840,1603268607,AT
1603268608,1603272703,PL
1603272704,1603796991,GB
1603796992,1603813375,RU
@@ -30272,7 +30690,9 @@
1605112648,1605112655,IT
1605112656,1605112847,GB
1605112848,1605112855,IT
-1605112856,1605113087,GB
+1605112856,1605112983,GB
+1605112984,1605112991,IT
+1605112992,1605113087,GB
1605113088,1605113095,IT
1605113096,1605113383,GB
1605113384,1605113391,IT
@@ -30290,9 +30710,7 @@
1605114328,1605114335,IT
1605114336,1605114871,GB
1605114872,1605114879,IT
-1605114880,1605114959,GB
-1605114960,1605114967,IT
-1605114968,1605115007,GB
+1605114880,1605115007,GB
1605115008,1605115015,IT
1605115016,1605115599,GB
1605115600,1605115607,IT
@@ -30408,9 +30826,13 @@
1607622656,1607624703,ES
1607624704,1607625727,IT
1607625728,1607625983,ES
-1607625984,1607626239,IT
+1607625984,1607626121,IT
+1607626122,1607626122,ES
+1607626123,1607626239,IT
1607626240,1607626751,ES
-1607626752,1607647231,IT
+1607626752,1607640805,IT
+1607640806,1607640806,CH
+1607640807,1607647231,IT
1607647232,1607651327,DE
1607651328,1607655423,FR
1607655424,1607660287,IT
@@ -30669,7 +31091,8 @@
1701003264,1701011455,MY
1701011456,1701019647,CN
1701019648,1701052415,GU
-1701052416,1701117951,NZ
+1701052416,1701101567,NZ
+1701101568,1701117951,SG
1701117952,1701134335,NC
1701134336,1701142527,CN
1701142528,1701143551,HK
@@ -30704,7 +31127,9 @@
1703411712,1703673855,TW
1703673856,1703935999,JP
1703936000,1704984575,CN
-1704984576,1707081727,AU
+1704984576,1705498623,AU
+1705498624,1705500671,GB
+1705500672,1707081727,AU
1707081728,1707737087,CN
1707737088,1707802623,KR
1707802624,1707835391,JP
@@ -30952,7 +31377,6 @@
1728420864,1728421887,NZ
1728421888,1728422911,JP
1728422912,1728423935,AU
-1728423936,1728424959,TW
1728424960,1728425983,AF
1728425984,1728427007,JP
1728427008,1728428031,MY
@@ -30991,7 +31415,7 @@
1728458752,1728459775,HK
1728459776,1728460799,ID
1728460800,1728462847,JP
-1728462848,1728463871,NZ
+1728462848,1728463871,US
1728463872,1728464895,JP
1728464896,1728465919,KR
1728465920,1728466943,CN
@@ -31204,7 +31628,6 @@
1728668672,1728669695,SG
1728669696,1728670207,BD
1728670208,1728670463,NZ
-1728670720,1728671743,JP
1728671744,1728672767,BD
1728672768,1728673791,TW
1728673792,1728674815,JP
@@ -31504,7 +31927,8 @@
1728951808,1728952063,SG
1728952064,1728952319,IN
1728952832,1728953343,AU
-1728953344,1728954367,HK
+1728953344,1728954112,GB
+1728954113,1728954367,HK
1728954368,1728955391,JP
1728955392,1728956415,CN
1728956416,1728957439,ID
@@ -31532,12 +31956,14 @@
1728977920,1728978943,MY
1728978944,1728979967,JP
1728979968,1728980991,MN
-1728980992,1728982015,NZ
+1728980992,1728982015,AU
1728982016,1728982527,ID
1728982528,1728982783,IN
1728982784,1728985087,AU
-1728985088,1728987135,PH
-1728987136,1728988159,AU
+1728985088,1728986111,SG
+1728986112,1728987135,PH
+1728987136,1728987391,JP
+1728987392,1728988159,AU
1728988160,1728988191,NZ
1728988192,1728988199,US
1728988200,1728989183,NZ
@@ -31645,7 +32071,7 @@
1729078272,1729079295,BD
1729079296,1729080319,AU
1729080320,1729081343,ID
-1729081344,1729081599,NP
+1729081344,1729081599,IN
1729081600,1729082111,AU
1729082112,1729082367,IN
1729082368,1729083391,HK
@@ -31773,6 +32199,7 @@
1729189888,1729190911,VN
1729190912,1729191935,HK
1729191936,1729195007,IN
+1729195008,1729195519,MN
1729195520,1729196031,BD
1729196032,1729197055,GU
1729197056,1729198079,HK
@@ -32155,7 +32582,9 @@
1729605632,1729606655,CN
1729606656,1729607679,ID
1729607680,1729609727,AU
-1729609728,1729610751,HK
+1729609728,1729609999,HK
+1729610000,1729610003,JP
+1729610004,1729610751,HK
1729610752,1729611775,JP
1729611776,1729612799,ID
1729613824,1729614847,SG
@@ -32266,7 +32695,7 @@
1729720320,1729721087,AU
1729721088,1729721343,IN
1729721344,1729722367,NZ
-1729722368,1729726463,IN
+1729723392,1729726463,IN
1729726464,1729727487,PK
1729727488,1729728511,KI
1729728512,1729729535,JP
@@ -32418,9 +32847,12 @@
1729876992,1729878015,JP
1729878016,1729879039,NZ
1729879040,1729879167,AU
-1729879168,1729879679,JP
+1729879168,1729879295,JP
+1729879296,1729879423,KR
+1729879424,1729879679,JP
1729879680,1729879807,AU
-1729879808,1729880063,JP
+1729879808,1729879935,JP
+1729879936,1729880063,KR
1729880064,1729880831,AU
1729880832,1729881087,NZ
1729881088,1729881215,PH
@@ -32619,7 +33051,9 @@
1730074368,1730074623,SG
1730074624,1730075647,CN
1730075648,1730076671,ID
-1730076672,1730080767,CN
+1730077696,1730078719,CN
+1730078720,1730079743,HK
+1730079744,1730080767,CN
1730080768,1730081791,HK
1730081792,1730082815,ID
1730082816,1730083839,PW
@@ -32691,8 +33125,8 @@
1742737408,1742738431,SG
1742738432,1742738687,HK
1742738688,1742738943,AU
-1742738944,1742739455,HK
-1742739456,1742740479,IN
+1742738944,1742739199,HK
+1742739200,1742740479,IN
1742740480,1742741503,KH
1742741504,1742743551,IN
1742743552,1742745599,CN
@@ -32819,8 +33253,8 @@
1742869504,1742870015,IN
1742870016,1742870527,VU
1742870528,1742872575,IN
-1742872576,1742873599,NZ
-1742873600,1742874623,PH
+1742872576,1742873855,NZ
+1742873856,1742874623,PH
1742874624,1742875647,CN
1742875648,1742876671,JP
1742876672,1742877695,ID
@@ -33053,7 +33487,10 @@
1743108864,1743109119,AU
1743109120,1743110143,HK
1743110144,1743111167,VN
-1743111168,1743112191,HK
+1743111168,1743111423,SG
+1743111424,1743111679,MY
+1743111680,1743111935,ID
+1743111936,1743112191,HK
1743112192,1743113215,ID
1743113216,1743114239,SG
1743114240,1743115263,IN
@@ -33160,7 +33597,8 @@
1743225856,1743226367,IN
1743226368,1743226623,PH
1743226624,1743226879,BD
-1743226880,1743227903,AF
+1743226880,1743227647,AF
+1743227648,1743227903,IR
1743227904,1743228927,HK
1743228928,1743229951,CN
1743229952,1743230975,VN
@@ -33174,7 +33612,7 @@
1743236096,1743237119,US
1743237120,1743238143,BD
1743238144,1743240191,CN
-1743240192,1743241215,VN
+1743240192,1743241215,SG
1743241216,1743242239,JP
1743242240,1743244287,ID
1743244288,1743245311,AU
@@ -33371,7 +33809,7 @@
1743438592,1743438847,ID
1743438848,1743439871,JP
1743439872,1743440895,BD
-1743440896,1743443967,TW
+1743440896,1743441919,TW
1743443968,1743444991,ID
1743444992,1743446015,HK
1743446016,1743448063,TW
@@ -33382,6 +33820,168 @@
1743453184,1743454207,ID
1743454208,1743455231,IN
1743455232,1743456255,HK
+1743456256,1743457279,IN
+1743457280,1743458303,JP
+1743458304,1743459327,CN
+1743459328,1743459583,AU
+1743459584,1743459839,ID
+1743459840,1743460095,AU
+1743460096,1743460351,IN
+1743460352,1743461375,KR
+1743461376,1743462399,MY
+1743462400,1743463423,ID
+1743463424,1743464447,AU
+1743464448,1743465471,JP
+1743465472,1743466495,HK
+1743466496,1743467519,CN
+1743467520,1743468543,AU
+1743468544,1743470591,CN
+1743470592,1743470847,IN
+1743470848,1743471103,AU
+1743471104,1743471615,ID
+1743471616,1743472639,IN
+1743472640,1743473663,KH
+1743473664,1743474687,JP
+1743474688,1743476735,CN
+1743476736,1743477759,TW
+1743477760,1743479807,AU
+1743479808,1743480831,HK
+1743480832,1743481855,IN
+1743481856,1743482111,AU
+1743482112,1743482367,ID
+1743482368,1743482879,WF
+1743482880,1743483903,JP
+1743483904,1743484927,AU
+1743484928,1743485951,IN
+1743485952,1743486975,JP
+1743486976,1743493119,CN
+1743493120,1743493631,ID
+1743493632,1743493887,AU
+1743493888,1743495167,IN
+1743495168,1743497215,JP
+1743497216,1743499263,HK
+1743499264,1743500287,AF
+1743500288,1743501311,JP
+1743501312,1743502335,CN
+1743502336,1743503359,AU
+1743503360,1743504383,CN
+1743504384,1743505407,NP
+1743505408,1743506431,CN
+1743506432,1743506943,SG
+1743506944,1743507455,IN
+1743507456,1743509503,VN
+1743509504,1743510527,HK
+1743510528,1743545343,CN
+1743585280,1743589375,CN
+1743589376,1743590399,AU
+1743590400,1743591423,KR
+1743591424,1743593471,CN
+1743593472,1743594495,ID
+1743594496,1743595519,BD
+1743595520,1743596543,NZ
+1743596544,1743598591,IN
+1743598592,1743599103,KH
+1743599104,1743599615,HK
+1743599616,1743600639,IN
+1743600640,1743602687,VN
+1743602688,1743603711,CN
+1743603712,1743605759,HK
+1743605760,1743606015,SG
+1743606016,1743606527,AU
+1743606528,1743606783,AF
+1743606784,1743607807,PK
+1743607808,1743608831,CN
+1743608832,1743609855,AU
+1743609856,1743610879,VN
+1743610880,1743611903,MO
+1743611904,1743613951,AU
+1743613952,1743615999,IN
+1743616000,1743617023,JP
+1743617024,1743618047,MO
+1743618048,1743619071,HK
+1743619072,1743619583,SG
+1743619584,1743619839,ID
+1743619840,1743620095,IN
+1743620096,1743621119,JP
+1743621120,1743621631,ID
+1743621632,1743622143,SG
+1743622144,1743624191,VN
+1743624192,1743625215,CN
+1743625216,1743626239,IN
+1743626240,1743627263,AU
+1743627264,1743628287,NZ
+1743628288,1743628799,SG
+1743628800,1743629055,IN
+1743629056,1743629311,AU
+1743629312,1743630335,IN
+1743630336,1743652863,CN
+1743652864,1743654911,IN
+1743654912,1743666175,CN
+1743666176,1743666431,NZ
+1743666432,1743666687,IN
+1743666688,1743666943,AU
+1743666944,1743667199,BD
+1743667200,1743668223,KH
+1743668224,1743672319,VN
+1743672320,1743673343,NZ
+1743673344,1743676415,CN
+1743676416,1743679487,IN
+1743679488,1743680511,JP
+1743680512,1743681535,TL
+1743681536,1743682559,AU
+1743682560,1743683583,MY
+1743683584,1743683839,JP
+1743683840,1743684607,HK
+1743684608,1743685631,CN
+1743685632,1743686655,ID
+1743686656,1743688703,CN
+1743688704,1743689727,MY
+1743689728,1743690751,IN
+1743690752,1743691263,AS
+1743691264,1743691775,IN
+1743691776,1743699967,CN
+1743699968,1743700479,IN
+1743700480,1743700735,NZ
+1743700736,1743700991,AU
+1743700992,1743702015,CN
+1743702016,1743703039,ID
+1743703040,1743704063,CN
+1743704064,1743706111,VN
+1743706112,1743708159,IN
+1743708160,1743709183,HK
+1743709184,1743711231,IN
+1743711232,1743712255,JP
+1743712256,1743713279,IN
+1743713280,1743714303,JP
+1743714304,1743715327,KR
+1743715328,1743717375,CN
+1743717376,1743718399,BD
+1743718400,1743719423,NZ
+1743719424,1743720447,HK
+1743720448,1743721471,JP
+1743721472,1743722495,SG
+1743722496,1743723519,AU
+1743723520,1743724543,HK
+1743724544,1743725567,VN
+1743725568,1743726591,IN
+1743726592,1743728639,CN
+1743728640,1743729151,AU
+1743729152,1743729407,IN
+1743729408,1743729663,AU
+1743729664,1743730687,KH
+1743730688,1743731711,IN
+1743731712,1743732735,TW
+1743732736,1743733759,HK
+1743733760,1743734783,CN
+1743734784,1743735807,HK
+1743735808,1743736319,AU
+1743736320,1743736575,IN
+1743736576,1743736831,AU
+1743736832,1743738879,IN
+1743738880,1743740927,JP
+1743740928,1743741951,CN
+1743741952,1743742975,HK
+1743742976,1743743487,NZ
1743781888,1743783935,JP
1743783936,1743784959,IN
1743784960,1743785983,JP
@@ -33407,7 +34007,7 @@
1743806464,1743809535,IN
1743809536,1743810559,ID
1743810560,1743811583,KH
-1743811584,1743813631,JP
+1743811584,1743812607,JP
1743813632,1743814655,CN
1743814656,1743815679,SG
1743815680,1743815935,AU
@@ -33631,8 +34231,8 @@
1744056576,1744056831,MY
1744056832,1744057087,NZ
1744057088,1744057343,ID
-1744057344,1744058367,HK
-1744058368,1744066559,CN
+1744057344,1744059391,HK
+1744059392,1744066559,CN
1744066560,1744067583,HK
1744067584,1744068607,JP
1744068608,1744069631,ID
@@ -33766,9 +34366,7 @@
1744202240,1744202495,IN
1744202496,1744202751,ID
1744202752,1744203775,PK
-1744203776,1744204287,MY
-1744204288,1744204415,HK
-1744204416,1744204799,MY
+1744203776,1744204799,HK
1744204800,1744205823,ID
1744205824,1744207871,CN
1744207872,1744208127,AU
@@ -33945,7 +34543,9 @@
1744378880,1744379903,KR
1744379904,1744380927,HK
1744380928,1744383999,IN
-1744384000,1744385023,AU
+1744384000,1744384039,AU
+1744384040,1744384047,GU
+1744384048,1744385023,AU
1744385024,1744386047,CN
1744386048,1744386303,BD
1744386304,1744386559,AU
@@ -33970,7 +34570,6 @@
1744408576,1744409599,CN
1744409600,1744410623,AU
1744410624,1744411647,PK
-1744411648,1744412671,JP
1744412672,1744413695,SG
1744413696,1744417791,CN
1744417792,1744418815,IN
@@ -34108,7 +34707,8 @@
1744555008,1744556031,CN
1744556032,1744562175,IN
1744562176,1744563199,BD
-1744563200,1744565247,CN
+1744563200,1744564223,HK
+1744564224,1744565247,CN
1744565248,1744566271,HK
1744566272,1744567295,IN
1744567296,1744568319,JP
@@ -34373,23 +34973,27 @@
1747219456,1747220479,CA
1747220480,1747227647,US
1747227648,1747228671,CA
-1747228672,1747229695,US
-1747230720,1747256575,US
+1747228672,1747256319,US
+1747256320,1747256575,IE
1747256576,1747256831,AU
-1747256832,1747259391,US
+1747256832,1747257087,AE
+1747257088,1747257343,IN
+1747257344,1747260415,US
1747260416,1747261439,CA
1747261440,1747270655,US
1747270656,1747272703,CA
1747272704,1747273727,US
1747273728,1747274751,CA
+1747274752,1747275775,US
1747275776,1747276799,CA
-1747276800,1747277823,US
-1747279872,1747283967,US
+1747276800,1747283967,US
1747283968,1747284991,CA
-1747284992,1747286015,US
-1747288064,1747304447,US
-1747306496,1747308543,CA
-1747308544,1753251839,US
+1747284992,1747293183,US
+1747294208,1747304447,US
+1747304448,1747308543,CA
+1747308544,1747316735,US
+1747316736,1747317759,CA
+1747317760,1753251839,US
1753251840,1753252095,MN
1753252096,1753252351,SY
1753252352,1753252607,BY
@@ -34411,11 +35015,124 @@
1753280512,1753284607,CA
1753284608,1753309183,US
1753309184,1753317375,CA
-1753333760,1753341951,US
+1753317376,1753341951,US
1753341952,1753346047,CA
-1753346048,1753481215,US
-1753743360,1754071039,US
+1753346048,1753483263,US
+1753483264,1753483519,IE
+1753483520,1753486335,US
+1753486336,1753486591,IN
+1753486592,1754136575,US
1754136576,1754169343,CA
+1754169344,1754206719,US
+1754206720,1754206975,GW
+1754206976,1754207231,RW
+1754207232,1754207487,GA
+1754207488,1754207743,KI
+1754207744,1754207999,MM
+1754208000,1754208255,VU
+1754208256,1754208511,NA
+1754208512,1754208767,DJ
+1754208768,1754209023,BF
+1754209024,1754209279,BW
+1754209280,1754209535,PW
+1754209536,1754209791,BR
+1754209792,1754210047,AR
+1754210048,1754210303,BJ
+1754210304,1754251519,US
+1754251520,1754251775,LY
+1754251776,1754252543,US
+1754252544,1754252799,MZ
+1754252800,1754253055,US
+1754253056,1754253311,GN
+1754253312,1754253567,US
+1754253568,1754253823,ML
+1754253824,1754254079,US
+1754254080,1754254335,SO
+1754254336,1754254591,CD
+1754254592,1754254847,US
+1754254848,1754255103,VE
+1754255104,1754255359,US
+1754255360,1754255615,EC
+1754255616,1754255871,US
+1754255872,1754256127,PY
+1754256128,1754256383,US
+1754256384,1754256639,BO
+1754256640,1754256895,US
+1754256896,1754257151,UY
+1754257152,1754257407,US
+1754257408,1754257663,TZ
+1754257664,1754257919,US
+1754257920,1754258175,TD
+1754258176,1754258431,US
+1754258432,1754258687,MG
+1754258688,1754258943,US
+1754258944,1754259199,TN
+1754259200,1754792959,US
+1754792960,1754793983,CA
+1754793984,1754799103,US
+1754799104,1754800127,CA
+1754800128,1754804223,US
+1754805248,1754822655,US
+1754822656,1754823679,CA
+1754823680,1754830847,US
+1754830848,1754831871,CA
+1754831872,1754832895,US
+1754832896,1754836991,CA
+1754836992,1754845183,US
+1754845184,1754846207,CA
+1754846208,1754849279,US
+1754849280,1754850303,CA
+1754850304,1754852351,US
+1754852352,1754853375,JM
+1754853376,1754863615,US
+1754863616,1754864639,CA
+1754864640,1754869759,US
+1754869760,1754870783,CA
+1754872832,1754890239,US
+1754890240,1754892287,BB
+1754923008,1755062271,US
+1755062272,1755066367,CA
+1755066368,1755070463,US
+1755070464,1755074559,CA
+1755074560,1755103487,US
+1755103488,1755103743,MH
+1755103744,1755103999,US
+1755104000,1755104255,ZM
+1755104256,1755104511,US
+1755104512,1755104767,HT
+1755104768,1755105023,US
+1755105024,1755105279,BB
+1755105280,1755106047,US
+1755106048,1755106303,SR
+1755106304,1755106559,US
+1755106560,1755106815,BZ
+1755106816,1755107071,US
+1755107072,1755107327,MW
+1755107328,1755107583,US
+1755107584,1755107839,DM
+1755107840,1755108095,US
+1755108096,1755108351,NE
+1755108352,1755108607,US
+1755108608,1755108863,AG
+1755108864,1755109119,US
+1755109120,1755109375,TL
+1755109376,1755109631,US
+1755109632,1755109887,HN
+1755109888,1755110143,US
+1755110144,1755110399,SB
+1755110400,1755110655,US
+1755110656,1755110911,JO
+1755110912,1755111167,US
+1755111168,1755111423,SD
+1755111424,1755119615,US
+1755119616,1755283455,CA
+1755283456,1755324415,US
+1755324416,1755328511,CA
+1755340800,1755348991,US
+1755357184,1755365375,US
+1755381760,1755512831,US
+1755512832,1755545599,CA
+1755578368,1755709439,US
1762656256,1763704831,MU
1763704832,1764753407,EG
1764753408,1765801983,KE
@@ -34443,7 +35160,7 @@
1777049600,1777053695,ZA
1777053696,1777057791,BF
1777057792,1777061887,NG
-1777061888,1777063935,SD
+1777061888,1777063935,SS
1777063936,1777065983,MZ
1777065984,1777070079,GQ
1777070080,1777074175,BW
@@ -34488,7 +35205,9 @@
1795559424,1795559679,AR
1795559680,1795560447,US
1795560448,1795560959,CA
-1795560960,1795561471,US
+1795560960,1795561247,US
+1795561248,1795561343,CA
+1795561344,1795561471,US
1795561472,1795562239,CA
1795562240,1795563263,US
1795563264,1795563519,CA
@@ -34554,9 +35273,20 @@
1807057664,1807057919,GB
1807057920,1807597567,US
1807597568,1807646719,CA
-1807646720,1807695871,US
+1807646720,1807655679,US
+1807655680,1807655935,IE
+1807655936,1807656191,LR
+1807656192,1807656447,CZ
+1807656448,1807656703,NL
+1807656704,1807657983,US
+1807657984,1807658239,SG
+1807658240,1807658495,GB
+1807658496,1807658751,BS
+1807658752,1807695871,US
1807695872,1807699967,VI
-1807699968,1807732735,US
+1807699968,1807707311,US
+1807707312,1807707312,JP
+1807707313,1807732735,US
1807732736,1807736831,GP
1807736832,1815822335,US
1815822336,1815826431,CA
@@ -35072,7 +35802,9 @@
1835922456,1835922463,IT
1835922464,1835922559,GB
1835922560,1835922567,IT
-1835922568,1835923351,GB
+1835922568,1835922647,GB
+1835922648,1835922655,IT
+1835922656,1835923351,GB
1835923352,1835923359,IT
1835923360,1835923487,GB
1835923488,1835923495,IT
@@ -35233,7 +35965,7 @@
1841590272,1841594367,PL
1841594368,1841598463,RU
1841598464,1841602559,PL
-1841602560,1841610751,UA
+1841606656,1841610751,UA
1841610752,1841618943,RU
1841618944,1841627135,PL
1841627136,1841629183,NO
@@ -35649,9 +36381,13 @@
1847730176,1847732223,PK
1847734272,1847735295,NZ
1847735296,1847736319,AU
-1847736320,1847738367,HK
+1847736320,1847738367,JP
1847738368,1847754751,KR
-1847754752,1847780351,TH
+1847754752,1847757823,TH
+1847757824,1847758847,CN
+1847758848,1847770111,TH
+1847770112,1847771135,SG
+1847771136,1847780351,TH
1847780352,1847780607,CN
1847780608,1847783423,TH
1847783424,1847787519,US
@@ -35702,7 +36438,8 @@
1850400768,1850408959,JP
1850408960,1850490879,CN
1850490880,1850507263,KR
-1850507264,1850510335,AU
+1850507776,1850508031,AU
+1850509312,1850510335,AU
1850510336,1850511359,KR
1850511360,1850513407,ID
1850513408,1850514431,TH
@@ -35746,8 +36483,7 @@
1855979520,1856241663,JP
1856241664,1856307199,TH
1856307200,1856315391,KR
-1856315392,1856319487,HK
-1856319488,1856323583,CN
+1856315392,1856323583,CN
1856323584,1856339967,KR
1856339968,1856372735,JP
1856372736,1856503807,CN
@@ -35848,7 +36584,8 @@
1868300288,1868333055,IN
1868333056,1868341247,PK
1868341248,1868345343,ID
-1868345344,1868346367,AU
+1868345344,1868346111,GU
+1868346112,1868346367,AU
1868346368,1868347391,TH
1868347392,1868348415,AU
1868348416,1868349439,KR
@@ -35907,7 +36644,6 @@
1876769792,1876770815,JP
1876770816,1876787199,SG
1876787200,1876885503,CN
-1876885504,1876893695,PH
1876893696,1876901887,TH
1876901888,1876918271,SG
1876918272,1876934655,LK
@@ -35940,7 +36676,8 @@
1883770880,1883783167,KR
1883783168,1883799551,VN
1883799552,1883832319,KR
-1883832320,1884028927,CN
+1883832320,1883833855,HK
+1883833856,1884028927,CN
1884028928,1884159999,KR
1884160000,1884164095,VN
1884164096,1884168191,TW
@@ -35971,8 +36708,8 @@
1886978048,1886986239,KR
1886986240,1886990335,TW
1886990336,1886994431,IN
-1886994432,1887008767,TW
-1887008768,1887010815,HK
+1886994432,1887005695,TW
+1887005696,1887010815,HK
1887010816,1887019007,TH
1887019008,1887027199,HK
1887027200,1887043583,KR
@@ -35983,7 +36720,9 @@
1887961088,1887993855,JP
1887993856,1888026623,KR
1888026624,1888030719,BD
-1888030720,1888034815,HK
+1888030720,1888030975,HK
+1888030976,1888031231,GB
+1888031232,1888034815,HK
1888034816,1888038911,JP
1888038912,1888040959,CN
1888040960,1888041471,JP
@@ -36062,7 +36801,8 @@
1897213952,1897218047,JP
1897218048,1897222143,IN
1897222144,1897226239,TW
-1897226240,1897234431,NC
+1897226240,1897231103,NC
+1897231104,1897234431,VU
1897234432,1897242623,MY
1897242624,1897250815,TW
1897250816,1897259007,HK
@@ -36170,7 +36910,9 @@
1909161984,1909194751,PK
1909194752,1909456895,CN
1909456896,1909473279,JP
-1909473280,1909481471,HK
+1909473280,1909474303,HK
+1909474304,1909475327,PH
+1909475328,1909481471,HK
1909481472,1909587967,CN
1909587968,1909719039,MY
1909719040,1909735423,CN
@@ -36211,7 +36953,7 @@
1914601472,1914634239,KR
1914634240,1914642431,BD
1914642432,1914650623,KR
-1914650624,1914652671,MN
+1914652160,1914652415,MN
1914652672,1914654719,AU
1914654720,1914658815,JP
1914658816,1914660863,AU
@@ -36219,7 +36961,8 @@
1914662912,1914667007,KR
1914667008,1914683391,IN
1914683392,1914687487,AU
-1914687488,1914689535,NZ
+1914687488,1914688511,US
+1914688512,1914689535,NZ
1914689536,1914691583,JP
1914691584,1914695679,IN
1914695680,1914697727,ID
@@ -36256,10 +36999,12 @@
1919909888,1919918079,AU
1919918080,1919926271,CN
1919926272,1919942655,KR
-1919942656,1920006847,CN
-1920006848,1920006911,HK
-1920006912,1920069631,CN
-1920069632,1920073727,HK
+1919942656,1919999999,CN
+1920000000,1920008191,HK
+1920008192,1920057343,CN
+1920057344,1920058111,HK
+1920058112,1920072703,CN
+1920072704,1920073727,HK
1920073728,1920466943,CN
1920466944,1920991231,ID
1920991232,1921056767,TH
@@ -36277,14 +37022,15 @@
1921253376,1921318911,CN
1921318912,1921384447,MY
1921384448,1921388543,NZ
-1921388544,1921392639,PG
1921392640,1921400831,JP
1921400832,1921404927,ID
1921404928,1921405823,HK
1921405824,1921405855,MM
1921405856,1921405919,HK
1921405920,1921405951,MM
-1921405952,1921406975,HK
+1921405952,1921406463,HK
+1921406464,1921406719,GB
+1921406720,1921406975,HK
1921406976,1921409023,BD
1921409024,1921425407,JP
1921425408,1921431551,NZ
@@ -36302,7 +37048,9 @@
1921861632,1921863679,SG
1921865728,1921867775,ID
1921867776,1921871871,AU
-1921871872,1921875967,US
+1921871872,1921872895,US
+1921872896,1921873663,NZ
+1921873664,1921875967,US
1921875968,1921892351,CN
1921892352,1921896447,AU
1921896448,1921898495,SG
@@ -36403,10 +37151,12 @@
1937516544,1937518591,IN
1937518592,1937522687,JP
1937522688,1937530879,ID
-1937530880,1937532927,US
-1937532928,1937535999,IN
+1937530880,1937534463,IN
+1937534464,1937534975,GB
+1937534976,1937535999,IN
1937536000,1937536511,GB
-1937536512,1937539071,IN
+1937536512,1937537023,US
+1937537024,1937539071,IN
1937539072,1937637375,JP
1937637376,1937670143,HK
1937670144,1937672191,NZ
@@ -36439,7 +37189,6 @@
1940258816,1940275199,AU
1940275200,1940283391,CN
1940283392,1940291583,ID
-1940291584,1940295679,HK
1940295680,1940324351,JP
1940324352,1940357119,PK
1940357120,1940389887,JP
@@ -36480,7 +37229,8 @@
1946163200,1946165247,CN
1946165248,1946173439,PK
1946173440,1946173695,PG
-1946173696,1946176511,SG
+1946173696,1946175487,SG
+1946175488,1946176511,SY
1946176512,1946176767,PH
1946176768,1946178047,SG
1946178048,1946178303,HK
@@ -36507,12 +37257,13 @@
1949440000,1949442047,ID
1949442048,1949446143,TW
1949446144,1949448191,JP
-1949448192,1949448703,HK
+1949448192,1949448447,AU
+1949448448,1949448703,HK
1949448704,1949448959,AU
1949448960,1949449215,IN
1949449216,1949449471,SG
1949449472,1949449727,JP
-1949449728,1949450239,HK
+1949449728,1949450239,AU
1949450240,1949466623,IN
1949466624,1949499391,PH
1949499392,1949564927,SG
@@ -36528,7 +37279,12 @@
1950089216,1950351359,CN
1950351360,1950482431,JP
1950482432,1950515199,CN
-1950515200,1950523391,IN
+1950515200,1950517247,IN
+1950517248,1950518271,US
+1950518272,1950519295,IN
+1950519296,1950520319,US
+1950520320,1950521343,PH
+1950521344,1950523391,IN
1950523392,1950527487,AU
1950527488,1950531583,JP
1950531584,1950533631,NP
@@ -36616,8 +37372,7 @@
1958850560,1958852607,CN
1958852608,1958853631,AU
1958853632,1958854655,ID
-1958854656,1958858751,AU
-1958858752,1958860799,NZ
+1958854656,1958860799,AU
1958860800,1958862847,BD
1958862848,1958871039,JP
1958871040,1959067647,CN
@@ -36667,7 +37422,17 @@
1960187904,1960189951,IN
1960189952,1960202239,CN
1960202240,1960206335,JP
-1960206336,1960214527,SG
+1960206336,1960210431,SG
+1960210432,1960210943,TH
+1960210944,1960211455,SG
+1960211456,1960211903,AU
+1960211904,1960212479,SG
+1960212480,1960212582,IN
+1960212583,1960212583,SG
+1960212584,1960212735,IN
+1960212736,1960214015,SG
+1960214016,1960214271,IN
+1960214272,1960214527,SG
1960214528,1960574975,CN
1960574976,1960837119,JP
1960837120,1961885695,CN
@@ -36683,6 +37448,7 @@
1962672128,1962803199,CN
1962803200,1962827775,JP
1962827776,1962829823,ID
+1962829824,1962831871,JP
1962831872,1962835967,ID
1962835968,1962868735,CN
1962868736,1962885119,AU
@@ -36694,7 +37460,9 @@
1964113920,1964118015,HK
1964118016,1964120063,ID
1964120064,1964122111,JP
-1964122112,1964126207,SG
+1964122112,1964122367,SG
+1964122368,1964122879,JP
+1964122880,1964126207,SG
1964126208,1964126463,HK
1964126464,1964130303,SG
1964130304,1964134399,HK
@@ -36763,7 +37531,7 @@
1966800896,1967783935,CN
1967783936,1967800319,JP
1967800320,1967808511,CN
-1967808512,1967812607,AT
+1967808512,1967812607,AU
1967812608,1967816703,ID
1967816704,1969225727,CN
1969225728,1969487871,IN
@@ -36886,7 +37654,7 @@
1986498560,1986502655,HK
1986510848,1986519039,KR
1986519040,1986523135,PK
-1986523136,1986525183,HK
+1986523136,1986525183,CN
1986525184,1986527231,BN
1986527232,1986723839,JP
1986723840,1986740223,AU
@@ -36925,7 +37693,9 @@
1991376896,1991442431,CN
1991442432,1991499775,BD
1991499776,1991507967,NC
-1991507968,1992097791,CN
+1991507968,1991835647,CN
+1991835648,1991901183,SG
+1991901184,1992097791,CN
1992097792,1992163327,SG
1992163328,1992818687,CN
1992818688,1992949759,SG
@@ -36945,7 +37715,7 @@
1995702272,1996627967,CN
1996627968,1996630015,PH
1996630016,1996634111,ID
-1996634112,1996636159,NP
+1996634112,1996636159,AU
1996636160,1996644351,ID
1996644352,1996652543,BT
1996652544,1997078527,CN
@@ -36992,9 +37762,13 @@
1997723648,1997725695,JP
1997725696,1998061567,CN
1998061568,1998258175,JP
-1998258176,1998271231,SG
+1998258176,1998266367,SG
+1998266368,1998268415,JP
+1998268416,1998271231,SG
1998271232,1998271487,AU
-1998271488,1998274559,SG
+1998271488,1998271815,SG
+1998271816,1998271823,JP
+1998271824,1998274559,SG
1998274560,1998454783,CN
1998454784,1998456831,AU
1998456832,1998458879,JP
@@ -37075,9 +37849,746 @@
2001559552,2001567743,KR
2001567744,2001600511,TW
2001600512,2001797119,CN
-2001797120,2001833007,SG
+2001797120,2001798047,SG
+2001798048,2001798079,US
+2001798080,2001798087,SG
+2001798088,2001798095,US
+2001798096,2001798787,SG
+2001798788,2001798791,AU
+2001798792,2001799687,SG
+2001799688,2001799695,US
+2001799696,2001799711,SG
+2001799712,2001799743,US
+2001799744,2001799807,SG
+2001799808,2001799935,US
+2001799936,2001799967,SG
+2001799968,2001799971,US
+2001799972,2001800391,SG
+2001800392,2001800399,US
+2001800400,2001800927,SG
+2001800928,2001800935,US
+2001800936,2001801023,SG
+2001801024,2001801039,US
+2001801040,2001801055,SG
+2001801056,2001801087,US
+2001801088,2001801135,SG
+2001801136,2001801151,US
+2001801152,2001801339,SG
+2001801340,2001801343,US
+2001801344,2001801615,SG
+2001801616,2001801623,NL
+2001801624,2001801663,SG
+2001801664,2001801703,US
+2001801704,2001801711,SG
+2001801712,2001801727,US
+2001801728,2001801775,SG
+2001801776,2001801807,US
+2001801808,2001801919,SG
+2001801920,2001801935,US
+2001801936,2001801983,SG
+2001801984,2001801999,US
+2001802000,2001802191,SG
+2001802192,2001802199,US
+2001802200,2001802879,SG
+2001802880,2001803007,US
+2001803008,2001803215,SG
+2001803216,2001803223,US
+2001803224,2001803647,SG
+2001803648,2001803679,US
+2001803680,2001803735,SG
+2001803736,2001803743,US
+2001803744,2001803839,SG
+2001803840,2001803871,US
+2001803872,2001803903,SG
+2001803904,2001803911,US
+2001803912,2001803919,SG
+2001803920,2001803935,US
+2001803936,2001804015,SG
+2001804016,2001804023,US
+2001804024,2001805943,SG
+2001805944,2001805951,US
+2001805952,2001809383,SG
+2001809384,2001809391,US
+2001809392,2001810495,SG
+2001810496,2001810527,MY
+2001810528,2001810559,SG
+2001810560,2001810623,MY
+2001810624,2001812127,SG
+2001812128,2001812159,SA
+2001812160,2001812255,SG
+2001812256,2001812263,US
+2001812264,2001812671,SG
+2001812672,2001812675,GB
+2001812676,2001813655,SG
+2001813656,2001813663,AU
+2001813664,2001813783,SG
+2001813784,2001813791,IN
+2001813792,2001814431,SG
+2001814432,2001814439,US
+2001814440,2001814575,SG
+2001814576,2001814583,US
+2001814584,2001815191,SG
+2001815192,2001815199,US
+2001815200,2001817079,SG
+2001817080,2001817087,US
+2001817088,2001818639,SG
+2001818640,2001818647,US
+2001818648,2001818847,SG
+2001818848,2001818851,AU
+2001818852,2001819495,SG
+2001819496,2001819503,US
+2001819504,2001819887,SG
+2001819888,2001819895,IE
+2001819896,2001819999,SG
+2001820000,2001820031,IE
+2001820032,2001820719,SG
+2001820720,2001820727,CA
+2001820728,2001820991,SG
+2001820992,2001820999,US
+2001821000,2001821191,SG
+2001821192,2001821199,US
+2001821200,2001821335,SG
+2001821336,2001821343,US
+2001821344,2001821367,SG
+2001821368,2001821375,US
+2001821376,2001821423,SG
+2001821424,2001821431,US
+2001821432,2001821439,SG
+2001821440,2001821447,US
+2001821448,2001821623,SG
+2001821624,2001821631,US
+2001821632,2001823007,SG
+2001823008,2001823015,US
+2001823016,2001823447,SG
+2001823448,2001823455,US
+2001823456,2001824175,SG
+2001824176,2001824183,US
+2001824184,2001824287,SG
+2001824288,2001824295,US
+2001824296,2001824479,SG
+2001824480,2001824487,US
+2001824488,2001824495,SG
+2001824496,2001824503,KR
+2001824504,2001825183,SG
+2001825184,2001825215,US
+2001825216,2001825647,SG
+2001825648,2001825655,US
+2001825656,2001829891,SG
+2001829892,2001829903,US
+2001829904,2001830091,SG
+2001830092,2001830095,US
+2001830096,2001830175,SG
+2001830176,2001830191,US
+2001830192,2001830207,SG
+2001830208,2001830223,US
+2001830224,2001830335,SG
+2001830336,2001830351,US
+2001830352,2001830479,SG
+2001830480,2001830495,US
+2001830496,2001830567,SG
+2001830568,2001830575,US
+2001830576,2001830673,SG
+2001830674,2001830674,HK
+2001830675,2001830719,SG
+2001830720,2001830783,US
+2001830784,2001830927,SG
+2001830928,2001830935,US
+2001830936,2001830943,NL
+2001830944,2001830975,SG
+2001830976,2001830983,US
+2001830984,2001831007,SG
+2001831008,2001831015,US
+2001831016,2001831027,SG
+2001831028,2001831031,US
+2001831032,2001831163,SG
+2001831164,2001831167,US
+2001831168,2001831287,SG
+2001831288,2001831295,US
+2001831296,2001831331,SG
+2001831332,2001831335,US
+2001831336,2001831683,SG
+2001831684,2001831687,US
+2001831688,2001831691,SG
+2001831692,2001831703,US
+2001831704,2001831915,SG
+2001831916,2001831919,US
+2001831920,2001831943,SG
+2001831944,2001831951,US
+2001831952,2001831963,SG
+2001831964,2001831967,US
+2001831968,2001831992,SG
+2001831993,2001831993,US
+2001831994,2001832135,SG
+2001832136,2001832139,US
+2001832140,2001832147,SG
+2001832148,2001832151,US
+2001832152,2001832315,SG
+2001832316,2001832319,US
+2001832320,2001832443,SG
+2001832444,2001832447,US
+2001832448,2001832615,SG
+2001832616,2001832623,AZ
+2001832624,2001832751,SG
+2001832752,2001832759,IE
+2001832760,2001832879,SG
+2001832880,2001832887,US
+2001832888,2001832903,SG
+2001832904,2001832911,US
+2001832912,2001832951,SG
+2001832952,2001832955,US
+2001832956,2001833007,SG
2001833008,2001833015,CN
-2001833016,2001862655,SG
+2001833016,2001833071,SG
+2001833072,2001833079,US
+2001833080,2001833099,SG
+2001833100,2001833103,US
+2001833104,2001833255,SG
+2001833256,2001833263,US
+2001833264,2001833419,SG
+2001833420,2001833421,US
+2001833422,2001833439,SG
+2001833440,2001833447,US
+2001833448,2001833487,SG
+2001833488,2001833495,US
+2001833496,2001833655,SG
+2001833656,2001833663,GB
+2001833664,2001833679,SG
+2001833680,2001833687,GB
+2001833688,2001833727,SG
+2001833728,2001833791,US
+2001833792,2001834096,SG
+2001834097,2001834097,US
+2001834098,2001834239,SG
+2001834240,2001834495,HK
+2001834496,2001834751,SG
+2001834752,2001834815,US
+2001834816,2001834935,SG
+2001834936,2001834943,JP
+2001834944,2001834947,US
+2001834948,2001835035,SG
+2001835036,2001835039,US
+2001835040,2001835103,SG
+2001835104,2001835135,US
+2001835136,2001835147,SG
+2001835148,2001835151,US
+2001835152,2001835231,SG
+2001835232,2001835239,US
+2001835240,2001835247,SG
+2001835248,2001835263,US
+2001835264,2001835515,SG
+2001835516,2001835519,US
+2001835520,2001835587,SG
+2001835588,2001835591,US
+2001835592,2001835711,SG
+2001835712,2001835719,US
+2001835720,2001835793,SG
+2001835794,2001835794,US
+2001835795,2001835795,SG
+2001835796,2001835799,US
+2001835800,2001835959,SG
+2001835960,2001835983,US
+2001835984,2001836107,SG
+2001836108,2001836111,US
+2001836112,2001836267,SG
+2001836268,2001836271,US
+2001836272,2001836291,SG
+2001836292,2001836295,US
+2001836296,2001836419,SG
+2001836420,2001836423,US
+2001836424,2001836427,SG
+2001836428,2001836431,US
+2001836432,2001836435,SG
+2001836436,2001836439,US
+2001836440,2001836451,SG
+2001836452,2001836455,US
+2001836456,2001836471,SG
+2001836472,2001836487,US
+2001836488,2001836506,SG
+2001836507,2001836507,US
+2001836508,2001836543,SG
+2001836544,2001838079,US
+2001838080,2001838627,SG
+2001838628,2001838631,US
+2001838632,2001838633,SG
+2001838634,2001838634,HK
+2001838635,2001838755,SG
+2001838756,2001838759,US
+2001838760,2001838763,SG
+2001838764,2001838767,US
+2001838768,2001838847,SG
+2001838848,2001839103,HK
+2001839104,2001839111,SG
+2001839112,2001839115,US
+2001839116,2001839535,SG
+2001839536,2001839543,US
+2001839544,2001839595,SG
+2001839596,2001839599,SA
+2001839600,2001839739,SG
+2001839740,2001839743,US
+2001839744,2001839775,SG
+2001839776,2001839783,US
+2001839784,2001839803,SG
+2001839804,2001839807,US
+2001839808,2001840057,SG
+2001840058,2001840059,SA
+2001840060,2001840071,SG
+2001840072,2001840079,US
+2001840080,2001840175,SG
+2001840176,2001840183,US
+2001840184,2001840767,SG
+2001840768,2001840799,US
+2001840800,2001841159,SG
+2001841160,2001841167,US
+2001841168,2001841175,SG
+2001841176,2001841176,US
+2001841177,2001841177,SA
+2001841178,2001841179,SG
+2001841180,2001841247,US
+2001841248,2001841279,SA
+2001841280,2001841311,SG
+2001841312,2001841319,US
+2001841320,2001841343,SG
+2001841344,2001841407,US
+2001841408,2001841639,SG
+2001841640,2001841647,US
+2001841648,2001842047,SG
+2001842048,2001842111,US
+2001842112,2001842175,SG
+2001842176,2001842271,US
+2001842272,2001842319,SG
+2001842320,2001842327,US
+2001842328,2001842343,SG
+2001842344,2001842351,US
+2001842352,2001842687,SG
+2001842688,2001842751,US
+2001842752,2001842783,SG
+2001842784,2001842815,US
+2001842816,2001843249,SG
+2001843250,2001843251,US
+2001843252,2001843471,SG
+2001843472,2001843475,US
+2001843476,2001843839,SG
+2001843840,2001843967,US
+2001843968,2001844127,SG
+2001844128,2001845247,US
+2001845248,2001845335,SG
+2001845336,2001845343,US
+2001845344,2001845359,SG
+2001845360,2001845375,US
+2001845376,2001845391,SG
+2001845392,2001845503,US
+2001845504,2001845695,SG
+2001845696,2001845703,US
+2001845704,2001845799,SG
+2001845800,2001845807,US
+2001845808,2001846015,SG
+2001846016,2001846311,US
+2001846312,2001846335,SG
+2001846336,2001846359,US
+2001846360,2001846479,SG
+2001846480,2001846495,US
+2001846496,2001846503,SG
+2001846504,2001846511,US
+2001846512,2001846519,SG
+2001846520,2001846523,US
+2001846524,2001846531,SG
+2001846532,2001846543,US
+2001846544,2001846559,SG
+2001846560,2001846567,US
+2001846568,2001846571,SG
+2001846572,2001846607,US
+2001846608,2001846615,SG
+2001846616,2001846727,US
+2001846728,2001846735,SG
+2001846736,2001846755,US
+2001846756,2001846847,SG
+2001846848,2001846911,US
+2001846912,2001846927,SG
+2001846928,2001846943,US
+2001846944,2001846959,SG
+2001846960,2001846975,IN
+2001846976,2001847071,SG
+2001847072,2001847103,US
+2001847104,2001847167,SG
+2001847168,2001847416,US
+2001847417,2001847417,SG
+2001847418,2001847429,US
+2001847430,2001847439,SG
+2001847440,2001847455,US
+2001847456,2001847463,SG
+2001847464,2001847479,US
+2001847480,2001847487,SG
+2001847488,2001847491,US
+2001847492,2001847493,SG
+2001847494,2001847495,US
+2001847496,2001847519,SG
+2001847520,2001847535,US
+2001847536,2001847537,SG
+2001847538,2001847559,US
+2001847560,2001847567,SG
+2001847568,2001847575,US
+2001847576,2001847591,SG
+2001847592,2001847599,US
+2001847600,2001847623,SG
+2001847624,2001847647,US
+2001847648,2001847663,SG
+2001847664,2001847671,US
+2001847672,2001847679,SG
+2001847680,2001847703,US
+2001847704,2001847711,SG
+2001847712,2001847727,US
+2001847728,2001847743,SG
+2001847744,2001847747,US
+2001847748,2001847755,SG
+2001847756,2001847771,US
+2001847772,2001847783,SG
+2001847784,2001847791,US
+2001847792,2001847799,SG
+2001847800,2001847839,US
+2001847840,2001847855,SG
+2001847856,2001847871,US
+2001847872,2001847875,SG
+2001847876,2001847879,US
+2001847880,2001847895,SG
+2001847896,2001847903,US
+2001847904,2001847935,SG
+2001847936,2001847951,US
+2001847952,2001847955,SG
+2001847956,2001847959,US
+2001847960,2001847963,SG
+2001847964,2001847967,US
+2001847968,2001847975,SG
+2001847976,2001847979,US
+2001847980,2001847981,SG
+2001847982,2001847991,US
+2001847992,2001848007,SG
+2001848008,2001848015,US
+2001848016,2001848047,SG
+2001848048,2001848055,US
+2001848056,2001848071,SG
+2001848072,2001848079,IN
+2001848080,2001848103,SG
+2001848104,2001848111,US
+2001848112,2001848135,SG
+2001848136,2001848143,US
+2001848144,2001848151,SG
+2001848152,2001848167,US
+2001848168,2001848189,SG
+2001848190,2001848199,US
+2001848200,2001848207,SG
+2001848208,2001848231,US
+2001848232,2001848247,SG
+2001848248,2001848253,US
+2001848254,2001848254,SG
+2001848255,2001848255,MY
+2001848256,2001848279,SG
+2001848280,2001848287,US
+2001848288,2001848303,SG
+2001848304,2001848327,US
+2001848328,2001848335,SG
+2001848336,2001848367,US
+2001848368,2001848383,SG
+2001848384,2001848407,US
+2001848408,2001848415,SG
+2001848416,2001848447,US
+2001848448,2001848479,SG
+2001848480,2001848575,US
+2001848576,2001848623,SG
+2001848624,2001848679,US
+2001848680,2001848687,SG
+2001848688,2001848767,US
+2001848768,2001848863,SG
+2001848864,2001848879,US
+2001848880,2001848895,SG
+2001848896,2001848943,US
+2001848944,2001848951,SG
+2001848952,2001848975,US
+2001848976,2001848991,SG
+2001848992,2001849015,US
+2001849016,2001849023,SG
+2001849024,2001849167,US
+2001849168,2001849183,SG
+2001849184,2001849247,US
+2001849248,2001849255,SG
+2001849256,2001849271,US
+2001849272,2001849279,SG
+2001849280,2001850391,US
+2001850392,2001850399,SG
+2001850400,2001850415,US
+2001850416,2001850423,SG
+2001850424,2001850435,US
+2001850436,2001850439,SG
+2001850440,2001850515,US
+2001850516,2001850517,SG
+2001850518,2001850519,US
+2001850520,2001850543,SG
+2001850544,2001850551,US
+2001850552,2001850591,SG
+2001850592,2001850599,US
+2001850600,2001850607,SG
+2001850608,2001850624,US
+2001850625,2001850625,SG
+2001850626,2001850655,US
+2001850656,2001850663,SG
+2001850664,2001850667,US
+2001850668,2001850679,SG
+2001850680,2001850727,US
+2001850728,2001850735,SG
+2001850736,2001850791,US
+2001850792,2001850795,SG
+2001850796,2001850823,US
+2001850824,2001850847,SG
+2001850848,2001850863,US
+2001850864,2001850867,SG
+2001850868,2001850871,US
+2001850872,2001850911,SG
+2001850912,2001850935,US
+2001850936,2001851023,SG
+2001851024,2001851083,US
+2001851084,2001851087,SG
+2001851088,2001851095,US
+2001851096,2001851099,SG
+2001851100,2001851159,US
+2001851160,2001851167,SG
+2001851168,2001851175,US
+2001851176,2001851231,SG
+2001851232,2001851239,US
+2001851240,2001851247,SG
+2001851248,2001851255,US
+2001851256,2001851271,SG
+2001851272,2001851287,US
+2001851288,2001851295,SG
+2001851296,2001851303,US
+2001851304,2001851311,SG
+2001851312,2001851407,US
+2001851408,2001851423,SG
+2001851424,2001851479,US
+2001851480,2001851487,SG
+2001851488,2001851503,US
+2001851504,2001851527,SG
+2001851528,2001851535,US
+2001851536,2001851551,SG
+2001851552,2001851591,US
+2001851592,2001851599,SG
+2001851600,2001851631,US
+2001851632,2001851647,SG
+2001851648,2001851655,US
+2001851656,2001851663,SG
+2001851664,2001851711,US
+2001851712,2001851727,SG
+2001851728,2001851743,US
+2001851744,2001851759,SG
+2001851760,2001851767,US
+2001851768,2001851771,SG
+2001851772,2001851775,US
+2001851776,2001851783,SG
+2001851784,2001851807,US
+2001851808,2001851815,SG
+2001851816,2001851823,US
+2001851824,2001851831,MY
+2001851832,2001851883,US
+2001851884,2001851903,SG
+2001851904,2001851905,US
+2001851906,2001851927,SG
+2001851928,2001851935,US
+2001851936,2001851967,SG
+2001851968,2001851975,US
+2001851976,2001851991,SG
+2001851992,2001851999,US
+2001852000,2001852007,SG
+2001852008,2001852015,US
+2001852016,2001852031,SG
+2001852032,2001852055,US
+2001852056,2001852065,SG
+2001852066,2001852067,PH
+2001852068,2001852103,US
+2001852104,2001852111,SG
+2001852112,2001852127,US
+2001852128,2001852135,SG
+2001852136,2001852167,US
+2001852168,2001852175,SG
+2001852176,2001852183,US
+2001852184,2001852207,SG
+2001852208,2001852215,US
+2001852216,2001852257,SG
+2001852258,2001852259,US
+2001852260,2001852263,SG
+2001852264,2001852271,US
+2001852272,2001852279,SG
+2001852280,2001852351,US
+2001852352,2001852357,SG
+2001852358,2001852359,US
+2001852360,2001852367,SG
+2001852368,2001852399,US
+2001852400,2001852403,SG
+2001852404,2001853015,US
+2001853016,2001853039,SG
+2001853040,2001853055,US
+2001853056,2001853063,SG
+2001853064,2001853071,US
+2001853072,2001853079,SG
+2001853080,2001853083,US
+2001853084,2001853087,SG
+2001853088,2001853239,US
+2001853240,2001853255,SG
+2001853256,2001853257,US
+2001853258,2001853258,MY
+2001853259,2001853263,SG
+2001853264,2001853271,US
+2001853272,2001853295,SG
+2001853296,2001853303,US
+2001853304,2001853335,SG
+2001853336,2001853375,US
+2001853376,2001853379,SG
+2001853380,2001853381,US
+2001853382,2001853383,SG
+2001853384,2001853399,US
+2001853400,2001853423,SG
+2001853424,2001853439,US
+2001853440,2001853463,SG
+2001853464,2001853471,US
+2001853472,2001853479,SG
+2001853480,2001853487,SA
+2001853488,2001853503,SG
+2001853504,2001853543,US
+2001853544,2001853559,SG
+2001853560,2001853575,US
+2001853576,2001853639,SG
+2001853640,2001853663,US
+2001853664,2001853671,SG
+2001853672,2001853676,US
+2001853677,2001853679,SG
+2001853680,2001853687,US
+2001853688,2001853703,SG
+2001853704,2001853727,US
+2001853728,2001853743,SG
+2001853744,2001853759,US
+2001853760,2001853803,SG
+2001853804,2001853823,US
+2001853824,2001853831,SG
+2001853832,2001853855,US
+2001853856,2001853863,SG
+2001853864,2001853895,US
+2001853896,2001853907,SG
+2001853908,2001853911,US
+2001853912,2001853943,SG
+2001853944,2001853947,US
+2001853948,2001853951,SG
+2001853952,2001854463,US
+2001854464,2001854475,SG
+2001854476,2001854479,US
+2001854480,2001854531,SG
+2001854532,2001854535,US
+2001854536,2001854547,SG
+2001854548,2001854551,US
+2001854552,2001854611,SG
+2001854612,2001854615,US
+2001854616,2001854703,SG
+2001854704,2001854707,US
+2001854708,2001854759,SG
+2001854760,2001854763,US
+2001854764,2001854767,SG
+2001854768,2001854775,AR
+2001854776,2001854783,SG
+2001854784,2001854787,US
+2001854788,2001854802,SG
+2001854803,2001854803,US
+2001854804,2001854863,SG
+2001854864,2001854867,US
+2001854868,2001855075,SG
+2001855076,2001855079,US
+2001855080,2001855083,SG
+2001855084,2001855087,US
+2001855088,2001855159,SG
+2001855160,2001855167,US
+2001855168,2001855183,SG
+2001855184,2001855187,US
+2001855188,2001855195,SG
+2001855196,2001855199,US
+2001855200,2001855223,SG
+2001855224,2001855231,IN
+2001855232,2001855247,SG
+2001855248,2001855251,US
+2001855252,2001855415,SG
+2001855416,2001855417,US
+2001855418,2001855419,SG
+2001855420,2001855423,US
+2001855424,2001855455,SG
+2001855456,2001855459,US
+2001855460,2001855655,SG
+2001855656,2001855663,US
+2001855664,2001855831,SG
+2001855832,2001855839,US
+2001855840,2001856055,SG
+2001856056,2001856059,US
+2001856060,2001856295,SG
+2001856296,2001856303,US
+2001856304,2001856355,SG
+2001856356,2001856363,US
+2001856364,2001856599,SG
+2001856600,2001856603,US
+2001856604,2001856639,SG
+2001856640,2001856703,US
+2001856704,2001856815,SG
+2001856816,2001856823,US
+2001856824,2001856835,SG
+2001856836,2001856847,US
+2001856848,2001857283,SG
+2001857284,2001857287,US
+2001857288,2001857383,SG
+2001857384,2001857391,US
+2001857392,2001857399,SG
+2001857400,2001857407,US
+2001857408,2001857428,SG
+2001857429,2001857429,US
+2001857430,2001857430,NL
+2001857431,2001857975,SG
+2001857976,2001857983,US
+2001857984,2001858007,SG
+2001858008,2001858011,US
+2001858012,2001858111,SG
+2001858112,2001858143,US
+2001858144,2001859007,SG
+2001859008,2001859015,NL
+2001859016,2001859039,SG
+2001859040,2001859071,US
+2001859072,2001859791,SG
+2001859792,2001859799,US
+2001859800,2001859807,SG
+2001859808,2001859811,US
+2001859812,2001859899,SG
+2001859900,2001859903,US
+2001859904,2001860119,SG
+2001860120,2001860127,US
+2001860128,2001860227,SG
+2001860228,2001860231,US
+2001860232,2001860335,SG
+2001860336,2001860343,US
+2001860344,2001860439,SG
+2001860440,2001860443,US
+2001860444,2001860527,SG
+2001860528,2001860531,US
+2001860532,2001860603,SG
+2001860604,2001860607,US
+2001860608,2001860791,SG
+2001860792,2001860795,US
+2001860796,2001860855,SG
+2001860856,2001860863,US
+2001860864,2001860903,SG
+2001860904,2001860907,US
+2001860908,2001860959,SG
+2001860960,2001860963,US
+2001860964,2001861087,SG
+2001861088,2001861095,US
+2001861096,2001861207,SG
+2001861208,2001861215,US
+2001861216,2001861399,SG
+2001861400,2001861415,US
+2001861416,2001861439,SG
+2001861440,2001861447,AU
+2001861448,2001862015,SG
+2001862016,2001862047,US
+2001862048,2001862655,SG
2001862656,2001864703,AU
2001864704,2001870847,JP
2001870848,2001879039,KR
@@ -37177,7 +38688,9 @@
2015207424,2015215615,JP
2015215616,2015216383,IN
2015216384,2015216639,AU
-2015216640,2015219711,IN
+2015216640,2015217663,IN
+2015217664,2015219456,GU
+2015219457,2015219711,IN
2015219712,2015219967,US
2015219968,2015220223,HK
2015220224,2015220479,IN
@@ -37242,7 +38755,6 @@
2022227968,2022244351,JP
2022244352,2022277119,CN
2022277120,2022309887,JP
-2022309888,2022313983,PH
2022313984,2022318079,NZ
2022318080,2022319135,AU
2022319136,2022319151,SG
@@ -37395,18 +38907,15 @@
2046836736,2046885887,CN
2046885888,2046951423,JP
2046951424,2047082495,PH
-2047082496,2047442943,CN
-2047442944,2047492095,HK
+2047082496,2047410175,CN
+2047410176,2047492095,HK
2047492096,2047496191,KR
-2047496192,2047508479,HK
-2047508480,2047526911,CN
-2047526912,2047531007,HK
-2047531008,2047574015,CN
+2047496192,2047506431,HK
+2047506432,2047508479,US
+2047508480,2047574015,CN
2047574016,2047606783,SG
-2047606784,2047770623,CN
-2047770624,2047787007,HK
-2047787008,2047868415,CN
-2047868416,2047868927,SG
+2047606784,2047803391,CN
+2047803392,2047868927,SG
2047868928,2048917503,JP
2048917504,2049966079,KR
2049966080,2050047999,CN
@@ -37417,8 +38926,7 @@
2050084864,2050088959,PH
2050088960,2050091007,ID
2050091008,2050097151,JP
-2050097152,2050099199,SG
-2050099200,2050101247,IN
+2050097152,2050101247,SG
2050101248,2050113535,JP
2050113536,2050129663,SG
2050129664,2050129919,JP
@@ -37455,8 +38963,10 @@
2053534720,2053537791,IN
2053537792,2053636095,JP
2053636096,2054160383,AU
-2054160384,2054373375,CN
-2054373376,2054377471,HK
+2054160384,2054189567,CN
+2054189568,2054190591,HK
+2054190592,2054376447,CN
+2054376448,2054377471,HK
2054377472,2054422527,CN
2054422528,2054619135,TW
2054619136,2054684671,CN
@@ -37499,7 +39009,9 @@
2056806400,2056814591,KR
2056814592,2056816863,JP
2056816864,2056816895,MY
-2056816896,2056817663,JP
+2056816896,2056817335,JP
+2056817336,2056817343,HK
+2056817344,2056817663,JP
2056817664,2056817919,AU
2056817920,2056818431,JP
2056818432,2056818687,SG
@@ -37561,21 +39073,24 @@
2063085568,2063089663,CN
2063089664,2063097855,JP
2063097856,2063106047,MM
-2063106048,2063106559,JP
+2063106048,2063106559,SG
2063106560,2063106815,AU
-2063106816,2063107623,JP
+2063106816,2063107071,SG
+2063107072,2063107327,JP
+2063107328,2063107623,SG
2063107624,2063107631,AU
-2063107632,2063111167,JP
-2063111168,2063112191,AU
-2063112192,2063113727,JP
-2063113728,2063113983,AU
-2063113984,2063114495,JP
-2063114496,2063114751,IN
-2063114752,2063115007,JP
-2063115008,2063115263,IN
+2063107632,2063108095,SG
+2063108096,2063110143,HK
+2063110144,2063111167,JP
+2063111168,2063114239,AU
+2063114240,2063115263,IN
2063115264,2063117311,JP
2063117312,2063117567,NZ
-2063117568,2063118335,JP
+2063117568,2063117823,JP
+2063117824,2063117839,PH
+2063117840,2063117951,JP
+2063117952,2063118079,PH
+2063118080,2063118335,JP
2063118336,2063118591,IN
2063118592,2063119871,JP
2063119872,2063120383,IN
@@ -37585,8 +39100,7 @@
2063122432,2063138815,SG
2063138816,2063335423,JP
2063335424,2063341567,AU
-2063341568,2063343615,SG
-2063343616,2063351807,JP
+2063341568,2063351807,SG
2063351808,2063368191,KR
2063368192,2063372287,JP
2063372288,2063374335,AU
@@ -37648,7 +39162,8 @@
2070183936,2070192127,AU
2070192128,2070200319,KR
2070200320,2070208511,JP
-2070208512,2070209535,SG
+2070208512,2070209279,MY
+2070209280,2070209535,SG
2070209536,2070210559,AU
2070210560,2070210815,SG
2070210816,2070211071,AU
@@ -37767,8 +39282,7 @@
2080768000,2080776191,TW
2080776192,2080777215,HK
2080777216,2080778239,GB
-2080778240,2080779263,US
-2080779264,2080780287,SG
+2080778240,2080780287,US
2080780288,2080781311,ID
2080781312,2080784383,SG
2080784384,2080800767,CN
@@ -37814,6 +39328,7 @@
2084569088,2084732927,CN
2084732928,2084741119,SG
2084741120,2084743167,ID
+2084743168,2084745215,JP
2084745216,2084749311,KR
2084749312,2084753407,JP
2084753408,2084757503,KR
@@ -37835,8 +39350,10 @@
2087460864,2087462911,JP
2087462912,2087464959,CN
2087464960,2087467007,KH
-2087467008,2087469055,JP
-2087469056,2087477247,HK
+2087467008,2087471103,JP
+2087471104,2087472127,SG
+2087472128,2087476223,HK
+2087476224,2087477247,TW
2087477248,2087478271,AU
2087478272,2087485439,HK
2087485440,2087501823,TW
@@ -37885,7 +39402,6 @@
2090696704,2090729471,TH
2090729472,2090733567,VN
2090733568,2090736639,AU
-2090736640,2090737663,IN
2090737664,2090745855,PH
2090745856,2090762239,MN
2090762240,2090778623,ID
@@ -37943,7 +39459,8 @@
2096668672,2096676863,KH
2096676864,2096693247,HK
2096693248,2096889855,CN
-2096889856,2096955391,AU
+2096889856,2096902143,BE
+2096902144,2096955391,AU
2096955392,2097020927,IN
2097020928,2097037311,CN
2097037312,2097053695,AU
@@ -38035,7 +39552,10 @@
2113688576,2113693599,JP
2113693600,2113693615,HK
2113693616,2113716223,JP
-2113716224,2113732607,SG
+2113716224,2113724927,SG
+2113724928,2113725183,IN
+2113725184,2113728511,SG
+2113728512,2113732607,JP
2113732608,2113761279,AU
2113761280,2113765375,VN
2113765376,2113798143,HK
@@ -38097,7 +39617,8 @@
2151784448,2151792639,IR
2151792640,2151794687,CH
2151794688,2151796735,IT
-2151796736,2151798783,NL
+2151796736,2151797759,DE
+2151797760,2151798783,NL
2151798784,2151799807,DE
2151799808,2151800831,NL
2151800832,2151809023,PT
@@ -38162,7 +39683,9 @@
2155827200,2155831295,PL
2155831296,2155833343,RU
2155833344,2155833855,SE
-2155833856,2155834367,NL
+2155833856,2155834084,NL
+2155834085,2155834111,SE
+2155834112,2155834367,NL
2155834368,2155834464,SE
2155834465,2155834512,NL
2155834513,2155834532,SE
@@ -38219,8 +39742,7 @@
2160908288,2160910335,PL
2160910336,2160914431,NL
2160914432,2160918527,SA
-2160918528,2161180671,US
-2161246208,2161508351,US
+2160918528,2161508351,US
2161508352,2161573887,FI
2161573888,2162228223,US
2162228224,2162228479,CA
@@ -38546,26 +40068,21 @@
2193686528,2193688575,FR
2193688576,2193692671,CZ
2193692672,2193694719,FR
-2193694720,2193695743,US
-2193695744,2193698815,RU
-2193698816,2193700863,US
-2193700864,2193704959,RU
+2193694720,2193704959,RU
2193704960,2193707007,IT
2193707008,2193707407,GB
2193707408,2193707415,IT
2193707416,2193707559,GB
2193707560,2193707567,IT
-2193707568,2193707607,GB
-2193707608,2193707615,IT
-2193707616,2193707751,GB
+2193707568,2193707615,GB
+2193707616,2193707623,IT
+2193707624,2193707751,GB
2193707752,2193707759,IT
2193707760,2193707831,GB
2193707832,2193707839,IT
2193707840,2193708511,GB
2193708512,2193708519,IT
-2193708520,2193708663,GB
-2193708664,2193708671,IT
-2193708672,2193708735,GB
+2193708520,2193708735,GB
2193708736,2193708743,IT
2193708744,2193709087,GB
2193709088,2193709095,IT
@@ -38586,7 +40103,9 @@
2194604032,2194669567,US
2194669568,2194735103,IS
2194735104,2194800639,GB
-2194800640,2195193855,US
+2194800640,2194888509,US
+2194888510,2194888510,IE
+2194888511,2195193855,US
2195193856,2195324927,NZ
2195324928,2195455999,US
2195456000,2195521535,AU
@@ -38631,8 +40150,45 @@
2197794816,2197796863,SA
2197796864,2197798911,DE
2197798912,2197815295,IR
+2197815296,2197816319,BO
+2197816320,2197828607,BR
+2197828608,2197829631,AR
+2197829632,2197833727,BR
+2197833728,2197834751,CR
+2197834752,2197841919,BR
+2197841920,2197842943,AR
+2197842944,2197843967,CL
+2197843968,2197847039,BR
+2197847040,2197848063,MX
+2197848064,2197849087,AR
+2197849088,2197850111,BR
+2197850112,2197851135,CO
+2197851136,2197858303,BR
+2197858304,2197859327,CO
+2197859328,2197860351,CL
+2197860352,2197865471,BR
+2197865472,2197866495,AR
+2197867520,2197869567,BR
+2197869568,2197870591,UY
+2197870592,2197874687,BR
+2197874688,2197875711,AR
+2197875712,2197876735,MX
+2197876736,2197880831,BR
2197880832,2197946367,IT
2197946368,2202533887,US
+2202533888,2202534911,AR
+2202534912,2202540031,BR
+2202540032,2202541055,PY
+2202541056,2202542079,AR
+2202542080,2202550271,BR
+2202552320,2202553343,AR
+2202554368,2202559487,BR
+2202562560,2202563583,CW
+2202565632,2202566655,BR
+2202567680,2202568703,AR
+2202569728,2202570751,BR
+2202573824,2202574847,AR
+2202574848,2202578943,BR
2202599424,2204172287,US
2204172288,2204237823,SE
2204237824,2204303359,US
@@ -38959,194 +40515,315 @@
2258305024,2258370559,DE
2258370560,2258436095,US
2258436096,2258567167,FR
-2258567168,2258568191,US
+2258567168,2258568191,TW
2258568192,2258568447,HK
-2258568448,2258582783,US
+2258568448,2258571647,TW
+2258571648,2258571711,US
+2258571712,2258571719,TW
+2258571720,2258571735,US
+2258571736,2258571743,TW
+2258571744,2258571751,US
+2258571752,2258571763,TW
+2258571764,2258571767,US
+2258571768,2258579463,TW
+2258579464,2258579467,US
+2258579468,2258579967,TW
+2258579968,2258580031,US
+2258580032,2258582783,TW
2258582784,2258582791,GB
-2258582792,2258583551,US
-2258583552,2258591743,GB
-2258591744,2258591935,AU
+2258582792,2258583551,TW
+2258583552,2258583575,GB
+2258583576,2258583583,TW
+2258583584,2258583775,GB
+2258583776,2258583807,TW
+2258583808,2258583935,GB
+2258583936,2258583967,TW
+2258583968,2258584007,GB
+2258584008,2258584351,TW
+2258584352,2258584383,GB
+2258584384,2258584574,TW
+2258584575,2258584575,GB
+2258584576,2258591575,TW
+2258591576,2258591579,GB
+2258591580,2258591631,TW
+2258591632,2258591639,GB
+2258591640,2258591935,TW
2258591936,2258591967,HK
-2258591968,2258592271,AU
+2258591968,2258592271,TW
2258592272,2258592279,JP
-2258592280,2258592287,AU
+2258592280,2258592287,TW
2258592288,2258592291,JP
-2258592292,2258592439,AU
+2258592292,2258592439,TW
2258592440,2258592447,JP
-2258592448,2258592791,AU
+2258592448,2258592479,TW
+2258592480,2258592495,AU
+2258592496,2258592511,TW
+2258592512,2258592767,AU
+2258592768,2258592791,TW
2258592792,2258592803,HK
-2258592804,2258593279,AU
+2258592804,2258593279,TW
2258593280,2258593535,HK
-2258593536,2258594047,AU
+2258593536,2258594047,TW
2258594048,2258594111,HK
-2258594112,2258594303,AU
+2258594112,2258594303,TW
2258594304,2258594319,HK
-2258594320,2258594559,PG
+2258594320,2258594559,TW
2258594560,2258594815,HK
-2258594816,2258595103,AU
-2258595104,2258595167,TW
-2258595168,2258595231,AU
-2258595232,2258595263,TW
-2258595264,2258595295,AU
-2258595296,2258595327,TW
-2258595328,2258595383,AU
+2258594816,2258595167,TW
+2258595168,2258595199,AU
+2258595200,2258595383,TW
2258595384,2258595391,KR
-2258595392,2258595887,AU
+2258595392,2258595519,TW
+2258595520,2258595551,AU
+2258595552,2258595887,TW
2258595888,2258595895,NZ
-2258595896,2258595967,AU
-2258595968,2258595983,TW
-2258595984,2258596095,AU
+2258595896,2258595983,TW
+2258595984,2258595991,AU
+2258595992,2258596031,TW
+2258596032,2258596063,AU
+2258596064,2258596095,TW
2258596096,2258596103,HK
-2258596104,2258596159,AU
+2258596104,2258596159,TW
2258596160,2258596255,HK
-2258596256,2258596351,AU
+2258596256,2258596351,TW
2258596352,2258596863,HK
-2258596864,2258596887,AU
+2258596864,2258596887,TW
2258596888,2258596903,HK
-2258596904,2258596991,AU
+2258596904,2258596991,TW
2258596992,2258597023,HK
-2258597024,2258597071,AU
-2258597072,2258597079,TW
-2258597080,2258597115,AU
+2258597024,2258597115,TW
2258597116,2258597215,HK
-2258597216,2258597263,PG
+2258597216,2258597263,TW
2258597264,2258597293,HK
2258597294,2258597294,PG
2258597295,2258597303,HK
-2258597304,2258597311,PG
+2258597304,2258597311,TW
2258597312,2258597367,HK
-2258597368,2258597371,PG
+2258597368,2258597371,TW
2258597372,2258597535,HK
-2258597536,2258597567,AU
+2258597536,2258597567,TW
2258597568,2258597583,HK
-2258597584,2258597599,AU
+2258597584,2258597599,TW
2258597600,2258597631,HK
2258597632,2258597759,AU
2258597760,2258597887,HK
-2258597888,2258597903,AU
+2258597888,2258597895,AU
+2258597896,2258597903,TW
2258597904,2258597919,JP
2258597920,2258597927,AU
2258597928,2258597935,JP
-2258597936,2258598079,AU
-2258598080,2258598087,TW
-2258598088,2258598095,AU
-2258598096,2258598111,TW
+2258597936,2258597951,AU
+2258597952,2258597975,TW
+2258597976,2258597983,AU
+2258597984,2258597999,TW
+2258598000,2258598007,AU
+2258598008,2258598111,TW
2258598112,2258598143,JP
-2258598144,2258598495,AU
+2258598144,2258598351,TW
+2258598352,2258598367,AU
+2258598368,2258598399,TW
+2258598400,2258598439,AU
+2258598440,2258598447,TW
+2258598448,2258598479,AU
+2258598480,2258598495,TW
2258598496,2258598511,NZ
-2258598512,2258598519,AU
+2258598512,2258598519,TW
2258598520,2258598527,JP
-2258598528,2258598623,AU
-2258598624,2258598655,TW
-2258598656,2258599183,AU
+2258598528,2258598567,TW
+2258598568,2258598623,AU
+2258598624,2258598667,TW
+2258598668,2258598671,AU
+2258598672,2258598991,TW
+2258598992,2258598999,AU
+2258599000,2258599011,TW
+2258599012,2258599019,AU
+2258599020,2258599183,TW
2258599184,2258599187,JP
-2258599188,2258599675,AU
+2258599188,2258599499,TW
+2258599500,2258599503,AU
+2258599504,2258599587,TW
+2258599588,2258599591,AU
+2258599592,2258599675,TW
2258599676,2258599679,JP
-2258599680,2258600263,AU
+2258599680,2258599743,TW
+2258599744,2258599747,AU
+2258599748,2258600263,TW
2258600264,2258600267,HK
-2258600268,2258600515,AU
+2258600268,2258600515,TW
2258600516,2258600519,IN
-2258600520,2258600523,AU
+2258600520,2258600523,TW
2258600524,2258600527,IN
-2258600528,2258600959,AU
+2258600528,2258600735,TW
+2258600736,2258600739,AU
+2258600740,2258600807,TW
+2258600808,2258600811,AU
+2258600812,2258600959,TW
2258600960,2258601087,SG
-2258601088,2258601167,AU
+2258601088,2258601119,AU
+2258601120,2258601151,TW
+2258601152,2258601167,AU
2258601168,2258601175,NZ
-2258601176,2258601215,AU
+2258601176,2258601199,AU
+2258601200,2258601207,TW
+2258601208,2258601215,AU
2258601216,2258601343,TW
-2258601344,2258601471,AU
+2258601344,2258601359,AU
+2258601360,2258601367,TW
+2258601368,2258601375,AU
+2258601376,2258601407,TW
+2258601408,2258601423,AU
+2258601424,2258601471,TW
2258601472,2258601983,JP
-2258601984,2258602303,AU
+2258601984,2258602303,TW
2258602304,2258602327,HK
-2258602328,2258602335,AU
+2258602328,2258602335,TW
2258602336,2258602367,HK
-2258602368,2258602399,AU
+2258602368,2258602399,TW
2258602400,2258602447,HK
-2258602448,2258602479,AU
+2258602448,2258602479,TW
2258602480,2258602495,HK
-2258602496,2258602815,AU
+2258602496,2258602815,TW
2258602816,2258602879,HK
-2258602880,2258603007,AU
+2258602880,2258603007,TW
2258603008,2258603071,HK
-2258603072,2258603087,PG
+2258603072,2258603087,TW
2258603088,2258603089,HK
2258603090,2258603090,PG
2258603091,2258603103,HK
-2258603104,2258603135,PG
+2258603104,2258603135,TW
2258603136,2258603139,HK
-2258603140,2258603199,PG
+2258603140,2258603199,TW
2258603200,2258603207,HK
-2258603208,2258603263,PG
-2258603264,2258603775,AU
+2258603208,2258603263,TW
+2258603264,2258603279,AU
+2258603280,2258603287,TW
+2258603288,2258603295,AU
+2258603296,2258603775,TW
2258603776,2258603839,HK
-2258603840,2258603903,AU
+2258603840,2258603903,TW
2258603904,2258603943,HK
-2258603944,2258603951,AU
+2258603944,2258603951,TW
2258603952,2258603967,HK
-2258603968,2258604031,AU
+2258603968,2258604031,TW
2258604032,2258604287,HK
-2258604288,2258604671,AU
+2258604288,2258604671,TW
2258604672,2258604735,SG
2258604736,2258604799,AU
2258604800,2258605055,HK
-2258605056,2258605311,AU
+2258605056,2258605311,TW
2258605312,2258605439,SG
-2258605440,2258606143,AU
+2258605440,2258605823,TW
+2258605824,2258605951,AU
+2258605952,2258605999,TW
+2258606000,2258606015,AU
+2258606016,2258606047,TW
+2258606048,2258606079,AU
+2258606080,2258606143,TW
2258606144,2258606147,HK
-2258606148,2258606151,AU
+2258606148,2258606151,TW
2258606152,2258606191,HK
-2258606192,2258606199,AU
+2258606192,2258606199,TW
2258606200,2258606367,HK
-2258606368,2258606415,AU
+2258606368,2258606415,TW
2258606416,2258606423,HK
-2258606424,2258606463,AU
+2258606424,2258606463,TW
2258606464,2258606471,HK
-2258606472,2258606487,AU
+2258606472,2258606487,TW
2258606488,2258606535,HK
-2258606536,2258606963,AU
+2258606536,2258606719,TW
+2258606720,2258606751,AU
+2258606752,2258606847,TW
+2258606848,2258606879,AU
+2258606880,2258606963,TW
2258606964,2258606967,NZ
-2258606968,2258607091,AU
+2258606968,2258606971,AU
+2258606972,2258607007,TW
+2258607008,2258607039,AU
+2258607040,2258607087,TW
+2258607088,2258607091,AU
2258607092,2258607095,NZ
-2258607096,2258607351,AU
+2258607096,2258607103,AU
+2258607104,2258607263,TW
+2258607264,2258607279,AU
+2258607280,2258607351,TW
2258607352,2258607359,NZ
-2258607360,2258607819,AU
+2258607360,2258607519,AU
+2258607520,2258607543,TW
+2258607544,2258607551,AU
+2258607552,2258607819,TW
2258607820,2258607823,HK
-2258607824,2258607871,AU
+2258607824,2258607871,TW
2258607872,2258607879,HK
-2258607880,2258607903,AU
+2258607880,2258607903,TW
2258607904,2258607999,HK
-2258608000,2258608063,AU
+2258608000,2258608063,TW
2258608064,2258608127,HK
-2258608128,2258608183,AU
-2258608184,2258608187,TW
-2258608188,2258608255,AU
+2258608128,2258608255,TW
2258608256,2258608259,JP
-2258608260,2258608279,AU
+2258608260,2258608279,TW
2258608280,2258608283,JP
-2258608284,2258608655,AU
+2258608284,2258608639,TW
+2258608640,2258608647,AU
+2258608648,2258608655,TW
2258608656,2258608663,JP
-2258608664,2258608671,AU
+2258608664,2258608671,TW
2258608672,2258608687,JP
-2258608688,2258610175,AU
-2258610176,2258610431,IN
-2258610432,2258610703,AU
-2258610704,2258610719,TW
-2258610720,2258610751,AU
-2258610752,2258610755,TW
-2258610756,2258610759,AU
-2258610760,2258610783,TW
-2258610784,2258611071,AU
+2258608688,2258608863,AU
+2258608864,2258608879,TW
+2258608880,2258608895,AU
+2258608896,2258609087,TW
+2258609088,2258609119,AU
+2258609120,2258609151,TW
+2258609152,2258609407,AU
+2258609408,2258609423,TW
+2258609424,2258609471,AU
+2258609472,2258609567,TW
+2258609568,2258609575,AU
+2258609576,2258609919,TW
+2258609920,2258609967,AU
+2258609968,2258610179,TW
+2258610180,2258610183,IN
+2258610184,2258610239,TW
+2258610240,2258610303,IN
+2258610304,2258610431,TW
+2258610432,2258610687,AU
+2258610688,2258611071,TW
2258611072,2258611103,JP
-2258611104,2258611119,AU
+2258611104,2258611119,TW
2258611120,2258611167,JP
-2258611168,2258611215,AU
+2258611168,2258611215,TW
2258611216,2258611223,NZ
-2258611224,2258614783,AU
+2258611224,2258611567,TW
+2258611568,2258611583,AU
+2258611584,2258612223,TW
+2258612224,2258612303,AU
+2258612304,2258612351,TW
+2258612352,2258612367,AU
+2258612368,2258612383,TW
+2258612384,2258612743,AU
+2258612744,2258613503,TW
+2258613504,2258613567,AU
+2258613568,2258614783,TW
2258614784,2258614815,IN
-2258614816,2258615039,AU
+2258614816,2258615039,TW
2258615040,2258615055,IN
-2258615056,2258616319,AU
-2258616320,2258632703,HK
+2258615056,2258615347,TW
+2258615348,2258615355,AU
+2258615356,2258615391,TW
+2258615392,2258615395,AU
+2258615396,2258616191,TW
+2258616192,2258616203,AU
+2258616204,2258616207,TW
+2258616208,2258616303,AU
+2258616304,2258616311,TW
+2258616312,2258616319,AU
+2258616320,2258620447,TW
+2258620448,2258620455,HK
+2258620456,2258620463,TW
+2258620464,2258620467,HK
+2258620468,2258620471,TW
+2258620472,2258620475,HK
+2258620476,2258632703,TW
2258632704,2258698239,JP
2258698240,2259222527,US
2259222528,2259288063,DE
@@ -39368,6 +41045,7 @@
2309226496,2309357567,US
2309357568,2309423103,AU
2309423104,2309685247,US
+2309685248,2309750783,ZA
2309750784,2309816319,AU
2309816320,2309881855,US
2309881856,2309947391,NL
@@ -39382,7 +41060,9 @@
2311061504,2311127039,US
2311127040,2311192575,DE
2311192576,2311258111,FR
-2311258112,2311323647,GB
+2311258112,2311315455,GB
+2311315456,2311319551,MY
+2311319552,2311323647,GB
2311389184,2311847935,US
2311847936,2311913471,IT
2311913472,2311979007,GB
@@ -39463,8 +41143,7 @@
2319974400,2320039935,US
2320039936,2320105471,CA
2320105472,2320171007,US
-2320171008,2320203775,NZ
-2320203776,2320236543,SG
+2320171008,2320236543,SG
2320236544,2320302079,US
2320302080,2320367615,AU
2320367616,2320433151,US
@@ -39672,8 +41351,10 @@
2344609024,2344609279,IT
2344615936,2344878079,ID
2344878080,2346188799,CN
-2346188800,2346450943,AU
-2346450944,2346582015,CN
+2346188800,2346254335,AU
+2346254336,2346319871,CN
+2346319872,2346385407,AU
+2346385408,2346582015,CN
2346582016,2346647551,GB
2346647552,2346713087,TW
2346713088,2346778623,CN
@@ -39829,7 +41510,6 @@
2371747840,2371878911,GB
2371878912,2371944447,BE
2371944448,2372009983,GB
-2372009984,2372075519,PL
2372075520,2372206591,DE
2372206592,2372214783,UA
2372214784,2372218879,DE
@@ -40158,7 +41838,8 @@
2407661568,2407727103,AT
2407727104,2408054783,US
2408054784,2408120319,JP
-2408185856,2409627647,US
+2408185856,2409562111,US
+2409562112,2409627647,GB
2409627648,2409693183,ZA
2409693184,2409758719,AT
2409758720,2409824255,US
@@ -40168,7 +41849,6 @@
2410151936,2410217471,US
2410217472,2410283007,BE
2410283008,2410348543,US
-2410348544,2410414079,JP
2410414080,2410545151,US
2410545152,2410610687,AU
2410610688,2410676223,US
@@ -40176,7 +41856,9 @@
2410938368,2411003903,CH
2411003904,2411462655,US
2411462656,2411593727,AU
-2411593728,2411986943,US
+2411593728,2411749375,US
+2411749376,2411753471,MY
+2411753472,2411986943,US
2411986944,2412052479,FR
2412052480,2412314623,US
2412445696,2412576767,US
@@ -40508,7 +42190,15 @@
2455244800,2455245567,AU
2455245568,2455245823,US
2455245824,2455246847,AU
-2455246848,2455371775,US
+2455246848,2455247871,IN
+2455247872,2455248895,US
+2455248896,2455257087,TH
+2455257088,2455261183,PH
+2455261184,2455262207,US
+2455262208,2455263231,KR
+2455263232,2455273471,US
+2455273472,2455275519,AU
+2455275520,2455371775,US
2455371776,2455437311,GB
2455437312,2455830527,US
2455830528,2455896063,GB
@@ -40538,7 +42228,8 @@
2457360896,2457361151,RU
2457361152,2457361407,CZ
2457361408,2457365503,RU
-2457365504,2457366527,CZ
+2457365504,2457366271,CZ
+2457366272,2457366527,RU
2457366528,2457367551,GB
2457367552,2457372671,CZ
2457372672,2457376767,RU
@@ -40611,8 +42302,8 @@
2462121984,2462187519,PT
2462187520,2462253055,GB
2462253056,2462326783,AU
-2462384128,2462580735,US
-2462580736,2462646271,GB
+2462384128,2462449663,US
+2462449664,2462646271,GB
2462646272,2463236095,US
2463236096,2463301631,AT
2463301632,2463367167,FI
@@ -40977,13 +42668,17 @@
2500199424,2500199679,IE
2500199680,2500201535,US
2500201536,2500201543,GB
-2500201544,2500219135,US
+2500201544,2500202879,US
+2500202880,2500203007,ES
+2500203008,2500219135,US
2500219136,2500219391,DE
2500219392,2500225551,US
2500225552,2500225559,ES
2500225560,2500228607,US
2500228608,2500228863,FR
-2500228864,2500235775,US
+2500228864,2500230041,US
+2500230042,2500230042,GB
+2500230043,2500235775,US
2500235776,2500236543,GB
2500236544,2500236837,US
2500236838,2500236838,ES
@@ -41031,7 +42726,9 @@
2500551680,2500551935,FR
2500551936,2500553759,US
2500553760,2500553767,GB
-2500553768,2500555263,US
+2500553768,2500554379,US
+2500554380,2500554487,DE
+2500554488,2500555263,US
2500555264,2500555519,FR
2500555520,2500558847,US
2500558848,2500559103,FR
@@ -41083,7 +42780,9 @@
2504491008,2504499199,IT
2504499200,2504916991,US
2504916992,2504982527,IL
-2504982528,2506293247,US
+2504982528,2505793535,US
+2505793536,2505801727,ES
+2505801728,2506293247,US
2506293248,2506358783,CA
2506358784,2506360831,US
2506360832,2506361087,ES
@@ -41112,7 +42811,9 @@
2508107776,2508109823,FI
2508109824,2508111871,DE
2508111872,2508128255,RU
-2508128256,2508455935,US
+2508128256,2508259327,US
+2508259328,2508324863,MY
+2508324864,2508455935,US
2508455936,2508521471,IT
2508521472,2508587007,CH
2508587008,2508652543,BE
@@ -41278,6 +42979,8 @@
2525038592,2525039615,HK
2525039616,2525040639,AU
2525040640,2525041151,BD
+2525041152,2525041407,ID
+2525041408,2525041663,IN
2525041664,2525042687,KH
2525042688,2525044735,IN
2525044736,2525045759,HK
@@ -41306,6 +43009,13 @@
2525085696,2525086719,CN
2525086720,2525089791,IN
2525089792,2525090815,HK
+2525090816,2525091839,IN
+2525091840,2525092863,CN
+2525092864,2525093887,BD
+2525093888,2525094911,KR
+2525094912,2525095935,TW
+2525095936,2525101055,IN
+2525101056,2525102079,CN
2525102080,2525233151,US
2525233152,2525298687,SE
2525298688,2525626367,US
@@ -41356,6 +43066,40 @@
2532114432,2532179967,GB
2532179968,2532376575,US
2532376576,2532442111,ES
+2532442112,2532445183,CN
+2532445184,2532449279,IN
+2532449280,2532450303,CN
+2532450304,2532451327,AU
+2532451328,2532452351,HK
+2532452352,2532453375,NZ
+2532453376,2532457471,CN
+2532457472,2532461567,IN
+2532461568,2532463615,CN
+2532463616,2532465663,IN
+2532465664,2532467711,CN
+2532467712,2532468735,TW
+2532468736,2532469759,BD
+2532469760,2532470783,ID
+2532470784,2532473855,CN
+2532473856,2532474879,HK
+2532474880,2532475903,NZ
+2532475904,2532476927,KR
+2532476928,2532477951,AU
+2532477952,2532478975,IN
+2532478976,2532479999,KR
+2532480000,2532481023,IN
+2532481024,2532486143,CN
+2532486144,2532488191,IN
+2532488192,2532489215,MY
+2532489216,2532492287,CN
+2532492288,2532495359,IN
+2532495360,2532496383,HK
+2532496384,2532497407,CN
+2532497408,2532499455,HK
+2532499456,2532500479,CN
+2532500480,2532501503,HK
+2532501504,2532506623,CN
+2532506624,2532507647,IN
2532507648,2532573183,US
2532573184,2532638719,ES
2532638720,2533031935,US
@@ -41363,7 +43107,8 @@
2533097472,2533228543,US
2533228544,2533294079,PL
2533294080,2533359615,CN
-2533359616,2533375999,UA
+2533359616,2533373951,UA
+2533373952,2533375999,BG
2533376000,2533392383,HU
2533392384,2533425151,RO
2533425152,2539978751,IT
@@ -41386,7 +43131,6 @@
2542338048,2543583231,US
2543583232,2543648767,SE
2543648768,2543714303,NO
-2543714304,2543779839,JP
2543779840,2544154840,US
2544154841,2544154842,CA
2544154843,2544500735,US
@@ -41410,8 +43154,7 @@
2545811456,2547187711,US
2547187712,2547318783,GB
2547318784,2547515391,US
-2547515392,2547523583,FR
-2547531776,2547539967,UA
+2547515392,2547523583,GB
2547553024,2547553279,RU
2548039680,2548563967,GB
2548563968,2548826111,IR
@@ -41474,7 +43217,7 @@
2549702656,2549704703,UA
2549704704,2549706751,CZ
2549706752,2549710847,NO
-2549710848,2549743615,CZ
+2549710848,2549743615,BY
2549743616,2549809151,TR
2549809152,2549874687,BG
2549874688,2549876735,GB
@@ -41535,7 +43278,9 @@
2556742080,2556742327,US
2556742328,2556742335,GB
2556742336,2556755967,US
-2556755968,2556821503,HK
+2556755968,2556780031,HK
+2556780032,2556780799,SG
+2556780800,2556821503,HK
2556821504,2556887039,SG
2556887040,2557018111,HK
2557018112,2557083647,GB
@@ -41655,7 +43400,8 @@
2585853952,2585985023,JP
2585985024,2586480639,US
2586480640,2586484735,IL
-2586484736,2586510335,US
+2586484736,2586486783,GB
+2586486784,2586510335,US
2586510336,2586511359,ES
2586511360,2586566655,US
2586566656,2586566687,FR
@@ -41670,7 +43416,9 @@
2586622464,2586622975,ES
2586622976,2586640895,US
2586640896,2586641407,FR
-2586641408,2586733567,US
+2586641408,2586650687,US
+2586650688,2586650703,DE
+2586650704,2586733567,US
2586733568,2586733823,LT
2586733824,2586804223,US
2586804224,2586804479,ES
@@ -41708,8 +43456,8 @@
2587249418,2587249418,FR
2587249419,2587394047,US
2587394048,2587394559,ES
-2587394560,2587398143,US
-2587398144,2587399167,ES
+2587394560,2587396095,US
+2587396096,2587399167,ES
2587399168,2587443199,US
2587443200,2587447295,CH
2587447296,2587476760,US
@@ -41722,7 +43470,9 @@
2587492352,2587493375,ES
2587493376,2587508735,US
2587508736,2587525119,GB
-2587525120,2587926527,US
+2587525120,2587542527,US
+2587542528,2587543551,ES
+2587543552,2587926527,US
2587926528,2587930623,BG
2587930624,2587951103,US
2587951104,2587952127,ZA
@@ -41821,17 +43571,24 @@
2588488704,2588489727,LY
2588489728,2588490751,GQ
2588490752,2588491775,GW
-2588493824,2588494847,ZA
+2588491776,2588492799,TZ
+2588492800,2588494847,ZA
+2588494848,2588495871,SO
2588495872,2588496895,ZW
+2588496896,2588497919,BW
2588497920,2588498943,SD
+2588498944,2588499967,DZ
2588499968,2588500991,ZA
2588500992,2588502015,CI
+2588502016,2588503039,BI
2588503040,2588504063,LY
2588504064,2588505087,TD
2588505088,2588506111,CG
2588506112,2588507135,ZA
2588507136,2588508159,SO
2588508160,2588510207,LY
+2588510208,2588512255,ZA
+2588522496,2588526591,ZA
2588526592,2588528639,CM
2588528640,2588530687,ZA
2588532736,2588534783,ZA
@@ -41839,8 +43596,10 @@
2588672000,2588934143,KE
2588934144,2589982719,SC
2589982720,2590507007,SD
+2590507008,2591031295,TN
2591031296,2591096831,GA
2591293440,2591326207,GA
+2591522816,2591526911,LR
2591531008,2591539199,ZA
2591539200,2591547391,GA
2591547392,2591555583,ZA
@@ -41978,11 +43737,109 @@
2616983552,2617049087,US
2617049088,2617114623,IT
2617114880,2617115135,US
-2617118720,2617131007,US
+2617118720,2617123839,US
+2617123840,2617124095,DE
+2617124096,2617131007,US
2617131008,2617139199,CA
-2617139200,2617148159,US
+2617139200,2617139455,PE
+2617139456,2617139711,SZ
+2617139712,2617139967,JM
+2617139968,2617140223,PA
+2617140224,2617140479,CO
+2617140480,2617140735,SC
+2617140736,2617140991,CA
+2617140992,2617141247,LC
+2617141248,2617141503,SV
+2617141504,2617141759,GT
+2617141760,2617142015,ZW
+2617142016,2617142271,KR
+2617142272,2617142527,US
+2617142528,2617142783,LU
+2617142784,2617143039,PH
+2617143040,2617143295,UG
+2617143296,2617143551,US
+2617143552,2617143807,TT
+2617143808,2617144063,US
+2617144064,2617144319,ZA
+2617144320,2617144575,MU
+2617144576,2617144831,FJ
+2617144832,2617145087,US
+2617145088,2617145343,MX
+2617145344,2617145599,NI
+2617145600,2617145855,UA
+2617145856,2617146111,US
+2617146112,2617146367,CI
+2617146368,2617146623,US
+2617146624,2617146879,GY
+2617146880,2617147135,DE
+2617147136,2617147391,AO
+2617147392,2617148159,US
2617151488,2617155583,CA
-2617155584,2617180159,US
+2617155584,2617163775,US
+2617163776,2617164031,SK
+2617164032,2617164287,MC
+2617164288,2617164543,AZ
+2617164544,2617164799,FI
+2617164800,2617165055,CZ
+2617165056,2617165311,UZ
+2617165312,2617165567,BT
+2617165568,2617165823,CN
+2617165824,2617166079,ME
+2617166080,2617166335,YE
+2617166336,2617166591,KH
+2617166592,2617166847,TJ
+2617166848,2617167103,KG
+2617167104,2617167359,IS
+2617167360,2617167615,DK
+2617167616,2617167871,IL
+2617167872,2617168127,PL
+2617168128,2617168383,LA
+2617168384,2617168639,GH
+2617168640,2617168895,BD
+2617168896,2617169151,LI
+2617169152,2617169407,ET
+2617169408,2617169663,SM
+2617169664,2617169919,BH
+2617169920,2617170175,CY
+2617170176,2617170431,NZ
+2617170432,2617170687,PS
+2617170688,2617170943,GI
+2617170944,2617171199,RS
+2617171200,2617171455,HK
+2617171456,2617171711,HR
+2617171712,2617171967,SN
+2617171968,2617172223,MV
+2617172224,2617172479,AF
+2617172480,2617172735,JP
+2617172736,2617172991,CM
+2617172992,2617173247,US
+2617173248,2617173503,JP
+2617173504,2617173759,TM
+2617173760,2617174015,GE
+2617174016,2617174271,TR
+2617174272,2617174527,TW
+2617174528,2617174783,KW
+2617174784,2617175039,EE
+2617175040,2617175295,CN
+2617175296,2617175551,MA
+2617175552,2617175807,BA
+2617175808,2617176063,IQ
+2617176064,2617176319,NO
+2617176320,2617176575,AU
+2617176576,2617176831,TH
+2617176832,2617177087,VN
+2617177088,2617177343,AM
+2617177344,2617177599,RU
+2617177600,2617177855,IN
+2617177856,2617178111,BE
+2617178112,2617178367,IM
+2617178368,2617178623,BN
+2617178624,2617178879,AD
+2617178880,2617179135,LT
+2617179136,2617179391,MD
+2617179392,2617179647,SI
+2617179648,2617179903,KE
+2617179904,2617180159,NG
2617311232,2617769983,US
2617769984,2617835519,ZA
2617835520,2617901055,US
@@ -42000,7 +43857,7 @@
2618884096,2618949631,CH
2618949632,2619080703,US
2619080704,2619146239,FR
-2619146240,2619211775,US
+2619146240,2619277311,US
2619277312,2619342847,BN
2619342848,2619473919,US
2619473920,2619539455,CA
@@ -42053,7 +43910,9 @@
2627076096,2627141631,NL
2627141632,2627403775,US
2634022912,2634088447,CN
-2634088448,2635202559,JP
+2634088448,2634350591,JP
+2634416128,2635005951,JP
+2635071488,2635202559,JP
2635202560,2635268095,CN
2635268096,2635399167,JP
2635399168,2635530239,US
@@ -42352,13 +44211,29 @@
2667642880,2667970559,US
2667970560,2668036095,CA
2668036096,2668101631,SE
-2668101632,2668101791,NL
+2668101632,2668101663,NL
+2668101664,2668101671,US
+2668101672,2668101791,NL
2668101792,2668101823,US
2668101824,2668101855,NL
2668101856,2668101863,US
2668101864,2668101887,NL
2668101888,2668101919,US
-2668101920,2668167167,NL
+2668101920,2668102063,NL
+2668102064,2668102071,US
+2668102072,2668102647,NL
+2668102648,2668102655,US
+2668102656,2668102991,NL
+2668102992,2668102999,US
+2668103000,2668103743,NL
+2668103744,2668103775,KE
+2668103776,2668104127,NL
+2668104128,2668104135,GB
+2668104136,2668104191,NL
+2668104192,2668104207,KE
+2668104208,2668104247,NL
+2668104248,2668104255,US
+2668104256,2668167167,NL
2668167168,2668363775,US
2668363776,2668429311,CH
2668429312,2668494847,AU
@@ -42476,7 +44351,9 @@
2677639680,2677639935,CA
2677639936,2677642239,US
2677642240,2677642495,ES
-2677642496,2677648383,US
+2677642496,2677642751,US
+2677642752,2677643007,SE
+2677643008,2677648383,US
2677648384,2677649407,JP
2677649408,2677650431,US
2677650432,2677650943,RO
@@ -42534,7 +44411,8 @@
2679242752,2679308287,US
2679308288,2679373823,CH
2679373824,2679406591,GB
-2679406592,2679431167,US
+2679406592,2679422975,BR
+2679422976,2679431167,US
2679431168,2679439359,FR
2679439360,2679523327,US
2679523328,2679525375,GB
@@ -42577,7 +44455,6 @@
2682322944,2682388479,US
2682388480,2682454015,CN
2682454016,2682519551,US
-2682519552,2682585087,JP
2682585088,2682716159,US
2682716160,2682781695,CA
2682781696,2682847231,CH
@@ -42773,7 +44650,9 @@
2684878848,2684944383,SE
2684944384,2685009919,GB
2685009920,2685075455,US
-2685075456,2686386175,JP
+2685075456,2685599743,JP
+2685665280,2685992959,JP
+2686058496,2686320639,JP
2686386176,2686844927,US
2686844928,2686910463,GB
2686910464,2686975999,US
@@ -42858,7 +44737,9 @@
2694381568,2694447103,US
2696151040,2696216575,IT
2696216576,2696282111,ZA
-2696413184,2697789439,JP
+2696413184,2696478719,ZA
+2696478720,2696871935,JP
+2696937472,2697789439,JP
2697789440,2697854975,US
2697854976,2697889791,AU
2697889792,2697891839,US
@@ -42883,8 +44764,11 @@
2699362304,2699624447,US
2699624448,2699689983,JP
2699755520,2699821055,JP
-2699886592,2700935167,JP
+2699886592,2699984895,JP
+2700017664,2700738559,JP
+2700804096,2700935167,JP
2700935168,2701066239,US
+2701066240,2701131775,ZA
2701131776,2701139967,HN
2701139968,2701148159,NI
2701148160,2701149183,AR
@@ -43430,9 +45314,7 @@
2734588928,2734589951,CA
2734589952,2734599167,US
2734599168,2734600191,CA
-2734600192,2734603263,US
-2734603264,2734604287,AI
-2734604288,2734633983,US
+2734600192,2734633983,US
2734633984,2734635007,CA
2734635008,2734649343,US
2734649344,2734650367,CA
@@ -43441,8 +45323,8 @@
2734658560,2734659583,CA
2734659584,2734665727,US
2734665728,2734666751,CA
-2734666752,2734673919,US
-2734673920,2734675967,CA
+2734666752,2734672895,US
+2734672896,2734675967,CA
2734675968,2734678015,BM
2734678016,2734679039,US
2734679040,2734680063,CA
@@ -43464,21 +45346,88 @@
2736848896,2736914431,US
2736914432,2736979967,NO
2736979968,2737438719,US
-2737438720,2737799167,JP
+2737438720,2737767423,JP
+2737767424,2737768447,CN
+2737768448,2737769471,AU
+2737769472,2737770495,IN
+2737770496,2737771263,AU
+2737771264,2737771519,JP
+2737771520,2737772031,AU
+2737772544,2737774591,JP
+2737774592,2737776639,BD
+2737776640,2737777663,AU
+2737777664,2737778175,HK
+2737778432,2737785855,AU
+2737785856,2737788927,BD
+2737788928,2737789951,MY
+2737789952,2737793023,AU
+2737793024,2737794047,NZ
+2737794048,2737795071,AU
+2737795072,2737796095,NZ
+2737796096,2737799167,AU
2737799168,2737800191,NZ
-2737800192,2737801215,JP
-2737801216,2737802239,AU
+2737800192,2737802239,AU
2737802240,2737803263,IN
-2737803264,2737805311,JP
+2737803264,2737804287,BD
+2737804288,2737805311,NP
2737805312,2737806335,IN
-2737806336,2737809407,JP
+2737806336,2737807359,BD
+2737807360,2737808383,AF
+2737808384,2737809407,NZ
2737809408,2737810431,AU
-2737810432,2737824767,JP
-2737824768,2737825791,NZ
-2737825792,2737828863,JP
-2737828864,2737829887,NZ
-2737829888,2738094079,JP
-2738225152,2738749439,JP
+2737810432,2737811455,KH
+2737811456,2737811711,SG
+2737811712,2737811967,HK
+2737811968,2737812223,GB
+2737812224,2737812479,US
+2737812480,2737813503,AU
+2737813504,2737815551,NZ
+2737815552,2737816575,MY
+2737816576,2737817599,AU
+2737817600,2737818623,MY
+2737818624,2737819647,NZ
+2737819648,2737821695,IN
+2737821696,2737822719,AU
+2737822720,2737823743,NZ
+2737823744,2737824767,NC
+2737824768,2737829887,NZ
+2737829888,2737830911,NC
+2737830912,2737831935,AU
+2737831936,2738094079,JP
+2738159616,2738163711,CN
+2738163712,2738164735,HK
+2738164736,2738165759,AU
+2738165760,2738166783,NP
+2738166784,2738167807,KH
+2738167808,2738168831,AU
+2738168832,2738177023,CN
+2738177024,2738178047,AU
+2738178048,2738179071,HK
+2738179072,2738182143,IN
+2738182144,2738195455,CN
+2738195456,2738196479,BD
+2738196480,2738197503,AU
+2738197504,2738198527,BD
+2738198528,2738199551,MY
+2738199552,2738200575,KR
+2738200576,2738204671,CN
+2738204672,2738205695,IN
+2738205696,2738206719,BD
+2738206720,2738207743,ID
+2738207744,2738208767,CN
+2738208768,2738209791,ID
+2738209792,2738210815,KH
+2738210816,2738213887,IN
+2738213888,2738215935,HK
+2738215936,2738216959,CN
+2738216960,2738217983,HK
+2738217984,2738220031,AU
+2738220032,2738221055,PK
+2738221056,2738222079,CN
+2738222080,2738223103,MO
+2738223104,2738224127,AU
+2738224128,2738225151,IN
+2738225152,2738683903,JP
2738749440,2742353919,FR
2742353920,2742419455,ES
2742419456,2742484991,US
@@ -43712,8 +45661,8 @@
2770337792,2770993151,US
2770993152,2771124223,IN
2771124224,2771451903,US
+2771648512,2771910655,ZA
2772434944,2772631551,US
-2772631552,2772697087,AU
2772697088,2772762623,US
2772762624,2772828159,AU
2772828160,2772959231,US
@@ -43731,7 +45680,8 @@
2774532096,2774597631,JP
2774597632,2774663167,US
2774663168,2774728703,NI
-2774728704,2774990847,JP
+2774728704,2774860799,JP
+2774925312,2774990847,JP
2774990848,2775318527,US
2775318528,2775384063,JP
2775384064,2775711743,US
@@ -43971,7 +45921,7 @@
2813591552,2813908479,US
2813908480,2813908735,AU
2813908736,2814181375,US
-2814181376,2814246911,AU
+2814181376,2814246911,CN
2814246912,2815033343,US
2815033344,2815098879,NL
2815098880,2815111347,GB
@@ -43996,7 +45946,8 @@
2816271872,2816272383,IN
2816272384,2816273407,JP
2816273408,2816275455,IN
-2816275456,2816671743,US
+2816275456,2816278527,SG
+2816278528,2816671743,US
2816671744,2816737279,CA
2816737280,2817061119,US
2817061120,2817062911,LU
@@ -44005,11 +45956,11 @@
2817294336,2817933055,US
2817933056,2817933311,CA
2817933312,2817933567,PR
-2817933568,2818003711,US
-2818003712,2818003722,GB
+2817933568,2818002943,US
+2818002944,2818003722,GB
2818003723,2818003723,US
-2818003724,2818003967,GB
-2818003968,2818113535,US
+2818003724,2818004991,GB
+2818004992,2818113535,US
2818244608,2818310143,US
2818310144,2818375679,AR
2818375680,2818572287,US
@@ -44111,7 +46062,7 @@
2831613952,2832007167,US
2832072704,2832138239,ZA
2832138240,2832269311,US
-2832269312,2832400383,ZA
+2832269312,2832465919,ZA
2832465920,2832793599,US
2832793600,2832859135,AU
2832859136,2832924671,US
@@ -44129,7 +46080,8 @@
2833973248,2834010111,US
2834010112,2834014207,CA
2834018304,2834030591,US
-2834038784,2834497535,US
+2834030592,2834034687,CA
+2834034688,2834497535,US
2834497536,2834563071,SV
2834563072,2834825215,US
2834825216,2834956287,KR
@@ -44166,7 +46118,6 @@
2848244736,2848245759,GB
2848245760,2848276479,US
2848325632,2848522239,US
-2848522240,2848587775,AU
2848587776,2848653311,ZA
2848653312,2848980991,US
2848980992,2849964031,KR
@@ -44537,7 +46488,11 @@
2918023168,2918043647,US
2918043648,2918047743,CA
2918047744,2918051839,US
-2918051840,2918121471,CA
+2918051840,2918111999,CA
+2918112000,2918112127,US
+2918112128,2918112895,CA
+2918112896,2918113023,US
+2918113024,2918121471,CA
2918121472,2918154239,US
2918154240,2918170623,CA
2918170624,2918187775,US
@@ -44679,8 +46634,14 @@
2925527040,2926575615,US
2926575616,2926777343,CA
2926777344,2926777855,US
-2926777856,2927084799,CA
-2927084800,2927085823,US
+2926777856,2926778111,CA
+2926778112,2926778239,US
+2926778240,2926779391,CA
+2926779392,2926779519,US
+2926779520,2927084799,CA
+2927084800,2927085055,US
+2927085056,2927085567,CA
+2927085568,2927085823,US
2927085824,2927099903,CA
2927099904,2927242751,US
2927242752,2927243263,AE
@@ -44713,7 +46674,7 @@
2936012800,2937847807,CN
2937847808,2937848831,KH
2937848832,2937849855,JP
-2937849856,2937850879,SG
+2937849856,2937850879,AU
2937850880,2937851903,MY
2937851904,2937855999,JP
2937856000,2937860095,KR
@@ -44792,7 +46753,6 @@
2943313920,2943314943,SG
2943315968,2943318015,ID
2943318016,2943320063,JP
-2943320064,2943336447,PK
2943336448,2943352831,TW
2943352832,2944401407,KR
2944401408,2944925695,JP
@@ -44814,7 +46774,13 @@
2947584000,2947586047,TO
2947588096,2947590143,ID
2947590144,2947590655,JP
-2947590656,2947592191,SG
+2947590656,2947590911,SG
+2947590912,2947590927,HK
+2947590928,2947591167,SG
+2947591168,2947591183,HK
+2947591184,2947591679,SG
+2947591680,2947591695,JP
+2947591696,2947592191,SG
2947596288,2947597311,IN
2947597312,2947598335,JP
2947598336,2947602431,AU
@@ -44948,7 +46914,8 @@
2954837868,2954837871,ES
2954837872,2954838599,FR
2954838600,2954838607,GB
-2954838608,2954839239,FR
+2954838608,2954838615,NL
+2954838616,2954839239,FR
2954839240,2954839243,IT
2954839244,2954839267,FR
2954839268,2954839271,ES
@@ -44962,7 +46929,11 @@
2954840928,2954840931,DE
2954840932,2954841567,FR
2954841568,2954841583,ES
-2954841584,2954843503,FR
+2954841584,2954841707,FR
+2954841708,2954841711,NL
+2954841712,2954841807,FR
+2954841808,2954841815,NL
+2954841816,2954843503,FR
2954843504,2954843507,ES
2954843508,2954843767,FR
2954843768,2954843771,ES
@@ -44970,7 +46941,9 @@
2954844148,2954844151,DE
2954844152,2954844999,FR
2954845000,2954845003,ES
-2954845004,2954846107,FR
+2954845004,2954846095,FR
+2954846096,2954846103,NL
+2954846104,2954846107,FR
2954846108,2954846111,ES
2954846112,2954846139,FR
2954846140,2954846143,ES
@@ -45022,7 +46995,9 @@
2954899456,2954901503,ES
2954901504,2954903551,IT
2954903552,2954911743,JP
-2954911744,2954918911,NL
+2954911744,2954911999,NL
+2954912000,2954912767,US
+2954912768,2954918911,NL
2954918912,2954919935,IE
2954919936,2954928127,RU
2954928128,2954932223,PL
@@ -45269,7 +47244,9 @@
2959282176,2959290367,RO
2959290368,2959292415,PL
2959292416,2959302655,RU
-2959302656,2959310847,UA
+2959302656,2959308877,UA
+2959308878,2959308878,RU
+2959308879,2959310847,UA
2959310848,2959343615,RU
2959343616,2959351807,UA
2959351808,2959353855,DE
@@ -45498,7 +47475,6 @@
2960594944,2960596991,UA
2960596992,2960605183,PL
2960605184,2960621567,UA
-2960621568,2960629759,CZ
2960629760,2960646143,RU
2960646144,2960648191,KZ
2960648192,2960650239,UA
@@ -45617,7 +47593,9 @@
2961088512,2961088767,SE
2961088768,2961089535,UA
2961089536,2961090559,KG
-2961090560,2961113087,RO
+2961090560,2961108991,RO
+2961108992,2961111039,GB
+2961111040,2961113087,RO
2961113088,2961178623,CH
2961178624,2965372927,FR
2965372928,2965766143,RU
@@ -45703,6 +47681,8 @@
2969042944,2969567231,GB
2969567232,2984247295,BR
2984247296,2984935423,MX
+2984935424,2984936447,AR
+2984936448,2984937471,BR
2984937472,2984939519,HN
2984939520,2984951807,BR
2984951808,2984968191,EC
@@ -45758,7 +47738,11 @@
2987552768,2987556863,GB
2987556864,2987560959,NL
2987560960,2987565055,DE
-2987565056,2987569151,AT
+2987565056,2987566591,AT
+2987566592,2987566847,HU
+2987566848,2987568383,AT
+2987568384,2987568639,HU
+2987568640,2987569151,AT
2987569152,2987573247,FR
2987573248,2987577343,TR
2987577344,2987585535,RU
@@ -45917,7 +47901,9 @@
2988449216,2988451839,FR
2988451840,2988453887,BE
2988453888,2988457983,GB
-2988457984,2988459119,FR
+2988457984,2988458319,FR
+2988458320,2988458327,NL
+2988458328,2988459119,FR
2988459120,2988459127,IT
2988459128,2988459135,PL
2988459136,2988459535,FR
@@ -45971,11 +47957,15 @@
2988484832,2988484847,GB
2988484848,2988485683,FR
2988485684,2988485687,PL
-2988485688,2988487071,FR
+2988485688,2988486311,FR
+2988486312,2988486319,NL
+2988486320,2988487071,FR
2988487072,2988487075,ES
2988487076,2988487095,FR
2988487096,2988487099,ES
-2988487100,2988489479,FR
+2988487100,2988489119,FR
+2988489120,2988489127,DE
+2988489128,2988489479,FR
2988489480,2988489483,DE
2988489484,2988489675,FR
2988489676,2988489679,ES
@@ -45986,7 +47976,9 @@
2988490687,2988490687,BE
2988490688,2988492799,FR
2988492800,2988494847,PL
-2988494848,2988499729,FR
+2988494848,2988499663,FR
+2988499664,2988499671,NL
+2988499672,2988499729,FR
2988499730,2988499730,GB
2988499731,2988499736,FR
2988499737,2988499737,NL
@@ -46096,7 +48088,8 @@
2988558204,2988558207,DE
2988558208,2988558803,FR
2988558804,2988558807,ES
-2988558808,2988561583,FR
+2988558808,2988558815,NL
+2988558816,2988561583,FR
2988561584,2988561591,GB
2988561592,2988561763,FR
2988561764,2988561767,IT
@@ -46112,7 +48105,9 @@
2989096960,2989228031,PL
2989228032,2989490175,RU
2989490176,2989555711,HU
-2989555712,2989621247,RU
+2989555712,2989588479,RU
+2989588480,2989589503,CO
+2989589504,2989621247,RU
2989621248,2989752319,BE
2989752320,2989817855,SY
2989817856,2989883391,KW
@@ -46127,7 +48122,9 @@
2990211072,2990276607,GR
2990276608,2990342143,ES
2990342144,2990407679,KW
-2990407680,2990440447,GB
+2990407680,2990421728,US
+2990421729,2990421729,GB
+2990421730,2990440447,US
2990440448,2990473215,NL
2990473216,2990475674,DE
2990475675,2990475675,HR
@@ -46230,7 +48227,7 @@
2996666368,2996682751,RU
2996682752,2996699135,DK
2996699136,2996764671,UA
-2996764672,2996768767,NL
+2996764672,2996768767,GB
2996768768,2996772863,RU
2996772864,2996776959,UA
2996776960,2996781055,RU
@@ -46288,7 +48285,8 @@
2997513355,2997515683,FR
2997515684,2997515684,GB
2997515685,2997518335,FR
-2997518336,2997526527,NL
+2997518336,2997520383,DE
+2997520384,2997526527,NL
2997526528,2997583871,RU
2997583872,2997616639,SY
2997616640,2997649407,SI
@@ -46307,7 +48305,21 @@
2997878784,2998140927,RU
2998140928,2998403071,PL
2998403072,2998665215,RU
-2998665216,2998927359,AT
+2998665216,2998710451,AT
+2998710452,2998710455,DE
+2998710456,2998712975,AT
+2998712976,2998712979,DE
+2998712980,2998720227,AT
+2998720228,2998720231,CZ
+2998720232,2998820735,AT
+2998820736,2998820863,CZ
+2998820864,2998834559,AT
+2998834560,2998834687,HU
+2998834688,2998841343,AT
+2998841344,2998841599,DE
+2998841600,2998875391,AT
+2998875392,2998875519,CZ
+2998875520,2998927359,AT
2998927360,2998991615,CH
2998991616,2998991871,DE
2998991872,2999026943,CH
@@ -46373,7 +48385,7 @@
3000301568,3000302591,RU
3000302592,3000303103,LV
3000303104,3000303359,CH
-3000303360,3000303615,PL
+3000303360,3000303615,DE
3000303616,3000305663,UA
3000305664,3000313855,RU
3000313856,3000315903,CZ
@@ -46790,6 +48802,7 @@
3003173632,3003173887,AR
3003173888,3003174143,EC
3003174144,3003174399,CO
+3003174400,3003174911,BR
3003174912,3003179007,CR
3003179008,3003187199,AR
3003187200,3003252735,CO
@@ -47035,7 +49048,8 @@
3007160064,3007160079,HR
3007160080,3007160575,CL
3007160576,3007160591,IE
-3007160592,3007161087,CL
+3007160592,3007160607,US
+3007160608,3007161087,CL
3007161088,3007161103,GB
3007161104,3007161599,CL
3007161600,3007161615,GB
@@ -47069,11 +49083,13 @@
3007168512,3007168767,QA
3007168768,3007169023,CL
3007169024,3007169151,US
-3007169152,3007175679,CL
+3007169152,3007171855,CL
+3007171856,3007171871,US
+3007171872,3007175679,CL
3007175680,3007175935,GB
3007175936,3007183359,CL
3007183360,3007183615,AU
-3007183616,3007183871,SA
+3007183616,3007183871,IE
3007183872,3007184127,JO
3007184128,3007184383,KW
3007184384,3007184895,CL
@@ -47142,24 +49158,32 @@
3024879616,3025141759,CN
3025141760,3025403903,KR
3025403904,3025600511,CN
-3025600512,3025603839,IN
+3025600512,3025603071,IN
+3025603072,3025603087,HK
+3025603088,3025603839,IN
3025603840,3025604095,HK
3025604096,3025604381,IN
-3025604382,3025604637,SG
-3025604638,3025606815,IN
+3025604382,3025606655,SG
+3025606656,3025606815,IN
3025606816,3025606831,SG
3025606832,3025607167,IN
3025607168,3025607423,SG
3025607424,3025607679,HK
3025607680,3025608191,IN
3025608192,3025608203,JP
-3025608204,3025616895,IN
+3025608204,3025610751,IN
+3025610752,3025612799,SG
+3025612800,3025616895,IN
3025616896,3025617407,SG
3025617408,3025618943,IN
3025618944,3025619487,SG
3025619488,3025620991,IN
3025620992,3025621247,PH
-3025621248,3025625343,IN
+3025621248,3025621503,IN
+3025621504,3025621759,PH
+3025621760,3025623295,IN
+3025623296,3025623551,JP
+3025623552,3025625343,IN
3025625344,3025625375,SG
3025625376,3025625391,IN
3025625392,3025625395,SG
@@ -47167,7 +49191,8 @@
3025625400,3025625407,TH
3025625408,3025625471,SG
3025625472,3025625503,MY
-3025625504,3025625599,IN
+3025625504,3025625535,IN
+3025625536,3025625599,CA
3025625600,3025625855,SG
3025625856,3025629439,IN
3025629440,3025629503,HK
@@ -47183,7 +49208,9 @@
3025632272,3025633535,IN
3025633536,3025633791,HK
3025633792,3025633807,AU
-3025633808,3025637375,IN
+3025633808,3025637151,IN
+3025637152,3025637183,MY
+3025637184,3025637375,IN
3025637376,3025637631,HK
3025637632,3025637887,MY
3025637888,3025638279,IN
@@ -47210,7 +49237,8 @@
3025647776,3025647791,SG
3025647792,3025648079,IN
3025648080,3025648087,SG
-3025648088,3025649151,IN
+3025648088,3025648091,US
+3025648092,3025649151,IN
3025649152,3025649663,HK
3025649664,3025666047,IN
3025666048,3025928191,CN
@@ -47410,7 +49438,8 @@
3035103232,3035168767,PH
3035168768,3035193343,CN
3035193344,3035197439,JP
-3035197440,3035199487,HK
+3035197440,3035198463,SG
+3035198464,3035199487,HK
3035199488,3035200511,IN
3035200512,3035202559,AU
3035202560,3035205631,JP
@@ -47458,14 +49487,18 @@
3039414272,3039414527,BR
3039414528,3039415295,CL
3039415296,3039415807,BR
-3039415808,3039416831,CL
+3039415808,3039416713,CL
+3039416714,3039416715,US
+3039416716,3039416735,CL
+3039416736,3039416739,US
+3039416740,3039416831,CL
3039416832,3039417343,BR
3039417344,3039417855,CL
3039417856,3039418111,BR
3039418112,3039418367,CL
3039418368,3039418879,BR
-3039418880,3039419391,CL
-3039419392,3039420159,BR
+3039418880,3039419135,CL
+3039419136,3039420159,BR
3039420160,3039420415,CL
3039420416,3039428607,AR
3039428608,3039559679,CL
@@ -47569,7 +49602,8 @@
3050700800,3050700815,JP
3050700816,3050701311,CL
3050701312,3050701327,IE
-3050701328,3050701823,CL
+3050701328,3050701343,US
+3050701344,3050701823,CL
3050701824,3050701839,SG
3050701840,3050702335,CL
3050702336,3050702351,DK
@@ -47804,7 +49838,8 @@
3057052672,3057052927,IL
3057052928,3057053183,GB
3057053184,3057053695,AU
-3057053696,3057057791,JP
+3057053696,3057054719,JP
+3057055744,3057057791,JP
3057057792,3057123327,SG
3057123328,3057451007,IN
3057451008,3057516543,CN
@@ -47895,7 +49930,6 @@
3074949120,3075342335,JP
3075342336,3075375103,MY
3075375104,3075383295,KR
-3075383296,3075385343,IN
3075385344,3075386367,MY
3075386368,3075387391,AU
3075388416,3075389439,CN
@@ -47941,7 +49975,12 @@
3081437184,3081502719,MY
3081502720,3081764863,CN
3081764864,3081846783,JP
-3081846784,3081854975,HK
+3081846784,3081847807,TW
+3081847808,3081848831,KR
+3081848832,3081850879,SG
+3081850880,3081851903,HK
+3081851904,3081852927,JP
+3081852928,3081854975,HK
3081854976,3081859071,MN
3081859072,3081861119,PH
3081861120,3081862143,AU
@@ -47951,7 +49990,7 @@
3082027008,3082158079,JP
3082158080,3082166271,CN
3082166272,3082174463,JP
-3082174464,3082178559,PH
+3082174464,3082178559,BZ
3082178560,3082179583,HK
3082179584,3082181631,IN
3082181632,3082182655,ID
@@ -48098,7 +50137,7 @@
3103855104,3103855359,DE
3103855360,3103855615,RU
3103855616,3103855871,ES
-3103855872,3103856383,PL
+3103856128,3103856383,PL
3103856384,3103856639,RU
3103856640,3103856895,HU
3103856896,3103857151,CZ
@@ -48217,6 +50256,7 @@
3104026624,3104027647,NL
3104027648,3104028671,RU
3104028672,3104029695,DE
+3104029696,3104030719,AM
3104030720,3104031743,HR
3104031744,3104032767,FR
3104032768,3104033791,IR
@@ -48502,9 +50542,7 @@
3104331776,3104333823,GB
3104333824,3104334847,ES
3104334848,3104335871,SE
-3104335872,3104336239,LT
-3104336240,3104336255,DE
-3104336256,3104336359,LT
+3104335872,3104336359,LT
3104336360,3104336367,BE
3104336368,3104336407,LT
3104336408,3104336415,CH
@@ -49309,7 +51347,7 @@
3105212416,3105213439,NL
3105213440,3105214463,TR
3105214464,3105215487,GB
-3105215488,3105216511,FR
+3105215488,3105216511,GP
3105216512,3105217535,GB
3105217536,3105218559,CZ
3105218560,3105219583,DE
@@ -49732,7 +51770,6 @@
3105662976,3105663999,ES
3105664000,3105665023,DE
3105665024,3105666047,PL
-3105666048,3105667071,GB
3105667072,3105668095,DE
3105668096,3105669119,NL
3105669120,3105670143,CZ
@@ -49981,9 +52018,7 @@
3105933344,3105933359,IT
3105933360,3105933463,GB
3105933464,3105933471,IT
-3105933472,3105934007,GB
-3105934008,3105934015,IT
-3105934016,3105934127,GB
+3105933472,3105934127,GB
3105934128,3105934135,IT
3105934136,3105934215,GB
3105934216,3105934223,IT
@@ -50221,7 +52256,9 @@
3106166784,3106167807,BH
3106167808,3106168831,RO
3106168832,3106169855,FI
-3106169856,3106170879,CZ
+3106169856,3106170000,NL
+3106170001,3106170001,CZ
+3106170002,3106170879,NL
3106170880,3106171903,RU
3106171904,3106172927,GB
3106172928,3106173951,NL
@@ -50512,7 +52549,9 @@
3106483424,3106483424,ES
3106483425,3106483425,NL
3106483426,3106483426,FR
-3106483427,3106484223,GB
+3106483427,3106483429,GB
+3106483430,3106483430,IE
+3106483431,3106484223,GB
3106484224,3106485247,NL
3106485248,3106486271,CZ
3106486272,3106488319,DE
@@ -50672,8 +52711,7 @@
3106661376,3106662399,TR
3106662400,3106663423,IE
3106663424,3106664447,UA
-3106664448,3106665471,FR
-3106665472,3106666495,CH
+3106664448,3106666495,FR
3106666496,3106667519,UA
3106667520,3106668543,ES
3106668544,3106669567,RU
@@ -51207,8 +53245,7 @@
3107252224,3107253247,SY
3107253248,3107254271,NL
3107254272,3107255295,IT
-3107255296,3107256319,DE
-3107256320,3107257343,CZ
+3107255296,3107257343,DE
3107257344,3107258367,GB
3107258368,3107259391,IT
3107259392,3107260415,CZ
@@ -51437,12 +53474,12 @@
3107492864,3107493887,DE
3107493888,3107494911,FR
3107494912,3107495935,IT
-3107495936,3107495999,FR
-3107496000,3107496031,BS
+3107495936,3107496031,FR
3107496032,3107496063,VG
3107496064,3107496191,FR
3107496192,3107496255,DE
-3107496256,3107496319,FR
+3107496256,3107496287,BS
+3107496288,3107496319,FR
3107496320,3107496703,NL
3107496704,3107496719,PE
3107496720,3107496735,KP
@@ -51454,7 +53491,7 @@
3107496816,3107496831,CN
3107496832,3107496847,BR
3107496848,3107496863,KP
-3107496864,3107496879,FR
+3107496864,3107496879,HK
3107496880,3107496911,IS
3107496912,3107496927,PL
3107496928,3107496959,FR
@@ -51755,7 +53792,8 @@
3107817472,3107818495,UA
3107818496,3107819519,GB
3107819520,3107820543,FR
-3107820544,3107821567,SE
+3107820544,3107821055,LV
+3107821056,3107821567,SE
3107821568,3107822591,GB
3107822592,3107823615,UA
3107823616,3107824639,FR
@@ -51808,6 +53846,225 @@
3107876864,3107877887,RS
3107877888,3107878911,NL
3107878912,3107879935,IL
+3107879936,3107880959,DE
+3107880960,3107881983,HU
+3107881984,3107883007,RS
+3107883008,3107884031,US
+3107884032,3107885055,NO
+3107885056,3107887103,DE
+3107887104,3107888127,BG
+3107888128,3107889151,GB
+3107889152,3107890175,NO
+3107890176,3107891199,IE
+3107891200,3107892223,CH
+3107892224,3107893247,AL
+3107893248,3107894271,SA
+3107894272,3107895295,PL
+3107895296,3107896319,FR
+3107896320,3107897343,NL
+3107897344,3107898367,RU
+3107898368,3107899391,LV
+3107899392,3107900415,RU
+3107900416,3107901439,SE
+3107901440,3107902463,NL
+3107902464,3107904511,GB
+3107904512,3107907583,FR
+3107907584,3107908607,IR
+3107908608,3107909631,BG
+3107909632,3107910655,IT
+3107910656,3107911679,DE
+3107911680,3107912703,IT
+3107912704,3107913727,SE
+3107913728,3107914751,AT
+3107914752,3107915775,RO
+3107915776,3107916799,DE
+3107916800,3107917823,IT
+3107917824,3107918847,HU
+3107918848,3107919871,NL
+3107919872,3107920895,CZ
+3107920896,3107921919,ES
+3107921920,3107922943,UA
+3107922944,3107923967,CH
+3107923968,3107924991,IT
+3107924992,3107926015,HU
+3107926016,3107927039,FR
+3107927040,3107928063,IT
+3107928064,3107929087,NL
+3107929088,3107930111,RU
+3107930112,3107931135,CH
+3107931136,3107932159,NL
+3107932160,3107934207,MT
+3107934208,3107935231,GB
+3107935232,3107936255,PL
+3107936256,3107937279,IT
+3107937280,3107938303,FR
+3107938304,3107939327,CZ
+3107939328,3107940351,IT
+3107940352,3107941375,CZ
+3107941376,3107942399,PL
+3107942400,3107943423,RU
+3107943424,3107944447,NL
+3107944448,3107945471,FR
+3107945472,3107947519,DE
+3107947520,3107948543,IT
+3107948544,3107949567,RO
+3107949568,3107950591,GB
+3107950592,3107951615,US
+3107951616,3107952639,CH
+3107952640,3107953663,NL
+3107953664,3107954687,SK
+3107954688,3107955711,IT
+3107955712,3107956735,NL
+3107956736,3107957759,IT
+3107957760,3107958783,FR
+3107958784,3107959807,AL
+3107959808,3107960831,PT
+3107960832,3107961855,IM
+3107961856,3107962879,RU
+3107962880,3107963903,FR
+3107963904,3107964927,RU
+3107964928,3107965951,ES
+3107965952,3107966975,DE
+3107966976,3107967999,NO
+3107968000,3107969023,DE
+3107969024,3107970047,RU
+3107970048,3107971071,GB
+3107971072,3107972095,UZ
+3107972096,3107973119,IT
+3107973120,3107974143,SA
+3107974144,3107976191,IR
+3107976192,3107977215,NL
+3107977216,3107978239,AT
+3107978240,3107979263,NL
+3107979264,3107980287,ME
+3107980288,3107981311,BE
+3107981312,3107982335,IL
+3107982336,3107983359,GB
+3107983360,3107984383,IE
+3107984384,3107985407,BG
+3107985408,3107986431,OM
+3107986432,3107987455,PL
+3107987456,3107988479,NL
+3107988480,3107989503,GB
+3107989504,3107990527,CZ
+3107990528,3107991551,RU
+3107991552,3107992575,AT
+3107992576,3107993599,RU
+3107993600,3107994623,RO
+3107994624,3107995647,DE
+3107995648,3107996671,BE
+3107996672,3107997695,IT
+3107997696,3107998719,SE
+3107998720,3107999743,AE
+3107999744,3108000767,TR
+3108000768,3108001791,MK
+3108001792,3108002815,GB
+3108002816,3108003839,RO
+3108003840,3108004863,DE
+3108004864,3108005887,RU
+3108005888,3108006911,RO
+3108006912,3108007935,NL
+3108007936,3108008959,DE
+3108008960,3108009983,CH
+3108009984,3108011007,NL
+3108011008,3108012031,DE
+3108012032,3108013055,FR
+3108013056,3108014079,HR
+3108014080,3108015103,NL
+3108015104,3108016127,IE
+3108016128,3108017151,DE
+3108017152,3108018175,FR
+3108018176,3108019199,AT
+3108019200,3108020223,DE
+3108020224,3108021247,US
+3108021248,3108022271,AT
+3108022272,3108023295,DE
+3108023296,3108024319,RS
+3108024320,3108025343,IR
+3108025344,3108026367,BE
+3108026368,3108027391,CH
+3108027392,3108028415,GB
+3108028416,3108029439,NL
+3108029440,3108030463,CH
+3108030464,3108031487,KW
+3108031488,3108032511,IT
+3108032512,3108033535,RU
+3108033536,3108034559,GB
+3108034560,3108036607,CZ
+3108036608,3108037631,GB
+3108037632,3108038655,RU
+3108038656,3108039679,ES
+3108039680,3108040703,MD
+3108040704,3108041727,ES
+3108041728,3108042751,DE
+3108042752,3108044799,GB
+3108044800,3108045823,LU
+3108045824,3108046847,DE
+3108046848,3108047871,HU
+3108047872,3108048895,RU
+3108048896,3108049919,UA
+3108049920,3108050943,RU
+3108050944,3108051967,GB
+3108051968,3108052991,FR
+3108052992,3108054015,IR
+3108054016,3108055039,LV
+3108055040,3108056063,GB
+3108056064,3108057087,IT
+3108057088,3108058111,LT
+3108058112,3108059135,NL
+3108059136,3108060159,FR
+3108060160,3108061183,CH
+3108061184,3108062207,ES
+3108062208,3108063231,TR
+3108063232,3108064255,BE
+3108064256,3108065279,CZ
+3108065280,3108066303,FR
+3108066304,3108067327,GB
+3108067328,3108068351,AT
+3108068352,3108069375,CZ
+3108069376,3108070399,FR
+3108070400,3108073471,GB
+3108073472,3108074495,FR
+3108074496,3108075519,DK
+3108075520,3108076543,BA
+3108076544,3108077567,NL
+3108077568,3108078591,GB
+3108078592,3108079615,SE
+3108079616,3108080639,MD
+3108080640,3108081663,SE
+3108081664,3108082687,GB
+3108082688,3108083711,RU
+3108083712,3108084735,NO
+3108084736,3108085759,ES
+3108085760,3108086783,LV
+3108086784,3108087807,GB
+3108087808,3108088831,CH
+3108088832,3108089855,NL
+3108089856,3108090879,SE
+3108090880,3108091903,BE
+3108091904,3108092927,ES
+3108092928,3108093951,SE
+3108093952,3108095999,DE
+3108096000,3108097023,RU
+3108097024,3108098047,TR
+3108098048,3108099071,DE
+3108099072,3108100095,NL
+3108100096,3108101119,IT
+3108101120,3108102143,SK
+3108102144,3108103167,FR
+3108103168,3108104191,SI
+3108104192,3108105215,AT
+3108105216,3108106239,GB
+3108106240,3108107263,DE
+3108107264,3108108287,UA
+3108108288,3108109311,FR
+3108109312,3108110335,IQ
+3108110336,3108111359,DK
+3108111360,3108112383,GB
+3108112384,3108113407,UA
+3108113408,3108114431,RU
+3108114432,3108115455,AE
+3108115456,3108116479,GB
3120562176,3120594943,CO
3120594944,3120599039,AR
3120599040,3120601087,EC
@@ -52013,6 +54270,7 @@
3133075456,3133079551,CW
3133079552,3133145087,AR
3133145088,3136985343,BR
+3136985344,3136986111,AR
3136986112,3145727999,BR
3145728000,3149135871,MX
3149135872,3149398015,BR
@@ -52036,7 +54294,31 @@
3154575360,3154640895,FR
3154640896,3155165183,IT
3155165184,3155427327,RU
-3155427328,3155689471,AT
+3155427328,3155536647,AT
+3155536648,3155536655,DE
+3155536656,3155540735,AT
+3155540736,3155540991,HU
+3155540992,3155542323,AT
+3155542324,3155542327,CH
+3155542328,3155598079,AT
+3155598080,3155598335,DE
+3155598336,3155628031,AT
+3155628032,3155628287,HU
+3155628288,3155663743,AT
+3155663744,3155663871,CH
+3155663872,3155675647,AT
+3155675648,3155675775,DE
+3155675776,3155676415,AT
+3155676416,3155676671,HU
+3155676672,3155681791,AT
+3155681792,3155682047,HU
+3155682048,3155684095,AT
+3155684096,3155684223,HU
+3155684224,3155685119,AT
+3155685120,3155685247,HU
+3155685248,3155685375,AT
+3155685376,3155685631,CZ
+3155685632,3155689471,AT
3155689472,3155951615,RO
3155951616,3156213759,GB
3156213760,3156279295,RU
@@ -52145,9 +54427,12 @@
3158704128,3158835199,KW
3158835200,3158851583,IQ
3158851584,3158859775,RU
-3158859776,3158860031,NL
-3158860032,3158861055,DE
-3158861056,3158862847,NL
+3158859776,3158861567,NL
+3158861568,3158861823,AE
+3158861824,3158862079,IN
+3158862080,3158862335,GB
+3158862336,3158862591,NL
+3158862592,3158862847,FR
3158862848,3158863103,PL
3158863104,3158863359,IT
3158863360,3158863615,MD
@@ -52497,9 +54782,7 @@
3163186535,3163186535,FR
3163186536,3163186673,DE
3163186674,3163186674,FR
-3163186675,3163192621,DE
-3163192622,3163192622,EG
-3163192623,3163193343,DE
+3163186675,3163193343,DE
3163193344,3163226111,MD
3163226112,3163258879,SA
3163258880,3163291647,SY
@@ -52547,7 +54830,9 @@
3164947580,3164947583,IT
3164947584,3164949135,FR
3164949136,3164949151,NL
-3164949152,3164951663,FR
+3164949152,3164950695,FR
+3164950696,3164950703,NL
+3164950704,3164951663,FR
3164951664,3164951671,PL
3164951672,3164952224,FR
3164952225,3164952231,GB
@@ -52557,7 +54842,9 @@
3164952237,3164952237,GB
3164952238,3164953255,FR
3164953256,3164953263,CZ
-3164953264,3164953583,FR
+3164953264,3164953391,FR
+3164953392,3164953399,NL
+3164953400,3164953583,FR
3164953584,3164953599,ES
3164953600,3164954511,FR
3164954512,3164954515,IT
@@ -52586,11 +54873,15 @@
3164968836,3164968839,ES
3164968840,3164969019,FR
3164969020,3164969023,BE
-3164969024,3164970413,FR
+3164969024,3164969039,FR
+3164969040,3164969047,NL
+3164969048,3164970413,FR
3164970414,3164970415,IT
3164970416,3164970923,FR
3164970924,3164970927,LT
-3164970928,3164973419,FR
+3164970928,3164971791,FR
+3164971792,3164971799,IT
+3164971800,3164973419,FR
3164973420,3164973423,ES
3164973424,3164973663,FR
3164973664,3164973695,GB
@@ -52611,7 +54902,8 @@
3165323264,3165388799,ES
3165388800,3165417471,RO
3165417472,3165421567,DE
-3165421568,3165437951,RO
+3165421568,3165425663,IE
+3165425664,3165437951,RO
3165437952,3165454335,AT
3165454336,3165519871,RO
3165519872,3165585407,DE
@@ -52648,14 +54940,19 @@
3166697472,3166699519,RO
3166699520,3166961663,DE
3166961664,3167223807,SI
-3167223808,3167748095,NL
+3167223808,3167321095,NL
+3167321096,3167321099,DE
+3167321100,3167476583,NL
+3167476584,3167476591,DE
+3167476592,3167748095,NL
3167748096,3167762431,RO
3167762432,3167764479,MD
3167764480,3167772671,RO
3167772672,3167773695,MD
3167773696,3167774719,RO
3167774720,3167775743,MD
-3167775744,3167776767,RO
+3167775744,3167776511,RO
+3167776512,3167776767,GB
3167776768,3167777791,MD
3167777792,3167778815,RO
3167778816,3167780863,MD
@@ -52667,11 +54964,14 @@
3167813632,3167815679,MD
3167815680,3167868927,RO
3167868928,3167879167,MD
-3167879168,3167938559,RO
+3167879168,3167895551,DE
+3167895552,3167938559,RO
3167938560,3167939583,MD
3167939584,3167940607,RO
3167940608,3167943679,MD
-3167943680,3167987711,RO
+3167943680,3167944447,RO
+3167944448,3167944703,GB
+3167944704,3167987711,RO
3167987712,3167989759,MD
3167989760,3168005887,RO
3168005888,3168006143,NL
@@ -52685,16 +54985,17 @@
3168020480,3168022527,MD
3168022528,3168038911,RO
3168038912,3168039935,MD
-3168039936,3168050431,RO
+3168039936,3168040959,BE
+3168040960,3168050431,RO
3168050432,3168050687,MD
3168050688,3168081919,RO
-3168081920,3168082943,FR
-3168082944,3168084991,RO
+3168081920,3168083967,FR
+3168083968,3168084991,RO
3168084992,3168086015,MD
3168086016,3168088063,IT
3168088064,3168089087,RO
3168089088,3168090111,MD
-3168090112,3168092159,FR
+3168090112,3168092159,ES
3168092160,3168096255,RO
3168096256,3168100351,MD
3168100352,3168129023,RO
@@ -52709,15 +55010,21 @@
3168156672,3168157695,MD
3168157696,3168165887,RO
3168165888,3168166911,MD
-3168166912,3168176127,RO
+3168166912,3168169983,RO
+3168169984,3168172031,ES
+3168172032,3168176127,RO
3168176128,3168177151,MD
3168177152,3168178175,RO
3168178176,3168179199,MD
-3168179200,3168192511,RO
+3168179200,3168191999,RO
+3168192000,3168192255,GB
+3168192256,3168192511,RO
3168192512,3168194559,MD
3168194560,3168199679,RO
3168199680,3168200703,MD
-3168200704,3168267263,RO
+3168200704,3168202751,RO
+3168202752,3168203775,ES
+3168203776,3168267263,RO
3168267264,3168269311,MD
3168269312,3168271359,RO
3168271360,3168272383,MD
@@ -52745,8 +55052,8 @@
3169189888,3169222655,UA
3169222656,3169255423,SI
3169255424,3169279999,KW
-3169280000,3169282047,GB
-3169282048,3169288191,KW
+3169280000,3169285119,GB
+3169285120,3169288191,KW
3169288192,3169320959,UA
3169320960,3169583103,RU
3169583104,3169648639,KW
@@ -53710,7 +56017,8 @@
3210740480,3210740735,US
3210740736,3210742015,BR
3210742016,3210742031,IT
-3210742032,3210742271,BR
+3210742032,3210742047,US
+3210742048,3210742271,BR
3210742272,3210742527,CL
3210742528,3210742543,KR
3210742544,3210743039,CL
@@ -53718,13 +56026,15 @@
3210743056,3210743295,CL
3210743296,3210743551,US
3210743552,3210743567,TH
-3210743568,3210744063,CL
+3210743568,3210743583,US
+3210743584,3210744063,CL
3210744064,3210744079,TR
3210744080,3210744575,CL
3210744576,3210744591,BE
3210744592,3210745343,CL
3210745344,3210745359,RU
-3210745360,3210745855,CL
+3210745360,3210745375,US
+3210745376,3210745855,CL
3210745856,3210745871,IT
3210745872,3210746367,CL
3210746368,3210746383,SE
@@ -53739,13 +56049,15 @@
3210752000,3210752255,US
3210752256,3210755839,CL
3210755840,3210755855,MY
-3210755856,3210757119,CL
+3210755856,3210755871,US
+3210755872,3210757119,CL
3210757120,3210757375,US
3210757376,3210763519,CL
3210763520,3210763775,US
3210763776,3210764031,CL
3210764032,3210764047,IE
-3210764048,3210765055,CL
+3210764048,3210764063,US
+3210764064,3210765055,CL
3210765056,3210765071,SE
3210765072,3210769919,CL
3210769920,3210770175,US
@@ -53779,7 +56091,9 @@
3210786048,3210786063,AU
3210786064,3210786559,CL
3210786560,3210786575,GR
-3210786576,3210803327,CL
+3210786576,3210803071,CL
+3210803072,3210803087,US
+3210803088,3210803327,CL
3210803328,3210803455,BR
3210803456,3210805247,CL
3210805248,3210809343,PA
@@ -53806,20 +56120,30 @@
3210926080,3210928127,AR
3210928128,3210936319,NI
3210936320,3211067391,EC
-3211067392,3211069439,US
-3211069440,3211073023,CL
+3211067392,3211073023,US
3211073024,3211073279,CA
-3211073280,3211083775,CL
+3211073280,3211073535,US
+3211073536,3211075583,CL
+3211075584,3211075839,US
+3211075840,3211080703,CL
+3211080704,3211080959,NL
+3211080960,3211081215,CL
+3211081216,3211081727,CH
+3211081728,3211083775,CL
3211083776,3211083791,RU
3211083792,3211084287,CL
3211084288,3211084303,NL
-3211084304,3211084799,CL
+3211084304,3211084671,CL
+3211084672,3211084799,BY
3211084800,3211084815,AT
3211084816,3211085311,CL
3211085312,3211085327,GB
-3211085328,3211085823,CL
+3211085328,3211085695,CL
+3211085696,3211085823,GE
3211085824,3211085839,TH
-3211085840,3211086335,CL
+3211085840,3211086095,CL
+3211086096,3211086111,US
+3211086112,3211086335,CL
3211086336,3211086351,FR
3211086352,3211086847,CL
3211086848,3211086863,PL
@@ -53859,7 +56183,13 @@
3211095552,3211095567,GB
3211095568,3211096063,CL
3211096064,3211096079,GB
-3211096080,3211129599,CL
+3211096080,3211096575,CL
+3211096576,3211096831,GB
+3211096832,3211097087,CL
+3211097088,3211097103,DE
+3211097104,3211099647,CL
+3211099648,3211099663,DE
+3211099664,3211129599,CL
3211129600,3211129855,BR
3211129856,3211132927,CL
3211132928,3211137023,CO
@@ -53957,7 +56287,9 @@
3220041472,3220041727,BR
3220041728,3220042239,JP
3220042240,3220042751,BR
-3220042752,3220062207,US
+3220042752,3220043775,US
+3220043776,3220045823,BR
+3220045824,3220062207,US
3220062208,3220062719,SG
3220062720,3220063231,AU
3220063232,3220063743,JP
@@ -53976,12 +56308,13 @@
3220168704,3220172799,US
3220172800,3221225471,BR
3221225480,3221225727,GB
-3221225728,3221225983,US
3221226240,3221226495,US
3221226496,3221227519,KY
3221227520,3221242879,US
3221242880,3221243391,GB
-3221243392,3221258239,US
+3221243392,3221243647,US
+3221243648,3221243903,SG
+3221243904,3221258239,US
3221258240,3221291007,CA
3221291008,3221334269,US
3221334270,3221334270,DZ
@@ -54138,8 +56471,7 @@
3223215104,3223215359,AU
3223215360,3223216383,US
3223216384,3223217151,CA
-3223217152,3223219711,US
-3223220224,3223223295,US
+3223217152,3223223295,US
3223223296,3223223551,AI
3223223552,3223227903,US
3223227904,3223228159,CA
@@ -54150,7 +56482,7 @@
3223236608,3223237631,GB
3223237632,3223243263,US
3223243264,3223243519,CA
-3223243520,3223248895,US
+3223243520,3223249407,US
3223249408,3223249663,CA
3223249664,3223250943,US
3223250944,3223252991,CA
@@ -54173,41 +56505,35 @@
3223267584,3223269119,US
3223269376,3223270399,US
3223270400,3223271423,CA
-3223271424,3223272447,US
+3223271424,3223272959,US
3223272960,3223273215,GB
3223273216,3223283199,US
3223283200,3223283455,NL
3223283456,3223286783,US
3223286784,3223289087,JP
-3223289088,3223289343,US
-3223289856,3223299583,US
+3223289088,3223299583,US
3223299584,3223301119,NL
3223301120,3223302399,US
3223302400,3223302655,CA
+3223302656,3223303167,US
3223303168,3223303423,CA
-3223303424,3223303679,US
-3223304192,3223305215,US
-3223305728,3223307519,US
+3223303424,3223307519,US
3223307520,3223310079,JP
-3223310080,3223310335,US
-3223310848,3223311103,US
+3223310080,3223311103,US
3223311104,3223311359,NL
3223311360,3223314431,US
3223314688,3223315455,US
3223315456,3223315711,CA
3223315712,3223316223,US
3223316224,3223316479,NL
-3223316480,3223319039,US
-3223319552,3223321343,US
+3223316480,3223321343,US
3223321344,3223321599,CA
3223321600,3223321855,FR
-3223321856,3223388159,US
-3223388672,3223390719,US
+3223321856,3223390719,US
3223390720,3223390975,MU
3223390976,3223391999,US
3223392000,3223392511,NL
-3223392512,3223393791,US
-3223394304,3223397375,US
+3223392512,3223397375,US
3223397376,3223397631,NL
3223397632,3223410431,US
3223410432,3223416831,CH
@@ -54217,8 +56543,8 @@
3223418368,3223420927,CH
3223420928,3223421439,US
3223421440,3223421951,NL
-3223422464,3223422719,US
-3223422720,3223422975,AU
+3223421952,3223422719,US
+3223422720,3223422975,JP
3223422976,3223424767,US
3223424768,3223425535,NL
3223425536,3223425791,US
@@ -54235,25 +56561,23 @@
3223449088,3223449343,NL
3223449344,3223453183,US
3223453184,3223453439,NL
-3223453440,3223457791,US
-3223458304,3223458559,US
+3223453440,3223458559,US
3223458560,3223458815,NL
3223458816,3223460351,US
-3223460864,3223461887,US
-3223462400,3223462911,US
+3223460352,3223460863,CA
+3223460864,3223462911,US
3223462912,3223463935,CA
-3223463936,3223465983,US
+3223463936,3223466495,US
3223466496,3223466751,NL
3223466752,3223467007,US
3223467008,3223468031,CA
-3223468032,3223471103,US
+3223468032,3223471615,US
3223471616,3223471871,CA
-3223471872,3223472639,US
+3223471872,3223473151,US
3223473152,3223473215,CA
3223473216,3223473231,US
3223473232,3223474175,CA
-3223474176,3223476223,US
-3223476736,3223477247,US
+3223474176,3223477247,US
3223477248,3223478271,CA
3223478272,3223480319,US
3223480832,3223481087,US
@@ -54280,8 +56604,7 @@
3223534336,3223534591,AU
3223534592,3223535359,US
3223535360,3223537919,DE
-3223537920,3223540991,US
-3223541248,3223542271,US
+3223537920,3223542271,US
3223542272,3223542527,NL
3223542528,3223543295,US
3223543296,3223543551,NL
@@ -54304,7 +56627,7 @@
3223566080,3223568639,NL
3223568640,3223569663,US
3223569664,3223570175,GB
-3223570432,3223571711,US
+3223570176,3223571711,US
3223571712,3223572223,GB
3223572224,3223572479,IE
3223572480,3223577855,US
@@ -54314,8 +56637,7 @@
3223581952,3223582207,US
3223582208,3223582719,NL
3223582720,3223582975,AU
-3223582976,3223583231,US
-3223583488,3223584767,US
+3223582976,3223584767,US
3223584768,3223585023,GB
3223585024,3223585791,SE
3223585792,3223586047,GB
@@ -54375,32 +56697,32 @@
3223781376,3223847935,US
3223848448,3223855103,US
3223855104,3223857151,CA
-3223857152,3223859711,US
-3223859968,3223862271,US
-3223862528,3223862783,US
+3223857152,3223862783,US
3223863296,3223863807,US
+3223864320,3223864575,US
3223864576,3223864831,AE
3223864832,3223865343,HR
3223865344,3223867391,FI
3223867392,3223867647,GB
+3223867648,3223867903,CA
3223868416,3223869439,BM
3223869440,3223871487,US
3223871488,3223873535,CA
-3223873536,3223874559,US
-3223874816,3223875071,US
-3223875584,3223876863,US
+3223873536,3223875071,US
+3223875584,3223877119,US
3223877632,3223881727,US
3223881728,3223882751,CA
-3223883520,3223898111,US
-3223898368,3223898623,US
+3223883264,3223883519,CA
+3223883520,3223898623,US
3223899136,3223902207,US
3223902464,3223902719,CA
3223903232,3223905279,US
3223905280,3223905535,FI
+3223905536,3223905791,US
3223906304,3223909375,CA
3223909376,3223910911,US
3223911936,3223912191,CA
-3223912448,3223938559,US
+3223912192,3223938815,US
3223938816,3223946239,GB
3223946240,3223947519,CH
3223947520,3223947775,US
@@ -54426,11 +56748,11 @@
3223967744,3223967999,NL
3223968000,3223968255,US
3223968256,3223968511,NL
-3223968512,3223970303,US
+3223968512,3223970559,US
3223970560,3223970815,DE
-3223971072,3223977983,US
+3223970816,3223978239,US
3223978240,3223978495,NL
-3223978752,3223979263,US
+3223978496,3223979263,US
3223979264,3223979775,CA
3223979776,3223988735,US
3223988736,3223990271,CH
@@ -54443,38 +56765,34 @@
3223994112,3223994623,DE
3223994880,3223995391,US
3223995392,3223995647,CA
-3223995648,3223996159,US
-3223996416,3223999487,US
+3223995648,3223999487,US
3224000256,3224000511,NL
3224000512,3224001023,US
3224001024,3224001279,CA
-3224001280,3224002559,US
-3224002816,3224003327,US
+3224001280,3224003327,US
3224003328,3224003583,ZA
3224003584,3224003839,NL
3224003840,3224004095,US
3224004096,3224004351,NL
3224004352,3224005631,JP
-3224005632,3224006655,US
+3224005632,3224006911,US
3224006912,3224012031,NL
3224012032,3224014591,US
3224014592,3224014847,NL
3224014848,3224015615,US
3224015872,3224016639,US
3224016640,3224016895,AU
-3224016896,3224017663,US
-3224017920,3224024063,US
+3224016896,3224024063,US
3224024064,3224029695,CH
3224029696,3224030463,CA
+3224030464,3224030719,US
3224030720,3224030975,CA
3224030976,3224038655,US
3224038656,3224038911,AU
3224038912,3224039679,US
-3224039936,3224040959,US
-3224041216,3224042751,US
+3224039936,3224042751,US
3224042752,3224043007,DE
-3224043008,3224043263,US
-3224043520,3224084991,US
+3224043008,3224084991,US
3224084992,3224087551,SE
3224087552,3224088063,US
3224088064,3224088319,AU
@@ -54482,32 +56800,34 @@
3224090880,3224091135,AU
3224091648,3224091903,US
3224091904,3224092159,AU
+3224092160,3224092415,CA
3224092416,3224092671,US
3224092672,3224093951,CH
3224093952,3224094207,US
3224094208,3224094463,AU
3224094464,3224094975,US
3224094976,3224095487,AU
-3224095488,3224096255,US
+3224095488,3224096511,US
3224096512,3224097279,AU
3224097280,3224097535,NL
3224097536,3224097791,US
3224097792,3224098047,NL
-3224098048,3224098559,US
-3224098816,3224099583,US
+3224098048,3224099583,US
3224099584,3224099839,CA
3224099840,3224100863,US
3224101120,3224101375,US
3224101376,3224102399,AU
3224103424,3224103679,NL
-3224103680,3224104447,US
+3224103680,3224104703,US
3224104704,3224104959,AU
3224104960,3224105471,US
3224105728,3224106495,US
-3224106752,3224108799,US
+3224106752,3224109055,US
3224109056,3224109311,NL
3224109312,3224119551,DE
-3224119552,3224129791,FR
+3224119552,3224126463,FR
+3224126976,3224127231,US
+3224127232,3224129791,FR
3224129792,3224132351,DE
3224132352,3224170495,US
3224170496,3224173567,SE
@@ -54859,7 +57179,7 @@
3225664512,3225669887,DE
3225669888,3225671935,US
3225671936,3225672191,AU
-3225672192,3225672447,NL
+3225672192,3225672447,DE
3225672448,3225672703,US
3225672704,3225673215,NL
3225673472,3225673727,IE
@@ -55626,7 +57946,19 @@
3227724032,3227724287,US
3227724288,3227748035,CA
3227748036,3227748039,US
-3227748040,3227779071,CA
+3227748040,3227751868,CA
+3227751869,3227751869,US
+3227751870,3227756505,CA
+3227756506,3227756506,US
+3227756507,3227765503,CA
+3227765504,3227765759,US
+3227765760,3227777759,CA
+3227777760,3227777763,US
+3227777764,3227777951,CA
+3227777952,3227777967,US
+3227777968,3227777983,CA
+3227777984,3227777999,US
+3227778000,3227779071,CA
3227779328,3227779583,MU
3227779584,3227779839,AU
3227779840,3227783679,US
@@ -55679,11 +58011,15 @@
3227827200,3227829759,MX
3227829760,3227830015,BR
3227830016,3227831807,MX
+3227831808,3227832063,BR
3227832064,3227833855,MX
3227833856,3227834367,BR
3227834368,3227837439,MX
+3227837440,3227837951,BR
3227837952,3227842303,MX
+3227842560,3227842815,BR
3227842816,3227843327,MX
+3227843328,3227843583,BR
3227844096,3227844351,AR
3227844864,3227845119,ES
3227845120,3227845631,US
@@ -55964,7 +58300,9 @@
3228406016,3228406271,US
3228406272,3228407039,FR
3228407040,3228420095,DE
-3228420608,3228426239,DE
+3228420608,3228424703,DE
+3228424704,3228424959,US
+3228425216,3228426239,DE
3228426752,3228430847,DE
3228430848,3228431103,MU
3228431104,3228434431,DE
@@ -56006,7 +58344,7 @@
3228532480,3228532735,NL
3228532736,3228554751,US
3228555008,3228558591,US
-3228558592,3228558847,BR
+3228558592,3228559103,BR
3228559104,3228564479,US
3228564480,3228564735,AT
3228564992,3228565247,US
@@ -56578,7 +58916,9 @@
3230897664,3230897919,NL
3230898688,3230898943,US
3230898944,3230899199,NL
-3230899200,3230913535,US
+3230899200,3230913023,US
+3230913024,3230913279,BR
+3230913280,3230913535,US
3230913536,3230913791,NL
3230913792,3230914047,CA
3230914048,3230914303,US
@@ -56934,7 +59274,8 @@
3231483136,3231484927,US
3231484928,3231487999,JP
3231488512,3231488767,JP
-3231489536,3231490047,AU
+3231489536,3231489791,JP
+3231489792,3231490047,AU
3231490048,3231490559,US
3231490560,3231490815,NL
3231490816,3231491071,US
@@ -57359,15 +59700,7 @@
3233288192,3233292287,CA
3233292288,3233431551,US
3233431552,3233447935,CA
-3233447936,3233449095,US
-3233449096,3233449103,GB
-3233449104,3233449207,US
-3233449208,3233449215,GB
-3233449216,3233449359,US
-3233449360,3233449367,GB
-3233449368,3233450199,US
-3233450200,3233450207,GB
-3233450208,3233451519,US
+3233447936,3233451519,US
3233451520,3233451775,GB
3233451776,3233453567,US
3233453568,3233453823,IT
@@ -57399,7 +59732,8 @@
3233564672,3233564927,US
3233564928,3233566719,JP
3233567744,3233568767,JP
-3233568768,3233570047,AU
+3233568768,3233569791,AU
+3233569792,3233570047,JP
3233570048,3233570559,US
3233570816,3233571071,GB
3233571072,3233572095,US
@@ -57428,7 +59762,7 @@
3233583360,3233583615,NL
3233583616,3233584895,US
3233584896,3233585151,AU
-3233585152,3233586431,US
+3233585152,3233586175,US
3233586432,3233586943,NL
3233586944,3233588223,US
3233588224,3233589247,GA
@@ -57722,7 +60056,9 @@
3234226984,3234226991,CA
3234226992,3234227455,US
3234227456,3234227711,CA
-3234227712,3234230015,US
+3234227712,3234228223,US
+3234228224,3234228351,CA
+3234228352,3234230015,US
3234230016,3234230271,ES
3234230272,3234232319,US
3234232320,3234232575,EG
@@ -57846,7 +60182,7 @@
3234809088,3234810879,US
3234810880,3234811135,CA
3234811136,3234814719,US
-3234814720,3234814975,AU
+3234814720,3234814975,HK
3234814976,3234815999,US
3234816000,3234816767,AU
3234816768,3234820351,US
@@ -57897,9 +60233,7 @@
3235004416,3235021823,CA
3235021824,3235026943,US
3235026944,3235028991,CA
-3235028992,3235038463,US
-3235038464,3235038719,GB
-3235038720,3235045375,US
+3235028992,3235045375,US
3235045376,3235046143,CA
3235046144,3235085311,US
3235085312,3235086335,CA
@@ -58207,7 +60541,7 @@
3237328384,3237328639,US
3237328640,3237328895,CA
3237328896,3237329151,US
-3237329152,3237329407,AU
+3237329152,3237329407,NZ
3237329408,3237330943,US
3237330944,3237331199,AU
3237331456,3237331711,US
@@ -58294,7 +60628,8 @@
3237867776,3237868031,GB
3237868032,3237868287,HK
3237868288,3237869311,US
-3237869312,3237869567,CA
+3237869312,3237869439,KR
+3237869440,3237869567,JP
3237869568,3237869823,AU
3237869824,3237869951,PH
3237869952,3237870079,VN
@@ -58931,7 +61266,8 @@
3239691520,3239691775,FR
3239691822,3239691822,GB
3239692032,3239692287,AT
-3239692288,3239695871,DE
+3239692288,3239694847,DE
+3239695360,3239695871,DE
3239697408,3239697663,HR
3239697664,3239697919,RU
3239697920,3239698175,PL
@@ -58975,7 +61311,6 @@
3239741184,3239741439,RU
3239741440,3239759871,DE
3239760128,3239760383,UA
-3239760640,3239760895,PL
3239761408,3239761663,RU
3239761920,3239762175,BG
3239762176,3239762431,RU
@@ -58992,7 +61327,7 @@
3239773952,3239774207,SA
3239774464,3239774719,ES
3239774976,3239775231,PT
-3239775232,3239782399,DE
+3239776256,3239782399,DE
3239782400,3239782655,AT
3239782656,3239782911,RU
3239782912,3239783167,GB
@@ -59034,7 +61369,6 @@
3239828992,3239829503,RU
3239830016,3239830527,CH
3239831040,3239831551,RU
-3239832064,3239832575,UA
3239832576,3239834111,RU
3239834112,3239834623,UA
3239834624,3239835135,AT
@@ -59042,7 +61376,6 @@
3239836672,3239837183,DE
3239837184,3239837695,SE
3239837696,3239837951,PL
-3239838208,3239838463,DE
3239838976,3239839231,DE
3239839232,3239839487,RU
3239839488,3239839743,DE
@@ -59215,9 +61548,7 @@
3240083456,3240085503,RU
3240085504,3240087551,KZ
3240087552,3240097791,DE
-3240098304,3240098815,DE
3240098816,3240099327,CH
-3240099584,3240099839,DE
3240100352,3240100863,GB
3240101376,3240101887,GB
3240102144,3240102399,GB
@@ -59247,7 +61578,7 @@
3240118272,3240120319,ES
3240120320,3240120831,IR
3240120832,3240121343,GB
-3240122368,3240124927,GB
+3240122368,3240123391,GB
3240125440,3240125695,RO
3240125696,3240132607,GB
3240140800,3240142847,GB
@@ -59445,12 +61776,11 @@
3240285184,3240286207,PL
3240286208,3240287231,UA
3240287232,3240288255,PL
-3240288256,3240296447,GB
+3240288256,3240292351,GB
+3240294400,3240296447,GB
3240296448,3240296703,RO
3240297472,3240300543,GB
3240302848,3240303103,UA
-3240303104,3240303359,GB
-3240303616,3240304639,GB
3240304640,3240305663,RU
3240305664,3240305919,PL
3240306176,3240306687,RU
@@ -59500,7 +61830,9 @@
3240373760,3240374015,DE
3240374016,3240374271,GB
3240378368,3240394751,GB
-3240395264,3240398847,GB
+3240395264,3240395775,GB
+3240396032,3240396287,GB
+3240396800,3240398847,GB
3240400896,3240407039,GB
3240407040,3240407295,IL
3240407296,3240407551,NL
@@ -59624,7 +61956,6 @@
3240704000,3240705023,GR
3240705024,3240706047,UA
3240706048,3240707071,BG
-3240707072,3240707839,NL
3240707840,3240709119,FR
3240709120,3240710143,RU
3240710144,3240710399,UA
@@ -59674,7 +62005,7 @@
3240739840,3240740095,DE
3240740096,3240740351,LT
3240740352,3240740607,IT
-3240740608,3240741119,DE
+3240740864,3240741119,DE
3240741120,3240741375,AT
3240741376,3240741631,IL
3240741632,3240741887,RU
@@ -60037,7 +62368,9 @@
3243238400,3243245567,NL
3243245568,3243376639,AT
3243376640,3243442175,GB
-3243442176,3243507711,AT
+3243442176,3243443199,AT
+3243443200,3243443455,DE
+3243443456,3243507711,AT
3243507712,3243507967,GB
3243509248,3243509759,CZ
3243509760,3243510015,RU
@@ -61149,9 +63482,7 @@
3246784512,3246825727,CH
3246825728,3246825983,GB
3246825984,3246826239,US
-3246826240,3246874623,CH
-3246874624,3246875647,DE
-3246875648,3246915583,CH
+3246826240,3246915583,CH
3246915584,3247046655,PT
3247046656,3247046911,AT
3247046912,3247048191,SI
@@ -61243,7 +63574,9 @@
3247112192,3247177727,FR
3247177728,3247243263,TR
3247243264,3247244287,DE
-3247244288,3247253503,NL
+3247244288,3247252319,NL
+3247252320,3247252327,DE
+3247252328,3247253503,NL
3247253504,3247254527,DE
3247254528,3247267839,NL
3247267840,3247268351,DE
@@ -61262,7 +63595,6 @@
3247322368,3247322623,DE
3247322624,3247323135,FI
3247323136,3247323647,RU
-3247323648,3247323903,FI
3247324160,3247324415,FI
3247324416,3247324671,SE
3247324672,3247324927,CH
@@ -61326,7 +63658,7 @@
3247382528,3247390719,FI
3247392256,3247393791,FI
3247394048,3247394303,PL
-3247394304,3247397887,FI
+3247394560,3247397887,FI
3247397888,3247398143,RU
3247398144,3247399167,FI
3247399424,3247399679,RU
@@ -61345,7 +63677,6 @@
3247702016,3247702271,RO
3247702528,3247703551,ES
3247703552,3247704063,FR
-3247705088,3247705855,ES
3247705856,3247706111,RU
3247708160,3247711743,ES
3247711744,3247712255,IT
@@ -61355,9 +63686,7 @@
3247714304,3247716351,CH
3247726592,3247742975,ES
3247742976,3247751167,DE
-3247751168,3247764479,ES
-3247764992,3247765247,ES
-3247766528,3247769599,ES
+3247751168,3247769599,ES
3247769600,3247771647,DE
3247775744,3247783935,DE
3247783936,3247792127,GB
@@ -61443,8 +63772,7 @@
3247909888,3247910911,DE
3247910912,3247912959,PL
3247912960,3247913983,UA
-3247913984,3247914239,DE
-3247914240,3247915007,AT
+3247913984,3247915007,DE
3247915008,3247917055,PL
3247917056,3247918079,NL
3247918080,3247919103,PL
@@ -61474,14 +63802,14 @@
3248490752,3248491007,NO
3248491520,3248492031,RU
3248493568,3248493823,NO
-3248494592,3248496639,NO
+3248494592,3248496127,NO
3248496896,3248497151,IL
3248497152,3248498431,NO
3248498432,3248498687,DE
3248498688,3248504831,NO
3248513280,3248513535,UA
3248513536,3248514047,AT
-3248514560,3248521215,NO
+3248514816,3248521215,NO
3248521984,3248522239,RU
3248522240,3248522751,NO
3248523264,3248524287,NO
@@ -61511,7 +63839,9 @@
3248603648,3248604159,NO
3248604928,3248608767,NO
3248609280,3248619519,NO
-3248619520,3248750591,DK
+3248619520,3248624383,DK
+3248624384,3248624639,US
+3248624640,3248750591,DK
3248750592,3248750847,PT
3248751616,3248752127,PL
3248752640,3248752895,DE
@@ -61692,7 +64022,9 @@
3249141760,3249142271,RU
3249142784,3249143295,UA
3249143296,3249143807,GB
-3249143808,3249274879,AT
+3249143808,3249242879,AT
+3249242880,3249243135,DE
+3249243136,3249274879,AT
3249274880,3249405951,NL
3249405952,3249521279,DE
3249521280,3249521343,UA
@@ -61710,7 +64042,8 @@
3249574912,3249583103,NL
3249583616,3249590527,NL
3249590528,3249590783,FR
-3249590784,3249600255,NL
+3249590784,3249591295,NL
+3249591808,3249600255,NL
3249600256,3249600511,AT
3249600512,3249601535,UA
3249601536,3249601791,RU
@@ -61760,7 +64093,6 @@
3249711360,3249711615,DE
3249711872,3249712127,AT
3249712384,3249712639,GB
-3249712640,3249712895,BE
3249712896,3249713151,DK
3249713152,3249715199,LV
3249715200,3249715455,AT
@@ -62140,7 +64472,6 @@
3250847744,3250978815,DE
3250978816,3251044351,HR
3251044352,3251109887,FI
-3251110144,3251110655,BG
3251110656,3251110911,IT
3251110912,3251111167,FR
3251111168,3251111423,CH
@@ -62733,7 +65064,7 @@
3252587264,3252587519,AT
3252587520,3252587775,UA
3252587776,3252588031,SE
-3252588032,3252600319,CH
+3252588032,3252599807,CH
3252600320,3252600575,NL
3252600576,3252600831,RU
3252600832,3252616703,CH
@@ -63247,7 +65578,6 @@
3254648832,3254649087,GB
3254649088,3254649855,AL
3254649856,3254650879,SE
-3254650880,3254653439,CH
3254653440,3254654847,DE
3254654848,3254654975,DK
3254654976,3254655999,IT
@@ -63386,7 +65716,6 @@
3254828544,3254828799,RO
3254828800,3254829055,SI
3254829056,3254829311,NO
-3254829312,3254829567,GB
3254829568,3254829823,NL
3254829824,3254830079,FR
3254830080,3254830335,IE
@@ -63514,7 +65843,8 @@
3255058432,3255067647,FR
3255068672,3255114751,FR
3255115264,3255117823,FR
-3255118336,3255120639,FR
+3255118336,3255120127,FR
+3255120384,3255120639,FR
3255120640,3255120895,DE
3255120896,3255123711,FR
3255123712,3255123967,DE
@@ -63742,7 +66072,8 @@
3255544576,3255544831,AT
3255544832,3255558143,CH
3255558400,3255558655,UA
-3255558656,3255563263,CH
+3255558656,3255561983,CH
+3255562240,3255563263,CH
3255563776,3255564031,CH
3255564032,3255564287,RU
3255564288,3255565311,CH
@@ -64023,7 +66354,6 @@
3256975360,3256988671,GB
3256988672,3256988927,RU
3256988928,3256989183,UA
-3256989184,3256989439,FR
3256989440,3256989695,GB
3256989696,3256989951,HU
3256989952,3256990207,PL
@@ -64036,8 +66366,9 @@
3257011200,3257011455,BG
3257011456,3257024511,GB
3257024512,3257032703,AU
-3257032704,3257051135,GB
-3257051648,3257057279,GB
+3257032704,3257040895,GB
+3257042944,3257051135,GB
+3257052160,3257057279,GB
3257058816,3257059071,PL
3257059072,3257092607,GB
3257092608,3257092863,RO
@@ -64111,12 +66442,9 @@
3257470976,3257471999,FI
3257472000,3257472511,SG
3257472512,3257475071,FI
-3257475328,3257475583,FI
-3257475584,3257475839,DE
3257476096,3257477119,DE
-3257477120,3257477375,NL
-3257477376,3257477631,SE
-3257479168,3257481471,GB
+3257480192,3257480447,GB
+3257481216,3257481471,GB
3257481472,3257481727,DE
3257481728,3257481983,FI
3257481984,3257482239,FR
@@ -64140,8 +66468,8 @@
3257546688,3257546719,DE
3257546720,3257546751,DK
3257546752,3257548799,IE
-3257548800,3257554943,GB
-3257554944,3257555455,CH
+3257548800,3257555199,GB
+3257555200,3257555455,CH
3257555456,3257556991,GB
3257557504,3257558015,LU
3257558016,3257559039,RO
@@ -64179,7 +66507,9 @@
3257748480,3257749503,DE
3257749504,3257753087,NL
3257753088,3257753343,DE
-3257753344,3257765887,NL
+3257753344,3257759631,NL
+3257759632,3257759639,DE
+3257759640,3257765887,NL
3257765888,3257767935,DE
3257767936,3257782271,NL
3257782272,3257784319,DE
@@ -64213,7 +66543,7 @@
3257987584,3257988095,AT
3257989120,3257991167,AT
3257991168,3257995519,DE
-3257995776,3258003967,DE
+3257996032,3258003967,DE
3258003968,3258004479,RU
3258004480,3258018815,DE
3258019328,3258021887,DE
@@ -64223,7 +66553,7 @@
3258023424,3258023679,TR
3258023680,3258023935,RU
3258023936,3258056703,DE
-3258057216,3258057727,CZ
+3258057216,3258057471,CZ
3258058240,3258058495,RU
3258058496,3258059007,RO
3258059008,3258059263,UA
@@ -64408,7 +66738,9 @@
3258427648,3258427903,RO
3258427904,3258428159,DE
3258428416,3258449919,DE
-3258449920,3258503935,CH
+3258449920,3258486783,CH
+3258486784,3258487807,LI
+3258487808,3258503935,CH
3258503936,3258504191,PL
3258504192,3258504703,CH
3258504704,3258504959,DE
@@ -64429,7 +66761,8 @@
3258693888,3258694143,SI
3258694144,3258694399,RU
3258694656,3258694911,GB
-3258694912,3258712063,DE
+3258694912,3258701823,DE
+3258702848,3258712063,DE
3258712064,3258728447,GB
3258728448,3258729471,FR
3258729472,3258729727,DE
@@ -64449,12 +66782,13 @@
3258733056,3258733311,RO
3258733312,3258734591,GB
3258735104,3258735359,GB
-3258736640,3258762751,GB
+3258736640,3258745855,GB
+3258746880,3258762751,GB
3258763264,3258764287,GB
3258764288,3258764543,DE
3258764800,3258765055,BE
3258765056,3258765311,NL
-3258765312,3258767615,GB
+3258767360,3258767615,GB
3258767616,3258767871,CH
3258767872,3258769919,GB
3258769920,3258770431,PL
@@ -64593,7 +66927,7 @@
3259760640,3259814399,DE
3259814400,3259814655,AT
3259814656,3259816447,DE
-3259816704,3259821823,DE
+3259816704,3259821055,DE
3259821824,3259822079,AT
3259822080,3259823103,DE
3259823104,3259823615,RO
@@ -64696,7 +67030,7 @@
3260678144,3260743679,IL
3260743680,3260809215,IT
3260809216,3260874751,PL
-3260874752,3260893439,DK
+3260891136,3260893439,DK
3260893440,3260894207,SE
3260894208,3260895231,AT
3260895232,3260898303,SE
@@ -64722,7 +67056,8 @@
3261202432,3261213439,FR
3261213440,3261213695,AF
3261213696,3261267967,FR
-3261267968,3261297663,DE
+3261267968,3261281023,DE
+3261281280,3261297663,DE
3261297664,3261297919,RU
3261297920,3261298175,PL
3261298176,3261333503,DE
@@ -64833,7 +67168,7 @@
3261857792,3261923327,CZ
3261923328,3261988863,NL
3261988864,3261989119,SE
-3261989120,3261989887,FI
+3261989120,3261989631,FI
3261990144,3261990399,FI
3261990400,3261990655,UA
3261990656,3261990911,FI
@@ -64862,7 +67197,7 @@
3262017536,3262018559,FI
3262018560,3262018815,PL
3262018816,3262019071,FI
-3262019584,3262021119,FI
+3262020096,3262021119,FI
3262021120,3262021375,UA
3262021376,3262021631,PL
3262021632,3262021887,CH
@@ -64916,7 +67251,6 @@
3262050816,3262051071,CH
3262051072,3262051583,GB
3262051584,3262051839,FR
-3262052352,3262052607,UA
3262052608,3262052863,IL
3262052864,3262053119,GB
3262053120,3262053375,RU
@@ -64968,7 +67302,8 @@
3262227712,3262227967,RO
3262227968,3262229247,DE
3262229248,3262229503,NL
-3262229504,3262283775,DE
+3262229504,3262248191,DE
+3262248448,3262283775,DE
3262283776,3262284799,RU
3262284800,3262286847,UA
3262286848,3262287871,SE
@@ -65038,7 +67373,6 @@
3262460672,3262460927,AE
3262460928,3262461055,CY
3262461056,3262461183,DK
-3262461184,3262461311,SN
3262461312,3262461439,NO
3262461440,3262461567,DE
3262461568,3262461695,GB
@@ -65168,7 +67502,11 @@
3262511104,3262511615,GB
3262512128,3262512639,UA
3262512640,3262513151,DE
-3262513152,3262578687,AT
+3262513152,3262550271,AT
+3262550272,3262550527,DE
+3262550528,3262562815,AT
+3262562816,3262563071,HU
+3262563072,3262578687,AT
3262578688,3262611455,FR
3262611456,3262627839,GB
3262627840,3262636031,IT
@@ -65177,7 +67515,9 @@
3262648320,3262648575,DE
3262648576,3262654463,NL
3262654464,3262654719,DE
-3262654720,3262664703,NL
+3262654720,3262658967,NL
+3262658968,3262658975,DE
+3262658976,3262664703,NL
3262664704,3262670847,DE
3262670848,3262690815,NL
3262690816,3262691583,DE
@@ -65185,7 +67525,9 @@
3262693376,3262701567,DE
3262701568,3262715135,NL
3262715136,3262715391,DE
-3262715392,3262722815,NL
+3262715392,3262718463,NL
+3262718464,3262718471,DE
+3262718472,3262722815,NL
3262722816,3262723071,DE
3262723072,3262732799,NL
3262732800,3262733055,DE
@@ -65194,7 +67536,9 @@
3262754816,3262832639,NL
3262832640,3262840319,DE
3262840320,3262906367,NL
-3262906368,3262964991,CH
+3262906368,3262954495,CH
+3262954496,3262955519,LI
+3262955520,3262964991,CH
3262964992,3262965247,DE
3262965248,3262971903,CH
3262971904,3263029247,IE
@@ -65358,7 +67702,6 @@
3264014848,3264015103,IE
3264015104,3264015359,RO
3264015360,3264015615,DK
-3264015616,3264015871,UA
3264015872,3264016127,PT
3264016128,3264016383,UA
3264016384,3264016639,SE
@@ -65507,13 +67850,18 @@
3264409600,3264410623,RU
3264410624,3264411647,NO
3264411648,3264413695,PL
-3264417536,3264431103,CH
+3264417536,3264419327,CH
+3264423424,3264428031,CH
+3264430592,3264431103,CH
3264431104,3264431615,LI
3264431616,3264431871,CH
3264432128,3264434687,CH
-3264434944,3264441343,CH
+3264434944,3264438783,CH
+3264439296,3264439551,CH
+3264439808,3264441343,CH
3264441344,3264441599,PL
-3264442112,3264444927,CH
+3264442112,3264444415,CH
+3264444672,3264444927,CH
3264444928,3264445183,DE
3264445184,3264445439,CH
3264447488,3264447743,CH
@@ -65564,7 +67912,6 @@
3264624640,3264624671,US
3264624672,3264626687,GB
3264626688,3264627711,EE
-3264627712,3264628735,GR
3264628736,3264630783,UA
3264630784,3264631807,DE
3264631808,3264632831,RO
@@ -65661,7 +68008,6 @@
3264831488,3264831743,CH
3264831744,3264831999,FR
3264832000,3264832255,IE
-3264832256,3264832511,IT
3264832512,3264832767,DE
3264832768,3264833023,IL
3264833536,3264834047,DE
@@ -65681,7 +68027,7 @@
3264840192,3264840447,DE
3264840448,3264840703,IT
3264840704,3264840959,PT
-3264840960,3264841471,PL
+3264841216,3264841471,PL
3264841472,3264841727,LV
3264841728,3264844031,GB
3264844032,3264844287,BG
@@ -65734,11 +68080,10 @@
3264937984,3265003519,GB
3265003520,3265018879,DE
3265018880,3265019903,HK
-3265019904,3265042943,DE
+3265036288,3265042943,DE
3265043456,3265045759,DE
3265045760,3265046015,TR
-3265046016,3265048575,DE
-3265049600,3265055231,DE
+3265046016,3265055231,DE
3265055232,3265055743,FR
3265055744,3265069055,DE
3265069056,3265134591,FI
@@ -65965,7 +68310,8 @@
3266617344,3266634383,DE
3266634392,3266634399,EE
3266634400,3266634431,DE
-3266634464,3266637055,DE
+3266634464,3266634751,DE
+3266635520,3266637055,DE
3266637312,3266641919,DE
3266641920,3266707455,PL
3266707456,3266772991,DK
@@ -66216,7 +68562,9 @@
3268345856,3268411391,GB
3268411392,3268426751,AT
3268426752,3268427775,CH
-3268427776,3268464127,AT
+3268427776,3268463615,AT
+3268463616,3268463871,CH
+3268463872,3268464127,AT
3268464128,3268464383,LI
3268464384,3268476927,AT
3268476928,3268537087,CH
@@ -66406,7 +68754,8 @@
3270644224,3270644735,NL
3270644736,3270645247,DE
3270645760,3270646271,IL
-3270646272,3270647807,RU
+3270646272,3270646783,RU
+3270647296,3270647807,RU
3270647808,3270648063,TR
3270648064,3270648319,RU
3270648320,3270648575,CH
@@ -66928,7 +69277,6 @@
3272480512,3272480767,CH
3272480768,3272481023,DE
3272481024,3272481279,SE
-3272481536,3272481791,FR
3272481792,3272482047,IT
3272482048,3272482303,NL
3272482304,3272482559,PL
@@ -67144,7 +69492,7 @@
3273331712,3273331743,GB
3273331752,3273331791,GB
3273331808,3273331823,GB
-3273331832,3273331887,GB
+3273331828,3273331887,GB
3273331904,3273331967,GB
3273331968,3273332031,DE
3273332032,3273332095,GB
@@ -67157,6 +69505,7 @@
3273334784,3273335039,AE
3273335040,3273335295,DE
3273335296,3273335423,GB
+3273335432,3273335439,GB
3273335936,3273335999,DE
3273336848,3273336863,DE
3273336864,3273336871,GB
@@ -67354,8 +69703,6 @@
3273873920,3273874431,GB
3273874432,3273875455,GR
3273875456,3273875711,PT
-3273875712,3273875967,SE
-3273875968,3273876223,DE
3273876224,3273876479,IT
3273876480,3273876991,SE
3273877248,3273877503,DE
@@ -67640,7 +69987,6 @@
3274690304,3274690559,GB
3274690560,3274690815,GR
3274690816,3274691071,ES
-3274691072,3274691327,DK
3274691328,3274691583,SI
3274691840,3274692095,SI
3274692096,3274692351,RO
@@ -67744,7 +70090,6 @@
3275120640,3275137023,SE
3275137536,3275138047,UA
3275138048,3275138559,DE
-3275138560,3275139071,UA
3275139072,3275139583,PT
3275140096,3275140607,AT
3275140608,3275141119,NL
@@ -68166,7 +70511,7 @@
3276109824,3276110847,BG
3276110848,3276111871,PL
3276111872,3276112895,DK
-3276112896,3276114943,UA
+3276112896,3276113919,UA
3276115968,3276116991,NL
3276116992,3276118015,RU
3276118016,3276119039,GB
@@ -68314,6 +70659,7 @@
3276695040,3276695551,RU
3276695552,3276696063,UA
3276696064,3276696575,RO
+3276696576,3276697087,CZ
3276697088,3276697599,GB
3276697600,3276698111,UA
3276698112,3276699647,RU
@@ -68369,7 +70715,9 @@
3276865536,3276866303,NL
3276866304,3276866559,GB
3276866560,3276866815,IT
-3276866816,3276873983,GB
+3276866816,3276870911,GB
+3276870912,3276871423,IT
+3276871424,3276873983,GB
3276873984,3276874239,ES
3276874240,3276876383,GB
3276876384,3276876415,NL
@@ -68387,7 +70735,9 @@
3276893696,3276893951,IT
3276893952,3276898671,GB
3276898672,3276898687,CH
-3276898688,3276902655,GB
+3276898688,3276902141,GB
+3276902142,3276902142,CH
+3276902143,3276902655,GB
3276902656,3276902911,SE
3276902912,3276903167,GB
3276903168,3276903679,SE
@@ -68406,7 +70756,9 @@
3276912208,3276912215,IT
3276912216,3276912383,GB
3276912384,3276912511,IT
-3276912512,3276912879,GB
+3276912512,3276912671,GB
+3276912672,3276912687,IT
+3276912688,3276912879,GB
3276912880,3276912895,IT
3276912896,3276917231,GB
3276917232,3276917247,FR
@@ -69211,7 +71563,6 @@
3280576512,3280576767,BY
3280576768,3280577279,PL
3280577280,3280577535,DE
-3280577536,3280577791,IL
3280577792,3280578047,NL
3280578048,3280578303,RO
3280578304,3280578559,UA
@@ -69237,7 +71588,6 @@
3280583936,3280584191,PL
3280584192,3280584447,KW
3280584448,3280584703,DE
-3280584704,3280585215,UA
3280585216,3280585727,DK
3280585728,3280586239,UA
3280586240,3280586751,DE
@@ -69905,7 +72255,8 @@
3284016384,3284016639,CH
3284016640,3284017151,DK
3284017152,3284025343,GR
-3284025344,3284030479,GB
+3284025344,3284030471,GB
+3284030472,3284030479,IL
3284030480,3284030495,FR
3284030496,3284033535,GB
3284033536,3284041727,RU
@@ -70365,10 +72716,11 @@
3285913656,3285913703,GB
3285913708,3285913711,FI
3285917696,3285917703,GB
-3285917728,3285917759,GB
+3285917712,3285917759,GB
3285919744,3285921791,QA
3285922048,3285922303,FR
3285924912,3285924919,CH
+3285925164,3285925171,CH
3285926432,3285926463,CH
3285926592,3285926623,DE
3285928304,3285928311,GB
@@ -70550,7 +72902,9 @@
3286662400,3286662655,UA
3286662656,3286662911,DE
3286662912,3286671359,UA
-3286671360,3286679551,AT
+3286671360,3286672639,AT
+3286672640,3286672895,HU
+3286672896,3286679551,AT
3286679552,3286695935,IT
3286695936,3286761471,DK
3286761472,3286773759,GB
@@ -70639,7 +72993,6 @@
3286932736,3286932991,AT
3286932992,3286933247,IL
3286933504,3286933759,DK
-3286933760,3286934015,RO
3286934016,3286934271,BE
3286934272,3286934527,CH
3286934528,3286934783,PL
@@ -70900,7 +73253,6 @@
3287671296,3287671551,PL
3287671552,3287671807,TR
3287671808,3287672063,CH
-3287672064,3287672319,LT
3287672320,3287672575,DE
3287672576,3287672831,NL
3287672832,3287673087,RU
@@ -71157,9 +73509,10 @@
3288485888,3288489983,MA
3288489984,3288514559,ZA
3288514560,3288522751,EG
+3288522752,3288530943,ZA
3288530944,3288532991,JM
3288532992,3288534527,PR
-3288534528,3288535039,MG
+3288534528,3288535039,EG
3288535040,3288539135,CW
3288539136,3288540415,US
3288540416,3288540671,BR
@@ -71244,7 +73597,7 @@
3289021440,3289024767,ZA
3289024768,3289025023,GH
3289025024,3289025535,UG
-3289026048,3289027327,ZA
+3289025536,3289027327,ZA
3289027328,3289027583,TZ
3289027584,3289027839,MZ
3289027840,3289041407,ZA
@@ -71302,10 +73655,12 @@
3289217280,3289217535,KE
3289218560,3289220351,ZA
3289220352,3289220607,TZ
+3289220608,3289221119,ZA
3289221632,3289229311,ZA
3289229312,3289229567,SZ
3289229824,3289230591,ZA
3289233408,3289233919,ZA
+3289233920,3289234175,TZ
3289234176,3289235199,ZA
3289235200,3289235455,KE
3289237504,3289243391,ZA
@@ -71408,8 +73763,7 @@
3291045888,3291078655,ZA
3291078656,3291086847,DZ
3291086848,3291103231,PR
-3291103232,3291119615,ZA
-3291152384,3291168767,ZA
+3291103232,3291168767,ZA
3291168768,3291176959,TZ
3291176960,3291185151,ZW
3291185152,3291201535,UG
@@ -71542,6 +73896,7 @@
3291546368,3291546623,BI
3291546624,3291546879,SZ
3291546880,3291547135,TZ
+3291547136,3291547391,AO
3291742208,3292004351,US
3292004352,3292266495,SC
3292397568,3292528639,ZA
@@ -71552,7 +73907,7 @@
3300937728,3300938751,MU
3300941824,3300950015,MU
3300953088,3300954111,MU
-3300982784,3301113855,ZA
+3300966400,3301113855,ZA
3301113856,3301146623,NG
3301146624,3301175295,ZA
3301175296,3301177343,AF
@@ -71729,7 +74084,7 @@
3302957824,3302958079,NA
3302958080,3302958335,BI
3302958336,3302958591,SZ
-3302985728,3302987775,MU
+3302958592,3302958847,DJ
3304062976,3304456191,SC
3304456192,3304521727,NG
3304521728,3304587263,SC
@@ -72114,9 +74469,15 @@
3323682960,3323684863,CA
3323684864,3323685375,US
3323685376,3323685887,CA
-3323685888,3323687423,US
-3323687424,3323688959,CA
-3323688960,3323689471,US
+3323685888,3323686399,US
+3323686400,3323686911,CA
+3323686912,3323687423,US
+3323687424,3323687935,CA
+3323687936,3323687999,US
+3323688000,3323688959,CA
+3323688960,3323689199,US
+3323689200,3323689215,BY
+3323689216,3323689471,US
3323689472,3323690495,CA
3323690496,3323741439,US
3323741440,3323741695,GB
@@ -72565,13 +74926,17 @@
3328479232,3328481279,CA
3328481280,3328481791,US
3328481792,3328482303,CA
-3328482304,3328510064,US
+3328482304,3328483071,US
+3328483072,3328483327,CA
+3328483328,3328510064,US
3328510065,3328510077,AE
3328510078,3328515071,US
3328515072,3328516095,DM
3328516096,3328617983,US
3328617984,3328618239,CA
-3328618240,3328630015,US
+3328618240,3328629631,US
+3328629632,3328629695,GB
+3328629696,3328630015,US
3328630016,3328630271,CA
3328630272,3328630783,US
3328630784,3328631807,CA
@@ -72726,7 +75091,8 @@
3332491264,3332492031,US
3332492032,3332500735,CA
3332500736,3332500991,US
-3332500992,3332503039,CA
+3332500992,3332501247,CA
+3332501504,3332503039,CA
3332503040,3332503551,US
3332503552,3332505343,CA
3332505344,3332505855,US
@@ -72839,7 +75205,9 @@
3333624320,3333624575,CA
3333624576,3333675775,US
3333675776,3333676031,CA
-3333676032,3333701887,US
+3333676032,3333677311,US
+3333677312,3333677567,HK
+3333677568,3333701887,US
3333701888,3333702143,GB
3333702144,3333702399,US
3333702400,3333702655,CH
@@ -73428,13 +75796,7 @@
3343364096,3343365631,US
3343365632,3343366655,CA
3343366912,3343372543,CA
-3343372800,3343378511,US
-3343378512,3343378519,GB
-3343378520,3343378535,US
-3343378536,3343378543,GB
-3343378544,3343378575,US
-3343378576,3343378583,GB
-3343378584,3343378823,US
+3343372800,3343378823,US
3343378824,3343378839,SE
3343378840,3343379079,US
3343379080,3343379087,SE
@@ -73530,6 +75892,7 @@
3344678912,3344681983,US
3344681984,3344685055,CA
3344685056,3344691199,US
+3344691200,3344693247,CA
3344693248,3344694271,US
3344694272,3344695295,CA
3344695296,3344937471,US
@@ -73877,9 +76240,7 @@
3351336960,3351339007,CA
3351339008,3351357439,US
3351357440,3351359487,CA
-3351359488,3351364607,US
-3351364608,3351365119,AU
-3351365120,3351372799,US
+3351359488,3351372799,US
3351372800,3351373823,BM
3351373824,3351380223,US
3351380224,3351380479,CA
@@ -74066,7 +76427,9 @@
3353653504,3353653759,GB
3353653760,3353722367,US
3353722368,3353722623,GB
-3353722624,3353729023,US
+3353722624,3353726975,US
+3353726976,3353727231,IN
+3353727232,3353729023,US
3353729024,3353729279,HK
3353729280,3353730047,US
3353730048,3353731071,CA
@@ -74188,7 +76551,8 @@
3355459840,3355460095,VE
3355460096,3355460351,CL
3355460352,3355460607,BR
-3355460864,3355461631,BR
+3355460608,3355460863,UY
+3355460864,3355461887,BR
3355461888,3355463423,EC
3355463424,3355463935,AR
3355463936,3355464191,BR
@@ -74196,7 +76560,9 @@
3355464448,3355464959,MX
3355464960,3355465727,BR
3355465728,3355465983,UY
+3355466240,3355466751,MX
3355466752,3355467007,BR
+3355467008,3355467263,MX
3355467264,3355467519,US
3355467520,3355467775,MX
3355467776,3355468799,AR
@@ -74867,10 +77233,13 @@
3357581312,3357589503,CL
3357589504,3357605887,BZ
3357605888,3357606911,MX
+3357606912,3357607167,AR
3357607168,3357613055,MX
+3357613056,3357613311,AR
3357613312,3357616127,MX
3357616384,3357618943,MX
3357619200,3357623039,MX
+3357623040,3357623295,AR
3357623296,3357626623,MX
3357627392,3357627647,MX
3357627904,3357628415,MX
@@ -74888,9 +77257,12 @@
3357648896,3357650431,MX
3357650944,3357657855,MX
3357658112,3357670655,MX
-3357670912,3357712383,MX
+3357670912,3357671423,MX
+3357671424,3357671679,CO
+3357671680,3357712383,MX
3357712384,3357713407,BR
3357713408,3357715199,MX
+3357715200,3357715455,CO
3357715456,3357715711,MX
3357715968,3357723903,MX
3357724416,3357725183,MX
@@ -75317,7 +77689,7 @@
3361538048,3361570815,VE
3361570816,3361587199,CO
3361587200,3361599487,EC
-3361599488,3361601279,UY
+3361599488,3361601535,UY
3361601536,3361603583,EC
3361603584,3361665023,MX
3361665024,3361667071,BR
@@ -75503,7 +77875,7 @@
3363684352,3363708927,EC
3363708928,3363713023,CL
3363713024,3363713279,EC
-3363713536,3363714047,CL
+3363713280,3363714047,CL
3363714048,3363717119,PE
3363717120,3363733503,CL
3363733504,3363831807,AR
@@ -75522,9 +77894,12 @@
3368087552,3370188799,BR
3370188800,3370196991,MX
3370196992,3370487807,BR
+3370487808,3370488831,CR
3370488832,3370489855,AR
3370489856,3370490879,VE
-3370490880,3370514943,BR
+3370490880,3370506239,BR
+3370506240,3370507263,VE
+3370507264,3370514943,BR
3370515456,3370516479,AR
3370516480,3376873471,BR
3376881664,3376922623,BR
@@ -75538,13 +77913,16 @@
3380745216,3380746239,BR
3380746240,3380747263,PE
3380747264,3380748287,BR
-3380748288,3380760831,MX
+3380748288,3380761087,MX
+3380761088,3380761599,VE
3380761600,3380764671,BR
3380764672,3380808191,MX
3380808704,3380811775,MX
3380811776,3380813823,BR
3380813824,3380815103,MX
+3380815104,3380815359,CR
3380815872,3380816127,MX
+3380816128,3380816383,BO
3380816896,3380817151,MX
3380817920,3380818175,MX
3380818944,3380822527,MX
@@ -75564,7 +77942,8 @@
3380837376,3380840447,MX
3380840448,3380843519,BR
3380843520,3380844543,PA
-3380844544,3380854783,BR
+3380844544,3380853759,BR
+3380853760,3380854783,CO
3380854784,3380858879,MX
3380858880,3380860927,BR
3380860928,3380861951,CO
@@ -75573,7 +77952,8 @@
3380865024,3380867071,MX
3380867072,3380869119,BR
3380869120,3381350399,MX
-3381350400,3381354495,BR
+3381350400,3381351423,AR
+3381351424,3381354495,BR
3381354496,3381373951,MX
3381373952,3381374975,BR
3381374976,3381377023,MX
@@ -75585,20 +77965,37 @@
3381452800,3381453823,AR
3381453824,3381455871,BR
3381455872,3381456895,CO
+3381456896,3381460991,BR
3381460992,3381944319,MX
-3381947392,3381948415,BR
+3381944320,3381946367,BR
+3381946368,3381947391,CL
+3381947392,3381952511,BR
3381952512,3381960703,MX
+3381960704,3381962751,BR
+3381962752,3381963775,HN
+3381963776,3381968895,BR
3381968896,3381972991,MX
3381972992,3381974015,BR
3381974016,3381975039,CL
-3381976064,3381977087,BR
+3381975040,3381979135,BR
+3381979136,3381980159,CR
+3381980160,3381985279,BR
3381985280,3382009855,MX
+3382009856,3382018047,BR
3382018048,3382053887,MX
-3382053888,3382059007,BR
+3382053888,3382057983,BR
+3382057984,3382059007,CL
3382059008,3382063103,MX
-3382063104,3382064127,BR
+3382063104,3382066175,BR
+3382066176,3382067199,PE
3382067200,3382071295,MX
-3382071296,3382075391,BR
+3382071296,3382072319,BR
+3382072320,3382073343,SV
+3382073344,3382075391,BR
+3382075392,3382076415,CO
+3382076416,3382077439,BR
+3382077440,3382078463,HT
+3382078464,3382083583,BR
3382083584,3382087679,MX
3382087680,3382091775,BR
3382091776,3382099967,BO
@@ -75631,8 +78028,9 @@
3382661120,3382662143,MX
3382662144,3382665215,BR
3382665216,3382669311,MX
-3382669312,3382673407,BR
-3382673408,3382677503,MX
+3382669312,3382670335,GT
+3382670336,3382672383,BR
+3382672384,3382677503,MX
3382677504,3382681599,BR
3382681600,3382683647,MX
3382683648,3382685695,CL
@@ -75642,7 +78040,7 @@
3382695936,3382696959,AR
3382696960,3382697983,EC
3382697984,3382704127,MX
-3382704128,3382705151,BR
+3382704128,3382706175,BR
3382706176,3382853631,MX
3382853632,3382870015,BR
3382870016,3383630843,MX
@@ -75737,7 +78135,7 @@
3386761216,3386769407,PA
3386769408,3386773503,VE
3386773504,3386774527,AR
-3386775552,3386776575,BR
+3386774528,3386777599,BR
3386777600,3386781695,CW
3386781696,3386783743,PY
3386783744,3386784767,AR
@@ -75880,11 +78278,7 @@
3389197824,3389198079,ID
3389198080,3389198335,IN
3389198336,3389202431,KR
-3389202432,3389203455,NZ
-3389203456,3389203967,AU
-3389203968,3389204223,NZ
-3389204224,3389204479,AU
-3389204480,3389210623,NZ
+3389202432,3389210623,AU
3389210624,3389210879,IN
3389210880,3389211135,AU
3389211136,3389211391,IN
@@ -76065,7 +78459,8 @@
3389595648,3389595903,CN
3389595904,3389596159,AU
3389596160,3389596671,CN
-3389596672,3389597695,MY
+3389596672,3389597439,SG
+3389597440,3389597695,MY
3389597696,3389599743,MN
3389599744,3389600255,CN
3389600256,3389600511,AU
@@ -76102,7 +78497,7 @@
3389661184,3389669375,ID
3389669376,3389673471,CN
3389673472,3389677567,AU
-3389677568,3389681663,JP
+3389677568,3389685759,JP
3389685760,3389718527,AU
3389718528,3389784063,JP
3389784064,3389784319,NZ
@@ -76111,8 +78506,8 @@
3389785088,3389786111,HK
3389786112,3389788159,JP
3389788160,3389788415,IN
-3389788416,3389789183,CN
-3389789184,3389789695,TH
+3389788416,3389788927,CN
+3389788928,3389789695,US
3389789696,3389790719,AU
3389790720,3389790975,BN
3389790976,3389791231,JP
@@ -76157,7 +78552,7 @@
3389919232,3389931519,NZ
3389931520,3389932031,CN
3389932032,3389932287,AU
-3389932288,3389932799,HK
+3389932288,3389932799,JP
3389932800,3389933055,CN
3389933056,3389933567,PK
3389933568,3389933823,IN
@@ -76243,7 +78638,8 @@
3390310400,3390316543,AU
3390316544,3390325247,NZ
3390325248,3390325503,CN
-3390325504,3390327807,AU
+3390325504,3390325759,AU
+3390326016,3390327807,AU
3390327808,3390328575,NZ
3390328576,3390328831,CN
3390328832,3390329087,NZ
@@ -76264,7 +78660,7 @@
3390337024,3390337279,GU
3390337280,3390337535,NZ
3390337536,3390337791,CN
-3390337792,3390338303,SG
+3390337792,3390338303,JP
3390338304,3390338559,CN
3390338560,3390338815,HK
3390338816,3390339071,KR
@@ -76291,7 +78687,7 @@
3390409984,3390410495,CN
3390410496,3390410751,NZ
3390410752,3390411007,TH
-3390411008,3390411519,SG
+3390411008,3390411519,JP
3390411520,3390412031,CN
3390412032,3390412287,TH
3390412288,3390413567,CN
@@ -76386,8 +78782,7 @@
3391664128,3391668223,BD
3391668224,3391676415,HK
3391676416,3391684607,SG
-3391684608,3391685631,IN
-3391685632,3391686655,AU
+3391684608,3391686655,IN
3391686656,3391687167,CN
3391687168,3391687423,IN
3391687424,3391688191,CN
@@ -76407,85 +78802,16 @@
3391725568,3391733759,TH
3391733760,3391734015,CN
3391734016,3391734783,AU
+3391735808,3391736831,JP
3391736832,3391737855,IN
3391737856,3391741951,JP
-3391741952,3391742207,HK
-3391742208,3391742211,IN
-3391742212,3391742223,HK
-3391742224,3391742227,IN
-3391742228,3391742231,HK
-3391742232,3391742243,IN
-3391742244,3391742287,HK
-3391742288,3391742291,IN
-3391742292,3391742319,HK
-3391742320,3391742323,IN
-3391742324,3391742327,HK
-3391742328,3391742331,IN
-3391742332,3391742335,HK
-3391742336,3391742343,IN
-3391742344,3391742347,HK
-3391742348,3391742351,IN
-3391742352,3391742399,HK
-3391742400,3391742403,IN
-3391742404,3391742423,HK
-3391742424,3391742427,IN
-3391742428,3391742443,HK
-3391742444,3391742447,IN
-3391742448,3391742471,HK
-3391742472,3391742475,IN
-3391742476,3391742523,HK
-3391742524,3391742531,IN
-3391742532,3391742571,HK
-3391742572,3391742575,IN
-3391742576,3391742591,HK
-3391742592,3391742595,IN
-3391742596,3391742687,HK
-3391742688,3391742691,IN
-3391742692,3391742719,HK
-3391742720,3391742727,IN
-3391742728,3391742731,HK
-3391742732,3391742735,IN
-3391742736,3391742847,HK
-3391742848,3391742879,IN
-3391742880,3391742903,HK
-3391742904,3391742919,IN
-3391742920,3391742927,HK
-3391742928,3391742935,IN
-3391742936,3391742943,HK
-3391742944,3391742951,IN
-3391742952,3391742983,HK
-3391742984,3391742991,IN
-3391742992,3391743135,HK
-3391743136,3391743151,IN
-3391743152,3391743175,HK
-3391743176,3391743199,IN
-3391743200,3391743359,HK
-3391743360,3391743391,IN
-3391743392,3391743743,HK
-3391743744,3391743759,IN
-3391743760,3391744039,HK
-3391744040,3391744063,IN
-3391744064,3391744111,HK
-3391744112,3391744119,IN
-3391744120,3391744271,HK
-3391744272,3391744367,IN
-3391744368,3391744383,HK
-3391744384,3391744447,IN
-3391744448,3391744511,HK
-3391744512,3391744519,IN
-3391744520,3391744535,HK
-3391744536,3391744543,IN
-3391744544,3391744791,HK
-3391744792,3391744799,IN
-3391744800,3391744823,HK
-3391744824,3391744831,IN
-3391744832,3391745055,HK
-3391745056,3391745087,IN
-3391745088,3391745279,HK
-3391745280,3391745295,IN
-3391745296,3391746047,HK
+3391741952,3391746047,IN
3391746048,3391750143,CN
-3391750144,3391815679,SG
+3391750144,3391766783,SG
+3391766784,3391767039,JP
+3391767040,3391810047,SG
+3391810048,3391810303,JP
+3391810304,3391815679,SG
3391815680,3391817727,AU
3391817728,3391819775,TO
3391819776,3391823871,JP
@@ -76514,7 +78840,9 @@
3391852544,3391856639,CN
3391856640,3391864831,ID
3391864832,3391866879,TW
-3391866880,3391873023,US
+3391866880,3391868927,US
+3391868928,3391870975,SG
+3391870976,3391873023,US
3391873024,3391877119,AU
3391877120,3391879167,JP
3391879168,3391881215,ID
@@ -76687,7 +79015,6 @@
3392440832,3392441343,BD
3392441344,3392441855,ID
3392441856,3392442111,AU
-3392442368,3392442623,HK
3392442624,3392442879,AU
3392442880,3392443391,ID
3392443392,3392443647,IN
@@ -76711,7 +79038,8 @@
3392479232,3392487423,AU
3392487424,3392499711,IN
3392499712,3392503807,JP
-3392503808,3392511999,HK
+3392503808,3392505343,HK
+3392506880,3392507903,HK
3392512000,3392516095,BD
3392516096,3392520191,NZ
3392520192,3392524287,AU
@@ -76926,7 +79254,9 @@
3393314816,3393318911,ID
3393318912,3393320959,SG
3393320960,3393363967,HK
-3393372160,3393388543,HK
+3393372160,3393374975,HK
+3393374976,3393375743,SG
+3393375744,3393388543,HK
3393388544,3393389567,CN
3393389568,3393390591,IN
3393390592,3393392639,ID
@@ -76977,7 +79307,7 @@
3393620992,3393621247,JP
3393621248,3393622015,AU
3393622016,3393626111,PK
-3393626112,3393630207,HK
+3393626112,3393630207,CN
3393630208,3393634303,JP
3393634304,3393638399,CN
3393638400,3393650687,JP
@@ -77048,9 +79378,11 @@
3393867776,3393871871,CN
3393871872,3393874943,HK
3393874944,3393875967,AU
-3393875968,3393878271,HK
-3393878272,3393878527,IN
-3393878528,3393880063,HK
+3393875968,3393876991,HK
+3393876992,3393878015,SG
+3393878016,3393879039,IN
+3393879040,3393879551,JP
+3393879552,3393880063,HK
3393880064,3393896447,AU
3393896448,3393906687,NZ
3393908736,3393910783,BD
@@ -77094,7 +79426,9 @@
3394078720,3394078975,AU
3394078976,3394079231,IN
3394079232,3394079743,PH
-3394079744,3394111487,HK
+3394079744,3394087471,HK
+3394087472,3394087487,CN
+3394087488,3394111487,HK
3394111488,3394113535,CN
3394113536,3394117631,SG
3394117632,3394121727,AU
@@ -77218,7 +79552,6 @@
3394756608,3394760703,JP
3394760704,3394764799,ID
3394764800,3394772991,HK
-3394772992,3394775039,PK
3394777088,3394781183,JP
3394781184,3394789375,MP
3394789376,3394797567,HK
@@ -77229,12 +79562,24 @@
3394830336,3394831359,HK
3394831360,3394832383,NZ
3394832384,3394834431,CN
-3394834432,3394836479,HK
+3394834432,3394834687,HK
+3394834688,3394834943,JP
+3394834944,3394834959,HK
+3394834960,3394834975,JP
+3394834976,3394834983,HK
+3394834984,3394834991,SG
+3394834992,3394835199,HK
+3394835200,3394835455,JP
+3394835456,3394835583,SG
+3394835584,3394835711,JP
+3394835712,3394835967,CN
+3394835968,3394836223,HK
+3394836224,3394836239,JP
+3394836240,3394836247,AS
+3394836248,3394836415,JP
+3394836416,3394836479,HK
3394836480,3394838527,BT
-3394838528,3394844671,NZ
-3394844672,3394845695,AU
-3394845696,3394846207,NZ
-3394846208,3394846719,AU
+3394838528,3394846719,NZ
3394846720,3394850815,IN
3394850816,3394854911,JP
3394855936,3394856959,AU
@@ -77468,44 +79813,9 @@
3397279744,3397283839,AU
3397283840,3397285887,KR
3397285888,3397287935,BD
-3397287936,3397296175,SG
-3397296176,3397296191,HK
-3397296192,3397296271,SG
-3397296272,3397296279,HK
-3397296280,3397296479,SG
-3397296480,3397297263,HK
-3397297264,3397297271,SG
-3397297272,3397297295,HK
-3397297296,3397297311,SG
-3397297312,3397297407,HK
-3397297408,3397297439,SG
-3397297440,3397297919,HK
-3397297920,3397297983,SG
-3397297984,3397298015,HK
-3397298016,3397298071,SG
-3397298072,3397298079,HK
-3397298080,3397298431,SG
-3397298432,3397298495,HK
-3397298496,3397298511,SG
-3397298512,3397298559,HK
-3397298560,3397298943,SG
-3397298944,3397298959,HK
-3397298960,3397299047,SG
-3397299048,3397299055,HK
-3397299056,3397299183,SG
-3397299184,3397299191,HK
-3397299192,3397299359,SG
+3397287936,3397299359,SG
3397299360,3397299375,IN
-3397299376,3397299455,SG
-3397299456,3397299483,HK
-3397299484,3397299487,SG
-3397299488,3397299599,HK
-3397299600,3397299603,SG
-3397299604,3397304211,HK
-3397304212,3397304215,SG
-3397304216,3397304299,HK
-3397304300,3397304303,SG
-3397304304,3397304319,HK
+3397299376,3397304319,SG
3397304320,3397308415,NZ
3397308416,3397312511,HK
3397312512,3397320703,JP
@@ -77637,9 +79947,19 @@
3397812224,3397816319,CN
3397816320,3397832703,IN
3397836800,3397844991,AU
-3397844992,3397869823,JP
+3397844992,3397857791,JP
+3397857792,3397858047,AU
+3397858048,3397862143,JP
+3397862144,3397862399,PH
+3397862400,3397869823,JP
3397869824,3397870079,AU
-3397870080,3397910527,JP
+3397870080,3397878527,JP
+3397878528,3397878783,TW
+3397878784,3397881855,JP
+3397881856,3397882111,HK
+3397882112,3397887999,JP
+3397888000,3397888768,IN
+3397888769,3397910527,JP
3397910528,3397918719,SG
3397918720,3397922815,AU
3397922816,3397926911,CN
@@ -77738,13 +80058,19 @@
3398619136,3398621183,AU
3398621184,3398623231,HK
3398623232,3398631423,ID
-3398631424,3398637119,JP
+3398631424,3398634439,JP
+3398634440,3398634447,KR
+3398634448,3398636543,JP
+3398636544,3398636575,HK
+3398636576,3398637119,JP
3398637120,3398637183,HK
3398637184,3398637823,JP
3398637824,3398638079,PH
3398638080,3398639903,JP
3398639904,3398639907,MY
-3398639908,3398641407,JP
+3398639908,3398640671,JP
+3398640672,3398640695,SG
+3398640696,3398641407,JP
3398641408,3398641663,MY
3398641664,3398641919,JP
3398641920,3398642175,AU
@@ -77957,14 +80283,17 @@
3399946240,3399950335,HK
3399950336,3399954943,AU
3399954944,3399974911,US
-3399974912,3399983744,MY
+3399974912,3399979007,HK
+3399979008,3399983744,US
3399983745,3399983745,SG
-3399983746,3399991295,MY
+3399983746,3399991295,US
3399991296,3399995391,IN
3399995392,3399999487,KR
3399999488,3400000255,SG
3400000256,3400000511,AU
-3400000512,3400004607,SG
+3400000512,3400002303,SG
+3400002304,3400002367,HK
+3400002368,3400004607,SG
3400004608,3400004863,AU
3400004864,3400005119,SG
3400005120,3400005375,AU
@@ -78096,7 +80425,9 @@
3400647936,3400648191,AU
3400648192,3400648815,SG
3400648816,3400648831,HK
-3400648832,3400650239,SG
+3400648832,3400649943,SG
+3400649944,3400649951,HK
+3400649952,3400650239,SG
3400650240,3400654847,AU
3400654848,3400663039,IN
3400663040,3400683519,MY
@@ -78214,7 +80545,9 @@
3405820160,3405820415,CN
3405820416,3405832191,AU
3405832192,3405832447,CN
-3405832448,3405841407,AU
+3405832448,3405839359,AU
+3405839360,3405840383,HK
+3405840384,3405841407,AU
3405841408,3405842431,CN
3405842432,3405844991,AU
3405844992,3405845247,CN
@@ -78261,7 +80594,7 @@
3405960704,3405961215,CN
3405961216,3405963775,AU
3405963776,3405964287,CN
-3405964288,3405964543,AU
+3405964288,3405964543,JP
3405964544,3405964799,CN
3405964800,3405966335,AU
3405966336,3405966847,CN
@@ -78291,7 +80624,9 @@
3406008064,3406008319,CN
3406008320,3406070783,AU
3406070784,3406071551,CN
-3406071552,3406075647,AU
+3406071552,3406071807,AU
+3406071808,3406073855,US
+3406073856,3406075647,AU
3406075648,3406076927,CN
3406076928,3406077951,AU
3406077952,3406078207,TH
@@ -78394,7 +80729,8 @@
3406299392,3406301183,AU
3406301184,3406301439,CN
3406301440,3406305023,AU
-3406305024,3406307327,CN
+3406305024,3406305279,CN
+3406305280,3406307327,HK
3406307328,3406317055,AU
3406317056,3406317311,CN
3406317312,3406320127,AU
@@ -78459,7 +80795,9 @@
3406405120,3406405375,CN
3406405376,3406409727,AU
3406409728,3406411775,NZ
-3406411776,3406434303,AU
+3406411776,3406413311,AU
+3406413312,3406413823,JP
+3406413824,3406434303,AU
3406434304,3406436351,MY
3406436352,3406438911,AU
3406438912,3406439167,CN
@@ -78518,15 +80856,20 @@
3406566400,3406566911,ID
3406566912,3406567423,AU
3406567424,3406567679,CN
-3406567680,3406575871,AU
+3406567680,3406572031,AU
+3406572032,3406572287,JP
+3406572288,3406575871,AU
3406575872,3406576127,CN
3406576128,3406577919,AU
3406577920,3406578431,CN
3406578432,3406579199,AU
3406579200,3406579711,CN
3406579712,3406583295,AU
-3406583552,3406585855,CN
-3406585856,3406586879,AU
+3406583552,3406583807,CN
+3406583808,3406585855,HK
+3406585856,3406586111,AU
+3406586112,3406586367,JP
+3406586368,3406586879,AU
3406586880,3406587391,CN
3406587392,3406587647,AU
3406587648,3406587903,CN
@@ -78539,7 +80882,8 @@
3406594816,3406596351,AU
3406596352,3406596607,CN
3406596608,3406611455,AU
-3406611456,3406614527,CN
+3406611456,3406612479,CN
+3406612480,3406614527,HK
3406614528,3406615295,AU
3406615296,3406615551,CN
3406615552,3406617343,AU
@@ -78562,7 +80906,8 @@
3406637312,3406638079,AU
3406638080,3406638591,CN
3406638592,3406647295,AU
-3406647296,3406649855,CN
+3406647296,3406649343,HK
+3406649344,3406649855,CN
3406649856,3406650367,AU
3406650368,3406651391,CN
3406651392,3406664191,AU
@@ -78575,7 +80920,8 @@
3406684160,3406684671,CN
3406684672,3406684927,AU
3406684928,3406685183,CN
-3406685184,3406686463,AU
+3406685184,3406685951,AU
+3406686208,3406686463,AU
3406686464,3406686719,CN
3406686720,3406696959,AU
3406696960,3406697215,IN
@@ -78601,7 +80947,8 @@
3406737408,3406737663,ID
3406737664,3406739199,AU
3406739200,3406739455,ID
-3406739456,3406741759,CN
+3406739456,3406741503,HK
+3406741504,3406741759,CN
3406741760,3406742015,AU
3406742016,3406742527,CN
3406742528,3406746623,AU
@@ -78616,7 +80963,9 @@
3406757888,3406761983,CN
3406761984,3406763007,AU
3406763008,3406763775,CN
-3406763776,3406780159,AU
+3406763776,3406775295,AU
+3406775296,3406775551,JP
+3406775552,3406780159,AU
3406780160,3406780927,CN
3406780928,3406784767,AU
3406784768,3406785023,CN
@@ -78690,7 +81039,9 @@
3406911488,3406911999,CN
3406912000,3406923775,AU
3406923776,3406924031,CN
-3406924032,3406930943,AU
+3406924032,3406930431,AU
+3406930432,3406930687,JP
+3406930688,3406930943,AU
3406930944,3406931199,CN
3406931200,3406936831,AU
3406936832,3406937087,CN
@@ -78819,7 +81170,8 @@
3407089920,3407090175,CN
3407090176,3407095807,AU
3407095808,3407096319,CN
-3407096576,3407097855,AU
+3407096576,3407096831,AU
+3407097088,3407097855,AU
3407097856,3407098111,CN
3407098112,3407101183,AU
3407101184,3407101439,CN
@@ -78926,7 +81278,9 @@
3407261696,3407263743,CN
3407263744,3407266303,AU
3407266304,3407266559,CN
-3407266560,3407278591,AU
+3407266560,3407268863,AU
+3407268864,3407269119,US
+3407269120,3407278591,AU
3407278592,3407279103,CN
3407279104,3407279359,AU
3407279360,3407279871,CN
@@ -79007,7 +81361,9 @@
3407377408,3407377663,CN
3407377664,3407378943,AU
3407378944,3407379455,CN
-3407379456,3407384831,AU
+3407379456,3407382271,AU
+3407382272,3407382527,JP
+3407382528,3407384831,AU
3407384832,3407385087,CN
3407385088,3407386623,AU
3407386624,3407387135,CN
@@ -79121,7 +81477,8 @@
3407522304,3407522559,CN
3407522560,3407523071,AU
3407523072,3407523327,CN
-3407523328,3407523839,AU
+3407523328,3407523583,AU
+3407523584,3407523839,JP
3407523840,3407524095,CN
3407524096,3407526143,AU
3407526144,3407526399,CN
@@ -79161,7 +81518,9 @@
3407558144,3407560959,AU
3407560960,3407561471,CN
3407561472,3407561727,NZ
-3407561728,3407565055,AU
+3407561728,3407561983,AU
+3407561984,3407562239,JP
+3407562240,3407565055,AU
3407565056,3407565311,CN
3407565312,3407566847,AU
3407566848,3407567103,CN
@@ -79531,7 +81890,7 @@
3408017408,3408017919,CN
3408017920,3408020223,AU
3408020224,3408020479,CN
-3408020480,3408020735,AU
+3408020480,3408020735,JP
3408020736,3408020991,CN
3408020992,3408022527,AU
3408022528,3408022783,CN
@@ -79733,7 +82092,9 @@
3409574144,3409574399,CN
3409574400,3409575167,AU
3409575168,3409575935,CN
-3409575936,3409838335,AU
+3409575936,3409707007,AU
+3409707008,3409772543,HK
+3409772544,3409838335,AU
3409838336,3409838591,MY
3409838592,3409838847,CN
3409838848,3409871615,AU
@@ -79848,11 +82209,12 @@
3411149824,3411150847,IN
3411150848,3411152895,HK
3411152896,3411154943,CN
+3411154944,3411156991,JP
3411156992,3411161087,PH
3411161088,3411165183,PK
3411165184,3411173375,MY
3411173376,3411177471,AU
-3411181568,3411189759,JP
+3411177472,3411189759,JP
3411189760,3411197951,AU
3411197952,3411202047,BD
3411202048,3411204607,AU
@@ -79898,7 +82260,9 @@
3411335680,3411337215,HK
3411337216,3411341311,AU
3411341312,3411345407,KR
-3411345408,3411410943,HK
+3411345408,3411354879,HK
+3411354880,3411355647,SG
+3411355648,3411410943,HK
3411410944,3411443711,CN
3411443712,3411460095,HK
3411460096,3411464191,NZ
@@ -79939,15 +82303,9 @@
3411644928,3411645951,ID
3411645952,3411646207,SG
3411646208,3411647487,IN
-3411647488,3411648767,AU
-3411648768,3411649023,NZ
-3411649024,3411649279,AU
-3411649280,3411649535,NZ
-3411649536,3411649791,AU
-3411649792,3411650303,NZ
-3411650304,3411654399,AU
-3411654400,3411654655,NZ
-3411654656,3411673087,AU
+3411647488,3411648511,AU
+3411648512,3411656703,NZ
+3411656704,3411673087,AU
3411673088,3411674111,CN
3411674112,3411674623,IN
3411674624,3411675135,HK
@@ -79988,7 +82346,12 @@
3411859252,3411861503,JP
3411861504,3411869695,AU
3411869696,3411943423,CN
-3411943424,3411951615,NZ
+3411943424,3411946495,NZ
+3411946496,3411947007,AU
+3411947008,3411948031,NZ
+3411948032,3411948543,AU
+3411948544,3411950591,NZ
+3411950592,3411951615,AU
3411951616,3411967999,LK
3411968000,3411984383,AU
3411984384,3412000767,IN
@@ -80002,7 +82365,10 @@
3412213760,3412221951,AU
3412221952,3412230143,IN
3412230144,3412246527,HK
-3412246528,3412254719,AU
+3412246528,3412249903,AU
+3412249904,3412249919,SG
+3412249920,3412253695,AU
+3412253696,3412254719,JP
3412254720,3412262911,NR
3412262912,3412264959,JP
3412264960,3412271103,CN
@@ -80047,14 +82413,11 @@
3412381696,3412385791,NZ
3412385792,3412393983,AU
3412393984,3412426751,IN
-3412426752,3412431487,HK
-3412431488,3412431551,TH
-3412431552,3412433679,HK
-3412433680,3412433695,TH
-3412433696,3412433759,HK
+3412426752,3412433759,TH
3412433760,3412433775,ID
-3412433776,3412433783,TH
-3412433784,3412434943,HK
+3412433776,3412433791,TH
+3412433792,3412433823,HK
+3412433824,3412434943,TH
3412434944,3412443135,PK
3412443136,3412451327,SG
3412451328,3412526079,AU
@@ -80065,7 +82428,9 @@
3412598784,3412602879,CN
3412602880,3412606975,NC
3412606976,3412615167,PH
-3412615168,3412656127,JP
+3412615168,3412631551,JP
+3412631552,3412639743,KR
+3412639744,3412656127,JP
3412656128,3412672511,HK
3412672512,3412675071,JP
3412675072,3412675327,US
@@ -80113,8 +82478,8 @@
3413180416,3413213183,TH
3413213184,3413229567,VN
3413229568,3413245951,AU
-3413245952,3413262335,SG
-3413262336,3413270527,PH
+3413245952,3413262335,MY
+3413262336,3413263359,PH
3413270528,3413278719,TH
3413278720,3413295103,NZ
3413295104,3413303295,JP
@@ -80212,7 +82577,9 @@
3413934080,3413946367,IN
3413946368,3413950463,AU
3413950464,3413966847,IN
-3413966848,3414155519,SG
+3413966848,3414050303,SG
+3414050304,3414050559,US
+3414050560,3414155519,SG
3414155520,3414155775,PH
3414155776,3414163455,SG
3414163456,3414171647,PK
@@ -80278,11 +82645,13 @@
3414670592,3414670847,SG
3414670848,3414671359,MY
3414671360,3415080959,JP
-3415080960,3415083007,SG
+3415080960,3415082239,MY
+3415082240,3415083007,SG
3415083008,3415083519,AU
3415083520,3415084031,SG
3415084032,3415084159,CN
-3415084160,3415089151,SG
+3415084160,3415088127,SG
+3415088128,3415089151,HK
3415089152,3415097343,MY
3415097344,3415103487,ID
3415103488,3415113727,HK
@@ -80337,8 +82706,7 @@
3415564288,3415568383,JP
3415568384,3415572479,KR
3415572480,3415605247,SG
-3415605248,3415736319,TH
-3415736320,3415752703,SG
+3415605248,3415752703,TH
3415752704,3415760895,CN
3415760896,3415769087,NZ
3415769088,3415777279,CN
@@ -80401,7 +82769,7 @@
3416327168,3416328191,HK
3416328192,3416330239,AU
3416330240,3416334335,ID
-3416334336,3416342527,MY
+3416334336,3416342527,SG
3416342528,3416371199,AU
3416371200,3416371711,PH
3416371712,3416371967,VN
@@ -80418,7 +82786,11 @@
3416375296,3416383487,CN
3416383488,3416391679,HK
3416391680,3416457215,VN
-3416457216,3416475391,JP
+3416457216,3416474583,JP
+3416474584,3416474599,AU
+3416474600,3416474639,JP
+3416474640,3416474647,NZ
+3416474648,3416475391,JP
3416475392,3416475647,NZ
3416475648,3416482047,JP
3416482048,3416482303,SG
@@ -80429,7 +82801,11 @@
3416514560,3416522751,IN
3416522752,3416588287,AU
3416588288,3416653823,JP
-3416653824,3416686591,AU
+3416653824,3416667135,AU
+3416667136,3416667647,US
+3416667648,3416667775,AU
+3416667776,3416668159,US
+3416668160,3416686591,AU
3416686592,3416694783,SG
3416694784,3416702975,CN
3416702976,3416707071,ID
@@ -80439,7 +82815,7 @@
3416709632,3416710143,AU
3416710144,3416711167,HK
3416711168,3416719359,AU
-3416719360,3416727551,PH
+3416719360,3416723455,PH
3416727552,3416735743,JP
3416735744,3416752127,PH
3416752128,3416784895,NZ
@@ -80455,8 +82831,28 @@
3416856576,3416858623,BD
3416858624,3416862719,HK
3416862720,3416864767,MN
-3416864768,3416866815,HK
-3416866816,3416883199,SG
+3416864768,3416864895,JP
+3416864896,3416865023,SG
+3416865024,3416865151,HK
+3416865152,3416865279,SG
+3416865280,3416865287,JP
+3416865288,3416865295,HK
+3416865296,3416865303,AU
+3416865304,3416865311,HK
+3416865312,3416865327,SG
+3416865328,3416865343,HK
+3416865344,3416865359,JP
+3416865360,3416865407,HK
+3416865408,3416865599,JP
+3416865600,3416865655,HK
+3416865656,3416865791,JP
+3416865792,3416865919,SG
+3416865920,3416866055,HK
+3416866056,3416866071,SG
+3416866072,3416866079,HK
+3416866080,3416866095,SG
+3416866096,3416866559,HK
+3416866560,3416883199,SG
3416883200,3416915967,HK
3416915968,3416920063,AU
3416920064,3416921087,TH
@@ -80662,7 +83058,9 @@
3418292992,3418293503,HK
3418293760,3418294015,AU
3418294272,3418296319,VN
-3418296320,3418300415,HK
+3418296320,3418298367,CN
+3418298368,3418299391,HK
+3418299392,3418300415,CN
3418300416,3418300927,BD
3418300928,3418301439,IN
3418301440,3418302463,AU
@@ -80703,7 +83101,9 @@
3418472448,3418480639,AU
3418480640,3418488831,CN
3418488832,3418505215,AU
-3418505216,3418513407,JP
+3418505216,3418512319,JP
+3418512320,3418512335,AU
+3418512336,3418513407,JP
3418513408,3418517503,IN
3418517504,3418519551,MN
3418519552,3418521599,CN
@@ -80723,7 +83123,11 @@
3418642944,3418643199,ID
3418643200,3418643455,JP
3418643456,3418644479,AU
-3418644480,3418652671,JP
+3418644480,3418650807,JP
+3418650808,3418650808,HK
+3418650809,3418650823,JP
+3418650824,3418650839,HK
+3418650840,3418652671,JP
3418652672,3418750975,IN
3418750976,3418816511,HK
3418816512,3418947583,IN
@@ -80870,16 +83274,20 @@
3420061696,3420127231,HK
3420127232,3420323839,AU
3420323840,3420332031,TW
-3420332032,3420369007,AU
+3420332032,3420337439,AU
+3420337440,3420337471,SG
+3420337472,3420366959,AU
+3420366960,3420366975,KR
+3420366976,3420369007,AU
3420369008,3420369023,HK
3420369024,3420370559,AU
3420370560,3420370575,JP
3420370576,3420372991,AU
-3420372992,3420374527,CN
+3420372992,3420374527,HK
3420374528,3420374783,ID
-3420374784,3420375551,CN
+3420374784,3420375551,HK
3420375552,3420375807,ID
-3420375808,3420377087,CN
+3420375808,3420377087,HK
3420377088,3420389375,JP
3420389376,3420393471,US
3420393472,3420395519,CN
@@ -80941,8 +83349,7 @@
3423273984,3423285247,US
3423285248,3423287295,CA
3423287296,3423288319,VG
-3423288320,3423301631,US
-3423302656,3423303679,US
+3423288320,3423303679,US
3423303680,3423304703,CA
3423304704,3423311871,US
3423311872,3423313151,VI
@@ -80957,8 +83364,8 @@
3423416320,3423417343,CA
3423417344,3423430655,US
3423430656,3423431167,TC
-3423431168,3423458303,US
-3423459328,3423468543,US
+3423431168,3423468543,US
+3423468544,3423469567,CA
3423469568,3423473663,US
3423473664,3423474687,CA
3423474688,3423480063,US
@@ -80969,7 +83376,7 @@
3423480989,3423481343,NG
3423481344,3423487999,US
3423488000,3423490047,CA
-3423491072,3423493631,US
+3423490048,3423493631,US
3423493632,3423493887,RU
3423493888,3423533055,US
3423533056,3423535103,AI
@@ -80984,7 +83391,7 @@
3423586304,3423588351,US
3423590400,3423602687,US
3423602688,3423603711,KN
-3423603712,3423625215,US
+3423603712,3423626239,US
3423626240,3423627263,CA
3423627264,3423629311,US
3423629312,3423630335,AG
@@ -80992,8 +83399,7 @@
3423637504,3423639551,CA
3423639552,3423651839,US
3423651840,3423653887,CA
-3423653888,3423654911,US
-3423655936,3423705599,US
+3423653888,3423705599,US
3423705600,3423705855,CA
3423705856,3423725423,US
3423725424,3423725427,CA
@@ -81028,8 +83434,7 @@
3424378880,3424379135,PR
3424379136,3424412415,US
3424412416,3424412671,CA
-3424412672,3424413695,US
-3424415744,3424493823,US
+3424412672,3424493823,US
3424493824,3424494079,CA
3424494080,3424507135,US
3424507136,3424507391,CA
@@ -82253,7 +84658,8 @@
3453180672,3453180927,US
3453180928,3453195263,CA
3453195264,3453195519,US
-3453195520,3453199871,CA
+3453195520,3453198335,CA
+3453198592,3453199871,CA
3453200384,3453206527,CA
3453206528,3453207551,HN
3453207552,3453207807,NI
@@ -82557,7 +84963,8 @@
3458813952,3458818047,CA
3458818048,3458820095,US
3458820096,3458820351,CA
-3458820352,3458820607,US
+3458820352,3458820863,US
+3458820864,3458821119,JM
3458822144,3459055615,US
3459055616,3459121151,CA
3459121152,3459186687,US
@@ -82869,7 +85276,12 @@
3461357568,3461408767,US
3461410816,3461414911,CA
3461414912,3461441535,US
-3461447680,3461507071,US
+3461443584,3461462015,US
+3461462016,3461462271,AU
+3461462272,3461462527,NL
+3461462528,3461462783,US
+3461462784,3461463039,SG
+3461463040,3461507071,US
3461509120,3461513727,US
3461513728,3461513983,BF
3461513984,3461514495,US
@@ -83068,7 +85480,9 @@
3464664320,3464684543,CA
3464684800,3464688383,CA
3464688640,3464691711,CA
-3464691712,3464769535,US
+3464691712,3464740863,US
+3464740864,3464744959,PH
+3464744960,3464769535,US
3464769536,3464773631,CA
3464773632,3464774079,US
3464774080,3464774111,ES
@@ -83319,8 +85733,7 @@
3470573568,3470575615,CA
3470575616,3470610431,US
3470610432,3470614527,AR
-3470614528,3470635007,US
-3470639104,3470646591,US
+3470614528,3470646591,US
3470646592,3470646599,CN
3470646600,3470651391,US
3470651392,3470655487,CA
@@ -83460,7 +85873,9 @@
3478192128,3478257663,CA
3478257664,3478274823,US
3478274824,3478274831,GB
-3478274832,3478372351,US
+3478274832,3478288671,US
+3478288672,3478288703,GB
+3478288704,3478372351,US
3478372352,3478380543,MX
3478380544,3478831103,US
3478847488,3479207935,US
@@ -84274,15 +86689,13 @@
3493866496,3493867519,VG
3493867520,3493881855,US
3493881856,3493882879,CA
-3493882880,3493898239,US
-3493900288,3493900371,US
+3493882880,3493900371,US
3493900372,3493900375,GB
3493900376,3493901023,US
3493901024,3493901031,HK
3493901032,3493901311,US
3493901312,3493901567,AE
-3493901568,3493928959,US
-3493931008,3493936127,US
+3493901568,3493936127,US
3493936128,3493937151,CA
3493937152,3493939455,US
3493939456,3493939711,CA
@@ -84305,19 +86718,17 @@
3494010880,3494014975,US
3494014976,3494017023,CA
3494017024,3494043647,US
-3494044672,3494045695,CA
+3494043648,3494045695,CA
3494045696,3494049791,US
3494049792,3494051839,CA
-3494051840,3494059007,US
-3494060032,3494075391,US
+3494051840,3494075391,US
3494075392,3494076415,CA
3494076416,3494085887,US
3494086656,3494088703,US
3494088704,3494090751,CA
3494090752,3494094847,US
3494094848,3494095871,CA
-3494095872,3494106111,US
-3494107136,3494121471,US
+3494095872,3494121471,US
3494121472,3494122495,CA
3494122496,3494125567,US
3494125568,3494126591,CA
@@ -84325,20 +86736,22 @@
3494135808,3494136831,CA
3494136832,3494139903,US
3494139904,3494141951,CA
-3494141952,3494142975,US
+3494141952,3494143999,US
3494144000,3494145023,CA
-3494145024,3494168575,US
+3494145024,3494163455,US
+3494164480,3494168575,US
3494168576,3494170623,CA
3494170624,3494181631,US
3494181632,3494181887,SN
-3494182912,3494184959,US
+3494181888,3494184959,US
3494184960,3494187007,CA
-3494187008,3494190079,US
-3494191104,3494191359,US
+3494187008,3494191359,US
3494191360,3494191615,DE
3494191616,3494191871,GB
3494191872,3494192127,NL
-3494192128,3494197247,US
+3494192128,3494192383,US
+3494192384,3494192639,JP
+3494192640,3494197247,US
3494197248,3494198271,CA
3494198272,3494244351,US
3494244352,3494246399,CA
@@ -84351,7 +86764,7 @@
3494273024,3494275071,US
3494275072,3494277119,CA
3494277120,3494294527,US
-3494295040,3494301695,US
+3494295040,3494302719,US
3494302720,3494303743,CA
3494303744,3494310911,US
3494310912,3494311935,CA
@@ -84386,9 +86799,7 @@
3494459392,3494460415,CA
3494460416,3494464511,US
3494464512,3494465535,CA
-3494465536,3494470655,US
-3494471680,3494486015,US
-3494488064,3494496255,US
+3494465536,3494496255,US
3494496512,3494496767,US
3494498304,3494510591,US
3494510592,3494512639,CA
@@ -84428,6 +86839,7 @@
3494729728,3494730751,US
3494730752,3494731775,CA
3494731776,3494743039,US
+3494743040,3494744063,CA
3494744064,3494747135,US
3494747136,3494748159,CA
3494748160,3494749439,US
@@ -84443,19 +86855,15 @@
3494788096,3494788351,NG
3494788352,3494788607,LY
3494788608,3494789119,CA
-3494789120,3494830079,US
-3494831104,3494852607,US
+3494789120,3494852607,US
3494852608,3494854655,CA
3494854656,3494862847,US
3494862848,3494863871,DM
3494863872,3494866943,US
3494866944,3494867967,CA
-3494867968,3494868991,US
-3494870016,3494874111,US
+3494867968,3494874111,US
3494874112,3494874367,ES
-3494874368,3494879231,US
-3494879488,3494879743,US
-3494881280,3494893567,US
+3494874368,3494893567,US
3494893568,3494894591,CA
3494894592,3494917119,US
3494917120,3494917631,CA
@@ -84500,16 +86908,16 @@
3495123456,3495123967,GB
3495123968,3495153663,US
3495153664,3495155711,CA
-3495155712,3495157759,US
-3495159808,3495187199,US
+3495155712,3495187199,US
3495187200,3495187455,IM
3495187456,3495192575,US
3495192576,3495193599,CA
3495193600,3495215103,US
3495215104,3495217151,VI
3495217152,3495219199,VC
-3495219200,3495239679,US
-3495241728,3495251967,US
+3495219200,3495225343,US
+3495226624,3495226879,US
+3495227392,3495251967,US
3495251968,3495254015,CA
3495254016,3495260159,US
3495260160,3495261183,CA
@@ -84549,17 +86957,14 @@
3495479296,3495501823,US
3495502848,3495505919,US
3495505920,3495507967,CA
-3495507968,3495508991,US
-3495510016,3495515135,US
+3495507968,3495515135,US
3495515136,3495516159,CA
3495516160,3495521279,US
3495522304,3495526399,US
3495526400,3495527423,CA
3495527424,3495544063,US
3495544064,3495544319,NG
-3495544320,3495550207,US
-3495550208,3495550463,CA
-3495550464,3495551999,US
+3495544320,3495551999,US
3495552000,3495553023,BM
3495553024,3495556095,US
3495557120,3495576575,US
@@ -84569,9 +86974,7 @@
3495583744,3495585791,CA
3495585792,3495587839,US
3495587840,3495588863,MS
-3495588864,3495593983,US
-3495594496,3495595519,US
-3495596032,3495618559,US
+3495588864,3495618559,US
3495618560,3495619583,CA
3495619584,3495620607,US
3495620608,3495622655,CA
@@ -84589,8 +86992,7 @@
3495696384,3495703551,US
3495703552,3495704063,GB
3495704064,3495704575,CA
-3495704576,3495712767,US
-3495714816,3495718911,US
+3495704576,3495718911,US
3495718912,3495723007,CA
3495723008,3495724031,US
3495724032,3495727103,CA
@@ -85501,7 +87903,9 @@
3514592256,3514593279,SV
3514593280,3514596863,US
3514596864,3514597375,SV
-3514597376,3514826751,US
+3514597376,3514732071,US
+3514732072,3514732075,UA
+3514732076,3514826751,US
3514826752,3514843135,CA
3514843136,3514993919,US
3514993920,3514993983,GB
@@ -85551,7 +87955,9 @@
3516366848,3516370943,CA
3516370944,3516514303,US
3516514304,3516530687,CA
-3516530688,3516899839,US
+3516530688,3516643083,US
+3516643084,3516643087,PR
+3516643088,3516899839,US
3516899840,3516900095,NG
3516900096,3516900351,US
3516900352,3516900607,NG
@@ -85734,7 +88140,9 @@
3517597696,3517597951,IE
3517597952,3517598207,DE
3517598208,3517598463,IE
-3517598464,3517599359,SE
+3517598464,3517599263,SE
+3517599264,3517599295,US
+3517599296,3517599359,SE
3517599360,3517599615,US
3517599616,3517600767,SE
3517600768,3517601279,US
@@ -85852,9 +88260,7 @@
3519934464,3519938559,CA
3519938560,3520020479,US
3520020480,3520036863,CA
-3520036864,3520086271,US
-3520086272,3520086527,CA
-3520086528,3520135167,US
+3520036864,3520135167,US
3520167936,3520344063,US
3520348160,3520356351,US
3520356352,3520364543,ZA
@@ -85930,7 +88336,9 @@
3522123520,3522123775,GB
3522123776,3522125055,US
3522125056,3522125311,GB
-3522125312,3522174975,US
+3522125312,3522132395,US
+3522132396,3522132396,BR
+3522132397,3522174975,US
3522174976,3522179071,BM
3522179072,3522195455,US
3522195456,3522199551,CA
@@ -85988,7 +88396,9 @@
3523682304,3523686399,NZ
3523686400,3523690495,AU
3523690496,3523698687,IN
-3523698688,3523707903,JP
+3523698688,3523700735,JP
+3523700736,3523701759,HK
+3523701760,3523707903,JP
3523707904,3523708159,AU
3523708160,3523709183,JP
3523709184,3523709951,CN
@@ -86020,22 +88430,7 @@
3524745728,3524745983,GU
3524745984,3524747263,MP
3524747264,3524755455,PH
-3524755456,3524756223,AU
-3524756224,3524756479,SG
-3524756480,3524756991,AU
-3524756992,3524757247,SG
-3524757248,3524758015,AU
-3524758016,3524758271,SG
-3524758272,3524758527,AU
-3524758528,3524758783,SG
-3524758784,3524759039,AU
-3524759040,3524759295,SG
-3524759296,3524759551,AU
-3524759552,3524760575,SG
-3524760576,3524761343,AU
-3524761344,3524761599,SG
-3524761600,3524761855,AU
-3524761856,3524763647,SG
+3524755456,3524763647,AU
3524763648,3524788223,PH
3524788224,3524853759,SG
3524853760,3526361087,CN
@@ -86077,7 +88472,7 @@
3528404992,3528407039,NZ
3528407040,3528409087,AU
3528409088,3528425471,CN
-3528441856,3528445951,JP
+3528425472,3528445951,JP
3528445952,3528450047,ID
3528450048,3528458239,CN
3528458240,3528474623,AF
@@ -86107,20 +88502,19 @@
3531603968,3533765631,JP
3533765632,3533765887,CN
3533765888,3534749695,JP
-3534749696,3534758043,HK
-3534758044,3534758143,AU
+3534749696,3534757887,HK
+3534757888,3534758143,AU
3534758144,3534758147,JP
-3534758148,3534758911,HK
+3534758148,3534758911,AU
3534758912,3534758927,PH
-3534758928,3534758975,HK
+3534758928,3534758975,AU
3534758976,3534759039,PH
-3534759040,3534759167,HK
+3534759040,3534759167,AU
3534759168,3534759183,JP
-3534759184,3534760703,HK
+3534759184,3534760703,AU
3534760704,3534760711,NZ
-3534760712,3534761471,HK
-3534761472,3534761535,AU
-3534761536,3534863443,HK
+3534760712,3534761983,AU
+3534761984,3534863443,HK
3534863444,3534863444,CN
3534863445,3534880767,HK
3534880768,3535273983,KR
@@ -86230,8 +88624,8 @@
3557081088,3557089279,NL
3557089280,3557105663,DE
3557105664,3557111807,BG
-3557111808,3557112830,GB
-3557112831,3557113855,BG
+3557111808,3557112831,GB
+3557112832,3557113855,BG
3557113856,3557130239,RU
3557130240,3557138431,BG
3557138432,3557146623,RU
@@ -86348,8 +88742,7 @@
3557990400,3557998591,PT
3557998592,3558006783,DE
3558006784,3558010879,GB
-3558010880,3558011903,FR
-3558011904,3558012927,US
+3558010880,3558012927,FR
3558012928,3558014975,GB
3558014976,3558023167,RU
3558023168,3558031359,DE
@@ -86380,7 +88773,9 @@
3558203392,3558211583,ES
3558211584,3558219775,GB
3558219776,3558227967,ES
-3558227968,3558234623,RU
+3558227968,3558232063,RU
+3558232064,3558234111,ES
+3558234112,3558234623,RU
3558234624,3558234879,UA
3558234880,3558235647,RU
3558235648,3558235903,LB
@@ -86611,7 +89006,9 @@
3559899648,3559899967,EE
3559899968,3559900223,UA
3559900224,3559900287,EE
-3559900288,3559903231,UA
+3559900288,3559902719,UA
+3559902720,3559902975,EE
+3559902976,3559903231,UA
3559903232,3559907327,EE
3559907328,3559915519,FR
3559915520,3559923711,IT
@@ -86854,7 +89251,9 @@
3561242624,3561259007,DE
3561259008,3561267199,IL
3561267200,3561275391,UA
-3561275392,3561291775,BE
+3561275392,3561288831,BE
+3561288832,3561288959,FR
+3561288960,3561291775,BE
3561291776,3561299967,RS
3561299968,3561308159,GB
3561308160,3561316351,PL
@@ -87189,7 +89588,9 @@
3563847680,3563848447,NL
3563848448,3563848703,ES
3563848704,3563848847,NL
-3563848848,3563848855,ES
+3563848848,3563848848,ES
+3563848849,3563848849,NL
+3563848850,3563848855,ES
3563848856,3563855871,NL
3563855872,3563864063,AT
3563864064,3563872255,GB
@@ -87344,7 +89745,9 @@
3564895744,3564896255,GB
3564896256,3564904447,RU
3564904448,3564912639,DE
-3564912640,3564920831,BG
+3564912640,3564915711,NL
+3564915712,3564915967,BG
+3564915968,3564920831,NL
3564920832,3564922111,DE
3564922112,3564929023,US
3564929024,3564937215,AT
@@ -87502,8 +89905,7 @@
3566600192,3566607359,IL
3566607360,3566607615,GN
3566607616,3566665727,IL
-3566665728,3566678015,LT
-3566678016,3566723071,SE
+3566665728,3566723071,SE
3566723072,3566723327,RU
3566723328,3566739455,SE
3566739456,3566747647,RU
@@ -87602,7 +90004,9 @@
3567403008,3567419391,IT
3567419392,3567427583,SA
3567427584,3567435775,SE
-3567435776,3567456407,GB
+3567435776,3567453695,GB
+3567453696,3567453951,ES
+3567453952,3567456407,GB
3567456408,3567456415,ES
3567456416,3567458305,GB
3567458306,3567458306,ES
@@ -87616,7 +90020,9 @@
3567499008,3567499135,ES
3567499136,3567503359,GB
3567503360,3567504383,ES
-3567504384,3567511487,GB
+3567504384,3567505151,GB
+3567505152,3567505407,ES
+3567505408,3567511487,GB
3567511488,3567511495,ES
3567511496,3567516671,GB
3567516672,3567517695,ES
@@ -87913,7 +90319,9 @@
3575590912,3575640063,BE
3575640064,3575644159,TR
3575644160,3575709695,DK
-3575709696,3575739391,AT
+3575709696,3575715839,AT
+3575715840,3575716351,SK
+3575716352,3575739391,AT
3575739392,3575739647,FR
3575739648,3575742463,AT
3575742464,3575775231,RU
@@ -88084,7 +90492,9 @@
3576245248,3576245503,FR
3576245504,3576251135,GB
3576251136,3576251391,FR
-3576251392,3576252415,GB
+3576251392,3576251711,GB
+3576251712,3576251775,FR
+3576251776,3576252415,GB
3576252416,3576252671,FR
3576252672,3576253807,GB
3576253808,3576253815,FR
@@ -88337,7 +90747,21 @@
3581239296,3581241343,NL
3581242624,3581245439,FR
3581255680,3581258751,FR
-3581280256,3581411327,BE
+3581280256,3581365247,BE
+3581365248,3581365503,NL
+3581365504,3581365759,BE
+3581365760,3581366015,NL
+3581366016,3581366783,BE
+3581366784,3581367039,NL
+3581367040,3581367295,BE
+3581367296,3581367807,NL
+3581367808,3581368063,BE
+3581368064,3581368319,NL
+3581368320,3581371391,BE
+3581371392,3581371647,NL
+3581371648,3581371903,BE
+3581371904,3581372159,NL
+3581372160,3581411327,BE
3581411328,3581673471,GB
3581673472,3581935615,NL
3581935616,3581943807,RU
@@ -89026,7 +91450,9 @@
3587129344,3587145727,NL
3587145728,3587162111,CY
3587162112,3587178495,IR
-3587178496,3587186687,AT
+3587178496,3587182591,AT
+3587182592,3587182847,HU
+3587182848,3587186687,AT
3587186688,3587186943,DE
3587186944,3587187199,GB
3587187200,3587187455,DE
@@ -89230,13 +91656,17 @@
3589242880,3589259263,NL
3589259264,3589275647,DE
3589275648,3589292031,RS
-3589292032,3589308415,AT
+3589292032,3589305343,AT
+3589305344,3589305599,DE
+3589305600,3589308415,AT
3589308416,3589324799,DE
3589324800,3589341183,BG
3589341184,3589373951,PL
3589373952,3589390335,DE
3589390336,3589423103,RU
-3589423104,3589431039,GB
+3589423104,3589430591,GB
+3589430592,3589430655,ES
+3589430656,3589431039,GB
3589431040,3589431295,ES
3589431296,3589432831,GB
3589432832,3589433087,CH
@@ -89366,39 +91796,36 @@
3624255488,3624257535,ZA
3624257536,3624271871,US
3624271872,3624272383,SY
-3624272384,3624272639,CA
+3624272384,3624272639,US
3624272640,3624272895,DZ
-3624272896,3624275967,CA
-3624275968,3624276223,US
-3624276224,3624281087,CA
+3624272896,3624281087,US
3624281088,3624281343,HT
-3624281344,3624283135,CA
-3624283136,3624284159,US
-3624284160,3624286193,CA
+3624281344,3624284671,US
+3624284672,3624284927,CA
+3624284928,3624286193,US
3624286194,3624286194,ZA
-3624286195,3624288255,CA
+3624286195,3624287743,US
+3624287744,3624287999,CA
+3624288000,3624288255,US
3624288256,3624290303,IN
3624290304,3624292351,CA
3624292352,3624292607,MF
-3624292608,3624292863,US
-3624292864,3624294143,CA
-3624294144,3624294399,US
-3624294400,3624294911,CA
-3624294912,3624295167,US
-3624295168,3624295935,CA
+3624292608,3624295423,US
+3624295424,3624295679,CA
+3624295680,3624295935,US
3624295936,3624296191,LY
-3624296192,3624297215,CA
-3624297216,3624297471,US
+3624296192,3624296447,US
+3624296448,3624296703,CA
+3624296704,3624297471,US
3624297472,3624298495,CO
3624298496,3624299519,PH
-3624299520,3624300031,CA
+3624299520,3624300031,US
3624300032,3624300287,LY
-3624300288,3624302847,CA
+3624300288,3624302847,US
3624302848,3624303103,MY
-3624303104,3624303359,CA
-3624303360,3624303615,US
-3624303616,3624304639,CA
-3624304640,3624321023,US
+3624303104,3624303871,US
+3624303872,3624304127,CA
+3624304128,3624321023,US
3624321024,3624325119,CA
3624325120,3624357887,US
3624357888,3624358143,KN
@@ -89424,7 +91851,9 @@
3624377904,3624377911,GB
3624377912,3624386559,US
3624386560,3624394751,CA
-3624394752,3624435711,US
+3624394752,3624402943,US
+3624402944,3624407039,JP
+3624407040,3624435711,US
3624435712,3624443391,CA
3624443392,3624443903,US
3624443904,3624452095,CA
@@ -89521,9 +91950,7 @@
3627679744,3627712511,CA
3627712512,3627753471,US
3627753472,3627753727,AR
-3627753728,3627759359,US
-3627759360,3627759615,NL
-3627759616,3627802623,US
+3627753728,3627802623,US
3627802624,3627810815,CA
3627810816,3627842047,US
3627842048,3627842303,IS
@@ -89628,8 +92055,18 @@
3629789952,3629790207,CA
3629790208,3629839103,US
3629839104,3629839359,CA
-3629839360,3630039039,US
-3630039040,3630039551,CA
+3629839360,3630039047,US
+3630039048,3630039055,CA
+3630039056,3630039079,US
+3630039080,3630039087,CA
+3630039088,3630039119,US
+3630039120,3630039135,CA
+3630039136,3630039159,US
+3630039160,3630039167,CA
+3630039168,3630039183,US
+3630039184,3630039199,CA
+3630039200,3630039295,US
+3630039296,3630039551,CA
3630039552,3630040063,US
3630040064,3630040319,CA
3630040320,3630040431,US
@@ -89686,9 +92123,7 @@
3630069504,3630069759,CA
3630069760,3630071295,US
3630071296,3630071551,CA
-3630071552,3630072255,US
-3630072256,3630072287,CA
-3630072288,3630072575,US
+3630071552,3630072575,US
3630072576,3630074111,CA
3630074112,3630074879,US
3630074880,3630075135,CA
@@ -89753,9 +92188,7 @@
3630141952,3630142207,CA
3630142208,3630143999,US
3630144000,3630144255,CA
-3630144256,3630147327,US
-3630147328,3630147583,CA
-3630147584,3630148095,US
+3630144256,3630148095,US
3630148096,3630148607,CA
3630148608,3630148863,US
3630148864,3630149119,CA
@@ -89924,7 +92357,9 @@
3633817088,3633817343,CA
3633817344,3633818623,US
3633818624,3633819135,CA
-3633819136,3633844223,US
+3633819136,3633823743,US
+3633823744,3633827839,HK
+3633827840,3633844223,US
3633848320,3633881087,US
3633881088,3633885183,CW
3633885184,3633889279,US
@@ -90168,7 +92603,8 @@
3636166400,3636166655,CA
3636166656,3636206079,US
3636206080,3636206335,AU
-3636206336,3636396031,US
+3636206336,3636301823,US
+3636305920,3636396031,US
3636396032,3636461567,CA
3636461568,3636609023,US
3636609024,3636621311,CA
@@ -90417,7 +92853,8 @@
3641393152,3641397247,KZ
3641397248,3641401343,IT
3641401344,3641409535,ES
-3641409536,3641417727,PL
+3641409536,3641413631,PL
+3641413632,3641417727,DE
3641417728,3641421823,GE
3641421824,3641425919,TJ
3641425920,3641430015,DE
@@ -91093,7 +93530,9 @@
3647988736,3647989759,BE
3647989760,3647995903,DE
3647995904,3648004095,RU
-3648004096,3648008191,GB
+3648004096,3648007167,GB
+3648007168,3648007679,US
+3648007680,3648008191,GB
3648008192,3648016383,FR
3648016384,3648020479,GB
3648020480,3648024575,IT
@@ -91228,7 +93667,9 @@
3648512000,3648516095,NL
3648516096,3648519167,RS
3648519168,3648520191,MK
-3648520192,3648782335,NL
+3648520192,3648523775,NL
+3648523776,3648524031,DE
+3648524032,3648782335,NL
3648782336,3649044479,ES
3649044480,3649110015,FR
3649110016,3649175551,PT
@@ -91686,8 +94127,7 @@
3653652480,3653656575,RU
3653656576,3653660671,GB
3653660672,3653664767,CZ
-3653664768,3653665791,NL
-3653665792,3653666815,DE
+3653664768,3653666815,DE
3653666816,3653667839,NL
3653667840,3653668863,DE
3653668864,3653672959,SE
@@ -91916,12 +94356,7 @@
3707209728,3707215871,CN
3707215872,3707217919,BD
3707217920,3707219967,ID
-3707219968,3707220479,NZ
-3707220480,3707220735,AU
-3707220736,3707220991,NZ
-3707220992,3707221247,AU
-3707221248,3707221759,NZ
-3707221760,3707222015,AU
+3707219968,3707222015,AU
3707222016,3707224063,JP
3707224064,3707240447,LK
3707240448,3707568127,CN
@@ -92056,7 +94491,7 @@
3743219712,3743252479,JP
3743252480,3743264767,NC
3743264768,3743268863,JP
-3743268864,3743277055,IN
+3743268864,3743272959,IN
3743277056,3743281151,PK
3743281152,3743282175,AU
3743282176,3743283199,JP
@@ -92118,7 +94553,9 @@
3757834240,3757867007,AU
3757867008,3757875519,CN
3757875520,3757875583,HK
-3757875584,3757899775,CN
+3757875584,3757880063,CN
+3757880064,3757883391,HK
+3757883392,3757899775,CN
3757899776,3757965311,KR
3757965312,3758063615,CN
3758063616,3758079999,HK
diff --git a/src/config/geoip6 b/src/config/geoip6
index 70fa6e34bf..06bd578b85 100644
--- a/src/config/geoip6
+++ b/src/config/geoip6
@@ -1,4 +1,4 @@
-# Last updated based on July 10 2014 Maxmind GeoLite2 Country
+# Last updated based on August 7 2014 Maxmind GeoLite2 Country
# wget https://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.mmdb.gz
# gunzip GeoLite2-Country.mmdb.gz
# python mmdb-convert.py GeoLite2-Country.mmdb
@@ -60,165 +60,9 @@
2001:3d8::,2001:3d8:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:3e0::,2001:3e0:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:3e8::,2001:3e8:ffff:ffff:ffff:ffff:ffff:ffff,JP
-2001:400::,2001:400:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:408::,2001:408:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:410::,2001:410:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:418::,2001:418:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:420::,2001:420:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:428::,2001:428:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:430::,2001:430:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:438::,2001:438:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:440::,2001:440:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:448::,2001:448:ffff:ffff:ffff:ffff:ffff:ffff,MX
-2001:450::,2001:450:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:458::,2001:458:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:460::,2001:460:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:468::,2001:468:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:470::,2001:470:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:478::,2001:478:ffff:ffff:ffff:ffff:ffff:ffff,KN
-2001:480::,2001:480:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:490::,2001:490:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4a0::,2001:4a0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4b0::,2001:4b0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4b8::,2001:4b8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4c0::,2001:4c0:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:4c8::,2001:4c8:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:4d0::,2001:4d0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4e0::,2001:4e0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4e8::,2001:4e8:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:4f0::,2001:4f0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4f8::,2001:4f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:500:1::,2001:500:4:ffff:ffff:ffff:ffff:ffff,US
-2001:500:6::,2001:500:f:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:10::,2001:500:10:ffff:ffff:ffff:ffff:ffff,PR
-2001:500:11::,2001:500:15:ffff:ffff:ffff:ffff:ffff,US
-2001:500:16::,2001:500:2c:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:2d::,2001:500:31:ffff:ffff:ffff:ffff:ffff,US
-2001:500:40::,2001:500:56:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:60::,2001:500:7d:ffff:ffff:ffff:ffff:ffff,US
-2001:500:80::,2001:500:83:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:84::,2001:500:89:ffff:ffff:ffff:ffff:ffff,US
-2001:500:8c::,2001:500:9a:ffff:ffff:ffff:ffff:ffff,US
-2001:500:9c::,2001:500:9f:ffff:ffff:ffff:ffff:ffff,US
-2001:500:a0::,2001:500:a7:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:a8::,2001:500:a8:ffff:ffff:ffff:ffff:ffff,US
-2001:500:c0::,2001:500:ef:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:f0::,2001:500:f0:ffff:ffff:ffff:ffff:ffff,US
-2001:500:f1::,2001:500:f1:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:100::,2001:500:109:ffff:ffff:ffff:ffff:ffff,CA
-2001:500:3e5::,2001:500:3e5:ffff:ffff:ffff:ffff:ffff,US
-2001:500:30ff::,2001:500:30ff:ffff:ffff:ffff:ffff:ffff,US
-2001:500:3682::,2001:500:3682:ffff:ffff:ffff:ffff:ffff,US
-2001:500:4431::,2001:500:4431:ffff:ffff:ffff:ffff:ffff,US
-2001:500:7967::,2001:500:7967:ffff:ffff:ffff:ffff:ffff,US
-2001:500:856e::,2001:500:856e:ffff:ffff:ffff:ffff:ffff,US
-2001:500:d937::,2001:500:d937:ffff:ffff:ffff:ffff:ffff,US
-2001:500:ed30::,2001:500:ed30:ffff:ffff:ffff:ffff:ffff,US
-2001:501:8a29::,2001:501:8a29:ffff:ffff:ffff:ffff:ffff,US
-2001:501:973c::,2001:501:973c:ffff:ffff:ffff:ffff:ffff,US
-2001:501:b1f9::,2001:501:b1f9:ffff:ffff:ffff:ffff:ffff,US
-2001:502:8cc::,2001:502:8cc:ffff:ffff:ffff:ffff:ffff,US
-2001:502:100e::,2001:502:100e:ffff:ffff:ffff:ffff:ffff,US
-2001:502:1ca1::,2001:502:1ca1:ffff:ffff:ffff:ffff:ffff,US
-2001:502:2eda::,2001:502:2eda:ffff:ffff:ffff:ffff:ffff,US
-2001:502:4612::,2001:502:4612:ffff:ffff:ffff:ffff:ffff,US
-2001:502:63bd::,2001:502:63bd:ffff:ffff:ffff:ffff:ffff,US
-2001:502:7094::,2001:502:7094:ffff:ffff:ffff:ffff:ffff,US
-2001:502:7a71::,2001:502:7a71:ffff:ffff:ffff:ffff:ffff,US
-2001:502:8c25::,2001:502:8c25:ffff:ffff:ffff:ffff:ffff,US
-2001:502:ad09::,2001:502:ad09:ffff:ffff:ffff:ffff:ffff,US
-2001:502:be98::,2001:502:be98:ffff:ffff:ffff:ffff:ffff,US
-2001:502:cbe4::,2001:502:cbe4:ffff:ffff:ffff:ffff:ffff,US
-2001:502:cfb5::,2001:502:cfb5:ffff:ffff:ffff:ffff:ffff,US
-2001:502:d399::,2001:502:d399:ffff:ffff:ffff:ffff:ffff,US
-2001:502:f3ff::,2001:502:f3ff:ffff:ffff:ffff:ffff:ffff,US
-2001:503:c27::,2001:503:c27:ffff:ffff:ffff:ffff:ffff,US
-2001:503:d2d::,2001:503:d2d:ffff:ffff:ffff:ffff:ffff,US
-2001:503:231d::,2001:503:231d:ffff:ffff:ffff:ffff:ffff,US
-2001:503:3227::,2001:503:3227:ffff:ffff:ffff:ffff:ffff,US
-2001:503:39c1::,2001:503:39c1:ffff:ffff:ffff:ffff:ffff,US
-2001:503:4872::,2001:503:4872:ffff:ffff:ffff:ffff:ffff,US
-2001:503:5419::,2001:503:5419:ffff:ffff:ffff:ffff:ffff,US
-2001:503:5ae2::,2001:503:5ae2:ffff:ffff:ffff:ffff:ffff,US
-2001:503:6810::,2001:503:6810:ffff:ffff:ffff:ffff:ffff,US
-2001:503:7bbb::,2001:503:7bbb:ffff:ffff:ffff:ffff:ffff,US
-2001:503:7bbf::,2001:503:7bbf:ffff:ffff:ffff:ffff:ffff,US
-2001:503:8028::,2001:503:8028:ffff:ffff:ffff:ffff:ffff,US
-2001:503:83eb::,2001:503:83eb:ffff:ffff:ffff:ffff:ffff,US
-2001:503:91ef::,2001:503:91ef:ffff:ffff:ffff:ffff:ffff,US
-2001:503:a124::,2001:503:a124:ffff:ffff:ffff:ffff:ffff,US
-2001:503:a83e::,2001:503:a83e:ffff:ffff:ffff:ffff:ffff,US
-2001:503:ba3e::,2001:503:ba3e:ffff:ffff:ffff:ffff:ffff,US
-2001:503:bfb0::,2001:503:bfb0:ffff:ffff:ffff:ffff:ffff,US
-2001:503:c779::,2001:503:c779:ffff:ffff:ffff:ffff:ffff,US
-2001:503:cc2c::,2001:503:cc2c:ffff:ffff:ffff:ffff:ffff,US
-2001:503:d1ae::,2001:503:d1ae:ffff:ffff:ffff:ffff:ffff,US
-2001:503:d414::,2001:503:d414:ffff:ffff:ffff:ffff:ffff,US
-2001:503:e239::,2001:503:e239:ffff:ffff:ffff:ffff:ffff,US
-2001:503:e8ef::,2001:503:e8ef:ffff:ffff:ffff:ffff:ffff,US
-2001:503:eea3::,2001:503:eea3:ffff:ffff:ffff:ffff:ffff,US
-2001:503:f189::,2001:503:f189:ffff:ffff:ffff:ffff:ffff,US
-2001:503:f261::,2001:503:f261:ffff:ffff:ffff:ffff:ffff,US
-2001:503:f3da::,2001:503:f3da:ffff:ffff:ffff:ffff:ffff,US
-2001:503:ff39::,2001:503:ff39:ffff:ffff:ffff:ffff:ffff,US
-2001:504::,2001:504:13:ffff:ffff:ffff:ffff:ffff,US
-2001:504:15::,2001:504:15:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:16::,2001:504:19:ffff:ffff:ffff:ffff:ffff,US
-2001:504:1a::,2001:504:1a:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:1b::,2001:504:1c:ffff:ffff:ffff:ffff:ffff,US
-2001:504:1d::,2001:504:1d:ffff:ffff:ffff:ffff:ffff,PR
-2001:504:20::,2001:504:23:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:24::,2001:504:24:ffff:ffff:ffff:ffff:ffff,US
-2001:504:25::,2001:504:26:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:27::,2001:504:29:ffff:ffff:ffff:ffff:ffff,US
-2001:504:2b::,2001:504:2d:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:2e::,2001:504:2e:ffff:ffff:ffff:ffff:ffff,US
-2001:504:2f::,2001:504:2f:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:30::,2001:504:34:ffff:ffff:ffff:ffff:ffff,US
-2001:504:35::,2001:504:35:ffff:ffff:ffff:ffff:ffff,GD
-2001:504:36::,2001:504:36:ffff:ffff:ffff:ffff:ffff,US
-2001:504:37::,2001:504:37:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:38::,2001:504:38:ffff:ffff:ffff:ffff:ffff,US
-2001:504:39::,2001:504:39:ffff:ffff:ffff:ffff:ffff,CA
-2001:504:3a::,2001:504:3d:ffff:ffff:ffff:ffff:ffff,US
-2001:506::,2001:506:1:ffff:ffff:ffff:ffff:ffff,US
-2001:506:8::,2001:506:8:ffff:ffff:ffff:ffff:ffff,US
-2001:506:20::,2001:506:20:ffff:ffff:ffff:ffff:ffff,CA
-2001:506:28::,2001:506:28:ffff:ffff:ffff:ffff:ffff,US
-2001:506:100::,2001:506:100:ffff:ffff:ffff:ffff:ffff,US
-2001:506:1000::,2001:506:2fff:ffff:ffff:ffff:ffff:ffff,US
-2001:506:4000::,2001:506:7fff:ffff:ffff:ffff:ffff:ffff,US
-2001:508::,2001:508:ffff:ffff:ffff:ffff:ffff:ffff,BM
-2001:510::,2001:510:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:518::,2001:518:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:520::,2001:520:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:528::,2001:528:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:530::,2001:530:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:538::,2001:538:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:540::,2001:540:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:548::,2001:548:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:550::,2001:550:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:558::,2001:560:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:568::,2001:56f:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:570::,2001:570:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:578::,2001:57b:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:580::,2001:580:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:590::,2001:590:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:598::,2001:598:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:5a0::,2001:5a0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5a8::,2001:5a8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5b0::,2001:5b0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5b8::,2001:5b8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5c0::,2001:5c0:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:5c8::,2001:5c8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5d0::,2001:5d0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5d8::,2001:5d8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5e0::,2001:5e0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5e8::,2001:5e8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5f0::,2001:5f0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:5f8::,2001:5f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:600::,2001:6ff:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:700::,2001:7ff:ffff:ffff:ffff:ffff:ffff:ffff,LU
+2001:400::,2001:4ff:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:500::,2001:5ff:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:600::,2001:7ff:ffff:ffff:ffff:ffff:ffff:ffff,DE
2001:808::,2001:808:ffff:ffff:ffff:ffff:ffff:ffff,PL
2001:810::,2001:810:ffff:ffff:ffff:ffff:ffff:ffff,FR
2001:818::,2001:81f:ffff:ffff:ffff:ffff:ffff:ffff,PT
@@ -302,7 +146,7 @@
2001:c98::,2001:c98:ffff:ffff:ffff:ffff:ffff:ffff,KR
2001:ca0::,2001:ca0:ffff:ffff:ffff:ffff:ffff:ffff,TW
2001:ca8::,2001:ca8:ffff:ffff:ffff:ffff:ffff:ffff,IN
-2001:cb0::,2001:cb0:ffff:ffff:ffff:ffff:ffff:ffff,SG
+2001:cb0::,2001:cb0:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:cb8::,2001:cb8:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:cc0::,2001:cc0:ffff:ffff:ffff:ffff:ffff:ffff,CN
2001:cc8::,2001:cc9:ffff:ffff:ffff:ffff:ffff:ffff,JP
@@ -314,7 +158,37 @@
2001:cf8::,2001:cf8:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:d00::,2001:db7:ffff:ffff:ffff:ffff:ffff:ffff,CN
2001:db9::,2001:dff:ffff:ffff:ffff:ffff:ffff:ffff,CN
-2001:e00::,2001:eff:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2001:e00::,2001:e01:ffff:ffff:ffff:ffff:ffff:ffff,ID
+2001:e08::,2001:e08:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2001:e10::,2001:e10:ffff:ffff:ffff:ffff:ffff:ffff,TW
+2001:e18::,2001:e18:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2001:e20::,2001:e20:ffff:ffff:ffff:ffff:ffff:ffff,NZ
+2001:e28::,2001:e28:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2001:e30::,2001:e30:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2001:e38::,2001:e38:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2001:e40::,2001:e47:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2001:e48::,2001:e48:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2001:e58::,2001:e58:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2001:e60::,2001:e60:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:e68::,2001:e68:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2001:e70::,2001:e70:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:e78::,2001:e78:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:e80::,2001:e80:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2001:e88::,2001:e88:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2001:e90::,2001:e90:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2001:e98::,2001:e98:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ea0::,2001:ea0:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ea8::,2001:ea8:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:eb0::,2001:eb0:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2001:eb8::,2001:eb8:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ec0::,2001:ec0:ffff:ffff:ffff:ffff:ffff:ffff,TH
+2001:ec8::,2001:ec8:ffff:ffff:ffff:ffff:ffff:ffff,PH
+2001:ed0::,2001:ed0:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ed8::,2001:ed8:ffff:ffff:ffff:ffff:ffff:ffff,TW
+2001:ee0::,2001:ee0:ffff:ffff:ffff:ffff:ffff:ffff,VN
+2001:ee8::,2001:ee8:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ef0::,2001:ef0:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2001:ef8::,2001:ef8:ffff:ffff:ffff:ffff:ffff:ffff,KR
2001:f00::,2001:f00:ffff:ffff:ffff:ffff:ffff:ffff,TH
2001:f08::,2001:f08:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:f10::,2001:f10:ffff:ffff:ffff:ffff:ffff:ffff,TW
@@ -385,8 +259,81 @@
2001:12f8::,2001:12f8:1:ffff:ffff:ffff:ffff:ffff,BR
2001:12f8:4::,2001:12f8:4:ffff:ffff:ffff:ffff:ffff,BR
2001:12fe::,2001:12ff:ffff:ffff:ffff:ffff:ffff:ffff,BR
-2001:1300::,2001:13ff:ffff:ffff:ffff:ffff:ffff:ffff,PE
-2001:1400::,2001:14ff:ffff:ffff:ffff:ffff:ffff:ffff,SI
+2001:1300::,2001:1300:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2001:1308::,2001:1308:ffff:ffff:ffff:ffff:ffff:ffff,DO
+2001:1310::,2001:1310:ffff:ffff:ffff:ffff:ffff:ffff,CL
+2001:1318::,2001:1318:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2001:1320::,2001:1320:ffff:ffff:ffff:ffff:ffff:ffff,PY
+2001:1328::,2001:1328:ffff:ffff:ffff:ffff:ffff:ffff,UY
+2001:1330::,2001:1337:ffff:ffff:ffff:ffff:ffff:ffff,CR
+2001:1338::,2001:1338:ffff:ffff:ffff:ffff:ffff:ffff,VE
+2001:1340::,2001:1340:ffff:ffff:ffff:ffff:ffff:ffff,CU
+2001:1348::,2001:1348:ffff:ffff:ffff:ffff:ffff:ffff,UY
+2001:1350::,2001:1350:ffff:ffff:ffff:ffff:ffff:ffff,VE
+2001:1358::,2001:1358:ffff:ffff:ffff:ffff:ffff:ffff,CU
+2001:1360::,2001:1360:ffff:ffff:ffff:ffff:ffff:ffff,GT
+2001:1368::,2001:1368:ffff:ffff:ffff:ffff:ffff:ffff,PA
+2001:1370::,2001:1370:ffff:ffff:ffff:ffff:ffff:ffff,HT
+2001:1378::,2001:1378:ffff:ffff:ffff:ffff:ffff:ffff,BO
+2001:1380::,2001:1380:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2001:1388::,2001:1388:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2001:1398::,2001:1398:ffff:ffff:ffff:ffff:ffff:ffff,CL
+2001:13a0::,2001:13a0:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2001:13a8::,2001:13a8:ffff:ffff:ffff:ffff:ffff:ffff,MX
+2001:13b0::,2001:13b7:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2001:13c7:6000::,2001:13c7:6000:ffff:ffff:ffff:ffff:ffff,CO
+2001:13c7:6001::,2001:13c7:6001:ffff:ffff:ffff:ffff:ffff,AR
+2001:13c7:6002::,2001:13c7:6002:ffff:ffff:ffff:ffff:ffff,SX
+2001:13c7:6003::,2001:13c7:6003:ffff:ffff:ffff:ffff:ffff,HT
+2001:13c7:6004::,2001:13c7:6005:ffff:ffff:ffff:ffff:ffff,CW
+2001:13c7:6006::,2001:13c7:6006:ffff:ffff:ffff:ffff:ffff,EC
+2001:13c7:6007::,2001:13c7:600e:ffff:ffff:ffff:ffff:ffff,AR
+2001:13c7:6010::,2001:13c7:601f:ffff:ffff:ffff:ffff:ffff,AR
+2001:13c7:6f00::,2001:13c7:6fff:ffff:ffff:ffff:ffff:ffff,EC
+2001:13c7:7000::,2001:13c7:7000:ffff:ffff:ffff:ffff:ffff,MX
+2001:13c7:7001::,2001:13c7:7003:ffff:ffff:ffff:ffff:ffff,UY
+2001:13c7:7004::,2001:13c7:7004:ffff:ffff:ffff:ffff:ffff,CR
+2001:13c7:7005::,2001:13c7:7009:ffff:ffff:ffff:ffff:ffff,UY
+2001:13c7:7010::,2001:13c7:7013:ffff:ffff:ffff:ffff:ffff,UY
+2001:13c7:7014::,2001:13c7:7014:ffff:ffff:ffff:ffff:ffff,MX
+2001:13c8::,2001:13c8:ffff:ffff:ffff:ffff:ffff:ffff,CU
+2001:13d0::,2001:13d7:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2001:13d8::,2001:13d8:ffff:ffff:ffff:ffff:ffff:ffff,CR
+2001:13e0::,2001:13e0:ffff:ffff:ffff:ffff:ffff:ffff,DO
+2001:13e8::,2001:13e8:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2001:13f0::,2001:13f0:ffff:ffff:ffff:ffff:ffff:ffff,DO
+2001:13f8::,2001:13f8:ffff:ffff:ffff:ffff:ffff:ffff,CO
+2001:1400::,2001:1400:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2001:1408::,2001:1408:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2001:1410::,2001:1410:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:1418::,2001:1418:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2001:1420::,2001:1420:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2001:1428::,2001:1428:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2001:1430::,2001:1430:ffff:ffff:ffff:ffff:ffff:ffff,FI
+2001:1438::,2001:1438:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:1440::,2001:1440:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:1448::,2001:1448:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2001:1450::,2001:1450:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2001:1458::,2001:1459:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2001:1460::,2001:1460:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2001:1468::,2001:146f:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2001:1470::,2001:1477:ffff:ffff:ffff:ffff:ffff:ffff,SI
+2001:1478::,2001:1478:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2001:1488::,2001:1488:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2001:1490::,2001:1490:ffff:ffff:ffff:ffff:ffff:ffff,SA
+2001:1498::,2001:1498:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2001:14a0::,2001:14a0:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2001:14a8::,2001:14a8:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2001:14b0::,2001:14b0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:14b8::,2001:14bf:ffff:ffff:ffff:ffff:ffff:ffff,FI
+2001:14c0::,2001:14c0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:14c8::,2001:14c8:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2001:14d0::,2001:14d0:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2001:14d8::,2001:14d8:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:14e0::,2001:14e0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:14e8::,2001:14e8:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2001:14f0::,2001:14f0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:14f8::,2001:14f8:ffff:ffff:ffff:ffff:ffff:ffff,DE
2001:1500::,2001:1500:ffff:ffff:ffff:ffff:ffff:ffff,IR
2001:1508::,2001:1508:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2001:1510::,2001:1510:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -448,7 +395,34 @@
2001:16f0::,2001:16f0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2001:16f8::,2001:16f8:ffff:ffff:ffff:ffff:ffff:ffff,NL
2001:1700::,2001:171f:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:1800::,2001:1900:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1800::,2001:1800:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1808::,2001:1808:ffff:ffff:ffff:ffff:ffff:ffff,GD
+2001:1810::,2001:1810:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1818::,2001:1818:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1820::,2001:1820:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1828::,2001:1828:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1830::,2001:1830:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1838::,2001:1838:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1840::,2001:1840:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1848::,2001:1848:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1850::,2001:1850:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1860::,2001:1860:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1868::,2001:1868:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1878::,2001:1878:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1888::,2001:1888:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:1890::,2001:1898:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18a0::,2001:18a0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18a8::,2001:18a8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18b0::,2001:18b0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18b8::,2001:18b8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18c0::,2001:18c0:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2001:18c8::,2001:18c8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18d8::,2001:18d8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18e0::,2001:18e0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18e8::,2001:18e8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:18f0::,2001:18f0:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2001:18f8::,2001:18f8:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2001:1900::,2001:1900:ffff:ffff:ffff:ffff:ffff:ffff,US
2001:1908::,2001:1908:ffff:ffff:ffff:ffff:ffff:ffff,US
2001:1910::,2001:1910:ffff:ffff:ffff:ffff:ffff:ffff,US
2001:1920::,2001:1920:ffff:ffff:ffff:ffff:ffff:ffff,CA
@@ -494,7 +468,7 @@
2001:1a68::,2001:1a68:ffff:ffff:ffff:ffff:ffff:ffff,PL
2001:1a70::,2001:1a70:ffff:ffff:ffff:ffff:ffff:ffff,MT
2001:1a78::,2001:1a78:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:1a80::,2001:1a80:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2001:1a80::,2001:1a87:ffff:ffff:ffff:ffff:ffff:ffff,DE
2001:1a88::,2001:1a8f:ffff:ffff:ffff:ffff:ffff:ffff,CH
2001:1a90::,2001:1a90:ffff:ffff:ffff:ffff:ffff:ffff,GB
2001:1a98::,2001:1a9f:ffff:ffff:ffff:ffff:ffff:ffff,IS
@@ -628,7 +602,6 @@
2001:42d8::,2001:42d8:ffff:ffff:ffff:ffff:ffff:ffff,CI
2001:42e0::,2001:42e0:ffff:ffff:ffff:ffff:ffff:ffff,SC
2001:42f0::,2001:42f0:ffff:ffff:ffff:ffff:ffff:ffff,ZA
-2001:42f8::,2001:42f8:ffff:ffff:ffff:ffff:ffff:ffff,GH
2001:4300::,2001:4300:ffff:ffff:ffff:ffff:ffff:ffff,EG
2001:4308::,2001:4308:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2001:4310::,2001:4310:ffff:ffff:ffff:ffff:ffff:ffff,MA
@@ -668,7 +641,6 @@
2001:43f8:a0::,2001:43f8:a0:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:b0::,2001:43f8:b0:ffff:ffff:ffff:ffff:ffff,SL
2001:43f8:c0::,2001:43f8:c0:ffff:ffff:ffff:ffff:ffff,KE
-2001:43f8:d0::,2001:43f8:d0:ffff:ffff:ffff:ffff:ffff,MU
2001:43f8:e0::,2001:43f8:e0:ffff:ffff:ffff:ffff:ffff,TZ
2001:43f8:100::,2001:43f8:100:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:110::,2001:43f8:110:ffff:ffff:ffff:ffff:ffff,MU
@@ -687,7 +659,6 @@
2001:43f8:1f0::,2001:43f8:1f5:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:200::,2001:43f8:200:ffff:ffff:ffff:ffff:ffff,KE
2001:43f8:210::,2001:43f8:210:ffff:ffff:ffff:ffff:ffff,LS
-2001:43f8:220::,2001:43f8:220:ffff:ffff:ffff:ffff:ffff,MU
2001:43f8:230::,2001:43f8:230:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:240::,2001:43f8:241:ffff:ffff:ffff:ffff:ffff,GH
2001:43f8:250::,2001:43f8:250:ffff:ffff:ffff:ffff:ffff,KE
@@ -706,7 +677,7 @@
2001:43f8:360::,2001:43f8:360:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:370::,2001:43f8:370:ffff:ffff:ffff:ffff:ffff,NG
2001:43f8:380::,2001:43f8:380:ffff:ffff:ffff:ffff:ffff,MW
-2001:43f8:390::,2001:43f8:390:ffff:ffff:ffff:ffff:ffff,AO
+2001:43f8:390::,2001:43f8:391:ffff:ffff:ffff:ffff:ffff,AO
2001:43f8:3a0::,2001:43f8:3a0:ffff:ffff:ffff:ffff:ffff,ZA
2001:43f8:3b0::,2001:43f8:3b0:ffff:ffff:ffff:ffff:ffff,NA
2001:43f8:3c0::,2001:43f8:3c0:ffff:ffff:ffff:ffff:ffff,CD
@@ -752,6 +723,7 @@
2001:43f8:990::,2001:43f8:991:ffff:ffff:ffff:ffff:ffff,BI
2001:43f8:9a0::,2001:43f8:9a0:ffff:ffff:ffff:ffff:ffff,BJ
2001:43f8:9b0::,2001:43f8:9b1:ffff:ffff:ffff:ffff:ffff,SZ
+2001:43f8:9c0::,2001:43f8:9c0:ffff:ffff:ffff:ffff:ffff,DJ
2001:4400::,2001:44ff:ffff:ffff:ffff:ffff:ffff:ffff,AU
2001:4500::,2001:4500:ffff:ffff:ffff:ffff:ffff:ffff,TW
2001:4508::,2001:4508:ffff:ffff:ffff:ffff:ffff:ffff,TW
@@ -763,34 +735,7 @@
2001:4540::,2001:455f:ffff:ffff:ffff:ffff:ffff:ffff,TW
2001:4580::,2001:45bf:ffff:ffff:ffff:ffff:ffff:ffff,TW
2001:4600::,2001:46ff:ffff:ffff:ffff:ffff:ffff:ffff,NO
-2001:4800::,2001:4808:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4810::,2001:4810:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4818::,2001:4818:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2001:4828::,2001:4828:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4830::,2001:4830:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4838::,2001:4838:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4840::,2001:4840:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4848::,2001:4848:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4850::,2001:4850:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4858::,2001:4858:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4860::,2001:4860:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4868::,2001:4868:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4870::,2001:4871:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4878::,2001:4878:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4888::,2001:4888:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4890::,2001:4890:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:4898::,2001:489a:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48a0::,2001:48a0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48a8::,2001:48a8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48b0::,2001:48b0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48b8::,2001:48b8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48c0::,2001:48c0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48c8::,2001:48c8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48d0::,2001:48d0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48d8::,2001:48d8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48e0::,2001:48e0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48e8::,2001:48e8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2001:48f8::,2001:48f8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2001:4800::,2001:48ff:ffff:ffff:ffff:ffff:ffff:ffff,US
2001:4900::,2001:4900:ffff:ffff:ffff:ffff:ffff:ffff,CA
2001:4908::,2001:4908:ffff:ffff:ffff:ffff:ffff:ffff,US
2001:4910::,2001:4910:ffff:ffff:ffff:ffff:ffff:ffff,BM
@@ -854,36 +799,7 @@
2001:4be8::,2001:4be8:ffff:ffff:ffff:ffff:ffff:ffff,GB
2001:4bf0::,2001:4bf0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2001:4bf8::,2001:4bf8:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:4c00::,2001:4cff:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4d00::,2001:4d00:ffff:ffff:ffff:ffff:ffff:ffff,AM
-2001:4d08::,2001:4d08:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4d10::,2001:4d10:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2001:4d18::,2001:4d18:ffff:ffff:ffff:ffff:ffff:ffff,RO
-2001:4d20::,2001:4d20:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4d30::,2001:4d30:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2001:4d38::,2001:4d38:ffff:ffff:ffff:ffff:ffff:ffff,IT
-2001:4d48::,2001:4d48:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2001:4d50::,2001:4d50:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4d58::,2001:4d58:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:4d60::,2001:4d60:ffff:ffff:ffff:ffff:ffff:ffff,NL
-2001:4d68::,2001:4d68:ffff:ffff:ffff:ffff:ffff:ffff,IE
-2001:4d70::,2001:4d70:ffff:ffff:ffff:ffff:ffff:ffff,GR
-2001:4d78::,2001:4d78:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2001:4d80::,2001:4d80:ffff:ffff:ffff:ffff:ffff:ffff,RO
-2001:4d88::,2001:4d88:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4d90::,2001:4d90:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2001:4d98::,2001:4d98:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:4da0::,2001:4da7:ffff:ffff:ffff:ffff:ffff:ffff,CH
-2001:4da8::,2001:4da8:ffff:ffff:ffff:ffff:ffff:ffff,NO
-2001:4db0::,2001:4db0:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2001:4db8::,2001:4db8:ffff:ffff:ffff:ffff:ffff:ffff,SE
-2001:4dc0::,2001:4dc0:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2001:4dc8::,2001:4dc8:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4dd0::,2001:4dd7:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2001:4dd8::,2001:4dd8:ffff:ffff:ffff:ffff:ffff:ffff,NO
-2001:4de0::,2001:4de0:ffff:ffff:ffff:ffff:ffff:ffff,NL
-2001:4de8::,2001:4de8:ffff:ffff:ffff:ffff:ffff:ffff,CZ
-2001:4df0::,2001:4df0:ffff:ffff:ffff:ffff:ffff:ffff,IL
+2001:4c00::,2001:4dff:ffff:ffff:ffff:ffff:ffff:ffff,DE
2001:8000::,2001:8fff:ffff:ffff:ffff:ffff:ffff:ffff,AU
2001:a000::,2001:a7ff:ffff:ffff:ffff:ffff:ffff:ffff,JP
2001:b000::,2001:b7ff:ffff:ffff:ffff:ffff:ffff:ffff,TW
@@ -892,7 +808,6 @@
2400:1000::,2400:1000:ffff:ffff:ffff:ffff:ffff:ffff,JP
2400:1080::,2400:1080:ffff:ffff:ffff:ffff:ffff:ffff,HK
2400:1100::,2400:1100:ffff:ffff:ffff:ffff:ffff:ffff,HK
-2400:1180::,2400:1180:ffff:ffff:ffff:ffff:ffff:ffff,HK
2400:1200::,2400:1200:ffff:ffff:ffff:ffff:ffff:ffff,NZ
2400:1300::,2400:1300:ffff:ffff:ffff:ffff:ffff:ffff,TW
2400:1380::,2400:1380:ffff:ffff:ffff:ffff:ffff:ffff,CN
@@ -934,7 +849,6 @@
2400:3580::,2400:3580:ffff:ffff:ffff:ffff:ffff:ffff,ID
2400:3600::,2400:3600:ffff:ffff:ffff:ffff:ffff:ffff,CN
2400:3680::,2400:3680:ffff:ffff:ffff:ffff:ffff:ffff,IN
-2400:3700::,2400:3700:ffff:ffff:ffff:ffff:ffff:ffff,MY
2400:3800::,2400:3800:ffff:ffff:ffff:ffff:ffff:ffff,JP
2400:3880::,2400:3880:ffff:ffff:ffff:ffff:ffff:ffff,AU
2400:3900::,2400:3900:ffff:ffff:ffff:ffff:ffff:ffff,AU
@@ -1089,7 +1003,8 @@
2400:8780::,2400:8780:ffff:ffff:ffff:ffff:ffff:ffff,CN
2400:8800::,2400:8800:ffff:ffff:ffff:ffff:ffff:ffff,HK
2400:8880::,2400:8880:ffff:ffff:ffff:ffff:ffff:ffff,IN
-2400:8900::,2400:89ff:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2400:8900::,2400:8900:ffff:ffff:ffff:ffff:ffff:ffff,SG
+2400:8980::,2400:8980:ffff:ffff:ffff:ffff:ffff:ffff,CN
2400:8a00::,2400:8a00:ffff:ffff:ffff:ffff:ffff:ffff,AU
2400:8a80::,2400:8a80:ffff:ffff:ffff:ffff:ffff:ffff,PH
2400:8b00::,2400:8b00:ffff:ffff:ffff:ffff:ffff:ffff,ID
@@ -1326,7 +1241,7 @@
2401:280::,2401:280:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:300::,2401:300:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:380::,2401:380:ffff:ffff:ffff:ffff:ffff:ffff,AU
-2401:400::,2401:400:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2401:400::,2401:403:ffff:ffff:ffff:ffff:ffff:ffff,AU
2401:480::,2401:480:ffff:ffff:ffff:ffff:ffff:ffff,PH
2401:500::,2401:500:ffff:ffff:ffff:ffff:ffff:ffff,TH
2401:580::,2401:580:ffff:ffff:ffff:ffff:ffff:ffff,BD
@@ -1351,7 +1266,6 @@
2401:f00::,2401:f00:ffff:ffff:ffff:ffff:ffff:ffff,ID
2401:f80::,2401:f80:ffff:ffff:ffff:ffff:ffff:ffff,AU
2401:1000::,2401:1000:ffff:ffff:ffff:ffff:ffff:ffff,CN
-2401:1080::,2401:1080:ffff:ffff:ffff:ffff:ffff:ffff,IN
2401:1100::,2401:1100:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:1180::,2401:1180:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:1200::,2401:1200:ffff:ffff:ffff:ffff:ffff:ffff,CN
@@ -1408,45 +1322,86 @@
2401:2b00::,2401:2b00:ffff:ffff:ffff:ffff:ffff:ffff,BD
2401:2b80::,2401:2b80:ffff:ffff:ffff:ffff:ffff:ffff,NP
2401:2c00::,2401:2c00:ffff:ffff:ffff:ffff:ffff:ffff,NZ
+2401:2c80::,2401:2c80:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:2d00::,2401:2d00:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2401:2d80::,2401:2d80:ffff:ffff:ffff:ffff:ffff:ffff,SG
2401:2e00::,2401:2e00:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:2e80::,2401:2e80:ffff:ffff:ffff:ffff:ffff:ffff,NZ
2401:2f00::,2401:2f00:ffff:ffff:ffff:ffff:ffff:ffff,SG
+2401:2f80::,2401:2f80:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:3000::,2401:3000:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2401:3080::,2401:3080:ffff:ffff:ffff:ffff:ffff:ffff,AU
2401:3100::,2401:3100:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:3180::,2401:3180:ffff:ffff:ffff:ffff:ffff:ffff,AU
2401:3200::,2401:3200:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2401:3280::,2401:3280:ffff:ffff:ffff:ffff:ffff:ffff,MO
2401:3300::,2401:3300:ffff:ffff:ffff:ffff:ffff:ffff,BD
+2401:3380::,2401:3380:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3400::,2401:3400:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2401:3480::,2401:3480:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3500::,2401:3500:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2401:3580::,2401:3580:ffff:ffff:ffff:ffff:ffff:ffff,BD
2401:3600::,2401:3600:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2401:3680::,2401:3680:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2401:3780::,2401:3780:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3800::,2401:3800:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:3880::,2401:3880:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3900::,2401:3900:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2401:3980::,2401:3980:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3a00::,2401:3a00:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:3a80::,2401:3a80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3b00::,2401:3b00:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2401:3b80::,2401:3b80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3c00::,2401:3c00:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2401:3c80::,2401:3c80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3d00::,2401:3d0f:ffff:ffff:ffff:ffff:ffff:ffff,SG
+2401:3d80::,2401:3d80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3e00::,2401:3e00:ffff:ffff:ffff:ffff:ffff:ffff,KH
+2401:3e80::,2401:3e80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:3f00::,2401:3f00:ffff:ffff:ffff:ffff:ffff:ffff,SG
+2401:3f80::,2401:3f80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4000::,2401:4000:ffff:ffff:ffff:ffff:ffff:ffff,KR
+2401:4080::,2401:4080:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4100::,2401:4100:ffff:ffff:ffff:ffff:ffff:ffff,PK
+2401:4180::,2401:4180:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4200::,2401:4200:ffff:ffff:ffff:ffff:ffff:ffff,ID
+2401:4280::,2401:4280:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4300::,2401:4300:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2401:4380::,2401:4380:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4400::,2401:4400:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2401:4480::,2401:4480:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4500::,2401:4500:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2401:4580::,2401:4580:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:4680::,2401:4680:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4700::,2401:4700:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2401:4780::,2401:4780:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4800::,2401:4800:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2401:4880::,2401:4880:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4900::,2401:4900:ffff:ffff:ffff:ffff:ffff:ffff,IN
2401:4a00::,2401:4a00:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2401:4a80::,2401:4a80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:4b00::,2401:4b00:ffff:ffff:ffff:ffff:ffff:ffff,CN
+2401:4b80::,2401:4b80:ffff:ffff:ffff:ffff:ffff:ffff,TL
2401:4c00::,2401:4c00:ffff:ffff:ffff:ffff:ffff:ffff,HK
+2401:4c80::,2401:4c80:ffff:ffff:ffff:ffff:ffff:ffff,AU
2401:4d00::,2401:4d00:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2401:4d80::,2401:4d80:ffff:ffff:ffff:ffff:ffff:ffff,KH
2401:4e00::,2401:4e00:ffff:ffff:ffff:ffff:ffff:ffff,ID
+2401:4e80::,2401:4e80:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:4f00::,2401:4f00:ffff:ffff:ffff:ffff:ffff:ffff,TH
+2401:4f80::,2401:4f80:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:5000::,2401:5000:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2401:5080::,2401:5080:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:5100::,2401:5100:ffff:ffff:ffff:ffff:ffff:ffff,FJ
+2401:5180::,2401:5180:ffff:ffff:ffff:ffff:ffff:ffff,CN
2401:5200::,2401:5200:ffff:ffff:ffff:ffff:ffff:ffff,MY
+2401:5280::,2401:5280:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:5300::,2401:5300:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2401:5380::,2401:5380:ffff:ffff:ffff:ffff:ffff:ffff,SG
2401:5400::,2401:5400:ffff:ffff:ffff:ffff:ffff:ffff,ID
+2401:5480::,2401:5480:ffff:ffff:ffff:ffff:ffff:ffff,HK
2401:5500::,2401:5500:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2401:5580::,2401:5580:ffff:ffff:ffff:ffff:ffff:ffff,NZ
2401:5700::,2401:5700:ffff:ffff:ffff:ffff:ffff:ffff,TH
2401:5800::,2401:5800:ffff:ffff:ffff:ffff:ffff:ffff,BD
2401:5900::,2401:5900:ffff:ffff:ffff:ffff:ffff:ffff,HK
@@ -1701,7 +1656,7 @@
2402:6800::,2402:6800:ffff:ffff:ffff:ffff:ffff:ffff,JP
2402:6900::,2402:6900:ffff:ffff:ffff:ffff:ffff:ffff,AU
2402:6a00::,2402:6a00:ffff:ffff:ffff:ffff:ffff:ffff,CN
-2402:6b00::,2402:6bff:ffff:ffff:ffff:ffff:ffff:ffff,JP
+2402:6b00::,2402:6b00:ffff:ffff:ffff:ffff:ffff:ffff,JP
2402:6c00::,2402:6c00:ffff:ffff:ffff:ffff:ffff:ffff,MY
2402:6d00::,2402:6d00:ffff:ffff:ffff:ffff:ffff:ffff,PF
2402:6e00::,2402:6e00:ffff:ffff:ffff:ffff:ffff:ffff,CN
@@ -2050,7 +2005,6 @@
2403:d400::,2403:d400:ffff:ffff:ffff:ffff:ffff:ffff,CN
2403:d500::,2403:d500:ffff:ffff:ffff:ffff:ffff:ffff,AU
2403:d600::,2403:d600:ffff:ffff:ffff:ffff:ffff:ffff,AU
-2403:d700::,2403:d700:ffff:ffff:ffff:ffff:ffff:ffff,MN
2403:d800::,2403:d800:ffff:ffff:ffff:ffff:ffff:ffff,NZ
2403:d900::,2403:d900:ffff:ffff:ffff:ffff:ffff:ffff,AU
2403:da00::,2403:da00:ffff:ffff:ffff:ffff:ffff:ffff,ID
@@ -2187,7 +2141,7 @@
2404:4c00::,2404:4c00:ffff:ffff:ffff:ffff:ffff:ffff,AU
2404:4d00::,2404:4d00:ffff:ffff:ffff:ffff:ffff:ffff,CN
2404:4e00::,2404:4e00:ffff:ffff:ffff:ffff:ffff:ffff,SG
-2404:4f00::,2404:4f00:ffff:ffff:ffff:ffff:ffff:ffff,AU
+2404:4f00::,2404:4f01:ffff:ffff:ffff:ffff:ffff:ffff,AU
2404:5000::,2404:5000:ffff:ffff:ffff:ffff:ffff:ffff,AU
2404:5100::,2404:5100:ffff:ffff:ffff:ffff:ffff:ffff,JP
2404:5200::,2404:5200:ffff:ffff:ffff:ffff:ffff:ffff,JP
@@ -2887,7 +2841,6 @@
2407:2000::,2407:2000:ffff:ffff:ffff:ffff:ffff:ffff,KR
2407:2100::,2407:2100:ffff:ffff:ffff:ffff:ffff:ffff,HK
2407:2200::,2407:2200:ffff:ffff:ffff:ffff:ffff:ffff,AU
-2407:2300::,2407:2300:ffff:ffff:ffff:ffff:ffff:ffff,PG
2407:2400::,2407:2400:ffff:ffff:ffff:ffff:ffff:ffff,NZ
2407:2500::,2407:2500:ffff:ffff:ffff:ffff:ffff:ffff,AU
2407:2600::,2407:2600:ffff:ffff:ffff:ffff:ffff:ffff,AU
@@ -3137,6 +3090,7 @@
2600:1b00::,2600:1bff:ffff:ffff:ffff:ffff:ffff:ffff,JM
2600:1c00::,2600:1c0f:ffff:ffff:ffff:ffff:ffff:ffff,US
2600:1d00::,2600:1d0f:ffff:ffff:ffff:ffff:ffff:ffff,US
+2600:1e00::,2600:1e0f:ffff:ffff:ffff:ffff:ffff:ffff,VC
2600:2000::,2600:200f:ffff:ffff:ffff:ffff:ffff:ffff,US
2600:2400::,2600:2407:ffff:ffff:ffff:ffff:ffff:ffff,US
2600:2800::,2600:2803:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3163,6 +3117,7 @@
2600:7c00::,2600:7c0f:ffff:ffff:ffff:ffff:ffff:ffff,VC
2600:8000::,2600:80ff:ffff:ffff:ffff:ffff:ffff:ffff,US
2600:8400::,2600:840f:ffff:ffff:ffff:ffff:ffff:ffff,BB
+2600:8800::,2600:880f:ffff:ffff:ffff:ffff:ffff:ffff,US
2600:e000::,2600:e00f:ffff:ffff:ffff:ffff:ffff:ffff,CA
2601::,2601:ff:ffff:ffff:ffff:ffff:ffff:ffff,US
2602::,2602:10f:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3173,6 +3128,10 @@
2602:232::,2602:232:ffff:ffff:ffff:ffff:ffff:ffff,CA
2602:240::,2602:25f:ffff:ffff:ffff:ffff:ffff:ffff,US
2602:300::,2602:3ff:ffff:ffff:ffff:ffff:ffff:ffff,US
+2602:ffb0::,2602:ffb0:fff:ffff:ffff:ffff:ffff:ffff,US
+2602:ffb1::,2602:ffb1:fff:ffff:ffff:ffff:ffff:ffff,CA
+2602:ffb2::,2602:ffb2:fff:ffff:ffff:ffff:ffff:ffff,US
+2602:ffb3::,2602:ffb3:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffb4::,2602:ffb4:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffb5::,2602:ffb5:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffb6::,2602:ffb6:fff:ffff:ffff:ffff:ffff:ffff,CA
@@ -3225,8 +3184,7 @@
2602:ffe6::,2602:ffe6:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffe7::,2602:ffe7:fff:ffff:ffff:ffff:ffff:ffff,PR
2602:ffe8::,2602:ffe9:fff:ffff:ffff:ffff:ffff:ffff,US
-2602:ffea::,2602:ffea:fff:ffff:ffff:ffff:ffff:ffff,US
-2602:ffeb::,2602:ffeb:fff:ffff:ffff:ffff:ffff:ffff,US
+2602:ffea::,2602:ffeb:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffec::,2602:ffec:fff:ffff:ffff:ffff:ffff:ffff,CA
2602:ffed::,2602:ffed:fff:ffff:ffff:ffff:ffff:ffff,US
2602:ffee::,2602:ffee:fff:ffff:ffff:ffff:ffff:ffff,US
@@ -3362,6 +3320,7 @@
2604:3900::,2604:3900:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:3980::,2604:3980:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:3a00::,2604:3a00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2604:3a80::,2604:3a80:ffff:ffff:ffff:ffff:ffff:ffff,CA
2604:3b00::,2604:3b00:ffff:ffff:ffff:ffff:ffff:ffff,CA
2604:3b80::,2604:3b80:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:3c00::,2604:3c00:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3374,7 +3333,7 @@
2604:3f80::,2604:3f80:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:4000::,2604:4000:ffff:ffff:ffff:ffff:ffff:ffff,CA
2604:4080::,2604:4080:ffff:ffff:ffff:ffff:ffff:ffff,US
-2604:4100::,2604:4100:ffff:ffff:ffff:ffff:ffff:ffff,US
+2604:4100::,2604:4100:fff:ffff:ffff:ffff:ffff:ffff,US
2604:4180::,2604:4180:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:4200::,2604:4200:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:4280::,2604:4280:ffff:ffff:ffff:ffff:ffff:ffff,CA
@@ -3473,7 +3432,6 @@
2604:7200::,2604:7200:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:7280::,2604:7280:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:7300::,2604:7300:ffff:ffff:ffff:ffff:ffff:ffff,US
-2604:7380::,2604:7380:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:7400::,2604:7400:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:7480::,2604:7480:ffff:ffff:ffff:ffff:ffff:ffff,CA
2604:7500::,2604:7500:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3540,6 +3498,7 @@
2604:9400::,2604:9400:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:9480::,2604:9480:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:9500::,2604:9500:ffff:ffff:ffff:ffff:ffff:ffff,US
+2604:9580::,2604:9580:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:9600::,2604:9600:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:9680::,2604:9680:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:9700::,2604:9700:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3677,6 +3636,7 @@
2604:da00::,2604:da00:fff:ffff:ffff:ffff:ffff:ffff,US
2604:da80::,2604:da80:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:db00::,2604:db00:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2604:db80::,2604:db80:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:dc00::,2604:dc00:ffff:ffff:ffff:ffff:ffff:ffff,CA
2604:dc80::,2604:dc80:ffff:ffff:ffff:ffff:ffff:ffff,US
2604:dd00::,2604:dd00:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -3828,7 +3788,6 @@
2605:2600::,2605:2600:ffff:ffff:ffff:ffff:ffff:ffff,CA
2605:2680::,2605:2680:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:2700::,2605:2700:ffff:ffff:ffff:ffff:ffff:ffff,US
-2605:2780::,2605:2780:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:2800::,2605:2800:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:2880::,2605:2880:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:2900::,2605:2900:ffff:ffff:ffff:ffff:ffff:ffff,CA
@@ -3941,6 +3900,7 @@
2605:5f00::,2605:5f00:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:5f80::,2605:5f80:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:6000::,2605:6100:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:6180::,2605:6180:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:6200::,2605:6200:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:6280::,2605:6280:ffff:ffff:ffff:ffff:ffff:ffff,AI
2605:6300::,2605:6300:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -4032,16 +3992,27 @@
2605:8e00::,2605:8e00:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:8e80::,2605:8e80:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:8f00::,2605:8f00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:8f80::,2605:8f80:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9000::,2605:9000:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2605:9080::,2605:9080:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9100::,2605:9100:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9180::,2605:9180:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9200::,2605:9200:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9280::,2605:9280:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9300::,2605:9300:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2605:9380::,2605:9380:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9400::,2605:9400:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9480::,2605:9480:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9500::,2605:9500:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9580::,2605:9580:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9600::,2605:9600:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9680::,2605:9680:ffff:ffff:ffff:ffff:ffff:ffff,CA
2605:9700::,2605:9700:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9780::,2605:9780:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9800::,2605:9800:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9880::,2605:9880:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9900::,2605:9900:ffff:ffff:ffff:ffff:ffff:ffff,US
+2605:9980::,2605:9980:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9a00::,2605:9a00:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9b00::,2605:9b00:ffff:ffff:ffff:ffff:ffff:ffff,US
2605:9c00::,2605:9c00:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -4322,6 +4293,7 @@
2606:b400::,2606:b400:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:b500::,2606:b500:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:b600::,2606:b600:fff:ffff:ffff:ffff:ffff:ffff,US
+2606:b700::,2606:b700:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:b800::,2606:b800:ffff:ffff:ffff:ffff:ffff:ffff,CA
2606:b900::,2606:b900:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:ba00::,2606:ba00:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -4332,7 +4304,6 @@
2606:bf00::,2606:bf00:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:c000::,2606:c000:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:c100::,2606:c100:ffff:ffff:ffff:ffff:ffff:ffff,US
-2606:c200::,2606:c200:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:c300::,2606:c300:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:c400::,2606:c400:ffff:ffff:ffff:ffff:ffff:ffff,US
2606:c500::,2606:c500:ffff:ffff:ffff:ffff:ffff:ffff,JM
@@ -4487,6 +4458,7 @@
2607:5a00::,2607:5a00:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:5b00::,2607:5b00:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:5c00::,2607:5c00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:5d00::,2607:5d00:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:5e00::,2607:5e00:ffff:ffff:ffff:ffff:ffff:ffff,CA
2607:5f00::,2607:5f00:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:6000::,2607:6000:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -4722,36 +4694,7 @@
2607:f2e8::,2607:f2e8:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f2f0::,2607:f2f0:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f2f8::,2607:f2f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f300::,2607:f300:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f308::,2607:f308:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f310::,2607:f310:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f318::,2607:f318:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f330::,2607:f330:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f338::,2607:f338:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2607:f340::,2607:f340:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f348::,2607:f348:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f350::,2607:f350:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f358::,2607:f358:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f360::,2607:f360:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f368::,2607:f368:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f370::,2607:f370:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f378::,2607:f378:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f380::,2607:f380:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f388::,2607:f388:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f390::,2607:f390:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f398::,2607:f398:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3a0::,2607:f3a0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3b0::,2607:f3b0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3b8::,2607:f3b8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3c0::,2607:f3c0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3c8::,2607:f3c8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3d0::,2607:f3d0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3d8::,2607:f3d8:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2607:f3e0::,2607:f3e0:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2607:f3e8::,2607:f3e8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3f0::,2607:f3f0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f3f8::,2607:f3f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:f400::,2607:f400:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:f300::,2607:f400:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f408::,2607:f408:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f418::,2607:f418:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f420::,2607:f420:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -4930,8 +4873,67 @@
2607:f9e0::,2607:f9e0:fff:ffff:ffff:ffff:ffff:ffff,US
2607:f9f0::,2607:f9f1:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:f9f8::,2607:f9f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2607:fa00::,2607:faff:ffff:ffff:ffff:ffff:ffff:ffff,CA
-2607:fb00::,2607:fd00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa00::,2607:fa00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa08::,2607:fa08:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa10::,2607:fa10:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa18::,2607:fa18:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa20::,2607:fa20:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa28::,2607:fa28:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa38::,2607:fa38:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa40::,2607:fa40:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa48::,2607:fa48:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2607:fa58::,2607:fa58:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa60::,2607:fa60:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa68::,2607:fa68:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa70::,2607:fa70:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa78::,2607:fa78:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa88::,2607:fa88:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa90::,2607:fa90:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fa98::,2607:fa98:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:faa0::,2607:faa0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:faa8::,2607:faa8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fab0::,2607:fab0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fab8::,2607:fab8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fac0::,2607:fac0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fac8::,2607:fac8:fff:ffff:ffff:ffff:ffff:ffff,US
+2607:fad0::,2607:fad0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fad8::,2607:fad8:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2607:fae0::,2607:fae0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fae8::,2607:fae8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:faf0::,2607:faf0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:faf8::,2607:faf8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb00::,2607:fb00:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb08::,2607:fb08:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb10::,2607:fb10:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb18::,2607:fb18:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb20::,2607:fb20:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb28::,2607:fb28:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb30::,2607:fb30:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb38::,2607:fb38:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb40::,2607:fb40:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb48::,2607:fb48:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb50::,2607:fb50:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb58::,2607:fb58:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb60::,2607:fb60:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb68::,2607:fb68:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb70::,2607:fb70:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb78::,2607:fb78:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb80::,2607:fb80:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb88::,2607:fb88:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb90::,2607:fb90:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fb98::,2607:fb98:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fba0::,2607:fba0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fba8::,2607:fba8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbb0::,2607:fbb0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbb8::,2607:fbb8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbc0::,2607:fbc0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbd0::,2607:fbd0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbd8::,2607:fbd8:ffff:ffff:ffff:ffff:ffff:ffff,CA
+2607:fbe0::,2607:fbe0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbe8::,2607:fbe8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbf0::,2607:fbf0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fbf8::,2607:fbf8:ffff:ffff:ffff:ffff:ffff:ffff,US
+2607:fc00::,2607:fd00:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:fd08::,2607:fd08:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:fd10::,2607:fd10:ffff:ffff:ffff:ffff:ffff:ffff,US
2607:fd28::,2607:fd28:ffff:ffff:ffff:ffff:ffff:ffff,US
@@ -5096,991 +5098,7 @@
2610:1e8::,2610:1e8:ffff:ffff:ffff:ffff:ffff:ffff,CA
2610:1f0::,2610:1f0:ffff:ffff:ffff:ffff:ffff:ffff,US
2610:1f8::,2610:1f8:ffff:ffff:ffff:ffff:ffff:ffff,US
-2620::,2620::ffff:ffff:ffff:ffff:ffff,US
-2620:0:10::,2620::10:ffff:ffff:ffff:ffff:ffff,US
-2620:0:20::,2620::20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:30::,2620::37:ffff:ffff:ffff:ffff:ffff,US
-2620:0:40::,2620::40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:60::,2620::60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:70::,2620::70:ffff:ffff:ffff:ffff:ffff,US
-2620:0:80::,2620::80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:90::,2620::90:ffff:ffff:ffff:ffff:ffff,US
-2620:0:a0::,2620::a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b0::,2620::b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c0::,2620::c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:f0::,2620::f0:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:100::,2620::100:ffff:ffff:ffff:ffff:ffff,US
-2620:0:110::,2620::110:ffff:ffff:ffff:ffff:ffff,US
-2620:0:120::,2620::120:ffff:ffff:ffff:ffff:ffff,US
-2620:0:140::,2620::140:ffff:ffff:ffff:ffff:ffff,US
-2620:0:150::,2620::150:ffff:ffff:ffff:ffff:ffff,US
-2620:0:160::,2620::160:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:170::,2620::170:ffff:ffff:ffff:ffff:ffff,US
-2620:0:180::,2620::180:ffff:ffff:ffff:ffff:ffff,US
-2620:0:190::,2620::190:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a0::,2620::1a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1b0::,2620::1b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1c0::,2620::1c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1d0::,2620::1d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1f0::,2620::1f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:200::,2620::200:ffff:ffff:ffff:ffff:ffff,US
-2620:0:210::,2620::210:ffff:ffff:ffff:ffff:ffff,US
-2620:0:220::,2620::220:ffff:ffff:ffff:ffff:ffff,US
-2620:0:230::,2620::230:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:240::,2620::240:ffff:ffff:ffff:ffff:ffff,US
-2620:0:250::,2620::250:ffff:ffff:ffff:ffff:ffff,US
-2620:0:260::,2620::260:ffff:ffff:ffff:ffff:ffff,US
-2620:0:270::,2620::270:ffff:ffff:ffff:ffff:ffff,US
-2620:0:280::,2620::280:ffff:ffff:ffff:ffff:ffff,US
-2620:0:290::,2620::290:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b0::,2620::2b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2c0::,2620::2c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2d0::,2620::2d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2f0::,2620::2f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:300::,2620::300:ffff:ffff:ffff:ffff:ffff,US
-2620:0:320::,2620::320:ffff:ffff:ffff:ffff:ffff,US
-2620:0:350::,2620::353:ffff:ffff:ffff:ffff:ffff,US
-2620:0:360::,2620::361:ffff:ffff:ffff:ffff:ffff,US
-2620:0:380::,2620::380:ffff:ffff:ffff:ffff:ffff,US
-2620:0:390::,2620::390:ffff:ffff:ffff:ffff:ffff,US
-2620:0:3b0::,2620::3b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:3c0::,2620::3c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:3e0::,2620::3e0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:3f0::,2620::3f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:400::,2620::57f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:600::,2620::600:ffff:ffff:ffff:ffff:ffff,US
-2620:0:610::,2620::610:ffff:ffff:ffff:ffff:ffff,US
-2620:0:630::,2620::630:ffff:ffff:ffff:ffff:ffff,US
-2620:0:640::,2620::640:ffff:ffff:ffff:ffff:ffff,US
-2620:0:650::,2620::650:ffff:ffff:ffff:ffff:ffff,US
-2620:0:660::,2620::660:ffff:ffff:ffff:ffff:ffff,US
-2620:0:670::,2620::671:ffff:ffff:ffff:ffff:ffff,US
-2620:0:680::,2620::680:ffff:ffff:ffff:ffff:ffff,US
-2620:0:690::,2620::691:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6a0::,2620::6a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6b0::,2620::6b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6c0::,2620::6c7:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6d0::,2620::6d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6e0::,2620::6e0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:6f0::,2620::6f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:700::,2620::77f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:800::,2620::802:ffff:ffff:ffff:ffff:ffff,US
-2620:0:810::,2620::810:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:820::,2620::820:ffff:ffff:ffff:ffff:ffff,US
-2620:0:840::,2620::840:ffff:ffff:ffff:ffff:ffff,US
-2620:0:850::,2620::850:ffff:ffff:ffff:ffff:ffff,US
-2620:0:860::,2620::863:ffff:ffff:ffff:ffff:ffff,US
-2620:0:870::,2620::877:ffff:ffff:ffff:ffff:ffff,US
-2620:0:880::,2620::880:ffff:ffff:ffff:ffff:ffff,US
-2620:0:890::,2620::890:ffff:ffff:ffff:ffff:ffff,US
-2620:0:8a0::,2620::8a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:8d0::,2620::8d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:8e0::,2620::8e0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:8f0::,2620::8f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:900::,2620::900:ffff:ffff:ffff:ffff:ffff,US
-2620:0:910::,2620::910:ffff:ffff:ffff:ffff:ffff,US
-2620:0:920::,2620::920:ffff:ffff:ffff:ffff:ffff,US
-2620:0:930::,2620::930:ffff:ffff:ffff:ffff:ffff,US
-2620:0:940::,2620::940:ffff:ffff:ffff:ffff:ffff,US
-2620:0:950::,2620::950:ffff:ffff:ffff:ffff:ffff,US
-2620:0:960::,2620::960:ffff:ffff:ffff:ffff:ffff,US
-2620:0:970::,2620::970:ffff:ffff:ffff:ffff:ffff,US
-2620:0:980::,2620::980:ffff:ffff:ffff:ffff:ffff,US
-2620:0:990::,2620::990:ffff:ffff:ffff:ffff:ffff,US
-2620:0:9a0::,2620::9a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:9b0::,2620::9b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:9c0::,2620::9c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:9e0::,2620::9e0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:9f0::,2620::9f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:a00::,2620::a1f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b00::,2620::b00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b10::,2620::b13:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b20::,2620::b20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b30::,2620::b30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b40::,2620::b40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b50::,2620::b50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b60::,2620::b61:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b80::,2620::b80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:b90::,2620::b90:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ba0::,2620::ba0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:bb0::,2620::bb0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:bd0::,2620::bd0:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:be0::,2620::be0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:bf0::,2620::bf0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c10::,2620::c20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c30::,2620::c30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c40::,2620::c40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c60::,2620::c60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c70::,2620::c70:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c80::,2620::c80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:c90::,2620::ca0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:cb0::,2620::cb0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:cc0::,2620::ccf:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ce0::,2620::ce0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:cf0::,2620::cf0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d00::,2620::d00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d20::,2620::d20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d30::,2620::d30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d50::,2620::d50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d60::,2620::d63:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d70::,2620::d77:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d80::,2620::d80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:d90::,2620::d90:ffff:ffff:ffff:ffff:ffff,US
-2620:0:dc0::,2620::dc0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:dd0::,2620::dd0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:de0::,2620::de0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:df0::,2620::df0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e00::,2620::e00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e10::,2620::e10:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e20::,2620::e23:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e30::,2620::e30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e50::,2620::e50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e60::,2620::e60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e80::,2620::e80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:e90::,2620::e90:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ea0::,2620::eb0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ed0::,2620::ed0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ee0::,2620::ee0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:ef0::,2620::ef0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:f00::,2620::f7f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1000::,2620::10ff:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1400::,2620::143f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1500::,2620::157f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1600::,2620::167f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1700::,2620::170f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1800::,2620::181f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a00::,2620::1a00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a10::,2620::1a10:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a20::,2620::1a20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a30::,2620::1a30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a40::,2620::1a40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a50::,2620::1a50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a60::,2620::1a60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a70::,2620::1a70:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1a80::,2620::1a80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1aa0::,2620::1aa0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1ab0::,2620::1ab0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1ac0::,2620::1ac0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1ad0::,2620::1ad7:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1ae0::,2620::1ae0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1af0::,2620::1af0:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:1b00::,2620::1b07:ffff:ffff:ffff:ffff:ffff,US
-2620:0:1c00::,2620::1cff:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2000::,2620::203f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2100::,2620::213f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2210::,2620::2210:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2220::,2620::2220:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:2240::,2620::2240:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2250::,2620::2250:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2260::,2620::2260:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2280::,2620::2280:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2290::,2620::2290:ffff:ffff:ffff:ffff:ffff,US
-2620:0:22a0::,2620::22a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:22b0::,2620::22b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:22c0::,2620::22c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:22d0::,2620::22d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:22e0::,2620::22e0:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:22f0::,2620::22f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2300::,2620::230f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2400::,2620::24ff:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2800::,2620::2800:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2810::,2620::2810:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2820::,2620::2820:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2830::,2620::2830:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2840::,2620::2840:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2850::,2620::2850:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2860::,2620::2860:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2870::,2620::2870:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2880::,2620::2880:ffff:ffff:ffff:ffff:ffff,US
-2620:0:28a0::,2620::28a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:28b0::,2620::28b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:28d0::,2620::28d0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:28f0::,2620::28f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2900::,2620::290f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2a00::,2620::2a1f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b00::,2620::2b00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b10::,2620::2b10:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b20::,2620::2b20:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b30::,2620::2b40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b50::,2620::2b50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b60::,2620::2b60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2b70::,2620::2b8f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2bc0::,2620::2bc3:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2be0::,2620::2be0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2bf0::,2620::2bf0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2d00::,2620::2d7f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e00::,2620::2e00:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e10::,2620::2e10:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e30::,2620::2e30:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e40::,2620::2e40:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e50::,2620::2e50:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e60::,2620::2e60:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2e70::,2620::2e80:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2ea0::,2620::2ea0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2eb0::,2620::2eb0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2ed0::,2620::2ed0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2ee0::,2620::2ee0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:2f00::,2620::2f7f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5000::,2620::5000:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5010::,2620::5010:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5030::,2620::5030:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5040::,2620::5040:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5050::,2620::5050:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5060::,2620::5060:ffff:ffff:ffff:ffff:ffff,CA
-2620:0:5070::,2620::5070:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5080::,2620::5080:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5090::,2620::5090:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50a0::,2620::50a0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50b0::,2620::50b0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50c0::,2620::50c0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50d0::,2620::50d1:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50e0::,2620::50e0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:50f0::,2620::50f0:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5100::,2620::510f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5200::,2620::5200:ffff:ffff:ffff:ffff:ffff,US
-2620:0:5300::,2620::530f:ffff:ffff:ffff:ffff:ffff,US
-2620:0:aa00::,2620::aa00:ffff:ffff:ffff:ffff:ffff,US
-2620:1::,2620:1::ffff:ffff:ffff:ffff:ffff,US
-2620:1:4000::,2620:1:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1:8000::,2620:1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1:c000::,2620:1:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:2::,2620:2::ffff:ffff:ffff:ffff:ffff,US
-2620:2:4000::,2620:2:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:2:8000::,2620:2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:2:c000::,2620:2:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:3::,2620:3::ffff:ffff:ffff:ffff:ffff,US
-2620:3:4000::,2620:3:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:3:8000::,2620:3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3:c000::,2620:3:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:4::,2620:4::ffff:ffff:ffff:ffff:ffff,US
-2620:4:4000::,2620:4:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:4:8000::,2620:4:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:4:c000::,2620:4:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:5::,2620:5::ffff:ffff:ffff:ffff:ffff,US
-2620:5:4000::,2620:5:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:5:8000::,2620:5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5:c000::,2620:5:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:6::,2620:6::ffff:ffff:ffff:ffff:ffff,CA
-2620:6:4000::,2620:6:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:6:8000::,2620:6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6:c000::,2620:6:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:7::,2620:7::ffff:ffff:ffff:ffff:ffff,US
-2620:7:4000::,2620:7:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:7:8000::,2620:7:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:7:c000::,2620:7:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:8::,2620:8:7f:ffff:ffff:ffff:ffff:ffff,CA
-2620:8:8200::,2620:8:8200:ffff:ffff:ffff:ffff:ffff,US
-2620:9::,2620:9::ffff:ffff:ffff:ffff:ffff,US
-2620:9:4000::,2620:9:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:9:8000::,2620:9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9:c000::,2620:9:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:a::,2620:a:f:ffff:ffff:ffff:ffff:ffff,CA
-2620:a:4000::,2620:a:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:a:8000::,2620:a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a:c000::,2620:a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:b::,2620:b::ffff:ffff:ffff:ffff:ffff,US
-2620:b:4000::,2620:b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:b:8000::,2620:b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b:c000::,2620:b:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:c::,2620:c::ffff:ffff:ffff:ffff:ffff,US
-2620:c:4000::,2620:c:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:c:8000::,2620:c:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c:c000::,2620:c:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:d::,2620:d::ffff:ffff:ffff:ffff:ffff,US
-2620:d:4000::,2620:d:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:d:8000::,2620:d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d:c000::,2620:d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:e::,2620:e::ffff:ffff:ffff:ffff:ffff,US
-2620:e:4000::,2620:e:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:e:8000::,2620:e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e:c000::,2620:e:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:f::,2620:f:f:ffff:ffff:ffff:ffff:ffff,US
-2620:f:4000::,2620:f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:f:8000::,2620:f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f:c000::,2620:f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:10::,2620:10::ffff:ffff:ffff:ffff:ffff,US
-2620:10:4000::,2620:10:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:10:8000::,2620:10:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:10:c000::,2620:10:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:11::,2620:11:ff:ffff:ffff:ffff:ffff:ffff,US
-2620:11:4000::,2620:11:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:11:8000::,2620:11:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:11:c000::,2620:11:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:12::,2620:12::ffff:ffff:ffff:ffff:ffff,US
-2620:12:4000::,2620:12:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:12:8000::,2620:12:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:12:c000::,2620:12:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:13::,2620:13::ffff:ffff:ffff:ffff:ffff,CA
-2620:13:8000::,2620:13:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:13:c000::,2620:13:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:14::,2620:14::ffff:ffff:ffff:ffff:ffff,US
-2620:14:4000::,2620:14:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:14:8000::,2620:14:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:14:c000::,2620:14:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:15::,2620:15::ffff:ffff:ffff:ffff:ffff,US
-2620:15:4000::,2620:15:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:15:8000::,2620:15:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:15:c000::,2620:15:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:16::,2620:16::ffff:ffff:ffff:ffff:ffff,CA
-2620:16:4000::,2620:16:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:16:8000::,2620:16:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:16:c000::,2620:16:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:17::,2620:17::ffff:ffff:ffff:ffff:ffff,US
-2620:17:4000::,2620:17:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:17:8000::,2620:17:800f:ffff:ffff:ffff:ffff:ffff,US
-2620:17:c000::,2620:17:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:18::,2620:18::ffff:ffff:ffff:ffff:ffff,US
-2620:18:4000::,2620:18:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:18:8000::,2620:18:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:18:c000::,2620:18:c000:ffff:ffff:ffff:ffff:ffff,KN
-2620:19::,2620:19::ffff:ffff:ffff:ffff:ffff,US
-2620:19:4000::,2620:19:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:19:8000::,2620:19:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:19:c000::,2620:19:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1a::,2620:1a::ffff:ffff:ffff:ffff:ffff,US
-2620:1a:4000::,2620:1a:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1a:8000::,2620:1a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1a:c000::,2620:1a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1b::,2620:1b:f:ffff:ffff:ffff:ffff:ffff,US
-2620:1b:4000::,2620:1b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1b:8000::,2620:1b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1b:c000::,2620:1b:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1c::,2620:1c::ffff:ffff:ffff:ffff:ffff,US
-2620:1c:4000::,2620:1c:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1c:8000::,2620:1c:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1c:c000::,2620:1c:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1d::,2620:1d::ffff:ffff:ffff:ffff:ffff,US
-2620:1d:4000::,2620:1d:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1d:8000::,2620:1d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1d:c000::,2620:1d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1e::,2620:1e::ffff:ffff:ffff:ffff:ffff,US
-2620:1e:4000::,2620:1e:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:1e:8000::,2620:1e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1e:c000::,2620:1e:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:1f::,2620:1f::ffff:ffff:ffff:ffff:ffff,US
-2620:1f:4000::,2620:1f:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:1f:8000::,2620:1f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:1f:c000::,2620:1f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:20::,2620:20::ffff:ffff:ffff:ffff:ffff,US
-2620:20:4000::,2620:20:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:20:8000::,2620:20:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:20:c000::,2620:20:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:21::,2620:21::ffff:ffff:ffff:ffff:ffff,US
-2620:21:4000::,2620:21:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:21:8000::,2620:21:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:21:c000::,2620:21:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:22::,2620:22::ffff:ffff:ffff:ffff:ffff,US
-2620:22:4000::,2620:22:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:22:8000::,2620:22:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:22:c000::,2620:22:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:23::,2620:23::ffff:ffff:ffff:ffff:ffff,US
-2620:23:4000::,2620:23:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:23:8000::,2620:23:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:23:c000::,2620:23:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:24::,2620:24:1f:ffff:ffff:ffff:ffff:ffff,US
-2620:24:8080::,2620:24:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:25::,2620:25::ffff:ffff:ffff:ffff:ffff,US
-2620:25:4000::,2620:25:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:25:8000::,2620:25:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:25:c000::,2620:25:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:26::,2620:26::ffff:ffff:ffff:ffff:ffff,US
-2620:26:4000::,2620:26:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:26:8000::,2620:26:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:26:c000::,2620:26:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:27::,2620:27:f:ffff:ffff:ffff:ffff:ffff,US
-2620:27:8080::,2620:27:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:28::,2620:28::ffff:ffff:ffff:ffff:ffff,US
-2620:28:4000::,2620:28:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:28:8000::,2620:28:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:28:c000::,2620:28:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:29::,2620:29::ffff:ffff:ffff:ffff:ffff,US
-2620:29:4000::,2620:29:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:29:8000::,2620:29:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:29:c000::,2620:29:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:2a::,2620:2a::ffff:ffff:ffff:ffff:ffff,US
-2620:2a:4000::,2620:2a:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:2a:8000::,2620:2a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:2a:c000::,2620:2a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:2b::,2620:2b::ffff:ffff:ffff:ffff:ffff,US
-2620:2b:4000::,2620:2b:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:2b:8000::,2620:2b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:2b:c000::,2620:2b:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:2c::,2620:2c:f:ffff:ffff:ffff:ffff:ffff,US
-2620:2c:8080::,2620:2c:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:2d::,2620:2d::ffff:ffff:ffff:ffff:ffff,US
-2620:2d:4000::,2620:2d:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:2d:8000::,2620:2d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:2d:c000::,2620:2d:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:2e::,2620:2e:3f:ffff:ffff:ffff:ffff:ffff,US
-2620:2e:8080::,2620:2e:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:2f::,2620:2f::ffff:ffff:ffff:ffff:ffff,CA
-2620:2f:4000::,2620:2f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:2f:8000::,2620:2f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:2f:c000::,2620:2f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:30::,2620:30::ffff:ffff:ffff:ffff:ffff,US
-2620:30:4000::,2620:30:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:30:8000::,2620:30:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:30:c000::,2620:30:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:31::,2620:31::ffff:ffff:ffff:ffff:ffff,US
-2620:31:4000::,2620:31:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:31:8000::,2620:31:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:31:c000::,2620:31:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:32::,2620:32::ffff:ffff:ffff:ffff:ffff,US
-2620:32:4000::,2620:32:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:32:8000::,2620:32:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:32:c000::,2620:32:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:33::,2620:33::ffff:ffff:ffff:ffff:ffff,US
-2620:33:4000::,2620:33:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:33:8000::,2620:33:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:33:c000::,2620:33:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:34::,2620:34::ffff:ffff:ffff:ffff:ffff,US
-2620:34:4000::,2620:34:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:34:8000::,2620:34:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:34:c000::,2620:34:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:35::,2620:35::ffff:ffff:ffff:ffff:ffff,US
-2620:35:4000::,2620:35:400f:ffff:ffff:ffff:ffff:ffff,CA
-2620:35:8000::,2620:35:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:35:c000::,2620:35:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:36::,2620:36::ffff:ffff:ffff:ffff:ffff,US
-2620:36:4000::,2620:36:400f:ffff:ffff:ffff:ffff:ffff,CA
-2620:36:8000::,2620:36:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:36:c000::,2620:36:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:37::,2620:37::ffff:ffff:ffff:ffff:ffff,US
-2620:37:4000::,2620:37:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:37:8000::,2620:37:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:37:c000::,2620:37:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:38::,2620:38::ffff:ffff:ffff:ffff:ffff,US
-2620:38:4000::,2620:38:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:38:8000::,2620:38:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:38:c000::,2620:38:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:39::,2620:39::ffff:ffff:ffff:ffff:ffff,US
-2620:39:4000::,2620:39:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:39:8000::,2620:39:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:39:c000::,2620:39:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:3a::,2620:3a::ffff:ffff:ffff:ffff:ffff,US
-2620:3a:4000::,2620:3a:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:3a:8000::,2620:3a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3a:c000::,2620:3a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:3b::,2620:3b::ffff:ffff:ffff:ffff:ffff,US
-2620:3b:4000::,2620:3b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:3b:8000::,2620:3b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3b:c000::,2620:3b:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:3c::,2620:3c:3f:ffff:ffff:ffff:ffff:ffff,US
-2620:3c:8080::,2620:3c:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:3d::,2620:3d::ffff:ffff:ffff:ffff:ffff,US
-2620:3d:4000::,2620:3d:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:3d:8000::,2620:3d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3d:c000::,2620:3d:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:3e::,2620:3e::ffff:ffff:ffff:ffff:ffff,US
-2620:3e:4000::,2620:3e:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:3e:8000::,2620:3e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3e:c000::,2620:3e:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:3f::,2620:3f::ffff:ffff:ffff:ffff:ffff,US
-2620:3f:4000::,2620:3f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:3f:8000::,2620:3f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:3f:c000::,2620:3f:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:40::,2620:40::ffff:ffff:ffff:ffff:ffff,US
-2620:40:4000::,2620:40:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:40:8000::,2620:40:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:40:c000::,2620:40:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:41::,2620:41::ffff:ffff:ffff:ffff:ffff,US
-2620:41:4000::,2620:41:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:41:8000::,2620:41:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:41:c000::,2620:41:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:42::,2620:42::ffff:ffff:ffff:ffff:ffff,US
-2620:42:4000::,2620:42:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:42:8000::,2620:42:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:42:c000::,2620:42:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:43::,2620:43::ffff:ffff:ffff:ffff:ffff,US
-2620:43:4000::,2620:43:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:43:8000::,2620:43:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:43:c000::,2620:43:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:44::,2620:44:1:ffff:ffff:ffff:ffff:ffff,US
-2620:44:4000::,2620:44:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:44:8000::,2620:44:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:44:c000::,2620:44:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:45::,2620:45::ffff:ffff:ffff:ffff:ffff,CA
-2620:45:4000::,2620:45:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:45:8000::,2620:45:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:45:c000::,2620:45:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:46::,2620:46::ffff:ffff:ffff:ffff:ffff,US
-2620:46:4000::,2620:46:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:46:8000::,2620:46:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:46:c000::,2620:46:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:47::,2620:47::ffff:ffff:ffff:ffff:ffff,US
-2620:47:4000::,2620:47:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:47:8000::,2620:47:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:47:c000::,2620:47:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:48::,2620:48::ffff:ffff:ffff:ffff:ffff,US
-2620:48:4000::,2620:48:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:48:8000::,2620:48:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:48:c000::,2620:48:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:49::,2620:49:f:ffff:ffff:ffff:ffff:ffff,CA
-2620:49:8080::,2620:49:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:4a::,2620:4a::ffff:ffff:ffff:ffff:ffff,US
-2620:4a:4000::,2620:4a:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:4a:8000::,2620:4a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:4a:c000::,2620:4a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:4b::,2620:4b::ffff:ffff:ffff:ffff:ffff,CA
-2620:4b:4000::,2620:4b:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:4b:8000::,2620:4b:800f:ffff:ffff:ffff:ffff:ffff,US
-2620:4b:c000::,2620:4b:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:4c::,2620:4c:1:ffff:ffff:ffff:ffff:ffff,US
-2620:4c:4000::,2620:4c:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:4c:c000::,2620:4c:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:4d::,2620:4d::ffff:ffff:ffff:ffff:ffff,US
-2620:4d:4000::,2620:4d:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:4d:8000::,2620:4d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:4d:c000::,2620:4d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:4e::,2620:4e::ffff:ffff:ffff:ffff:ffff,US
-2620:4e:4000::,2620:4e:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:4e:8000::,2620:4e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:4e:c000::,2620:4e:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:4f::,2620:4f::ffff:ffff:ffff:ffff:ffff,US
-2620:4f:4000::,2620:4f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:4f:8000::,2620:4f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:4f:c000::,2620:4f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:50::,2620:50:f:ffff:ffff:ffff:ffff:ffff,US
-2620:50:8080::,2620:50:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:51::,2620:51::ffff:ffff:ffff:ffff:ffff,US
-2620:51:4000::,2620:51:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:51:8000::,2620:51:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:51:c000::,2620:51:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:52::,2620:52:3:ffff:ffff:ffff:ffff:ffff,US
-2620:52:4000::,2620:52:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:52:8000::,2620:52:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:52:c000::,2620:52:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:53::,2620:53::ffff:ffff:ffff:ffff:ffff,US
-2620:53:4000::,2620:53:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:53:8000::,2620:53:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:53:c000::,2620:53:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:54::,2620:54::ffff:ffff:ffff:ffff:ffff,US
-2620:54:4000::,2620:54:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:54:8000::,2620:54:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:54:c000::,2620:54:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:55::,2620:55::ffff:ffff:ffff:ffff:ffff,US
-2620:55:4000::,2620:55:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:55:8000::,2620:55:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:55:c000::,2620:55:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:56::,2620:56::ffff:ffff:ffff:ffff:ffff,US
-2620:56:4000::,2620:56:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:56:8000::,2620:56:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:56:c000::,2620:56:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:57::,2620:57::ffff:ffff:ffff:ffff:ffff,US
-2620:57:4000::,2620:57:400f:ffff:ffff:ffff:ffff:ffff,KY
-2620:57:8000::,2620:57:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:57:c000::,2620:57:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:58::,2620:58:ff:ffff:ffff:ffff:ffff:ffff,US
-2620:58:8800::,2620:58:8800:ffff:ffff:ffff:ffff:ffff,US
-2620:59::,2620:59::ffff:ffff:ffff:ffff:ffff,US
-2620:59:4000::,2620:59:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:59:8000::,2620:59:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:59:c000::,2620:59:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:5a::,2620:5a::ffff:ffff:ffff:ffff:ffff,US
-2620:5a:4000::,2620:5a:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:5a:8000::,2620:5a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5a:c000::,2620:5a:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:5b::,2620:5b::ffff:ffff:ffff:ffff:ffff,US
-2620:5b:4000::,2620:5b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:5b:8000::,2620:5b:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:5b:c000::,2620:5b:c00f:ffff:ffff:ffff:ffff:ffff,CA
-2620:5c::,2620:5c::ffff:ffff:ffff:ffff:ffff,US
-2620:5c:4000::,2620:5c:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:5c:8000::,2620:5c:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5c:c000::,2620:5c:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:5d::,2620:5d::ffff:ffff:ffff:ffff:ffff,US
-2620:5d:4000::,2620:5d:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:5d:8000::,2620:5d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5d:c000::,2620:5d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:5e::,2620:5e::ffff:ffff:ffff:ffff:ffff,US
-2620:5e:4000::,2620:5e:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:5e:8000::,2620:5e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5e:c000::,2620:5e:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:5f::,2620:5f::ffff:ffff:ffff:ffff:ffff,US
-2620:5f:4000::,2620:5f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:5f:8000::,2620:5f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:5f:c000::,2620:5f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:60::,2620:60::ffff:ffff:ffff:ffff:ffff,US
-2620:60:4000::,2620:60:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:60:8000::,2620:60:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:60:c000::,2620:60:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:61::,2620:61::ffff:ffff:ffff:ffff:ffff,CA
-2620:61:4000::,2620:61:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:61:8000::,2620:61:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:61:c000::,2620:61:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:62::,2620:62::ffff:ffff:ffff:ffff:ffff,US
-2620:62:4000::,2620:62:400f:ffff:ffff:ffff:ffff:ffff,CA
-2620:62:8000::,2620:62:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:62:c000::,2620:62:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:63::,2620:63::ffff:ffff:ffff:ffff:ffff,US
-2620:63:4000::,2620:63:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:63:8000::,2620:63:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:63:c000::,2620:63:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:64::,2620:64::ffff:ffff:ffff:ffff:ffff,US
-2620:64:4000::,2620:64:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:64:8000::,2620:64:8000:ffff:ffff:ffff:ffff:ffff,TW
-2620:64:c000::,2620:64:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:65::,2620:65:ff:ffff:ffff:ffff:ffff:ffff,US
-2620:65:8000::,2620:65:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:65:c000::,2620:65:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:66::,2620:66::ffff:ffff:ffff:ffff:ffff,CA
-2620:66:4000::,2620:66:400f:ffff:ffff:ffff:ffff:ffff,US
-2620:66:8000::,2620:66:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:66:c000::,2620:66:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:67::,2620:67::ffff:ffff:ffff:ffff:ffff,US
-2620:67:4000::,2620:67:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:67:8000::,2620:67:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:67:c000::,2620:67:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:68::,2620:68::ffff:ffff:ffff:ffff:ffff,US
-2620:68:4000::,2620:68:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:68:8000::,2620:68:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:68:c000::,2620:68:c00f:ffff:ffff:ffff:ffff:ffff,US
-2620:69:4000::,2620:69:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:69:8000::,2620:69:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:69:c000::,2620:69:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:6a::,2620:6a::ffff:ffff:ffff:ffff:ffff,US
-2620:6a:4000::,2620:6a:4000:ffff:ffff:ffff:ffff:ffff,CA
-2620:6a:8000::,2620:6a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6a:c000::,2620:6a:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:6b::,2620:6b::ffff:ffff:ffff:ffff:ffff,US
-2620:6b:4000::,2620:6b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:6b:8000::,2620:6b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6b:c000::,2620:6b:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:6c::,2620:6c:3f:ffff:ffff:ffff:ffff:ffff,US
-2620:6c:8080::,2620:6c:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:6d:40::,2620:6d:40:ffff:ffff:ffff:ffff:ffff,US
-2620:6d:8000::,2620:6d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6d:c000::,2620:6d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:6e::,2620:6e::ffff:ffff:ffff:ffff:ffff,US
-2620:6e:4000::,2620:6e:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:6e:8000::,2620:6e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6e:c000::,2620:6e:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:6f::,2620:6f::ffff:ffff:ffff:ffff:ffff,US
-2620:6f:4000::,2620:6f:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:6f:8000::,2620:6f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:6f:c000::,2620:6f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:70::,2620:70::ffff:ffff:ffff:ffff:ffff,US
-2620:70:4000::,2620:70:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:70:8000::,2620:70:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:70:c000::,2620:70:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:71::,2620:71::ffff:ffff:ffff:ffff:ffff,US
-2620:71:4000::,2620:71:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:71:8000::,2620:71:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:71:c000::,2620:71:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:72::,2620:72::ffff:ffff:ffff:ffff:ffff,US
-2620:72:4000::,2620:72:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:72:8000::,2620:72:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:72:c000::,2620:72:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:73::,2620:73::ffff:ffff:ffff:ffff:ffff,US
-2620:73:4000::,2620:73:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:73:8000::,2620:73:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:73:c000::,2620:73:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:74::,2620:74:1f:ffff:ffff:ffff:ffff:ffff,US
-2620:74:8080::,2620:74:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:75::,2620:75::ffff:ffff:ffff:ffff:ffff,US
-2620:75:4000::,2620:75:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:75:8000::,2620:75:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:75:c000::,2620:75:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:76::,2620:76::ffff:ffff:ffff:ffff:ffff,US
-2620:76:4000::,2620:76:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:76:8000::,2620:76:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:76:c000::,2620:76:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:77::,2620:77::ffff:ffff:ffff:ffff:ffff,US
-2620:77:4000::,2620:77:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:77:8000::,2620:77:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:77:c000::,2620:77:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:78::,2620:78::ffff:ffff:ffff:ffff:ffff,US
-2620:78:4000::,2620:78:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:78:8000::,2620:78:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:78:c000::,2620:78:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:79::,2620:79::ffff:ffff:ffff:ffff:ffff,US
-2620:79:4000::,2620:79:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:79:8000::,2620:79:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:79:c000::,2620:79:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:7a::,2620:7a::ffff:ffff:ffff:ffff:ffff,US
-2620:7a:4000::,2620:7a:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:7a:8000::,2620:7a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:7a:c000::,2620:7a:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:7b::,2620:7b::ffff:ffff:ffff:ffff:ffff,US
-2620:7b:4000::,2620:7b:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:7b:8000::,2620:7b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:7b:e000::,2620:7b:e000:ffff:ffff:ffff:ffff:ffff,US
-2620:7c:4000::,2620:7c:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:7c:a000::,2620:7c:a000:ffff:ffff:ffff:ffff:ffff,US
-2620:7d::,2620:7d::ffff:ffff:ffff:ffff:ffff,US
-2620:7d:4000::,2620:7d:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:7d:8000::,2620:7d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:7d:c000::,2620:7d:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:7e::,2620:7e:f:ffff:ffff:ffff:ffff:ffff,US
-2620:7e:60c0::,2620:7e:60c0:ffff:ffff:ffff:ffff:ffff,US
-2620:7e:c080::,2620:7e:c080:ffff:ffff:ffff:ffff:ffff,US
-2620:7f:2040::,2620:7f:2040:ffff:ffff:ffff:ffff:ffff,US
-2620:7f:8000::,2620:7f:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:7f:c000::,2620:7f:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:80::,2620:80::ffff:ffff:ffff:ffff:ffff,US
-2620:80:4000::,2620:80:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:80:8000::,2620:80:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:80:c000::,2620:80:c000:ffff:ffff:ffff:ffff:ffff,CA
-2620:81::,2620:81::ffff:ffff:ffff:ffff:ffff,US
-2620:81:4000::,2620:81:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:81:8000::,2620:81:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:81:c000::,2620:81:c000:ffff:ffff:ffff:ffff:ffff,US
-2620:82:4000::,2620:82:4000:ffff:ffff:ffff:ffff:ffff,US
-2620:82:8000::,2620:82:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:83::,2620:83::ffff:ffff:ffff:ffff:ffff,US
-2620:83:8000::,2620:83:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:84::,2620:84:1:ffff:ffff:ffff:ffff:ffff,US
-2620:84:8000::,2620:84:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:85::,2620:85::ffff:ffff:ffff:ffff:ffff,US
-2620:85:8000::,2620:85:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:86::,2620:86::ffff:ffff:ffff:ffff:ffff,US
-2620:86:8000::,2620:86:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:87::,2620:87::ffff:ffff:ffff:ffff:ffff,US
-2620:87:8000::,2620:87:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:88::,2620:88::ffff:ffff:ffff:ffff:ffff,US
-2620:88:8000::,2620:88:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:89::,2620:89::ffff:ffff:ffff:ffff:ffff,US
-2620:89:8000::,2620:89:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:8a::,2620:8a::ffff:ffff:ffff:ffff:ffff,US
-2620:8a:8000::,2620:8a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:8b::,2620:8b::ffff:ffff:ffff:ffff:ffff,US
-2620:8b:8000::,2620:8b:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:8c::,2620:8c::ffff:ffff:ffff:ffff:ffff,US
-2620:8c:8000::,2620:8c:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:8d::,2620:8d::ffff:ffff:ffff:ffff:ffff,US
-2620:8d:8000::,2620:8d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:8e::,2620:8e::ffff:ffff:ffff:ffff:ffff,US
-2620:8e:8000::,2620:8e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:8f::,2620:8f::ffff:ffff:ffff:ffff:ffff,US
-2620:8f:8000::,2620:8f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:90::,2620:90::ffff:ffff:ffff:ffff:ffff,CA
-2620:90:8000::,2620:90:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:91::,2620:91::ffff:ffff:ffff:ffff:ffff,US
-2620:91:8000::,2620:91:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:92::,2620:92:f:ffff:ffff:ffff:ffff:ffff,US
-2620:92:8000::,2620:92:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:93::,2620:93::ffff:ffff:ffff:ffff:ffff,US
-2620:93:8000::,2620:93:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:94::,2620:94::ffff:ffff:ffff:ffff:ffff,US
-2620:94:8000::,2620:94:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:95::,2620:95::ffff:ffff:ffff:ffff:ffff,US
-2620:95:8000::,2620:95:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:96::,2620:96::ffff:ffff:ffff:ffff:ffff,US
-2620:96:8000::,2620:96:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:97::,2620:97::ffff:ffff:ffff:ffff:ffff,US
-2620:97:8000::,2620:97:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:98::,2620:98::ffff:ffff:ffff:ffff:ffff,US
-2620:98:8000::,2620:98:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:99::,2620:99::ffff:ffff:ffff:ffff:ffff,US
-2620:99:8000::,2620:99:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9a::,2620:9a::ffff:ffff:ffff:ffff:ffff,CA
-2620:9a:8000::,2620:9a:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9b::,2620:9b::ffff:ffff:ffff:ffff:ffff,US
-2620:9b:8000::,2620:9b:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9c::,2620:9c::ffff:ffff:ffff:ffff:ffff,US
-2620:9c:8000::,2620:9c:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9d::,2620:9d::ffff:ffff:ffff:ffff:ffff,US
-2620:9d:8000::,2620:9d:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9e::,2620:9e::ffff:ffff:ffff:ffff:ffff,US
-2620:9e:8000::,2620:9e:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:9f::,2620:9f:ff:ffff:ffff:ffff:ffff:ffff,US
-2620:9f:8000::,2620:9f:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a0::,2620:a0::ffff:ffff:ffff:ffff:ffff,US
-2620:a0:8000::,2620:a0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a1::,2620:a1::ffff:ffff:ffff:ffff:ffff,US
-2620:a1:8000::,2620:a1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a2::,2620:a2::ffff:ffff:ffff:ffff:ffff,US
-2620:a2:8000::,2620:a2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a3::,2620:a3::ffff:ffff:ffff:ffff:ffff,US
-2620:a3:8000::,2620:a3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a3:c020::,2620:a3:c020:ffff:ffff:ffff:ffff:ffff,US
-2620:a4:40::,2620:a4:40:ffff:ffff:ffff:ffff:ffff,US
-2620:a4:4060::,2620:a4:4060:ffff:ffff:ffff:ffff:ffff,US
-2620:a4:8080::,2620:a4:8080:ffff:ffff:ffff:ffff:ffff,US
-2620:a5::,2620:a5::ffff:ffff:ffff:ffff:ffff,US
-2620:a5:8000::,2620:a5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a6::,2620:a6::ffff:ffff:ffff:ffff:ffff,US
-2620:a6:8000::,2620:a6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a7::,2620:a7::ffff:ffff:ffff:ffff:ffff,US
-2620:a7:8000::,2620:a7:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a8::,2620:a8::ffff:ffff:ffff:ffff:ffff,US
-2620:a8:8000::,2620:a8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:a9::,2620:a9::ffff:ffff:ffff:ffff:ffff,US
-2620:a9:8000::,2620:a9:800f:ffff:ffff:ffff:ffff:ffff,US
-2620:aa::,2620:aa::ffff:ffff:ffff:ffff:ffff,US
-2620:aa:8000::,2620:aa:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ab::,2620:ab::ffff:ffff:ffff:ffff:ffff,US
-2620:ab:8000::,2620:ab:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ac::,2620:ac::ffff:ffff:ffff:ffff:ffff,US
-2620:ac:8000::,2620:ac:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ad::,2620:ad::ffff:ffff:ffff:ffff:ffff,US
-2620:ad:8000::,2620:ad:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ae::,2620:ae::ffff:ffff:ffff:ffff:ffff,CA
-2620:ae:8000::,2620:ae:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:af::,2620:af::ffff:ffff:ffff:ffff:ffff,US
-2620:af:8000::,2620:af:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b0::,2620:b0::ffff:ffff:ffff:ffff:ffff,CA
-2620:b0:8000::,2620:b0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b1::,2620:b1::ffff:ffff:ffff:ffff:ffff,US
-2620:b1:8000::,2620:b1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b2::,2620:b2::ffff:ffff:ffff:ffff:ffff,US
-2620:b2:8000::,2620:b2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b3::,2620:b3::ffff:ffff:ffff:ffff:ffff,US
-2620:b3:8000::,2620:b3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b4::,2620:b4::ffff:ffff:ffff:ffff:ffff,US
-2620:b4:8000::,2620:b4:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:b5::,2620:b5::ffff:ffff:ffff:ffff:ffff,US
-2620:b5:8000::,2620:b5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b6::,2620:b6::ffff:ffff:ffff:ffff:ffff,US
-2620:b6:8000::,2620:b6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b7::,2620:b7::ffff:ffff:ffff:ffff:ffff,US
-2620:b7:8000::,2620:b7:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:b8::,2620:b8::ffff:ffff:ffff:ffff:ffff,US
-2620:b8:8000::,2620:b8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:b9::,2620:b9::ffff:ffff:ffff:ffff:ffff,US
-2620:b9:8000::,2620:b9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ba::,2620:ba::ffff:ffff:ffff:ffff:ffff,US
-2620:ba:8000::,2620:ba:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:bb::,2620:bb::ffff:ffff:ffff:ffff:ffff,US
-2620:bb:8000::,2620:bb:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:bc::,2620:bc::ffff:ffff:ffff:ffff:ffff,US
-2620:bc:8000::,2620:bc:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:bd::,2620:bd::ffff:ffff:ffff:ffff:ffff,CA
-2620:bd:8000::,2620:bd:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:be::,2620:be::ffff:ffff:ffff:ffff:ffff,US
-2620:be:8000::,2620:be:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:bf::,2620:bf::ffff:ffff:ffff:ffff:ffff,US
-2620:bf:8000::,2620:bf:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c0::,2620:c0::ffff:ffff:ffff:ffff:ffff,US
-2620:c0:8000::,2620:c0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c1::,2620:c1::ffff:ffff:ffff:ffff:ffff,US
-2620:c1:8000::,2620:c1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c2::,2620:c2::ffff:ffff:ffff:ffff:ffff,CA
-2620:c2:8000::,2620:c2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c3::,2620:c3::ffff:ffff:ffff:ffff:ffff,US
-2620:c3:8000::,2620:c3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c4::,2620:c4::ffff:ffff:ffff:ffff:ffff,US
-2620:c4:8000::,2620:c4:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c5::,2620:c5::ffff:ffff:ffff:ffff:ffff,US
-2620:c5:8000::,2620:c5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c6::,2620:c6::ffff:ffff:ffff:ffff:ffff,US
-2620:c6:8000::,2620:c6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c7::,2620:c7::ffff:ffff:ffff:ffff:ffff,US
-2620:c7:8000::,2620:c7:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c8::,2620:c8::ffff:ffff:ffff:ffff:ffff,US
-2620:c8:8000::,2620:c8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:c9::,2620:c9::ffff:ffff:ffff:ffff:ffff,US
-2620:c9:8000::,2620:c9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ca::,2620:ca::ffff:ffff:ffff:ffff:ffff,US
-2620:ca:8000::,2620:ca:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:cb::,2620:cb::ffff:ffff:ffff:ffff:ffff,US
-2620:cb:8000::,2620:cb:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:cc::,2620:cc::ffff:ffff:ffff:ffff:ffff,US
-2620:cc:8000::,2620:cc:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:cd::,2620:cd::ffff:ffff:ffff:ffff:ffff,US
-2620:cd:8000::,2620:cd:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ce::,2620:ce::ffff:ffff:ffff:ffff:ffff,US
-2620:ce:8000::,2620:ce:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:cf::,2620:cf::ffff:ffff:ffff:ffff:ffff,US
-2620:cf:8000::,2620:cf:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d0::,2620:d0::ffff:ffff:ffff:ffff:ffff,US
-2620:d0:8000::,2620:d0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d1::,2620:d1::ffff:ffff:ffff:ffff:ffff,US
-2620:d1:8000::,2620:d1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d2::,2620:d2::ffff:ffff:ffff:ffff:ffff,US
-2620:d2:8000::,2620:d2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d3::,2620:d3::ffff:ffff:ffff:ffff:ffff,US
-2620:d3:8000::,2620:d3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d4::,2620:d4::ffff:ffff:ffff:ffff:ffff,US
-2620:d4:8000::,2620:d4:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d5::,2620:d5::ffff:ffff:ffff:ffff:ffff,US
-2620:d5:8000::,2620:d5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d6::,2620:d6::ffff:ffff:ffff:ffff:ffff,US
-2620:d6:8000::,2620:d6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d7::,2620:d7::ffff:ffff:ffff:ffff:ffff,US
-2620:d7:8000::,2620:d7:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d8::,2620:d8::ffff:ffff:ffff:ffff:ffff,US
-2620:d8:8000::,2620:d8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:d9::,2620:d9::ffff:ffff:ffff:ffff:ffff,US
-2620:d9:8000::,2620:d9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:da::,2620:da::ffff:ffff:ffff:ffff:ffff,US
-2620:da:8000::,2620:da:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:db::,2620:db::ffff:ffff:ffff:ffff:ffff,US
-2620:db:8000::,2620:db:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:dc::,2620:dc::ffff:ffff:ffff:ffff:ffff,US
-2620:dc:8::,2620:dc:8:ffff:ffff:ffff:ffff:ffff,US
-2620:dc:8000::,2620:dc:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:dd::,2620:dd::ffff:ffff:ffff:ffff:ffff,CA
-2620:dd:8000::,2620:dd:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:de::,2620:de::ffff:ffff:ffff:ffff:ffff,US
-2620:de:8000::,2620:de:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:df::,2620:df::ffff:ffff:ffff:ffff:ffff,US
-2620:df:8000::,2620:df:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e0::,2620:e0::ffff:ffff:ffff:ffff:ffff,US
-2620:e0:8000::,2620:e0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e1::,2620:e1::ffff:ffff:ffff:ffff:ffff,US
-2620:e1:8000::,2620:e1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e2::,2620:e2::ffff:ffff:ffff:ffff:ffff,US
-2620:e2:8000::,2620:e2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e3::,2620:e3::ffff:ffff:ffff:ffff:ffff,US
-2620:e3:8000::,2620:e3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e4::,2620:e4::ffff:ffff:ffff:ffff:ffff,US
-2620:e4:8000::,2620:e4:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e5::,2620:e5::ffff:ffff:ffff:ffff:ffff,US
-2620:e5:8000::,2620:e5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e6::,2620:e6::ffff:ffff:ffff:ffff:ffff,US
-2620:e6:8000::,2620:e6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e7::,2620:e7::ffff:ffff:ffff:ffff:ffff,US
-2620:e7:8000::,2620:e7:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:e8::,2620:e8::ffff:ffff:ffff:ffff:ffff,US
-2620:e8:8000::,2620:e8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:e9::,2620:e9::ffff:ffff:ffff:ffff:ffff,US
-2620:e9:8000::,2620:e9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ea::,2620:ea:f:ffff:ffff:ffff:ffff:ffff,US
-2620:ea:8000::,2620:ea:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:eb::,2620:eb::ffff:ffff:ffff:ffff:ffff,US
-2620:eb:8000::,2620:eb:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ec::,2620:ec::ffff:ffff:ffff:ffff:ffff,US
-2620:ec:8000::,2620:ec:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ed::,2620:ed::ffff:ffff:ffff:ffff:ffff,US
-2620:ed:8000::,2620:ed:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ee::,2620:ee::ffff:ffff:ffff:ffff:ffff,US
-2620:ee:8000::,2620:ee:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ef::,2620:ef::ffff:ffff:ffff:ffff:ffff,US
-2620:ef:8000::,2620:ef:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f0::,2620:f0::ffff:ffff:ffff:ffff:ffff,US
-2620:f0:8000::,2620:f0:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f1::,2620:f1::ffff:ffff:ffff:ffff:ffff,US
-2620:f1:8000::,2620:f1:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f2::,2620:f2::ffff:ffff:ffff:ffff:ffff,CA
-2620:f2:8000::,2620:f2:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f3::,2620:f3::ffff:ffff:ffff:ffff:ffff,US
-2620:f3:8000::,2620:f3:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f4::,2620:f4::ffff:ffff:ffff:ffff:ffff,US
-2620:f4:8000::,2620:f4:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:f5::,2620:f5::ffff:ffff:ffff:ffff:ffff,US
-2620:f5:8000::,2620:f5:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f6::,2620:f6::ffff:ffff:ffff:ffff:ffff,CA
-2620:f6:8000::,2620:f6:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f7::,2620:f7::ffff:ffff:ffff:ffff:ffff,US
-2620:f7:8000::,2620:f7:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f8::,2620:f8::ffff:ffff:ffff:ffff:ffff,US
-2620:f8:8000::,2620:f8:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:f9::,2620:f9:f:ffff:ffff:ffff:ffff:ffff,US
-2620:f9:8000::,2620:f9:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:fa::,2620:fa::ffff:ffff:ffff:ffff:ffff,US
-2620:fa:8000::,2620:fa:8000:ffff:ffff:ffff:ffff:ffff,CA
-2620:fb::,2620:fb::ffff:ffff:ffff:ffff:ffff,US
-2620:fb:8000::,2620:fb:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:fc::,2620:fc::ffff:ffff:ffff:ffff:ffff,CA
-2620:fc:8000::,2620:fc:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:fd::,2620:fd::ffff:ffff:ffff:ffff:ffff,CA
-2620:fd:8000::,2620:fd:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:fe::,2620:fe:ff:ffff:ffff:ffff:ffff:ffff,US
-2620:fe:8000::,2620:fe:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:ff::,2620:ff::ffff:ffff:ffff:ffff:ffff,US
-2620:ff:8000::,2620:ff:8000:ffff:ffff:ffff:ffff:ffff,US
-2620:100::,2620:100:f:ffff:ffff:ffff:ffff:ffff,US
+2620::,2620:100:f:ffff:ffff:ffff:ffff:ffff,US
2620:100:1000::,2620:100:1001:ffff:ffff:ffff:ffff:ffff,US
2620:100:3000::,2620:100:3007:ffff:ffff:ffff:ffff:ffff,US
2620:100:4000::,2620:100:403f:ffff:ffff:ffff:ffff:ffff,US
@@ -6274,7 +5292,6 @@
2620:10c:5000::,2620:10c:500f:ffff:ffff:ffff:ffff:ffff,US
2620:10c:6000::,2620:10c:600f:ffff:ffff:ffff:ffff:ffff,US
2620:10c:7000::,2620:10c:700f:ffff:ffff:ffff:ffff:ffff,US
-2620:10c:8000::,2620:10c:80ff:ffff:ffff:ffff:ffff:ffff,US
2620:10c:9000::,2620:10c:90ff:ffff:ffff:ffff:ffff:ffff,US
2620:10c:a000::,2620:10c:a00f:ffff:ffff:ffff:ffff:ffff,US
2620:10c:b000::,2620:10c:b0ff:ffff:ffff:ffff:ffff:ffff,US
@@ -6496,6 +5513,19 @@
2620:11a:7000::,2620:11a:700f:ffff:ffff:ffff:ffff:ffff,US
2620:11a:8000::,2620:11a:800f:ffff:ffff:ffff:ffff:ffff,US
2620:11a:9000::,2620:11a:900f:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:a000::,2620:11a:a0ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:b000::,2620:11a:b00f:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:c000::,2620:11a:c0ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:d000::,2620:11a:d0ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:e000::,2620:11a:e00f:ffff:ffff:ffff:ffff:ffff,US
+2620:11a:f000::,2620:11a:f0ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b::,2620:11b:ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:1000::,2620:11b:10ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:2000::,2620:11b:20ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:3000::,2620:11b:30ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:4000::,2620:11b:40ff:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:5000::,2620:11b:500f:ffff:ffff:ffff:ffff:ffff,US
+2620:11b:6000::,2620:11b:600f:ffff:ffff:ffff:ffff:ffff,US
2620:140::,2620:140:3ff:ffff:ffff:ffff:ffff:ffff,US
2620:141::,2620:141:fff:ffff:ffff:ffff:ffff:ffff,US
2620:143::,2620:143:7ff:ffff:ffff:ffff:ffff:ffff,US
@@ -6555,7 +5585,8 @@
2620:1b0::,2620:1b0:ffff:ffff:ffff:ffff:ffff:ffff,US
2620:1c0::,2620:1c0:ffff:ffff:ffff:ffff:ffff:ffff,US
2620:1d0::,2620:1d0:ffff:ffff:ffff:ffff:ffff:ffff,US
-2620:1e0::,2620:1e0:ffff:ffff:ffff:ffff:ffff:ffff,US
+2620:1e0::,2620:1e1:fff:ffff:ffff:ffff:ffff:ffff,US
+2620:1e2::,2620:1e2:fff:ffff:ffff:ffff:ffff:ffff,US
2620:1f0::,2620:1f1:fff:ffff:ffff:ffff:ffff:ffff,US
2620:1f2::,2620:1f4:fff:ffff:ffff:ffff:ffff:ffff,US
2620:1f5::,2620:1f5:fff:ffff:ffff:ffff:ffff:ffff,CA
@@ -6575,7 +5606,6 @@
2800:48::,2800:48:ffff:ffff:ffff:ffff:ffff:ffff,AR
2800:68::,2800:68:ffff:ffff:ffff:ffff:ffff:ffff,EC
2800:70::,2800:70:ffff:ffff:ffff:ffff:ffff:ffff,TT
-2800:78::,2800:78:ffff:ffff:ffff:ffff:ffff:ffff,CO
2800:80::,2800:80:ffff:ffff:ffff:ffff:ffff:ffff,CW
2800:88::,2800:88:ffff:ffff:ffff:ffff:ffff:ffff,BO
2800:90::,2800:90:ffff:ffff:ffff:ffff:ffff:ffff,SV
@@ -6646,7 +5676,6 @@
2800:4f0::,2800:4f0:ffff:ffff:ffff:ffff:ffff:ffff,EC
2800:500::,2800:500:ffff:ffff:ffff:ffff:ffff:ffff,VE
2800:510::,2800:510:ffff:ffff:ffff:ffff:ffff:ffff,CR
-2800:520::,2800:520:ffff:ffff:ffff:ffff:ffff:ffff,TT
2800:530::,2800:530:ffff:ffff:ffff:ffff:ffff:ffff,CW
2800:540::,2800:540:ffff:ffff:ffff:ffff:ffff:ffff,CL
2800:550::,2800:550:ffff:ffff:ffff:ffff:ffff:ffff,CL
@@ -6666,7 +5695,7 @@
2800:630::,2800:630:ffff:ffff:ffff:ffff:ffff:ffff,AR
2800:640::,2800:640:ffff:ffff:ffff:ffff:ffff:ffff,CR
2800:650::,2800:650:ffff:ffff:ffff:ffff:ffff:ffff,PE
-2800:660::,2800:660:ffff:ffff:ffff:ffff:ffff:ffff,EC
+2800:660::,2800:661:ffff:ffff:ffff:ffff:ffff:ffff,EC
2800:670::,2800:670:ffff:ffff:ffff:ffff:ffff:ffff,CL
2800:680::,2800:680:ffff:ffff:ffff:ffff:ffff:ffff,CO
2800:690::,2800:690:ffff:ffff:ffff:ffff:ffff:ffff,PE
@@ -6757,6 +5786,7 @@
2800:d00::,2800:d00:ffff:ffff:ffff:ffff:ffff:ffff,AR
2800:d10::,2800:d10:ffff:ffff:ffff:ffff:ffff:ffff,AR
2800:d20::,2800:d20:ffff:ffff:ffff:ffff:ffff:ffff,DO
+2800:e00::,2800:eff:ffff:ffff:ffff:ffff:ffff:ffff,TT
2800:1000::,2800:10ff:ffff:ffff:ffff:ffff:ffff:ffff,VE
2800:2000::,2800:2fff:ffff:ffff:ffff:ffff:ffff:ffff,AR
2800:a000::,2800:a000:ffff:ffff:ffff:ffff:ffff:ffff,VE
@@ -6846,16 +5876,19 @@
2801:10:2000::,2801:10:2000:ffff:ffff:ffff:ffff:ffff,AR
2801:10:4000::,2801:10:4000:ffff:ffff:ffff:ffff:ffff,AR
2801:10:8000::,2801:10:8000:ffff:ffff:ffff:ffff:ffff,AR
+2801:10:a000::,2801:10:a000:ffff:ffff:ffff:ffff:ffff,AR
2801:10:c000::,2801:10:c000:ffff:ffff:ffff:ffff:ffff,CO
2801:11::,2801:11::ffff:ffff:ffff:ffff:ffff,AR
2801:11:2000::,2801:11:2000:ffff:ffff:ffff:ffff:ffff,AR
2801:11:4000::,2801:11:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:11:8000::,2801:11:8000:ffff:ffff:ffff:ffff:ffff,CO
+2801:11:a000::,2801:11:a000:ffff:ffff:ffff:ffff:ffff,VE
2801:11:c000::,2801:11:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:12::,2801:12::ffff:ffff:ffff:ffff:ffff,PY
2801:12:2000::,2801:12:2000:ffff:ffff:ffff:ffff:ffff,HN
2801:12:4000::,2801:12:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:12:8000::,2801:12:8000:ffff:ffff:ffff:ffff:ffff,AR
+2801:12:a000::,2801:12:a000:ffff:ffff:ffff:ffff:ffff,CL
2801:12:c000::,2801:12:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:13::,2801:13::ffff:ffff:ffff:ffff:ffff,VE
2801:13:2000::,2801:13:2000:ffff:ffff:ffff:ffff:ffff,AR
@@ -6865,6 +5898,7 @@
2801:14::,2801:14::ffff:ffff:ffff:ffff:ffff,CO
2801:14:2000::,2801:14:2000:ffff:ffff:ffff:ffff:ffff,AR
2801:14:4000::,2801:14:4000:ffff:ffff:ffff:ffff:ffff,CO
+2801:14:a000::,2801:14:a001:ffff:ffff:ffff:ffff:ffff,UY
2801:14:c000::,2801:14:c000:ffff:ffff:ffff:ffff:ffff,BO
2801:15::,2801:15::ffff:ffff:ffff:ffff:ffff,EC
2801:15:2000::,2801:15:2000:ffff:ffff:ffff:ffff:ffff,CR
@@ -6875,8 +5909,10 @@
2801:16:2000::,2801:16:2000:ffff:ffff:ffff:ffff:ffff,HN
2801:16:4000::,2801:16:4000:ffff:ffff:ffff:ffff:ffff,AR
2801:16:8000::,2801:16:8000:ffff:ffff:ffff:ffff:ffff,CO
+2801:16:a000::,2801:16:a000:ffff:ffff:ffff:ffff:ffff,CR
2801:16:c000::,2801:16:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:17::,2801:17::ffff:ffff:ffff:ffff:ffff,CL
+2801:17:2000::,2801:17:2000:ffff:ffff:ffff:ffff:ffff,PY
2801:17:4000::,2801:17:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:17:8000::,2801:17:8000:ffff:ffff:ffff:ffff:ffff,CR
2801:17:c000::,2801:17:c000:ffff:ffff:ffff:ffff:ffff,PA
@@ -6884,18 +5920,22 @@
2801:18:2000::,2801:18:2000:ffff:ffff:ffff:ffff:ffff,CO
2801:18:4000::,2801:18:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:18:8000::,2801:18:8000:ffff:ffff:ffff:ffff:ffff,AR
+2801:18:a000::,2801:18:a000:ffff:ffff:ffff:ffff:ffff,BO
2801:18:c000::,2801:18:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:19::,2801:19::ffff:ffff:ffff:ffff:ffff,AR
2801:19:2000::,2801:19:2000:ffff:ffff:ffff:ffff:ffff,CL
2801:19:4000::,2801:19:4000:ffff:ffff:ffff:ffff:ffff,PY
2801:19:8000::,2801:19:8000:ffff:ffff:ffff:ffff:ffff,EC
+2801:19:a000::,2801:19:a000:ffff:ffff:ffff:ffff:ffff,BO
2801:19:c000::,2801:19:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:1a::,2801:1a::ffff:ffff:ffff:ffff:ffff,CO
2801:1a:2000::,2801:1a:2000:ffff:ffff:ffff:ffff:ffff,AR
2801:1a:4000::,2801:1a:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:1a:8000::,2801:1a:8000:ffff:ffff:ffff:ffff:ffff,CL
+2801:1a:a000::,2801:1a:a000:ffff:ffff:ffff:ffff:ffff,AR
2801:1a:c000::,2801:1a:c000:ffff:ffff:ffff:ffff:ffff,CO
2801:1b::,2801:1b::ffff:ffff:ffff:ffff:ffff,CR
+2801:1b:2000::,2801:1b:2000:ffff:ffff:ffff:ffff:ffff,UY
2801:1b:4000::,2801:1b:4000:ffff:ffff:ffff:ffff:ffff,CL
2801:1b:8000::,2801:1b:8000:ffff:ffff:ffff:ffff:ffff,CL
2801:1b:c000::,2801:1b:c000:ffff:ffff:ffff:ffff:ffff,PA
@@ -6903,6 +5943,7 @@
2801:1c:2000::,2801:1c:2000:ffff:ffff:ffff:ffff:ffff,PE
2801:1c:4000::,2801:1c:4000:ffff:ffff:ffff:ffff:ffff,CO
2801:1c:8000::,2801:1c:8000:ffff:ffff:ffff:ffff:ffff,EC
+2801:1c:a000::,2801:1c:a000:ffff:ffff:ffff:ffff:ffff,CO
2801:1c:c000::,2801:1c:c000:ffff:ffff:ffff:ffff:ffff,HN
2801:1d::,2801:1d::ffff:ffff:ffff:ffff:ffff,PY
2801:1d:2000::,2801:1d:2000:ffff:ffff:ffff:ffff:ffff,GT
@@ -6913,8 +5954,10 @@
2801:1e:2000::,2801:1e:2000:ffff:ffff:ffff:ffff:ffff,AR
2801:1e:4000::,2801:1e:4007:ffff:ffff:ffff:ffff:ffff,AR
2801:1e:8000::,2801:1e:8000:ffff:ffff:ffff:ffff:ffff,CR
+2801:1e:a000::,2801:1e:a000:ffff:ffff:ffff:ffff:ffff,AR
2801:1e:c000::,2801:1e:c000:ffff:ffff:ffff:ffff:ffff,AR
2801:1f::,2801:1f::ffff:ffff:ffff:ffff:ffff,AR
+2801:1f:2000::,2801:1f:2000:ffff:ffff:ffff:ffff:ffff,CR
2801:1f:4000::,2801:1f:4000:ffff:ffff:ffff:ffff:ffff,CR
2801:1f:8000::,2801:1f:8000:ffff:ffff:ffff:ffff:ffff,AR
2801:1f:c000::,2801:1f:c000:ffff:ffff:ffff:ffff:ffff,CR
@@ -7096,6 +6139,18 @@
2801:80:b30::,2801:80:b30:ffff:ffff:ffff:ffff:ffff,BR
2801:80:b40::,2801:80:b40:ffff:ffff:ffff:ffff:ffff,BR
2801:80:b50::,2801:80:b50:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:b60::,2801:80:b60:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:b70::,2801:80:b70:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:b80::,2801:80:b80:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:b90::,2801:80:b90:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:ba0::,2801:80:baf:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:bc0::,2801:80:bcf:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:be0::,2801:80:be0:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:bf0::,2801:80:bf0:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:c00::,2801:80:c00:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:c10::,2801:80:c10:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:c20::,2801:80:c20:ffff:ffff:ffff:ffff:ffff,BR
+2801:80:c30::,2801:80:c30:ffff:ffff:ffff:ffff:ffff,BR
2801:82::,2801:82:ffff:ffff:ffff:ffff:ffff:ffff,BR
2801:84::,2801:84:ffff:ffff:ffff:ffff:ffff:ffff,BR
2801:86::,2801:86:ffff:ffff:ffff:ffff:ffff:ffff,BR
@@ -7145,6 +6200,7 @@
2801:f0:20::,2801:f0:20:ffff:ffff:ffff:ffff:ffff,MX
2801:f0:28::,2801:f0:28:ffff:ffff:ffff:ffff:ffff,MX
2801:100::,2801:100:ff:ffff:ffff:ffff:ffff:ffff,AR
+2801:108::,2801:108:f:ffff:ffff:ffff:ffff:ffff,CO
2801:110::,2801:110:1fff:ffff:ffff:ffff:ffff:ffff,CO
2801:120::,2801:120:ffff:ffff:ffff:ffff:ffff:ffff,AR
2801:130::,2801:130:fff:ffff:ffff:ffff:ffff:ffff,CO
@@ -7159,6 +6215,7 @@
2801:1c0::,2801:1c0:1ff:ffff:ffff:ffff:ffff:ffff,AR
2801:1d0::,2801:1d0:f:ffff:ffff:ffff:ffff:ffff,CO
2801:1e0::,2801:1e0:7f:ffff:ffff:ffff:ffff:ffff,AR
+2801:1f0::,2801:1f0:ffff:ffff:ffff:ffff:ffff:ffff,AR
2802::,2802:3:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803::,2803::ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:80::,2803:80:ffff:ffff:ffff:ffff:ffff:ffff,CL
@@ -7170,6 +6227,7 @@
2803:400::,2803:400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:480::,2803:480:ffff:ffff:ffff:ffff:ffff:ffff,EC
2803:500::,2803:500:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2803:580::,2803:580:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:600::,2803:600:ffff:ffff:ffff:ffff:ffff:ffff,PA
2803:680::,2803:680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:700::,2803:700:ffff:ffff:ffff:ffff:ffff:ffff,AR
@@ -7183,6 +6241,7 @@
2803:c00::,2803:c00:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:c80::,2803:c80:ffff:ffff:ffff:ffff:ffff:ffff,PY
2803:d00::,2803:d00:ffff:ffff:ffff:ffff:ffff:ffff,GY
+2803:d80::,2803:d8f:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:e00::,2803:e00:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:e80::,2803:e80:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:f00::,2803:f00:ffff:ffff:ffff:ffff:ffff:ffff,PE
@@ -7196,6 +6255,7 @@
2803:1400::,2803:1400:ffff:ffff:ffff:ffff:ffff:ffff,DO
2803:1480::,2803:1480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:1500::,2803:1500:ffff:ffff:ffff:ffff:ffff:ffff,TT
+2803:1580::,2803:1580:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:1600::,2803:1600:ffff:ffff:ffff:ffff:ffff:ffff,BQ
2803:1680::,2803:1680:ffff:ffff:ffff:ffff:ffff:ffff,GF
2803:1700::,2803:1700:ffff:ffff:ffff:ffff:ffff:ffff,AR
@@ -7221,6 +6281,7 @@
2803:2400::,2803:2400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:2480::,2803:2480:ffff:ffff:ffff:ffff:ffff:ffff,PE
2803:2500::,2803:2500:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2803:2580::,2803:2580:ffff:ffff:ffff:ffff:ffff:ffff,HN
2803:2600::,2803:2600:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:2680::,2803:2680:ffff:ffff:ffff:ffff:ffff:ffff,UY
2803:2700::,2803:2700:ffff:ffff:ffff:ffff:ffff:ffff,AR
@@ -7247,6 +6308,7 @@
2803:3400::,2803:3400:ffff:ffff:ffff:ffff:ffff:ffff,PA
2803:3480::,2803:3480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:3500::,2803:3500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:3580::,2803:3580:ffff:ffff:ffff:ffff:ffff:ffff,PE
2803:3600::,2803:3600:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:3680::,2803:3680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:3700::,2803:3700:ffff:ffff:ffff:ffff:ffff:ffff,DO
@@ -7273,6 +6335,7 @@
2803:4400::,2803:4400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:4480::,2803:4480:ffff:ffff:ffff:ffff:ffff:ffff,PE
2803:4500::,2803:4500:ffff:ffff:ffff:ffff:ffff:ffff,CW
+2803:4580::,2803:4580:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:4600::,2803:4600:ffff:ffff:ffff:ffff:ffff:ffff,HN
2803:4680::,2803:4680:ffff:ffff:ffff:ffff:ffff:ffff,TT
2803:4700::,2803:4700:ffff:ffff:ffff:ffff:ffff:ffff,AR
@@ -7286,6 +6349,7 @@
2803:4c00::,2803:4c00:ffff:ffff:ffff:ffff:ffff:ffff,EC
2803:4c80::,2803:4c80:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:4d00::,2803:4d00:ffff:ffff:ffff:ffff:ffff:ffff,CL
+2803:4d80::,2803:4d80:ffff:ffff:ffff:ffff:ffff:ffff,CW
2803:4e00::,2803:4e00:ffff:ffff:ffff:ffff:ffff:ffff,UY
2803:4e80::,2803:4e80:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:4f00::,2803:4f00:ffff:ffff:ffff:ffff:ffff:ffff,VE
@@ -7299,6 +6363,7 @@
2803:5400::,2803:5400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:5480::,2803:5480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:5500::,2803:5500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:5580::,2803:5580:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:5600::,2803:5600:ffff:ffff:ffff:ffff:ffff:ffff,HN
2803:5680::,2803:5680:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:5700::,2803:5700:ffff:ffff:ffff:ffff:ffff:ffff,BO
@@ -7324,6 +6389,7 @@
2803:6400::,2803:6400:ffff:ffff:ffff:ffff:ffff:ffff,DO
2803:6480::,2803:6480:ffff:ffff:ffff:ffff:ffff:ffff,BZ
2803:6500::,2803:6500:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2803:6580::,2803:6580:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:6600::,2803:6600:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:6680::,2803:6680:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:6700::,2803:6700:ffff:ffff:ffff:ffff:ffff:ffff,CO
@@ -7350,12 +6416,14 @@
2803:7400::,2803:7400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7480::,2803:7480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7500::,2803:7500:ffff:ffff:ffff:ffff:ffff:ffff,CL
+2803:7580::,2803:7580:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7600::,2803:7600:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7680::,2803:7680:ffff:ffff:ffff:ffff:ffff:ffff,BO
2803:7700::,2803:7700:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7800::,2803:7800:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:7880::,2803:7880:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:7900::,2803:7900:ffff:ffff:ffff:ffff:ffff:ffff,BZ
+2803:7980::,2803:7980:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:7a00::,2803:7a00:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:7a80::,2803:7a80:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:7b00::,2803:7b00:ffff:ffff:ffff:ffff:ffff:ffff,CL
@@ -7375,6 +6443,7 @@
2803:8400::,2803:8400:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:8480::,2803:8480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:8500::,2803:8500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:8580::,2803:8580:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:8600::,2803:8600:ffff:ffff:ffff:ffff:ffff:ffff,HT
2803:8680::,2803:8680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:8700::,2803:8700:ffff:ffff:ffff:ffff:ffff:ffff,CR
@@ -7388,6 +6457,7 @@
2803:8c00::,2803:8c00:ffff:ffff:ffff:ffff:ffff:ffff,BZ
2803:8c80::,2803:8c80:ffff:ffff:ffff:ffff:ffff:ffff,PA
2803:8d00::,2803:8d00:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:8d80::,2803:8d80:ffff:ffff:ffff:ffff:ffff:ffff,UY
2803:8e00::,2803:8e00:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:8e80::,2803:8e80:ffff:ffff:ffff:ffff:ffff:ffff,PY
2803:8f00::,2803:8f00:ffff:ffff:ffff:ffff:ffff:ffff,PA
@@ -7401,6 +6471,7 @@
2803:9400::,2803:9400:ffff:ffff:ffff:ffff:ffff:ffff,BO
2803:9480::,2803:9480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:9500::,2803:9500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:9580::,2803:9580:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:9600::,2803:9600:ffff:ffff:ffff:ffff:ffff:ffff,CW
2803:9680::,2803:9680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:9700::,2803:9700:ffff:ffff:ffff:ffff:ffff:ffff,EC
@@ -7427,6 +6498,7 @@
2803:a400::,2803:a400:ffff:ffff:ffff:ffff:ffff:ffff,EC
2803:a480::,2803:a480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:a500::,2803:a500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:a580::,2803:a580:ffff:ffff:ffff:ffff:ffff:ffff,HT
2803:a600::,2803:a600:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:a680::,2803:a680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:a700::,2803:a700:ffff:ffff:ffff:ffff:ffff:ffff,HN
@@ -7453,6 +6525,7 @@
2803:b400::,2803:b400:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:b480::,2803:b480:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:b500::,2803:b500:ffff:ffff:ffff:ffff:ffff:ffff,VE
+2803:b580::,2803:b580:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:b600::,2803:b600:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:b680::,2803:b680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:b700::,2803:b700:ffff:ffff:ffff:ffff:ffff:ffff,HN
@@ -7479,6 +6552,7 @@
2803:c400::,2803:c400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:c480::,2803:c480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:c500::,2803:c500:ffff:ffff:ffff:ffff:ffff:ffff,AR
+2803:c580::,2803:c580:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:c600::,2803:c600:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:c680::,2803:c680:ffff:ffff:ffff:ffff:ffff:ffff,HT
2803:c700::,2803:c700:ffff:ffff:ffff:ffff:ffff:ffff,GF
@@ -7505,6 +6579,7 @@
2803:d400::,2803:d400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:d480::,2803:d480:ffff:ffff:ffff:ffff:ffff:ffff,VE
2803:d500::,2803:d500:ffff:ffff:ffff:ffff:ffff:ffff,BZ
+2803:d580::,2803:d580:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:d600::,2803:d600:ffff:ffff:ffff:ffff:ffff:ffff,UY
2803:d680::,2803:d680:ffff:ffff:ffff:ffff:ffff:ffff,PE
2803:d700::,2803:d700:ffff:ffff:ffff:ffff:ffff:ffff,VE
@@ -7531,6 +6606,7 @@
2803:e400::,2803:e400:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:e480::,2803:e480:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:e500::,2803:e500:ffff:ffff:ffff:ffff:ffff:ffff,PE
+2803:e580::,2803:e580:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:e600::,2803:e600:ffff:ffff:ffff:ffff:ffff:ffff,PA
2803:e680::,2803:e680:ffff:ffff:ffff:ffff:ffff:ffff,HN
2803:e700::,2803:e700:ffff:ffff:ffff:ffff:ffff:ffff,HN
@@ -7557,12 +6633,14 @@
2803:f400::,2803:f400:ffff:ffff:ffff:ffff:ffff:ffff,HN
2803:f480::,2803:f480:ffff:ffff:ffff:ffff:ffff:ffff,CO
2803:f500::,2803:f500:ffff:ffff:ffff:ffff:ffff:ffff,CW
+2803:f580::,2803:f580:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:f600::,2803:f600:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:f680::,2803:f680:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:f700::,2803:f700:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:f800::,2803:f800:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:f880::,2803:f880:ffff:ffff:ffff:ffff:ffff:ffff,CR
2803:f900::,2803:f900:ffff:ffff:ffff:ffff:ffff:ffff,BZ
+2803:f980::,2803:f980:ffff:ffff:ffff:ffff:ffff:ffff,CL
2803:fa00::,2803:fa00:ffff:ffff:ffff:ffff:ffff:ffff,BO
2803:fa80::,2803:fa80:ffff:ffff:ffff:ffff:ffff:ffff,AR
2803:fb00::,2803:fb00:ffff:ffff:ffff:ffff:ffff:ffff,PA
@@ -9202,6 +8280,107 @@
2804:19e4::,2804:19e4:ffff:ffff:ffff:ffff:ffff:ffff,BR
2804:19e8::,2804:19e8:ffff:ffff:ffff:ffff:ffff:ffff,BR
2804:19ec::,2804:19ec:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:19f0::,2804:19f0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:19f4::,2804:19f4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:19f8::,2804:19f8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:19fc::,2804:19fc:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a00::,2804:1a00:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a04::,2804:1a04:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a08::,2804:1a08:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a0c::,2804:1a0c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a10::,2804:1a10:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a14::,2804:1a14:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a18::,2804:1a18:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a1c::,2804:1a1c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a20::,2804:1a20:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a24::,2804:1a24:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a28::,2804:1a28:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a2c::,2804:1a2c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a30::,2804:1a30:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a34::,2804:1a34:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a38::,2804:1a38:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a3c::,2804:1a3c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a40::,2804:1a40:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a44::,2804:1a44:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a48::,2804:1a48:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a4c::,2804:1a4c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a50::,2804:1a50:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a54::,2804:1a54:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a58::,2804:1a58:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a5c::,2804:1a5c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a60::,2804:1a60:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a64::,2804:1a64:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a68::,2804:1a68:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a6c::,2804:1a6c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a70::,2804:1a70:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a74::,2804:1a74:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a78::,2804:1a78:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a7c::,2804:1a7c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a80::,2804:1a80:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a84::,2804:1a84:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a88::,2804:1a88:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a8c::,2804:1a8c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a90::,2804:1a90:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a94::,2804:1a94:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a98::,2804:1a98:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1a9c::,2804:1a9c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1aa0::,2804:1aa0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1aa4::,2804:1aa4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1aa8::,2804:1aa8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1aac::,2804:1aac:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ab0::,2804:1ab0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ab4::,2804:1ab4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ab8::,2804:1ab8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1abc::,2804:1abc:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ac0::,2804:1ac0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ac4::,2804:1ac4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ac8::,2804:1ac8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1acc::,2804:1acc:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ad0::,2804:1ad0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ad4::,2804:1ad4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ad8::,2804:1ad8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1adc::,2804:1adc:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ae0::,2804:1ae0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ae4::,2804:1ae4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1ae8::,2804:1ae8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1aec::,2804:1aec:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1af0::,2804:1af0:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1af4::,2804:1af4:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1af8::,2804:1af8:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1afc::,2804:1afc:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b00::,2804:1b00:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b04::,2804:1b04:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b08::,2804:1b08:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b0c::,2804:1b0c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b10::,2804:1b10:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b14::,2804:1b14:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b18::,2804:1b18:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b1c::,2804:1b1c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b20::,2804:1b20:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b24::,2804:1b24:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b28::,2804:1b28:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b2c::,2804:1b2c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b30::,2804:1b30:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b34::,2804:1b34:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b38::,2804:1b38:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b3c::,2804:1b3c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b40::,2804:1b40:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b44::,2804:1b44:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b48::,2804:1b48:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b4c::,2804:1b4c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b50::,2804:1b50:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b54::,2804:1b54:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b58::,2804:1b58:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b5c::,2804:1b5c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b60::,2804:1b60:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b64::,2804:1b64:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b68::,2804:1b68:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b6c::,2804:1b6c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b70::,2804:1b70:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b74::,2804:1b74:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b78::,2804:1b78:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b7c::,2804:1b7c:ffff:ffff:ffff:ffff:ffff:ffff,BR
+2804:1b80::,2804:1b80:ffff:ffff:ffff:ffff:ffff:ffff,BR
2804:1f00::,2804:1f00:ffff:ffff:ffff:ffff:ffff:ffff,BR
2804:1f02::,2804:1f02:ffff:ffff:ffff:ffff:ffff:ffff,BR
2804:1f04::,2804:1f04:ffff:ffff:ffff:ffff:ffff:ffff,BR
@@ -9209,7 +8388,8 @@
2804:1f08::,2804:1f08:ffff:ffff:ffff:ffff:ffff:ffff,BR
2806::,2806:f:ffff:ffff:ffff:ffff:ffff:ffff,MX
2806:200::,2806:200:ffff:ffff:ffff:ffff:ffff:ffff,MX
-2806:210::,2806:214:ffff:ffff:ffff:ffff:ffff:ffff,MX
+2806:210::,2806:216::ffff:ffff:ffff:ffff:ffff,MX
+2806:217::,2806:218:ffff:ffff:ffff:ffff:ffff:ffff,MX
2806:220::,2806:220:ffff:ffff:ffff:ffff:ffff:ffff,MX
2806:230::,2806:230:ffff:ffff:ffff:ffff:ffff:ffff,MX
2806:238::,2806:238::ffff:ffff:ffff:ffff:ffff,MX
@@ -9329,7 +8509,7 @@
2a00:ef8::,2a00:ef8:ffff:ffff:ffff:ffff:ffff:ffff,NO
2a00:f00::,2a00:f00:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a00:f08::,2a00:f08:ffff:ffff:ffff:ffff:ffff:ffff,RU
-2a00:f10::,2a00:f10:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a00:f10::,2a00:f17:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:f18::,2a00:f18:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:f20::,2a00:f20:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a00:f28::,2a00:f2f:ffff:ffff:ffff:ffff:ffff:ffff,AE
@@ -9358,7 +8538,36 @@
2a00:fe8::,2a00:fe8:ffff:ffff:ffff:ffff:ffff:ffff,BA
2a00:ff0::,2a00:ff0:ffff:ffff:ffff:ffff:ffff:ffff,RO
2a00:ff8::,2a00:fff:ffff:ffff:ffff:ffff:ffff:ffff,IR
-2a00:1000::,2a00:10ff:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a00:1000::,2a00:1000:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:1008::,2a00:1008:ffff:ffff:ffff:ffff:ffff:ffff,NO
+2a00:1010::,2a00:1010:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:1018::,2a00:1018:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:1020::,2a00:1020:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:1028::,2a00:1028:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a00:1030::,2a00:1030:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:1038::,2a00:1038:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a00:1040::,2a00:1040:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2a00:1048::,2a00:1048:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a00:1050::,2a00:1050:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:1058::,2a00:1058:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a00:1060::,2a00:1060:ffff:ffff:ffff:ffff:ffff:ffff,MT
+2a00:1068::,2a00:1068:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a00:1070::,2a00:1070:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a00:1078::,2a00:1078:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:1080::,2a00:1080:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a00:1088::,2a00:1088:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a00:1098::,2a00:1098:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a00:10a0::,2a00:10a0:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a00:10a8::,2a00:10a8:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:10b0::,2a00:10b7:ffff:ffff:ffff:ffff:ffff:ffff,NO
+2a00:10b8::,2a00:10b8:ffff:ffff:ffff:ffff:ffff:ffff,HU
+2a00:10c0::,2a00:10c0:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a00:10c8::,2a00:10c8:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a00:10d0::,2a00:10d0:ffff:ffff:ffff:ffff:ffff:ffff,HU
+2a00:10d8::,2a00:10d8:ffff:ffff:ffff:ffff:ffff:ffff,SK
+2a00:10e0::,2a00:10e0:ffff:ffff:ffff:ffff:ffff:ffff,MD
+2a00:10e8::,2a00:10f0:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a00:10f8::,2a00:10f8:ffff:ffff:ffff:ffff:ffff:ffff,LU
2a00:1100::,2a00:1107:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:1108::,2a00:1108:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a00:1110::,2a00:1117:ffff:ffff:ffff:ffff:ffff:ffff,HU
@@ -9424,7 +8633,7 @@
2a00:1300::,2a00:1300:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a00:1308::,2a00:1308:ffff:ffff:ffff:ffff:ffff:ffff,PL
2a00:1318::,2a00:1318:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a00:1320::,2a00:1320:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a00:1320::,2a00:1327:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:1328::,2a00:1328:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:1338::,2a00:1338:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:1340::,2a00:1340:ffff:ffff:ffff:ffff:ffff:ffff,DE
@@ -9703,7 +8912,7 @@
2a00:1c30::,2a00:1c30:ffff:ffff:ffff:ffff:ffff:ffff,FI
2a00:1c38::,2a00:1c3f:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:1c40::,2a00:1c40:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a00:1c48::,2a00:1c48:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:1c48::,2a00:1c49:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a00:1c50::,2a00:1c50:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a00:1c58::,2a00:1c58:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:1c60::,2a00:1c60:ffff:ffff:ffff:ffff:ffff:ffff,PT
@@ -10213,7 +9422,6 @@
2a00:7380::,2a00:7380:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:73a0::,2a00:73a0:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a00:73c0::,2a00:73c0:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2a00:73e0::,2a00:73e0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:7400::,2a00:7400:ffff:ffff:ffff:ffff:ffff:ffff,IE
2a00:7420::,2a00:7420:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:7440::,2a00:7447:ffff:ffff:ffff:ffff:ffff:ffff,DE
@@ -10278,7 +9486,6 @@
2a00:7c00::,2a00:7c00:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a00:7c20::,2a00:7c20:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:7c40::,2a00:7c40:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a00:7c60::,2a00:7c60:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:7c80::,2a00:7c80:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:7ca0::,2a00:7ca0:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a00:7cc0::,2a00:7cc0:ffff:ffff:ffff:ffff:ffff:ffff,DE
@@ -10830,7 +10037,6 @@
2a00:c640::,2a00:c640:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a00:c660::,2a00:c660:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:c680::,2a00:c680:ffff:ffff:ffff:ffff:ffff:ffff,IT
-2a00:c6a0::,2a00:c6a0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:c6c0::,2a00:c6c0:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:c6e0::,2a00:c6e0:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a00:c700::,2a00:c700:ffff:ffff:ffff:ffff:ffff:ffff,EE
@@ -11174,7 +10380,14 @@
2a00:f3a0::,2a00:f3a0:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a00:f3c0::,2a00:f3c0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:f3e0::,2a00:f3e0:ffff:ffff:ffff:ffff:ffff:ffff,RU
-2a00:f400::,2a00:f4ff:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:f400::,2a00:f400:ffff:ffff:ffff:ffff:ffff:ffff,LU
+2a00:f420::,2a00:f420:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a00:f440::,2a00:f440:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:f460::,2a00:f460:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:f480::,2a00:f480:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a00:f4a0::,2a00:f4a0:ffff:ffff:ffff:ffff:ffff:ffff,LV
+2a00:f4c0::,2a00:f4c0:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a00:f4e0::,2a00:f4e0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a00:f500::,2a00:f507:ffff:ffff:ffff:ffff:ffff:ffff,LT
2a00:f520::,2a00:f520:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a00:f540::,2a00:f540:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -11260,42 +10473,12 @@
2a00:ffa0::,2a00:ffa0:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a00:ffc0::,2a00:ffc0:ffff:ffff:ffff:ffff:ffff:ffff,PL
2a00:ffe0::,2a00:ffe0:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01::,2a01::ffff:ffff:ffff:ffff:ffff:ffff,FR
-2a01:8::,2a01:8:ffff:ffff:ffff:ffff:ffff:ffff,PT
-2a01:10::,2a01:10:ffff:ffff:ffff:ffff:ffff:ffff,PT
-2a01:18::,2a01:18:ffff:ffff:ffff:ffff:ffff:ffff,FI
-2a01:20::,2a01:20:ffff:ffff:ffff:ffff:ffff:ffff,FR
-2a01:28::,2a01:28:ffff:ffff:ffff:ffff:ffff:ffff,CZ
-2a01:30::,2a01:30:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a01:38::,2a01:38:ffff:ffff:ffff:ffff:ffff:ffff,BE
-2a01:40::,2a01:40:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:48::,2a01:48:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2a01:50::,2a01:50:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:58::,2a01:58:ffff:ffff:ffff:ffff:ffff:ffff,SE
-2a01:68::,2a01:68:ffff:ffff:ffff:ffff:ffff:ffff,FR
-2a01:70::,2a01:70:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:78::,2a01:78:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a01:80::,2a01:80:ffff:ffff:ffff:ffff:ffff:ffff,EE
-2a01:88::,2a01:88:ffff:ffff:ffff:ffff:ffff:ffff,IE
-2a01:90::,2a01:90:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:98::,2a01:98:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:a0::,2a01:a0:ffff:ffff:ffff:ffff:ffff:ffff,MT
-2a01:a8::,2a01:a8:ffff:ffff:ffff:ffff:ffff:ffff,IE
-2a01:b0::,2a01:b1:ffff:ffff:ffff:ffff:ffff:ffff,BE
-2a01:b8::,2a01:b8:ffff:ffff:ffff:ffff:ffff:ffff,VA
-2a01:c0::,2a01:c0:ffff:ffff:ffff:ffff:ffff:ffff,GB
-2a01:c8::,2a01:c8:ffff:ffff:ffff:ffff:ffff:ffff,FR
-2a01:d0::,2a01:d0:ffff:ffff:ffff:ffff:ffff:ffff,UA
-2a01:d8::,2a01:d8:ffff:ffff:ffff:ffff:ffff:ffff,RU
-2a01:e0::,2a01:e0:ffff:ffff:ffff:ffff:ffff:ffff,SK
-2a01:e8::,2a01:e8:ffff:ffff:ffff:ffff:ffff:ffff,SE
-2a01:f0::,2a01:f0:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2a01:f8::,2a01:f8:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a01::,2a01:ff:ffff:ffff:ffff:ffff:ffff:ffff,IE
2a01:100::,2a01:100:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a01:108::,2a01:108:ffff:ffff:ffff:ffff:ffff:ffff,SK
2a01:120::,2a01:120:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a01:130::,2a01:130:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a01:138::,2a01:138:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a01:138::,2a01:13f:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a01:140::,2a01:140:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a01:148::,2a01:148:ffff:ffff:ffff:ffff:ffff:ffff,IE
2a01:150::,2a01:150:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -11454,7 +10637,6 @@
2a01:6a0::,2a01:6a0:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a01:6a8::,2a01:6a8:ffff:ffff:ffff:ffff:ffff:ffff,CH
2a01:6b0::,2a01:6b0:ffff:ffff:ffff:ffff:ffff:ffff,UA
-2a01:6b8::,2a01:6b8:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a01:6c0::,2a01:6c0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a01:6c8::,2a01:6c8:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a01:6d0::,2a01:6d0:ffff:ffff:ffff:ffff:ffff:ffff,SE
@@ -11674,7 +10856,7 @@
2a01:56e0::,2a01:56e0:ffff:ffff:ffff:ffff:ffff:ffff,PL
2a01:5700::,2a01:5700:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a01:5720::,2a01:5720:ffff:ffff:ffff:ffff:ffff:ffff,IT
-2a01:5740::,2a01:5740:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a01:5740::,2a01:5741:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a01:5760::,2a01:5760:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a01:5780::,2a01:5780:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a01:57a0::,2a01:57a0:ffff:ffff:ffff:ffff:ffff:ffff,ES
@@ -12120,7 +11302,7 @@
2a01:90a0::,2a01:90a0:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a01:90c0::,2a01:90c0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a01:90e0::,2a01:90e0:ffff:ffff:ffff:ffff:ffff:ffff,AT
-2a01:9100::,2a01:9100:ffff:ffff:ffff:ffff:ffff:ffff,BE
+2a01:9100::,2a01:9107:ffff:ffff:ffff:ffff:ffff:ffff,BE
2a01:9120::,2a01:9120:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a01:9140::,2a01:9140:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a01:9160::,2a01:9160:ffff:ffff:ffff:ffff:ffff:ffff,RU
@@ -12494,7 +11676,7 @@
2a02:68::,2a02:68:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a02:70::,2a02:70:ffff:ffff:ffff:ffff:ffff:ffff,UA
2a02:78::,2a02:78:ffff:ffff:ffff:ffff:ffff:ffff,PL
-2a02:80::,2a02:80:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a02:80::,2a02:87:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a02:88::,2a02:88:ffff:ffff:ffff:ffff:ffff:ffff,EE
2a02:90::,2a02:97:ffff:ffff:ffff:ffff:ffff:ffff,FI
2a02:98::,2a02:98:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -13329,11 +12511,7 @@
2a02:2dc0::,2a02:2dc0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a02:2de0::,2a02:2de0:ffff:ffff:ffff:ffff:ffff:ffff,PL
2a02:2e00::,2a02:2e1f:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2a02:2f00::,2a02:2f0f:ffff:ffff:ffff:ffff:ffff:ffff,RO
-2a02:2f80::,2a02:2f80:ffff:ffff:ffff:ffff:ffff:ffff,ES
-2a02:2fa0::,2a02:2fa0:ffff:ffff:ffff:ffff:ffff:ffff,NL
-2a02:2fc0::,2a02:2fc0:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a02:2fe0::,2a02:2fe0:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a02:2f00::,2a02:2fff:ffff:ffff:ffff:ffff:ffff:ffff,RO
2a02:3000::,2a02:31ff:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a02:4000::,2a02:4000:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a02:4020::,2a02:4020:ffff:ffff:ffff:ffff:ffff:ffff,SE
@@ -13459,7 +12637,7 @@
2a02:5060::,2a02:5060:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a02:5080::,2a02:5080:ffff:ffff:ffff:ffff:ffff:ffff,IL
2a02:50a0::,2a02:50a0:ffff:ffff:ffff:ffff:ffff:ffff,PL
-2a02:50c0::,2a02:50c0:ffff:ffff:ffff:ffff:ffff:ffff,KZ
+2a02:50c0::,2a02:50c7:ffff:ffff:ffff:ffff:ffff:ffff,KZ
2a02:50e0::,2a02:50e0:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a02:5100::,2a02:5100:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a02:5120::,2a02:5120:ffff:ffff:ffff:ffff:ffff:ffff,SE
@@ -13673,7 +12851,7 @@
2a02:6c40::,2a02:6c40:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a02:6c60::,2a02:6c60:ffff:ffff:ffff:ffff:ffff:ffff,UA
2a02:6c80::,2a02:6c80:ffff:ffff:ffff:ffff:ffff:ffff,RU
-2a02:6ca0::,2a02:6ca0:ffff:ffff:ffff:ffff:ffff:ffff,SK
+2a02:6ca0::,2a02:6ca7:ffff:ffff:ffff:ffff:ffff:ffff,SK
2a02:6cc0::,2a02:6cc0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a02:6ce0::,2a02:6ce0:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a02:6d00::,2a02:6d00:ffff:ffff:ffff:ffff:ffff:ffff,RU
@@ -13687,7 +12865,6 @@
2a02:6e00::,2a02:6e00:ffff:ffff:ffff:ffff:ffff:ffff,RO
2a02:6e20::,2a02:6e20:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a02:6e60::,2a02:6e60:ffff:ffff:ffff:ffff:ffff:ffff,RU
-2a02:6e80::,2a02:6e80:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a02:6ea0::,2a02:6ea0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a02:6ec0::,2a02:6ec0:ffff:ffff:ffff:ffff:ffff:ffff,IR
2a02:6ee0::,2a02:6ee0:ffff:ffff:ffff:ffff:ffff:ffff,PL
@@ -13822,10 +12999,10 @@
2a02:7fa0::,2a02:7fa0:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a02:7fc0::,2a02:7fc0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a02:7fe0::,2a02:7fe0:ffff:ffff:ffff:ffff:ffff:ffff,IS
-2a02:8000::,2a02:811f:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a02:8200::,2a02:821f:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a02:8300::,2a02:83ff:ffff:ffff:ffff:ffff:ffff:ffff,AT
-2a02:8400::,2a02:84ff:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a02:8000::,2a02:821f:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a02:8300::,2a02:830f:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a02:8380::,2a02:838f:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a02:8400::,2a02:847f:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a02:8800::,2a02:88ff:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a02:9000::,2a02:91ff:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a02:a000::,2a02:a0ff:ffff:ffff:ffff:ffff:ffff:ffff,BE
@@ -14142,115 +13319,221 @@
2a03:340::,2a03:340:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:360::,2a03:360:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:380::,2a03:380:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a03:3a0::,2a03:3a0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:3c0::,2a03:3c0:ffff:ffff:ffff:ffff:ffff:ffff,TR
+2a03:3e0::,2a03:3e0:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a03:400::,2a03:400:ffff:ffff:ffff:ffff:ffff:ffff,TR
+2a03:420::,2a03:420:ffff:ffff:ffff:ffff:ffff:ffff,UA
2a03:440::,2a03:440:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:460::,2a03:460:ffff:ffff:ffff:ffff:ffff:ffff,US
2a03:480::,2a03:480:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a03:4a0::,2a03:4a0:ffff:ffff:ffff:ffff:ffff:ffff,NO
2a03:4c0::,2a03:4c0:ffff:ffff:ffff:ffff:ffff:ffff,IE
+2a03:4e0::,2a03:4e0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:500::,2a03:500:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:520::,2a03:520:ffff:ffff:ffff:ffff:ffff:ffff,NO
2a03:540::,2a03:540:ffff:ffff:ffff:ffff:ffff:ffff,UZ
+2a03:560::,2a03:560:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:580::,2a03:580:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a03:5a0::,2a03:5a0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:5c0::,2a03:5c0:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:5e0::,2a03:5e0:ffff:ffff:ffff:ffff:ffff:ffff,AM
2a03:600::,2a03:600:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:620::,2a03:620:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a03:640::,2a03:640:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:660::,2a03:660:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a03:680::,2a03:680:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:6a0::,2a03:6a0:ffff:ffff:ffff:ffff:ffff:ffff,LV
2a03:6c0::,2a03:6c0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:6e0::,2a03:6e0:ffff:ffff:ffff:ffff:ffff:ffff,SK
2a03:700::,2a03:700:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:720::,2a03:720:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:740::,2a03:740:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:760::,2a03:760:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:780::,2a03:780:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a03:7a0::,2a03:7a0:ffff:ffff:ffff:ffff:ffff:ffff,ME
2a03:7c0::,2a03:7c0:ffff:ffff:ffff:ffff:ffff:ffff,PS
+2a03:7e0::,2a03:7e0:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a03:800::,2a03:800:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:820::,2a03:820:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:840::,2a03:840:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:860::,2a03:860:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:880::,2a03:880:ffff:ffff:ffff:ffff:ffff:ffff,FI
+2a03:8a0::,2a03:8a0:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:8c0::,2a03:8c0:ffff:ffff:ffff:ffff:ffff:ffff,AZ
+2a03:8e0::,2a03:8e0:ffff:ffff:ffff:ffff:ffff:ffff,UA
2a03:900::,2a03:900:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a03:920::,2a03:920:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:940::,2a03:940:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a03:960::,2a03:960:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:980::,2a03:980:ffff:ffff:ffff:ffff:ffff:ffff,IL
+2a03:9a0::,2a03:9a0:ffff:ffff:ffff:ffff:ffff:ffff,MT
2a03:9c0::,2a03:9c0:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:9e0::,2a03:9e0:ffff:ffff:ffff:ffff:ffff:ffff,HU
2a03:a00::,2a03:a00:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:a20::,2a03:a20:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:a40::,2a03:a40:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a03:a60::,2a03:a60:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:a80::,2a03:a80:ffff:ffff:ffff:ffff:ffff:ffff,MD
+2a03:aa0::,2a03:aa0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:ac0::,2a03:ac0:ffff:ffff:ffff:ffff:ffff:ffff,IE
+2a03:ae0::,2a03:ae0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:b00::,2a03:b00:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:b40::,2a03:b40:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:b60::,2a03:b60:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:b80::,2a03:b80:ffff:ffff:ffff:ffff:ffff:ffff,FI
+2a03:ba0::,2a03:ba0:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:bc0::,2a03:bc7:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:c00::,2a03:c00:ffff:ffff:ffff:ffff:ffff:ffff,TR
+2a03:c20::,2a03:c20:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:c40::,2a03:c40:ffff:ffff:ffff:ffff:ffff:ffff,PS
+2a03:c60::,2a03:c60:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:c80::,2a03:c80:ffff:ffff:ffff:ffff:ffff:ffff,FI
+2a03:ca0::,2a03:ca0:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:cc0::,2a03:cc0:ffff:ffff:ffff:ffff:ffff:ffff,RO
+2a03:ce0::,2a03:ce0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:d00::,2a03:d00:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2a03:d20::,2a03:d20:ffff:ffff:ffff:ffff:ffff:ffff,IR
2a03:d40::,2a03:d40:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:d60::,2a03:d60:ffff:ffff:ffff:ffff:ffff:ffff,PL
2a03:d80::,2a03:d80:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:da0::,2a03:da0:ffff:ffff:ffff:ffff:ffff:ffff,PT
2a03:dc0::,2a03:dc0:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:de0::,2a03:de0:ffff:ffff:ffff:ffff:ffff:ffff,BE
2a03:e00::,2a03:e00:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:e20::,2a03:e20:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:e40::,2a03:e40:ffff:ffff:ffff:ffff:ffff:ffff,GR
+2a03:e60::,2a03:e60:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:e80::,2a03:e80:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:ea0::,2a03:ea0:ffff:ffff:ffff:ffff:ffff:ffff,IE
2a03:ec0::,2a03:ec0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:ee0::,2a03:ee0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:f00::,2a03:f07:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:f40::,2a03:f40:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a03:f60::,2a03:f60:ffff:ffff:ffff:ffff:ffff:ffff,NO
2a03:f80::,2a03:f87:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a03:fc0::,2a03:fc0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:fe0::,2a03:fe0:ffff:ffff:ffff:ffff:ffff:ffff,BG
2a03:1000::,2a03:1000:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a03:1020::,2a03:1020:ffff:ffff:ffff:ffff:ffff:ffff,UZ
2a03:1040::,2a03:1040:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:1060::,2a03:1060:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:1080::,2a03:1080:ffff:ffff:ffff:ffff:ffff:ffff,AM
+2a03:10a0::,2a03:10a0:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:10c0::,2a03:10c3:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:10e0::,2a03:10e0:ffff:ffff:ffff:ffff:ffff:ffff,IL
2a03:1100::,2a03:1100:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2a03:1120::,2a03:1120:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1140::,2a03:1140:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:1160::,2a03:1160:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:1180::,2a03:1180:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:11a0::,2a03:11a0:ffff:ffff:ffff:ffff:ffff:ffff,OM
2a03:11c0::,2a03:11c0:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:11e0::,2a03:11e0:ffff:ffff:ffff:ffff:ffff:ffff,SA
2a03:1200::,2a03:1200:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:1220::,2a03:1220:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:1240::,2a03:1240:ffff:ffff:ffff:ffff:ffff:ffff,UA
+2a03:1260::,2a03:1260:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:1280::,2a03:1280:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a03:12a0::,2a03:12a0:ffff:ffff:ffff:ffff:ffff:ffff,BE
2a03:12c0::,2a03:12c0:ffff:ffff:ffff:ffff:ffff:ffff,NO
+2a03:12e0::,2a03:12e0:ffff:ffff:ffff:ffff:ffff:ffff,AE
2a03:1300::,2a03:1300:ffff:ffff:ffff:ffff:ffff:ffff,CY
+2a03:1320::,2a03:1320:ffff:ffff:ffff:ffff:ffff:ffff,TR
2a03:1340::,2a03:1340:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:1360::,2a03:1360:ffff:ffff:ffff:ffff:ffff:ffff,CH
2a03:1380::,2a03:1380:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a03:13a0::,2a03:13a0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:13c0::,2a03:13c0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:13e0::,2a03:13e0:ffff:ffff:ffff:ffff:ffff:ffff,CH
2a03:1400::,2a03:1400:ffff:ffff:ffff:ffff:ffff:ffff,NO
+2a03:1420::,2a03:1420:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a03:1440::,2a03:1440:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:1460::,2a03:1460:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a03:1480::,2a03:1480:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:14a0::,2a03:14a0:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:14c0::,2a03:14c0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:14e0::,2a03:14e0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1500::,2a03:1500:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2a03:1520::,2a03:1520:ffff:ffff:ffff:ffff:ffff:ffff,TR
2a03:1540::,2a03:1540:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:1560::,2a03:1560:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a03:1580::,2a03:1580:ffff:ffff:ffff:ffff:ffff:ffff,BE
+2a03:15a0::,2a03:15a0:ffff:ffff:ffff:ffff:ffff:ffff,HK
2a03:15c0::,2a03:15c0:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a03:15e0::,2a03:15e0:ffff:ffff:ffff:ffff:ffff:ffff,BE
2a03:1600::,2a03:1600:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:1620::,2a03:1620:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1640::,2a03:1640:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:1660::,2a03:1660:ffff:ffff:ffff:ffff:ffff:ffff,KW
2a03:1680::,2a03:1680:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a03:16a0::,2a03:16a0:ffff:ffff:ffff:ffff:ffff:ffff,ME
2a03:16c0::,2a03:16c0:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:16e0::,2a03:16e0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:1700::,2a03:1707:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:1740::,2a03:1740:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:1760::,2a03:1760:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1780::,2a03:1780:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:17a0::,2a03:17a0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:17c0::,2a03:17c0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:17e0::,2a03:17e0:ffff:ffff:ffff:ffff:ffff:ffff,CH
2a03:1800::,2a03:1800:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:1820::,2a03:1820:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:1840::,2a03:1840:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a03:1860::,2a03:1860:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1880::,2a03:1880:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a03:18a0::,2a03:18a0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:18c0::,2a03:18c0:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:18e0::,2a03:18e0:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:1900::,2a03:1900:ffff:ffff:ffff:ffff:ffff:ffff,AM
+2a03:1920::,2a03:1920:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a03:1940::,2a03:1940:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a03:1960::,2a03:1960:ffff:ffff:ffff:ffff:ffff:ffff,LT
2a03:1980::,2a03:1980:ffff:ffff:ffff:ffff:ffff:ffff,BE
+2a03:19a0::,2a03:19a0:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a03:19e0::,2a03:19e0:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a03:1a00::,2a03:1a00:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:1a20::,2a03:1a20:ffff:ffff:ffff:ffff:ffff:ffff,BE
2a03:1a40::,2a03:1a40:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:1a60::,2a03:1a60:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:1a80::,2a03:1a80:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a03:1aa0::,2a03:1aa0:ffff:ffff:ffff:ffff:ffff:ffff,CA
2a03:1ac0::,2a03:1ac0:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:1ae0::,2a03:1ae0:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:1b00::,2a03:1b00:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a03:1b20::,2a03:1b20:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:1b40::,2a03:1b40:ffff:ffff:ffff:ffff:ffff:ffff,RS
+2a03:1b60::,2a03:1b60:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1b80::,2a03:1b80:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a03:1ba0::,2a03:1ba0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1bc0::,2a03:1bc0:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:1be0::,2a03:1be0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1c00::,2a03:1c00:ffff:ffff:ffff:ffff:ffff:ffff,BH
+2a03:1c20::,2a03:1c20:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:1c40::,2a03:1c40:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:1c60::,2a03:1c60:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:1c80::,2a03:1c80:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a03:1ca0::,2a03:1ca0:ffff:ffff:ffff:ffff:ffff:ffff,NO
2a03:1cc0::,2a03:1cc0:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a03:1ce0::,2a03:1ce0:ffff:ffff:ffff:ffff:ffff:ffff,SE
2a03:1d00::,2a03:1d00:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:1d20::,2a03:1d20:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a03:1d40::,2a03:1d40:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a03:1d60::,2a03:1d60:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:1d80::,2a03:1d80:ffff:ffff:ffff:ffff:ffff:ffff,SK
+2a03:1da0::,2a03:1da0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:1dc0::,2a03:1dc0:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:1de0::,2a03:1de0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:1e00::,2a03:1e00:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:1e20::,2a03:1e20:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:1e40::,2a03:1e40:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a03:1e60::,2a03:1e60:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1e80::,2a03:1e80:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a03:1ea0::,2a03:1ea0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1ec0::,2a03:1ec0:ffff:ffff:ffff:ffff:ffff:ffff,BG
+2a03:1ee0::,2a03:1ee0:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:1f00::,2a03:1f00:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a03:1f20::,2a03:1f20:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:1f40::,2a03:1f40:ffff:ffff:ffff:ffff:ffff:ffff,IE
2a03:1f80::,2a03:1f80:ffff:ffff:ffff:ffff:ffff:ffff,CZ
2a03:2000::,2a03:2000:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -14335,7 +13618,7 @@
2a03:3480::,2a03:3480:ffff:ffff:ffff:ffff:ffff:ffff,RU
2a03:34c0::,2a03:34c0:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a03:3500::,2a03:3500:ffff:ffff:ffff:ffff:ffff:ffff,DE
-2a03:3540::,2a03:3540:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a03:3540::,2a03:3547:ffff:ffff:ffff:ffff:ffff:ffff,FR
2a03:3580::,2a03:3580:ffff:ffff:ffff:ffff:ffff:ffff,GE
2a03:35c0::,2a03:35c0:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a03:3600::,2a03:3600:ffff:ffff:ffff:ffff:ffff:ffff,BE
@@ -15621,7 +14904,7 @@
2a04:8140::,2a04:8147:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a04:8180::,2a04:8181:ffff:ffff:ffff:ffff:ffff:ffff,SY
2a04:8190::,2a04:8191:ffff:ffff:ffff:ffff:ffff:ffff,NL
-2a04:81a0::,2a04:81a3:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a04:81a0::,2a04:81a7:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a04:81c0::,2a04:81c7:ffff:ffff:ffff:ffff:ffff:ffff,LU
2a04:8200::,2a04:8207:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a04:8240::,2a04:8247:ffff:ffff:ffff:ffff:ffff:ffff,RU
@@ -15877,7 +15160,6 @@
2a04:c1c0::,2a04:c1c7:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a04:c200::,2a04:c207:ffff:ffff:ffff:ffff:ffff:ffff,GE
2a04:c240::,2a04:c247:ffff:ffff:ffff:ffff:ffff:ffff,IT
-2a04:c280::,2a04:c287:ffff:ffff:ffff:ffff:ffff:ffff,AT
2a04:c2c0::,2a04:c2c7:ffff:ffff:ffff:ffff:ffff:ffff,SA
2a04:c300::,2a04:c307:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a04:c340::,2a04:c347:ffff:ffff:ffff:ffff:ffff:ffff,RU
@@ -15925,7 +15207,6 @@
2a04:ce40::,2a04:ce47:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a04:ce80::,2a04:ce87:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a04:cec0::,2a04:cec7:ffff:ffff:ffff:ffff:ffff:ffff,FR
-2a04:cf00::,2a04:cf07:ffff:ffff:ffff:ffff:ffff:ffff,NL
2a04:cf40::,2a04:cf47:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a04:cf80::,2a04:cf87:ffff:ffff:ffff:ffff:ffff:ffff,SA
2a04:cfc0::,2a04:cfc7:ffff:ffff:ffff:ffff:ffff:ffff,RU
@@ -16040,6 +15321,7 @@
2a04:eb80::,2a04:eb87:ffff:ffff:ffff:ffff:ffff:ffff,ES
2a04:ebc0::,2a04:ebc7:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a04:ec00::,2a04:ec01:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:ec20::,2a04:ec23:ffff:ffff:ffff:ffff:ffff:ffff,RS
2a04:ec40::,2a04:ec47:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a04:ec80::,2a04:ec87:ffff:ffff:ffff:ffff:ffff:ffff,DE
2a04:ecc0::,2a04:ecc7:ffff:ffff:ffff:ffff:ffff:ffff,GB
@@ -16055,6 +15337,81 @@
2a04:ef80::,2a04:ef87:ffff:ffff:ffff:ffff:ffff:ffff,GB
2a04:efc0::,2a04:efc7:ffff:ffff:ffff:ffff:ffff:ffff,IT
2a04:f000::,2a04:f007:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a04:f040::,2a04:f047:ffff:ffff:ffff:ffff:ffff:ffff,HU
+2a04:f080::,2a04:f087:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2a04:f0c0::,2a04:f0c7:ffff:ffff:ffff:ffff:ffff:ffff,LV
+2a04:f100::,2a04:f107:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a04:f140::,2a04:f147:ffff:ffff:ffff:ffff:ffff:ffff,CY
+2a04:f180::,2a04:f187:ffff:ffff:ffff:ffff:ffff:ffff,SE
+2a04:f1c0::,2a04:f1c7:ffff:ffff:ffff:ffff:ffff:ffff,SA
+2a04:f200::,2a04:f207:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a04:f240::,2a04:f247:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a04:f280::,2a04:f287:ffff:ffff:ffff:ffff:ffff:ffff,BG
+2a04:f2c0::,2a04:f2c7:ffff:ffff:ffff:ffff:ffff:ffff,BA
+2a04:f300::,2a04:f300:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:f320::,2a04:f323:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a04:f340::,2a04:f347:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a04:f380::,2a04:f387:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:f3c0::,2a04:f3c7:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a04:f440::,2a04:f447:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a04:f480::,2a04:f487:ffff:ffff:ffff:ffff:ffff:ffff,SK
+2a04:f4c0::,2a04:f4c7:ffff:ffff:ffff:ffff:ffff:ffff,RO
+2a04:f500::,2a04:f507:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a04:f540::,2a04:f547:ffff:ffff:ffff:ffff:ffff:ffff,US
+2a04:f580::,2a04:f587:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a04:f5c0::,2a04:f5c7:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a04:f600::,2a04:f607:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a04:f680::,2a04:f687:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a04:f6c0::,2a04:f6c7:ffff:ffff:ffff:ffff:ffff:ffff,SC
+2a04:f700::,2a04:f707:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2a04:f740::,2a04:f747:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:f780::,2a04:f787:ffff:ffff:ffff:ffff:ffff:ffff,IN
+2a04:f7c0::,2a04:f7c7:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:f800::,2a04:f807:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a04:f840::,2a04:f847:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:f880::,2a04:f887:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a04:f8c0::,2a04:f8c7:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a04:f900::,2a04:f907:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a04:f940::,2a04:f947:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a04:f980::,2a04:f987:ffff:ffff:ffff:ffff:ffff:ffff,RO
+2a04:f9c0::,2a04:f9c7:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a04:fa00::,2a04:fa07:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:fa40::,2a04:fa47:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2a04:fa80::,2a04:fa87:ffff:ffff:ffff:ffff:ffff:ffff,IE
+2a04:fb40::,2a04:fb47:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2a04:fb80::,2a04:fb87:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a04:fbc0::,2a04:fbc7:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a04:fc00::,2a04:fc07:ffff:ffff:ffff:ffff:ffff:ffff,IT
+2a04:fc40::,2a04:fc47:ffff:ffff:ffff:ffff:ffff:ffff,LU
+2a04:fc80::,2a04:fc87:ffff:ffff:ffff:ffff:ffff:ffff,IR
+2a04:fcc0::,2a04:fcc7:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a04:fd00::,2a04:fd07:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a04:ff40::,2a04:ff47:ffff:ffff:ffff:ffff:ffff:ffff,AT
+2a04:ff80::,2a04:ff87:ffff:ffff:ffff:ffff:ffff:ffff,BA
+2a04:ffc0::,2a04:ffc7:ffff:ffff:ffff:ffff:ffff:ffff,HU
+2a05::,2a05:7:ffff:ffff:ffff:ffff:ffff:ffff,BE
+2a05:40::,2a05:47:ffff:ffff:ffff:ffff:ffff:ffff,MD
+2a05:80::,2a05:87:ffff:ffff:ffff:ffff:ffff:ffff,CH
+2a05:c0::,2a05:c7:ffff:ffff:ffff:ffff:ffff:ffff,DK
+2a05:100::,2a05:107:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a05:140::,2a05:147:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a05:180::,2a05:187:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a05:1c0::,2a05:1c7:ffff:ffff:ffff:ffff:ffff:ffff,GB
+2a05:200::,2a05:207:ffff:ffff:ffff:ffff:ffff:ffff,BE
+2a05:240::,2a05:247:ffff:ffff:ffff:ffff:ffff:ffff,NL
+2a05:280::,2a05:287:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a05:2c0::,2a05:2c7:ffff:ffff:ffff:ffff:ffff:ffff,CZ
+2a05:300::,2a05:307:ffff:ffff:ffff:ffff:ffff:ffff,TR
+2a05:340::,2a05:347:ffff:ffff:ffff:ffff:ffff:ffff,ES
+2a05:380::,2a05:387:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a05:3c0::,2a05:3c7:ffff:ffff:ffff:ffff:ffff:ffff,FR
+2a05:400::,2a05:407:ffff:ffff:ffff:ffff:ffff:ffff,DE
+2a05:440::,2a05:447:ffff:ffff:ffff:ffff:ffff:ffff,PL
+2a05:480::,2a05:487:ffff:ffff:ffff:ffff:ffff:ffff,UA
+2a05:4c0::,2a05:4c7:ffff:ffff:ffff:ffff:ffff:ffff,IQ
+2a05:500::,2a05:507:ffff:ffff:ffff:ffff:ffff:ffff,UA
+2a05:540::,2a05:547:ffff:ffff:ffff:ffff:ffff:ffff,RU
+2a05:580::,2a05:587:ffff:ffff:ffff:ffff:ffff:ffff,AE
2c0e::,2c0e:fff:ffff:ffff:ffff:ffff:ffff:ffff,EG
2c0e:2000::,2c0e:200f:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:f600::,2c0f:f600:ffff:ffff:ffff:ffff:ffff:ffff,GN
@@ -16095,6 +15452,7 @@
2c0f:f718::,2c0f:f718:ffff:ffff:ffff:ffff:ffff:ffff,BW
2c0f:f720::,2c0f:f720:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:f728::,2c0f:f728:ffff:ffff:ffff:ffff:ffff:ffff,BW
+2c0f:f730::,2c0f:f730:ffff:ffff:ffff:ffff:ffff:ffff,TZ
2c0f:f800::,2c0f:f80f:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:f810::,2c0f:f810:ffff:ffff:ffff:ffff:ffff:ffff,AO
2c0f:f818::,2c0f:f818:ffff:ffff:ffff:ffff:ffff:ffff,BJ
@@ -16107,7 +15465,6 @@
2c0f:f850::,2c0f:f850:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:f858::,2c0f:f858:ffff:ffff:ffff:ffff:ffff:ffff,DZ
2c0f:f860::,2c0f:f860:ffff:ffff:ffff:ffff:ffff:ffff,RW
-2c0f:f870::,2c0f:f870:ffff:ffff:ffff:ffff:ffff:ffff,NG
2c0f:f878::,2c0f:f878:ffff:ffff:ffff:ffff:ffff:ffff,KE
2c0f:f880::,2c0f:f880:ffff:ffff:ffff:ffff:ffff:ffff,NG
2c0f:f888::,2c0f:f888:ffff:ffff:ffff:ffff:ffff:ffff,AO
@@ -16189,7 +15546,6 @@
2c0f:fb10::,2c0f:fb10:ffff:ffff:ffff:ffff:ffff:ffff,LY
2c0f:fb18::,2c0f:fb18:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:fb20::,2c0f:fb20:ffff:ffff:ffff:ffff:ffff:ffff,MA
-2c0f:fb28::,2c0f:fb28:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:fb30::,2c0f:fb30:ffff:ffff:ffff:ffff:ffff:ffff,ZA
2c0f:fb38::,2c0f:fb38:ffff:ffff:ffff:ffff:ffff:ffff,SO
2c0f:fb40::,2c0f:fb40:ffff:ffff:ffff:ffff:ffff:ffff,ZA
diff --git a/src/config/include.am b/src/config/include.am
index 35961b829a..c283628513 100644
--- a/src/config/include.am
+++ b/src/config/include.am
@@ -2,7 +2,7 @@ confdir = $(sysconfdir)/tor
tordatadir = $(datadir)/tor
-EXTRA_DIST+= src/config/geoip src/config/geoip6
+EXTRA_DIST+= src/config/geoip src/config/geoip6 src/config/torrc.minimal.in
# fallback-consensus
conf_DATA = src/config/torrc.sample
diff --git a/src/config/torrc.minimal.in b/src/config/torrc.minimal.in
new file mode 100644
index 0000000000..d842fbcaf5
--- /dev/null
+++ b/src/config/torrc.minimal.in
@@ -0,0 +1,192 @@
+## Configuration file for a typical Tor user
+## Last updated 9 October 2013 for Tor 0.2.5.2-alpha.
+## (may or may not work for much older or much newer versions of Tor.)
+##
+## Lines that begin with "## " try to explain what's going on. Lines
+## that begin with just "#" are disabled commands: you can enable them
+## by removing the "#" symbol.
+##
+## See 'man tor', or https://www.torproject.org/docs/tor-manual.html,
+## for more options you can use in this file.
+##
+## Tor will look for this file in various places based on your platform:
+## https://www.torproject.org/docs/faq#torrc
+
+## Tor opens a socks proxy on port 9050 by default -- even if you don't
+## configure one below. Set "SocksPort 0" if you plan to run Tor only
+## as a relay, and not make any local application connections yourself.
+#SocksPort 9050 # Default: Bind to localhost:9050 for local connections.
+#SocksPort 192.168.0.1:9100 # Bind to this address:port too.
+
+## Entry policies to allow/deny SOCKS requests based on IP address.
+## First entry that matches wins. If no SocksPolicy is set, we accept
+## all (and only) requests that reach a SocksPort. Untrusted users who
+## can access your SocksPort may be able to learn about the connections
+## you make.
+#SocksPolicy accept 192.168.0.0/16
+#SocksPolicy reject *
+
+## Logs go to stdout at level "notice" unless redirected by something
+## else, like one of the below lines. You can have as many Log lines as
+## you want.
+##
+## We advise using "notice" in most cases, since anything more verbose
+## may provide sensitive information to an attacker who obtains the logs.
+##
+## Send all messages of level 'notice' or higher to @LOCALSTATEDIR@/log/tor/notices.log
+#Log notice file @LOCALSTATEDIR@/log/tor/notices.log
+## Send every possible message to @LOCALSTATEDIR@/log/tor/debug.log
+#Log debug file @LOCALSTATEDIR@/log/tor/debug.log
+## Use the system log instead of Tor's logfiles
+#Log notice syslog
+## To send all messages to stderr:
+#Log debug stderr
+
+## Uncomment this to start the process in the background... or use
+## --runasdaemon 1 on the command line. This is ignored on Windows;
+## see the FAQ entry if you want Tor to run as an NT service.
+#RunAsDaemon 1
+
+## The directory for keeping all the keys/etc. By default, we store
+## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
+#DataDirectory @LOCALSTATEDIR@/lib/tor
+
+## The port on which Tor will listen for local connections from Tor
+## controller applications, as documented in control-spec.txt.
+#ControlPort 9051
+## If you enable the controlport, be sure to enable one of these
+## authentication methods, to prevent attackers from accessing it.
+#HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
+#CookieAuthentication 1
+
+############### This section is just for location-hidden services ###
+
+## Once you have configured a hidden service, you can look at the
+## contents of the file ".../hidden_service/hostname" for the address
+## to tell people.
+##
+## HiddenServicePort x y:z says to redirect requests on port x to the
+## address y:z.
+
+#HiddenServiceDir @LOCALSTATEDIR@/lib/tor/hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+
+#HiddenServiceDir @LOCALSTATEDIR@/lib/tor/other_hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+#HiddenServicePort 22 127.0.0.1:22
+
+################ This section is just for relays #####################
+#
+## See https://www.torproject.org/docs/tor-doc-relay for details.
+
+## Required: what port to advertise for incoming Tor connections.
+#ORPort 9001
+## If you want to listen on a port other than the one advertised in
+## ORPort (e.g. to advertise 443 but bind to 9090), you can do it as
+## follows. You'll need to do ipchains or other port forwarding
+## yourself to make this work.
+#ORPort 443 NoListen
+#ORPort 127.0.0.1:9090 NoAdvertise
+
+## The IP address or full DNS name for incoming connections to your
+## relay. Leave commented out and Tor will guess.
+#Address noname.example.com
+
+## If you have multiple network interfaces, you can specify one for
+## outgoing traffic to use.
+# OutboundBindAddress 10.0.0.5
+
+## A handle for your relay, so people don't have to refer to it by key.
+#Nickname ididnteditheconfig
+
+## Define these to limit how much relayed traffic you will allow. Your
+## own traffic is still unthrottled. Note that RelayBandwidthRate must
+## be at least 20 KB.
+## Note that units for these config options are bytes per second, not bits
+## per second, and that prefixes are binary prefixes, i.e. 2^10, 2^20, etc.
+#RelayBandwidthRate 100 KB # Throttle traffic to 100KB/s (800Kbps)
+#RelayBandwidthBurst 200 KB # But allow bursts up to 200KB/s (1600Kbps)
+
+## Use these to restrict the maximum traffic per day, week, or month.
+## Note that this threshold applies separately to sent and received bytes,
+## not to their sum: setting "4 GB" may allow up to 8 GB total before
+## hibernating.
+##
+## Set a maximum of 4 gigabytes each way per period.
+#AccountingMax 4 GB
+## Each period starts daily at midnight (AccountingMax is per day)
+#AccountingStart day 00:00
+## Each period starts on the 3rd of the month at 15:00 (AccountingMax
+## is per month)
+#AccountingStart month 3 15:00
+
+## Administrative contact information for this relay or bridge. This line
+## can be used to contact you if your relay or bridge is misconfigured or
+## something else goes wrong. Note that we archive and publish all
+## descriptors containing these lines and that Google indexes them, so
+## spammers might also collect them. You may want to obscure the fact that
+## it's an email address and/or generate a new address for this purpose.
+#ContactInfo Random Person <nobody AT example dot com>
+## You might also include your PGP or GPG fingerprint if you have one:
+#ContactInfo 0xFFFFFFFF Random Person <nobody AT example dot com>
+
+## Uncomment this to mirror directory information for others. Please do
+## if you have enough bandwidth.
+#DirPort 9030 # what port to advertise for directory connections
+## If you want to listen on a port other than the one advertised in
+## DirPort (e.g. to advertise 80 but bind to 9091), you can do it as
+## follows. below too. You'll need to do ipchains or other port
+## forwarding yourself to make this work.
+#DirPort 80 NoListen
+#DirPort 127.0.0.1:9091 NoAdvertise
+## Uncomment to return an arbitrary blob of html on your DirPort. Now you
+## can explain what Tor is if anybody wonders why your IP address is
+## contacting them. See contrib/tor-exit-notice.html in Tor's source
+## distribution for a sample.
+#DirPortFrontPage @CONFDIR@/tor-exit-notice.html
+
+## Uncomment this if you run more than one Tor relay, and add the identity
+## key fingerprint of each Tor relay you control, even if they're on
+## different networks. You declare it here so Tor clients can avoid
+## using more than one of your relays in a single circuit. See
+## https://www.torproject.org/docs/faq#MultipleRelays
+## However, you should never include a bridge's fingerprint here, as it would
+## break its concealability and potentionally reveal its IP/TCP address.
+#MyFamily $keyid,$keyid,...
+
+## A comma-separated list of exit policies. They're considered first
+## to last, and the first match wins. If you want to _replace_
+## the default exit policy, end this with either a reject *:* or an
+## accept *:*. Otherwise, you're _augmenting_ (prepending to) the
+## default exit policy. Leave commented to just use the default, which is
+## described in the man page or at
+## https://www.torproject.org/documentation.html
+##
+## Look at https://www.torproject.org/faq-abuse.html#TypicalAbuses
+## for issues you might encounter if you use the default exit policy.
+##
+## If certain IPs and ports are blocked externally, e.g. by your firewall,
+## you should update your exit policy to reflect this -- otherwise Tor
+## users will be told that those destinations are down.
+##
+## For security, by default Tor rejects connections to private (local)
+## networks, including to your public IP address. See the man page entry
+## for ExitPolicyRejectPrivate if you want to allow "exit enclaving".
+##
+#ExitPolicy accept *:6660-6667,reject *:* # allow irc ports but no more
+#ExitPolicy accept *:119 # accept nntp as well as default exit policy
+#ExitPolicy reject *:* # no exits allowed
+
+## Bridge relays (or "bridges") are Tor relays that aren't listed in the
+## main directory. Since there is no complete public list of them, even an
+## ISP that filters connections to all the known Tor relays probably
+## won't be able to block all the bridges. Also, websites won't treat you
+## differently because they won't know you're running Tor. If you can
+## be a real relay, please do; but if not, be a bridge!
+#BridgeRelay 1
+## By default, Tor will advertise your bridge to users through various
+## mechanisms like https://bridges.torproject.org/. If you want to run
+## a private bridge, for example because you'll give out your bridge
+## address manually to your friends, uncomment this line:
+#PublishServerDescriptor 0
+
diff --git a/src/config/torrc.minimal.in-staging b/src/config/torrc.minimal.in-staging
new file mode 100644
index 0000000000..bde800fd23
--- /dev/null
+++ b/src/config/torrc.minimal.in-staging
@@ -0,0 +1,193 @@
+## Configuration file for a typical Tor user
+## Last updated 2 September 2014 for Tor 0.2.6.1-alpha.
+## (may or may not work for much older or much newer versions of Tor.)
+##
+## Lines that begin with "## " try to explain what's going on. Lines
+## that begin with just "#" are disabled commands: you can enable them
+## by removing the "#" symbol.
+##
+## See 'man tor', or https://www.torproject.org/docs/tor-manual.html,
+## for more options you can use in this file.
+##
+## Tor will look for this file in various places based on your platform:
+## https://www.torproject.org/docs/faq#torrc
+
+## Tor opens a socks proxy on port 9050 by default -- even if you don't
+## configure one below. Set "SocksPort 0" if you plan to run Tor only
+## as a relay, and not make any local application connections yourself.
+#SocksPort 9050 # Default: Bind to localhost:9050 for local connections.
+#SocksPort 192.168.0.1:9100 # Bind to this address:port too.
+
+## Entry policies to allow/deny SOCKS requests based on IP address.
+## First entry that matches wins. If no SocksPolicy is set, we accept
+## all (and only) requests that reach a SocksPort. Untrusted users who
+## can access your SocksPort may be able to learn about the connections
+## you make.
+#SocksPolicy accept 192.168.0.0/16
+#SocksPolicy reject *
+
+## Logs go to stdout at level "notice" unless redirected by something
+## else, like one of the below lines. You can have as many Log lines as
+## you want.
+##
+## We advise using "notice" in most cases, since anything more verbose
+## may provide sensitive information to an attacker who obtains the logs.
+##
+## Send all messages of level 'notice' or higher to @LOCALSTATEDIR@/log/tor/notices.log
+#Log notice file @LOCALSTATEDIR@/log/tor/notices.log
+## Send every possible message to @LOCALSTATEDIR@/log/tor/debug.log
+#Log debug file @LOCALSTATEDIR@/log/tor/debug.log
+## Use the system log instead of Tor's logfiles
+#Log notice syslog
+## To send all messages to stderr:
+#Log debug stderr
+
+## Uncomment this to start the process in the background... or use
+## --runasdaemon 1 on the command line. This is ignored on Windows;
+## see the FAQ entry if you want Tor to run as an NT service.
+#RunAsDaemon 1
+
+## The directory for keeping all the keys/etc. By default, we store
+## things in $HOME/.tor on Unix, and in Application Data\tor on Windows.
+#DataDirectory @LOCALSTATEDIR@/lib/tor
+
+## The port on which Tor will listen for local connections from Tor
+## controller applications, as documented in control-spec.txt.
+#ControlPort 9051
+## If you enable the controlport, be sure to enable one of these
+## authentication methods, to prevent attackers from accessing it.
+#HashedControlPassword 16:872860B76453A77D60CA2BB8C1A7042072093276A3D701AD684053EC4C
+#CookieAuthentication 1
+
+############### This section is just for location-hidden services ###
+
+## Once you have configured a hidden service, you can look at the
+## contents of the file ".../hidden_service/hostname" for the address
+## to tell people.
+##
+## HiddenServicePort x y:z says to redirect requests on port x to the
+## address y:z.
+
+#HiddenServiceDir @LOCALSTATEDIR@/lib/tor/hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+
+#HiddenServiceDir @LOCALSTATEDIR@/lib/tor/other_hidden_service/
+#HiddenServicePort 80 127.0.0.1:80
+#HiddenServicePort 22 127.0.0.1:22
+
+################ This section is just for relays #####################
+#
+## See https://www.torproject.org/docs/tor-doc-relay for details.
+
+## Required: what port to advertise for incoming Tor connections.
+#ORPort 9001
+## If you want to listen on a port other than the one advertised in
+## ORPort (e.g. to advertise 443 but bind to 9090), you can do it as
+## follows. You'll need to do ipchains or other port forwarding
+## yourself to make this work.
+#ORPort 443 NoListen
+#ORPort 127.0.0.1:9090 NoAdvertise
+
+## The IP address or full DNS name for incoming connections to your
+## relay. Leave commented out and Tor will guess.
+#Address noname.example.com
+
+## If you have multiple network interfaces, you can specify one for
+## outgoing traffic to use.
+# OutboundBindAddress 10.0.0.5
+
+## A handle for your relay, so people don't have to refer to it by key.
+#Nickname ididnteditheconfig
+
+## Define these to limit how much relayed traffic you will allow. Your
+## own traffic is still unthrottled. Note that RelayBandwidthRate must
+## be at least 20 kilobytes per second.
+## Note that units for these config options are bytes (per second), not
+## bits (per second), and that prefixes are binary prefixes, i.e. 2^10,
+## 2^20, etc.
+#RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps)
+#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)
+
+## Use these to restrict the maximum traffic per day, week, or month.
+## Note that this threshold applies separately to sent and received bytes,
+## not to their sum: setting "4 GB" may allow up to 8 GB total before
+## hibernating.
+##
+## Set a maximum of 4 gigabytes each way per period.
+#AccountingMax 4 GBytes
+## Each period starts daily at midnight (AccountingMax is per day)
+#AccountingStart day 00:00
+## Each period starts on the 3rd of the month at 15:00 (AccountingMax
+## is per month)
+#AccountingStart month 3 15:00
+
+## Administrative contact information for this relay or bridge. This line
+## can be used to contact you if your relay or bridge is misconfigured or
+## something else goes wrong. Note that we archive and publish all
+## descriptors containing these lines and that Google indexes them, so
+## spammers might also collect them. You may want to obscure the fact that
+## it's an email address and/or generate a new address for this purpose.
+#ContactInfo Random Person <nobody AT example dot com>
+## You might also include your PGP or GPG fingerprint if you have one:
+#ContactInfo 0xFFFFFFFF Random Person <nobody AT example dot com>
+
+## Uncomment this to mirror directory information for others. Please do
+## if you have enough bandwidth.
+#DirPort 9030 # what port to advertise for directory connections
+## If you want to listen on a port other than the one advertised in
+## DirPort (e.g. to advertise 80 but bind to 9091), you can do it as
+## follows. below too. You'll need to do ipchains or other port
+## forwarding yourself to make this work.
+#DirPort 80 NoListen
+#DirPort 127.0.0.1:9091 NoAdvertise
+## Uncomment to return an arbitrary blob of html on your DirPort. Now you
+## can explain what Tor is if anybody wonders why your IP address is
+## contacting them. See contrib/tor-exit-notice.html in Tor's source
+## distribution for a sample.
+#DirPortFrontPage @CONFDIR@/tor-exit-notice.html
+
+## Uncomment this if you run more than one Tor relay, and add the identity
+## key fingerprint of each Tor relay you control, even if they're on
+## different networks. You declare it here so Tor clients can avoid
+## using more than one of your relays in a single circuit. See
+## https://www.torproject.org/docs/faq#MultipleRelays
+## However, you should never include a bridge's fingerprint here, as it would
+## break its concealability and potentially reveal its IP/TCP address.
+#MyFamily $keyid,$keyid,...
+
+## A comma-separated list of exit policies. They're considered first
+## to last, and the first match wins. If you want to _replace_
+## the default exit policy, end this with either a reject *:* or an
+## accept *:*. Otherwise, you're _augmenting_ (prepending to) the
+## default exit policy. Leave commented to just use the default, which is
+## described in the man page or at
+## https://www.torproject.org/documentation.html
+##
+## Look at https://www.torproject.org/faq-abuse.html#TypicalAbuses
+## for issues you might encounter if you use the default exit policy.
+##
+## If certain IPs and ports are blocked externally, e.g. by your firewall,
+## you should update your exit policy to reflect this -- otherwise Tor
+## users will be told that those destinations are down.
+##
+## For security, by default Tor rejects connections to private (local)
+## networks, including to your public IP address. See the man page entry
+## for ExitPolicyRejectPrivate if you want to allow "exit enclaving".
+##
+#ExitPolicy accept *:6660-6667,reject *:* # allow irc ports but no more
+#ExitPolicy accept *:119 # accept nntp as well as default exit policy
+#ExitPolicy reject *:* # no exits allowed
+
+## Bridge relays (or "bridges") are Tor relays that aren't listed in the
+## main directory. Since there is no complete public list of them, even an
+## ISP that filters connections to all the known Tor relays probably
+## won't be able to block all the bridges. Also, websites won't treat you
+## differently because they won't know you're running Tor. If you can
+## be a real relay, please do; but if not, be a bridge!
+#BridgeRelay 1
+## By default, Tor will advertise your bridge to users through various
+## mechanisms like https://bridges.torproject.org/. If you want to run
+## a private bridge, for example because you'll give out your bridge
+## address manually to your friends, uncomment this line:
+#PublishServerDescriptor 0
+
diff --git a/src/config/torrc.sample.in b/src/config/torrc.sample.in
index d842fbcaf5..bde800fd23 100644
--- a/src/config/torrc.sample.in
+++ b/src/config/torrc.sample.in
@@ -1,5 +1,5 @@
## Configuration file for a typical Tor user
-## Last updated 9 October 2013 for Tor 0.2.5.2-alpha.
+## Last updated 2 September 2014 for Tor 0.2.6.1-alpha.
## (may or may not work for much older or much newer versions of Tor.)
##
## Lines that begin with "## " try to explain what's going on. Lines
@@ -101,11 +101,12 @@
## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must
-## be at least 20 KB.
-## Note that units for these config options are bytes per second, not bits
-## per second, and that prefixes are binary prefixes, i.e. 2^10, 2^20, etc.
-#RelayBandwidthRate 100 KB # Throttle traffic to 100KB/s (800Kbps)
-#RelayBandwidthBurst 200 KB # But allow bursts up to 200KB/s (1600Kbps)
+## be at least 20 kilobytes per second.
+## Note that units for these config options are bytes (per second), not
+## bits (per second), and that prefixes are binary prefixes, i.e. 2^10,
+## 2^20, etc.
+#RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps)
+#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)
## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes,
@@ -113,7 +114,7 @@
## hibernating.
##
## Set a maximum of 4 gigabytes each way per period.
-#AccountingMax 4 GB
+#AccountingMax 4 GBytes
## Each period starts daily at midnight (AccountingMax is per day)
#AccountingStart day 00:00
## Each period starts on the 3rd of the month at 15:00 (AccountingMax
@@ -151,7 +152,7 @@
## using more than one of your relays in a single circuit. See
## https://www.torproject.org/docs/faq#MultipleRelays
## However, you should never include a bridge's fingerprint here, as it would
-## break its concealability and potentionally reveal its IP/TCP address.
+## break its concealability and potentially reveal its IP/TCP address.
#MyFamily $keyid,$keyid,...
## A comma-separated list of exit policies. They're considered first
diff --git a/src/ext/Makefile.nmake b/src/ext/Makefile.nmake
new file mode 100644
index 0000000000..d02d03bf41
--- /dev/null
+++ b/src/ext/Makefile.nmake
@@ -0,0 +1,12 @@
+all: csiphash.lib
+
+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
+ /I ..\ext
+
+CSIPHASH_OBJECTS = csiphash.obj
+
+csiphash.lib: $(CSIPHASH_OBJECTS)
+ lib $(CSIPHASH_OBJECTS) $(CURVE25519_DONNA_OBJECTS) /out:csiphash.lib
+
+clean:
+ del *.obj *.lib
diff --git a/src/ext/OpenBSD_malloc_Linux.c b/src/ext/OpenBSD_malloc_Linux.c
index da82729811..855c912310 100644
--- a/src/ext/OpenBSD_malloc_Linux.c
+++ b/src/ext/OpenBSD_malloc_Linux.c
@@ -58,7 +58,7 @@
#include <limits.h>
#include <errno.h>
#include <err.h>
-/* For SIZE_T_MAX */
+/* For SIZE_MAX */
#include "torint.h"
//#include "thread_private.h"
@@ -1961,16 +1961,6 @@ realloc(void *ptr, size_t size)
return (r);
}
-#ifndef SIZE_MAX
-//#if defined(__i386__)||defined(__arm__)||defined(__powerpc__)
-//#define SIZE_MAX 0xffffffff
-//#endif
-//#if defined(__x86_64__)
-//#define SIZE_MAX 0xffffffffffffffff
-//#endif
-#define SIZE_MAX SIZE_T_MAX
-#endif
-
void *
calloc(size_t num, size_t size)
{
diff --git a/src/ext/README b/src/ext/README
index 5d5a6e1518..616716e099 100644
--- a/src/ext/README
+++ b/src/ext/README
@@ -49,3 +49,15 @@ siphash.h
Marek Majkowski's implementation of siphash 2-4, a secure keyed
hash algorithm to avoid collision-based DoS attacks against hash
tables.
+
+trunnel/*.[ch]
+
+ Headers and runtime code for Trunnel, a system for generating
+ code to encode and decode binary formats.
+
+ed25519/ref10/*
+
+ Daniel Bernsten's portable ref10 implementation of ed25519.
+ Public domain.
+
+
diff --git a/src/ext/csiphash.c b/src/ext/csiphash.c
index c247886038..faca9ef362 100644
--- a/src/ext/csiphash.c
+++ b/src/ext/csiphash.c
@@ -1,5 +1,5 @@
/* <MIT License>
- Copyright (c) 2013 Marek Majkowski <marek@popcount.org>
+ Copyright (c) 2013-2014 Marek Majkowski <marek@popcount.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
diff --git a/src/ext/curve25519_donna/curve25519-donna.c b/src/ext/curve25519_donna/curve25519-donna.c
index 5c6821ccd8..5a0c3401dd 100644
--- a/src/ext/curve25519_donna/curve25519-donna.c
+++ b/src/ext/curve25519_donna/curve25519-donna.c
@@ -43,8 +43,7 @@
*
* This is, almost, a clean room reimplementation from the curve25519 paper. It
* uses many of the tricks described therein. Only the crecip function is taken
- * from the sample implementation.
- */
+ * from the sample implementation. */
#include "orconfig.h"
@@ -61,25 +60,23 @@ typedef int64_t limb;
* significant first. The value of the field element is:
* x[0] + 2^26·x[1] + x^51·x[2] + 2^102·x[3] + ...
*
- * i.e. the limbs are 26, 25, 26, 25, ... bits wide.
- */
+ * i.e. the limbs are 26, 25, 26, 25, ... bits wide. */
/* Sum two numbers: output += in */
static void fsum(limb *output, const limb *in) {
unsigned i;
for (i = 0; i < 10; i += 2) {
- output[0+i] = (output[0+i] + in[0+i]);
- output[1+i] = (output[1+i] + in[1+i]);
+ output[0+i] = output[0+i] + in[0+i];
+ output[1+i] = output[1+i] + in[1+i];
}
}
/* Find the difference of two numbers: output = in - output
- * (note the order of the arguments!)
- */
+ * (note the order of the arguments!). */
static void fdifference(limb *output, const limb *in) {
unsigned i;
for (i = 0; i < 10; ++i) {
- output[i] = (in[i] - output[i]);
+ output[i] = in[i] - output[i];
}
}
@@ -95,7 +92,8 @@ static void fscalar_product(limb *output, const limb *in, const limb scalar) {
*
* output must be distinct to both inputs. The inputs are reduced coefficient
* form, the output is not.
- */
+ *
+ * output[x] <= 14 * the largest product of the input limbs. */
static void fproduct(limb *output, const limb *in2, const limb *in) {
output[0] = ((limb) ((s32) in2[0])) * ((s32) in[0]);
output[1] = ((limb) ((s32) in2[0])) * ((s32) in[1]) +
@@ -199,9 +197,15 @@ static void fproduct(limb *output, const limb *in2, const limb *in) {
output[18] = 2 * ((limb) ((s32) in2[9])) * ((s32) in[9]);
}
-/* Reduce a long form to a short form by taking the input mod 2^255 - 19. */
+/* Reduce a long form to a short form by taking the input mod 2^255 - 19.
+ *
+ * On entry: |output[i]| < 14*2^54
+ * On exit: |output[0..8]| < 280*2^54 */
static void freduce_degree(limb *output) {
- /* Each of these shifts and adds ends up multiplying the value by 19. */
+ /* Each of these shifts and adds ends up multiplying the value by 19.
+ *
+ * For output[0..8], the absolute entry value is < 14*2^54 and we add, at
+ * most, 19*14*2^54 thus, on exit, |output[0..8]| < 280*2^54. */
output[8] += output[18] << 4;
output[8] += output[18] << 1;
output[8] += output[18];
@@ -235,11 +239,13 @@ static void freduce_degree(limb *output) {
#error "This code only works on a two's complement system"
#endif
-/* return v / 2^26, using only shifts and adds. */
+/* return v / 2^26, using only shifts and adds.
+ *
+ * On entry: v can take any value. */
static inline limb
div_by_2_26(const limb v)
{
- /* High word of v; no shift needed*/
+ /* High word of v; no shift needed. */
const uint32_t highword = (uint32_t) (((uint64_t) v) >> 32);
/* Set to all 1s if v was negative; else set to 0s. */
const int32_t sign = ((int32_t) highword) >> 31;
@@ -249,7 +255,9 @@ div_by_2_26(const limb v)
return (v + roundoff) >> 26;
}
-/* return v / (2^25), using only shifts and adds. */
+/* return v / (2^25), using only shifts and adds.
+ *
+ * On entry: v can take any value. */
static inline limb
div_by_2_25(const limb v)
{
@@ -263,17 +271,21 @@ div_by_2_25(const limb v)
return (v + roundoff) >> 25;
}
+#if 0
+/* return v / (2^25), using only shifts and adds.
+ *
+ * On entry: v can take any value. */
static inline s32
div_s32_by_2_25(const s32 v)
{
const s32 roundoff = ((uint32_t)(v >> 31)) >> 7;
return (v + roundoff) >> 25;
}
+#endif
/* Reduce all coefficients of the short form input so that |x| < 2^26.
*
- * On entry: |output[i]| < 2^62
- */
+ * On entry: |output[i]| < 280*2^54 */
static void freduce_coefficients(limb *output) {
unsigned i;
@@ -281,56 +293,65 @@ static void freduce_coefficients(limb *output) {
for (i = 0; i < 10; i += 2) {
limb over = div_by_2_26(output[i]);
+ /* The entry condition (that |output[i]| < 280*2^54) means that over is, at
+ * most, 280*2^28 in the first iteration of this loop. This is added to the
+ * next limb and we can approximate the resulting bound of that limb by
+ * 281*2^54. */
output[i] -= over << 26;
output[i+1] += over;
+ /* For the first iteration, |output[i+1]| < 281*2^54, thus |over| <
+ * 281*2^29. When this is added to the next limb, the resulting bound can
+ * be approximated as 281*2^54.
+ *
+ * For subsequent iterations of the loop, 281*2^54 remains a conservative
+ * bound and no overflow occurs. */
over = div_by_2_25(output[i+1]);
output[i+1] -= over << 25;
output[i+2] += over;
}
- /* Now |output[10]| < 2 ^ 38 and all other coefficients are reduced. */
+ /* Now |output[10]| < 281*2^29 and all other coefficients are reduced. */
output[0] += output[10] << 4;
output[0] += output[10] << 1;
output[0] += output[10];
output[10] = 0;
- /* Now output[1..9] are reduced, and |output[0]| < 2^26 + 19 * 2^38
- * So |over| will be no more than 77825 */
+ /* Now output[1..9] are reduced, and |output[0]| < 2^26 + 19*281*2^29
+ * So |over| will be no more than 2^16. */
{
limb over = div_by_2_26(output[0]);
output[0] -= over << 26;
output[1] += over;
}
- /* Now output[0,2..9] are reduced, and |output[1]| < 2^25 + 77825
- * So |over| will be no more than 1. */
- {
- /* output[1] fits in 32 bits, so we can use div_s32_by_2_25 here. */
- s32 over32 = div_s32_by_2_25((s32) output[1]);
- output[1] -= over32 << 25;
- output[2] += over32;
- }
-
- /* Finally, output[0,1,3..9] are reduced, and output[2] is "nearly reduced":
- * we have |output[2]| <= 2^26. This is good enough for all of our math,
- * but it will require an extra freduce_coefficients before fcontract. */
+ /* Now output[0,2..9] are reduced, and |output[1]| < 2^25 + 2^16 < 2^26. The
+ * bound on |output[1]| is sufficient to meet our needs. */
}
/* A helpful wrapper around fproduct: output = in * in2.
*
- * output must be distinct to both inputs. The output is reduced degree and
- * reduced coefficient.
- */
+ * On entry: |in[i]| < 2^27 and |in2[i]| < 2^27.
+ *
+ * output must be distinct to both inputs. The output is reduced degree
+ * (indeed, one need only provide storage for 10 limbs) and |output[i]| < 2^26. */
static void
fmul(limb *output, const limb *in, const limb *in2) {
limb t[19];
fproduct(t, in, in2);
+ /* |t[i]| < 14*2^54 */
freduce_degree(t);
freduce_coefficients(t);
+ /* |t[i]| < 2^26 */
memcpy(output, t, sizeof(limb) * 10);
}
+/* Square a number: output = in**2
+ *
+ * output must be distinct from the input. The inputs are reduced coefficient
+ * form, the output is not.
+ *
+ * output[x] <= 14 * the largest product of the input limbs. */
static void fsquare_inner(limb *output, const limb *in) {
output[0] = ((limb) ((s32) in[0])) * ((s32) in[0]);
output[1] = 2 * ((limb) ((s32) in[0])) * ((s32) in[1]);
@@ -389,12 +410,23 @@ static void fsquare_inner(limb *output, const limb *in) {
output[18] = 2 * ((limb) ((s32) in[9])) * ((s32) in[9]);
}
+/* fsquare sets output = in^2.
+ *
+ * On entry: The |in| argument is in reduced coefficients form and |in[i]| <
+ * 2^27.
+ *
+ * On exit: The |output| argument is in reduced coefficients form (indeed, one
+ * need only provide storage for 10 limbs) and |out[i]| < 2^26. */
static void
fsquare(limb *output, const limb *in) {
limb t[19];
fsquare_inner(t, in);
+ /* |t[i]| < 14*2^54 because the largest product of two limbs will be <
+ * 2^(27+27) and fsquare_inner adds together, at most, 14 of those
+ * products. */
freduce_degree(t);
freduce_coefficients(t);
+ /* |t[i]| < 2^26 */
memcpy(output, t, sizeof(limb) * 10);
}
@@ -423,60 +455,143 @@ fexpand(limb *output, const u8 *input) {
#error "This code only works when >> does sign-extension on negative numbers"
#endif
+/* s32_eq returns 0xffffffff iff a == b and zero otherwise. */
+static s32 s32_eq(s32 a, s32 b) {
+ a = ~(a ^ b);
+ a &= a << 16;
+ a &= a << 8;
+ a &= a << 4;
+ a &= a << 2;
+ a &= a << 1;
+ return a >> 31;
+}
+
+/* s32_gte returns 0xffffffff if a >= b and zero otherwise, where a and b are
+ * both non-negative. */
+static s32 s32_gte(s32 a, s32 b) {
+ a -= b;
+ /* a >= 0 iff a >= b. */
+ return ~(a >> 31);
+}
+
/* Take a fully reduced polynomial form number and contract it into a
- * little-endian, 32-byte array
- */
+ * little-endian, 32-byte array.
+ *
+ * On entry: |input_limbs[i]| < 2^26 */
static void
-fcontract(u8 *output, limb *input) {
+fcontract(u8 *output, limb *input_limbs) {
int i;
int j;
+ s32 input[10];
+ s32 mask;
+
+ /* |input_limbs[i]| < 2^26, so it's valid to convert to an s32. */
+ for (i = 0; i < 10; i++) {
+ input[i] = (s32) input_limbs[i];
+ }
for (j = 0; j < 2; ++j) {
for (i = 0; i < 9; ++i) {
if ((i & 1) == 1) {
- /* This calculation is a time-invariant way to make input[i] positive
- by borrowing from the next-larger limb.
- */
- const s32 mask = (s32)(input[i]) >> 31;
- const s32 carry = -(((s32)(input[i]) & mask) >> 25);
- input[i] = (s32)(input[i]) + (carry << 25);
- input[i+1] = (s32)(input[i+1]) - carry;
+ /* This calculation is a time-invariant way to make input[i]
+ * non-negative by borrowing from the next-larger limb. */
+ const s32 mask = input[i] >> 31;
+ const s32 carry = -((input[i] & mask) >> 25);
+ input[i] = input[i] + (carry << 25);
+ input[i+1] = input[i+1] - carry;
} else {
- const s32 mask = (s32)(input[i]) >> 31;
- const s32 carry = -(((s32)(input[i]) & mask) >> 26);
- input[i] = (s32)(input[i]) + (carry << 26);
- input[i+1] = (s32)(input[i+1]) - carry;
+ const s32 mask = input[i] >> 31;
+ const s32 carry = -((input[i] & mask) >> 26);
+ input[i] = input[i] + (carry << 26);
+ input[i+1] = input[i+1] - carry;
}
}
+
+ /* There's no greater limb for input[9] to borrow from, but we can multiply
+ * by 19 and borrow from input[0], which is valid mod 2^255-19. */
{
- const s32 mask = (s32)(input[9]) >> 31;
- const s32 carry = -(((s32)(input[9]) & mask) >> 25);
- input[9] = (s32)(input[9]) + (carry << 25);
- input[0] = (s32)(input[0]) - (carry * 19);
+ const s32 mask = input[9] >> 31;
+ const s32 carry = -((input[9] & mask) >> 25);
+ input[9] = input[9] + (carry << 25);
+ input[0] = input[0] - (carry * 19);
}
+
+ /* After the first iteration, input[1..9] are non-negative and fit within
+ * 25 or 26 bits, depending on position. However, input[0] may be
+ * negative. */
}
/* The first borrow-propagation pass above ended with every limb
except (possibly) input[0] non-negative.
- Since each input limb except input[0] is decreased by at most 1
- by a borrow-propagation pass, the second borrow-propagation pass
- could only have wrapped around to decrease input[0] again if the
- first pass left input[0] negative *and* input[1] through input[9]
- were all zero. In that case, input[1] is now 2^25 - 1, and this
- last borrow-propagation step will leave input[1] non-negative.
- */
+ If input[0] was negative after the first pass, then it was because of a
+ carry from input[9]. On entry, input[9] < 2^26 so the carry was, at most,
+ one, since (2**26-1) >> 25 = 1. Thus input[0] >= -19.
+
+ In the second pass, each limb is decreased by at most one. Thus the second
+ borrow-propagation pass could only have wrapped around to decrease
+ input[0] again if the first pass left input[0] negative *and* input[1]
+ through input[9] were all zero. In that case, input[1] is now 2^25 - 1,
+ and this last borrow-propagation step will leave input[1] non-negative. */
{
- const s32 mask = (s32)(input[0]) >> 31;
- const s32 carry = -(((s32)(input[0]) & mask) >> 26);
- input[0] = (s32)(input[0]) + (carry << 26);
- input[1] = (s32)(input[1]) - carry;
+ const s32 mask = input[0] >> 31;
+ const s32 carry = -((input[0] & mask) >> 26);
+ input[0] = input[0] + (carry << 26);
+ input[1] = input[1] - carry;
}
- /* Both passes through the above loop, plus the last 0-to-1 step, are
- necessary: if input[9] is -1 and input[0] through input[8] are 0,
- negative values will remain in the array until the end.
- */
+ /* All input[i] are now non-negative. However, there might be values between
+ * 2^25 and 2^26 in a limb which is, nominally, 25 bits wide. */
+ for (j = 0; j < 2; j++) {
+ for (i = 0; i < 9; i++) {
+ if ((i & 1) == 1) {
+ const s32 carry = input[i] >> 25;
+ input[i] &= 0x1ffffff;
+ input[i+1] += carry;
+ } else {
+ const s32 carry = input[i] >> 26;
+ input[i] &= 0x3ffffff;
+ input[i+1] += carry;
+ }
+ }
+
+ {
+ const s32 carry = input[9] >> 25;
+ input[9] &= 0x1ffffff;
+ input[0] += 19*carry;
+ }
+ }
+
+ /* If the first carry-chain pass, just above, ended up with a carry from
+ * input[9], and that caused input[0] to be out-of-bounds, then input[0] was
+ * < 2^26 + 2*19, because the carry was, at most, two.
+ *
+ * If the second pass carried from input[9] again then input[0] is < 2*19 and
+ * the input[9] -> input[0] carry didn't push input[0] out of bounds. */
+
+ /* It still remains the case that input might be between 2^255-19 and 2^255.
+ * In this case, input[1..9] must take their maximum value and input[0] must
+ * be >= (2^255-19) & 0x3ffffff, which is 0x3ffffed. */
+ mask = s32_gte(input[0], 0x3ffffed);
+ for (i = 1; i < 10; i++) {
+ if ((i & 1) == 1) {
+ mask &= s32_eq(input[i], 0x1ffffff);
+ } else {
+ mask &= s32_eq(input[i], 0x3ffffff);
+ }
+ }
+
+ /* mask is either 0xffffffff (if input >= 2^255-19) and zero otherwise. Thus
+ * this conditionally subtracts 2^255-19. */
+ input[0] -= mask & 0x3ffffed;
+
+ for (i = 1; i < 10; i++) {
+ if ((i & 1) == 1) {
+ input[i] -= mask & 0x1ffffff;
+ } else {
+ input[i] -= mask & 0x3ffffff;
+ }
+ }
input[1] <<= 2;
input[2] <<= 3;
@@ -514,7 +629,9 @@ fcontract(u8 *output, limb *input) {
* x z: short form, destroyed
* xprime zprime: short form, destroyed
* qmqp: short form, preserved
- */
+ *
+ * On entry and exit, the absolute value of the limbs of all inputs and outputs
+ * are < 2^26. */
static void fmonty(limb *x2, limb *z2, /* output 2Q */
limb *x3, limb *z3, /* output Q + Q' */
limb *x, limb *z, /* input Q */
@@ -525,43 +642,69 @@ static void fmonty(limb *x2, limb *z2, /* output 2Q */
memcpy(origx, x, 10 * sizeof(limb));
fsum(x, z);
- fdifference(z, origx); // does x - z
+ /* |x[i]| < 2^27 */
+ fdifference(z, origx); /* does x - z */
+ /* |z[i]| < 2^27 */
memcpy(origxprime, xprime, sizeof(limb) * 10);
fsum(xprime, zprime);
+ /* |xprime[i]| < 2^27 */
fdifference(zprime, origxprime);
+ /* |zprime[i]| < 2^27 */
fproduct(xxprime, xprime, z);
+ /* |xxprime[i]| < 14*2^54: the largest product of two limbs will be <
+ * 2^(27+27) and fproduct adds together, at most, 14 of those products.
+ * (Approximating that to 2^58 doesn't work out.) */
fproduct(zzprime, x, zprime);
+ /* |zzprime[i]| < 14*2^54 */
freduce_degree(xxprime);
freduce_coefficients(xxprime);
+ /* |xxprime[i]| < 2^26 */
freduce_degree(zzprime);
freduce_coefficients(zzprime);
+ /* |zzprime[i]| < 2^26 */
memcpy(origxprime, xxprime, sizeof(limb) * 10);
fsum(xxprime, zzprime);
+ /* |xxprime[i]| < 2^27 */
fdifference(zzprime, origxprime);
+ /* |zzprime[i]| < 2^27 */
fsquare(xxxprime, xxprime);
+ /* |xxxprime[i]| < 2^26 */
fsquare(zzzprime, zzprime);
+ /* |zzzprime[i]| < 2^26 */
fproduct(zzprime, zzzprime, qmqp);
+ /* |zzprime[i]| < 14*2^52 */
freduce_degree(zzprime);
freduce_coefficients(zzprime);
+ /* |zzprime[i]| < 2^26 */
memcpy(x3, xxxprime, sizeof(limb) * 10);
memcpy(z3, zzprime, sizeof(limb) * 10);
fsquare(xx, x);
+ /* |xx[i]| < 2^26 */
fsquare(zz, z);
+ /* |zz[i]| < 2^26 */
fproduct(x2, xx, zz);
+ /* |x2[i]| < 14*2^52 */
freduce_degree(x2);
freduce_coefficients(x2);
+ /* |x2[i]| < 2^26 */
fdifference(zz, xx); // does zz = xx - zz
+ /* |zz[i]| < 2^27 */
memset(zzz + 10, 0, sizeof(limb) * 9);
fscalar_product(zzz, zz, 121665);
+ /* |zzz[i]| < 2^(27+17) */
/* No need to call freduce_degree here:
fscalar_product doesn't increase the degree of its input. */
freduce_coefficients(zzz);
+ /* |zzz[i]| < 2^26 */
fsum(zzz, xx);
+ /* |zzz[i]| < 2^27 */
fproduct(z2, zz, zzz);
+ /* |z2[i]| < 14*2^(26+27) */
freduce_degree(z2);
freduce_coefficients(z2);
+ /* |z2|i| < 2^26 */
}
/* Conditionally swap two reduced-form limb arrays if 'iswap' is 1, but leave
@@ -572,8 +715,7 @@ static void fmonty(limb *x2, limb *z2, /* output 2Q */
* wrong results. Also, the two limb arrays must be in reduced-coefficient,
* reduced-degree form: the values in a[10..19] or b[10..19] aren't swapped,
* and all all values in a[0..9],b[0..9] must have magnitude less than
- * INT32_MAX.
- */
+ * INT32_MAX. */
static void
swap_conditional(limb a[19], limb b[19], limb iswap) {
unsigned i;
@@ -590,8 +732,7 @@ swap_conditional(limb a[19], limb b[19], limb iswap) {
*
* resultx/resultz: the x coordinate of the resulting curve point (short form)
* n: a little endian, 32-byte number
- * q: a point of the curve (short form)
- */
+ * q: a point of the curve (short form) */
static void
cmult(limb *resultx, limb *resultz, const u8 *n, const limb *q) {
limb a[19] = {0}, b[19] = {1}, c[19] = {1}, d[19] = {0};
@@ -709,7 +850,7 @@ crecip(limb *out, const limb *z) {
/* 2^255 - 21 */ fmul(out,t1,z11);
}
-int curve25519_donna(u8 *, const u8 *, const u8 *);
+int curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint);
int
curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint) {
@@ -726,7 +867,6 @@ curve25519_donna(u8 *mypublic, const u8 *secret, const u8 *basepoint) {
cmult(x, z, e, bp);
crecip(zmone, z);
fmul(z, x, zmone);
- freduce_coefficients(z);
fcontract(mypublic, z);
return 0;
}
diff --git a/src/ext/ed25519/ref10/Makefile b/src/ext/ed25519/ref10/Makefile
new file mode 100644
index 0000000000..9b0ba7ad45
--- /dev/null
+++ b/src/ext/ed25519/ref10/Makefile
@@ -0,0 +1,41 @@
+all: d.h d2.h sqrtm1.h base.h base2.h \
+ge_add.h ge_sub.h \
+ge_madd.h ge_msub.h \
+ge_p2_dbl.h \
+pow225521.h pow22523.h
+
+d.h: d.py
+ python d.py > d.h
+
+d2.h: d2.py
+ python d2.py > d2.h
+
+sqrtm1.h: sqrtm1.py
+ python sqrtm1.py > sqrtm1.h
+
+base.h: base.py
+ python base.py > base.h
+
+base2.h: base2.py
+ python base2.py > base2.h
+
+ge_add.h: ge_add.q q2h.sh
+ ./q2h.sh < ge_add.q > ge_add.h
+
+ge_sub.h: ge_sub.q q2h.sh
+ ./q2h.sh < ge_sub.q > ge_sub.h
+
+ge_madd.h: ge_madd.q q2h.sh
+ ./q2h.sh < ge_madd.q > ge_madd.h
+
+ge_msub.h: ge_msub.q q2h.sh
+ ./q2h.sh < ge_msub.q > ge_msub.h
+
+ge_p2_dbl.h: ge_p2_dbl.q q2h.sh
+ ./q2h.sh < ge_p2_dbl.q > ge_p2_dbl.h
+
+pow22523.h: pow22523.q q2h.sh
+ ./q2h.sh < pow22523.q > pow22523.h
+
+pow225521.h: pow225521.q q2h.sh
+ ./q2h.sh < pow225521.q > pow225521.h
diff --git a/src/ext/ed25519/ref10/README.tor b/src/ext/ed25519/ref10/README.tor
new file mode 100644
index 0000000000..38ed97ba05
--- /dev/null
+++ b/src/ext/ed25519/ref10/README.tor
@@ -0,0 +1,23 @@
+
+We've made the following changes to the stock ed25519_ref10 from
+supercop-20140622:
+
+ * We added the necessary glue to provide integers of fixed bit
+ sizes, SHA512, and to compile without warnings everywhere we need
+ to build.
+
+ * Secret keys are stored in expanded format. There are functions
+ to expand them from the 32-byte seed.
+
+ * Signatures are made and processed detached from the messages that
+ they sign. (In other words, we support "make signature" and
+ "check signature", not "create signed message" and "check and
+ unpack signed message".)
+
+ * There's an implementation of 'convert a curve25519 key to an
+ ed25519 key' so we can do cross-certification with curve25519 keys.
+ (keyconv.c)
+
+ * There's an implementation of multiplicative key blinding so we
+ can use it for next-gen hidden srevice descriptors. (blinding.c)
+
diff --git a/src/ext/ed25519/ref10/api.h b/src/ext/ed25519/ref10/api.h
new file mode 100644
index 0000000000..d88dae0c32
--- /dev/null
+++ b/src/ext/ed25519/ref10/api.h
@@ -0,0 +1,4 @@
+#define CRYPTO_SECRETKEYBYTES 64
+#define CRYPTO_PUBLICKEYBYTES 32
+#define CRYPTO_BYTES 64
+#define CRYPTO_DETERMINISTIC 1
diff --git a/src/ext/ed25519/ref10/base.h b/src/ext/ed25519/ref10/base.h
new file mode 100644
index 0000000000..573bd8a05c
--- /dev/null
+++ b/src/ext/ed25519/ref10/base.h
@@ -0,0 +1,1344 @@
+{
+ {
+ { 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
+ { -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
+ { -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
+ },
+ {
+ { -12815894,-12976347,-21581243,11784320,-25355658,-2750717,-11717903,-3814571,-358445,-10211303 },
+ { -21703237,6903825,27185491,6451973,-29577724,-9554005,-15616551,11189268,-26829678,-5319081 },
+ { 26966642,11152617,32442495,15396054,14353839,-12752335,-3128826,-9541118,-15472047,-4166697 },
+ },
+ {
+ { 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
+ { 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
+ { 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
+ },
+ {
+ { -17036878,13921892,10945806,-6033431,27105052,-16084379,-28926210,15006023,3284568,-6276540 },
+ { 23599295,-8306047,-11193664,-7687416,13236774,10506355,7464579,9656445,13059162,10374397 },
+ { 7798556,16710257,3033922,2874086,28997861,2835604,32406664,-3839045,-641708,-101325 },
+ },
+ {
+ { 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
+ { 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
+ { 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
+ },
+ {
+ { -15371964,-12862754,32573250,4720197,-26436522,5875511,-19188627,-15224819,-9818940,-12085777 },
+ { -8549212,109983,15149363,2178705,22900618,4543417,3044240,-15689887,1762328,14866737 },
+ { -18199695,-15951423,-10473290,1707278,-17185920,3916101,-28236412,3959421,27914454,4383652 },
+ },
+ {
+ { 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
+ { -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
+ { 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
+ },
+ {
+ { 14499471,-2729599,-33191113,-4254652,28494862,14271267,30290735,10876454,-33154098,2381726 },
+ { -7195431,-2655363,-14730155,462251,-27724326,3941372,-6236617,3696005,-32300832,15351955 },
+ { 27431194,8222322,16448760,-3907995,-18707002,11938355,-32961401,-2970515,29551813,10109425 },
+ },
+},
+{
+ {
+ { -13657040,-13155431,-31283750,11777098,21447386,6519384,-2378284,-1627556,10092783,-4764171 },
+ { 27939166,14210322,4677035,16277044,-22964462,-12398139,-32508754,12005538,-17810127,12803510 },
+ { 17228999,-15661624,-1233527,300140,-1224870,-11714777,30364213,-9038194,18016357,4397660 },
+ },
+ {
+ { -10958843,-7690207,4776341,-14954238,27850028,-15602212,-26619106,14544525,-17477504,982639 },
+ { 29253598,15796703,-2863982,-9908884,10057023,3163536,7332899,-4120128,-21047696,9934963 },
+ { 5793303,16271923,-24131614,-10116404,29188560,1206517,-14747930,4559895,-30123922,-10897950 },
+ },
+ {
+ { -27643952,-11493006,16282657,-11036493,28414021,-15012264,24191034,4541697,-13338309,5500568 },
+ { 12650548,-1497113,9052871,11355358,-17680037,-8400164,-17430592,12264343,10874051,13524335 },
+ { 25556948,-3045990,714651,2510400,23394682,-10415330,33119038,5080568,-22528059,5376628 },
+ },
+ {
+ { -26088264,-4011052,-17013699,-3537628,-6726793,1920897,-22321305,-9447443,4535768,1569007 },
+ { -2255422,14606630,-21692440,-8039818,28430649,8775819,-30494562,3044290,31848280,12543772 },
+ { -22028579,2943893,-31857513,6777306,13784462,-4292203,-27377195,-2062731,7718482,14474653 },
+ },
+ {
+ { 2385315,2454213,-22631320,46603,-4437935,-15680415,656965,-7236665,24316168,-5253567 },
+ { 13741529,10911568,-33233417,-8603737,-20177830,-1033297,33040651,-13424532,-20729456,8321686 },
+ { 21060490,-2212744,15712757,-4336099,1639040,10656336,23845965,-11874838,-9984458,608372 },
+ },
+ {
+ { -13672732,-15087586,-10889693,-7557059,-6036909,11305547,1123968,-6780577,27229399,23887 },
+ { -23244140,-294205,-11744728,14712571,-29465699,-2029617,12797024,-6440308,-1633405,16678954 },
+ { -29500620,4770662,-16054387,14001338,7830047,9564805,-1508144,-4795045,-17169265,4904953 },
+ },
+ {
+ { 24059557,14617003,19037157,-15039908,19766093,-14906429,5169211,16191880,2128236,-4326833 },
+ { -16981152,4124966,-8540610,-10653797,30336522,-14105247,-29806336,916033,-6882542,-2986532 },
+ { -22630907,12419372,-7134229,-7473371,-16478904,16739175,285431,2763829,15736322,4143876 },
+ },
+ {
+ { 2379352,11839345,-4110402,-5988665,11274298,794957,212801,-14594663,23527084,-16458268 },
+ { 33431127,-11130478,-17838966,-15626900,8909499,8376530,-32625340,4087881,-15188911,-14416214 },
+ { 1767683,7197987,-13205226,-2022635,-13091350,448826,5799055,4357868,-4774191,-16323038 },
+ },
+},
+{
+ {
+ { 6721966,13833823,-23523388,-1551314,26354293,-11863321,23365147,-3949732,7390890,2759800 },
+ { 4409041,2052381,23373853,10530217,7676779,-12885954,21302353,-4264057,1244380,-12919645 },
+ { -4421239,7169619,4982368,-2957590,30256825,-2777540,14086413,9208236,15886429,16489664 },
+ },
+ {
+ { 1996075,10375649,14346367,13311202,-6874135,-16438411,-13693198,398369,-30606455,-712933 },
+ { -25307465,9795880,-2777414,14878809,-33531835,14780363,13348553,12076947,-30836462,5113182 },
+ { -17770784,11797796,31950843,13929123,-25888302,12288344,-30341101,-7336386,13847711,5387222 },
+ },
+ {
+ { -18582163,-3416217,17824843,-2340966,22744343,-10442611,8763061,3617786,-19600662,10370991 },
+ { 20246567,-14369378,22358229,-543712,18507283,-10413996,14554437,-8746092,32232924,16763880 },
+ { 9648505,10094563,26416693,14745928,-30374318,-6472621,11094161,15689506,3140038,-16510092 },
+ },
+ {
+ { -16160072,5472695,31895588,4744994,8823515,10365685,-27224800,9448613,-28774454,366295 },
+ { 19153450,11523972,-11096490,-6503142,-24647631,5420647,28344573,8041113,719605,11671788 },
+ { 8678025,2694440,-6808014,2517372,4964326,11152271,-15432916,-15266516,27000813,-10195553 },
+ },
+ {
+ { -15157904,7134312,8639287,-2814877,-7235688,10421742,564065,5336097,6750977,-14521026 },
+ { 11836410,-3979488,26297894,16080799,23455045,15735944,1695823,-8819122,8169720,16220347 },
+ { -18115838,8653647,17578566,-6092619,-8025777,-16012763,-11144307,-2627664,-5990708,-14166033 },
+ },
+ {
+ { -23308498,-10968312,15213228,-10081214,-30853605,-11050004,27884329,2847284,2655861,1738395 },
+ { -27537433,-14253021,-25336301,-8002780,-9370762,8129821,21651608,-3239336,-19087449,-11005278 },
+ { 1533110,3437855,23735889,459276,29970501,11335377,26030092,5821408,10478196,8544890 },
+ },
+ {
+ { 32173121,-16129311,24896207,3921497,22579056,-3410854,19270449,12217473,17789017,-3395995 },
+ { -30552961,-2228401,-15578829,-10147201,13243889,517024,15479401,-3853233,30460520,1052596 },
+ { -11614875,13323618,32618793,8175907,-15230173,12596687,27491595,-4612359,3179268,-9478891 },
+ },
+ {
+ { 31947069,-14366651,-4640583,-15339921,-15125977,-6039709,-14756777,-16411740,19072640,-9511060 },
+ { 11685058,11822410,3158003,-13952594,33402194,-4165066,5977896,-5215017,473099,5040608 },
+ { -20290863,8198642,-27410132,11602123,1290375,-2799760,28326862,1721092,-19558642,-3131606 },
+ },
+},
+{
+ {
+ { 7881532,10687937,7578723,7738378,-18951012,-2553952,21820786,8076149,-27868496,11538389 },
+ { -19935666,3899861,18283497,-6801568,-15728660,-11249211,8754525,7446702,-5676054,5797016 },
+ { -11295600,-3793569,-15782110,-7964573,12708869,-8456199,2014099,-9050574,-2369172,-5877341 },
+ },
+ {
+ { -22472376,-11568741,-27682020,1146375,18956691,16640559,1192730,-3714199,15123619,10811505 },
+ { 14352098,-3419715,-18942044,10822655,32750596,4699007,-70363,15776356,-28886779,-11974553 },
+ { -28241164,-8072475,-4978962,-5315317,29416931,1847569,-20654173,-16484855,4714547,-9600655 },
+ },
+ {
+ { 15200332,8368572,19679101,15970074,-31872674,1959451,24611599,-4543832,-11745876,12340220 },
+ { 12876937,-10480056,33134381,6590940,-6307776,14872440,9613953,8241152,15370987,9608631 },
+ { -4143277,-12014408,8446281,-391603,4407738,13629032,-7724868,15866074,-28210621,-8814099 },
+ },
+ {
+ { 26660628,-15677655,8393734,358047,-7401291,992988,-23904233,858697,20571223,8420556 },
+ { 14620715,13067227,-15447274,8264467,14106269,15080814,33531827,12516406,-21574435,-12476749 },
+ { 236881,10476226,57258,-14677024,6472998,2466984,17258519,7256740,8791136,15069930 },
+ },
+ {
+ { 1276410,-9371918,22949635,-16322807,-23493039,-5702186,14711875,4874229,-30663140,-2331391 },
+ { 5855666,4990204,-13711848,7294284,-7804282,1924647,-1423175,-7912378,-33069337,9234253 },
+ { 20590503,-9018988,31529744,-7352666,-2706834,10650548,31559055,-11609587,18979186,13396066 },
+ },
+ {
+ { 24474287,4968103,22267082,4407354,24063882,-8325180,-18816887,13594782,33514650,7021958 },
+ { -11566906,-6565505,-21365085,15928892,-26158305,4315421,-25948728,-3916677,-21480480,12868082 },
+ { -28635013,13504661,19988037,-2132761,21078225,6443208,-21446107,2244500,-12455797,-8089383 },
+ },
+ {
+ { -30595528,13793479,-5852820,319136,-25723172,-6263899,33086546,8957937,-15233648,5540521 },
+ { -11630176,-11503902,-8119500,-7643073,2620056,1022908,-23710744,-1568984,-16128528,-14962807 },
+ { 23152971,775386,27395463,14006635,-9701118,4649512,1689819,892185,-11513277,-15205948 },
+ },
+ {
+ { 9770129,9586738,26496094,4324120,1556511,-3550024,27453819,4763127,-19179614,5867134 },
+ { -32765025,1927590,31726409,-4753295,23962434,-16019500,27846559,5931263,-29749703,-16108455 },
+ { 27461885,-2977536,22380810,1815854,-23033753,-3031938,7283490,-15148073,-19526700,7734629 },
+ },
+},
+{
+ {
+ { -8010264,-9590817,-11120403,6196038,29344158,-13430885,7585295,-3176626,18549497,15302069 },
+ { -32658337,-6171222,-7672793,-11051681,6258878,13504381,10458790,-6418461,-8872242,8424746 },
+ { 24687205,8613276,-30667046,-3233545,1863892,-1830544,19206234,7134917,-11284482,-828919 },
+ },
+ {
+ { 11334899,-9218022,8025293,12707519,17523892,-10476071,10243738,-14685461,-5066034,16498837 },
+ { 8911542,6887158,-9584260,-6958590,11145641,-9543680,17303925,-14124238,6536641,10543906 },
+ { -28946384,15479763,-17466835,568876,-1497683,11223454,-2669190,-16625574,-27235709,8876771 },
+ },
+ {
+ { -25742899,-12566864,-15649966,-846607,-33026686,-796288,-33481822,15824474,-604426,-9039817 },
+ { 10330056,70051,7957388,-9002667,9764902,15609756,27698697,-4890037,1657394,3084098 },
+ { 10477963,-7470260,12119566,-13250805,29016247,-5365589,31280319,14396151,-30233575,15272409 },
+ },
+ {
+ { -12288309,3169463,28813183,16658753,25116432,-5630466,-25173957,-12636138,-25014757,1950504 },
+ { -26180358,9489187,11053416,-14746161,-31053720,5825630,-8384306,-8767532,15341279,8373727 },
+ { 28685821,7759505,-14378516,-12002860,-31971820,4079242,298136,-10232602,-2878207,15190420 },
+ },
+ {
+ { -32932876,13806336,-14337485,-15794431,-24004620,10940928,8669718,2742393,-26033313,-6875003 },
+ { -1580388,-11729417,-25979658,-11445023,-17411874,-10912854,9291594,-16247779,-12154742,6048605 },
+ { -30305315,14843444,1539301,11864366,20201677,1900163,13934231,5128323,11213262,9168384 },
+ },
+ {
+ { -26280513,11007847,19408960,-940758,-18592965,-4328580,-5088060,-11105150,20470157,-16398701 },
+ { -23136053,9282192,14855179,-15390078,-7362815,-14408560,-22783952,14461608,14042978,5230683 },
+ { 29969567,-2741594,-16711867,-8552442,9175486,-2468974,21556951,3506042,-5933891,-12449708 },
+ },
+ {
+ { -3144746,8744661,19704003,4581278,-20430686,6830683,-21284170,8971513,-28539189,15326563 },
+ { -19464629,10110288,-17262528,-3503892,-23500387,1355669,-15523050,15300988,-20514118,9168260 },
+ { -5353335,4488613,-23803248,16314347,7780487,-15638939,-28948358,9601605,33087103,-9011387 },
+ },
+ {
+ { -19443170,-15512900,-20797467,-12445323,-29824447,10229461,-27444329,-15000531,-5996870,15664672 },
+ { 23294591,-16632613,-22650781,-8470978,27844204,11461195,13099750,-2460356,18151676,13417686 },
+ { -24722913,-4176517,-31150679,5988919,-26858785,6685065,1661597,-12551441,15271676,-15452665 },
+ },
+},
+{
+ {
+ { 11433042,-13228665,8239631,-5279517,-1985436,-725718,-18698764,2167544,-6921301,-13440182 },
+ { -31436171,15575146,30436815,12192228,-22463353,9395379,-9917708,-8638997,12215110,12028277 },
+ { 14098400,6555944,23007258,5757252,-15427832,-12950502,30123440,4617780,-16900089,-655628 },
+ },
+ {
+ { -4026201,-15240835,11893168,13718664,-14809462,1847385,-15819999,10154009,23973261,-12684474 },
+ { -26531820,-3695990,-1908898,2534301,-31870557,-16550355,18341390,-11419951,32013174,-10103539 },
+ { -25479301,10876443,-11771086,-14625140,-12369567,1838104,21911214,6354752,4425632,-837822 },
+ },
+ {
+ { -10433389,-14612966,22229858,-3091047,-13191166,776729,-17415375,-12020462,4725005,14044970 },
+ { 19268650,-7304421,1555349,8692754,-21474059,-9910664,6347390,-1411784,-19522291,-16109756 },
+ { -24864089,12986008,-10898878,-5558584,-11312371,-148526,19541418,8180106,9282262,10282508 },
+ },
+ {
+ { -26205082,4428547,-8661196,-13194263,4098402,-14165257,15522535,8372215,5542595,-10702683 },
+ { -10562541,14895633,26814552,-16673850,-17480754,-2489360,-2781891,6993761,-18093885,10114655 },
+ { -20107055,-929418,31422704,10427861,-7110749,6150669,-29091755,-11529146,25953725,-106158 },
+ },
+ {
+ { -4234397,-8039292,-9119125,3046000,2101609,-12607294,19390020,6094296,-3315279,12831125 },
+ { -15998678,7578152,5310217,14408357,-33548620,-224739,31575954,6326196,7381791,-2421839 },
+ { -20902779,3296811,24736065,-16328389,18374254,7318640,6295303,8082724,-15362489,12339664 },
+ },
+ {
+ { 27724736,2291157,6088201,-14184798,1792727,5857634,13848414,15768922,25091167,14856294 },
+ { -18866652,8331043,24373479,8541013,-701998,-9269457,12927300,-12695493,-22182473,-9012899 },
+ { -11423429,-5421590,11632845,3405020,30536730,-11674039,-27260765,13866390,30146206,9142070 },
+ },
+ {
+ { 3924129,-15307516,-13817122,-10054960,12291820,-668366,-27702774,9326384,-8237858,4171294 },
+ { -15921940,16037937,6713787,16606682,-21612135,2790944,26396185,3731949,345228,-5462949 },
+ { -21327538,13448259,25284571,1143661,20614966,-8849387,2031539,-12391231,-16253183,-13582083 },
+ },
+ {
+ { 31016211,-16722429,26371392,-14451233,-5027349,14854137,17477601,3842657,28012650,-16405420 },
+ { -5075835,9368966,-8562079,-4600902,-15249953,6970560,-9189873,16292057,-8867157,3507940 },
+ { 29439664,3537914,23333589,6997794,-17555561,-11018068,-15209202,-15051267,-9164929,6580396 },
+ },
+},
+{
+ {
+ { -12185861,-7679788,16438269,10826160,-8696817,-6235611,17860444,-9273846,-2095802,9304567 },
+ { 20714564,-4336911,29088195,7406487,11426967,-5095705,14792667,-14608617,5289421,-477127 },
+ { -16665533,-10650790,-6160345,-13305760,9192020,-1802462,17271490,12349094,26939669,-3752294 },
+ },
+ {
+ { -12889898,9373458,31595848,16374215,21471720,13221525,-27283495,-12348559,-3698806,117887 },
+ { 22263325,-6560050,3984570,-11174646,-15114008,-566785,28311253,5358056,-23319780,541964 },
+ { 16259219,3261970,2309254,-15534474,-16885711,-4581916,24134070,-16705829,-13337066,-13552195 },
+ },
+ {
+ { 9378160,-13140186,-22845982,-12745264,28198281,-7244098,-2399684,-717351,690426,14876244 },
+ { 24977353,-314384,-8223969,-13465086,28432343,-1176353,-13068804,-12297348,-22380984,6618999 },
+ { -1538174,11685646,12944378,13682314,-24389511,-14413193,8044829,-13817328,32239829,-5652762 },
+ },
+ {
+ { -18603066,4762990,-926250,8885304,-28412480,-3187315,9781647,-10350059,32779359,5095274 },
+ { -33008130,-5214506,-32264887,-3685216,9460461,-9327423,-24601656,14506724,21639561,-2630236 },
+ { -16400943,-13112215,25239338,15531969,3987758,-4499318,-1289502,-6863535,17874574,558605 },
+ },
+ {
+ { -13600129,10240081,9171883,16131053,-20869254,9599700,33499487,5080151,2085892,5119761 },
+ { -22205145,-2519528,-16381601,414691,-25019550,2170430,30634760,-8363614,-31999993,-5759884 },
+ { -6845704,15791202,8550074,-1312654,29928809,-12092256,27534430,-7192145,-22351378,12961482 },
+ },
+ {
+ { -24492060,-9570771,10368194,11582341,-23397293,-2245287,16533930,8206996,-30194652,-5159638 },
+ { -11121496,-3382234,2307366,6362031,-135455,8868177,-16835630,7031275,7589640,8945490 },
+ { -32152748,8917967,6661220,-11677616,-1192060,-15793393,7251489,-11182180,24099109,-14456170 },
+ },
+ {
+ { 5019558,-7907470,4244127,-14714356,-26933272,6453165,-19118182,-13289025,-6231896,-10280736 },
+ { 10853594,10721687,26480089,5861829,-22995819,1972175,-1866647,-10557898,-3363451,-6441124 },
+ { -17002408,5906790,221599,-6563147,7828208,-13248918,24362661,-2008168,-13866408,7421392 },
+ },
+ {
+ { 8139927,-6546497,32257646,-5890546,30375719,1886181,-21175108,15441252,28826358,-4123029 },
+ { 6267086,9695052,7709135,-16603597,-32869068,-1886135,14795160,-7840124,13746021,-1742048 },
+ { 28584902,7787108,-6732942,-15050729,22846041,-7571236,-3181936,-363524,4771362,-8419958 },
+ },
+},
+{
+ {
+ { 24949256,6376279,-27466481,-8174608,-18646154,-9930606,33543569,-12141695,3569627,11342593 },
+ { 26514989,4740088,27912651,3697550,19331575,-11472339,6809886,4608608,7325975,-14801071 },
+ { -11618399,-14554430,-24321212,7655128,-1369274,5214312,-27400540,10258390,-17646694,-8186692 },
+ },
+ {
+ { 11431204,15823007,26570245,14329124,18029990,4796082,-31446179,15580664,9280358,-3973687 },
+ { -160783,-10326257,-22855316,-4304997,-20861367,-13621002,-32810901,-11181622,-15545091,4387441 },
+ { -20799378,12194512,3937617,-5805892,-27154820,9340370,-24513992,8548137,20617071,-7482001 },
+ },
+ {
+ { -938825,-3930586,-8714311,16124718,24603125,-6225393,-13775352,-11875822,24345683,10325460 },
+ { -19855277,-1568885,-22202708,8714034,14007766,6928528,16318175,-1010689,4766743,3552007 },
+ { -21751364,-16730916,1351763,-803421,-4009670,3950935,3217514,14481909,10988822,-3994762 },
+ },
+ {
+ { 15564307,-14311570,3101243,5684148,30446780,-8051356,12677127,-6505343,-8295852,13296005 },
+ { -9442290,6624296,-30298964,-11913677,-4670981,-2057379,31521204,9614054,-30000824,12074674 },
+ { 4771191,-135239,14290749,-13089852,27992298,14998318,-1413936,-1556716,29832613,-16391035 },
+ },
+ {
+ { 7064884,-7541174,-19161962,-5067537,-18891269,-2912736,25825242,5293297,-27122660,13101590 },
+ { -2298563,2439670,-7466610,1719965,-27267541,-16328445,32512469,-5317593,-30356070,-4190957 },
+ { -30006540,10162316,-33180176,3981723,-16482138,-13070044,14413974,9515896,19568978,9628812 },
+ },
+ {
+ { 33053803,199357,15894591,1583059,27380243,-4580435,-17838894,-6106839,-6291786,3437740 },
+ { -18978877,3884493,19469877,12726490,15913552,13614290,-22961733,70104,7463304,4176122 },
+ { -27124001,10659917,11482427,-16070381,12771467,-6635117,-32719404,-5322751,24216882,5944158 },
+ },
+ {
+ { 8894125,7450974,-2664149,-9765752,-28080517,-12389115,19345746,14680796,11632993,5847885 },
+ { 26942781,-2315317,9129564,-4906607,26024105,11769399,-11518837,6367194,-9727230,4782140 },
+ { 19916461,-4828410,-22910704,-11414391,25606324,-5972441,33253853,8220911,6358847,-1873857 },
+ },
+ {
+ { 801428,-2081702,16569428,11065167,29875704,96627,7908388,-4480480,-13538503,1387155 },
+ { 19646058,5720633,-11416706,12814209,11607948,12749789,14147075,15156355,-21866831,11835260 },
+ { 19299512,1155910,28703737,14890794,2925026,7269399,26121523,15467869,-26560550,5052483 },
+ },
+},
+{
+ {
+ { -3017432,10058206,1980837,3964243,22160966,12322533,-6431123,-12618185,12228557,-7003677 },
+ { 32944382,14922211,-22844894,5188528,21913450,-8719943,4001465,13238564,-6114803,8653815 },
+ { 22865569,-4652735,27603668,-12545395,14348958,8234005,24808405,5719875,28483275,2841751 },
+ },
+ {
+ { -16420968,-1113305,-327719,-12107856,21886282,-15552774,-1887966,-315658,19932058,-12739203 },
+ { -11656086,10087521,-8864888,-5536143,-19278573,-3055912,3999228,13239134,-4777469,-13910208 },
+ { 1382174,-11694719,17266790,9194690,-13324356,9720081,20403944,11284705,-14013818,3093230 },
+ },
+ {
+ { 16650921,-11037932,-1064178,1570629,-8329746,7352753,-302424,16271225,-24049421,-6691850 },
+ { -21911077,-5927941,-4611316,-5560156,-31744103,-10785293,24123614,15193618,-21652117,-16739389 },
+ { -9935934,-4289447,-25279823,4372842,2087473,10399484,31870908,14690798,17361620,11864968 },
+ },
+ {
+ { -11307610,6210372,13206574,5806320,-29017692,-13967200,-12331205,-7486601,-25578460,-16240689 },
+ { 14668462,-12270235,26039039,15305210,25515617,4542480,10453892,6577524,9145645,-6443880 },
+ { 5974874,3053895,-9433049,-10385191,-31865124,3225009,-7972642,3936128,-5652273,-3050304 },
+ },
+ {
+ { 30625386,-4729400,-25555961,-12792866,-20484575,7695099,17097188,-16303496,-27999779,1803632 },
+ { -3553091,9865099,-5228566,4272701,-5673832,-16689700,14911344,12196514,-21405489,7047412 },
+ { 20093277,9920966,-11138194,-5343857,13161587,12044805,-32856851,4124601,-32343828,-10257566 },
+ },
+ {
+ { -20788824,14084654,-13531713,7842147,19119038,-13822605,4752377,-8714640,-21679658,2288038 },
+ { -26819236,-3283715,29965059,3039786,-14473765,2540457,29457502,14625692,-24819617,12570232 },
+ { -1063558,-11551823,16920318,12494842,1278292,-5869109,-21159943,-3498680,-11974704,4724943 },
+ },
+ {
+ { 17960970,-11775534,-4140968,-9702530,-8876562,-1410617,-12907383,-8659932,-29576300,1903856 },
+ { 23134274,-14279132,-10681997,-1611936,20684485,15770816,-12989750,3190296,26955097,14109738 },
+ { 15308788,5320727,-30113809,-14318877,22902008,7767164,29425325,-11277562,31960942,11934971 },
+ },
+ {
+ { -27395711,8435796,4109644,12222639,-24627868,14818669,20638173,4875028,10491392,1379718 },
+ { -13159415,9197841,3875503,-8936108,-1383712,-5879801,33518459,16176658,21432314,12180697 },
+ { -11787308,11500838,13787581,-13832590,-22430679,10140205,1465425,12689540,-10301319,-13872883 },
+ },
+},
+{
+ {
+ { 5414091,-15386041,-21007664,9643570,12834970,1186149,-2622916,-1342231,26128231,6032912 },
+ { -26337395,-13766162,32496025,-13653919,17847801,-12669156,3604025,8316894,-25875034,-10437358 },
+ { 3296484,6223048,24680646,-12246460,-23052020,5903205,-8862297,-4639164,12376617,3188849 },
+ },
+ {
+ { 29190488,-14659046,27549113,-1183516,3520066,-10697301,32049515,-7309113,-16109234,-9852307 },
+ { -14744486,-9309156,735818,-598978,-20407687,-5057904,25246078,-15795669,18640741,-960977 },
+ { -6928835,-16430795,10361374,5642961,4910474,12345252,-31638386,-494430,10530747,1053335 },
+ },
+ {
+ { -29265967,-14186805,-13538216,-12117373,-19457059,-10655384,-31462369,-2948985,24018831,15026644 },
+ { -22592535,-3145277,-2289276,5953843,-13440189,9425631,25310643,13003497,-2314791,-15145616 },
+ { -27419985,-603321,-8043984,-1669117,-26092265,13987819,-27297622,187899,-23166419,-2531735 },
+ },
+ {
+ { -21744398,-13810475,1844840,5021428,-10434399,-15911473,9716667,16266922,-5070217,726099 },
+ { 29370922,-6053998,7334071,-15342259,9385287,2247707,-13661962,-4839461,30007388,-15823341 },
+ { -936379,16086691,23751945,-543318,-1167538,-5189036,9137109,730663,9835848,4555336 },
+ },
+ {
+ { -23376435,1410446,-22253753,-12899614,30867635,15826977,17693930,544696,-11985298,12422646 },
+ { 31117226,-12215734,-13502838,6561947,-9876867,-12757670,-5118685,-4096706,29120153,13924425 },
+ { -17400879,-14233209,19675799,-2734756,-11006962,-5858820,-9383939,-11317700,7240931,-237388 },
+ },
+ {
+ { -31361739,-11346780,-15007447,-5856218,-22453340,-12152771,1222336,4389483,3293637,-15551743 },
+ { -16684801,-14444245,11038544,11054958,-13801175,-3338533,-24319580,7733547,12796905,-6335822 },
+ { -8759414,-10817836,-25418864,10783769,-30615557,-9746811,-28253339,3647836,3222231,-11160462 },
+ },
+ {
+ { 18606113,1693100,-25448386,-15170272,4112353,10045021,23603893,-2048234,-7550776,2484985 },
+ { 9255317,-3131197,-12156162,-1004256,13098013,-9214866,16377220,-2102812,-19802075,-3034702 },
+ { -22729289,7496160,-5742199,11329249,19991973,-3347502,-31718148,9936966,-30097688,-10618797 },
+ },
+ {
+ { 21878590,-5001297,4338336,13643897,-3036865,13160960,19708896,5415497,-7360503,-4109293 },
+ { 27736861,10103576,12500508,8502413,-3413016,-9633558,10436918,-1550276,-23659143,-8132100 },
+ { 19492550,-12104365,-29681976,-852630,-3208171,12403437,30066266,8367329,13243957,8709688 },
+ },
+},
+{
+ {
+ { 12015105,2801261,28198131,10151021,24818120,-4743133,-11194191,-5645734,5150968,7274186 },
+ { 2831366,-12492146,1478975,6122054,23825128,-12733586,31097299,6083058,31021603,-9793610 },
+ { -2529932,-2229646,445613,10720828,-13849527,-11505937,-23507731,16354465,15067285,-14147707 },
+ },
+ {
+ { 7840942,14037873,-33364863,15934016,-728213,-3642706,21403988,1057586,-19379462,-12403220 },
+ { 915865,-16469274,15608285,-8789130,-24357026,6060030,-17371319,8410997,-7220461,16527025 },
+ { 32922597,-556987,20336074,-16184568,10903705,-5384487,16957574,52992,23834301,6588044 },
+ },
+ {
+ { 32752030,11232950,3381995,-8714866,22652988,-10744103,17159699,16689107,-20314580,-1305992 },
+ { -4689649,9166776,-25710296,-10847306,11576752,12733943,7924251,-2752281,1976123,-7249027 },
+ { 21251222,16309901,-2983015,-6783122,30810597,12967303,156041,-3371252,12331345,-8237197 },
+ },
+ {
+ { 8651614,-4477032,-16085636,-4996994,13002507,2950805,29054427,-5106970,10008136,-4667901 },
+ { 31486080,15114593,-14261250,12951354,14369431,-7387845,16347321,-13662089,8684155,-10532952 },
+ { 19443825,11385320,24468943,-9659068,-23919258,2187569,-26263207,-6086921,31316348,14219878 },
+ },
+ {
+ { -28594490,1193785,32245219,11392485,31092169,15722801,27146014,6992409,29126555,9207390 },
+ { 32382935,1110093,18477781,11028262,-27411763,-7548111,-4980517,10843782,-7957600,-14435730 },
+ { 2814918,7836403,27519878,-7868156,-20894015,-11553689,-21494559,8550130,28346258,1994730 },
+ },
+ {
+ { -19578299,8085545,-14000519,-3948622,2785838,-16231307,-19516951,7174894,22628102,8115180 },
+ { -30405132,955511,-11133838,-15078069,-32447087,-13278079,-25651578,3317160,-9943017,930272 },
+ { -15303681,-6833769,28856490,1357446,23421993,1057177,24091212,-1388970,-22765376,-10650715 },
+ },
+ {
+ { -22751231,-5303997,-12907607,-12768866,-15811511,-7797053,-14839018,-16554220,-1867018,8398970 },
+ { -31969310,2106403,-4736360,1362501,12813763,16200670,22981545,-6291273,18009408,-15772772 },
+ { -17220923,-9545221,-27784654,14166835,29815394,7444469,29551787,-3727419,19288549,1325865 },
+ },
+ {
+ { 15100157,-15835752,-23923978,-1005098,-26450192,15509408,12376730,-3479146,33166107,-8042750 },
+ { 20909231,13023121,-9209752,16251778,-5778415,-8094914,12412151,10018715,2213263,-13878373 },
+ { 32529814,-11074689,30361439,-16689753,-9135940,1513226,22922121,6382134,-5766928,8371348 },
+ },
+},
+{
+ {
+ { 9923462,11271500,12616794,3544722,-29998368,-1721626,12891687,-8193132,-26442943,10486144 },
+ { -22597207,-7012665,8587003,-8257861,4084309,-12970062,361726,2610596,-23921530,-11455195 },
+ { 5408411,-1136691,-4969122,10561668,24145918,14240566,31319731,-4235541,19985175,-3436086 },
+ },
+ {
+ { -13994457,16616821,14549246,3341099,32155958,13648976,-17577068,8849297,65030,8370684 },
+ { -8320926,-12049626,31204563,5839400,-20627288,-1057277,-19442942,6922164,12743482,-9800518 },
+ { -2361371,12678785,28815050,4759974,-23893047,4884717,23783145,11038569,18800704,255233 },
+ },
+ {
+ { -5269658,-1773886,13957886,7990715,23132995,728773,13393847,9066957,19258688,-14753793 },
+ { -2936654,-10827535,-10432089,14516793,-3640786,4372541,-31934921,2209390,-1524053,2055794 },
+ { 580882,16705327,5468415,-2683018,-30926419,-14696000,-7203346,-8994389,-30021019,7394435 },
+ },
+ {
+ { 23838809,1822728,-15738443,15242727,8318092,-3733104,-21672180,-3492205,-4821741,14799921 },
+ { 13345610,9759151,3371034,-16137791,16353039,8577942,31129804,13496856,-9056018,7402518 },
+ { 2286874,-4435931,-20042458,-2008336,-13696227,5038122,11006906,-15760352,8205061,1607563 },
+ },
+ {
+ { 14414086,-8002132,3331830,-3208217,22249151,-5594188,18364661,-2906958,30019587,-9029278 },
+ { -27688051,1585953,-10775053,931069,-29120221,-11002319,-14410829,12029093,9944378,8024 },
+ { 4368715,-3709630,29874200,-15022983,-20230386,-11410704,-16114594,-999085,-8142388,5640030 },
+ },
+ {
+ { 10299610,13746483,11661824,16234854,7630238,5998374,9809887,-16694564,15219798,-14327783 },
+ { 27425505,-5719081,3055006,10660664,23458024,595578,-15398605,-1173195,-18342183,9742717 },
+ { 6744077,2427284,26042789,2720740,-847906,1118974,32324614,7406442,12420155,1994844 },
+ },
+ {
+ { 14012521,-5024720,-18384453,-9578469,-26485342,-3936439,-13033478,-10909803,24319929,-6446333 },
+ { 16412690,-4507367,10772641,15929391,-17068788,-4658621,10555945,-10484049,-30102368,-4739048 },
+ { 22397382,-7767684,-9293161,-12792868,17166287,-9755136,-27333065,6199366,21880021,-12250760 },
+ },
+ {
+ { -4283307,5368523,-31117018,8163389,-30323063,3209128,16557151,8890729,8840445,4957760 },
+ { -15447727,709327,-6919446,-10870178,-29777922,6522332,-21720181,12130072,-14796503,5005757 },
+ { -2114751,-14308128,23019042,15765735,-25269683,6002752,10183197,-13239326,-16395286,-2176112 },
+ },
+},
+{
+ {
+ { -19025756,1632005,13466291,-7995100,-23640451,16573537,-32013908,-3057104,22208662,2000468 },
+ { 3065073,-1412761,-25598674,-361432,-17683065,-5703415,-8164212,11248527,-3691214,-7414184 },
+ { 10379208,-6045554,8877319,1473647,-29291284,-12507580,16690915,2553332,-3132688,16400289 },
+ },
+ {
+ { 15716668,1254266,-18472690,7446274,-8448918,6344164,-22097271,-7285580,26894937,9132066 },
+ { 24158887,12938817,11085297,-8177598,-28063478,-4457083,-30576463,64452,-6817084,-2692882 },
+ { 13488534,7794716,22236231,5989356,25426474,-12578208,2350710,-3418511,-4688006,2364226 },
+ },
+ {
+ { 16335052,9132434,25640582,6678888,1725628,8517937,-11807024,-11697457,15445875,-7798101 },
+ { 29004207,-7867081,28661402,-640412,-12794003,-7943086,31863255,-4135540,-278050,-15759279 },
+ { -6122061,-14866665,-28614905,14569919,-10857999,-3591829,10343412,-6976290,-29828287,-10815811 },
+ },
+ {
+ { 27081650,3463984,14099042,-4517604,1616303,-6205604,29542636,15372179,17293797,960709 },
+ { 20263915,11434237,-5765435,11236810,13505955,-10857102,-16111345,6493122,-19384511,7639714 },
+ { -2830798,-14839232,25403038,-8215196,-8317012,-16173699,18006287,-16043750,29994677,-15808121 },
+ },
+ {
+ { 9769828,5202651,-24157398,-13631392,-28051003,-11561624,-24613141,-13860782,-31184575,709464 },
+ { 12286395,13076066,-21775189,-1176622,-25003198,4057652,-32018128,-8890874,16102007,13205847 },
+ { 13733362,5599946,10557076,3195751,-5557991,8536970,-25540170,8525972,10151379,10394400 },
+ },
+ {
+ { 4024660,-16137551,22436262,12276534,-9099015,-2686099,19698229,11743039,-33302334,8934414 },
+ { -15879800,-4525240,-8580747,-2934061,14634845,-698278,-9449077,3137094,-11536886,11721158 },
+ { 17555939,-5013938,8268606,2331751,-22738815,9761013,9319229,8835153,-9205489,-1280045 },
+ },
+ {
+ { -461409,-7830014,20614118,16688288,-7514766,-4807119,22300304,505429,6108462,-6183415 },
+ { -5070281,12367917,-30663534,3234473,32617080,-8422642,29880583,-13483331,-26898490,-7867459 },
+ { -31975283,5726539,26934134,10237677,-3173717,-605053,24199304,3795095,7592688,-14992079 },
+ },
+ {
+ { 21594432,-14964228,17466408,-4077222,32537084,2739898,6407723,12018833,-28256052,4298412 },
+ { -20650503,-11961496,-27236275,570498,3767144,-1717540,13891942,-1569194,13717174,10805743 },
+ { -14676630,-15644296,15287174,11927123,24177847,-8175568,-796431,14860609,-26938930,-5863836 },
+ },
+},
+{
+ {
+ { 12962541,5311799,-10060768,11658280,18855286,-7954201,13286263,-12808704,-4381056,9882022 },
+ { 18512079,11319350,-20123124,15090309,18818594,5271736,-22727904,3666879,-23967430,-3299429 },
+ { -6789020,-3146043,16192429,13241070,15898607,-14206114,-10084880,-6661110,-2403099,5276065 },
+ },
+ {
+ { 30169808,-5317648,26306206,-11750859,27814964,7069267,7152851,3684982,1449224,13082861 },
+ { 10342826,3098505,2119311,193222,25702612,12233820,23697382,15056736,-21016438,-8202000 },
+ { -33150110,3261608,22745853,7948688,19370557,-15177665,-26171976,6482814,-10300080,-11060101 },
+ },
+ {
+ { 32869458,-5408545,25609743,15678670,-10687769,-15471071,26112421,2521008,-22664288,6904815 },
+ { 29506923,4457497,3377935,-9796444,-30510046,12935080,1561737,3841096,-29003639,-6657642 },
+ { 10340844,-6630377,-18656632,-2278430,12621151,-13339055,30878497,-11824370,-25584551,5181966 },
+ },
+ {
+ { 25940115,-12658025,17324188,-10307374,-8671468,15029094,24396252,-16450922,-2322852,-12388574 },
+ { -21765684,9916823,-1300409,4079498,-1028346,11909559,1782390,12641087,20603771,-6561742 },
+ { -18882287,-11673380,24849422,11501709,13161720,-4768874,1925523,11914390,4662781,7820689 },
+ },
+ {
+ { 12241050,-425982,8132691,9393934,32846760,-1599620,29749456,12172924,16136752,15264020 },
+ { -10349955,-14680563,-8211979,2330220,-17662549,-14545780,10658213,6671822,19012087,3772772 },
+ { 3753511,-3421066,10617074,2028709,14841030,-6721664,28718732,-15762884,20527771,12988982 },
+ },
+ {
+ { -14822485,-5797269,-3707987,12689773,-898983,-10914866,-24183046,-10564943,3299665,-12424953 },
+ { -16777703,-15253301,-9642417,4978983,3308785,8755439,6943197,6461331,-25583147,8991218 },
+ { -17226263,1816362,-1673288,-6086439,31783888,-8175991,-32948145,7417950,-30242287,1507265 },
+ },
+ {
+ { 29692663,6829891,-10498800,4334896,20945975,-11906496,-28887608,8209391,14606362,-10647073 },
+ { -3481570,8707081,32188102,5672294,22096700,1711240,-33020695,9761487,4170404,-2085325 },
+ { -11587470,14855945,-4127778,-1531857,-26649089,15084046,22186522,16002000,-14276837,-8400798 },
+ },
+ {
+ { -4811456,13761029,-31703877,-2483919,-3312471,7869047,-7113572,-9620092,13240845,10965870 },
+ { -7742563,-8256762,-14768334,-13656260,-23232383,12387166,4498947,14147411,29514390,4302863 },
+ { -13413405,-12407859,20757302,-13801832,14785143,8976368,-5061276,-2144373,17846988,-13971927 },
+ },
+},
+{
+ {
+ { -2244452,-754728,-4597030,-1066309,-6247172,1455299,-21647728,-9214789,-5222701,12650267 },
+ { -9906797,-16070310,21134160,12198166,-27064575,708126,387813,13770293,-19134326,10958663 },
+ { 22470984,12369526,23446014,-5441109,-21520802,-9698723,-11772496,-11574455,-25083830,4271862 },
+ },
+ {
+ { -25169565,-10053642,-19909332,15361595,-5984358,2159192,75375,-4278529,-32526221,8469673 },
+ { 15854970,4148314,-8893890,7259002,11666551,13824734,-30531198,2697372,24154791,-9460943 },
+ { 15446137,-15806644,29759747,14019369,30811221,-9610191,-31582008,12840104,24913809,9815020 },
+ },
+ {
+ { -4709286,-5614269,-31841498,-12288893,-14443537,10799414,-9103676,13438769,18735128,9466238 },
+ { 11933045,9281483,5081055,-5183824,-2628162,-4905629,-7727821,-10896103,-22728655,16199064 },
+ { 14576810,379472,-26786533,-8317236,-29426508,-10812974,-102766,1876699,30801119,2164795 },
+ },
+ {
+ { 15995086,3199873,13672555,13712240,-19378835,-4647646,-13081610,-15496269,-13492807,1268052 },
+ { -10290614,-3659039,-3286592,10948818,23037027,3794475,-3470338,-12600221,-17055369,3565904 },
+ { 29210088,-9419337,-5919792,-4952785,10834811,-13327726,-16512102,-10820713,-27162222,-14030531 },
+ },
+ {
+ { -13161890,15508588,16663704,-8156150,-28349942,9019123,-29183421,-3769423,2244111,-14001979 },
+ { -5152875,-3800936,-9306475,-6071583,16243069,14684434,-25673088,-16180800,13491506,4641841 },
+ { 10813417,643330,-19188515,-728916,30292062,-16600078,27548447,-7721242,14476989,-12767431 },
+ },
+ {
+ { 10292079,9984945,6481436,8279905,-7251514,7032743,27282937,-1644259,-27912810,12651324 },
+ { -31185513,-813383,22271204,11835308,10201545,15351028,17099662,3988035,21721536,-3148940 },
+ { 10202177,-6545839,-31373232,-9574638,-32150642,-8119683,-12906320,3852694,13216206,14842320 },
+ },
+ {
+ { -15815640,-10601066,-6538952,-7258995,-6984659,-6581778,-31500847,13765824,-27434397,9900184 },
+ { 14465505,-13833331,-32133984,-14738873,-27443187,12990492,33046193,15796406,-7051866,-8040114 },
+ { 30924417,-8279620,6359016,-12816335,16508377,9071735,-25488601,15413635,9524356,-7018878 },
+ },
+ {
+ { 12274201,-13175547,32627641,-1785326,6736625,13267305,5237659,-5109483,15663516,4035784 },
+ { -2951309,8903985,17349946,601635,-16432815,-4612556,-13732739,-15889334,-22258478,4659091 },
+ { -16916263,-4952973,-30393711,-15158821,20774812,15897498,5736189,15026997,-2178256,-13455585 },
+ },
+},
+{
+ {
+ { -8858980,-2219056,28571666,-10155518,-474467,-10105698,-3801496,278095,23440562,-290208 },
+ { 10226241,-5928702,15139956,120818,-14867693,5218603,32937275,11551483,-16571960,-7442864 },
+ { 17932739,-12437276,-24039557,10749060,11316803,7535897,22503767,5561594,-3646624,3898661 },
+ },
+ {
+ { 7749907,-969567,-16339731,-16464,-25018111,15122143,-1573531,7152530,21831162,1245233 },
+ { 26958459,-14658026,4314586,8346991,-5677764,11960072,-32589295,-620035,-30402091,-16716212 },
+ { -12165896,9166947,33491384,13673479,29787085,13096535,6280834,14587357,-22338025,13987525 },
+ },
+ {
+ { -24349909,7778775,21116000,15572597,-4833266,-5357778,-4300898,-5124639,-7469781,-2858068 },
+ { 9681908,-6737123,-31951644,13591838,-6883821,386950,31622781,6439245,-14581012,4091397 },
+ { -8426427,1470727,-28109679,-1596990,3978627,-5123623,-19622683,12092163,29077877,-14741988 },
+ },
+ {
+ { 5269168,-6859726,-13230211,-8020715,25932563,1763552,-5606110,-5505881,-20017847,2357889 },
+ { 32264008,-15407652,-5387735,-1160093,-2091322,-3946900,23104804,-12869908,5727338,189038 },
+ { 14609123,-8954470,-6000566,-16622781,-14577387,-7743898,-26745169,10942115,-25888931,-14884697 },
+ },
+ {
+ { 20513500,5557931,-15604613,7829531,26413943,-2019404,-21378968,7471781,13913677,-5137875 },
+ { -25574376,11967826,29233242,12948236,-6754465,4713227,-8940970,14059180,12878652,8511905 },
+ { -25656801,3393631,-2955415,-7075526,-2250709,9366908,-30223418,6812974,5568676,-3127656 },
+ },
+ {
+ { 11630004,12144454,2116339,13606037,27378885,15676917,-17408753,-13504373,-14395196,8070818 },
+ { 27117696,-10007378,-31282771,-5570088,1127282,12772488,-29845906,10483306,-11552749,-1028714 },
+ { 10637467,-5688064,5674781,1072708,-26343588,-6982302,-1683975,9177853,-27493162,15431203 },
+ },
+ {
+ { 20525145,10892566,-12742472,12779443,-29493034,16150075,-28240519,14943142,-15056790,-7935931 },
+ { -30024462,5626926,-551567,-9981087,753598,11981191,25244767,-3239766,-3356550,9594024 },
+ { -23752644,2636870,-5163910,-10103818,585134,7877383,11345683,-6492290,13352335,-10977084 },
+ },
+ {
+ { -1931799,-5407458,3304649,-12884869,17015806,-4877091,-29783850,-7752482,-13215537,-319204 },
+ { 20239939,6607058,6203985,3483793,-18386976,-779229,-20723742,15077870,-22750759,14523817 },
+ { 27406042,-6041657,27423596,-4497394,4996214,10002360,-28842031,-4545494,-30172742,-4805667 },
+ },
+},
+{
+ {
+ { 11374242,12660715,17861383,-12540833,10935568,1099227,-13886076,-9091740,-27727044,11358504 },
+ { -12730809,10311867,1510375,10778093,-2119455,-9145702,32676003,11149336,-26123651,4985768 },
+ { -19096303,341147,-6197485,-239033,15756973,-8796662,-983043,13794114,-19414307,-15621255 },
+ },
+ {
+ { 6490081,11940286,25495923,-7726360,8668373,-8751316,3367603,6970005,-1691065,-9004790 },
+ { 1656497,13457317,15370807,6364910,13605745,8362338,-19174622,-5475723,-16796596,-5031438 },
+ { -22273315,-13524424,-64685,-4334223,-18605636,-10921968,-20571065,-7007978,-99853,-10237333 },
+ },
+ {
+ { 17747465,10039260,19368299,-4050591,-20630635,-16041286,31992683,-15857976,-29260363,-5511971 },
+ { 31932027,-4986141,-19612382,16366580,22023614,88450,11371999,-3744247,4882242,-10626905 },
+ { 29796507,37186,19818052,10115756,-11829032,3352736,18551198,3272828,-5190932,-4162409 },
+ },
+ {
+ { 12501286,4044383,-8612957,-13392385,-32430052,5136599,-19230378,-3529697,330070,-3659409 },
+ { 6384877,2899513,17807477,7663917,-2358888,12363165,25366522,-8573892,-271295,12071499 },
+ { -8365515,-4042521,25133448,-4517355,-6211027,2265927,-32769618,1936675,-5159697,3829363 },
+ },
+ {
+ { 28425966,-5835433,-577090,-4697198,-14217555,6870930,7921550,-6567787,26333140,14267664 },
+ { -11067219,11871231,27385719,-10559544,-4585914,-11189312,10004786,-8709488,-21761224,8930324 },
+ { -21197785,-16396035,25654216,-1725397,12282012,11008919,1541940,4757911,-26491501,-16408940 },
+ },
+ {
+ { 13537262,-7759490,-20604840,10961927,-5922820,-13218065,-13156584,6217254,-15943699,13814990 },
+ { -17422573,15157790,18705543,29619,24409717,-260476,27361681,9257833,-1956526,-1776914 },
+ { -25045300,-10191966,15366585,15166509,-13105086,8423556,-29171540,12361135,-18685978,4578290 },
+ },
+ {
+ { 24579768,3711570,1342322,-11180126,-27005135,14124956,-22544529,14074919,21964432,8235257 },
+ { -6528613,-2411497,9442966,-5925588,12025640,-1487420,-2981514,-1669206,13006806,2355433 },
+ { -16304899,-13605259,-6632427,-5142349,16974359,-10911083,27202044,1719366,1141648,-12796236 },
+ },
+ {
+ { -12863944,-13219986,-8318266,-11018091,-6810145,-4843894,13475066,-3133972,32674895,13715045 },
+ { 11423335,-5468059,32344216,8962751,24989809,9241752,-13265253,16086212,-28740881,-15642093 },
+ { -1409668,12530728,-6368726,10847387,19531186,-14132160,-11709148,7791794,-27245943,4383347 },
+ },
+},
+{
+ {
+ { -28970898,5271447,-1266009,-9736989,-12455236,16732599,-4862407,-4906449,27193557,6245191 },
+ { -15193956,5362278,-1783893,2695834,4960227,12840725,23061898,3260492,22510453,8577507 },
+ { -12632451,11257346,-32692994,13548177,-721004,10879011,31168030,13952092,-29571492,-3635906 },
+ },
+ {
+ { 3877321,-9572739,32416692,5405324,-11004407,-13656635,3759769,11935320,5611860,8164018 },
+ { -16275802,14667797,15906460,12155291,-22111149,-9039718,32003002,-8832289,5773085,-8422109 },
+ { -23788118,-8254300,1950875,8937633,18686727,16459170,-905725,12376320,31632953,190926 },
+ },
+ {
+ { -24593607,-16138885,-8423991,13378746,14162407,6901328,-8288749,4508564,-25341555,-3627528 },
+ { 8884438,-5884009,6023974,10104341,-6881569,-4941533,18722941,-14786005,-1672488,827625 },
+ { -32720583,-16289296,-32503547,7101210,13354605,2659080,-1800575,-14108036,-24878478,1541286 },
+ },
+ {
+ { 2901347,-1117687,3880376,-10059388,-17620940,-3612781,-21802117,-3567481,20456845,-1885033 },
+ { 27019610,12299467,-13658288,-1603234,-12861660,-4861471,-19540150,-5016058,29439641,15138866 },
+ { 21536104,-6626420,-32447818,-10690208,-22408077,5175814,-5420040,-16361163,7779328,109896 },
+ },
+ {
+ { 30279744,14648750,-8044871,6425558,13639621,-743509,28698390,12180118,23177719,-554075 },
+ { 26572847,3405927,-31701700,12890905,-19265668,5335866,-6493768,2378492,4439158,-13279347 },
+ { -22716706,3489070,-9225266,-332753,18875722,-1140095,14819434,-12731527,-17717757,-5461437 },
+ },
+ {
+ { -5056483,16566551,15953661,3767752,-10436499,15627060,-820954,2177225,8550082,-15114165 },
+ { -18473302,16596775,-381660,15663611,22860960,15585581,-27844109,-3582739,-23260460,-8428588 },
+ { -32480551,15707275,-8205912,-5652081,29464558,2713815,-22725137,15860482,-21902570,1494193 },
+ },
+ {
+ { -19562091,-14087393,-25583872,-9299552,13127842,759709,21923482,16529112,8742704,12967017 },
+ { -28464899,1553205,32536856,-10473729,-24691605,-406174,-8914625,-2933896,-29903758,15553883 },
+ { 21877909,3230008,9881174,10539357,-4797115,2841332,11543572,14513274,19375923,-12647961 },
+ },
+ {
+ { 8832269,-14495485,13253511,5137575,5037871,4078777,24880818,-6222716,2862653,9455043 },
+ { 29306751,5123106,20245049,-14149889,9592566,8447059,-2077124,-2990080,15511449,4789663 },
+ { -20679756,7004547,8824831,-9434977,-4045704,-3750736,-5754762,108893,23513200,16652362 },
+ },
+},
+{
+ {
+ { -33256173,4144782,-4476029,-6579123,10770039,-7155542,-6650416,-12936300,-18319198,10212860 },
+ { 2756081,8598110,7383731,-6859892,22312759,-1105012,21179801,2600940,-9988298,-12506466 },
+ { -24645692,13317462,-30449259,-15653928,21365574,-10869657,11344424,864440,-2499677,-16710063 },
+ },
+ {
+ { -26432803,6148329,-17184412,-14474154,18782929,-275997,-22561534,211300,2719757,4940997 },
+ { -1323882,3911313,-6948744,14759765,-30027150,7851207,21690126,8518463,26699843,5276295 },
+ { -13149873,-6429067,9396249,365013,24703301,-10488939,1321586,149635,-15452774,7159369 },
+ },
+ {
+ { 9987780,-3404759,17507962,9505530,9731535,-2165514,22356009,8312176,22477218,-8403385 },
+ { 18155857,-16504990,19744716,9006923,15154154,-10538976,24256460,-4864995,-22548173,9334109 },
+ { 2986088,-4911893,10776628,-3473844,10620590,-7083203,-21413845,14253545,-22587149,536906 },
+ },
+ {
+ { 4377756,8115836,24567078,15495314,11625074,13064599,7390551,10589625,10838060,-15420424 },
+ { -19342404,867880,9277171,-3218459,-14431572,-1986443,19295826,-15796950,6378260,699185 },
+ { 7895026,4057113,-7081772,-13077756,-17886831,-323126,-716039,15693155,-5045064,-13373962 },
+ },
+ {
+ { -7737563,-5869402,-14566319,-7406919,11385654,13201616,31730678,-10962840,-3918636,-9669325 },
+ { 10188286,-15770834,-7336361,13427543,22223443,14896287,30743455,7116568,-21786507,5427593 },
+ { 696102,13206899,27047647,-10632082,15285305,-9853179,10798490,-4578720,19236243,12477404 },
+ },
+ {
+ { -11229439,11243796,-17054270,-8040865,-788228,-8167967,-3897669,11180504,-23169516,7733644 },
+ { 17800790,-14036179,-27000429,-11766671,23887827,3149671,23466177,-10538171,10322027,15313801 },
+ { 26246234,11968874,32263343,-5468728,6830755,-13323031,-15794704,-101982,-24449242,10890804 },
+ },
+ {
+ { -31365647,10271363,-12660625,-6267268,16690207,-13062544,-14982212,16484931,25180797,-5334884 },
+ { -586574,10376444,-32586414,-11286356,19801893,10997610,2276632,9482883,316878,13820577 },
+ { -9882808,-4510367,-2115506,16457136,-11100081,11674996,30756178,-7515054,30696930,-3712849 },
+ },
+ {
+ { 32988917,-9603412,12499366,7910787,-10617257,-11931514,-7342816,-9985397,-32349517,7392473 },
+ { -8855661,15927861,9866406,-3649411,-2396914,-16655781,-30409476,-9134995,25112947,-2926644 },
+ { -2504044,-436966,25621774,-5678772,15085042,-5479877,-24884878,-13526194,5537438,-13914319 },
+ },
+},
+{
+ {
+ { -11225584,2320285,-9584280,10149187,-33444663,5808648,-14876251,-1729667,31234590,6090599 },
+ { -9633316,116426,26083934,2897444,-6364437,-2688086,609721,15878753,-6970405,-9034768 },
+ { -27757857,247744,-15194774,-9002551,23288161,-10011936,-23869595,6503646,20650474,1804084 },
+ },
+ {
+ { -27589786,15456424,8972517,8469608,15640622,4439847,3121995,-10329713,27842616,-202328 },
+ { -15306973,2839644,22530074,10026331,4602058,5048462,28248656,5031932,-11375082,12714369 },
+ { 20807691,-7270825,29286141,11421711,-27876523,-13868230,-21227475,1035546,-19733229,12796920 },
+ },
+ {
+ { 12076899,-14301286,-8785001,-11848922,-25012791,16400684,-17591495,-12899438,3480665,-15182815 },
+ { -32361549,5457597,28548107,7833186,7303070,-11953545,-24363064,-15921875,-33374054,2771025 },
+ { -21389266,421932,26597266,6860826,22486084,-6737172,-17137485,-4210226,-24552282,15673397 },
+ },
+ {
+ { -20184622,2338216,19788685,-9620956,-4001265,-8740893,-20271184,4733254,3727144,-12934448 },
+ { 6120119,814863,-11794402,-622716,6812205,-15747771,2019594,7975683,31123697,-10958981 },
+ { 30069250,-11435332,30434654,2958439,18399564,-976289,12296869,9204260,-16432438,9648165 },
+ },
+ {
+ { 32705432,-1550977,30705658,7451065,-11805606,9631813,3305266,5248604,-26008332,-11377501 },
+ { 17219865,2375039,-31570947,-5575615,-19459679,9219903,294711,15298639,2662509,-16297073 },
+ { -1172927,-7558695,-4366770,-4287744,-21346413,-8434326,32087529,-1222777,32247248,-14389861 },
+ },
+ {
+ { 14312628,1221556,17395390,-8700143,-4945741,-8684635,-28197744,-9637817,-16027623,-13378845 },
+ { -1428825,-9678990,-9235681,6549687,-7383069,-468664,23046502,9803137,17597934,2346211 },
+ { 18510800,15337574,26171504,981392,-22241552,7827556,-23491134,-11323352,3059833,-11782870 },
+ },
+ {
+ { 10141598,6082907,17829293,-1947643,9830092,13613136,-25556636,-5544586,-33502212,3592096 },
+ { 33114168,-15889352,-26525686,-13343397,33076705,8716171,1151462,1521897,-982665,-6837803 },
+ { -32939165,-4255815,23947181,-324178,-33072974,-12305637,-16637686,3891704,26353178,693168 },
+ },
+ {
+ { 30374239,1595580,-16884039,13186931,4600344,406904,9585294,-400668,31375464,14369965 },
+ { -14370654,-7772529,1510301,6434173,-18784789,-6262728,32732230,-13108839,17901441,16011505 },
+ { 18171223,-11934626,-12500402,15197122,-11038147,-15230035,-19172240,-16046376,8764035,12309598 },
+ },
+},
+{
+ {
+ { 5975908,-5243188,-19459362,-9681747,-11541277,14015782,-23665757,1228319,17544096,-10593782 },
+ { 5811932,-1715293,3442887,-2269310,-18367348,-8359541,-18044043,-15410127,-5565381,12348900 },
+ { -31399660,11407555,25755363,6891399,-3256938,14872274,-24849353,8141295,-10632534,-585479 },
+ },
+ {
+ { -12675304,694026,-5076145,13300344,14015258,-14451394,-9698672,-11329050,30944593,1130208 },
+ { 8247766,-6710942,-26562381,-7709309,-14401939,-14648910,4652152,2488540,23550156,-271232 },
+ { 17294316,-3788438,7026748,15626851,22990044,113481,2267737,-5908146,-408818,-137719 },
+ },
+ {
+ { 16091085,-16253926,18599252,7340678,2137637,-1221657,-3364161,14550936,3260525,-7166271 },
+ { -4910104,-13332887,18550887,10864893,-16459325,-7291596,-23028869,-13204905,-12748722,2701326 },
+ { -8574695,16099415,4629974,-16340524,-20786213,-6005432,-10018363,9276971,11329923,1862132 },
+ },
+ {
+ { 14763076,-15903608,-30918270,3689867,3511892,10313526,-21951088,12219231,-9037963,-940300 },
+ { 8894987,-3446094,6150753,3013931,301220,15693451,-31981216,-2909717,-15438168,11595570 },
+ { 15214962,3537601,-26238722,-14058872,4418657,-15230761,13947276,10730794,-13489462,-4363670 },
+ },
+ {
+ { -2538306,7682793,32759013,263109,-29984731,-7955452,-22332124,-10188635,977108,699994 },
+ { -12466472,4195084,-9211532,550904,-15565337,12917920,19118110,-439841,-30534533,-14337913 },
+ { 31788461,-14507657,4799989,7372237,8808585,-14747943,9408237,-10051775,12493932,-5409317 },
+ },
+ {
+ { -25680606,5260744,-19235809,-6284470,-3695942,16566087,27218280,2607121,29375955,6024730 },
+ { 842132,-2794693,-4763381,-8722815,26332018,-12405641,11831880,6985184,-9940361,2854096 },
+ { -4847262,-7969331,2516242,-5847713,9695691,-7221186,16512645,960770,12121869,16648078 },
+ },
+ {
+ { -15218652,14667096,-13336229,2013717,30598287,-464137,-31504922,-7882064,20237806,2838411 },
+ { -19288047,4453152,15298546,-16178388,22115043,-15972604,12544294,-13470457,1068881,-12499905 },
+ { -9558883,-16518835,33238498,13506958,30505848,-1114596,-8486907,-2630053,12521378,4845654 },
+ },
+ {
+ { -28198521,10744108,-2958380,10199664,7759311,-13088600,3409348,-873400,-6482306,-12885870 },
+ { -23561822,6230156,-20382013,10655314,-24040585,-11621172,10477734,-1240216,-3113227,13974498 },
+ { 12966261,15550616,-32038948,-1615346,21025980,-629444,5642325,7188737,18895762,12629579 },
+ },
+},
+{
+ {
+ { 14741879,-14946887,22177208,-11721237,1279741,8058600,11758140,789443,32195181,3895677 },
+ { 10758205,15755439,-4509950,9243698,-4879422,6879879,-2204575,-3566119,-8982069,4429647 },
+ { -2453894,15725973,-20436342,-10410672,-5803908,-11040220,-7135870,-11642895,18047436,-15281743 },
+ },
+ {
+ { -25173001,-11307165,29759956,11776784,-22262383,-15820455,10993114,-12850837,-17620701,-9408468 },
+ { 21987233,700364,-24505048,14972008,-7774265,-5718395,32155026,2581431,-29958985,8773375 },
+ { -25568350,454463,-13211935,16126715,25240068,8594567,20656846,12017935,-7874389,-13920155 },
+ },
+ {
+ { 6028182,6263078,-31011806,-11301710,-818919,2461772,-31841174,-5468042,-1721788,-2776725 },
+ { -12278994,16624277,987579,-5922598,32908203,1248608,7719845,-4166698,28408820,6816612 },
+ { -10358094,-8237829,19549651,-12169222,22082623,16147817,20613181,13982702,-10339570,5067943 },
+ },
+ {
+ { -30505967,-3821767,12074681,13582412,-19877972,2443951,-19719286,12746132,5331210,-10105944 },
+ { 30528811,3601899,-1957090,4619785,-27361822,-15436388,24180793,-12570394,27679908,-1648928 },
+ { 9402404,-13957065,32834043,10838634,-26580150,-13237195,26653274,-8685565,22611444,-12715406 },
+ },
+ {
+ { 22190590,1118029,22736441,15130463,-30460692,-5991321,19189625,-4648942,4854859,6622139 },
+ { -8310738,-2953450,-8262579,-3388049,-10401731,-271929,13424426,-3567227,26404409,13001963 },
+ { -31241838,-15415700,-2994250,8939346,11562230,-12840670,-26064365,-11621720,-15405155,11020693 },
+ },
+ {
+ { 1866042,-7949489,-7898649,-10301010,12483315,13477547,3175636,-12424163,28761762,1406734 },
+ { -448555,-1777666,13018551,3194501,-9580420,-11161737,24760585,-4347088,25577411,-13378680 },
+ { -24290378,4759345,-690653,-1852816,2066747,10693769,-29595790,9884936,-9368926,4745410 },
+ },
+ {
+ { -9141284,6049714,-19531061,-4341411,-31260798,9944276,-15462008,-11311852,10931924,-11931931 },
+ { -16561513,14112680,-8012645,4817318,-8040464,-11414606,-22853429,10856641,-20470770,13434654 },
+ { 22759489,-10073434,-16766264,-1871422,13637442,-10168091,1765144,-12654326,28445307,-5364710 },
+ },
+ {
+ { 29875063,12493613,2795536,-3786330,1710620,15181182,-10195717,-8788675,9074234,1167180 },
+ { -26205683,11014233,-9842651,-2635485,-26908120,7532294,-18716888,-9535498,3843903,9367684 },
+ { -10969595,-6403711,9591134,9582310,11349256,108879,16235123,8601684,-139197,4242895 },
+ },
+},
+{
+ {
+ { 22092954,-13191123,-2042793,-11968512,32186753,-11517388,-6574341,2470660,-27417366,16625501 },
+ { -11057722,3042016,13770083,-9257922,584236,-544855,-7770857,2602725,-27351616,14247413 },
+ { 6314175,-10264892,-32772502,15957557,-10157730,168750,-8618807,14290061,27108877,-1180880 },
+ },
+ {
+ { -8586597,-7170966,13241782,10960156,-32991015,-13794596,33547976,-11058889,-27148451,981874 },
+ { 22833440,9293594,-32649448,-13618667,-9136966,14756819,-22928859,-13970780,-10479804,-16197962 },
+ { -7768587,3326786,-28111797,10783824,19178761,14905060,22680049,13906969,-15933690,3797899 },
+ },
+ {
+ { 21721356,-4212746,-12206123,9310182,-3882239,-13653110,23740224,-2709232,20491983,-8042152 },
+ { 9209270,-15135055,-13256557,-6167798,-731016,15289673,25947805,15286587,30997318,-6703063 },
+ { 7392032,16618386,23946583,-8039892,-13265164,-1533858,-14197445,-2321576,17649998,-250080 },
+ },
+ {
+ { -9301088,-14193827,30609526,-3049543,-25175069,-1283752,-15241566,-9525724,-2233253,7662146 },
+ { -17558673,1763594,-33114336,15908610,-30040870,-12174295,7335080,-8472199,-3174674,3440183 },
+ { -19889700,-5977008,-24111293,-9688870,10799743,-16571957,40450,-4431835,4862400,1133 },
+ },
+ {
+ { -32856209,-7873957,-5422389,14860950,-16319031,7956142,7258061,311861,-30594991,-7379421 },
+ { -3773428,-1565936,28985340,7499440,24445838,9325937,29727763,16527196,18278453,15405622 },
+ { -4381906,8508652,-19898366,-3674424,-5984453,15149970,-13313598,843523,-21875062,13626197 },
+ },
+ {
+ { 2281448,-13487055,-10915418,-2609910,1879358,16164207,-10783882,3953792,13340839,15928663 },
+ { 31727126,-7179855,-18437503,-8283652,2875793,-16390330,-25269894,-7014826,-23452306,5964753 },
+ { 4100420,-5959452,-17179337,6017714,-18705837,12227141,-26684835,11344144,2538215,-7570755 },
+ },
+ {
+ { -9433605,6123113,11159803,-2156608,30016280,14966241,-20474983,1485421,-629256,-15958862 },
+ { -26804558,4260919,11851389,9658551,-32017107,16367492,-20205425,-13191288,11659922,-11115118 },
+ { 26180396,10015009,-30844224,-8581293,5418197,9480663,2231568,-10170080,33100372,-1306171 },
+ },
+ {
+ { 15121113,-5201871,-10389905,15427821,-27509937,-15992507,21670947,4486675,-5931810,-14466380 },
+ { 16166486,-9483733,-11104130,6023908,-31926798,-1364923,2340060,-16254968,-10735770,-10039824 },
+ { 28042865,-3557089,-12126526,12259706,-3717498,-6945899,6766453,-8689599,18036436,5803270 },
+ },
+},
+{
+ {
+ { -817581,6763912,11803561,1585585,10958447,-2671165,23855391,4598332,-6159431,-14117438 },
+ { -31031306,-14256194,17332029,-2383520,31312682,-5967183,696309,50292,-20095739,11763584 },
+ { -594563,-2514283,-32234153,12643980,12650761,14811489,665117,-12613632,-19773211,-10713562 },
+ },
+ {
+ { 30464590,-11262872,-4127476,-12734478,19835327,-7105613,-24396175,2075773,-17020157,992471 },
+ { 18357185,-6994433,7766382,16342475,-29324918,411174,14578841,8080033,-11574335,-10601610 },
+ { 19598397,10334610,12555054,2555664,18821899,-10339780,21873263,16014234,26224780,16452269 },
+ },
+ {
+ { -30223925,5145196,5944548,16385966,3976735,2009897,-11377804,-7618186,-20533829,3698650 },
+ { 14187449,3448569,-10636236,-10810935,-22663880,-3433596,7268410,-10890444,27394301,12015369 },
+ { 19695761,16087646,28032085,12999827,6817792,11427614,20244189,-1312777,-13259127,-3402461 },
+ },
+ {
+ { 30860103,12735208,-1888245,-4699734,-16974906,2256940,-8166013,12298312,-8550524,-10393462 },
+ { -5719826,-11245325,-1910649,15569035,26642876,-7587760,-5789354,-15118654,-4976164,12651793 },
+ { -2848395,9953421,11531313,-5282879,26895123,-12697089,-13118820,-16517902,9768698,-2533218 },
+ },
+ {
+ { -24719459,1894651,-287698,-4704085,15348719,-8156530,32767513,12765450,4940095,10678226 },
+ { 18860224,15980149,-18987240,-1562570,-26233012,-11071856,-7843882,13944024,-24372348,16582019 },
+ { -15504260,4970268,-29893044,4175593,-20993212,-2199756,-11704054,15444560,-11003761,7989037 },
+ },
+ {
+ { 31490452,5568061,-2412803,2182383,-32336847,4531686,-32078269,6200206,-19686113,-14800171 },
+ { -17308668,-15879940,-31522777,-2831,-32887382,16375549,8680158,-16371713,28550068,-6857132 },
+ { -28126887,-5688091,16837845,-1820458,-6850681,12700016,-30039981,4364038,1155602,5988841 },
+ },
+ {
+ { 21890435,-13272907,-12624011,12154349,-7831873,15300496,23148983,-4470481,24618407,8283181 },
+ { -33136107,-10512751,9975416,6841041,-31559793,16356536,3070187,-7025928,1466169,10740210 },
+ { -1509399,-15488185,-13503385,-10655916,32799044,909394,-13938903,-5779719,-32164649,-15327040 },
+ },
+ {
+ { 3960823,-14267803,-28026090,-15918051,-19404858,13146868,15567327,951507,-3260321,-573935 },
+ { 24740841,5052253,-30094131,8961361,25877428,6165135,-24368180,14397372,-7380369,-6144105 },
+ { -28888365,3510803,-28103278,-1158478,-11238128,-10631454,-15441463,-14453128,-1625486,-6494814 },
+ },
+},
+{
+ {
+ { 793299,-9230478,8836302,-6235707,-27360908,-2369593,33152843,-4885251,-9906200,-621852 },
+ { 5666233,525582,20782575,-8038419,-24538499,14657740,16099374,1468826,-6171428,-15186581 },
+ { -4859255,-3779343,-2917758,-6748019,7778750,11688288,-30404353,-9871238,-1558923,-9863646 },
+ },
+ {
+ { 10896332,-7719704,824275,472601,-19460308,3009587,25248958,14783338,-30581476,-15757844 },
+ { 10566929,12612572,-31944212,11118703,-12633376,12362879,21752402,8822496,24003793,14264025 },
+ { 27713862,-7355973,-11008240,9227530,27050101,2504721,23886875,-13117525,13958495,-5732453 },
+ },
+ {
+ { -23481610,4867226,-27247128,3900521,29838369,-8212291,-31889399,-10041781,7340521,-15410068 },
+ { 4646514,-8011124,-22766023,-11532654,23184553,8566613,31366726,-1381061,-15066784,-10375192 },
+ { -17270517,12723032,-16993061,14878794,21619651,-6197576,27584817,3093888,-8843694,3849921 },
+ },
+ {
+ { -9064912,2103172,25561640,-15125738,-5239824,9582958,32477045,-9017955,5002294,-15550259 },
+ { -12057553,-11177906,21115585,-13365155,8808712,-12030708,16489530,13378448,-25845716,12741426 },
+ { -5946367,10645103,-30911586,15390284,-3286982,-7118677,24306472,15852464,28834118,-7646072 },
+ },
+ {
+ { -17335748,-9107057,-24531279,9434953,-8472084,-583362,-13090771,455841,20461858,5491305 },
+ { 13669248,-16095482,-12481974,-10203039,-14569770,-11893198,-24995986,11293807,-28588204,-9421832 },
+ { 28497928,6272777,-33022994,14470570,8906179,-1225630,18504674,-14165166,29867745,-8795943 },
+ },
+ {
+ { -16207023,13517196,-27799630,-13697798,24009064,-6373891,-6367600,-13175392,22853429,-4012011 },
+ { 24191378,16712145,-13931797,15217831,14542237,1646131,18603514,-11037887,12876623,-2112447 },
+ { 17902668,4518229,-411702,-2829247,26878217,5258055,-12860753,608397,16031844,3723494 },
+ },
+ {
+ { -28632773,12763728,-20446446,7577504,33001348,-13017745,17558842,-7872890,23896954,-4314245 },
+ { -20005381,-12011952,31520464,605201,2543521,5991821,-2945064,7229064,-9919646,-8826859 },
+ { 28816045,298879,-28165016,-15920938,19000928,-1665890,-12680833,-2949325,-18051778,-2082915 },
+ },
+ {
+ { 16000882,-344896,3493092,-11447198,-29504595,-13159789,12577740,16041268,-19715240,7847707 },
+ { 10151868,10572098,27312476,7922682,14825339,4723128,-32855931,-6519018,-10020567,3852848 },
+ { -11430470,15697596,-21121557,-4420647,5386314,15063598,16514493,-15932110,29330899,-15076224 },
+ },
+},
+{
+ {
+ { -25499735,-4378794,-15222908,-6901211,16615731,2051784,3303702,15490,-27548796,12314391 },
+ { 15683520,-6003043,18109120,-9980648,15337968,-5997823,-16717435,15921866,16103996,-3731215 },
+ { -23169824,-10781249,13588192,-1628807,-3798557,-1074929,-19273607,5402699,-29815713,-9841101 },
+ },
+ {
+ { 23190676,2384583,-32714340,3462154,-29903655,-1529132,-11266856,8911517,-25205859,2739713 },
+ { 21374101,-3554250,-33524649,9874411,15377179,11831242,-33529904,6134907,4931255,11987849 },
+ { -7732,-2978858,-16223486,7277597,105524,-322051,-31480539,13861388,-30076310,10117930 },
+ },
+ {
+ { -29501170,-10744872,-26163768,13051539,-25625564,5089643,-6325503,6704079,12890019,15728940 },
+ { -21972360,-11771379,-951059,-4418840,14704840,2695116,903376,-10428139,12885167,8311031 },
+ { -17516482,5352194,10384213,-13811658,7506451,13453191,26423267,4384730,1888765,-5435404 },
+ },
+ {
+ { -25817338,-3107312,-13494599,-3182506,30896459,-13921729,-32251644,-12707869,-19464434,-3340243 },
+ { -23607977,-2665774,-526091,4651136,5765089,4618330,6092245,14845197,17151279,-9854116 },
+ { -24830458,-12733720,-15165978,10367250,-29530908,-265356,22825805,-7087279,-16866484,16176525 },
+ },
+ {
+ { -23583256,6564961,20063689,3798228,-4740178,7359225,2006182,-10363426,-28746253,-10197509 },
+ { -10626600,-4486402,-13320562,-5125317,3432136,-6393229,23632037,-1940610,32808310,1099883 },
+ { 15030977,5768825,-27451236,-2887299,-6427378,-15361371,-15277896,-6809350,2051441,-15225865 },
+ },
+ {
+ { -3362323,-7239372,7517890,9824992,23555850,295369,5148398,-14154188,-22686354,16633660 },
+ { 4577086,-16752288,13249841,-15304328,19958763,-14537274,18559670,-10759549,8402478,-9864273 },
+ { -28406330,-1051581,-26790155,-907698,-17212414,-11030789,9453451,-14980072,17983010,9967138 },
+ },
+ {
+ { -25762494,6524722,26585488,9969270,24709298,1220360,-1677990,7806337,17507396,3651560 },
+ { -10420457,-4118111,14584639,15971087,-15768321,8861010,26556809,-5574557,-18553322,-11357135 },
+ { 2839101,14284142,4029895,3472686,14402957,12689363,-26642121,8459447,-5605463,-7621941 },
+ },
+ {
+ { -4839289,-3535444,9744961,2871048,25113978,3187018,-25110813,-849066,17258084,-7977739 },
+ { 18164541,-10595176,-17154882,-1542417,19237078,-9745295,23357533,-15217008,26908270,12150756 },
+ { -30264870,-7647865,5112249,-7036672,-1499807,-6974257,43168,-5537701,-32302074,16215819 },
+ },
+},
+{
+ {
+ { -6898905,9824394,-12304779,-4401089,-31397141,-6276835,32574489,12532905,-7503072,-8675347 },
+ { -27343522,-16515468,-27151524,-10722951,946346,16291093,254968,7168080,21676107,-1943028 },
+ { 21260961,-8424752,-16831886,-11920822,-23677961,3968121,-3651949,-6215466,-3556191,-7913075 },
+ },
+ {
+ { 16544754,13250366,-16804428,15546242,-4583003,12757258,-2462308,-8680336,-18907032,-9662799 },
+ { -2415239,-15577728,18312303,4964443,-15272530,-12653564,26820651,16690659,25459437,-4564609 },
+ { -25144690,11425020,28423002,-11020557,-6144921,-15826224,9142795,-2391602,-6432418,-1644817 },
+ },
+ {
+ { -23104652,6253476,16964147,-3768872,-25113972,-12296437,-27457225,-16344658,6335692,7249989 },
+ { -30333227,13979675,7503222,-12368314,-11956721,-4621693,-30272269,2682242,25993170,-12478523 },
+ { 4364628,5930691,32304656,-10044554,-8054781,15091131,22857016,-10598955,31820368,15075278 },
+ },
+ {
+ { 31879134,-8918693,17258761,90626,-8041836,-4917709,24162788,-9650886,-17970238,12833045 },
+ { 19073683,14851414,-24403169,-11860168,7625278,11091125,-19619190,2074449,-9413939,14905377 },
+ { 24483667,-11935567,-2518866,-11547418,-1553130,15355506,-25282080,9253129,27628530,-7555480 },
+ },
+ {
+ { 17597607,8340603,19355617,552187,26198470,-3176583,4593324,-9157582,-14110875,15297016 },
+ { 510886,14337390,-31785257,16638632,6328095,2713355,-20217417,-11864220,8683221,2921426 },
+ { 18606791,11874196,27155355,-5281482,-24031742,6265446,-25178240,-1278924,4674690,13890525 },
+ },
+ {
+ { 13609624,13069022,-27372361,-13055908,24360586,9592974,14977157,9835105,4389687,288396 },
+ { 9922506,-519394,13613107,5883594,-18758345,-434263,-12304062,8317628,23388070,16052080 },
+ { 12720016,11937594,-31970060,-5028689,26900120,8561328,-20155687,-11632979,-14754271,-10812892 },
+ },
+ {
+ { 15961858,14150409,26716931,-665832,-22794328,13603569,11829573,7467844,-28822128,929275 },
+ { 11038231,-11582396,-27310482,-7316562,-10498527,-16307831,-23479533,-9371869,-21393143,2465074 },
+ { 20017163,-4323226,27915242,1529148,12396362,15675764,13817261,-9658066,2463391,-4622140 },
+ },
+ {
+ { -16358878,-12663911,-12065183,4996454,-1256422,1073572,9583558,12851107,4003896,12673717 },
+ { -1731589,-15155870,-3262930,16143082,19294135,13385325,14741514,-9103726,7903886,2348101 },
+ { 24536016,-16515207,12715592,-3862155,1511293,10047386,-3842346,-7129159,-28377538,10048127 },
+ },
+},
+{
+ {
+ { -12622226,-6204820,30718825,2591312,-10617028,12192840,18873298,-7297090,-32297756,15221632 },
+ { -26478122,-11103864,11546244,-1852483,9180880,7656409,-21343950,2095755,29769758,6593415 },
+ { -31994208,-2907461,4176912,3264766,12538965,-868111,26312345,-6118678,30958054,8292160 },
+ },
+ {
+ { 31429822,-13959116,29173532,15632448,12174511,-2760094,32808831,3977186,26143136,-3148876 },
+ { 22648901,1402143,-22799984,13746059,7936347,365344,-8668633,-1674433,-3758243,-2304625 },
+ { -15491917,8012313,-2514730,-12702462,-23965846,-10254029,-1612713,-1535569,-16664475,8194478 },
+ },
+ {
+ { 27338066,-7507420,-7414224,10140405,-19026427,-6589889,27277191,8855376,28572286,3005164 },
+ { 26287124,4821776,25476601,-4145903,-3764513,-15788984,-18008582,1182479,-26094821,-13079595 },
+ { -7171154,3178080,23970071,6201893,-17195577,-4489192,-21876275,-13982627,32208683,-1198248 },
+ },
+ {
+ { -16657702,2817643,-10286362,14811298,6024667,13349505,-27315504,-10497842,-27672585,-11539858 },
+ { 15941029,-9405932,-21367050,8062055,31876073,-238629,-15278393,-1444429,15397331,-4130193 },
+ { 8934485,-13485467,-23286397,-13423241,-32446090,14047986,31170398,-1441021,-27505566,15087184 },
+ },
+ {
+ { -18357243,-2156491,24524913,-16677868,15520427,-6360776,-15502406,11461896,16788528,-5868942 },
+ { -1947386,16013773,21750665,3714552,-17401782,-16055433,-3770287,-10323320,31322514,-11615635 },
+ { 21426655,-5650218,-13648287,-5347537,-28812189,-4920970,-18275391,-14621414,13040862,-12112948 },
+ },
+ {
+ { 11293895,12478086,-27136401,15083750,-29307421,14748872,14555558,-13417103,1613711,4896935 },
+ { -25894883,15323294,-8489791,-8057900,25967126,-13425460,2825960,-4897045,-23971776,-11267415 },
+ { -15924766,-5229880,-17443532,6410664,3622847,10243618,20615400,12405433,-23753030,-8436416 },
+ },
+ {
+ { -7091295,12556208,-20191352,9025187,-17072479,4333801,4378436,2432030,23097949,-566018 },
+ { 4565804,-16025654,20084412,-7842817,1724999,189254,24767264,10103221,-18512313,2424778 },
+ { 366633,-11976806,8173090,-6890119,30788634,5745705,-7168678,1344109,-3642553,12412659 },
+ },
+ {
+ { -24001791,7690286,14929416,-168257,-32210835,-13412986,24162697,-15326504,-3141501,11179385 },
+ { 18289522,-14724954,8056945,16430056,-21729724,7842514,-6001441,-1486897,-18684645,-11443503 },
+ { 476239,6601091,-6152790,-9723375,17503545,-4863900,27672959,13403813,11052904,5219329 },
+ },
+},
+{
+ {
+ { 20678546,-8375738,-32671898,8849123,-5009758,14574752,31186971,-3973730,9014762,-8579056 },
+ { -13644050,-10350239,-15962508,5075808,-1514661,-11534600,-33102500,9160280,8473550,-3256838 },
+ { 24900749,14435722,17209120,-15292541,-22592275,9878983,-7689309,-16335821,-24568481,11788948 },
+ },
+ {
+ { -3118155,-11395194,-13802089,14797441,9652448,-6845904,-20037437,10410733,-24568470,-1458691 },
+ { -15659161,16736706,-22467150,10215878,-9097177,7563911,11871841,-12505194,-18513325,8464118 },
+ { -23400612,8348507,-14585951,-861714,-3950205,-6373419,14325289,8628612,33313881,-8370517 },
+ },
+ {
+ { -20186973,-4967935,22367356,5271547,-1097117,-4788838,-24805667,-10236854,-8940735,-5818269 },
+ { -6948785,-1795212,-32625683,-16021179,32635414,-7374245,15989197,-12838188,28358192,-4253904 },
+ { -23561781,-2799059,-32351682,-1661963,-9147719,10429267,-16637684,4072016,-5351664,5596589 },
+ },
+ {
+ { -28236598,-3390048,12312896,6213178,3117142,16078565,29266239,2557221,1768301,15373193 },
+ { -7243358,-3246960,-4593467,-7553353,-127927,-912245,-1090902,-4504991,-24660491,3442910 },
+ { -30210571,5124043,14181784,8197961,18964734,-11939093,22597931,7176455,-18585478,13365930 },
+ },
+ {
+ { -7877390,-1499958,8324673,4690079,6261860,890446,24538107,-8570186,-9689599,-3031667 },
+ { 25008904,-10771599,-4305031,-9638010,16265036,15721635,683793,-11823784,15723479,-15163481 },
+ { -9660625,12374379,-27006999,-7026148,-7724114,-12314514,11879682,5400171,519526,-1235876 },
+ },
+ {
+ { 22258397,-16332233,-7869817,14613016,-22520255,-2950923,-20353881,7315967,16648397,7605640 },
+ { -8081308,-8464597,-8223311,9719710,19259459,-15348212,23994942,-5281555,-9468848,4763278 },
+ { -21699244,9220969,-15730624,1084137,-25476107,-2852390,31088447,-7764523,-11356529,728112 },
+ },
+ {
+ { 26047220,-11751471,-6900323,-16521798,24092068,9158119,-4273545,-12555558,-29365436,-5498272 },
+ { 17510331,-322857,5854289,8403524,17133918,-3112612,-28111007,12327945,10750447,10014012 },
+ { -10312768,3936952,9156313,-8897683,16498692,-994647,-27481051,-666732,3424691,7540221 },
+ },
+ {
+ { 30322361,-6964110,11361005,-4143317,7433304,4989748,-7071422,-16317219,-9244265,15258046 },
+ { 13054562,-2779497,19155474,469045,-12482797,4566042,5631406,2711395,1062915,-5136345 },
+ { -19240248,-11254599,-29509029,-7499965,-5835763,13005411,-6066489,12194497,32960380,1459310 },
+ },
+},
+{
+ {
+ { 19852034,7027924,23669353,10020366,8586503,-6657907,394197,-6101885,18638003,-11174937 },
+ { 31395534,15098109,26581030,8030562,-16527914,-5007134,9012486,-7584354,-6643087,-5442636 },
+ { -9192165,-2347377,-1997099,4529534,25766844,607986,-13222,9677543,-32294889,-6456008 },
+ },
+ {
+ { -2444496,-149937,29348902,8186665,1873760,12489863,-30934579,-7839692,-7852844,-8138429 },
+ { -15236356,-15433509,7766470,746860,26346930,-10221762,-27333451,10754588,-9431476,5203576 },
+ { 31834314,14135496,-770007,5159118,20917671,-16768096,-7467973,-7337524,31809243,7347066 },
+ },
+ {
+ { -9606723,-11874240,20414459,13033986,13716524,-11691881,19797970,-12211255,15192876,-2087490 },
+ { -12663563,-2181719,1168162,-3804809,26747877,-14138091,10609330,12694420,33473243,-13382104 },
+ { 33184999,11180355,15832085,-11385430,-1633671,225884,15089336,-11023903,-6135662,14480053 },
+ },
+ {
+ { 31308717,-5619998,31030840,-1897099,15674547,-6582883,5496208,13685227,27595050,8737275 },
+ { -20318852,-15150239,10933843,-16178022,8335352,-7546022,-31008351,-12610604,26498114,66511 },
+ { 22644454,-8761729,-16671776,4884562,-3105614,-13559366,30540766,-4286747,-13327787,-7515095 },
+ },
+ {
+ { -28017847,9834845,18617207,-2681312,-3401956,-13307506,8205540,13585437,-17127465,15115439 },
+ { 23711543,-672915,31206561,-8362711,6164647,-9709987,-33535882,-1426096,8236921,16492939 },
+ { -23910559,-13515526,-26299483,-4503841,25005590,-7687270,19574902,10071562,6708380,-6222424 },
+ },
+ {
+ { 2101391,-4930054,19702731,2367575,-15427167,1047675,5301017,9328700,29955601,-11678310 },
+ { 3096359,9271816,-21620864,-15521844,-14847996,-7592937,-25892142,-12635595,-9917575,6216608 },
+ { -32615849,338663,-25195611,2510422,-29213566,-13820213,24822830,-6146567,-26767480,7525079 },
+ },
+ {
+ { -23066649,-13985623,16133487,-7896178,-3389565,778788,-910336,-2782495,-19386633,11994101 },
+ { 21691500,-13624626,-641331,-14367021,3285881,-3483596,-25064666,9718258,-7477437,13381418 },
+ { 18445390,-4202236,14979846,11622458,-1727110,-3582980,23111648,-6375247,28535282,15779576 },
+ },
+ {
+ { 30098053,3089662,-9234387,16662135,-21306940,11308411,-14068454,12021730,9955285,-16303356 },
+ { 9734894,-14576830,-7473633,-9138735,2060392,11313496,-18426029,9924399,20194861,13380996 },
+ { -26378102,-7965207,-22167821,15789297,-18055342,-6168792,-1984914,15707771,26342023,10146099 },
+ },
+},
+{
+ {
+ { -26016874,-219943,21339191,-41388,19745256,-2878700,-29637280,2227040,21612326,-545728 },
+ { -13077387,1184228,23562814,-5970442,-20351244,-6348714,25764461,12243797,-20856566,11649658 },
+ { -10031494,11262626,27384172,2271902,26947504,-15997771,39944,6114064,33514190,2333242 },
+ },
+ {
+ { -21433588,-12421821,8119782,7219913,-21830522,-9016134,-6679750,-12670638,24350578,-13450001 },
+ { -4116307,-11271533,-23886186,4843615,-30088339,690623,-31536088,-10406836,8317860,12352766 },
+ { 18200138,-14475911,-33087759,-2696619,-23702521,-9102511,-23552096,-2287550,20712163,6719373 },
+ },
+ {
+ { 26656208,6075253,-7858556,1886072,-28344043,4262326,11117530,-3763210,26224235,-3297458 },
+ { -17168938,-14854097,-3395676,-16369877,-19954045,14050420,21728352,9493610,18620611,-16428628 },
+ { -13323321,13325349,11432106,5964811,18609221,6062965,-5269471,-9725556,-30701573,-16479657 },
+ },
+ {
+ { -23860538,-11233159,26961357,1640861,-32413112,-16737940,12248509,-5240639,13735342,1934062 },
+ { 25089769,6742589,17081145,-13406266,21909293,-16067981,-15136294,-3765346,-21277997,5473616 },
+ { 31883677,-7961101,1083432,-11572403,22828471,13290673,-7125085,12469656,29111212,-5451014 },
+ },
+ {
+ { 24244947,-15050407,-26262976,2791540,-14997599,16666678,24367466,6388839,-10295587,452383 },
+ { -25640782,-3417841,5217916,16224624,19987036,-4082269,-24236251,-5915248,15766062,8407814 },
+ { -20406999,13990231,15495425,16395525,5377168,15166495,-8917023,-4388953,-8067909,2276718 },
+ },
+ {
+ { 30157918,12924066,-17712050,9245753,19895028,3368142,-23827587,5096219,22740376,-7303417 },
+ { 2041139,-14256350,7783687,13876377,-25946985,-13352459,24051124,13742383,-15637599,13295222 },
+ { 33338237,-8505733,12532113,7977527,9106186,-1715251,-17720195,-4612972,-4451357,-14669444 },
+ },
+ {
+ { -20045281,5454097,-14346548,6447146,28862071,1883651,-2469266,-4141880,7770569,9620597 },
+ { 23208068,7979712,33071466,8149229,1758231,-10834995,30945528,-1694323,-33502340,-14767970 },
+ { 1439958,-16270480,-1079989,-793782,4625402,10647766,-5043801,1220118,30494170,-11440799 },
+ },
+ {
+ { -5037580,-13028295,-2970559,-3061767,15640974,-6701666,-26739026,926050,-1684339,-13333647 },
+ { 13908495,-3549272,30919928,-6273825,-21521863,7989039,9021034,9078865,3353509,4033511 },
+ { -29663431,-15113610,32259991,-344482,24295849,-12912123,23161163,8839127,27485041,7356032 },
+ },
+},
+{
+ {
+ { 9661027,705443,11980065,-5370154,-1628543,14661173,-6346142,2625015,28431036,-16771834 },
+ { -23839233,-8311415,-25945511,7480958,-17681669,-8354183,-22545972,14150565,15970762,4099461 },
+ { 29262576,16756590,26350592,-8793563,8529671,-11208050,13617293,-9937143,11465739,8317062 },
+ },
+ {
+ { -25493081,-6962928,32500200,-9419051,-23038724,-2302222,14898637,3848455,20969334,-5157516 },
+ { -20384450,-14347713,-18336405,13884722,-33039454,2842114,-21610826,-3649888,11177095,14989547 },
+ { -24496721,-11716016,16959896,2278463,12066309,10137771,13515641,2581286,-28487508,9930240 },
+ },
+ {
+ { -17751622,-2097826,16544300,-13009300,-15914807,-14949081,18345767,-13403753,16291481,-5314038 },
+ { -33229194,2553288,32678213,9875984,8534129,6889387,-9676774,6957617,4368891,9788741 },
+ { 16660756,7281060,-10830758,12911820,20108584,-8101676,-21722536,-8613148,16250552,-11111103 },
+ },
+ {
+ { -19765507,2390526,-16551031,14161980,1905286,6414907,4689584,10604807,-30190403,4782747 },
+ { -1354539,14736941,-7367442,-13292886,7710542,-14155590,-9981571,4383045,22546403,437323 },
+ { 31665577,-12180464,-16186830,1491339,-18368625,3294682,27343084,2786261,-30633590,-14097016 },
+ },
+ {
+ { -14467279,-683715,-33374107,7448552,19294360,14334329,-19690631,2355319,-19284671,-6114373 },
+ { 15121312,-15796162,6377020,-6031361,-10798111,-12957845,18952177,15496498,-29380133,11754228 },
+ { -2637277,-13483075,8488727,-14303896,12728761,-1622493,7141596,11724556,22761615,-10134141 },
+ },
+ {
+ { 16918416,11729663,-18083579,3022987,-31015732,-13339659,-28741185,-12227393,32851222,11717399 },
+ { 11166634,7338049,-6722523,4531520,-29468672,-7302055,31474879,3483633,-1193175,-4030831 },
+ { -185635,9921305,31456609,-13536438,-12013818,13348923,33142652,6546660,-19985279,-3948376 },
+ },
+ {
+ { -32460596,11266712,-11197107,-7899103,31703694,3855903,-8537131,-12833048,-30772034,-15486313 },
+ { -18006477,12709068,3991746,-6479188,-21491523,-10550425,-31135347,-16049879,10928917,3011958 },
+ { -6957757,-15594337,31696059,334240,29576716,14796075,-30831056,-12805180,18008031,10258577 },
+ },
+ {
+ { -22448644,15655569,7018479,-4410003,-30314266,-1201591,-1853465,1367120,25127874,6671743 },
+ { 29701166,-14373934,-10878120,9279288,-17568,13127210,21382910,11042292,25838796,4642684 },
+ { -20430234,14955537,-24126347,8124619,-5369288,-5990470,30468147,-13900640,18423289,4177476 },
+ },
+},
diff --git a/src/ext/ed25519/ref10/base.py b/src/ext/ed25519/ref10/base.py
new file mode 100644
index 0000000000..84accc8580
--- /dev/null
+++ b/src/ext/ed25519/ref10/base.py
@@ -0,0 +1,65 @@
+b = 256
+q = 2**255 - 19
+l = 2**252 + 27742317777372353535851937790883648493
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+d = -121665 * inv(121666)
+I = expmod(2,(q-1)/4,q)
+
+def xrecover(y):
+ xx = (y*y-1) * inv(d*y*y+1)
+ x = expmod(xx,(q+3)/8,q)
+ if (x*x - xx) % q != 0: x = (x*I) % q
+ if x % 2 != 0: x = q-x
+ return x
+
+By = 4 * inv(5)
+Bx = xrecover(By)
+B = [Bx % q,By % q]
+
+def edwards(P,Q):
+ x1 = P[0]
+ y1 = P[1]
+ x2 = Q[0]
+ y2 = Q[1]
+ x3 = (x1*y2+x2*y1) * inv(1+d*x1*x2*y1*y2)
+ y3 = (y1*y2+x1*x2) * inv(1-d*x1*x2*y1*y2)
+ return [x3 % q,y3 % q]
+
+def radix255(x):
+ x = x % q
+ if x + x > q: x -= q
+ x = [x,0,0,0,0,0,0,0,0,0]
+ bits = [26,25,26,25,26,25,26,25,26,25]
+ for i in range(9):
+ carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
+ x[i] -= carry * 2**bits[i]
+ x[i + 1] += carry
+ result = ""
+ for i in range(9):
+ result = result+str(x[i])+","
+ result = result+str(x[9])
+ return result
+
+Bi = B
+for i in range(32):
+ print "{"
+ Bij = Bi
+ for j in range(8):
+ print " {"
+ print " {",radix255(Bij[1]+Bij[0]),"},"
+ print " {",radix255(Bij[1]-Bij[0]),"},"
+ print " {",radix255(2*d*Bij[0]*Bij[1]),"},"
+ Bij = edwards(Bij,Bi)
+ print " },"
+ print "},"
+ for k in range(8):
+ Bi = edwards(Bi,Bi)
diff --git a/src/ext/ed25519/ref10/base2.h b/src/ext/ed25519/ref10/base2.h
new file mode 100644
index 0000000000..8c538440ff
--- /dev/null
+++ b/src/ext/ed25519/ref10/base2.h
@@ -0,0 +1,40 @@
+ {
+ { 25967493,-14356035,29566456,3660896,-12694345,4014787,27544626,-11754271,-6079156,2047605 },
+ { -12545711,934262,-2722910,3049990,-727428,9406986,12720692,5043384,19500929,-15469378 },
+ { -8738181,4489570,9688441,-14785194,10184609,-12363380,29287919,11864899,-24514362,-4438546 },
+ },
+ {
+ { 15636291,-9688557,24204773,-7912398,616977,-16685262,27787600,-14772189,28944400,-1550024 },
+ { 16568933,4717097,-11556148,-1102322,15682896,-11807043,16354577,-11775962,7689662,11199574 },
+ { 30464156,-5976125,-11779434,-15670865,23220365,15915852,7512774,10017326,-17749093,-9920357 },
+ },
+ {
+ { 10861363,11473154,27284546,1981175,-30064349,12577861,32867885,14515107,-15438304,10819380 },
+ { 4708026,6336745,20377586,9066809,-11272109,6594696,-25653668,12483688,-12668491,5581306 },
+ { 19563160,16186464,-29386857,4097519,10237984,-4348115,28542350,13850243,-23678021,-15815942 },
+ },
+ {
+ { 5153746,9909285,1723747,-2777874,30523605,5516873,19480852,5230134,-23952439,-15175766 },
+ { -30269007,-3463509,7665486,10083793,28475525,1649722,20654025,16520125,30598449,7715701 },
+ { 28881845,14381568,9657904,3680757,-20181635,7843316,-31400660,1370708,29794553,-1409300 },
+ },
+ {
+ { -22518993,-6692182,14201702,-8745502,-23510406,8844726,18474211,-1361450,-13062696,13821877 },
+ { -6455177,-7839871,3374702,-4740862,-27098617,-10571707,31655028,-7212327,18853322,-14220951 },
+ { 4566830,-12963868,-28974889,-12240689,-7602672,-2830569,-8514358,-10431137,2207753,-3209784 },
+ },
+ {
+ { -25154831,-4185821,29681144,7868801,-6854661,-9423865,-12437364,-663000,-31111463,-16132436 },
+ { 25576264,-2703214,7349804,-11814844,16472782,9300885,3844789,15725684,171356,6466918 },
+ { 23103977,13316479,9739013,-16149481,817875,-15038942,8965339,-14088058,-30714912,16193877 },
+ },
+ {
+ { -33521811,3180713,-2394130,14003687,-16903474,-16270840,17238398,4729455,-18074513,9256800 },
+ { -25182317,-4174131,32336398,5036987,-21236817,11360617,22616405,9761698,-19827198,630305 },
+ { -13720693,2639453,-24237460,-7406481,9494427,-5774029,-6554551,-15960994,-2449256,-14291300 },
+ },
+ {
+ { -3151181,-5046075,9282714,6866145,-31907062,-863023,-18940575,15033784,25105118,-7894876 },
+ { -24326370,15950226,-31801215,-14592823,-11662737,-5090925,1573892,-2625887,2198790,-15804619 },
+ { -3099351,10324967,-2241613,7453183,-5446979,-2735503,-13812022,-16236442,-32461234,-12290683 },
+ },
diff --git a/src/ext/ed25519/ref10/base2.py b/src/ext/ed25519/ref10/base2.py
new file mode 100644
index 0000000000..5e4e8739d0
--- /dev/null
+++ b/src/ext/ed25519/ref10/base2.py
@@ -0,0 +1,60 @@
+b = 256
+q = 2**255 - 19
+l = 2**252 + 27742317777372353535851937790883648493
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+d = -121665 * inv(121666)
+I = expmod(2,(q-1)/4,q)
+
+def xrecover(y):
+ xx = (y*y-1) * inv(d*y*y+1)
+ x = expmod(xx,(q+3)/8,q)
+ if (x*x - xx) % q != 0: x = (x*I) % q
+ if x % 2 != 0: x = q-x
+ return x
+
+By = 4 * inv(5)
+Bx = xrecover(By)
+B = [Bx % q,By % q]
+
+def edwards(P,Q):
+ x1 = P[0]
+ y1 = P[1]
+ x2 = Q[0]
+ y2 = Q[1]
+ x3 = (x1*y2+x2*y1) * inv(1+d*x1*x2*y1*y2)
+ y3 = (y1*y2+x1*x2) * inv(1-d*x1*x2*y1*y2)
+ return [x3 % q,y3 % q]
+
+def radix255(x):
+ x = x % q
+ if x + x > q: x -= q
+ x = [x,0,0,0,0,0,0,0,0,0]
+ bits = [26,25,26,25,26,25,26,25,26,25]
+ for i in range(9):
+ carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
+ x[i] -= carry * 2**bits[i]
+ x[i + 1] += carry
+ result = ""
+ for i in range(9):
+ result = result+str(x[i])+","
+ result = result+str(x[9])
+ return result
+
+Bi = B
+
+for i in range(8):
+ print " {"
+ print " {",radix255(Bi[1]+Bi[0]),"},"
+ print " {",radix255(Bi[1]-Bi[0]),"},"
+ print " {",radix255(2*d*Bi[0]*Bi[1]),"},"
+ print " },"
+ Bi = edwards(B,edwards(B,Bi))
diff --git a/src/ext/ed25519/ref10/blinding.c b/src/ext/ed25519/ref10/blinding.c
new file mode 100644
index 0000000000..4d9a9cbbe7
--- /dev/null
+++ b/src/ext/ed25519/ref10/blinding.c
@@ -0,0 +1,76 @@
+/* Added to ref10 for Tor. We place this in the public domain. Alternatively,
+ * you may have it under the Creative Commons 0 "CC0" license. */
+//#include "fe.h"
+#include "ge.h"
+#include "sc.h"
+#include "crypto_hash_sha512.h"
+#include "ed25519_ref10.h"
+
+#include <string.h>
+#include "crypto.h"
+
+static void
+gettweak(unsigned char *out, const unsigned char *param)
+{
+ const char str[] = "Derive temporary signing key";
+ crypto_hash_sha512_2(out, (const unsigned char*)str, strlen(str), param, 32);
+ out[0] &= 248; /* Is this necessary necessary ? */
+ out[31] &= 63;
+ out[31] |= 64;
+}
+
+int ed25519_ref10_blind_secret_key(unsigned char *out,
+ const unsigned char *inp,
+ const unsigned char *param)
+{
+ const char str[] = "Derive temporary signing key hash input";
+ unsigned char tweak[64];
+ unsigned char zero[32];
+ gettweak(tweak, param);
+
+ memset(zero, 0, 32);
+ sc_muladd(out, inp, tweak, zero);
+
+ crypto_hash_sha512_2(tweak, (const unsigned char *)str, strlen(str),
+ inp+32, 32);
+ memcpy(out+32, tweak, 32);
+
+ memwipe(tweak, 0, sizeof(tweak));
+
+ return 0;
+}
+
+int ed25519_ref10_blind_public_key(unsigned char *out,
+ const unsigned char *inp,
+ const unsigned char *param)
+{
+ unsigned char tweak[64];
+ unsigned char zero[32];
+ unsigned char pkcopy[32];
+ ge_p3 A;
+ ge_p2 Aprime;
+
+ gettweak(tweak, param);
+
+ memset(zero, 0, sizeof(zero));
+ /* Not the greatest implementation of all of this. I wish I had
+ * better-suited primitives to work with here... (but I don't wish that so
+ * strongly that I'm about to code my own ge_scalarmult_vartime). */
+
+ /* We negate the public key first, so that we can pass it to
+ * frombytes_negate_vartime, which negates it again. If there were a
+ * "ge_frombytes", we'd use that, but there isn't. */
+ memcpy(pkcopy, inp, 32);
+ pkcopy[31] ^= (1<<7);
+ ge_frombytes_negate_vartime(&A, pkcopy);
+ /* There isn't a regular ge_scalarmult -- we have to do tweak*A + zero*B. */
+ ge_double_scalarmult_vartime(&Aprime, tweak, &A, zero);
+ ge_tobytes(out, &Aprime);
+
+ memwipe(tweak, 0, sizeof(tweak));
+ memwipe(&A, 0, sizeof(A));
+ memwipe(&Aprime, 0, sizeof(Aprime));
+ memwipe(pkcopy, 0, sizeof(pkcopy));
+
+ return 0;
+}
diff --git a/src/ext/ed25519/ref10/crypto_hash_sha512.h b/src/ext/ed25519/ref10/crypto_hash_sha512.h
new file mode 100644
index 0000000000..0278571522
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_hash_sha512.h
@@ -0,0 +1,30 @@
+/* Added for Tor. */
+#include <openssl/sha.h>
+
+/* Set 'out' to the 512-bit SHA512 hash of the 'len'-byte string in 'inp' */
+#define crypto_hash_sha512(out, inp, len) \
+ SHA512((inp), (len), (out))
+
+/* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1',
+ * concatenated with the 'len2'-byte string in 'inp2'. */
+#define crypto_hash_sha512_2(out, inp1, len1, inp2, len2) \
+ do { \
+ SHA512_CTX sha_ctx_; \
+ SHA512_Init(&sha_ctx_); \
+ SHA512_Update(&sha_ctx_, (inp1), (len1)); \
+ SHA512_Update(&sha_ctx_, (inp2), (len2)); \
+ SHA512_Final((out), &sha_ctx_); \
+ } while(0)
+
+/* Set 'out' to the 512-bit SHA512 hash of the 'len1'-byte string in 'inp1',
+ * concatenated with the 'len2'-byte string in 'inp2', concatenated with
+ * the 'len3'-byte string in 'len3'. */
+#define crypto_hash_sha512_3(out, inp1, len1, inp2, len2, inp3, len3) \
+ do { \
+ SHA512_CTX sha_ctx_; \
+ SHA512_Init(&sha_ctx_); \
+ SHA512_Update(&sha_ctx_, (inp1), (len1)); \
+ SHA512_Update(&sha_ctx_, (inp2), (len2)); \
+ SHA512_Update(&sha_ctx_, (inp3), (len3)); \
+ SHA512_Final((out), &sha_ctx_); \
+ } while(0)
diff --git a/src/ext/ed25519/ref10/crypto_int32.h b/src/ext/ed25519/ref10/crypto_int32.h
new file mode 100644
index 0000000000..dd13c91bd0
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_int32.h
@@ -0,0 +1,25 @@
+/* Added for Tor. */
+
+#ifndef CRYPTO_INT32_H
+#define CRYPTO_INT32_H
+
+#include "torint.h"
+#define crypto_int32 int32_t
+#define crypto_uint32 uint32_t
+
+/*
+ Stop signed left shifts overflowing
+ by using unsigned types for bitwise operations
+ */
+
+#ifndef OVERFLOW_SAFE_SIGNED_LSHIFT
+#define OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, utype, stype) \
+ ((stype)((utype)(s) << (utype)(lshift)))
+#endif
+
+#define SHL32(s, lshift) \
+ OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, crypto_uint32, crypto_int32)
+#define SHL8(s, lshift) \
+ OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, unsigned char, signed char)
+
+#endif /* CRYPTO_INT32_H */
diff --git a/src/ext/ed25519/ref10/crypto_int64.h b/src/ext/ed25519/ref10/crypto_int64.h
new file mode 100644
index 0000000000..46e8852ed0
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_int64.h
@@ -0,0 +1,23 @@
+/* Added for Tor. */
+
+#ifndef CRYPTO_INT64_H
+#define CRYPTO_INT64_H
+
+#include "torint.h"
+#define crypto_int64 int64_t
+#define crypto_uint64 uint64_t
+
+/*
+ Stop signed left shifts overflowing
+ by using unsigned types for bitwise operations
+ */
+
+#ifndef OVERFLOW_SAFE_SIGNED_LSHIFT
+#define OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, utype, stype) \
+ ((stype)((utype)(s) << (utype)(lshift)))
+#endif
+
+#define SHL64(s, lshift) \
+ OVERFLOW_SAFE_SIGNED_LSHIFT(s, lshift, crypto_uint64, crypto_int64)
+
+#endif /* CRYPTO_INT64_H */
diff --git a/src/ext/ed25519/ref10/crypto_sign.h b/src/ext/ed25519/ref10/crypto_sign.h
new file mode 100644
index 0000000000..549626793a
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_sign.h
@@ -0,0 +1,9 @@
+/* Added for Tor */
+#define crypto_sign ed25519_ref10_sign
+#define crypto_sign_keypair ed25519_ref10_keygen
+#define crypto_sign_seckey ed25519_ref10_seckey
+#define crypto_sign_seckey_expand ed25519_ref10_seckey_expand
+#define crypto_sign_pubkey ed25519_ref10_pubkey
+#define crypto_sign_open ed25519_ref10_open
+
+#include "ed25519_ref10.h"
diff --git a/src/ext/ed25519/ref10/crypto_uint32.h b/src/ext/ed25519/ref10/crypto_uint32.h
new file mode 100644
index 0000000000..62655a5b66
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_uint32.h
@@ -0,0 +1,3 @@
+/* Added for Tor. */
+#include "torint.h"
+#define crypto_uint32 uint32_t
diff --git a/src/ext/ed25519/ref10/crypto_uint64.h b/src/ext/ed25519/ref10/crypto_uint64.h
new file mode 100644
index 0000000000..cbda882a6a
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_uint64.h
@@ -0,0 +1,3 @@
+/* Added for Tor. */
+#include "torint.h"
+#define crypto_uint64 uint64_t
diff --git a/src/ext/ed25519/ref10/crypto_verify_32.h b/src/ext/ed25519/ref10/crypto_verify_32.h
new file mode 100644
index 0000000000..0f63efc7a3
--- /dev/null
+++ b/src/ext/ed25519/ref10/crypto_verify_32.h
@@ -0,0 +1,5 @@
+/* Added for Tor. */
+#include "di_ops.h"
+#define crypto_verify_32(a,b) \
+ (! tor_memeq((a), (b), 32))
+
diff --git a/src/ext/ed25519/ref10/d.h b/src/ext/ed25519/ref10/d.h
new file mode 100644
index 0000000000..e25f578350
--- /dev/null
+++ b/src/ext/ed25519/ref10/d.h
@@ -0,0 +1 @@
+-10913610,13857413,-15372611,6949391,114729,-8787816,-6275908,-3247719,-18696448,-12055116
diff --git a/src/ext/ed25519/ref10/d.py b/src/ext/ed25519/ref10/d.py
new file mode 100644
index 0000000000..8995bb86a3
--- /dev/null
+++ b/src/ext/ed25519/ref10/d.py
@@ -0,0 +1,28 @@
+q = 2**255 - 19
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+def radix255(x):
+ x = x % q
+ if x + x > q: x -= q
+ x = [x,0,0,0,0,0,0,0,0,0]
+ bits = [26,25,26,25,26,25,26,25,26,25]
+ for i in range(9):
+ carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
+ x[i] -= carry * 2**bits[i]
+ x[i + 1] += carry
+ result = ""
+ for i in range(9):
+ result = result+str(x[i])+","
+ result = result+str(x[9])
+ return result
+
+d = -121665 * inv(121666)
+print radix255(d)
diff --git a/src/ext/ed25519/ref10/d2.h b/src/ext/ed25519/ref10/d2.h
new file mode 100644
index 0000000000..01aaec7512
--- /dev/null
+++ b/src/ext/ed25519/ref10/d2.h
@@ -0,0 +1 @@
+-21827239,-5839606,-30745221,13898782,229458,15978800,-12551817,-6495438,29715968,9444199
diff --git a/src/ext/ed25519/ref10/d2.py b/src/ext/ed25519/ref10/d2.py
new file mode 100644
index 0000000000..79841758be
--- /dev/null
+++ b/src/ext/ed25519/ref10/d2.py
@@ -0,0 +1,28 @@
+q = 2**255 - 19
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+def radix255(x):
+ x = x % q
+ if x + x > q: x -= q
+ x = [x,0,0,0,0,0,0,0,0,0]
+ bits = [26,25,26,25,26,25,26,25,26,25]
+ for i in range(9):
+ carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
+ x[i] -= carry * 2**bits[i]
+ x[i + 1] += carry
+ result = ""
+ for i in range(9):
+ result = result+str(x[i])+","
+ result = result+str(x[9])
+ return result
+
+d = -121665 * inv(121666)
+print radix255(d*2)
diff --git a/src/ext/ed25519/ref10/ed25519_ref10.h b/src/ext/ed25519/ref10/ed25519_ref10.h
new file mode 100644
index 0000000000..af7e21a2ad
--- /dev/null
+++ b/src/ext/ed25519/ref10/ed25519_ref10.h
@@ -0,0 +1,30 @@
+/* Added for Tor */
+#ifndef SRC_EXT_ED25519_REF10_H_INCLUDED_
+#define SRC_EXT_ED25519_REF10_H_INCLUDED_
+#include <torint.h>
+
+int ed25519_ref10_seckey(unsigned char *sk);
+int ed25519_ref10_seckey_expand(unsigned char *sk, const unsigned char *sk_seed);
+int ed25519_ref10_pubkey(unsigned char *pk,const unsigned char *sk);
+int ed25519_ref10_keygen(unsigned char *pk,unsigned char *sk);
+int ed25519_ref10_open(
+ const unsigned char *signature,
+ const unsigned char *m, size_t mlen,
+ const unsigned char *pk);
+int ed25519_ref10_sign(
+ unsigned char *sig,
+ const unsigned char *m, size_t mlen,
+ const unsigned char *sk, const unsigned char *pk);
+
+/* Added in Tor */
+int ed25519_ref10_pubkey_from_curve25519_pubkey(unsigned char *out,
+ const unsigned char *inp,
+ int signbit);
+int ed25519_ref10_blind_secret_key(unsigned char *out,
+ const unsigned char *inp,
+ const unsigned char *param);
+int ed25519_ref10_blind_public_key(unsigned char *out,
+ const unsigned char *inp,
+ const unsigned char *param);
+
+#endif
diff --git a/src/ext/ed25519/ref10/fe.h b/src/ext/ed25519/ref10/fe.h
new file mode 100644
index 0000000000..60c308ba46
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe.h
@@ -0,0 +1,56 @@
+#ifndef FE_H
+#define FE_H
+
+#include "crypto_int32.h"
+
+typedef crypto_int32 fe[10];
+
+/*
+fe means field element.
+Here the field is \Z/(2^255-19).
+An element t, entries t[0]...t[9], represents the integer
+t[0]+2^26 t[1]+2^51 t[2]+2^77 t[3]+2^102 t[4]+...+2^230 t[9].
+Bounds on each t[i] vary depending on context.
+*/
+
+#define fe_frombytes crypto_sign_ed25519_ref10_fe_frombytes
+#define fe_tobytes crypto_sign_ed25519_ref10_fe_tobytes
+#define fe_copy crypto_sign_ed25519_ref10_fe_copy
+#define fe_isnonzero crypto_sign_ed25519_ref10_fe_isnonzero
+#define fe_isnegative crypto_sign_ed25519_ref10_fe_isnegative
+#define fe_0 crypto_sign_ed25519_ref10_fe_0
+#define fe_1 crypto_sign_ed25519_ref10_fe_1
+#define fe_cswap crypto_sign_ed25519_ref10_fe_cswap
+#define fe_cmov crypto_sign_ed25519_ref10_fe_cmov
+#define fe_add crypto_sign_ed25519_ref10_fe_add
+#define fe_sub crypto_sign_ed25519_ref10_fe_sub
+#define fe_neg crypto_sign_ed25519_ref10_fe_neg
+#define fe_mul crypto_sign_ed25519_ref10_fe_mul
+#define fe_sq crypto_sign_ed25519_ref10_fe_sq
+#define fe_sq2 crypto_sign_ed25519_ref10_fe_sq2
+#define fe_mul121666 crypto_sign_ed25519_ref10_fe_mul121666
+#define fe_invert crypto_sign_ed25519_ref10_fe_invert
+#define fe_pow22523 crypto_sign_ed25519_ref10_fe_pow22523
+
+extern void fe_frombytes(fe,const unsigned char *);
+extern void fe_tobytes(unsigned char *,const fe);
+
+extern void fe_copy(fe,const fe);
+extern int fe_isnonzero(const fe);
+extern int fe_isnegative(const fe);
+extern void fe_0(fe);
+extern void fe_1(fe);
+extern void fe_cswap(fe,fe,unsigned int);
+extern void fe_cmov(fe,const fe,unsigned int);
+
+extern void fe_add(fe,const fe,const fe);
+extern void fe_sub(fe,const fe,const fe);
+extern void fe_neg(fe,const fe);
+extern void fe_mul(fe,const fe,const fe);
+extern void fe_sq(fe,const fe);
+extern void fe_sq2(fe,const fe);
+extern void fe_mul121666(fe,const fe);
+extern void fe_invert(fe,const fe);
+extern void fe_pow22523(fe,const fe);
+
+#endif
diff --git a/src/ext/ed25519/ref10/fe_0.c b/src/ext/ed25519/ref10/fe_0.c
new file mode 100644
index 0000000000..ec879d7337
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_0.c
@@ -0,0 +1,19 @@
+#include "fe.h"
+
+/*
+h = 0
+*/
+
+void fe_0(fe h)
+{
+ h[0] = 0;
+ h[1] = 0;
+ h[2] = 0;
+ h[3] = 0;
+ h[4] = 0;
+ h[5] = 0;
+ h[6] = 0;
+ h[7] = 0;
+ h[8] = 0;
+ h[9] = 0;
+}
diff --git a/src/ext/ed25519/ref10/fe_1.c b/src/ext/ed25519/ref10/fe_1.c
new file mode 100644
index 0000000000..8cf7784844
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_1.c
@@ -0,0 +1,19 @@
+#include "fe.h"
+
+/*
+h = 1
+*/
+
+void fe_1(fe h)
+{
+ h[0] = 1;
+ h[1] = 0;
+ h[2] = 0;
+ h[3] = 0;
+ h[4] = 0;
+ h[5] = 0;
+ h[6] = 0;
+ h[7] = 0;
+ h[8] = 0;
+ h[9] = 0;
+}
diff --git a/src/ext/ed25519/ref10/fe_add.c b/src/ext/ed25519/ref10/fe_add.c
new file mode 100644
index 0000000000..e6a81da202
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_add.c
@@ -0,0 +1,57 @@
+#include "fe.h"
+
+/*
+h = f + g
+Can overlap h with f or g.
+
+Preconditions:
+ |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+ |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+
+Postconditions:
+ |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
+*/
+
+void fe_add(fe h,const fe f,const fe g)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 g0 = g[0];
+ crypto_int32 g1 = g[1];
+ crypto_int32 g2 = g[2];
+ crypto_int32 g3 = g[3];
+ crypto_int32 g4 = g[4];
+ crypto_int32 g5 = g[5];
+ crypto_int32 g6 = g[6];
+ crypto_int32 g7 = g[7];
+ crypto_int32 g8 = g[8];
+ crypto_int32 g9 = g[9];
+ crypto_int32 h0 = f0 + g0;
+ crypto_int32 h1 = f1 + g1;
+ crypto_int32 h2 = f2 + g2;
+ crypto_int32 h3 = f3 + g3;
+ crypto_int32 h4 = f4 + g4;
+ crypto_int32 h5 = f5 + g5;
+ crypto_int32 h6 = f6 + g6;
+ crypto_int32 h7 = f7 + g7;
+ crypto_int32 h8 = f8 + g8;
+ crypto_int32 h9 = f9 + g9;
+ h[0] = h0;
+ h[1] = h1;
+ h[2] = h2;
+ h[3] = h3;
+ h[4] = h4;
+ h[5] = h5;
+ h[6] = h6;
+ h[7] = h7;
+ h[8] = h8;
+ h[9] = h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_cmov.c b/src/ext/ed25519/ref10/fe_cmov.c
new file mode 100644
index 0000000000..8ca584fb19
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_cmov.c
@@ -0,0 +1,63 @@
+#include "fe.h"
+
+/*
+Replace (f,g) with (g,g) if b == 1;
+replace (f,g) with (f,g) if b == 0.
+
+Preconditions: b in {0,1}.
+*/
+
+void fe_cmov(fe f,const fe g,unsigned int b)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 g0 = g[0];
+ crypto_int32 g1 = g[1];
+ crypto_int32 g2 = g[2];
+ crypto_int32 g3 = g[3];
+ crypto_int32 g4 = g[4];
+ crypto_int32 g5 = g[5];
+ crypto_int32 g6 = g[6];
+ crypto_int32 g7 = g[7];
+ crypto_int32 g8 = g[8];
+ crypto_int32 g9 = g[9];
+ crypto_int32 x0 = f0 ^ g0;
+ crypto_int32 x1 = f1 ^ g1;
+ crypto_int32 x2 = f2 ^ g2;
+ crypto_int32 x3 = f3 ^ g3;
+ crypto_int32 x4 = f4 ^ g4;
+ crypto_int32 x5 = f5 ^ g5;
+ crypto_int32 x6 = f6 ^ g6;
+ crypto_int32 x7 = f7 ^ g7;
+ crypto_int32 x8 = f8 ^ g8;
+ crypto_int32 x9 = f9 ^ g9;
+ b = -b;
+ x0 &= b;
+ x1 &= b;
+ x2 &= b;
+ x3 &= b;
+ x4 &= b;
+ x5 &= b;
+ x6 &= b;
+ x7 &= b;
+ x8 &= b;
+ x9 &= b;
+ f[0] = f0 ^ x0;
+ f[1] = f1 ^ x1;
+ f[2] = f2 ^ x2;
+ f[3] = f3 ^ x3;
+ f[4] = f4 ^ x4;
+ f[5] = f5 ^ x5;
+ f[6] = f6 ^ x6;
+ f[7] = f7 ^ x7;
+ f[8] = f8 ^ x8;
+ f[9] = f9 ^ x9;
+}
diff --git a/src/ext/ed25519/ref10/fe_copy.c b/src/ext/ed25519/ref10/fe_copy.c
new file mode 100644
index 0000000000..9c5bf865a2
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_copy.c
@@ -0,0 +1,29 @@
+#include "fe.h"
+
+/*
+h = f
+*/
+
+void fe_copy(fe h,const fe f)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ h[0] = f0;
+ h[1] = f1;
+ h[2] = f2;
+ h[3] = f3;
+ h[4] = f4;
+ h[5] = f5;
+ h[6] = f6;
+ h[7] = f7;
+ h[8] = f8;
+ h[9] = f9;
+}
diff --git a/src/ext/ed25519/ref10/fe_frombytes.c b/src/ext/ed25519/ref10/fe_frombytes.c
new file mode 100644
index 0000000000..98b8e5f7c1
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_frombytes.c
@@ -0,0 +1,73 @@
+#include "fe.h"
+#include "crypto_int64.h"
+#include "crypto_uint64.h"
+
+static crypto_uint64 load_3(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ return result;
+}
+
+static crypto_uint64 load_4(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ result |= ((crypto_uint64) in[3]) << 24;
+ return result;
+}
+
+/*
+Ignores top bit of h.
+*/
+
+void fe_frombytes(fe h,const unsigned char *s)
+{
+ crypto_int64 h0 = load_4(s);
+ crypto_int64 h1 = load_3(s + 4) << 6;
+ crypto_int64 h2 = load_3(s + 7) << 5;
+ crypto_int64 h3 = load_3(s + 10) << 3;
+ crypto_int64 h4 = load_3(s + 13) << 2;
+ crypto_int64 h5 = load_4(s + 16);
+ crypto_int64 h6 = load_3(s + 20) << 7;
+ crypto_int64 h7 = load_3(s + 23) << 5;
+ crypto_int64 h8 = load_3(s + 26) << 4;
+ crypto_int64 h9 = (load_3(s + 29) & 8388607) << 2;
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+
+ carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= SHL64(carry9,25);
+ carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= SHL64(carry1,25);
+ carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= SHL64(carry3,25);
+ carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= SHL64(carry5,25);
+ carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= SHL64(carry7,25);
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+ carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= SHL64(carry2,26);
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+ carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= SHL64(carry6,26);
+ carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= SHL64(carry8,26);
+
+ h[0] = (crypto_int32) h0;
+ h[1] = (crypto_int32) h1;
+ h[2] = (crypto_int32) h2;
+ h[3] = (crypto_int32) h3;
+ h[4] = (crypto_int32) h4;
+ h[5] = (crypto_int32) h5;
+ h[6] = (crypto_int32) h6;
+ h[7] = (crypto_int32) h7;
+ h[8] = (crypto_int32) h8;
+ h[9] = (crypto_int32) h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_invert.c b/src/ext/ed25519/ref10/fe_invert.c
new file mode 100644
index 0000000000..bcfdb8ff87
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_invert.c
@@ -0,0 +1,14 @@
+#include "fe.h"
+
+void fe_invert(fe out,const fe z)
+{
+ fe t0;
+ fe t1;
+ fe t2;
+ fe t3;
+ int i;
+
+#include "pow225521.h"
+
+ return;
+}
diff --git a/src/ext/ed25519/ref10/fe_isnegative.c b/src/ext/ed25519/ref10/fe_isnegative.c
new file mode 100644
index 0000000000..3b2c8b8d52
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_isnegative.c
@@ -0,0 +1,16 @@
+#include "fe.h"
+
+/*
+return 1 if f is in {1,3,5,...,q-2}
+return 0 if f is in {0,2,4,...,q-1}
+
+Preconditions:
+ |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
+*/
+
+int fe_isnegative(const fe f)
+{
+ unsigned char s[32];
+ fe_tobytes(s,f);
+ return s[0] & 1;
+}
diff --git a/src/ext/ed25519/ref10/fe_isnonzero.c b/src/ext/ed25519/ref10/fe_isnonzero.c
new file mode 100644
index 0000000000..47568001ce
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_isnonzero.c
@@ -0,0 +1,19 @@
+#include "fe.h"
+#include "crypto_verify_32.h"
+
+/*
+return 1 if f == 0
+return 0 if f != 0
+
+Preconditions:
+ |f| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
+*/
+
+static const unsigned char zero[32];
+
+int fe_isnonzero(const fe f)
+{
+ unsigned char s[32];
+ fe_tobytes(s,f);
+ return crypto_verify_32(s,zero);
+}
diff --git a/src/ext/ed25519/ref10/fe_mul.c b/src/ext/ed25519/ref10/fe_mul.c
new file mode 100644
index 0000000000..ace63e64c1
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_mul.c
@@ -0,0 +1,253 @@
+#include "fe.h"
+#include "crypto_int64.h"
+
+/*
+h = f * g
+Can overlap h with f or g.
+
+Preconditions:
+ |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
+ |g| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
+
+Postconditions:
+ |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
+*/
+
+/*
+Notes on implementation strategy:
+
+Using schoolbook multiplication.
+Karatsuba would save a little in some cost models.
+
+Most multiplications by 2 and 19 are 32-bit precomputations;
+cheaper than 64-bit postcomputations.
+
+There is one remaining multiplication by 19 in the carry chain;
+one *19 precomputation can be merged into this,
+but the resulting data flow is considerably less clean.
+
+There are 12 carries below.
+10 of them are 2-way parallelizable and vectorizable.
+Can get away with 11 carries, but then data flow is much deeper.
+
+With tighter constraints on inputs can squeeze carries into int32.
+*/
+
+void fe_mul(fe h,const fe f,const fe g)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 g0 = g[0];
+ crypto_int32 g1 = g[1];
+ crypto_int32 g2 = g[2];
+ crypto_int32 g3 = g[3];
+ crypto_int32 g4 = g[4];
+ crypto_int32 g5 = g[5];
+ crypto_int32 g6 = g[6];
+ crypto_int32 g7 = g[7];
+ crypto_int32 g8 = g[8];
+ crypto_int32 g9 = g[9];
+ crypto_int32 g1_19 = 19 * g1; /* 1.959375*2^29 */
+ crypto_int32 g2_19 = 19 * g2; /* 1.959375*2^30; still ok */
+ crypto_int32 g3_19 = 19 * g3;
+ crypto_int32 g4_19 = 19 * g4;
+ crypto_int32 g5_19 = 19 * g5;
+ crypto_int32 g6_19 = 19 * g6;
+ crypto_int32 g7_19 = 19 * g7;
+ crypto_int32 g8_19 = 19 * g8;
+ crypto_int32 g9_19 = 19 * g9;
+ crypto_int32 f1_2 = 2 * f1;
+ crypto_int32 f3_2 = 2 * f3;
+ crypto_int32 f5_2 = 2 * f5;
+ crypto_int32 f7_2 = 2 * f7;
+ crypto_int32 f9_2 = 2 * f9;
+ crypto_int64 f0g0 = f0 * (crypto_int64) g0;
+ crypto_int64 f0g1 = f0 * (crypto_int64) g1;
+ crypto_int64 f0g2 = f0 * (crypto_int64) g2;
+ crypto_int64 f0g3 = f0 * (crypto_int64) g3;
+ crypto_int64 f0g4 = f0 * (crypto_int64) g4;
+ crypto_int64 f0g5 = f0 * (crypto_int64) g5;
+ crypto_int64 f0g6 = f0 * (crypto_int64) g6;
+ crypto_int64 f0g7 = f0 * (crypto_int64) g7;
+ crypto_int64 f0g8 = f0 * (crypto_int64) g8;
+ crypto_int64 f0g9 = f0 * (crypto_int64) g9;
+ crypto_int64 f1g0 = f1 * (crypto_int64) g0;
+ crypto_int64 f1g1_2 = f1_2 * (crypto_int64) g1;
+ crypto_int64 f1g2 = f1 * (crypto_int64) g2;
+ crypto_int64 f1g3_2 = f1_2 * (crypto_int64) g3;
+ crypto_int64 f1g4 = f1 * (crypto_int64) g4;
+ crypto_int64 f1g5_2 = f1_2 * (crypto_int64) g5;
+ crypto_int64 f1g6 = f1 * (crypto_int64) g6;
+ crypto_int64 f1g7_2 = f1_2 * (crypto_int64) g7;
+ crypto_int64 f1g8 = f1 * (crypto_int64) g8;
+ crypto_int64 f1g9_38 = f1_2 * (crypto_int64) g9_19;
+ crypto_int64 f2g0 = f2 * (crypto_int64) g0;
+ crypto_int64 f2g1 = f2 * (crypto_int64) g1;
+ crypto_int64 f2g2 = f2 * (crypto_int64) g2;
+ crypto_int64 f2g3 = f2 * (crypto_int64) g3;
+ crypto_int64 f2g4 = f2 * (crypto_int64) g4;
+ crypto_int64 f2g5 = f2 * (crypto_int64) g5;
+ crypto_int64 f2g6 = f2 * (crypto_int64) g6;
+ crypto_int64 f2g7 = f2 * (crypto_int64) g7;
+ crypto_int64 f2g8_19 = f2 * (crypto_int64) g8_19;
+ crypto_int64 f2g9_19 = f2 * (crypto_int64) g9_19;
+ crypto_int64 f3g0 = f3 * (crypto_int64) g0;
+ crypto_int64 f3g1_2 = f3_2 * (crypto_int64) g1;
+ crypto_int64 f3g2 = f3 * (crypto_int64) g2;
+ crypto_int64 f3g3_2 = f3_2 * (crypto_int64) g3;
+ crypto_int64 f3g4 = f3 * (crypto_int64) g4;
+ crypto_int64 f3g5_2 = f3_2 * (crypto_int64) g5;
+ crypto_int64 f3g6 = f3 * (crypto_int64) g6;
+ crypto_int64 f3g7_38 = f3_2 * (crypto_int64) g7_19;
+ crypto_int64 f3g8_19 = f3 * (crypto_int64) g8_19;
+ crypto_int64 f3g9_38 = f3_2 * (crypto_int64) g9_19;
+ crypto_int64 f4g0 = f4 * (crypto_int64) g0;
+ crypto_int64 f4g1 = f4 * (crypto_int64) g1;
+ crypto_int64 f4g2 = f4 * (crypto_int64) g2;
+ crypto_int64 f4g3 = f4 * (crypto_int64) g3;
+ crypto_int64 f4g4 = f4 * (crypto_int64) g4;
+ crypto_int64 f4g5 = f4 * (crypto_int64) g5;
+ crypto_int64 f4g6_19 = f4 * (crypto_int64) g6_19;
+ crypto_int64 f4g7_19 = f4 * (crypto_int64) g7_19;
+ crypto_int64 f4g8_19 = f4 * (crypto_int64) g8_19;
+ crypto_int64 f4g9_19 = f4 * (crypto_int64) g9_19;
+ crypto_int64 f5g0 = f5 * (crypto_int64) g0;
+ crypto_int64 f5g1_2 = f5_2 * (crypto_int64) g1;
+ crypto_int64 f5g2 = f5 * (crypto_int64) g2;
+ crypto_int64 f5g3_2 = f5_2 * (crypto_int64) g3;
+ crypto_int64 f5g4 = f5 * (crypto_int64) g4;
+ crypto_int64 f5g5_38 = f5_2 * (crypto_int64) g5_19;
+ crypto_int64 f5g6_19 = f5 * (crypto_int64) g6_19;
+ crypto_int64 f5g7_38 = f5_2 * (crypto_int64) g7_19;
+ crypto_int64 f5g8_19 = f5 * (crypto_int64) g8_19;
+ crypto_int64 f5g9_38 = f5_2 * (crypto_int64) g9_19;
+ crypto_int64 f6g0 = f6 * (crypto_int64) g0;
+ crypto_int64 f6g1 = f6 * (crypto_int64) g1;
+ crypto_int64 f6g2 = f6 * (crypto_int64) g2;
+ crypto_int64 f6g3 = f6 * (crypto_int64) g3;
+ crypto_int64 f6g4_19 = f6 * (crypto_int64) g4_19;
+ crypto_int64 f6g5_19 = f6 * (crypto_int64) g5_19;
+ crypto_int64 f6g6_19 = f6 * (crypto_int64) g6_19;
+ crypto_int64 f6g7_19 = f6 * (crypto_int64) g7_19;
+ crypto_int64 f6g8_19 = f6 * (crypto_int64) g8_19;
+ crypto_int64 f6g9_19 = f6 * (crypto_int64) g9_19;
+ crypto_int64 f7g0 = f7 * (crypto_int64) g0;
+ crypto_int64 f7g1_2 = f7_2 * (crypto_int64) g1;
+ crypto_int64 f7g2 = f7 * (crypto_int64) g2;
+ crypto_int64 f7g3_38 = f7_2 * (crypto_int64) g3_19;
+ crypto_int64 f7g4_19 = f7 * (crypto_int64) g4_19;
+ crypto_int64 f7g5_38 = f7_2 * (crypto_int64) g5_19;
+ crypto_int64 f7g6_19 = f7 * (crypto_int64) g6_19;
+ crypto_int64 f7g7_38 = f7_2 * (crypto_int64) g7_19;
+ crypto_int64 f7g8_19 = f7 * (crypto_int64) g8_19;
+ crypto_int64 f7g9_38 = f7_2 * (crypto_int64) g9_19;
+ crypto_int64 f8g0 = f8 * (crypto_int64) g0;
+ crypto_int64 f8g1 = f8 * (crypto_int64) g1;
+ crypto_int64 f8g2_19 = f8 * (crypto_int64) g2_19;
+ crypto_int64 f8g3_19 = f8 * (crypto_int64) g3_19;
+ crypto_int64 f8g4_19 = f8 * (crypto_int64) g4_19;
+ crypto_int64 f8g5_19 = f8 * (crypto_int64) g5_19;
+ crypto_int64 f8g6_19 = f8 * (crypto_int64) g6_19;
+ crypto_int64 f8g7_19 = f8 * (crypto_int64) g7_19;
+ crypto_int64 f8g8_19 = f8 * (crypto_int64) g8_19;
+ crypto_int64 f8g9_19 = f8 * (crypto_int64) g9_19;
+ crypto_int64 f9g0 = f9 * (crypto_int64) g0;
+ crypto_int64 f9g1_38 = f9_2 * (crypto_int64) g1_19;
+ crypto_int64 f9g2_19 = f9 * (crypto_int64) g2_19;
+ crypto_int64 f9g3_38 = f9_2 * (crypto_int64) g3_19;
+ crypto_int64 f9g4_19 = f9 * (crypto_int64) g4_19;
+ crypto_int64 f9g5_38 = f9_2 * (crypto_int64) g5_19;
+ crypto_int64 f9g6_19 = f9 * (crypto_int64) g6_19;
+ crypto_int64 f9g7_38 = f9_2 * (crypto_int64) g7_19;
+ crypto_int64 f9g8_19 = f9 * (crypto_int64) g8_19;
+ crypto_int64 f9g9_38 = f9_2 * (crypto_int64) g9_19;
+ crypto_int64 h0 = f0g0+f1g9_38+f2g8_19+f3g7_38+f4g6_19+f5g5_38+f6g4_19+f7g3_38+f8g2_19+f9g1_38;
+ crypto_int64 h1 = f0g1+f1g0 +f2g9_19+f3g8_19+f4g7_19+f5g6_19+f6g5_19+f7g4_19+f8g3_19+f9g2_19;
+ crypto_int64 h2 = f0g2+f1g1_2 +f2g0 +f3g9_38+f4g8_19+f5g7_38+f6g6_19+f7g5_38+f8g4_19+f9g3_38;
+ crypto_int64 h3 = f0g3+f1g2 +f2g1 +f3g0 +f4g9_19+f5g8_19+f6g7_19+f7g6_19+f8g5_19+f9g4_19;
+ crypto_int64 h4 = f0g4+f1g3_2 +f2g2 +f3g1_2 +f4g0 +f5g9_38+f6g8_19+f7g7_38+f8g6_19+f9g5_38;
+ crypto_int64 h5 = f0g5+f1g4 +f2g3 +f3g2 +f4g1 +f5g0 +f6g9_19+f7g8_19+f8g7_19+f9g6_19;
+ crypto_int64 h6 = f0g6+f1g5_2 +f2g4 +f3g3_2 +f4g2 +f5g1_2 +f6g0 +f7g9_38+f8g8_19+f9g7_38;
+ crypto_int64 h7 = f0g7+f1g6 +f2g5 +f3g4 +f4g3 +f5g2 +f6g1 +f7g0 +f8g9_19+f9g8_19;
+ crypto_int64 h8 = f0g8+f1g7_2 +f2g6 +f3g5_2 +f4g4 +f5g3_2 +f6g2 +f7g1_2 +f8g0 +f9g9_38;
+ crypto_int64 h9 = f0g9+f1g8 +f2g7 +f3g6 +f4g5 +f5g4 +f6g3 +f7g2 +f8g1 +f9g0 ;
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+
+ /*
+ |h0| <= (1.65*1.65*2^52*(1+19+19+19+19)+1.65*1.65*2^50*(38+38+38+38+38))
+ i.e. |h0| <= 1.4*2^60; narrower ranges for h2, h4, h6, h8
+ |h1| <= (1.65*1.65*2^51*(1+1+19+19+19+19+19+19+19+19))
+ i.e. |h1| <= 1.7*2^59; narrower ranges for h3, h5, h7, h9
+ */
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+ /* |h0| <= 2^25 */
+ /* |h4| <= 2^25 */
+ /* |h1| <= 1.71*2^59 */
+ /* |h5| <= 1.71*2^59 */
+
+ carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= SHL64(carry1,25);
+ carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= SHL64(carry5,25);
+ /* |h1| <= 2^24; from now on fits into int32 */
+ /* |h5| <= 2^24; from now on fits into int32 */
+ /* |h2| <= 1.41*2^60 */
+ /* |h6| <= 1.41*2^60 */
+
+ carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= SHL64(carry2,26);
+ carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= SHL64(carry6,26);
+ /* |h2| <= 2^25; from now on fits into int32 unchanged */
+ /* |h6| <= 2^25; from now on fits into int32 unchanged */
+ /* |h3| <= 1.71*2^59 */
+ /* |h7| <= 1.71*2^59 */
+
+ carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= SHL64(carry3,25);
+ carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= SHL64(carry7,25);
+ /* |h3| <= 2^24; from now on fits into int32 unchanged */
+ /* |h7| <= 2^24; from now on fits into int32 unchanged */
+ /* |h4| <= 1.72*2^34 */
+ /* |h8| <= 1.41*2^60 */
+
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+ carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= SHL64(carry8,26);
+ /* |h4| <= 2^25; from now on fits into int32 unchanged */
+ /* |h8| <= 2^25; from now on fits into int32 unchanged */
+ /* |h5| <= 1.01*2^24 */
+ /* |h9| <= 1.71*2^59 */
+
+ carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= SHL64(carry9,25);
+ /* |h9| <= 2^24; from now on fits into int32 unchanged */
+ /* |h0| <= 1.1*2^39 */
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+ /* |h0| <= 2^25; from now on fits into int32 unchanged */
+ /* |h1| <= 1.01*2^24 */
+
+ h[0] = (crypto_int32) h0;
+ h[1] = (crypto_int32) h1;
+ h[2] = (crypto_int32) h2;
+ h[3] = (crypto_int32) h3;
+ h[4] = (crypto_int32) h4;
+ h[5] = (crypto_int32) h5;
+ h[6] = (crypto_int32) h6;
+ h[7] = (crypto_int32) h7;
+ h[8] = (crypto_int32) h8;
+ h[9] = (crypto_int32) h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_neg.c b/src/ext/ed25519/ref10/fe_neg.c
new file mode 100644
index 0000000000..2078ce5284
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_neg.c
@@ -0,0 +1,45 @@
+#include "fe.h"
+
+/*
+h = -f
+
+Preconditions:
+ |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+
+Postconditions:
+ |h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+*/
+
+void fe_neg(fe h,const fe f)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 h0 = -f0;
+ crypto_int32 h1 = -f1;
+ crypto_int32 h2 = -f2;
+ crypto_int32 h3 = -f3;
+ crypto_int32 h4 = -f4;
+ crypto_int32 h5 = -f5;
+ crypto_int32 h6 = -f6;
+ crypto_int32 h7 = -f7;
+ crypto_int32 h8 = -f8;
+ crypto_int32 h9 = -f9;
+ h[0] = h0;
+ h[1] = h1;
+ h[2] = h2;
+ h[3] = h3;
+ h[4] = h4;
+ h[5] = h5;
+ h[6] = h6;
+ h[7] = h7;
+ h[8] = h8;
+ h[9] = h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_pow22523.c b/src/ext/ed25519/ref10/fe_pow22523.c
new file mode 100644
index 0000000000..56675a5902
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_pow22523.c
@@ -0,0 +1,13 @@
+#include "fe.h"
+
+void fe_pow22523(fe out,const fe z)
+{
+ fe t0;
+ fe t1;
+ fe t2;
+ int i;
+
+#include "pow22523.h"
+
+ return;
+}
diff --git a/src/ext/ed25519/ref10/fe_sq.c b/src/ext/ed25519/ref10/fe_sq.c
new file mode 100644
index 0000000000..0022a17510
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_sq.c
@@ -0,0 +1,149 @@
+#include "fe.h"
+#include "crypto_int64.h"
+
+/*
+h = f * f
+Can overlap h with f.
+
+Preconditions:
+ |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
+
+Postconditions:
+ |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
+*/
+
+/*
+See fe_mul.c for discussion of implementation strategy.
+*/
+
+void fe_sq(fe h,const fe f)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 f0_2 = 2 * f0;
+ crypto_int32 f1_2 = 2 * f1;
+ crypto_int32 f2_2 = 2 * f2;
+ crypto_int32 f3_2 = 2 * f3;
+ crypto_int32 f4_2 = 2 * f4;
+ crypto_int32 f5_2 = 2 * f5;
+ crypto_int32 f6_2 = 2 * f6;
+ crypto_int32 f7_2 = 2 * f7;
+ crypto_int32 f5_38 = 38 * f5; /* 1.959375*2^30 */
+ crypto_int32 f6_19 = 19 * f6; /* 1.959375*2^30 */
+ crypto_int32 f7_38 = 38 * f7; /* 1.959375*2^30 */
+ crypto_int32 f8_19 = 19 * f8; /* 1.959375*2^30 */
+ crypto_int32 f9_38 = 38 * f9; /* 1.959375*2^30 */
+ crypto_int64 f0f0 = f0 * (crypto_int64) f0;
+ crypto_int64 f0f1_2 = f0_2 * (crypto_int64) f1;
+ crypto_int64 f0f2_2 = f0_2 * (crypto_int64) f2;
+ crypto_int64 f0f3_2 = f0_2 * (crypto_int64) f3;
+ crypto_int64 f0f4_2 = f0_2 * (crypto_int64) f4;
+ crypto_int64 f0f5_2 = f0_2 * (crypto_int64) f5;
+ crypto_int64 f0f6_2 = f0_2 * (crypto_int64) f6;
+ crypto_int64 f0f7_2 = f0_2 * (crypto_int64) f7;
+ crypto_int64 f0f8_2 = f0_2 * (crypto_int64) f8;
+ crypto_int64 f0f9_2 = f0_2 * (crypto_int64) f9;
+ crypto_int64 f1f1_2 = f1_2 * (crypto_int64) f1;
+ crypto_int64 f1f2_2 = f1_2 * (crypto_int64) f2;
+ crypto_int64 f1f3_4 = f1_2 * (crypto_int64) f3_2;
+ crypto_int64 f1f4_2 = f1_2 * (crypto_int64) f4;
+ crypto_int64 f1f5_4 = f1_2 * (crypto_int64) f5_2;
+ crypto_int64 f1f6_2 = f1_2 * (crypto_int64) f6;
+ crypto_int64 f1f7_4 = f1_2 * (crypto_int64) f7_2;
+ crypto_int64 f1f8_2 = f1_2 * (crypto_int64) f8;
+ crypto_int64 f1f9_76 = f1_2 * (crypto_int64) f9_38;
+ crypto_int64 f2f2 = f2 * (crypto_int64) f2;
+ crypto_int64 f2f3_2 = f2_2 * (crypto_int64) f3;
+ crypto_int64 f2f4_2 = f2_2 * (crypto_int64) f4;
+ crypto_int64 f2f5_2 = f2_2 * (crypto_int64) f5;
+ crypto_int64 f2f6_2 = f2_2 * (crypto_int64) f6;
+ crypto_int64 f2f7_2 = f2_2 * (crypto_int64) f7;
+ crypto_int64 f2f8_38 = f2_2 * (crypto_int64) f8_19;
+ crypto_int64 f2f9_38 = f2 * (crypto_int64) f9_38;
+ crypto_int64 f3f3_2 = f3_2 * (crypto_int64) f3;
+ crypto_int64 f3f4_2 = f3_2 * (crypto_int64) f4;
+ crypto_int64 f3f5_4 = f3_2 * (crypto_int64) f5_2;
+ crypto_int64 f3f6_2 = f3_2 * (crypto_int64) f6;
+ crypto_int64 f3f7_76 = f3_2 * (crypto_int64) f7_38;
+ crypto_int64 f3f8_38 = f3_2 * (crypto_int64) f8_19;
+ crypto_int64 f3f9_76 = f3_2 * (crypto_int64) f9_38;
+ crypto_int64 f4f4 = f4 * (crypto_int64) f4;
+ crypto_int64 f4f5_2 = f4_2 * (crypto_int64) f5;
+ crypto_int64 f4f6_38 = f4_2 * (crypto_int64) f6_19;
+ crypto_int64 f4f7_38 = f4 * (crypto_int64) f7_38;
+ crypto_int64 f4f8_38 = f4_2 * (crypto_int64) f8_19;
+ crypto_int64 f4f9_38 = f4 * (crypto_int64) f9_38;
+ crypto_int64 f5f5_38 = f5 * (crypto_int64) f5_38;
+ crypto_int64 f5f6_38 = f5_2 * (crypto_int64) f6_19;
+ crypto_int64 f5f7_76 = f5_2 * (crypto_int64) f7_38;
+ crypto_int64 f5f8_38 = f5_2 * (crypto_int64) f8_19;
+ crypto_int64 f5f9_76 = f5_2 * (crypto_int64) f9_38;
+ crypto_int64 f6f6_19 = f6 * (crypto_int64) f6_19;
+ crypto_int64 f6f7_38 = f6 * (crypto_int64) f7_38;
+ crypto_int64 f6f8_38 = f6_2 * (crypto_int64) f8_19;
+ crypto_int64 f6f9_38 = f6 * (crypto_int64) f9_38;
+ crypto_int64 f7f7_38 = f7 * (crypto_int64) f7_38;
+ crypto_int64 f7f8_38 = f7_2 * (crypto_int64) f8_19;
+ crypto_int64 f7f9_76 = f7_2 * (crypto_int64) f9_38;
+ crypto_int64 f8f8_19 = f8 * (crypto_int64) f8_19;
+ crypto_int64 f8f9_38 = f8 * (crypto_int64) f9_38;
+ crypto_int64 f9f9_38 = f9 * (crypto_int64) f9_38;
+ crypto_int64 h0 = f0f0 +f1f9_76+f2f8_38+f3f7_76+f4f6_38+f5f5_38;
+ crypto_int64 h1 = f0f1_2+f2f9_38+f3f8_38+f4f7_38+f5f6_38;
+ crypto_int64 h2 = f0f2_2+f1f1_2 +f3f9_76+f4f8_38+f5f7_76+f6f6_19;
+ crypto_int64 h3 = f0f3_2+f1f2_2 +f4f9_38+f5f8_38+f6f7_38;
+ crypto_int64 h4 = f0f4_2+f1f3_4 +f2f2 +f5f9_76+f6f8_38+f7f7_38;
+ crypto_int64 h5 = f0f5_2+f1f4_2 +f2f3_2 +f6f9_38+f7f8_38;
+ crypto_int64 h6 = f0f6_2+f1f5_4 +f2f4_2 +f3f3_2 +f7f9_76+f8f8_19;
+ crypto_int64 h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38;
+ crypto_int64 h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4 +f9f9_38;
+ crypto_int64 h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2;
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+
+ carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= SHL64(carry1,25);
+ carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= SHL64(carry5,25);
+
+ carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= SHL64(carry2,26);
+ carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= SHL64(carry6,26);
+
+ carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= SHL64(carry3,25);
+ carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= SHL64(carry7,25);
+
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+ carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= SHL64(carry8,26);
+
+ carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= SHL64(carry9,25);
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+
+ h[0] = (crypto_int32) h0;
+ h[1] = (crypto_int32) h1;
+ h[2] = (crypto_int32) h2;
+ h[3] = (crypto_int32) h3;
+ h[4] = (crypto_int32) h4;
+ h[5] = (crypto_int32) h5;
+ h[6] = (crypto_int32) h6;
+ h[7] = (crypto_int32) h7;
+ h[8] = (crypto_int32) h8;
+ h[9] = (crypto_int32) h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_sq2.c b/src/ext/ed25519/ref10/fe_sq2.c
new file mode 100644
index 0000000000..e8faa69ec9
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_sq2.c
@@ -0,0 +1,160 @@
+#include "fe.h"
+#include "crypto_int64.h"
+
+/*
+h = 2 * f * f
+Can overlap h with f.
+
+Preconditions:
+ |f| bounded by 1.65*2^26,1.65*2^25,1.65*2^26,1.65*2^25,etc.
+
+Postconditions:
+ |h| bounded by 1.01*2^25,1.01*2^24,1.01*2^25,1.01*2^24,etc.
+*/
+
+/*
+See fe_mul.c for discussion of implementation strategy.
+*/
+
+void fe_sq2(fe h,const fe f)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 f0_2 = 2 * f0;
+ crypto_int32 f1_2 = 2 * f1;
+ crypto_int32 f2_2 = 2 * f2;
+ crypto_int32 f3_2 = 2 * f3;
+ crypto_int32 f4_2 = 2 * f4;
+ crypto_int32 f5_2 = 2 * f5;
+ crypto_int32 f6_2 = 2 * f6;
+ crypto_int32 f7_2 = 2 * f7;
+ crypto_int32 f5_38 = 38 * f5; /* 1.959375*2^30 */
+ crypto_int32 f6_19 = 19 * f6; /* 1.959375*2^30 */
+ crypto_int32 f7_38 = 38 * f7; /* 1.959375*2^30 */
+ crypto_int32 f8_19 = 19 * f8; /* 1.959375*2^30 */
+ crypto_int32 f9_38 = 38 * f9; /* 1.959375*2^30 */
+ crypto_int64 f0f0 = f0 * (crypto_int64) f0;
+ crypto_int64 f0f1_2 = f0_2 * (crypto_int64) f1;
+ crypto_int64 f0f2_2 = f0_2 * (crypto_int64) f2;
+ crypto_int64 f0f3_2 = f0_2 * (crypto_int64) f3;
+ crypto_int64 f0f4_2 = f0_2 * (crypto_int64) f4;
+ crypto_int64 f0f5_2 = f0_2 * (crypto_int64) f5;
+ crypto_int64 f0f6_2 = f0_2 * (crypto_int64) f6;
+ crypto_int64 f0f7_2 = f0_2 * (crypto_int64) f7;
+ crypto_int64 f0f8_2 = f0_2 * (crypto_int64) f8;
+ crypto_int64 f0f9_2 = f0_2 * (crypto_int64) f9;
+ crypto_int64 f1f1_2 = f1_2 * (crypto_int64) f1;
+ crypto_int64 f1f2_2 = f1_2 * (crypto_int64) f2;
+ crypto_int64 f1f3_4 = f1_2 * (crypto_int64) f3_2;
+ crypto_int64 f1f4_2 = f1_2 * (crypto_int64) f4;
+ crypto_int64 f1f5_4 = f1_2 * (crypto_int64) f5_2;
+ crypto_int64 f1f6_2 = f1_2 * (crypto_int64) f6;
+ crypto_int64 f1f7_4 = f1_2 * (crypto_int64) f7_2;
+ crypto_int64 f1f8_2 = f1_2 * (crypto_int64) f8;
+ crypto_int64 f1f9_76 = f1_2 * (crypto_int64) f9_38;
+ crypto_int64 f2f2 = f2 * (crypto_int64) f2;
+ crypto_int64 f2f3_2 = f2_2 * (crypto_int64) f3;
+ crypto_int64 f2f4_2 = f2_2 * (crypto_int64) f4;
+ crypto_int64 f2f5_2 = f2_2 * (crypto_int64) f5;
+ crypto_int64 f2f6_2 = f2_2 * (crypto_int64) f6;
+ crypto_int64 f2f7_2 = f2_2 * (crypto_int64) f7;
+ crypto_int64 f2f8_38 = f2_2 * (crypto_int64) f8_19;
+ crypto_int64 f2f9_38 = f2 * (crypto_int64) f9_38;
+ crypto_int64 f3f3_2 = f3_2 * (crypto_int64) f3;
+ crypto_int64 f3f4_2 = f3_2 * (crypto_int64) f4;
+ crypto_int64 f3f5_4 = f3_2 * (crypto_int64) f5_2;
+ crypto_int64 f3f6_2 = f3_2 * (crypto_int64) f6;
+ crypto_int64 f3f7_76 = f3_2 * (crypto_int64) f7_38;
+ crypto_int64 f3f8_38 = f3_2 * (crypto_int64) f8_19;
+ crypto_int64 f3f9_76 = f3_2 * (crypto_int64) f9_38;
+ crypto_int64 f4f4 = f4 * (crypto_int64) f4;
+ crypto_int64 f4f5_2 = f4_2 * (crypto_int64) f5;
+ crypto_int64 f4f6_38 = f4_2 * (crypto_int64) f6_19;
+ crypto_int64 f4f7_38 = f4 * (crypto_int64) f7_38;
+ crypto_int64 f4f8_38 = f4_2 * (crypto_int64) f8_19;
+ crypto_int64 f4f9_38 = f4 * (crypto_int64) f9_38;
+ crypto_int64 f5f5_38 = f5 * (crypto_int64) f5_38;
+ crypto_int64 f5f6_38 = f5_2 * (crypto_int64) f6_19;
+ crypto_int64 f5f7_76 = f5_2 * (crypto_int64) f7_38;
+ crypto_int64 f5f8_38 = f5_2 * (crypto_int64) f8_19;
+ crypto_int64 f5f9_76 = f5_2 * (crypto_int64) f9_38;
+ crypto_int64 f6f6_19 = f6 * (crypto_int64) f6_19;
+ crypto_int64 f6f7_38 = f6 * (crypto_int64) f7_38;
+ crypto_int64 f6f8_38 = f6_2 * (crypto_int64) f8_19;
+ crypto_int64 f6f9_38 = f6 * (crypto_int64) f9_38;
+ crypto_int64 f7f7_38 = f7 * (crypto_int64) f7_38;
+ crypto_int64 f7f8_38 = f7_2 * (crypto_int64) f8_19;
+ crypto_int64 f7f9_76 = f7_2 * (crypto_int64) f9_38;
+ crypto_int64 f8f8_19 = f8 * (crypto_int64) f8_19;
+ crypto_int64 f8f9_38 = f8 * (crypto_int64) f9_38;
+ crypto_int64 f9f9_38 = f9 * (crypto_int64) f9_38;
+ crypto_int64 h0 = f0f0 +f1f9_76+f2f8_38+f3f7_76+f4f6_38+f5f5_38;
+ crypto_int64 h1 = f0f1_2+f2f9_38+f3f8_38+f4f7_38+f5f6_38;
+ crypto_int64 h2 = f0f2_2+f1f1_2 +f3f9_76+f4f8_38+f5f7_76+f6f6_19;
+ crypto_int64 h3 = f0f3_2+f1f2_2 +f4f9_38+f5f8_38+f6f7_38;
+ crypto_int64 h4 = f0f4_2+f1f3_4 +f2f2 +f5f9_76+f6f8_38+f7f7_38;
+ crypto_int64 h5 = f0f5_2+f1f4_2 +f2f3_2 +f6f9_38+f7f8_38;
+ crypto_int64 h6 = f0f6_2+f1f5_4 +f2f4_2 +f3f3_2 +f7f9_76+f8f8_19;
+ crypto_int64 h7 = f0f7_2+f1f6_2 +f2f5_2 +f3f4_2 +f8f9_38;
+ crypto_int64 h8 = f0f8_2+f1f7_4 +f2f6_2 +f3f5_4 +f4f4 +f9f9_38;
+ crypto_int64 h9 = f0f9_2+f1f8_2 +f2f7_2 +f3f6_2 +f4f5_2;
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+
+ h0 += h0;
+ h1 += h1;
+ h2 += h2;
+ h3 += h3;
+ h4 += h4;
+ h5 += h5;
+ h6 += h6;
+ h7 += h7;
+ h8 += h8;
+ h9 += h9;
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+
+ carry1 = (h1 + (crypto_int64) (1<<24)) >> 25; h2 += carry1; h1 -= SHL64(carry1,25);
+ carry5 = (h5 + (crypto_int64) (1<<24)) >> 25; h6 += carry5; h5 -= SHL64(carry5,25);
+
+ carry2 = (h2 + (crypto_int64) (1<<25)) >> 26; h3 += carry2; h2 -= SHL64(carry2,26);
+ carry6 = (h6 + (crypto_int64) (1<<25)) >> 26; h7 += carry6; h6 -= SHL64(carry6,26);
+
+ carry3 = (h3 + (crypto_int64) (1<<24)) >> 25; h4 += carry3; h3 -= SHL64(carry3,25);
+ carry7 = (h7 + (crypto_int64) (1<<24)) >> 25; h8 += carry7; h7 -= SHL64(carry7,25);
+
+ carry4 = (h4 + (crypto_int64) (1<<25)) >> 26; h5 += carry4; h4 -= SHL64(carry4,26);
+ carry8 = (h8 + (crypto_int64) (1<<25)) >> 26; h9 += carry8; h8 -= SHL64(carry8,26);
+
+ carry9 = (h9 + (crypto_int64) (1<<24)) >> 25; h0 += carry9 * 19; h9 -= SHL64(carry9,25);
+
+ carry0 = (h0 + (crypto_int64) (1<<25)) >> 26; h1 += carry0; h0 -= SHL64(carry0,26);
+
+ h[0] = (crypto_int32) h0;
+ h[1] = (crypto_int32) h1;
+ h[2] = (crypto_int32) h2;
+ h[3] = (crypto_int32) h3;
+ h[4] = (crypto_int32) h4;
+ h[5] = (crypto_int32) h5;
+ h[6] = (crypto_int32) h6;
+ h[7] = (crypto_int32) h7;
+ h[8] = (crypto_int32) h8;
+ h[9] = (crypto_int32) h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_sub.c b/src/ext/ed25519/ref10/fe_sub.c
new file mode 100644
index 0000000000..6e26b7df8f
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_sub.c
@@ -0,0 +1,57 @@
+#include "fe.h"
+
+/*
+h = f - g
+Can overlap h with f or g.
+
+Preconditions:
+ |f| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+ |g| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
+
+Postconditions:
+ |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
+*/
+
+void fe_sub(fe h,const fe f,const fe g)
+{
+ crypto_int32 f0 = f[0];
+ crypto_int32 f1 = f[1];
+ crypto_int32 f2 = f[2];
+ crypto_int32 f3 = f[3];
+ crypto_int32 f4 = f[4];
+ crypto_int32 f5 = f[5];
+ crypto_int32 f6 = f[6];
+ crypto_int32 f7 = f[7];
+ crypto_int32 f8 = f[8];
+ crypto_int32 f9 = f[9];
+ crypto_int32 g0 = g[0];
+ crypto_int32 g1 = g[1];
+ crypto_int32 g2 = g[2];
+ crypto_int32 g3 = g[3];
+ crypto_int32 g4 = g[4];
+ crypto_int32 g5 = g[5];
+ crypto_int32 g6 = g[6];
+ crypto_int32 g7 = g[7];
+ crypto_int32 g8 = g[8];
+ crypto_int32 g9 = g[9];
+ crypto_int32 h0 = f0 - g0;
+ crypto_int32 h1 = f1 - g1;
+ crypto_int32 h2 = f2 - g2;
+ crypto_int32 h3 = f3 - g3;
+ crypto_int32 h4 = f4 - g4;
+ crypto_int32 h5 = f5 - g5;
+ crypto_int32 h6 = f6 - g6;
+ crypto_int32 h7 = f7 - g7;
+ crypto_int32 h8 = f8 - g8;
+ crypto_int32 h9 = f9 - g9;
+ h[0] = h0;
+ h[1] = h1;
+ h[2] = h2;
+ h[3] = h3;
+ h[4] = h4;
+ h[5] = h5;
+ h[6] = h6;
+ h[7] = h7;
+ h[8] = h8;
+ h[9] = h9;
+}
diff --git a/src/ext/ed25519/ref10/fe_tobytes.c b/src/ext/ed25519/ref10/fe_tobytes.c
new file mode 100644
index 0000000000..3c7f389622
--- /dev/null
+++ b/src/ext/ed25519/ref10/fe_tobytes.c
@@ -0,0 +1,119 @@
+#include "fe.h"
+
+/*
+Preconditions:
+ |h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
+
+Write p=2^255-19; q=floor(h/p).
+Basic claim: q = floor(2^(-255)(h + 19 2^(-25)h9 + 2^(-1))).
+
+Proof:
+ Have |h|<=p so |q|<=1 so |19^2 2^(-255) q|<1/4.
+ Also have |h-2^230 h9|<2^231 so |19 2^(-255)(h-2^230 h9)|<1/4.
+
+ Write y=2^(-1)-19^2 2^(-255)q-19 2^(-255)(h-2^230 h9).
+ Then 0<y<1.
+
+ Write r=h-pq.
+ Have 0<=r<=p-1=2^255-20.
+ Thus 0<=r+19(2^-255)r<r+19(2^-255)2^255<=2^255-1.
+
+ Write x=r+19(2^-255)r+y.
+ Then 0<x<2^255 so floor(2^(-255)x) = 0 so floor(q+2^(-255)x) = q.
+
+ Have q+2^(-255)x = 2^(-255)(h + 19 2^(-25) h9 + 2^(-1))
+ so floor(2^(-255)(h + 19 2^(-25) h9 + 2^(-1))) = q.
+*/
+
+void fe_tobytes(unsigned char *s,const fe h)
+{
+ crypto_int32 h0 = h[0];
+ crypto_int32 h1 = h[1];
+ crypto_int32 h2 = h[2];
+ crypto_int32 h3 = h[3];
+ crypto_int32 h4 = h[4];
+ crypto_int32 h5 = h[5];
+ crypto_int32 h6 = h[6];
+ crypto_int32 h7 = h[7];
+ crypto_int32 h8 = h[8];
+ crypto_int32 h9 = h[9];
+ crypto_int32 q;
+ crypto_int32 carry0;
+ crypto_int32 carry1;
+ crypto_int32 carry2;
+ crypto_int32 carry3;
+ crypto_int32 carry4;
+ crypto_int32 carry5;
+ crypto_int32 carry6;
+ crypto_int32 carry7;
+ crypto_int32 carry8;
+ crypto_int32 carry9;
+
+ q = (19 * h9 + (((crypto_int32) 1) << 24)) >> 25;
+ q = (h0 + q) >> 26;
+ q = (h1 + q) >> 25;
+ q = (h2 + q) >> 26;
+ q = (h3 + q) >> 25;
+ q = (h4 + q) >> 26;
+ q = (h5 + q) >> 25;
+ q = (h6 + q) >> 26;
+ q = (h7 + q) >> 25;
+ q = (h8 + q) >> 26;
+ q = (h9 + q) >> 25;
+
+ /* Goal: Output h-(2^255-19)q, which is between 0 and 2^255-20. */
+ h0 += 19 * q;
+ /* Goal: Output h-2^255 q, which is between 0 and 2^255-20. */
+
+ carry0 = h0 >> 26; h1 += carry0; h0 -= SHL32(carry0,26);
+ carry1 = h1 >> 25; h2 += carry1; h1 -= SHL32(carry1,25);
+ carry2 = h2 >> 26; h3 += carry2; h2 -= SHL32(carry2,26);
+ carry3 = h3 >> 25; h4 += carry3; h3 -= SHL32(carry3,25);
+ carry4 = h4 >> 26; h5 += carry4; h4 -= SHL32(carry4,26);
+ carry5 = h5 >> 25; h6 += carry5; h5 -= SHL32(carry5,25);
+ carry6 = h6 >> 26; h7 += carry6; h6 -= SHL32(carry6,26);
+ carry7 = h7 >> 25; h8 += carry7; h7 -= SHL32(carry7,25);
+ carry8 = h8 >> 26; h9 += carry8; h8 -= SHL32(carry8,26);
+ carry9 = h9 >> 25; h9 -= SHL32(carry9,25);
+ /* h10 = carry9 */
+
+ /*
+ Goal: Output h0+...+2^255 h10-2^255 q, which is between 0 and 2^255-20.
+ Have h0+...+2^230 h9 between 0 and 2^255-1;
+ evidently 2^255 h10-2^255 q = 0.
+ Goal: Output h0+...+2^230 h9.
+ */
+
+ s[0] = h0 >> 0;
+ s[1] = h0 >> 8;
+ s[2] = h0 >> 16;
+ s[3] = (h0 >> 24) | SHL32(h1,2);
+ s[4] = h1 >> 6;
+ s[5] = h1 >> 14;
+ s[6] = (h1 >> 22) | SHL32(h2,3);
+ s[7] = h2 >> 5;
+ s[8] = h2 >> 13;
+ s[9] = (h2 >> 21) | SHL32(h3,5);
+ s[10] = h3 >> 3;
+ s[11] = h3 >> 11;
+ s[12] = (h3 >> 19) | SHL32(h4,6);
+ s[13] = h4 >> 2;
+ s[14] = h4 >> 10;
+ s[15] = h4 >> 18;
+ s[16] = h5 >> 0;
+ s[17] = h5 >> 8;
+ s[18] = h5 >> 16;
+ s[19] = (h5 >> 24) | SHL32(h6,1);
+ s[20] = h6 >> 7;
+ s[21] = h6 >> 15;
+ s[22] = (h6 >> 23) | SHL32(h7,3);
+ s[23] = h7 >> 5;
+ s[24] = h7 >> 13;
+ s[25] = (h7 >> 21) | SHL32(h8,4);
+ s[26] = h8 >> 4;
+ s[27] = h8 >> 12;
+ s[28] = (h8 >> 20) | SHL32(h9,6);
+ s[29] = h9 >> 2;
+ s[30] = h9 >> 10;
+ s[31] = h9 >> 18;
+}
diff --git a/src/ext/ed25519/ref10/ge.h b/src/ext/ed25519/ref10/ge.h
new file mode 100644
index 0000000000..55e95f95b6
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge.h
@@ -0,0 +1,95 @@
+#ifndef GE_H
+#define GE_H
+
+/*
+ge means group element.
+
+Here the group is the set of pairs (x,y) of field elements (see fe.h)
+satisfying -x^2 + y^2 = 1 + d x^2y^2
+where d = -121665/121666.
+
+Representations:
+ ge_p2 (projective): (X:Y:Z) satisfying x=X/Z, y=Y/Z
+ ge_p3 (extended): (X:Y:Z:T) satisfying x=X/Z, y=Y/Z, XY=ZT
+ ge_p1p1 (completed): ((X:Z),(Y:T)) satisfying x=X/Z, y=Y/T
+ ge_precomp (Duif): (y+x,y-x,2dxy)
+*/
+
+#include "fe.h"
+
+typedef struct {
+ fe X;
+ fe Y;
+ fe Z;
+} ge_p2;
+
+typedef struct {
+ fe X;
+ fe Y;
+ fe Z;
+ fe T;
+} ge_p3;
+
+typedef struct {
+ fe X;
+ fe Y;
+ fe Z;
+ fe T;
+} ge_p1p1;
+
+typedef struct {
+ fe yplusx;
+ fe yminusx;
+ fe xy2d;
+} ge_precomp;
+
+typedef struct {
+ fe YplusX;
+ fe YminusX;
+ fe Z;
+ fe T2d;
+} ge_cached;
+
+#define ge_frombytes_negate_vartime crypto_sign_ed25519_ref10_ge_frombytes_negate_vartime
+#define ge_tobytes crypto_sign_ed25519_ref10_ge_tobytes
+#define ge_p3_tobytes crypto_sign_ed25519_ref10_ge_p3_tobytes
+
+#define ge_p2_0 crypto_sign_ed25519_ref10_ge_p2_0
+#define ge_p3_0 crypto_sign_ed25519_ref10_ge_p3_0
+#define ge_precomp_0 crypto_sign_ed25519_ref10_ge_precomp_0
+#define ge_p3_to_p2 crypto_sign_ed25519_ref10_ge_p3_to_p2
+#define ge_p3_to_cached crypto_sign_ed25519_ref10_ge_p3_to_cached
+#define ge_p1p1_to_p2 crypto_sign_ed25519_ref10_ge_p1p1_to_p2
+#define ge_p1p1_to_p3 crypto_sign_ed25519_ref10_ge_p1p1_to_p3
+#define ge_p2_dbl crypto_sign_ed25519_ref10_ge_p2_dbl
+#define ge_p3_dbl crypto_sign_ed25519_ref10_ge_p3_dbl
+
+#define ge_madd crypto_sign_ed25519_ref10_ge_madd
+#define ge_msub crypto_sign_ed25519_ref10_ge_msub
+#define ge_add crypto_sign_ed25519_ref10_ge_add
+#define ge_sub crypto_sign_ed25519_ref10_ge_sub
+#define ge_scalarmult_base crypto_sign_ed25519_ref10_ge_scalarmult_base
+#define ge_double_scalarmult_vartime crypto_sign_ed25519_ref10_ge_double_scalarmult_vartime
+
+extern void ge_tobytes(unsigned char *,const ge_p2 *);
+extern void ge_p3_tobytes(unsigned char *,const ge_p3 *);
+extern int ge_frombytes_negate_vartime(ge_p3 *,const unsigned char *);
+
+extern void ge_p2_0(ge_p2 *);
+extern void ge_p3_0(ge_p3 *);
+extern void ge_precomp_0(ge_precomp *);
+extern void ge_p3_to_p2(ge_p2 *,const ge_p3 *);
+extern void ge_p3_to_cached(ge_cached *,const ge_p3 *);
+extern void ge_p1p1_to_p2(ge_p2 *,const ge_p1p1 *);
+extern void ge_p1p1_to_p3(ge_p3 *,const ge_p1p1 *);
+extern void ge_p2_dbl(ge_p1p1 *,const ge_p2 *);
+extern void ge_p3_dbl(ge_p1p1 *,const ge_p3 *);
+
+extern void ge_madd(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
+extern void ge_msub(ge_p1p1 *,const ge_p3 *,const ge_precomp *);
+extern void ge_add(ge_p1p1 *,const ge_p3 *,const ge_cached *);
+extern void ge_sub(ge_p1p1 *,const ge_p3 *,const ge_cached *);
+extern void ge_scalarmult_base(ge_p3 *,const unsigned char *);
+extern void ge_double_scalarmult_vartime(ge_p2 *,const unsigned char *,const ge_p3 *,const unsigned char *);
+
+#endif
diff --git a/src/ext/ed25519/ref10/ge_add.c b/src/ext/ed25519/ref10/ge_add.c
new file mode 100644
index 0000000000..da7ff5d2eb
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_add.c
@@ -0,0 +1,11 @@
+#include "ge.h"
+
+/*
+r = p + q
+*/
+
+void ge_add(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
+{
+ fe t0;
+#include "ge_add.h"
+}
diff --git a/src/ext/ed25519/ref10/ge_add.h b/src/ext/ed25519/ref10/ge_add.h
new file mode 100644
index 0000000000..7481f8ffbe
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_add.h
@@ -0,0 +1,97 @@
+
+/* qhasm: enter ge_add */
+
+/* qhasm: fe X1 */
+
+/* qhasm: fe Y1 */
+
+/* qhasm: fe Z1 */
+
+/* qhasm: fe Z2 */
+
+/* qhasm: fe T1 */
+
+/* qhasm: fe ZZ */
+
+/* qhasm: fe YpX2 */
+
+/* qhasm: fe YmX2 */
+
+/* qhasm: fe T2d2 */
+
+/* qhasm: fe X3 */
+
+/* qhasm: fe Y3 */
+
+/* qhasm: fe Z3 */
+
+/* qhasm: fe T3 */
+
+/* qhasm: fe YpX1 */
+
+/* qhasm: fe YmX1 */
+
+/* qhasm: fe A */
+
+/* qhasm: fe B */
+
+/* qhasm: fe C */
+
+/* qhasm: fe D */
+
+/* qhasm: YpX1 = Y1+X1 */
+/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
+fe_add(r->X,p->Y,p->X);
+
+/* qhasm: YmX1 = Y1-X1 */
+/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
+fe_sub(r->Y,p->Y,p->X);
+
+/* qhasm: A = YpX1*YpX2 */
+/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<YpX2=fe#15); */
+/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<YpX2=q->YplusX); */
+fe_mul(r->Z,r->X,q->YplusX);
+
+/* qhasm: B = YmX1*YmX2 */
+/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<YmX2=fe#16); */
+/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<YmX2=q->YminusX); */
+fe_mul(r->Y,r->Y,q->YminusX);
+
+/* qhasm: C = T2d2*T1 */
+/* asm 1: fe_mul(>C=fe#4,<T2d2=fe#18,<T1=fe#14); */
+/* asm 2: fe_mul(>C=r->T,<T2d2=q->T2d,<T1=p->T); */
+fe_mul(r->T,q->T2d,p->T);
+
+/* qhasm: ZZ = Z1*Z2 */
+/* asm 1: fe_mul(>ZZ=fe#1,<Z1=fe#13,<Z2=fe#17); */
+/* asm 2: fe_mul(>ZZ=r->X,<Z1=p->Z,<Z2=q->Z); */
+fe_mul(r->X,p->Z,q->Z);
+
+/* qhasm: D = 2*ZZ */
+/* asm 1: fe_add(>D=fe#5,<ZZ=fe#1,<ZZ=fe#1); */
+/* asm 2: fe_add(>D=t0,<ZZ=r->X,<ZZ=r->X); */
+fe_add(t0,r->X,r->X);
+
+/* qhasm: X3 = A-B */
+/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
+fe_sub(r->X,r->Z,r->Y);
+
+/* qhasm: Y3 = A+B */
+/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
+fe_add(r->Y,r->Z,r->Y);
+
+/* qhasm: Z3 = D+C */
+/* asm 1: fe_add(>Z3=fe#3,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_add(>Z3=r->Z,<D=t0,<C=r->T); */
+fe_add(r->Z,t0,r->T);
+
+/* qhasm: T3 = D-C */
+/* asm 1: fe_sub(>T3=fe#4,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_sub(>T3=r->T,<D=t0,<C=r->T); */
+fe_sub(r->T,t0,r->T);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/ge_add.q b/src/ext/ed25519/ref10/ge_add.q
new file mode 100644
index 0000000000..a6572ab0f8
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_add.q
@@ -0,0 +1,49 @@
+:name:fe:r->X:r->Y:r->Z:r->T:t0:t1:t2:t3:t4:t5:p->X:p->Y:p->Z:p->T:q->YplusX:q->YminusX:q->Z:q->T2d:
+fe r:var/r=fe:
+
+enter f:enter/f:>X1=fe#11:>Y1=fe#12:>Z1=fe#13:>T1=fe#14:>YpX2=fe#15:>YmX2=fe#16:>Z2=fe#17:>T2d2=fe#18:
+return:nofallthrough:<X3=fe#1:<Y3=fe#2:<Z3=fe#3:<T3=fe#4:leave:
+
+h=f+g:<f=fe:<g=fe:>h=fe:asm/fe_add(>h,<f,<g);:
+h=f-g:<f=fe:<g=fe:>h=fe:asm/fe_sub(>h,<f,<g);:
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2:<f=fe:>h=fe:asm/fe_sq(>h,<f);:
+h=2*g:<g=fe:>h=fe:asm/fe_add(>h,<g,<g);:
+
+:
+
+enter ge_add
+
+fe X1
+fe Y1
+fe Z1
+fe Z2
+fe T1
+fe ZZ
+fe YpX2
+fe YmX2
+fe T2d2
+fe X3
+fe Y3
+fe Z3
+fe T3
+fe YpX1
+fe YmX1
+fe A
+fe B
+fe C
+fe D
+
+YpX1 = Y1+X1
+YmX1 = Y1-X1
+A = YpX1*YpX2
+B = YmX1*YmX2
+C = T2d2*T1
+ZZ = Z1*Z2
+D = 2*ZZ
+X3 = A-B
+Y3 = A+B
+Z3 = D+C
+T3 = D-C
+
+return
diff --git a/src/ext/ed25519/ref10/ge_double_scalarmult.c b/src/ext/ed25519/ref10/ge_double_scalarmult.c
new file mode 100644
index 0000000000..f8bf4bf775
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_double_scalarmult.c
@@ -0,0 +1,96 @@
+#include "ge.h"
+
+static void slide(signed char *r,const unsigned char *a)
+{
+ int i;
+ int b;
+ int k;
+
+ for (i = 0;i < 256;++i)
+ r[i] = 1 & (a[i >> 3] >> (i & 7));
+
+ for (i = 0;i < 256;++i)
+ if (r[i]) {
+ for (b = 1;b <= 6 && i + b < 256;++b) {
+ if (r[i + b]) {
+ if (r[i] + (r[i + b] << b) <= 15) {
+ r[i] += r[i + b] << b; r[i + b] = 0;
+ } else if (r[i] - (r[i + b] << b) >= -15) {
+ r[i] -= r[i + b] << b;
+ for (k = i + b;k < 256;++k) {
+ if (!r[k]) {
+ r[k] = 1;
+ break;
+ }
+ r[k] = 0;
+ }
+ } else
+ break;
+ }
+ }
+ }
+
+}
+
+static ge_precomp Bi[8] = {
+#include "base2.h"
+} ;
+
+/*
+r = a * A + b * B
+where a = a[0]+256*a[1]+...+256^31 a[31].
+and b = b[0]+256*b[1]+...+256^31 b[31].
+B is the Ed25519 base point (x,4/5) with x positive.
+*/
+
+void ge_double_scalarmult_vartime(ge_p2 *r,const unsigned char *a,const ge_p3 *A,const unsigned char *b)
+{
+ signed char aslide[256];
+ signed char bslide[256];
+ ge_cached Ai[8]; /* A,3A,5A,7A,9A,11A,13A,15A */
+ ge_p1p1 t;
+ ge_p3 u;
+ ge_p3 A2;
+ int i;
+
+ slide(aslide,a);
+ slide(bslide,b);
+
+ ge_p3_to_cached(&Ai[0],A);
+ ge_p3_dbl(&t,A); ge_p1p1_to_p3(&A2,&t);
+ ge_add(&t,&A2,&Ai[0]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[1],&u);
+ ge_add(&t,&A2,&Ai[1]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[2],&u);
+ ge_add(&t,&A2,&Ai[2]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[3],&u);
+ ge_add(&t,&A2,&Ai[3]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[4],&u);
+ ge_add(&t,&A2,&Ai[4]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[5],&u);
+ ge_add(&t,&A2,&Ai[5]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[6],&u);
+ ge_add(&t,&A2,&Ai[6]); ge_p1p1_to_p3(&u,&t); ge_p3_to_cached(&Ai[7],&u);
+
+ ge_p2_0(r);
+
+ for (i = 255;i >= 0;--i) {
+ if (aslide[i] || bslide[i]) break;
+ }
+
+ for (;i >= 0;--i) {
+ ge_p2_dbl(&t,r);
+
+ if (aslide[i] > 0) {
+ ge_p1p1_to_p3(&u,&t);
+ ge_add(&t,&u,&Ai[aslide[i]/2]);
+ } else if (aslide[i] < 0) {
+ ge_p1p1_to_p3(&u,&t);
+ ge_sub(&t,&u,&Ai[(-aslide[i])/2]);
+ }
+
+ if (bslide[i] > 0) {
+ ge_p1p1_to_p3(&u,&t);
+ ge_madd(&t,&u,&Bi[bslide[i]/2]);
+ } else if (bslide[i] < 0) {
+ ge_p1p1_to_p3(&u,&t);
+ ge_msub(&t,&u,&Bi[(-bslide[i])/2]);
+ }
+
+ ge_p1p1_to_p2(r,&t);
+ }
+}
diff --git a/src/ext/ed25519/ref10/ge_frombytes.c b/src/ext/ed25519/ref10/ge_frombytes.c
new file mode 100644
index 0000000000..1a059ee93f
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_frombytes.c
@@ -0,0 +1,50 @@
+#include "ge.h"
+
+static const fe d = {
+#include "d.h"
+} ;
+
+static const fe sqrtm1 = {
+#include "sqrtm1.h"
+} ;
+
+int ge_frombytes_negate_vartime(ge_p3 *h,const unsigned char *s)
+{
+ fe u;
+ fe v;
+ fe v3;
+ fe vxx;
+ fe check;
+
+ fe_frombytes(h->Y,s);
+ fe_1(h->Z);
+ fe_sq(u,h->Y);
+ fe_mul(v,u,d);
+ fe_sub(u,u,h->Z); /* u = y^2-1 */
+ fe_add(v,v,h->Z); /* v = dy^2+1 */
+
+ fe_sq(v3,v);
+ fe_mul(v3,v3,v); /* v3 = v^3 */
+ fe_sq(h->X,v3);
+ fe_mul(h->X,h->X,v);
+ fe_mul(h->X,h->X,u); /* x = uv^7 */
+
+ fe_pow22523(h->X,h->X); /* x = (uv^7)^((q-5)/8) */
+ fe_mul(h->X,h->X,v3);
+ fe_mul(h->X,h->X,u); /* x = uv^3(uv^7)^((q-5)/8) */
+
+ fe_sq(vxx,h->X);
+ fe_mul(vxx,vxx,v);
+ fe_sub(check,vxx,u); /* vx^2-u */
+ if (fe_isnonzero(check)) {
+ fe_add(check,vxx,u); /* vx^2+u */
+ if (fe_isnonzero(check)) return -1;
+ fe_mul(h->X,h->X,sqrtm1);
+ }
+
+ if (fe_isnegative(h->X) == (s[31] >> 7))
+ fe_neg(h->X,h->X);
+
+ fe_mul(h->T,h->X,h->Y);
+ return 0;
+}
diff --git a/src/ext/ed25519/ref10/ge_madd.c b/src/ext/ed25519/ref10/ge_madd.c
new file mode 100644
index 0000000000..622571774b
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_madd.c
@@ -0,0 +1,11 @@
+#include "ge.h"
+
+/*
+r = p + q
+*/
+
+void ge_madd(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
+{
+ fe t0;
+#include "ge_madd.h"
+}
diff --git a/src/ext/ed25519/ref10/ge_madd.h b/src/ext/ed25519/ref10/ge_madd.h
new file mode 100644
index 0000000000..ecae84952b
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_madd.h
@@ -0,0 +1,88 @@
+
+/* qhasm: enter ge_madd */
+
+/* qhasm: fe X1 */
+
+/* qhasm: fe Y1 */
+
+/* qhasm: fe Z1 */
+
+/* qhasm: fe T1 */
+
+/* qhasm: fe ypx2 */
+
+/* qhasm: fe ymx2 */
+
+/* qhasm: fe xy2d2 */
+
+/* qhasm: fe X3 */
+
+/* qhasm: fe Y3 */
+
+/* qhasm: fe Z3 */
+
+/* qhasm: fe T3 */
+
+/* qhasm: fe YpX1 */
+
+/* qhasm: fe YmX1 */
+
+/* qhasm: fe A */
+
+/* qhasm: fe B */
+
+/* qhasm: fe C */
+
+/* qhasm: fe D */
+
+/* qhasm: YpX1 = Y1+X1 */
+/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
+fe_add(r->X,p->Y,p->X);
+
+/* qhasm: YmX1 = Y1-X1 */
+/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
+fe_sub(r->Y,p->Y,p->X);
+
+/* qhasm: A = YpX1*ypx2 */
+/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<ypx2=fe#15); */
+/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<ypx2=q->yplusx); */
+fe_mul(r->Z,r->X,q->yplusx);
+
+/* qhasm: B = YmX1*ymx2 */
+/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<ymx2=fe#16); */
+/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<ymx2=q->yminusx); */
+fe_mul(r->Y,r->Y,q->yminusx);
+
+/* qhasm: C = xy2d2*T1 */
+/* asm 1: fe_mul(>C=fe#4,<xy2d2=fe#17,<T1=fe#14); */
+/* asm 2: fe_mul(>C=r->T,<xy2d2=q->xy2d,<T1=p->T); */
+fe_mul(r->T,q->xy2d,p->T);
+
+/* qhasm: D = 2*Z1 */
+/* asm 1: fe_add(>D=fe#5,<Z1=fe#13,<Z1=fe#13); */
+/* asm 2: fe_add(>D=t0,<Z1=p->Z,<Z1=p->Z); */
+fe_add(t0,p->Z,p->Z);
+
+/* qhasm: X3 = A-B */
+/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
+fe_sub(r->X,r->Z,r->Y);
+
+/* qhasm: Y3 = A+B */
+/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
+fe_add(r->Y,r->Z,r->Y);
+
+/* qhasm: Z3 = D+C */
+/* asm 1: fe_add(>Z3=fe#3,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_add(>Z3=r->Z,<D=t0,<C=r->T); */
+fe_add(r->Z,t0,r->T);
+
+/* qhasm: T3 = D-C */
+/* asm 1: fe_sub(>T3=fe#4,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_sub(>T3=r->T,<D=t0,<C=r->T); */
+fe_sub(r->T,t0,r->T);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/ge_madd.q b/src/ext/ed25519/ref10/ge_madd.q
new file mode 100644
index 0000000000..aa3db454e6
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_madd.q
@@ -0,0 +1,46 @@
+:name:fe:r->X:r->Y:r->Z:r->T:t0:t1:t2:t3:t4:t5:p->X:p->Y:p->Z:p->T:q->yplusx:q->yminusx:q->xy2d:
+fe r:var/r=fe:
+
+enter f:enter/f:>X1=fe#11:>Y1=fe#12:>Z1=fe#13:>T1=fe#14:>ypx2=fe#15:>ymx2=fe#16:>xy2d2=fe#17:
+return:nofallthrough:<X3=fe#1:<Y3=fe#2:<Z3=fe#3:<T3=fe#4:leave:
+
+h=f+g:<f=fe:<g=fe:>h=fe:asm/fe_add(>h,<f,<g);:
+h=f-g:<f=fe:<g=fe:>h=fe:asm/fe_sub(>h,<f,<g);:
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2:<f=fe:>h=fe:asm/fe_sq(>h,<f);:
+h=2*g:<g=fe:>h=fe:asm/fe_add(>h,<g,<g);:
+
+:
+
+enter ge_madd
+
+fe X1
+fe Y1
+fe Z1
+fe T1
+fe ypx2
+fe ymx2
+fe xy2d2
+fe X3
+fe Y3
+fe Z3
+fe T3
+fe YpX1
+fe YmX1
+fe A
+fe B
+fe C
+fe D
+
+YpX1 = Y1+X1
+YmX1 = Y1-X1
+A = YpX1*ypx2
+B = YmX1*ymx2
+C = xy2d2*T1
+D = 2*Z1
+X3 = A-B
+Y3 = A+B
+Z3 = D+C
+T3 = D-C
+
+return
diff --git a/src/ext/ed25519/ref10/ge_msub.c b/src/ext/ed25519/ref10/ge_msub.c
new file mode 100644
index 0000000000..741ecbf113
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_msub.c
@@ -0,0 +1,11 @@
+#include "ge.h"
+
+/*
+r = p - q
+*/
+
+void ge_msub(ge_p1p1 *r,const ge_p3 *p,const ge_precomp *q)
+{
+ fe t0;
+#include "ge_msub.h"
+}
diff --git a/src/ext/ed25519/ref10/ge_msub.h b/src/ext/ed25519/ref10/ge_msub.h
new file mode 100644
index 0000000000..500f986ba0
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_msub.h
@@ -0,0 +1,88 @@
+
+/* qhasm: enter ge_msub */
+
+/* qhasm: fe X1 */
+
+/* qhasm: fe Y1 */
+
+/* qhasm: fe Z1 */
+
+/* qhasm: fe T1 */
+
+/* qhasm: fe ypx2 */
+
+/* qhasm: fe ymx2 */
+
+/* qhasm: fe xy2d2 */
+
+/* qhasm: fe X3 */
+
+/* qhasm: fe Y3 */
+
+/* qhasm: fe Z3 */
+
+/* qhasm: fe T3 */
+
+/* qhasm: fe YpX1 */
+
+/* qhasm: fe YmX1 */
+
+/* qhasm: fe A */
+
+/* qhasm: fe B */
+
+/* qhasm: fe C */
+
+/* qhasm: fe D */
+
+/* qhasm: YpX1 = Y1+X1 */
+/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
+fe_add(r->X,p->Y,p->X);
+
+/* qhasm: YmX1 = Y1-X1 */
+/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
+fe_sub(r->Y,p->Y,p->X);
+
+/* qhasm: A = YpX1*ymx2 */
+/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<ymx2=fe#16); */
+/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<ymx2=q->yminusx); */
+fe_mul(r->Z,r->X,q->yminusx);
+
+/* qhasm: B = YmX1*ypx2 */
+/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<ypx2=fe#15); */
+/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<ypx2=q->yplusx); */
+fe_mul(r->Y,r->Y,q->yplusx);
+
+/* qhasm: C = xy2d2*T1 */
+/* asm 1: fe_mul(>C=fe#4,<xy2d2=fe#17,<T1=fe#14); */
+/* asm 2: fe_mul(>C=r->T,<xy2d2=q->xy2d,<T1=p->T); */
+fe_mul(r->T,q->xy2d,p->T);
+
+/* qhasm: D = 2*Z1 */
+/* asm 1: fe_add(>D=fe#5,<Z1=fe#13,<Z1=fe#13); */
+/* asm 2: fe_add(>D=t0,<Z1=p->Z,<Z1=p->Z); */
+fe_add(t0,p->Z,p->Z);
+
+/* qhasm: X3 = A-B */
+/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
+fe_sub(r->X,r->Z,r->Y);
+
+/* qhasm: Y3 = A+B */
+/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
+fe_add(r->Y,r->Z,r->Y);
+
+/* qhasm: Z3 = D-C */
+/* asm 1: fe_sub(>Z3=fe#3,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_sub(>Z3=r->Z,<D=t0,<C=r->T); */
+fe_sub(r->Z,t0,r->T);
+
+/* qhasm: T3 = D+C */
+/* asm 1: fe_add(>T3=fe#4,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_add(>T3=r->T,<D=t0,<C=r->T); */
+fe_add(r->T,t0,r->T);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/ge_msub.q b/src/ext/ed25519/ref10/ge_msub.q
new file mode 100644
index 0000000000..e3cadd882d
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_msub.q
@@ -0,0 +1,46 @@
+:name:fe:r->X:r->Y:r->Z:r->T:t0:t1:t2:t3:t4:t5:p->X:p->Y:p->Z:p->T:q->yplusx:q->yminusx:q->xy2d:
+fe r:var/r=fe:
+
+enter f:enter/f:>X1=fe#11:>Y1=fe#12:>Z1=fe#13:>T1=fe#14:>ypx2=fe#15:>ymx2=fe#16:>xy2d2=fe#17:
+return:nofallthrough:<X3=fe#1:<Y3=fe#2:<Z3=fe#3:<T3=fe#4:leave:
+
+h=f+g:<f=fe:<g=fe:>h=fe:asm/fe_add(>h,<f,<g);:
+h=f-g:<f=fe:<g=fe:>h=fe:asm/fe_sub(>h,<f,<g);:
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2:<f=fe:>h=fe:asm/fe_sq(>h,<f);:
+h=2*g:<g=fe:>h=fe:asm/fe_add(>h,<g,<g);:
+
+:
+
+enter ge_msub
+
+fe X1
+fe Y1
+fe Z1
+fe T1
+fe ypx2
+fe ymx2
+fe xy2d2
+fe X3
+fe Y3
+fe Z3
+fe T3
+fe YpX1
+fe YmX1
+fe A
+fe B
+fe C
+fe D
+
+YpX1 = Y1+X1
+YmX1 = Y1-X1
+A = YpX1*ymx2
+B = YmX1*ypx2
+C = xy2d2*T1
+D = 2*Z1
+X3 = A-B
+Y3 = A+B
+Z3 = D-C
+T3 = D+C
+
+return
diff --git a/src/ext/ed25519/ref10/ge_p1p1_to_p2.c b/src/ext/ed25519/ref10/ge_p1p1_to_p2.c
new file mode 100644
index 0000000000..9bb5013d66
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p1p1_to_p2.c
@@ -0,0 +1,12 @@
+#include "ge.h"
+
+/*
+r = p
+*/
+
+extern void ge_p1p1_to_p2(ge_p2 *r,const ge_p1p1 *p)
+{
+ fe_mul(r->X,p->X,p->T);
+ fe_mul(r->Y,p->Y,p->Z);
+ fe_mul(r->Z,p->Z,p->T);
+}
diff --git a/src/ext/ed25519/ref10/ge_p1p1_to_p3.c b/src/ext/ed25519/ref10/ge_p1p1_to_p3.c
new file mode 100644
index 0000000000..2f57b10968
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p1p1_to_p3.c
@@ -0,0 +1,13 @@
+#include "ge.h"
+
+/*
+r = p
+*/
+
+extern void ge_p1p1_to_p3(ge_p3 *r,const ge_p1p1 *p)
+{
+ fe_mul(r->X,p->X,p->T);
+ fe_mul(r->Y,p->Y,p->Z);
+ fe_mul(r->Z,p->Z,p->T);
+ fe_mul(r->T,p->X,p->Y);
+}
diff --git a/src/ext/ed25519/ref10/ge_p2_0.c b/src/ext/ed25519/ref10/ge_p2_0.c
new file mode 100644
index 0000000000..6191d1e6e4
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p2_0.c
@@ -0,0 +1,8 @@
+#include "ge.h"
+
+void ge_p2_0(ge_p2 *h)
+{
+ fe_0(h->X);
+ fe_1(h->Y);
+ fe_1(h->Z);
+}
diff --git a/src/ext/ed25519/ref10/ge_p2_dbl.c b/src/ext/ed25519/ref10/ge_p2_dbl.c
new file mode 100644
index 0000000000..2e332b5cee
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p2_dbl.c
@@ -0,0 +1,11 @@
+#include "ge.h"
+
+/*
+r = 2 * p
+*/
+
+void ge_p2_dbl(ge_p1p1 *r,const ge_p2 *p)
+{
+ fe t0;
+#include "ge_p2_dbl.h"
+}
diff --git a/src/ext/ed25519/ref10/ge_p2_dbl.h b/src/ext/ed25519/ref10/ge_p2_dbl.h
new file mode 100644
index 0000000000..128efed907
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p2_dbl.h
@@ -0,0 +1,73 @@
+
+/* qhasm: enter ge_p2_dbl */
+
+/* qhasm: fe X1 */
+
+/* qhasm: fe Y1 */
+
+/* qhasm: fe Z1 */
+
+/* qhasm: fe A */
+
+/* qhasm: fe AA */
+
+/* qhasm: fe XX */
+
+/* qhasm: fe YY */
+
+/* qhasm: fe B */
+
+/* qhasm: fe X3 */
+
+/* qhasm: fe Y3 */
+
+/* qhasm: fe Z3 */
+
+/* qhasm: fe T3 */
+
+/* qhasm: XX=X1^2 */
+/* asm 1: fe_sq(>XX=fe#1,<X1=fe#11); */
+/* asm 2: fe_sq(>XX=r->X,<X1=p->X); */
+fe_sq(r->X,p->X);
+
+/* qhasm: YY=Y1^2 */
+/* asm 1: fe_sq(>YY=fe#3,<Y1=fe#12); */
+/* asm 2: fe_sq(>YY=r->Z,<Y1=p->Y); */
+fe_sq(r->Z,p->Y);
+
+/* qhasm: B=2*Z1^2 */
+/* asm 1: fe_sq2(>B=fe#4,<Z1=fe#13); */
+/* asm 2: fe_sq2(>B=r->T,<Z1=p->Z); */
+fe_sq2(r->T,p->Z);
+
+/* qhasm: A=X1+Y1 */
+/* asm 1: fe_add(>A=fe#2,<X1=fe#11,<Y1=fe#12); */
+/* asm 2: fe_add(>A=r->Y,<X1=p->X,<Y1=p->Y); */
+fe_add(r->Y,p->X,p->Y);
+
+/* qhasm: AA=A^2 */
+/* asm 1: fe_sq(>AA=fe#5,<A=fe#2); */
+/* asm 2: fe_sq(>AA=t0,<A=r->Y); */
+fe_sq(t0,r->Y);
+
+/* qhasm: Y3=YY+XX */
+/* asm 1: fe_add(>Y3=fe#2,<YY=fe#3,<XX=fe#1); */
+/* asm 2: fe_add(>Y3=r->Y,<YY=r->Z,<XX=r->X); */
+fe_add(r->Y,r->Z,r->X);
+
+/* qhasm: Z3=YY-XX */
+/* asm 1: fe_sub(>Z3=fe#3,<YY=fe#3,<XX=fe#1); */
+/* asm 2: fe_sub(>Z3=r->Z,<YY=r->Z,<XX=r->X); */
+fe_sub(r->Z,r->Z,r->X);
+
+/* qhasm: X3=AA-Y3 */
+/* asm 1: fe_sub(>X3=fe#1,<AA=fe#5,<Y3=fe#2); */
+/* asm 2: fe_sub(>X3=r->X,<AA=t0,<Y3=r->Y); */
+fe_sub(r->X,t0,r->Y);
+
+/* qhasm: T3=B-Z3 */
+/* asm 1: fe_sub(>T3=fe#4,<B=fe#4,<Z3=fe#3); */
+/* asm 2: fe_sub(>T3=r->T,<B=r->T,<Z3=r->Z); */
+fe_sub(r->T,r->T,r->Z);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/ge_p2_dbl.q b/src/ext/ed25519/ref10/ge_p2_dbl.q
new file mode 100644
index 0000000000..170d42f9a7
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p2_dbl.q
@@ -0,0 +1,41 @@
+:name:fe:r->X:r->Y:r->Z:r->T:t0:t1:t2:t3:t4:t5:p->X:p->Y:p->Z:
+fe r:var/r=fe:
+
+enter f:enter/f:>X1=fe#11:>Y1=fe#12:>Z1=fe#13:
+return:nofallthrough:<X3=fe#1:<Y3=fe#2:<Z3=fe#3:<T3=fe#4:leave:
+
+h=f+g:<f=fe:<g=fe:>h=fe:asm/fe_add(>h,<f,<g);:
+h=f-g:<f=fe:<g=fe:>h=fe:asm/fe_sub(>h,<f,<g);:
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2:<f=fe:>h=fe:asm/fe_sq(>h,<f);:
+h=2*f^2:<f=fe:>h=fe:asm/fe_sq2(>h,<f);:
+h=2*g:<g=fe:>h=fe:asm/fe_add(>h,<g,<g);:
+
+:
+
+enter ge_p2_dbl
+
+fe X1
+fe Y1
+fe Z1
+fe A
+fe AA
+fe XX
+fe YY
+fe B
+fe X3
+fe Y3
+fe Z3
+fe T3
+
+XX=X1^2
+YY=Y1^2
+B=2*Z1^2
+A=X1+Y1
+AA=A^2
+Y3=YY+XX
+Z3=YY-XX
+X3=AA-Y3
+T3=B-Z3
+
+return
diff --git a/src/ext/ed25519/ref10/ge_p3_0.c b/src/ext/ed25519/ref10/ge_p3_0.c
new file mode 100644
index 0000000000..401b2935a1
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p3_0.c
@@ -0,0 +1,9 @@
+#include "ge.h"
+
+void ge_p3_0(ge_p3 *h)
+{
+ fe_0(h->X);
+ fe_1(h->Y);
+ fe_1(h->Z);
+ fe_0(h->T);
+}
diff --git a/src/ext/ed25519/ref10/ge_p3_dbl.c b/src/ext/ed25519/ref10/ge_p3_dbl.c
new file mode 100644
index 0000000000..0d8a05915d
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p3_dbl.c
@@ -0,0 +1,12 @@
+#include "ge.h"
+
+/*
+r = 2 * p
+*/
+
+void ge_p3_dbl(ge_p1p1 *r,const ge_p3 *p)
+{
+ ge_p2 q;
+ ge_p3_to_p2(&q,p);
+ ge_p2_dbl(r,&q);
+}
diff --git a/src/ext/ed25519/ref10/ge_p3_to_cached.c b/src/ext/ed25519/ref10/ge_p3_to_cached.c
new file mode 100644
index 0000000000..bde64228cf
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p3_to_cached.c
@@ -0,0 +1,17 @@
+#include "ge.h"
+
+/*
+r = p
+*/
+
+static const fe d2 = {
+#include "d2.h"
+} ;
+
+extern void ge_p3_to_cached(ge_cached *r,const ge_p3 *p)
+{
+ fe_add(r->YplusX,p->Y,p->X);
+ fe_sub(r->YminusX,p->Y,p->X);
+ fe_copy(r->Z,p->Z);
+ fe_mul(r->T2d,p->T,d2);
+}
diff --git a/src/ext/ed25519/ref10/ge_p3_to_p2.c b/src/ext/ed25519/ref10/ge_p3_to_p2.c
new file mode 100644
index 0000000000..e532a9e4cb
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p3_to_p2.c
@@ -0,0 +1,12 @@
+#include "ge.h"
+
+/*
+r = p
+*/
+
+extern void ge_p3_to_p2(ge_p2 *r,const ge_p3 *p)
+{
+ fe_copy(r->X,p->X);
+ fe_copy(r->Y,p->Y);
+ fe_copy(r->Z,p->Z);
+}
diff --git a/src/ext/ed25519/ref10/ge_p3_tobytes.c b/src/ext/ed25519/ref10/ge_p3_tobytes.c
new file mode 100644
index 0000000000..21cb2fc656
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_p3_tobytes.c
@@ -0,0 +1,14 @@
+#include "ge.h"
+
+void ge_p3_tobytes(unsigned char *s,const ge_p3 *h)
+{
+ fe recip;
+ fe x;
+ fe y;
+
+ fe_invert(recip,h->Z);
+ fe_mul(x,h->X,recip);
+ fe_mul(y,h->Y,recip);
+ fe_tobytes(s,y);
+ s[31] ^= fe_isnegative(x) << 7;
+}
diff --git a/src/ext/ed25519/ref10/ge_precomp_0.c b/src/ext/ed25519/ref10/ge_precomp_0.c
new file mode 100644
index 0000000000..2e218861d8
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_precomp_0.c
@@ -0,0 +1,8 @@
+#include "ge.h"
+
+void ge_precomp_0(ge_precomp *h)
+{
+ fe_1(h->yplusx);
+ fe_1(h->yminusx);
+ fe_0(h->xy2d);
+}
diff --git a/src/ext/ed25519/ref10/ge_scalarmult_base.c b/src/ext/ed25519/ref10/ge_scalarmult_base.c
new file mode 100644
index 0000000000..5292f83221
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_scalarmult_base.c
@@ -0,0 +1,109 @@
+#include "ge.h"
+#include "crypto_uint32.h"
+
+/* Rename this so as not to interfere with select() which torint.h apparently
+ * grabs. :p */
+#define select ed25519_ref10_select
+
+static unsigned char equal(signed char b,signed char c)
+{
+ unsigned char ub = b;
+ unsigned char uc = c;
+ unsigned char x = ub ^ uc; /* 0: yes; 1..255: no */
+ crypto_uint32 y = x; /* 0: yes; 1..255: no */
+ y -= 1; /* 4294967295: yes; 0..254: no */
+ y >>= 31; /* 1: yes; 0: no */
+ return y;
+}
+
+static unsigned char negative(signed char b)
+{
+ uint64_t x = b; /* 18446744073709551361..18446744073709551615: yes; 0..255: no */
+ x >>= 63; /* 1: yes; 0: no */
+ return x;
+}
+
+static void cmov(ge_precomp *t,ge_precomp *u,unsigned char b)
+{
+ fe_cmov(t->yplusx,u->yplusx,b);
+ fe_cmov(t->yminusx,u->yminusx,b);
+ fe_cmov(t->xy2d,u->xy2d,b);
+}
+
+/* base[i][j] = (j+1)*256^i*B */
+static ge_precomp base[32][8] = {
+#include "base.h"
+} ;
+
+static void select(ge_precomp *t,int pos,signed char b)
+{
+ ge_precomp minust;
+ unsigned char bnegative = negative(b);
+ unsigned char babs = b - SHL8( (-bnegative) & (unsigned char)b, 1);
+
+ ge_precomp_0(t);
+ cmov(t,&base[pos][0],equal(babs,1));
+ cmov(t,&base[pos][1],equal(babs,2));
+ cmov(t,&base[pos][2],equal(babs,3));
+ cmov(t,&base[pos][3],equal(babs,4));
+ cmov(t,&base[pos][4],equal(babs,5));
+ cmov(t,&base[pos][5],equal(babs,6));
+ cmov(t,&base[pos][6],equal(babs,7));
+ cmov(t,&base[pos][7],equal(babs,8));
+ fe_copy(minust.yplusx,t->yminusx);
+ fe_copy(minust.yminusx,t->yplusx);
+ fe_neg(minust.xy2d,t->xy2d);
+ cmov(t,&minust,bnegative);
+}
+
+/*
+h = a * B
+where a = a[0]+256*a[1]+...+256^31 a[31]
+B is the Ed25519 base point (x,4/5) with x positive.
+
+Preconditions:
+ a[31] <= 127
+*/
+
+void ge_scalarmult_base(ge_p3 *h,const unsigned char *a)
+{
+ signed char e[64];
+ signed char carry;
+ ge_p1p1 r;
+ ge_p2 s;
+ ge_precomp t;
+ int i;
+
+ for (i = 0;i < 32;++i) {
+ e[2 * i + 0] = (a[i] >> 0) & 15;
+ e[2 * i + 1] = (a[i] >> 4) & 15;
+ }
+ /* each e[i] is between 0 and 15 */
+ /* e[63] is between 0 and 7 */
+
+ carry = 0;
+ for (i = 0;i < 63;++i) {
+ e[i] += carry;
+ carry = e[i] + 8;
+ carry >>= 4;
+ e[i] -= SHL8(carry,4);
+ }
+ e[63] += carry;
+ /* each e[i] is between -8 and 8 */
+
+ ge_p3_0(h);
+ for (i = 1;i < 64;i += 2) {
+ select(&t,i / 2,e[i]);
+ ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r);
+ }
+
+ ge_p3_dbl(&r,h); ge_p1p1_to_p2(&s,&r);
+ ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r);
+ ge_p2_dbl(&r,&s); ge_p1p1_to_p2(&s,&r);
+ ge_p2_dbl(&r,&s); ge_p1p1_to_p3(h,&r);
+
+ for (i = 0;i < 64;i += 2) {
+ select(&t,i / 2,e[i]);
+ ge_madd(&r,h,&t); ge_p1p1_to_p3(h,&r);
+ }
+}
diff --git a/src/ext/ed25519/ref10/ge_sub.c b/src/ext/ed25519/ref10/ge_sub.c
new file mode 100644
index 0000000000..69f3d54062
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_sub.c
@@ -0,0 +1,11 @@
+#include "ge.h"
+
+/*
+r = p - q
+*/
+
+void ge_sub(ge_p1p1 *r,const ge_p3 *p,const ge_cached *q)
+{
+ fe t0;
+#include "ge_sub.h"
+}
diff --git a/src/ext/ed25519/ref10/ge_sub.h b/src/ext/ed25519/ref10/ge_sub.h
new file mode 100644
index 0000000000..b4ef1f5dd0
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_sub.h
@@ -0,0 +1,97 @@
+
+/* qhasm: enter ge_sub */
+
+/* qhasm: fe X1 */
+
+/* qhasm: fe Y1 */
+
+/* qhasm: fe Z1 */
+
+/* qhasm: fe Z2 */
+
+/* qhasm: fe T1 */
+
+/* qhasm: fe ZZ */
+
+/* qhasm: fe YpX2 */
+
+/* qhasm: fe YmX2 */
+
+/* qhasm: fe T2d2 */
+
+/* qhasm: fe X3 */
+
+/* qhasm: fe Y3 */
+
+/* qhasm: fe Z3 */
+
+/* qhasm: fe T3 */
+
+/* qhasm: fe YpX1 */
+
+/* qhasm: fe YmX1 */
+
+/* qhasm: fe A */
+
+/* qhasm: fe B */
+
+/* qhasm: fe C */
+
+/* qhasm: fe D */
+
+/* qhasm: YpX1 = Y1+X1 */
+/* asm 1: fe_add(>YpX1=fe#1,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_add(>YpX1=r->X,<Y1=p->Y,<X1=p->X); */
+fe_add(r->X,p->Y,p->X);
+
+/* qhasm: YmX1 = Y1-X1 */
+/* asm 1: fe_sub(>YmX1=fe#2,<Y1=fe#12,<X1=fe#11); */
+/* asm 2: fe_sub(>YmX1=r->Y,<Y1=p->Y,<X1=p->X); */
+fe_sub(r->Y,p->Y,p->X);
+
+/* qhasm: A = YpX1*YmX2 */
+/* asm 1: fe_mul(>A=fe#3,<YpX1=fe#1,<YmX2=fe#16); */
+/* asm 2: fe_mul(>A=r->Z,<YpX1=r->X,<YmX2=q->YminusX); */
+fe_mul(r->Z,r->X,q->YminusX);
+
+/* qhasm: B = YmX1*YpX2 */
+/* asm 1: fe_mul(>B=fe#2,<YmX1=fe#2,<YpX2=fe#15); */
+/* asm 2: fe_mul(>B=r->Y,<YmX1=r->Y,<YpX2=q->YplusX); */
+fe_mul(r->Y,r->Y,q->YplusX);
+
+/* qhasm: C = T2d2*T1 */
+/* asm 1: fe_mul(>C=fe#4,<T2d2=fe#18,<T1=fe#14); */
+/* asm 2: fe_mul(>C=r->T,<T2d2=q->T2d,<T1=p->T); */
+fe_mul(r->T,q->T2d,p->T);
+
+/* qhasm: ZZ = Z1*Z2 */
+/* asm 1: fe_mul(>ZZ=fe#1,<Z1=fe#13,<Z2=fe#17); */
+/* asm 2: fe_mul(>ZZ=r->X,<Z1=p->Z,<Z2=q->Z); */
+fe_mul(r->X,p->Z,q->Z);
+
+/* qhasm: D = 2*ZZ */
+/* asm 1: fe_add(>D=fe#5,<ZZ=fe#1,<ZZ=fe#1); */
+/* asm 2: fe_add(>D=t0,<ZZ=r->X,<ZZ=r->X); */
+fe_add(t0,r->X,r->X);
+
+/* qhasm: X3 = A-B */
+/* asm 1: fe_sub(>X3=fe#1,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_sub(>X3=r->X,<A=r->Z,<B=r->Y); */
+fe_sub(r->X,r->Z,r->Y);
+
+/* qhasm: Y3 = A+B */
+/* asm 1: fe_add(>Y3=fe#2,<A=fe#3,<B=fe#2); */
+/* asm 2: fe_add(>Y3=r->Y,<A=r->Z,<B=r->Y); */
+fe_add(r->Y,r->Z,r->Y);
+
+/* qhasm: Z3 = D-C */
+/* asm 1: fe_sub(>Z3=fe#3,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_sub(>Z3=r->Z,<D=t0,<C=r->T); */
+fe_sub(r->Z,t0,r->T);
+
+/* qhasm: T3 = D+C */
+/* asm 1: fe_add(>T3=fe#4,<D=fe#5,<C=fe#4); */
+/* asm 2: fe_add(>T3=r->T,<D=t0,<C=r->T); */
+fe_add(r->T,t0,r->T);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/ge_sub.q b/src/ext/ed25519/ref10/ge_sub.q
new file mode 100644
index 0000000000..2779a4a201
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_sub.q
@@ -0,0 +1,49 @@
+:name:fe:r->X:r->Y:r->Z:r->T:t0:t1:t2:t3:t4:t5:p->X:p->Y:p->Z:p->T:q->YplusX:q->YminusX:q->Z:q->T2d:
+fe r:var/r=fe:
+
+enter f:enter/f:>X1=fe#11:>Y1=fe#12:>Z1=fe#13:>T1=fe#14:>YpX2=fe#15:>YmX2=fe#16:>Z2=fe#17:>T2d2=fe#18:
+return:nofallthrough:<X3=fe#1:<Y3=fe#2:<Z3=fe#3:<T3=fe#4:leave:
+
+h=f+g:<f=fe:<g=fe:>h=fe:asm/fe_add(>h,<f,<g);:
+h=f-g:<f=fe:<g=fe:>h=fe:asm/fe_sub(>h,<f,<g);:
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2:<f=fe:>h=fe:asm/fe_sq(>h,<f);:
+h=2*g:<g=fe:>h=fe:asm/fe_add(>h,<g,<g);:
+
+:
+
+enter ge_sub
+
+fe X1
+fe Y1
+fe Z1
+fe Z2
+fe T1
+fe ZZ
+fe YpX2
+fe YmX2
+fe T2d2
+fe X3
+fe Y3
+fe Z3
+fe T3
+fe YpX1
+fe YmX1
+fe A
+fe B
+fe C
+fe D
+
+YpX1 = Y1+X1
+YmX1 = Y1-X1
+A = YpX1*YmX2
+B = YmX1*YpX2
+C = T2d2*T1
+ZZ = Z1*Z2
+D = 2*ZZ
+X3 = A-B
+Y3 = A+B
+Z3 = D-C
+T3 = D+C
+
+return
diff --git a/src/ext/ed25519/ref10/ge_tobytes.c b/src/ext/ed25519/ref10/ge_tobytes.c
new file mode 100644
index 0000000000..31b3d33e09
--- /dev/null
+++ b/src/ext/ed25519/ref10/ge_tobytes.c
@@ -0,0 +1,14 @@
+#include "ge.h"
+
+void ge_tobytes(unsigned char *s,const ge_p2 *h)
+{
+ fe recip;
+ fe x;
+ fe y;
+
+ fe_invert(recip,h->Z);
+ fe_mul(x,h->X,recip);
+ fe_mul(y,h->Y,recip);
+ fe_tobytes(s,y);
+ s[31] ^= fe_isnegative(x) << 7;
+}
diff --git a/src/ext/ed25519/ref10/keyconv.c b/src/ext/ed25519/ref10/keyconv.c
new file mode 100644
index 0000000000..854b150d69
--- /dev/null
+++ b/src/ext/ed25519/ref10/keyconv.c
@@ -0,0 +1,37 @@
+/* Added to ref10 for Tor. We place this in the public domain. Alternatively,
+ * you may have it under the Creative Commons 0 "CC0" license. */
+#include "fe.h"
+#include "ed25519_ref10.h"
+
+int ed25519_ref10_pubkey_from_curve25519_pubkey(unsigned char *out,
+ const unsigned char *inp,
+ int signbit)
+{
+ fe u;
+ fe one;
+ fe y;
+ fe uplus1;
+ fe uminus1;
+ fe inv_uplus1;
+
+ /* From prop228:
+
+ Given a curve25519 x-coordinate (u), we can get the y coordinate
+ of the ed25519 key using
+
+ y = (u-1)/(u+1)
+ */
+ fe_frombytes(u, inp);
+ fe_1(one);
+ fe_sub(uminus1, u, one);
+ fe_add(uplus1, u, one);
+ fe_invert(inv_uplus1, uplus1);
+ fe_mul(y, uminus1, inv_uplus1);
+
+ fe_tobytes(out, y);
+
+ /* propagate sign. */
+ out[31] |= (!!signbit) << 7;
+
+ return 0;
+}
diff --git a/src/ext/ed25519/ref10/keypair.c b/src/ext/ed25519/ref10/keypair.c
new file mode 100644
index 0000000000..7ddbaa971e
--- /dev/null
+++ b/src/ext/ed25519/ref10/keypair.c
@@ -0,0 +1,51 @@
+/* Modified for Tor: new API, 64-byte secret keys. */
+#include <string.h>
+#include "randombytes.h"
+#include "crypto_sign.h"
+#include "crypto_hash_sha512.h"
+#include "ge.h"
+
+int
+crypto_sign_seckey(unsigned char *sk)
+{
+ unsigned char seed[32];
+
+ if (randombytes(seed,32) < 0)
+ return -1;
+
+ crypto_sign_seckey_expand(sk, seed);
+
+ memwipe(seed, 0, 32);
+
+ return 0;
+}
+
+int crypto_sign_seckey_expand(unsigned char *sk, const unsigned char *skseed)
+{
+ crypto_hash_sha512(sk,skseed,32);
+ sk[0] &= 248;
+ sk[31] &= 63;
+ sk[31] |= 64;
+
+ return 0;
+}
+
+int crypto_sign_pubkey(unsigned char *pk,const unsigned char *sk)
+{
+ ge_p3 A;
+
+ ge_scalarmult_base(&A,sk);
+ ge_p3_tobytes(pk,&A);
+
+ return 0;
+}
+
+
+int crypto_sign_keypair(unsigned char *pk,unsigned char *sk)
+{
+ crypto_sign_seckey(sk);
+ crypto_sign_pubkey(pk, sk);
+
+ return 0;
+}
+
diff --git a/src/ext/ed25519/ref10/open.c b/src/ext/ed25519/ref10/open.c
new file mode 100644
index 0000000000..9dbeb4cdd0
--- /dev/null
+++ b/src/ext/ed25519/ref10/open.c
@@ -0,0 +1,42 @@
+/* (Modified by Tor to verify signature separately from message) */
+#include <string.h>
+#include "crypto_sign.h"
+#include "crypto_hash_sha512.h"
+#include "crypto_verify_32.h"
+#include "ge.h"
+#include "sc.h"
+
+/* 'signature' must be 64-bytes long. */
+int crypto_sign_open(
+ const unsigned char *signature,
+ const unsigned char *m, size_t mlen,
+ const unsigned char *pk
+)
+{
+ unsigned char pkcopy[32];
+ unsigned char rcopy[32];
+ unsigned char scopy[32];
+ unsigned char h[64];
+ unsigned char rcheck[32];
+ ge_p3 A;
+ ge_p2 R;
+
+ if (signature[63] & 224) goto badsig;
+ if (ge_frombytes_negate_vartime(&A,pk) != 0) goto badsig;
+
+ memmove(pkcopy,pk,32);
+ memmove(rcopy,signature,32);
+ memmove(scopy,signature + 32,32);
+
+ crypto_hash_sha512_3(h, rcopy, 32, pkcopy, 32, m, mlen);
+ sc_reduce(h);
+
+ ge_double_scalarmult_vartime(&R,h,&A,scopy);
+ ge_tobytes(rcheck,&R);
+ if (crypto_verify_32(rcheck,rcopy) == 0) {
+ return 0;
+ }
+
+badsig:
+ return -1;
+}
diff --git a/src/ext/ed25519/ref10/pow22523.h b/src/ext/ed25519/ref10/pow22523.h
new file mode 100644
index 0000000000..9204ff838f
--- /dev/null
+++ b/src/ext/ed25519/ref10/pow22523.h
@@ -0,0 +1,161 @@
+/* Modified by Tor: pointless loops removed to appease analysis tools */
+
+/* qhasm: fe z1 */
+
+/* qhasm: fe z2 */
+
+/* qhasm: fe z8 */
+
+/* qhasm: fe z9 */
+
+/* qhasm: fe z11 */
+
+/* qhasm: fe z22 */
+
+/* qhasm: fe z_5_0 */
+
+/* qhasm: fe z_10_5 */
+
+/* qhasm: fe z_10_0 */
+
+/* qhasm: fe z_20_10 */
+
+/* qhasm: fe z_20_0 */
+
+/* qhasm: fe z_40_20 */
+
+/* qhasm: fe z_40_0 */
+
+/* qhasm: fe z_50_10 */
+
+/* qhasm: fe z_50_0 */
+
+/* qhasm: fe z_100_50 */
+
+/* qhasm: fe z_100_0 */
+
+/* qhasm: fe z_200_100 */
+
+/* qhasm: fe z_200_0 */
+
+/* qhasm: fe z_250_50 */
+
+/* qhasm: fe z_250_0 */
+
+/* qhasm: fe z_252_2 */
+
+/* qhasm: fe z_252_3 */
+
+/* qhasm: enter pow22523 */
+
+/* qhasm: z2 = z1^2^1 */
+/* asm 1: fe_sq(>z2=fe#1,<z1=fe#11); for (i = 1;i < 1;++i) fe_sq(>z2=fe#1,>z2=fe#1); */
+/* asm 2: fe_sq(>z2=t0,<z1=z); for (i = 1;i < 1;++i) fe_sq(>z2=t0,>z2=t0); */
+fe_sq(t0,z); /* DEADCODE This loop has no effect: for (i = 1;i < 1;++i) fe_sq(t0,t0); */
+
+/* qhasm: z8 = z2^2^2 */
+/* asm 1: fe_sq(>z8=fe#2,<z2=fe#1); for (i = 1;i < 2;++i) fe_sq(>z8=fe#2,>z8=fe#2); */
+/* asm 2: fe_sq(>z8=t1,<z2=t0); for (i = 1;i < 2;++i) fe_sq(>z8=t1,>z8=t1); */
+fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1);
+
+/* qhasm: z9 = z1*z8 */
+/* asm 1: fe_mul(>z9=fe#2,<z1=fe#11,<z8=fe#2); */
+/* asm 2: fe_mul(>z9=t1,<z1=z,<z8=t1); */
+fe_mul(t1,z,t1);
+
+/* qhasm: z11 = z2*z9 */
+/* asm 1: fe_mul(>z11=fe#1,<z2=fe#1,<z9=fe#2); */
+/* asm 2: fe_mul(>z11=t0,<z2=t0,<z9=t1); */
+fe_mul(t0,t0,t1);
+
+/* qhasm: z22 = z11^2^1 */
+/* asm 1: fe_sq(>z22=fe#1,<z11=fe#1); for (i = 1;i < 1;++i) fe_sq(>z22=fe#1,>z22=fe#1); */
+/* asm 2: fe_sq(>z22=t0,<z11=t0); for (i = 1;i < 1;++i) fe_sq(>z22=t0,>z22=t0); */
+fe_sq(t0,t0); /* DEADCODE This loop has no effect: for (i = 1;i < 1;++i) fe_sq(t0,t0); */
+
+/* qhasm: z_5_0 = z9*z22 */
+/* asm 1: fe_mul(>z_5_0=fe#1,<z9=fe#2,<z22=fe#1); */
+/* asm 2: fe_mul(>z_5_0=t0,<z9=t1,<z22=t0); */
+fe_mul(t0,t1,t0);
+
+/* qhasm: z_10_5 = z_5_0^2^5 */
+/* asm 1: fe_sq(>z_10_5=fe#2,<z_5_0=fe#1); for (i = 1;i < 5;++i) fe_sq(>z_10_5=fe#2,>z_10_5=fe#2); */
+/* asm 2: fe_sq(>z_10_5=t1,<z_5_0=t0); for (i = 1;i < 5;++i) fe_sq(>z_10_5=t1,>z_10_5=t1); */
+fe_sq(t1,t0); for (i = 1;i < 5;++i) fe_sq(t1,t1);
+
+/* qhasm: z_10_0 = z_10_5*z_5_0 */
+/* asm 1: fe_mul(>z_10_0=fe#1,<z_10_5=fe#2,<z_5_0=fe#1); */
+/* asm 2: fe_mul(>z_10_0=t0,<z_10_5=t1,<z_5_0=t0); */
+fe_mul(t0,t1,t0);
+
+/* qhasm: z_20_10 = z_10_0^2^10 */
+/* asm 1: fe_sq(>z_20_10=fe#2,<z_10_0=fe#1); for (i = 1;i < 10;++i) fe_sq(>z_20_10=fe#2,>z_20_10=fe#2); */
+/* asm 2: fe_sq(>z_20_10=t1,<z_10_0=t0); for (i = 1;i < 10;++i) fe_sq(>z_20_10=t1,>z_20_10=t1); */
+fe_sq(t1,t0); for (i = 1;i < 10;++i) fe_sq(t1,t1);
+
+/* qhasm: z_20_0 = z_20_10*z_10_0 */
+/* asm 1: fe_mul(>z_20_0=fe#2,<z_20_10=fe#2,<z_10_0=fe#1); */
+/* asm 2: fe_mul(>z_20_0=t1,<z_20_10=t1,<z_10_0=t0); */
+fe_mul(t1,t1,t0);
+
+/* qhasm: z_40_20 = z_20_0^2^20 */
+/* asm 1: fe_sq(>z_40_20=fe#3,<z_20_0=fe#2); for (i = 1;i < 20;++i) fe_sq(>z_40_20=fe#3,>z_40_20=fe#3); */
+/* asm 2: fe_sq(>z_40_20=t2,<z_20_0=t1); for (i = 1;i < 20;++i) fe_sq(>z_40_20=t2,>z_40_20=t2); */
+fe_sq(t2,t1); for (i = 1;i < 20;++i) fe_sq(t2,t2);
+
+/* qhasm: z_40_0 = z_40_20*z_20_0 */
+/* asm 1: fe_mul(>z_40_0=fe#2,<z_40_20=fe#3,<z_20_0=fe#2); */
+/* asm 2: fe_mul(>z_40_0=t1,<z_40_20=t2,<z_20_0=t1); */
+fe_mul(t1,t2,t1);
+
+/* qhasm: z_50_10 = z_40_0^2^10 */
+/* asm 1: fe_sq(>z_50_10=fe#2,<z_40_0=fe#2); for (i = 1;i < 10;++i) fe_sq(>z_50_10=fe#2,>z_50_10=fe#2); */
+/* asm 2: fe_sq(>z_50_10=t1,<z_40_0=t1); for (i = 1;i < 10;++i) fe_sq(>z_50_10=t1,>z_50_10=t1); */
+fe_sq(t1,t1); for (i = 1;i < 10;++i) fe_sq(t1,t1);
+
+/* qhasm: z_50_0 = z_50_10*z_10_0 */
+/* asm 1: fe_mul(>z_50_0=fe#1,<z_50_10=fe#2,<z_10_0=fe#1); */
+/* asm 2: fe_mul(>z_50_0=t0,<z_50_10=t1,<z_10_0=t0); */
+fe_mul(t0,t1,t0);
+
+/* qhasm: z_100_50 = z_50_0^2^50 */
+/* asm 1: fe_sq(>z_100_50=fe#2,<z_50_0=fe#1); for (i = 1;i < 50;++i) fe_sq(>z_100_50=fe#2,>z_100_50=fe#2); */
+/* asm 2: fe_sq(>z_100_50=t1,<z_50_0=t0); for (i = 1;i < 50;++i) fe_sq(>z_100_50=t1,>z_100_50=t1); */
+fe_sq(t1,t0); for (i = 1;i < 50;++i) fe_sq(t1,t1);
+
+/* qhasm: z_100_0 = z_100_50*z_50_0 */
+/* asm 1: fe_mul(>z_100_0=fe#2,<z_100_50=fe#2,<z_50_0=fe#1); */
+/* asm 2: fe_mul(>z_100_0=t1,<z_100_50=t1,<z_50_0=t0); */
+fe_mul(t1,t1,t0);
+
+/* qhasm: z_200_100 = z_100_0^2^100 */
+/* asm 1: fe_sq(>z_200_100=fe#3,<z_100_0=fe#2); for (i = 1;i < 100;++i) fe_sq(>z_200_100=fe#3,>z_200_100=fe#3); */
+/* asm 2: fe_sq(>z_200_100=t2,<z_100_0=t1); for (i = 1;i < 100;++i) fe_sq(>z_200_100=t2,>z_200_100=t2); */
+fe_sq(t2,t1); for (i = 1;i < 100;++i) fe_sq(t2,t2);
+
+/* qhasm: z_200_0 = z_200_100*z_100_0 */
+/* asm 1: fe_mul(>z_200_0=fe#2,<z_200_100=fe#3,<z_100_0=fe#2); */
+/* asm 2: fe_mul(>z_200_0=t1,<z_200_100=t2,<z_100_0=t1); */
+fe_mul(t1,t2,t1);
+
+/* qhasm: z_250_50 = z_200_0^2^50 */
+/* asm 1: fe_sq(>z_250_50=fe#2,<z_200_0=fe#2); for (i = 1;i < 50;++i) fe_sq(>z_250_50=fe#2,>z_250_50=fe#2); */
+/* asm 2: fe_sq(>z_250_50=t1,<z_200_0=t1); for (i = 1;i < 50;++i) fe_sq(>z_250_50=t1,>z_250_50=t1); */
+fe_sq(t1,t1); for (i = 1;i < 50;++i) fe_sq(t1,t1);
+
+/* qhasm: z_250_0 = z_250_50*z_50_0 */
+/* asm 1: fe_mul(>z_250_0=fe#1,<z_250_50=fe#2,<z_50_0=fe#1); */
+/* asm 2: fe_mul(>z_250_0=t0,<z_250_50=t1,<z_50_0=t0); */
+fe_mul(t0,t1,t0);
+
+/* qhasm: z_252_2 = z_250_0^2^2 */
+/* asm 1: fe_sq(>z_252_2=fe#1,<z_250_0=fe#1); for (i = 1;i < 2;++i) fe_sq(>z_252_2=fe#1,>z_252_2=fe#1); */
+/* asm 2: fe_sq(>z_252_2=t0,<z_250_0=t0); for (i = 1;i < 2;++i) fe_sq(>z_252_2=t0,>z_252_2=t0); */
+fe_sq(t0,t0); for (i = 1;i < 2;++i) fe_sq(t0,t0);
+
+/* qhasm: z_252_3 = z_252_2*z1 */
+/* asm 1: fe_mul(>z_252_3=fe#12,<z_252_2=fe#1,<z1=fe#11); */
+/* asm 2: fe_mul(>z_252_3=out,<z_252_2=t0,<z1=z); */
+fe_mul(out,t0,z);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/pow22523.q b/src/ext/ed25519/ref10/pow22523.q
new file mode 100644
index 0000000000..2ce1da9d4d
--- /dev/null
+++ b/src/ext/ed25519/ref10/pow22523.q
@@ -0,0 +1,61 @@
+:name:fe:t0:t1:t2:t3:t4:t5:t6:t7:t8:t9:z:out:
+fe r:var/r=fe:
+
+enter f:enter/f:>z1=fe#11:
+return:nofallthrough:<z_252_3=fe#12:leave:
+
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2^k:<f=fe:>h=fe:#k:asm/fe_sq(>h,<f); for (i = 1;i !lt; #k;++i) fe_sq(>h,>h);:
+
+:
+
+fe z1
+fe z2
+fe z8
+fe z9
+fe z11
+fe z22
+fe z_5_0
+fe z_10_5
+fe z_10_0
+fe z_20_10
+fe z_20_0
+fe z_40_20
+fe z_40_0
+fe z_50_10
+fe z_50_0
+fe z_100_50
+fe z_100_0
+fe z_200_100
+fe z_200_0
+fe z_250_50
+fe z_250_0
+fe z_252_2
+fe z_252_3
+
+enter pow22523
+
+z2 = z1^2^1
+z8 = z2^2^2
+z9 = z1*z8
+z11 = z2*z9
+z22 = z11^2^1
+z_5_0 = z9*z22
+z_10_5 = z_5_0^2^5
+z_10_0 = z_10_5*z_5_0
+z_20_10 = z_10_0^2^10
+z_20_0 = z_20_10*z_10_0
+z_40_20 = z_20_0^2^20
+z_40_0 = z_40_20*z_20_0
+z_50_10 = z_40_0^2^10
+z_50_0 = z_50_10*z_10_0
+z_100_50 = z_50_0^2^50
+z_100_0 = z_100_50*z_50_0
+z_200_100 = z_100_0^2^100
+z_200_0 = z_200_100*z_100_0
+z_250_50 = z_200_0^2^50
+z_250_0 = z_250_50*z_50_0
+z_252_2 = z_250_0^2^2
+z_252_3 = z_252_2*z1
+
+return
diff --git a/src/ext/ed25519/ref10/pow225521.h b/src/ext/ed25519/ref10/pow225521.h
new file mode 100644
index 0000000000..fe2af94c03
--- /dev/null
+++ b/src/ext/ed25519/ref10/pow225521.h
@@ -0,0 +1,161 @@
+/* Modified by Tor: pointless loops removed to appease analysis tools */
+
+/* qhasm: fe z1 */
+
+/* qhasm: fe z2 */
+
+/* qhasm: fe z8 */
+
+/* qhasm: fe z9 */
+
+/* qhasm: fe z11 */
+
+/* qhasm: fe z22 */
+
+/* qhasm: fe z_5_0 */
+
+/* qhasm: fe z_10_5 */
+
+/* qhasm: fe z_10_0 */
+
+/* qhasm: fe z_20_10 */
+
+/* qhasm: fe z_20_0 */
+
+/* qhasm: fe z_40_20 */
+
+/* qhasm: fe z_40_0 */
+
+/* qhasm: fe z_50_10 */
+
+/* qhasm: fe z_50_0 */
+
+/* qhasm: fe z_100_50 */
+
+/* qhasm: fe z_100_0 */
+
+/* qhasm: fe z_200_100 */
+
+/* qhasm: fe z_200_0 */
+
+/* qhasm: fe z_250_50 */
+
+/* qhasm: fe z_250_0 */
+
+/* qhasm: fe z_255_5 */
+
+/* qhasm: fe z_255_21 */
+
+/* qhasm: enter pow225521 */
+
+/* qhasm: z2 = z1^2^1 */
+/* asm 1: fe_sq(>z2=fe#1,<z1=fe#11); for (i = 1;i < 1;++i) fe_sq(>z2=fe#1,>z2=fe#1); */
+/* asm 2: fe_sq(>z2=t0,<z1=z); for (i = 1;i < 1;++i) fe_sq(>z2=t0,>z2=t0); */
+fe_sq(t0,z); /* DEADCODE This loop has no effect: for (i = 1;i < 1;++i) fe_sq(t0,t0); */
+
+/* qhasm: z8 = z2^2^2 */
+/* asm 1: fe_sq(>z8=fe#2,<z2=fe#1); for (i = 1;i < 2;++i) fe_sq(>z8=fe#2,>z8=fe#2); */
+/* asm 2: fe_sq(>z8=t1,<z2=t0); for (i = 1;i < 2;++i) fe_sq(>z8=t1,>z8=t1); */
+fe_sq(t1,t0); for (i = 1;i < 2;++i) fe_sq(t1,t1);
+
+/* qhasm: z9 = z1*z8 */
+/* asm 1: fe_mul(>z9=fe#2,<z1=fe#11,<z8=fe#2); */
+/* asm 2: fe_mul(>z9=t1,<z1=z,<z8=t1); */
+fe_mul(t1,z,t1);
+
+/* qhasm: z11 = z2*z9 */
+/* asm 1: fe_mul(>z11=fe#1,<z2=fe#1,<z9=fe#2); */
+/* asm 2: fe_mul(>z11=t0,<z2=t0,<z9=t1); */
+fe_mul(t0,t0,t1);
+
+/* qhasm: z22 = z11^2^1 */
+/* asm 1: fe_sq(>z22=fe#3,<z11=fe#1); for (i = 1;i < 1;++i) fe_sq(>z22=fe#3,>z22=fe#3); */
+/* asm 2: fe_sq(>z22=t2,<z11=t0); for (i = 1;i < 1;++i) fe_sq(>z22=t2,>z22=t2); */
+fe_sq(t2,t0); /* DEADCODE This loop has no effect for (i = 1;i < 1;++i) fe_sq(t2,t2); */
+
+/* qhasm: z_5_0 = z9*z22 */
+/* asm 1: fe_mul(>z_5_0=fe#2,<z9=fe#2,<z22=fe#3); */
+/* asm 2: fe_mul(>z_5_0=t1,<z9=t1,<z22=t2); */
+fe_mul(t1,t1,t2);
+
+/* qhasm: z_10_5 = z_5_0^2^5 */
+/* asm 1: fe_sq(>z_10_5=fe#3,<z_5_0=fe#2); for (i = 1;i < 5;++i) fe_sq(>z_10_5=fe#3,>z_10_5=fe#3); */
+/* asm 2: fe_sq(>z_10_5=t2,<z_5_0=t1); for (i = 1;i < 5;++i) fe_sq(>z_10_5=t2,>z_10_5=t2); */
+fe_sq(t2,t1); for (i = 1;i < 5;++i) fe_sq(t2,t2);
+
+/* qhasm: z_10_0 = z_10_5*z_5_0 */
+/* asm 1: fe_mul(>z_10_0=fe#2,<z_10_5=fe#3,<z_5_0=fe#2); */
+/* asm 2: fe_mul(>z_10_0=t1,<z_10_5=t2,<z_5_0=t1); */
+fe_mul(t1,t2,t1);
+
+/* qhasm: z_20_10 = z_10_0^2^10 */
+/* asm 1: fe_sq(>z_20_10=fe#3,<z_10_0=fe#2); for (i = 1;i < 10;++i) fe_sq(>z_20_10=fe#3,>z_20_10=fe#3); */
+/* asm 2: fe_sq(>z_20_10=t2,<z_10_0=t1); for (i = 1;i < 10;++i) fe_sq(>z_20_10=t2,>z_20_10=t2); */
+fe_sq(t2,t1); for (i = 1;i < 10;++i) fe_sq(t2,t2);
+
+/* qhasm: z_20_0 = z_20_10*z_10_0 */
+/* asm 1: fe_mul(>z_20_0=fe#3,<z_20_10=fe#3,<z_10_0=fe#2); */
+/* asm 2: fe_mul(>z_20_0=t2,<z_20_10=t2,<z_10_0=t1); */
+fe_mul(t2,t2,t1);
+
+/* qhasm: z_40_20 = z_20_0^2^20 */
+/* asm 1: fe_sq(>z_40_20=fe#4,<z_20_0=fe#3); for (i = 1;i < 20;++i) fe_sq(>z_40_20=fe#4,>z_40_20=fe#4); */
+/* asm 2: fe_sq(>z_40_20=t3,<z_20_0=t2); for (i = 1;i < 20;++i) fe_sq(>z_40_20=t3,>z_40_20=t3); */
+fe_sq(t3,t2); for (i = 1;i < 20;++i) fe_sq(t3,t3);
+
+/* qhasm: z_40_0 = z_40_20*z_20_0 */
+/* asm 1: fe_mul(>z_40_0=fe#3,<z_40_20=fe#4,<z_20_0=fe#3); */
+/* asm 2: fe_mul(>z_40_0=t2,<z_40_20=t3,<z_20_0=t2); */
+fe_mul(t2,t3,t2);
+
+/* qhasm: z_50_10 = z_40_0^2^10 */
+/* asm 1: fe_sq(>z_50_10=fe#3,<z_40_0=fe#3); for (i = 1;i < 10;++i) fe_sq(>z_50_10=fe#3,>z_50_10=fe#3); */
+/* asm 2: fe_sq(>z_50_10=t2,<z_40_0=t2); for (i = 1;i < 10;++i) fe_sq(>z_50_10=t2,>z_50_10=t2); */
+fe_sq(t2,t2); for (i = 1;i < 10;++i) fe_sq(t2,t2);
+
+/* qhasm: z_50_0 = z_50_10*z_10_0 */
+/* asm 1: fe_mul(>z_50_0=fe#2,<z_50_10=fe#3,<z_10_0=fe#2); */
+/* asm 2: fe_mul(>z_50_0=t1,<z_50_10=t2,<z_10_0=t1); */
+fe_mul(t1,t2,t1);
+
+/* qhasm: z_100_50 = z_50_0^2^50 */
+/* asm 1: fe_sq(>z_100_50=fe#3,<z_50_0=fe#2); for (i = 1;i < 50;++i) fe_sq(>z_100_50=fe#3,>z_100_50=fe#3); */
+/* asm 2: fe_sq(>z_100_50=t2,<z_50_0=t1); for (i = 1;i < 50;++i) fe_sq(>z_100_50=t2,>z_100_50=t2); */
+fe_sq(t2,t1); for (i = 1;i < 50;++i) fe_sq(t2,t2);
+
+/* qhasm: z_100_0 = z_100_50*z_50_0 */
+/* asm 1: fe_mul(>z_100_0=fe#3,<z_100_50=fe#3,<z_50_0=fe#2); */
+/* asm 2: fe_mul(>z_100_0=t2,<z_100_50=t2,<z_50_0=t1); */
+fe_mul(t2,t2,t1);
+
+/* qhasm: z_200_100 = z_100_0^2^100 */
+/* asm 1: fe_sq(>z_200_100=fe#4,<z_100_0=fe#3); for (i = 1;i < 100;++i) fe_sq(>z_200_100=fe#4,>z_200_100=fe#4); */
+/* asm 2: fe_sq(>z_200_100=t3,<z_100_0=t2); for (i = 1;i < 100;++i) fe_sq(>z_200_100=t3,>z_200_100=t3); */
+fe_sq(t3,t2); for (i = 1;i < 100;++i) fe_sq(t3,t3);
+
+/* qhasm: z_200_0 = z_200_100*z_100_0 */
+/* asm 1: fe_mul(>z_200_0=fe#3,<z_200_100=fe#4,<z_100_0=fe#3); */
+/* asm 2: fe_mul(>z_200_0=t2,<z_200_100=t3,<z_100_0=t2); */
+fe_mul(t2,t3,t2);
+
+/* qhasm: z_250_50 = z_200_0^2^50 */
+/* asm 1: fe_sq(>z_250_50=fe#3,<z_200_0=fe#3); for (i = 1;i < 50;++i) fe_sq(>z_250_50=fe#3,>z_250_50=fe#3); */
+/* asm 2: fe_sq(>z_250_50=t2,<z_200_0=t2); for (i = 1;i < 50;++i) fe_sq(>z_250_50=t2,>z_250_50=t2); */
+fe_sq(t2,t2); for (i = 1;i < 50;++i) fe_sq(t2,t2);
+
+/* qhasm: z_250_0 = z_250_50*z_50_0 */
+/* asm 1: fe_mul(>z_250_0=fe#2,<z_250_50=fe#3,<z_50_0=fe#2); */
+/* asm 2: fe_mul(>z_250_0=t1,<z_250_50=t2,<z_50_0=t1); */
+fe_mul(t1,t2,t1);
+
+/* qhasm: z_255_5 = z_250_0^2^5 */
+/* asm 1: fe_sq(>z_255_5=fe#2,<z_250_0=fe#2); for (i = 1;i < 5;++i) fe_sq(>z_255_5=fe#2,>z_255_5=fe#2); */
+/* asm 2: fe_sq(>z_255_5=t1,<z_250_0=t1); for (i = 1;i < 5;++i) fe_sq(>z_255_5=t1,>z_255_5=t1); */
+fe_sq(t1,t1); for (i = 1;i < 5;++i) fe_sq(t1,t1);
+
+/* qhasm: z_255_21 = z_255_5*z11 */
+/* asm 1: fe_mul(>z_255_21=fe#12,<z_255_5=fe#2,<z11=fe#1); */
+/* asm 2: fe_mul(>z_255_21=out,<z_255_5=t1,<z11=t0); */
+fe_mul(out,t1,t0);
+
+/* qhasm: return */
diff --git a/src/ext/ed25519/ref10/pow225521.q b/src/ext/ed25519/ref10/pow225521.q
new file mode 100644
index 0000000000..45be57c08a
--- /dev/null
+++ b/src/ext/ed25519/ref10/pow225521.q
@@ -0,0 +1,61 @@
+:name:fe:t0:t1:t2:t3:t4:t5:t6:t7:t8:t9:z:out:
+fe r:var/r=fe:
+
+enter f:enter/f:>z1=fe#11:
+return:nofallthrough:<z_255_21=fe#12:leave:
+
+h=f*g:<f=fe:<g=fe:>h=fe:asm/fe_mul(>h,<f,<g);:
+h=f^2^k:<f=fe:>h=fe:#k:asm/fe_sq(>h,<f); for (i = 1;i !lt; #k;++i) fe_sq(>h,>h);:
+
+:
+
+fe z1
+fe z2
+fe z8
+fe z9
+fe z11
+fe z22
+fe z_5_0
+fe z_10_5
+fe z_10_0
+fe z_20_10
+fe z_20_0
+fe z_40_20
+fe z_40_0
+fe z_50_10
+fe z_50_0
+fe z_100_50
+fe z_100_0
+fe z_200_100
+fe z_200_0
+fe z_250_50
+fe z_250_0
+fe z_255_5
+fe z_255_21
+
+enter pow225521
+
+z2 = z1^2^1
+z8 = z2^2^2
+z9 = z1*z8
+z11 = z2*z9
+z22 = z11^2^1
+z_5_0 = z9*z22
+z_10_5 = z_5_0^2^5
+z_10_0 = z_10_5*z_5_0
+z_20_10 = z_10_0^2^10
+z_20_0 = z_20_10*z_10_0
+z_40_20 = z_20_0^2^20
+z_40_0 = z_40_20*z_20_0
+z_50_10 = z_40_0^2^10
+z_50_0 = z_50_10*z_10_0
+z_100_50 = z_50_0^2^50
+z_100_0 = z_100_50*z_50_0
+z_200_100 = z_100_0^2^100
+z_200_0 = z_200_100*z_100_0
+z_250_50 = z_200_0^2^50
+z_250_0 = z_250_50*z_50_0
+z_255_5 = z_250_0^2^5
+z_255_21 = z_255_5*z11
+
+return
diff --git a/src/ext/ed25519/ref10/q2h.sh b/src/ext/ed25519/ref10/q2h.sh
new file mode 100755
index 0000000000..47ec5110e8
--- /dev/null
+++ b/src/ext/ed25519/ref10/q2h.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+sed 's/^#.*//' \
+| qhasm-generic \
+| sed 's_//\(.*\)$_/*\1 */_'
diff --git a/src/ext/ed25519/ref10/randombytes.h b/src/ext/ed25519/ref10/randombytes.h
new file mode 100644
index 0000000000..fc709fcefc
--- /dev/null
+++ b/src/ext/ed25519/ref10/randombytes.h
@@ -0,0 +1,4 @@
+/* Added for Tor. */
+#include "crypto.h"
+#define randombytes(b, n) \
+ (crypto_strongest_rand((b), (n)))
diff --git a/src/ext/ed25519/ref10/sc.h b/src/ext/ed25519/ref10/sc.h
new file mode 100644
index 0000000000..d32ed2e8ca
--- /dev/null
+++ b/src/ext/ed25519/ref10/sc.h
@@ -0,0 +1,15 @@
+#ifndef SC_H
+#define SC_H
+
+/*
+The set of scalars is \Z/l
+where l = 2^252 + 27742317777372353535851937790883648493.
+*/
+
+#define sc_reduce crypto_sign_ed25519_ref10_sc_reduce
+#define sc_muladd crypto_sign_ed25519_ref10_sc_muladd
+
+extern void sc_reduce(unsigned char *);
+extern void sc_muladd(unsigned char *,const unsigned char *,const unsigned char *,const unsigned char *);
+
+#endif
diff --git a/src/ext/ed25519/ref10/sc_muladd.c b/src/ext/ed25519/ref10/sc_muladd.c
new file mode 100644
index 0000000000..20b94c1049
--- /dev/null
+++ b/src/ext/ed25519/ref10/sc_muladd.c
@@ -0,0 +1,368 @@
+#include "sc.h"
+#include "crypto_int64.h"
+#include "crypto_uint32.h"
+#include "crypto_uint64.h"
+
+static crypto_uint64 load_3(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ return result;
+}
+
+static crypto_uint64 load_4(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ result |= ((crypto_uint64) in[3]) << 24;
+ return result;
+}
+
+/*
+Input:
+ a[0]+256*a[1]+...+256^31*a[31] = a
+ b[0]+256*b[1]+...+256^31*b[31] = b
+ c[0]+256*c[1]+...+256^31*c[31] = c
+
+Output:
+ s[0]+256*s[1]+...+256^31*s[31] = (ab+c) mod l
+ where l = 2^252 + 27742317777372353535851937790883648493.
+*/
+
+void sc_muladd(unsigned char *s,const unsigned char *a,const unsigned char *b,const unsigned char *c)
+{
+ crypto_int64 a0 = 2097151 & load_3(a);
+ crypto_int64 a1 = 2097151 & (load_4(a + 2) >> 5);
+ crypto_int64 a2 = 2097151 & (load_3(a + 5) >> 2);
+ crypto_int64 a3 = 2097151 & (load_4(a + 7) >> 7);
+ crypto_int64 a4 = 2097151 & (load_4(a + 10) >> 4);
+ crypto_int64 a5 = 2097151 & (load_3(a + 13) >> 1);
+ crypto_int64 a6 = 2097151 & (load_4(a + 15) >> 6);
+ crypto_int64 a7 = 2097151 & (load_3(a + 18) >> 3);
+ crypto_int64 a8 = 2097151 & load_3(a + 21);
+ crypto_int64 a9 = 2097151 & (load_4(a + 23) >> 5);
+ crypto_int64 a10 = 2097151 & (load_3(a + 26) >> 2);
+ crypto_int64 a11 = (load_4(a + 28) >> 7);
+ crypto_int64 b0 = 2097151 & load_3(b);
+ crypto_int64 b1 = 2097151 & (load_4(b + 2) >> 5);
+ crypto_int64 b2 = 2097151 & (load_3(b + 5) >> 2);
+ crypto_int64 b3 = 2097151 & (load_4(b + 7) >> 7);
+ crypto_int64 b4 = 2097151 & (load_4(b + 10) >> 4);
+ crypto_int64 b5 = 2097151 & (load_3(b + 13) >> 1);
+ crypto_int64 b6 = 2097151 & (load_4(b + 15) >> 6);
+ crypto_int64 b7 = 2097151 & (load_3(b + 18) >> 3);
+ crypto_int64 b8 = 2097151 & load_3(b + 21);
+ crypto_int64 b9 = 2097151 & (load_4(b + 23) >> 5);
+ crypto_int64 b10 = 2097151 & (load_3(b + 26) >> 2);
+ crypto_int64 b11 = (load_4(b + 28) >> 7);
+ crypto_int64 c0 = 2097151 & load_3(c);
+ crypto_int64 c1 = 2097151 & (load_4(c + 2) >> 5);
+ crypto_int64 c2 = 2097151 & (load_3(c + 5) >> 2);
+ crypto_int64 c3 = 2097151 & (load_4(c + 7) >> 7);
+ crypto_int64 c4 = 2097151 & (load_4(c + 10) >> 4);
+ crypto_int64 c5 = 2097151 & (load_3(c + 13) >> 1);
+ crypto_int64 c6 = 2097151 & (load_4(c + 15) >> 6);
+ crypto_int64 c7 = 2097151 & (load_3(c + 18) >> 3);
+ crypto_int64 c8 = 2097151 & load_3(c + 21);
+ crypto_int64 c9 = 2097151 & (load_4(c + 23) >> 5);
+ crypto_int64 c10 = 2097151 & (load_3(c + 26) >> 2);
+ crypto_int64 c11 = (load_4(c + 28) >> 7);
+ crypto_int64 s0;
+ crypto_int64 s1;
+ crypto_int64 s2;
+ crypto_int64 s3;
+ crypto_int64 s4;
+ crypto_int64 s5;
+ crypto_int64 s6;
+ crypto_int64 s7;
+ crypto_int64 s8;
+ crypto_int64 s9;
+ crypto_int64 s10;
+ crypto_int64 s11;
+ crypto_int64 s12;
+ crypto_int64 s13;
+ crypto_int64 s14;
+ crypto_int64 s15;
+ crypto_int64 s16;
+ crypto_int64 s17;
+ crypto_int64 s18;
+ crypto_int64 s19;
+ crypto_int64 s20;
+ crypto_int64 s21;
+ crypto_int64 s22;
+ crypto_int64 s23;
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+ crypto_int64 carry10;
+ crypto_int64 carry11;
+ crypto_int64 carry12;
+ crypto_int64 carry13;
+ crypto_int64 carry14;
+ crypto_int64 carry15;
+ crypto_int64 carry16;
+ crypto_int64 carry17;
+ crypto_int64 carry18;
+ crypto_int64 carry19;
+ crypto_int64 carry20;
+ crypto_int64 carry21;
+ crypto_int64 carry22;
+
+ s0 = c0 + a0*b0;
+ s1 = c1 + a0*b1 + a1*b0;
+ s2 = c2 + a0*b2 + a1*b1 + a2*b0;
+ s3 = c3 + a0*b3 + a1*b2 + a2*b1 + a3*b0;
+ s4 = c4 + a0*b4 + a1*b3 + a2*b2 + a3*b1 + a4*b0;
+ s5 = c5 + a0*b5 + a1*b4 + a2*b3 + a3*b2 + a4*b1 + a5*b0;
+ s6 = c6 + a0*b6 + a1*b5 + a2*b4 + a3*b3 + a4*b2 + a5*b1 + a6*b0;
+ s7 = c7 + a0*b7 + a1*b6 + a2*b5 + a3*b4 + a4*b3 + a5*b2 + a6*b1 + a7*b0;
+ s8 = c8 + a0*b8 + a1*b7 + a2*b6 + a3*b5 + a4*b4 + a5*b3 + a6*b2 + a7*b1 + a8*b0;
+ s9 = c9 + a0*b9 + a1*b8 + a2*b7 + a3*b6 + a4*b5 + a5*b4 + a6*b3 + a7*b2 + a8*b1 + a9*b0;
+ s10 = c10 + a0*b10 + a1*b9 + a2*b8 + a3*b7 + a4*b6 + a5*b5 + a6*b4 + a7*b3 + a8*b2 + a9*b1 + a10*b0;
+ s11 = c11 + a0*b11 + a1*b10 + a2*b9 + a3*b8 + a4*b7 + a5*b6 + a6*b5 + a7*b4 + a8*b3 + a9*b2 + a10*b1 + a11*b0;
+ s12 = a1*b11 + a2*b10 + a3*b9 + a4*b8 + a5*b7 + a6*b6 + a7*b5 + a8*b4 + a9*b3 + a10*b2 + a11*b1;
+ s13 = a2*b11 + a3*b10 + a4*b9 + a5*b8 + a6*b7 + a7*b6 + a8*b5 + a9*b4 + a10*b3 + a11*b2;
+ s14 = a3*b11 + a4*b10 + a5*b9 + a6*b8 + a7*b7 + a8*b6 + a9*b5 + a10*b4 + a11*b3;
+ s15 = a4*b11 + a5*b10 + a6*b9 + a7*b8 + a8*b7 + a9*b6 + a10*b5 + a11*b4;
+ s16 = a5*b11 + a6*b10 + a7*b9 + a8*b8 + a9*b7 + a10*b6 + a11*b5;
+ s17 = a6*b11 + a7*b10 + a8*b9 + a9*b8 + a10*b7 + a11*b6;
+ s18 = a7*b11 + a8*b10 + a9*b9 + a10*b8 + a11*b7;
+ s19 = a8*b11 + a9*b10 + a10*b9 + a11*b8;
+ s20 = a9*b11 + a10*b10 + a11*b9;
+ s21 = a10*b11 + a11*b10;
+ s22 = a11*b11;
+ s23 = 0;
+
+ carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+ carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= SHL64(carry12,21);
+ carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= SHL64(carry14,21);
+ carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= SHL64(carry16,21);
+ carry18 = (s18 + (1<<20)) >> 21; s19 += carry18; s18 -= SHL64(carry18,21);
+ carry20 = (s20 + (1<<20)) >> 21; s21 += carry20; s20 -= SHL64(carry20,21);
+ carry22 = (s22 + (1<<20)) >> 21; s23 += carry22; s22 -= SHL64(carry22,21);
+
+ carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+ carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= SHL64(carry13,21);
+ carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= SHL64(carry15,21);
+ carry17 = (s17 + (1<<20)) >> 21; s18 += carry17; s17 -= SHL64(carry17,21);
+ carry19 = (s19 + (1<<20)) >> 21; s20 += carry19; s19 -= SHL64(carry19,21);
+ carry21 = (s21 + (1<<20)) >> 21; s22 += carry21; s21 -= SHL64(carry21,21);
+
+ s11 += s23 * 666643;
+ s12 += s23 * 470296;
+ s13 += s23 * 654183;
+ s14 -= s23 * 997805;
+ s15 += s23 * 136657;
+ s16 -= s23 * 683901;
+ s23 = 0;
+
+ s10 += s22 * 666643;
+ s11 += s22 * 470296;
+ s12 += s22 * 654183;
+ s13 -= s22 * 997805;
+ s14 += s22 * 136657;
+ s15 -= s22 * 683901;
+ s22 = 0;
+
+ s9 += s21 * 666643;
+ s10 += s21 * 470296;
+ s11 += s21 * 654183;
+ s12 -= s21 * 997805;
+ s13 += s21 * 136657;
+ s14 -= s21 * 683901;
+ s21 = 0;
+
+ s8 += s20 * 666643;
+ s9 += s20 * 470296;
+ s10 += s20 * 654183;
+ s11 -= s20 * 997805;
+ s12 += s20 * 136657;
+ s13 -= s20 * 683901;
+ s20 = 0;
+
+ s7 += s19 * 666643;
+ s8 += s19 * 470296;
+ s9 += s19 * 654183;
+ s10 -= s19 * 997805;
+ s11 += s19 * 136657;
+ s12 -= s19 * 683901;
+ s19 = 0;
+
+ s6 += s18 * 666643;
+ s7 += s18 * 470296;
+ s8 += s18 * 654183;
+ s9 -= s18 * 997805;
+ s10 += s18 * 136657;
+ s11 -= s18 * 683901;
+ s18 = 0;
+
+ carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+ carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= SHL64(carry12,21);
+ carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= SHL64(carry14,21);
+ carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= SHL64(carry16,21);
+
+ carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+ carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= SHL64(carry13,21);
+ carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= SHL64(carry15,21);
+
+ s5 += s17 * 666643;
+ s6 += s17 * 470296;
+ s7 += s17 * 654183;
+ s8 -= s17 * 997805;
+ s9 += s17 * 136657;
+ s10 -= s17 * 683901;
+ s17 = 0;
+
+ s4 += s16 * 666643;
+ s5 += s16 * 470296;
+ s6 += s16 * 654183;
+ s7 -= s16 * 997805;
+ s8 += s16 * 136657;
+ s9 -= s16 * 683901;
+ s16 = 0;
+
+ s3 += s15 * 666643;
+ s4 += s15 * 470296;
+ s5 += s15 * 654183;
+ s6 -= s15 * 997805;
+ s7 += s15 * 136657;
+ s8 -= s15 * 683901;
+ s15 = 0;
+
+ s2 += s14 * 666643;
+ s3 += s14 * 470296;
+ s4 += s14 * 654183;
+ s5 -= s14 * 997805;
+ s6 += s14 * 136657;
+ s7 -= s14 * 683901;
+ s14 = 0;
+
+ s1 += s13 * 666643;
+ s2 += s13 * 470296;
+ s3 += s13 * 654183;
+ s4 -= s13 * 997805;
+ s5 += s13 * 136657;
+ s6 -= s13 * 683901;
+ s13 = 0;
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+
+ carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = s0 >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry1 = s1 >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry2 = s2 >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry3 = s3 >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry4 = s4 >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry5 = s5 >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry6 = s6 >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry7 = s7 >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry8 = s8 >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry9 = s9 >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry10 = s10 >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+ carry11 = s11 >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = s0 >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry1 = s1 >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry2 = s2 >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry3 = s3 >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry4 = s4 >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry5 = s5 >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry6 = s6 >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry7 = s7 >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry8 = s8 >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry9 = s9 >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry10 = s10 >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+
+ s[0] = s0 >> 0;
+ s[1] = s0 >> 8;
+ s[2] = (s0 >> 16) | SHL64(s1,5);
+ s[3] = s1 >> 3;
+ s[4] = s1 >> 11;
+ s[5] = (s1 >> 19) | SHL64(s2,2);
+ s[6] = s2 >> 6;
+ s[7] = (s2 >> 14) | SHL64(s3,7);
+ s[8] = s3 >> 1;
+ s[9] = s3 >> 9;
+ s[10] = (s3 >> 17) | SHL64(s4,4);
+ s[11] = s4 >> 4;
+ s[12] = s4 >> 12;
+ s[13] = (s4 >> 20) | SHL64(s5,1);
+ s[14] = s5 >> 7;
+ s[15] = (s5 >> 15) | SHL64(s6,6);
+ s[16] = s6 >> 2;
+ s[17] = s6 >> 10;
+ s[18] = (s6 >> 18) | SHL64(s7,3);
+ s[19] = s7 >> 5;
+ s[20] = s7 >> 13;
+ s[21] = s8 >> 0;
+ s[22] = s8 >> 8;
+ s[23] = (s8 >> 16) | SHL64(s9,5);
+ s[24] = s9 >> 3;
+ s[25] = s9 >> 11;
+ s[26] = (s9 >> 19) | SHL64(s10,2);
+ s[27] = s10 >> 6;
+ s[28] = (s10 >> 14) | SHL64(s11,7);
+ s[29] = s11 >> 1;
+ s[30] = s11 >> 9;
+ s[31] = s11 >> 17;
+}
diff --git a/src/ext/ed25519/ref10/sc_reduce.c b/src/ext/ed25519/ref10/sc_reduce.c
new file mode 100644
index 0000000000..c5afa53741
--- /dev/null
+++ b/src/ext/ed25519/ref10/sc_reduce.c
@@ -0,0 +1,275 @@
+#include "sc.h"
+#include "crypto_int64.h"
+#include "crypto_uint32.h"
+#include "crypto_uint64.h"
+
+static crypto_uint64 load_3(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ return result;
+}
+
+static crypto_uint64 load_4(const unsigned char *in)
+{
+ crypto_uint64 result;
+ result = (crypto_uint64) in[0];
+ result |= ((crypto_uint64) in[1]) << 8;
+ result |= ((crypto_uint64) in[2]) << 16;
+ result |= ((crypto_uint64) in[3]) << 24;
+ return result;
+}
+
+/*
+Input:
+ s[0]+256*s[1]+...+256^63*s[63] = s
+
+Output:
+ s[0]+256*s[1]+...+256^31*s[31] = s mod l
+ where l = 2^252 + 27742317777372353535851937790883648493.
+ Overwrites s in place.
+*/
+
+void sc_reduce(unsigned char *s)
+{
+ crypto_int64 s0 = 2097151 & load_3(s);
+ crypto_int64 s1 = 2097151 & (load_4(s + 2) >> 5);
+ crypto_int64 s2 = 2097151 & (load_3(s + 5) >> 2);
+ crypto_int64 s3 = 2097151 & (load_4(s + 7) >> 7);
+ crypto_int64 s4 = 2097151 & (load_4(s + 10) >> 4);
+ crypto_int64 s5 = 2097151 & (load_3(s + 13) >> 1);
+ crypto_int64 s6 = 2097151 & (load_4(s + 15) >> 6);
+ crypto_int64 s7 = 2097151 & (load_3(s + 18) >> 3);
+ crypto_int64 s8 = 2097151 & load_3(s + 21);
+ crypto_int64 s9 = 2097151 & (load_4(s + 23) >> 5);
+ crypto_int64 s10 = 2097151 & (load_3(s + 26) >> 2);
+ crypto_int64 s11 = 2097151 & (load_4(s + 28) >> 7);
+ crypto_int64 s12 = 2097151 & (load_4(s + 31) >> 4);
+ crypto_int64 s13 = 2097151 & (load_3(s + 34) >> 1);
+ crypto_int64 s14 = 2097151 & (load_4(s + 36) >> 6);
+ crypto_int64 s15 = 2097151 & (load_3(s + 39) >> 3);
+ crypto_int64 s16 = 2097151 & load_3(s + 42);
+ crypto_int64 s17 = 2097151 & (load_4(s + 44) >> 5);
+ crypto_int64 s18 = 2097151 & (load_3(s + 47) >> 2);
+ crypto_int64 s19 = 2097151 & (load_4(s + 49) >> 7);
+ crypto_int64 s20 = 2097151 & (load_4(s + 52) >> 4);
+ crypto_int64 s21 = 2097151 & (load_3(s + 55) >> 1);
+ crypto_int64 s22 = 2097151 & (load_4(s + 57) >> 6);
+ crypto_int64 s23 = (load_4(s + 60) >> 3);
+ crypto_int64 carry0;
+ crypto_int64 carry1;
+ crypto_int64 carry2;
+ crypto_int64 carry3;
+ crypto_int64 carry4;
+ crypto_int64 carry5;
+ crypto_int64 carry6;
+ crypto_int64 carry7;
+ crypto_int64 carry8;
+ crypto_int64 carry9;
+ crypto_int64 carry10;
+ crypto_int64 carry11;
+ crypto_int64 carry12;
+ crypto_int64 carry13;
+ crypto_int64 carry14;
+ crypto_int64 carry15;
+ crypto_int64 carry16;
+
+ s11 += s23 * 666643;
+ s12 += s23 * 470296;
+ s13 += s23 * 654183;
+ s14 -= s23 * 997805;
+ s15 += s23 * 136657;
+ s16 -= s23 * 683901;
+ s23 = 0;
+
+ s10 += s22 * 666643;
+ s11 += s22 * 470296;
+ s12 += s22 * 654183;
+ s13 -= s22 * 997805;
+ s14 += s22 * 136657;
+ s15 -= s22 * 683901;
+ s22 = 0;
+
+ s9 += s21 * 666643;
+ s10 += s21 * 470296;
+ s11 += s21 * 654183;
+ s12 -= s21 * 997805;
+ s13 += s21 * 136657;
+ s14 -= s21 * 683901;
+ s21 = 0;
+
+ s8 += s20 * 666643;
+ s9 += s20 * 470296;
+ s10 += s20 * 654183;
+ s11 -= s20 * 997805;
+ s12 += s20 * 136657;
+ s13 -= s20 * 683901;
+ s20 = 0;
+
+ s7 += s19 * 666643;
+ s8 += s19 * 470296;
+ s9 += s19 * 654183;
+ s10 -= s19 * 997805;
+ s11 += s19 * 136657;
+ s12 -= s19 * 683901;
+ s19 = 0;
+
+ s6 += s18 * 666643;
+ s7 += s18 * 470296;
+ s8 += s18 * 654183;
+ s9 -= s18 * 997805;
+ s10 += s18 * 136657;
+ s11 -= s18 * 683901;
+ s18 = 0;
+
+ carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+ carry12 = (s12 + (1<<20)) >> 21; s13 += carry12; s12 -= SHL64(carry12,21);
+ carry14 = (s14 + (1<<20)) >> 21; s15 += carry14; s14 -= SHL64(carry14,21);
+ carry16 = (s16 + (1<<20)) >> 21; s17 += carry16; s16 -= SHL64(carry16,21);
+
+ carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+ carry13 = (s13 + (1<<20)) >> 21; s14 += carry13; s13 -= SHL64(carry13,21);
+ carry15 = (s15 + (1<<20)) >> 21; s16 += carry15; s15 -= SHL64(carry15,21);
+
+ s5 += s17 * 666643;
+ s6 += s17 * 470296;
+ s7 += s17 * 654183;
+ s8 -= s17 * 997805;
+ s9 += s17 * 136657;
+ s10 -= s17 * 683901;
+ s17 = 0;
+
+ s4 += s16 * 666643;
+ s5 += s16 * 470296;
+ s6 += s16 * 654183;
+ s7 -= s16 * 997805;
+ s8 += s16 * 136657;
+ s9 -= s16 * 683901;
+ s16 = 0;
+
+ s3 += s15 * 666643;
+ s4 += s15 * 470296;
+ s5 += s15 * 654183;
+ s6 -= s15 * 997805;
+ s7 += s15 * 136657;
+ s8 -= s15 * 683901;
+ s15 = 0;
+
+ s2 += s14 * 666643;
+ s3 += s14 * 470296;
+ s4 += s14 * 654183;
+ s5 -= s14 * 997805;
+ s6 += s14 * 136657;
+ s7 -= s14 * 683901;
+ s14 = 0;
+
+ s1 += s13 * 666643;
+ s2 += s13 * 470296;
+ s3 += s13 * 654183;
+ s4 -= s13 * 997805;
+ s5 += s13 * 136657;
+ s6 -= s13 * 683901;
+ s13 = 0;
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = (s0 + (1<<20)) >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry2 = (s2 + (1<<20)) >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry4 = (s4 + (1<<20)) >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry6 = (s6 + (1<<20)) >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry8 = (s8 + (1<<20)) >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry10 = (s10 + (1<<20)) >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+
+ carry1 = (s1 + (1<<20)) >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry3 = (s3 + (1<<20)) >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry5 = (s5 + (1<<20)) >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry7 = (s7 + (1<<20)) >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry9 = (s9 + (1<<20)) >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry11 = (s11 + (1<<20)) >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = s0 >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry1 = s1 >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry2 = s2 >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry3 = s3 >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry4 = s4 >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry5 = s5 >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry6 = s6 >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry7 = s7 >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry8 = s8 >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry9 = s9 >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry10 = s10 >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+ carry11 = s11 >> 21; s12 += carry11; s11 -= SHL64(carry11,21);
+
+ s0 += s12 * 666643;
+ s1 += s12 * 470296;
+ s2 += s12 * 654183;
+ s3 -= s12 * 997805;
+ s4 += s12 * 136657;
+ s5 -= s12 * 683901;
+ s12 = 0;
+
+ carry0 = s0 >> 21; s1 += carry0; s0 -= SHL64(carry0,21);
+ carry1 = s1 >> 21; s2 += carry1; s1 -= SHL64(carry1,21);
+ carry2 = s2 >> 21; s3 += carry2; s2 -= SHL64(carry2,21);
+ carry3 = s3 >> 21; s4 += carry3; s3 -= SHL64(carry3,21);
+ carry4 = s4 >> 21; s5 += carry4; s4 -= SHL64(carry4,21);
+ carry5 = s5 >> 21; s6 += carry5; s5 -= SHL64(carry5,21);
+ carry6 = s6 >> 21; s7 += carry6; s6 -= SHL64(carry6,21);
+ carry7 = s7 >> 21; s8 += carry7; s7 -= SHL64(carry7,21);
+ carry8 = s8 >> 21; s9 += carry8; s8 -= SHL64(carry8,21);
+ carry9 = s9 >> 21; s10 += carry9; s9 -= SHL64(carry9,21);
+ carry10 = s10 >> 21; s11 += carry10; s10 -= SHL64(carry10,21);
+
+ s[0] = s0 >> 0;
+ s[1] = s0 >> 8;
+ s[2] = (s0 >> 16) | SHL64(s1,5);
+ s[3] = s1 >> 3;
+ s[4] = s1 >> 11;
+ s[5] = (s1 >> 19) | SHL64(s2,2);
+ s[6] = s2 >> 6;
+ s[7] = (s2 >> 14) | SHL64(s3,7);
+ s[8] = s3 >> 1;
+ s[9] = s3 >> 9;
+ s[10] = (s3 >> 17) | SHL64(s4,4);
+ s[11] = s4 >> 4;
+ s[12] = s4 >> 12;
+ s[13] = (s4 >> 20) | SHL64(s5,1);
+ s[14] = s5 >> 7;
+ s[15] = (s5 >> 15) | SHL64(s6,6);
+ s[16] = s6 >> 2;
+ s[17] = s6 >> 10;
+ s[18] = (s6 >> 18) | SHL64(s7,3);
+ s[19] = s7 >> 5;
+ s[20] = s7 >> 13;
+ s[21] = s8 >> 0;
+ s[22] = s8 >> 8;
+ s[23] = (s8 >> 16) | SHL64(s9,5);
+ s[24] = s9 >> 3;
+ s[25] = s9 >> 11;
+ s[26] = (s9 >> 19) | SHL64(s10,2);
+ s[27] = s10 >> 6;
+ s[28] = (s10 >> 14) | SHL64(s11,7);
+ s[29] = s11 >> 1;
+ s[30] = s11 >> 9;
+ s[31] = s11 >> 17;
+}
diff --git a/src/ext/ed25519/ref10/sign.c b/src/ext/ed25519/ref10/sign.c
new file mode 100644
index 0000000000..1190a0fc99
--- /dev/null
+++ b/src/ext/ed25519/ref10/sign.c
@@ -0,0 +1,29 @@
+/* (Modified by Tor to generate detached signatures.) */
+#include <string.h>
+#include "crypto_sign.h"
+#include "crypto_hash_sha512.h"
+#include "ge.h"
+#include "sc.h"
+
+int crypto_sign(
+ unsigned char *sig,
+ const unsigned char *m, size_t mlen,
+ const unsigned char *sk,const unsigned char *pk
+)
+{
+ unsigned char nonce[64];
+ unsigned char hram[64];
+ ge_p3 R;
+
+ crypto_hash_sha512_2(nonce, sk+32, 32, m, mlen);
+
+ sc_reduce(nonce);
+ ge_scalarmult_base(&R,nonce);
+ ge_p3_tobytes(sig,&R);
+
+ crypto_hash_sha512_3(hram, sig, 32, pk, 32, m, mlen);
+ sc_reduce(hram);
+ sc_muladd(sig + 32,hram,sk,nonce);
+
+ return 0;
+}
diff --git a/src/ext/ed25519/ref10/sqrtm1.h b/src/ext/ed25519/ref10/sqrtm1.h
new file mode 100644
index 0000000000..d8caa23b6a
--- /dev/null
+++ b/src/ext/ed25519/ref10/sqrtm1.h
@@ -0,0 +1 @@
+-32595792,-7943725,9377950,3500415,12389472,-272473,-25146209,-2005654,326686,11406482
diff --git a/src/ext/ed25519/ref10/sqrtm1.py b/src/ext/ed25519/ref10/sqrtm1.py
new file mode 100644
index 0000000000..9a47fbc12a
--- /dev/null
+++ b/src/ext/ed25519/ref10/sqrtm1.py
@@ -0,0 +1,28 @@
+q = 2**255 - 19
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+def radix255(x):
+ x = x % q
+ if x + x > q: x -= q
+ x = [x,0,0,0,0,0,0,0,0,0]
+ bits = [26,25,26,25,26,25,26,25,26,25]
+ for i in range(9):
+ carry = (x[i] + 2**(bits[i]-1)) / 2**bits[i]
+ x[i] -= carry * 2**bits[i]
+ x[i + 1] += carry
+ result = ""
+ for i in range(9):
+ result = result+str(x[i])+","
+ result = result+str(x[9])
+ return result
+
+I = expmod(2,(q-1)/4,q)
+print radix255(I)
diff --git a/src/ext/ht.h b/src/ext/ht.h
index 838710784f..09f5dcccd5 100644
--- a/src/ext/ht.h
+++ b/src/ext/ht.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2002, Christopher Clark.
* Copyright (c) 2005-2006, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See license at end. */
/* Based on ideas by Christopher Clark and interfaces from Niels Provos. */
@@ -38,8 +38,9 @@
}
#endif
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
#define HT_EMPTY(head) \
- ((head)->hth_n_entries == 0)
+ (((head)->hth_n_entries == 0) || 0)
/* How many elements in 'head'? */
#define HT_SIZE(head) \
@@ -302,8 +303,8 @@ ht_string_hash(const char *s)
} \
}
-#define HT_GENERATE(name, type, field, hashfn, eqfn, load, mallocfn, \
- reallocfn, freefn) \
+#define HT_GENERATE2(name, type, field, hashfn, eqfn, load, reallocarrayfn, \
+ freefn) \
/* Primes that aren't too far from powers of two. We stop at */ \
/* P=402653189 because P*sizeof(void*) is less than SSIZE_MAX */ \
/* even on a 32-bit platform. */ \
@@ -336,7 +337,7 @@ ht_string_hash(const char *s)
new_load_limit = (unsigned)(load*new_len); \
} while (new_load_limit <= size && \
prime_idx < (int)name##_N_PRIMES); \
- if ((new_table = mallocfn(new_len*sizeof(struct type*)))) { \
+ if ((new_table = reallocarrayfn(NULL, new_len, sizeof(struct type*)))) { \
unsigned b; \
memset(new_table, 0, new_len*sizeof(struct type*)); \
for (b = 0; b < head->hth_table_length; ++b) { \
@@ -356,7 +357,7 @@ ht_string_hash(const char *s)
head->hth_table = new_table; \
} else { \
unsigned b, b2; \
- new_table = reallocfn(head->hth_table, new_len*sizeof(struct type*)); \
+ new_table = reallocarrayfn(head->hth_table, new_len, sizeof(struct type*)); \
if (!new_table) return -1; \
memset(new_table + head->hth_table_length, 0, \
(new_len - head->hth_table_length)*sizeof(struct type*)); \
@@ -427,6 +428,21 @@ ht_string_hash(const char *s)
return 0; \
}
+#define HT_GENERATE(name, type, field, hashfn, eqfn, load, mallocfn, \
+ reallocfn, freefn) \
+ static void * \
+ name##_reallocarray(void *arg, size_t a, size_t b) \
+ { \
+ if ((b) && (a) > SIZE_MAX / (b)) \
+ return NULL; \
+ if (arg) \
+ return reallocfn((arg),(a)*(b)); \
+ else \
+ return mallocfn((a)*(b)); \
+ } \
+ HT_GENERATE2(name, type, field, hashfn, eqfn, load, \
+ name##_reallocarray, freefn)
+
/** Implements an over-optimized "find and insert if absent" block;
* not meant for direct usage by typical code, or usage outside the critical
* path.*/
diff --git a/src/ext/include.am b/src/ext/include.am
index 26e194e88e..576fd4efb8 100644
--- a/src/ext/include.am
+++ b/src/ext/include.am
@@ -15,4 +15,80 @@ EXTHEADERS = \
noinst_HEADERS+= $(EXTHEADERS)
+src_ext_ed25519_ref10_libed25519_ref10_a_CFLAGS=
+
+src_ext_ed25519_ref10_libed25519_ref10_a_SOURCES= \
+ src/ext/ed25519/ref10/fe_0.c \
+ src/ext/ed25519/ref10/fe_1.c \
+ src/ext/ed25519/ref10/fe_add.c \
+ src/ext/ed25519/ref10/fe_cmov.c \
+ src/ext/ed25519/ref10/fe_copy.c \
+ src/ext/ed25519/ref10/fe_frombytes.c \
+ src/ext/ed25519/ref10/fe_invert.c \
+ src/ext/ed25519/ref10/fe_isnegative.c \
+ src/ext/ed25519/ref10/fe_isnonzero.c \
+ src/ext/ed25519/ref10/fe_mul.c \
+ src/ext/ed25519/ref10/fe_neg.c \
+ src/ext/ed25519/ref10/fe_pow22523.c \
+ src/ext/ed25519/ref10/fe_sq.c \
+ src/ext/ed25519/ref10/fe_sq2.c \
+ src/ext/ed25519/ref10/fe_sub.c \
+ src/ext/ed25519/ref10/fe_tobytes.c \
+ src/ext/ed25519/ref10/ge_add.c \
+ src/ext/ed25519/ref10/ge_double_scalarmult.c \
+ src/ext/ed25519/ref10/ge_frombytes.c \
+ src/ext/ed25519/ref10/ge_madd.c \
+ src/ext/ed25519/ref10/ge_msub.c \
+ src/ext/ed25519/ref10/ge_p1p1_to_p2.c \
+ src/ext/ed25519/ref10/ge_p1p1_to_p3.c \
+ src/ext/ed25519/ref10/ge_p2_0.c \
+ src/ext/ed25519/ref10/ge_p2_dbl.c \
+ src/ext/ed25519/ref10/ge_p3_0.c \
+ src/ext/ed25519/ref10/ge_p3_dbl.c \
+ src/ext/ed25519/ref10/ge_p3_to_cached.c \
+ src/ext/ed25519/ref10/ge_p3_to_p2.c \
+ src/ext/ed25519/ref10/ge_p3_tobytes.c \
+ src/ext/ed25519/ref10/ge_precomp_0.c \
+ src/ext/ed25519/ref10/ge_scalarmult_base.c \
+ src/ext/ed25519/ref10/ge_sub.c \
+ src/ext/ed25519/ref10/ge_tobytes.c \
+ src/ext/ed25519/ref10/keypair.c \
+ src/ext/ed25519/ref10/open.c \
+ src/ext/ed25519/ref10/sc_muladd.c \
+ src/ext/ed25519/ref10/sc_reduce.c \
+ src/ext/ed25519/ref10/sign.c \
+ src/ext/ed25519/ref10/keyconv.c \
+ src/ext/ed25519/ref10/blinding.c
+
+ED25519_REF10_HDRS = \
+ src/ext/ed25519/ref10/api.h \
+ src/ext/ed25519/ref10/base.h \
+ src/ext/ed25519/ref10/base2.h \
+ src/ext/ed25519/ref10/crypto_hash_sha512.h \
+ src/ext/ed25519/ref10/crypto_int32.h \
+ src/ext/ed25519/ref10/crypto_int64.h \
+ src/ext/ed25519/ref10/crypto_sign.h \
+ src/ext/ed25519/ref10/crypto_uint32.h \
+ src/ext/ed25519/ref10/crypto_uint64.h \
+ src/ext/ed25519/ref10/crypto_verify_32.h \
+ src/ext/ed25519/ref10/d.h \
+ src/ext/ed25519/ref10/d2.h \
+ src/ext/ed25519/ref10/ed25519_ref10.h \
+ src/ext/ed25519/ref10/fe.h \
+ src/ext/ed25519/ref10/ge.h \
+ src/ext/ed25519/ref10/ge_add.h \
+ src/ext/ed25519/ref10/ge_madd.h \
+ src/ext/ed25519/ref10/ge_msub.h \
+ src/ext/ed25519/ref10/ge_p2_dbl.h \
+ src/ext/ed25519/ref10/ge_sub.h \
+ src/ext/ed25519/ref10/pow22523.h \
+ src/ext/ed25519/ref10/pow225521.h \
+ src/ext/ed25519/ref10/randombytes.h \
+ src/ext/ed25519/ref10/sc.h \
+ src/ext/ed25519/ref10/sqrtm1.h
+
+noinst_HEADERS += $(ED25519_REF10_HDRS)
+
+LIBED25519_REF10=src/ext/ed25519/ref10/libed25519_ref10.a
+noinst_LIBRARIES += $(LIBED25519_REF10)
diff --git a/src/ext/tor_queue.h b/src/ext/tor_queue.h
index f05e48c18e..a6530c2b9b 100644
--- a/src/ext/tor_queue.h
+++ b/src/ext/tor_queue.h
@@ -109,7 +109,8 @@ struct { \
*/
#define TOR_SLIST_FIRST(head) ((head)->slh_first)
#define TOR_SLIST_END(head) NULL
-#define TOR_SLIST_EMPTY(head) (SLIST_FIRST(head) == TOR_SLIST_END(head))
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define TOR_SLIST_EMPTY(head) ((SLIST_FIRST(head) == TOR_SLIST_END(head)) || 0)
#define TOR_SLIST_NEXT(elm, field) ((elm)->field.sle_next)
#define TOR_SLIST_FOREACH(var, head, field) \
@@ -181,9 +182,11 @@ struct { \
/*
* List access methods
*/
-#define TOR_LIST_FIRST(head) ((head)->lh_first)
-#define TOR_LIST_END(head) NULL
-#define TOR_LIST_EMPTY(head) (TOR_LIST_FIRST(head) == TOR_LIST_END(head))
+#define TOR_LIST_FIRST(head) ((head)->lh_first)
+#define TOR_LIST_END(head) NULL
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define TOR_LIST_EMPTY(head) \
+ ((TOR_LIST_FIRST(head) == TOR_LIST_END(head)) || 0)
#define TOR_LIST_NEXT(elm, field) ((elm)->field.le_next)
#define TOR_LIST_FOREACH(var, head, field) \
@@ -265,8 +268,10 @@ struct { \
* Simple queue access methods.
*/
#define TOR_SIMPLEQ_FIRST(head) ((head)->sqh_first)
-#define TOR_SIMPLEQ_END(head) NULL
-#define TOR_SIMPLEQ_EMPTY(head) (TOR_SIMPLEQ_FIRST(head) == TOR_SIMPLEQ_END(head))
+#define TOR_SIMPLEQ_END(head) NULL
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define TOR_SIMPLEQ_EMPTY(head) \
+ ((TOR_SIMPLEQ_FIRST(head) == TOR_SIMPLEQ_END(head)) || 0)
#define TOR_SIMPLEQ_NEXT(elm, field) ((elm)->field.sqe_next)
#define TOR_SIMPLEQ_FOREACH(var, head, field) \
@@ -345,8 +350,9 @@ struct { \
/* XXX */
#define TOR_TAILQ_PREV(elm, headname, field) \
(*(((struct headname *)((elm)->field.tqe_prev))->tqh_last))
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
#define TOR_TAILQ_EMPTY(head) \
- (TOR_TAILQ_FIRST(head) == TOR_TAILQ_END(head))
+ ((TOR_TAILQ_FIRST(head) == TOR_TAILQ_END(head)) || 0)
#define TOR_TAILQ_FOREACH(var, head, field) \
for((var) = TOR_TAILQ_FIRST(head); \
@@ -462,8 +468,9 @@ struct { \
#define TOR_CIRCLEQ_END(head) ((void *)(head))
#define TOR_CIRCLEQ_NEXT(elm, field) ((elm)->field.cqe_next)
#define TOR_CIRCLEQ_PREV(elm, field) ((elm)->field.cqe_prev)
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
#define TOR_CIRCLEQ_EMPTY(head) \
- (TOR_CIRCLEQ_FIRST(head) == TOR_CIRCLEQ_END(head))
+ ((TOR_CIRCLEQ_FIRST(head) == TOR_CIRCLEQ_END(head)) || 0)
#define TOR_CIRCLEQ_FOREACH(var, head, field) \
for((var) = TOR_CIRCLEQ_FIRST(head); \
diff --git a/src/ext/trunnel/trunnel-impl.h b/src/ext/trunnel/trunnel-impl.h
new file mode 100644
index 0000000000..c88ee3988e
--- /dev/null
+++ b/src/ext/trunnel/trunnel-impl.h
@@ -0,0 +1,310 @@
+/* trunnel-impl.h -- copied from Trunnel v1.2
+ * https://gitweb.torproject.org/trunnel.git
+ * You probably shouldn't edit this file.
+ */
+/* trunnel-impl.h -- Implementation helpers for trunnel, included by
+ * generated trunnel files
+ *
+ * Copyright 2014, The Tor Project, Inc.
+ * See license at the end of this file for copying information.
+ */
+
+#ifndef TRUNNEL_IMPL_H_INCLUDED_
+#define TRUNNEL_IMPL_H_INCLUDED_
+#include "trunnel.h"
+#include <assert.h>
+#include <string.h>
+#ifdef TRUNNEL_LOCAL_H
+#include "trunnel-local.h"
+#endif
+
+#ifdef _MSC_VER
+#define uint8_t unsigned char
+#define uint16_t unsigned short
+#define uint32_t unsigned int
+#define uint64_t unsigned __int64
+#define inline __inline
+#else
+#include <stdint.h>
+#endif
+
+#ifdef _WIN32
+uint32_t trunnel_htonl(uint32_t a);
+uint32_t trunnel_ntohl(uint32_t a);
+uint16_t trunnel_htons(uint16_t a);
+uint16_t trunnel_ntohs(uint16_t a);
+#else
+#include <arpa/inet.h>
+#define trunnel_htonl(x) htonl(x)
+#define trunnel_htons(x) htons(x)
+#define trunnel_ntohl(x) ntohl(x)
+#define trunnel_ntohs(x) ntohs(x)
+#endif
+uint64_t trunnel_htonll(uint64_t a);
+uint64_t trunnel_ntohll(uint64_t a);
+
+#ifndef trunnel_assert
+#define trunnel_assert(x) assert(x)
+#endif
+
+static inline void
+trunnel_set_uint64(void *p, uint64_t v) {
+ memcpy(p, &v, 8);
+}
+static inline void
+trunnel_set_uint32(void *p, uint32_t v) {
+ memcpy(p, &v, 4);
+}
+static inline void
+trunnel_set_uint16(void *p, uint16_t v) {
+ memcpy(p, &v, 2);
+}
+static inline void
+trunnel_set_uint8(void *p, uint8_t v) {
+ memcpy(p, &v, 1);
+}
+
+static inline uint64_t
+trunnel_get_uint64(const void *p) {
+ uint64_t x;
+ memcpy(&x, p, 8);
+ return x;
+}
+static inline uint32_t
+trunnel_get_uint32(const void *p) {
+ uint32_t x;
+ memcpy(&x, p, 4);
+ return x;
+}
+static inline uint16_t
+trunnel_get_uint16(const void *p) {
+ uint16_t x;
+ memcpy(&x, p, 2);
+ return x;
+}
+static inline uint8_t
+trunnel_get_uint8(const void *p) {
+ return *(const uint8_t*)p;
+}
+
+
+#ifdef TRUNNEL_DEBUG_FAILING_ALLOC
+extern int trunnel_provoke_alloc_failure;
+
+static inline void *
+trunnel_malloc(size_t n)
+{
+ if (trunnel_provoke_alloc_failure) {
+ if (--trunnel_provoke_alloc_failure == 0)
+ return NULL;
+ }
+ return malloc(n);
+}
+static inline void *
+trunnel_calloc(size_t a, size_t b)
+{
+ if (trunnel_provoke_alloc_failure) {
+ if (--trunnel_provoke_alloc_failure == 0)
+ return NULL;
+ }
+ return calloc(a,b);
+}
+static inline char *
+trunnel_strdup(const char *s)
+{
+ if (trunnel_provoke_alloc_failure) {
+ if (--trunnel_provoke_alloc_failure == 0)
+ return NULL;
+ }
+ return strdup(s);
+}
+#else
+#ifndef trunnel_malloc
+#define trunnel_malloc(x) (malloc((x)))
+#endif
+#ifndef trunnel_calloc
+#define trunnel_calloc(a,b) (calloc((a),(b)))
+#endif
+#ifndef trunnel_strdup
+#define trunnel_strdup(s) (strdup((s)))
+#endif
+#endif
+
+#ifndef trunnel_realloc
+#define trunnel_realloc(a,b) realloc((a),(b))
+#endif
+
+#ifndef trunnel_free_
+#define trunnel_free_(x) (free(x))
+#endif
+#define trunnel_free(x) ((x) ? (trunnel_free_(x),0) : (0))
+
+#ifndef trunnel_abort
+#define trunnel_abort() abort()
+#endif
+
+#ifndef trunnel_memwipe
+#define trunnel_memwipe(mem, len) ((void)0)
+#define trunnel_wipestr(s) ((void)0)
+#else
+#define trunnel_wipestr(s) do { \
+ if (s) \
+ trunnel_memwipe(s, strlen(s)); \
+ } while (0)
+#endif
+
+/* ====== dynamic arrays ======== */
+
+#ifdef NDEBUG
+#define TRUNNEL_DYNARRAY_GET(da, n) \
+ ((da)->elts_[(n)])
+#else
+/** Return the 'n'th element of 'da'. */
+#define TRUNNEL_DYNARRAY_GET(da, n) \
+ (((n) >= (da)->n_ ? (trunnel_abort(),0) : 0), (da)->elts_[(n)])
+#endif
+
+/** Change the 'n'th element of 'da' to 'v'. */
+#define TRUNNEL_DYNARRAY_SET(da, n, v) do { \
+ trunnel_assert((n) < (da)->n_); \
+ (da)->elts_[(n)] = (v); \
+ } while (0)
+
+/** Expand the dynamic array 'da' of 'elttype' so that it can hold at least
+ * 'howmanymore' elements than its current capacity. Always tries to increase
+ * the length of the array. On failure, run the code in 'on_fail' and goto
+ * trunnel_alloc_failed. */
+#define TRUNNEL_DYNARRAY_EXPAND(elttype, da, howmanymore, on_fail) do { \
+ elttype *newarray; \
+ newarray = trunnel_dynarray_expand(&(da)->allocated_, \
+ (da)->elts_, (howmanymore), \
+ sizeof(elttype)); \
+ if (newarray == NULL) { \
+ on_fail; \
+ goto trunnel_alloc_failed; \
+ } \
+ (da)->elts_ = newarray; \
+ } while (0)
+
+/** Add 'v' to the end of the dynamic array 'da' of 'elttype', expanding it if
+ * necessary. code in 'on_fail' and goto trunnel_alloc_failed. */
+#define TRUNNEL_DYNARRAY_ADD(elttype, da, v, on_fail) do { \
+ if ((da)->n_ == (da)->allocated_) { \
+ TRUNNEL_DYNARRAY_EXPAND(elttype, da, 1, on_fail); \
+ } \
+ (da)->elts_[(da)->n_++] = (v); \
+ } while (0)
+
+/** Return the number of elements in 'da'. */
+#define TRUNNEL_DYNARRAY_LEN(da) ((da)->n_)
+
+/** Remove all storage held by 'da' and set it to be empty. Does not free
+ * storage held by the elements themselves. */
+#define TRUNNEL_DYNARRAY_CLEAR(da) do { \
+ trunnel_free((da)->elts_); \
+ (da)->elts_ = NULL; \
+ (da)->n_ = (da)->allocated_ = 0; \
+ } while (0)
+
+/** Remove all storage held by 'da' and set it to be empty. Does not free
+ * storage held by the elements themselves. */
+#define TRUNNEL_DYNARRAY_WIPE(da) do { \
+ trunnel_memwipe((da)->elts_, (da)->allocated_ * sizeof((da)->elts_[0])); \
+ } while (0)
+
+/** Helper: wraps or implements an OpenBSD-style reallocarray. Behaves
+ * as realloc(a, x*y), but verifies that no overflow will occur in the
+ * multiplication. Returns NULL on failure. */
+#ifndef trunnel_reallocarray
+void *trunnel_reallocarray(void *a, size_t x, size_t y);
+#endif
+
+/** Helper to expand a dynamic array. Behaves as TRUNNEL_DYNARRAY_EXPAND(),
+ * taking the array of elements in 'ptr', a pointer to thethe current number
+ * of allocated elements in allocated_p, the minimum numbeer of elements to
+ * add in 'howmanymore', and the size of a single element in 'eltsize'.
+ *
+ * On success, adjust *allocated_p, and return the new value for the array of
+ * elements. On failure, adjust nothing and return NULL.
+ */
+void *trunnel_dynarray_expand(size_t *allocated_p, void *ptr,
+ size_t howmanymore, size_t eltsize);
+
+/** Type for a function to free members of a dynarray of pointers. */
+typedef void (*trunnel_free_fn_t)(void *);
+
+/**
+ * Helper to change the length of a dynamic array. Takes pointers to the
+ * current allocated and n fields of the array in 'allocated_p' and 'len_p',
+ * and the current array of elements in 'ptr'; takes the length of a single
+ * element in 'eltsize'. Changes the length to 'newlen'. If 'newlen' is
+ * greater than the current length, pads the new elements with 0. If newlen
+ * is less than the current length, and free_fn is non-NULL, treat the
+ * array as an array of void *, and invoke free_fn() on each removed element.
+ *
+ * On success, adjust *allocated_p and *len_p, and return the new value for
+ * the array of elements. On failure, adjust nothing, set *errcode_ptr to 1,
+ * and return NULL.
+ */
+void *trunnel_dynarray_setlen(size_t *allocated_p, size_t *len_p,
+ void *ptr, size_t newlen,
+ size_t eltsize, trunnel_free_fn_t free_fn,
+ uint8_t *errcode_ptr);
+
+/**
+ * Helper: return a pointer to the value of 'str' as a NUL-terminated string.
+ * Might have to reallocate the storage for 'str' in order to fit in the final
+ * NUL character. On allocation failure, return NULL.
+ */
+const char *trunnel_string_getstr(trunnel_string_t *str);
+
+/**
+ * Helper: change the contents of 'str' to hold the 'len'-byte string in
+ * 'inp'. Adjusts the storage to have a terminating NUL that doesn't count
+ * towards the length of the string. On success, return 0. On failure, set
+ * *errcode_ptr to 1 and return -1.
+ */
+int trunnel_string_setstr0(trunnel_string_t *str, const char *inp, size_t len,
+ uint8_t *errcode_ptr);
+
+/**
+ * As trunnel_dynarray_setlen, but adjusts a string rather than a dynamic
+ * array, and ensures that the new string is NUL-terminated.
+ */
+int trunnel_string_setlen(trunnel_string_t *str, size_t newlen,
+ uint8_t *errcode_ptr);
+
+#endif
+
+
+/*
+Copyright 2014 The Tor Project, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+ * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
diff --git a/src/ext/trunnel/trunnel.c b/src/ext/trunnel/trunnel.c
new file mode 100644
index 0000000000..a18d67584e
--- /dev/null
+++ b/src/ext/trunnel/trunnel.c
@@ -0,0 +1,247 @@
+/* trunnel.c -- copied from Trunnel v1.4-pre
+ * https://gitweb.torproject.org/trunnel.git
+ * You probably shouldn't edit this file.
+ */
+/* trunnel.c -- Helper functions to implement trunnel.
+ *
+ * Copyright 2014, The Tor Project, Inc.
+ * See license at the end of this file for copying information.
+ *
+ * See trunnel-impl.h for documentation of these functions.
+ */
+
+#include <stdlib.h>
+#include <string.h>
+#include "trunnel-impl.h"
+
+#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
+ __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
+# define IS_LITTLE_ENDIAN 1
+#elif defined(BYTE_ORDER) && defined(ORDER_LITTLE_ENDIAN) && \
+ BYTE_ORDER == __ORDER_LITTLE_ENDIAN
+# define IS_LITTLE_ENDIAN 1
+#elif defined(_WIN32)
+# define IS_LITTLE_ENDIAN 1
+#elif defined(__APPLE__)
+# include <libkern/OSByteOrder.h>
+# define BSWAP64(x) OSSwapLittleToHostInt64(x)
+#elif defined(sun) || defined(__sun)
+# include <sys/byteorder.h>
+# ifndef _BIG_ENDIAN
+# define IS_LITTLE_ENDIAN
+# endif
+#else
+# if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
+# include <sys/endian.h>
+# else
+# include <endian.h>
+# endif
+# if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && \
+ __BYTE_ORDER == __LITTLE_ENDIAN
+# define IS_LITTLE_ENDIAN
+# endif
+#endif
+
+#ifdef _WIN32
+uint16_t
+trunnel_htons(uint16_t s)
+{
+ return (s << 8) | (s >> 8);
+}
+uint16_t
+trunnel_ntohs(uint16_t s)
+{
+ return (s << 8) | (s >> 8);
+}
+uint32_t
+trunnel_htonl(uint32_t s)
+{
+ return (s << 24) |
+ ((s << 8)&0xff0000) |
+ ((s >> 8)&0xff00) |
+ (s >> 24);
+}
+uint32_t
+trunnel_ntohl(uint32_t s)
+{
+ return (s << 24) |
+ ((s << 8)&0xff0000) |
+ ((s >> 8)&0xff00) |
+ (s >> 24);
+}
+#endif
+
+uint64_t
+trunnel_htonll(uint64_t a)
+{
+#ifdef IS_LITTLE_ENDIAN
+ return trunnel_htonl((uint32_t)(a>>32))
+ | (((uint64_t)trunnel_htonl((uint32_t)a))<<32);
+#else
+ return a;
+#endif
+}
+
+uint64_t
+trunnel_ntohll(uint64_t a)
+{
+ return trunnel_htonll(a);
+}
+
+#ifdef TRUNNEL_DEBUG_FAILING_ALLOC
+/** Used for debugging and running tricky test cases: Makes the nth
+ * memoryation allocation call from now fail.
+ */
+int trunnel_provoke_alloc_failure = 0;
+#endif
+
+void *
+trunnel_dynarray_expand(size_t *allocated_p, void *ptr,
+ size_t howmanymore, size_t eltsize)
+{
+ size_t newsize = howmanymore + *allocated_p;
+ void *newarray = NULL;
+ if (newsize < 8)
+ newsize = 8;
+ if (newsize < *allocated_p * 2)
+ newsize = *allocated_p * 2;
+ if (newsize <= *allocated_p || newsize < howmanymore)
+ return NULL;
+ newarray = trunnel_reallocarray(ptr, newsize, eltsize);
+ if (newarray == NULL)
+ return NULL;
+
+ *allocated_p = newsize;
+ return newarray;
+}
+
+#ifndef trunnel_reallocarray
+void *
+trunnel_reallocarray(void *a, size_t x, size_t y)
+{
+#ifdef TRUNNEL_DEBUG_FAILING_ALLOC
+ if (trunnel_provoke_alloc_failure) {
+ if (--trunnel_provoke_alloc_failure == 0)
+ return NULL;
+ }
+#endif
+ if (x > SIZE_MAX / y)
+ return NULL;
+ return trunnel_realloc(a, x * y);
+}
+#endif
+
+const char *
+trunnel_string_getstr(trunnel_string_t *str)
+{
+ trunnel_assert(str->allocated_ >= str->n_);
+ if (str->allocated_ == str->n_) {
+ TRUNNEL_DYNARRAY_EXPAND(char, str, 1, {});
+ }
+ str->elts_[str->n_] = 0;
+ return str->elts_;
+trunnel_alloc_failed:
+ return NULL;
+}
+
+int
+trunnel_string_setstr0(trunnel_string_t *str, const char *val, size_t len,
+ uint8_t *errcode_ptr)
+{
+ if (len == SIZE_MAX)
+ goto trunnel_alloc_failed;
+ if (str->allocated_ <= len) {
+ TRUNNEL_DYNARRAY_EXPAND(char, str, len + 1 - str->allocated_, {});
+ }
+ memcpy(str->elts_, val, len);
+ str->n_ = len;
+ str->elts_[len] = 0;
+ return 0;
+trunnel_alloc_failed:
+ *errcode_ptr = 1;
+ return -1;
+}
+
+int
+trunnel_string_setlen(trunnel_string_t *str, size_t newlen,
+ uint8_t *errcode_ptr)
+{
+ if (newlen == SIZE_MAX)
+ goto trunnel_alloc_failed;
+ if (str->allocated_ < newlen + 1) {
+ TRUNNEL_DYNARRAY_EXPAND(char, str, newlen + 1 - str->allocated_, {});
+ }
+ if (str->n_ < newlen) {
+ memset(& (str->elts_[str->n_]), 0, (newlen - str->n_));
+ }
+ str->n_ = newlen;
+ str->elts_[newlen] = 0;
+ return 0;
+
+ trunnel_alloc_failed:
+ *errcode_ptr = 1;
+ return -1;
+}
+
+void *
+trunnel_dynarray_setlen(size_t *allocated_p, size_t *len_p,
+ void *ptr, size_t newlen,
+ size_t eltsize, trunnel_free_fn_t free_fn,
+ uint8_t *errcode_ptr)
+{
+ if (*allocated_p < newlen) {
+ void *newptr = trunnel_dynarray_expand(allocated_p, ptr,
+ newlen - *allocated_p, eltsize);
+ if (newptr == NULL)
+ goto trunnel_alloc_failed;
+ ptr = newptr;
+ }
+ if (free_fn && *len_p > newlen) {
+ size_t i;
+ void **elts = (void **) ptr;
+ for (i = newlen; i < *len_p; ++i) {
+ free_fn(elts[i]);
+ elts[i] = NULL;
+ }
+ }
+ if (*len_p < newlen) {
+ memset( ((char*)ptr) + (eltsize * *len_p), 0, (newlen - *len_p) * eltsize);
+ }
+ *len_p = newlen;
+ return ptr;
+ trunnel_alloc_failed:
+ *errcode_ptr = 1;
+ return NULL;
+}
+
+/*
+Copyright 2014 The Tor Project, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+ * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
diff --git a/src/ext/trunnel/trunnel.h b/src/ext/trunnel/trunnel.h
new file mode 100644
index 0000000000..f51cade03f
--- /dev/null
+++ b/src/ext/trunnel/trunnel.h
@@ -0,0 +1,64 @@
+/* trunnel.h -- copied from Trunnel v1.2
+ * https://gitweb.torproject.org/trunnel.git
+ * You probably shouldn't edit this file.
+ */
+/* trunnel.h -- Public declarations for trunnel, to be included
+ * in trunnel header files.
+
+ * Copyright 2014, The Tor Project, Inc.
+ * See license at the end of this file for copying information.
+ */
+
+#ifndef TRUNNEL_H_INCLUDED_
+#define TRUNNEL_H_INCLUDED_
+
+#include <sys/types.h>
+
+/** Macro to declare a variable-length dynamically allocated array. Trunnel
+ * uses these to store all variable-length arrays. */
+#define TRUNNEL_DYNARRAY_HEAD(name, elttype) \
+ struct name { \
+ size_t n_; \
+ size_t allocated_; \
+ elttype *elts_; \
+ }
+
+/** Initializer for a dynamic array of a given element type. */
+#define TRUNNEL_DYNARRAY_INIT(elttype) { 0, 0, (elttype*)NULL }
+
+/** Typedef used for storing variable-length arrays of char. */
+typedef TRUNNEL_DYNARRAY_HEAD(trunnel_string_st, char) trunnel_string_t;
+
+#endif
+
+/*
+Copyright 2014 The Tor Project, Inc.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+distribution.
+
+ * Neither the names of the copyright owners nor the names of its
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
diff --git a/src/include.am b/src/include.am
index d0693e25b0..c468af3649 100644
--- a/src/include.am
+++ b/src/include.am
@@ -1,7 +1,9 @@
include src/ext/include.am
+include src/trunnel/include.am
include src/common/include.am
include src/or/include.am
include src/test/include.am
include src/tools/include.am
include src/win32/include.am
include src/config/include.am
+
diff --git a/src/or/Makefile.nmake b/src/or/Makefile.nmake
index 3b627b1d06..523bf3306b 100644
--- a/src/or/Makefile.nmake
+++ b/src/or/Makefile.nmake
@@ -1,6 +1,6 @@
all: tor.exe
-CFLAGS = /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
+CFLAGS = /O2 /MT /I ..\win32 /I ..\..\..\build-alpha\include /I ..\common \
/I ..\ext
LIBS = ..\..\..\build-alpha\lib\libevent.lib \
@@ -15,6 +15,7 @@ LIBTOR_OBJECTS = \
buffers.obj \
channel.obj \
channeltls.obj \
+ circpathbias.obj \
circuitbuild.obj \
circuitlist.obj \
circuitmux.obj \
@@ -35,6 +36,7 @@ LIBTOR_OBJECTS = \
dirvote.obj \
dns.obj \
dnsserv.obj \
+ ext_orport.obj \
fp_pair.obj \
entrynodes.obj \
geoip.obj \
@@ -69,7 +71,7 @@ libtor.lib: $(LIBTOR_OBJECTS)
lib $(LIBTOR_OBJECTS) /out:$@
tor.exe: libtor.lib tor_main.obj
- $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib tor_main.obj /Fe$@
+ $(CC) $(CFLAGS) $(LIBS) libtor.lib ..\common\*.lib ..\ext\*.lib tor_main.obj /Fe$@
clean:
- del $(LIBTOR_OBJECTS) *.lib tor.exe
+ del $(LIBTOR_OBJECTS) tor_main.obj *.lib tor.exe
diff --git a/src/or/addressmap.c b/src/or/addressmap.c
index 998770a3db..d7ac7c8ec7 100644
--- a/src/or/addressmap.c
+++ b/src/or/addressmap.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define ADDRESSMAP_PRIVATE
diff --git a/src/or/addressmap.h b/src/or/addressmap.h
index 417832b31f..598f7b0e3e 100644
--- a/src/or/addressmap.h
+++ b/src/or/addressmap.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_ADDRESSMAP_H
diff --git a/src/or/buffers.c b/src/or/buffers.c
index 033f86288e..bd33fe451d 100644
--- a/src/or/buffers.c
+++ b/src/or/buffers.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -55,6 +55,9 @@
* forever.
*/
+static void socks_request_set_socks5_error(socks_request_t *req,
+ socks5_reply_status_t reason);
+
static int parse_socks(const char *data, size_t datalen, socks_request_t *req,
int log_sockstype, int safe_socks, ssize_t *drain_out,
size_t *want_length_out);
@@ -1831,6 +1834,21 @@ fetch_ext_or_command_from_evbuffer(struct evbuffer *buf, ext_or_cmd_t **out)
}
#endif
+/** Create a SOCKS5 reply message with <b>reason</b> in its REP field and
+ * have Tor send it as error response to <b>req</b>.
+ */
+static void
+socks_request_set_socks5_error(socks_request_t *req,
+ socks5_reply_status_t reason)
+{
+ req->replylen = 10;
+ memset(req->reply,0,10);
+
+ req->reply[0] = 0x05; // VER field.
+ req->reply[1] = reason; // REP field.
+ req->reply[3] = 0x01; // ATYP field.
+}
+
/** Implementation helper to implement fetch_from_*_socks. Instead of looking
* at a buffer's contents, we look at the <b>datalen</b> bytes of data in
* <b>data</b>. Instead of removing data from the buffer, we set
@@ -1894,7 +1912,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
}
*drain_out = 2u + usernamelen + 1u + passlen;
req->got_auth = 1;
- *want_length_out = 7; /* Minimal socks5 sommand. */
+ *want_length_out = 7; /* Minimal socks5 command. */
return 0;
} else if (req->auth_type == SOCKS_USER_PASS) {
/* unknown version byte */
@@ -1966,6 +1984,8 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
req->command != SOCKS_COMMAND_RESOLVE &&
req->command != SOCKS_COMMAND_RESOLVE_PTR) {
/* not a connect or resolve or a resolve_ptr? we don't support it. */
+ socks_request_set_socks5_error(req,SOCKS5_COMMAND_NOT_SUPPORTED);
+
log_warn(LD_APP,"socks5: command %d not recognized. Rejecting.",
req->command);
return -1;
@@ -1989,6 +2009,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
tor_addr_to_str(tmpbuf, &destaddr, sizeof(tmpbuf), 1);
if (strlen(tmpbuf)+1 > MAX_SOCKS_ADDR_LEN) {
+ socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
log_warn(LD_APP,
"socks5 IP takes %d bytes, which doesn't fit in %d. "
"Rejecting.",
@@ -2001,14 +2022,18 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
if (req->command != SOCKS_COMMAND_RESOLVE_PTR &&
!addressmap_have_mapping(req->address,0)) {
log_unsafe_socks_warning(5, req->address, req->port, safe_socks);
- if (safe_socks)
+ if (safe_socks) {
+ socks_request_set_socks5_error(req, SOCKS5_NOT_ALLOWED);
return -1;
+ }
}
return 1;
}
case 3: /* fqdn */
log_debug(LD_APP,"socks5: fqdn address type");
if (req->command == SOCKS_COMMAND_RESOLVE_PTR) {
+ socks_request_set_socks5_error(req,
+ SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED);
log_warn(LD_APP, "socks5 received RESOLVE_PTR command with "
"hostname type. Rejecting.");
return -1;
@@ -2019,6 +2044,7 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
return 0; /* not yet */
}
if (len+1 > MAX_SOCKS_ADDR_LEN) {
+ socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
log_warn(LD_APP,
"socks5 hostname is %d bytes, which doesn't fit in "
"%d. Rejecting.", len+1,MAX_SOCKS_ADDR_LEN);
@@ -2028,7 +2054,20 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
req->address[len] = 0;
req->port = ntohs(get_uint16(data+5+len));
*drain_out = 5+len+2;
- if (!tor_strisprint(req->address) || strchr(req->address,'\"')) {
+
+ if (string_is_valid_ipv4_address(req->address) ||
+ string_is_valid_ipv6_address(req->address)) {
+ log_unsafe_socks_warning(5,req->address,req->port,safe_socks);
+
+ if (safe_socks) {
+ socks_request_set_socks5_error(req, SOCKS5_NOT_ALLOWED);
+ return -1;
+ }
+ }
+
+ if (!string_is_valid_hostname(req->address)) {
+ socks_request_set_socks5_error(req, SOCKS5_GENERAL_ERROR);
+
log_warn(LD_PROTOCOL,
"Your application (using socks5 to port %d) gave Tor "
"a malformed hostname: %s. Rejecting the connection.",
@@ -2042,6 +2081,8 @@ parse_socks(const char *data, size_t datalen, socks_request_t *req,
"necessary. This is good.", req->port);
return 1;
default: /* unsupported */
+ socks_request_set_socks5_error(req,
+ SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED);
log_warn(LD_APP,"socks5: unsupported address type %d. Rejecting.",
(int) *(data+3));
return -1;
diff --git a/src/or/buffers.h b/src/or/buffers.h
index c90e14750e..9c2c7d0e9d 100644
--- a/src/or/buffers.h
+++ b/src/or/buffers.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/channel.c b/src/or/channel.c
index 964b3fcac3..13a122662a 100644
--- a/src/or/channel.c
+++ b/src/or/channel.c
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -108,8 +108,8 @@ channel_idmap_eq(const channel_idmap_entry_t *a,
HT_PROTOTYPE(channel_idmap, channel_idmap_entry_s, node, channel_idmap_hash,
channel_idmap_eq);
-HT_GENERATE(channel_idmap, channel_idmap_entry_s, node, channel_idmap_hash,
- channel_idmap_eq, 0.5, tor_malloc, tor_realloc, tor_free_);
+HT_GENERATE2(channel_idmap, channel_idmap_entry_s, node, channel_idmap_hash,
+ channel_idmap_eq, 0.5, tor_reallocarray_, tor_free_);
static cell_queue_entry_t * cell_queue_entry_dup(cell_queue_entry_t *q);
static void cell_queue_entry_free(cell_queue_entry_t *q, int handed_off);
@@ -2682,6 +2682,14 @@ int
channel_send_destroy(circid_t circ_id, channel_t *chan, int reason)
{
tor_assert(chan);
+ if (circ_id == 0) {
+ log_warn(LD_BUG, "Attempted to send a destroy cell for circID 0 "
+ "on a channel " U64_FORMAT " at %p in state %s (%d)",
+ U64_PRINTF_ARG(chan->global_identifier),
+ chan, channel_state_to_string(chan->state),
+ chan->state);
+ return 0;
+ }
/* Check to make sure we can send on this channel first */
if (!(chan->state == CHANNEL_STATE_CLOSING ||
@@ -3352,7 +3360,7 @@ channel_dump_statistics(channel_t *chan, int severity)
U64_PRINTF_ARG(chan->timestamp_recv),
U64_PRINTF_ARG(now - chan->timestamp_recv));
tor_log(severity, LD_GENERAL,
- " * Channel " U64_FORMAT " last trasmitted a cell "
+ " * Channel " U64_FORMAT " last transmitted a cell "
"at " U64_FORMAT " (" U64_FORMAT " seconds ago)",
U64_PRINTF_ARG(chan->global_identifier),
U64_PRINTF_ARG(chan->timestamp_xmit),
@@ -3752,6 +3760,23 @@ channel_mark_local(channel_t *chan)
}
/**
+ * Mark a channel as remote
+ *
+ * This internal-only function should be called by the lower layer if the
+ * channel is not to a local address but has previously been marked local.
+ * See channel_is_local() above or the description of the is_local bit in
+ * channel.h
+ */
+
+void
+channel_mark_remote(channel_t *chan)
+{
+ tor_assert(chan);
+
+ chan->is_local = 0;
+}
+
+/**
* Test outgoing flag
*
* This function gets the outgoing flag; this is the inverse of the incoming
diff --git a/src/or/channel.h b/src/or/channel.h
index 3e164c6892..4cd8f4391e 100644
--- a/src/or/channel.h
+++ b/src/or/channel.h
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -349,6 +349,7 @@ void channel_clear_remote_end(channel_t *chan);
void channel_mark_local(channel_t *chan);
void channel_mark_incoming(channel_t *chan);
void channel_mark_outgoing(channel_t *chan);
+void channel_mark_remote(channel_t *chan);
void channel_set_identity_digest(channel_t *chan,
const char *identity_digest);
void channel_set_remote_end(channel_t *chan,
diff --git a/src/or/channeltls.c b/src/or/channeltls.c
index 632bc328b7..db044aee56 100644
--- a/src/or/channeltls.c
+++ b/src/or/channeltls.c
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -156,7 +156,18 @@ channel_tls_connect(const tor_addr_t *addr, uint16_t port,
tlschan,
U64_PRINTF_ARG(chan->global_identifier));
- if (is_local_addr(addr)) channel_mark_local(chan);
+ if (is_local_addr(addr)) {
+ log_debug(LD_CHANNEL,
+ "Marking new outgoing channel " U64_FORMAT " at %p as local",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_local(chan);
+ } else {
+ log_debug(LD_CHANNEL,
+ "Marking new outgoing channel " U64_FORMAT " at %p as remote",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_remote(chan);
+ }
+
channel_mark_outgoing(chan);
/* Set up or_connection stuff */
@@ -286,7 +297,18 @@ channel_tls_handle_incoming(or_connection_t *orconn)
tlschan->conn = orconn;
orconn->chan = tlschan;
- if (is_local_addr(&(TO_CONN(orconn)->addr))) channel_mark_local(chan);
+ if (is_local_addr(&(TO_CONN(orconn)->addr))) {
+ log_debug(LD_CHANNEL,
+ "Marking new incoming channel " U64_FORMAT " at %p as local",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_local(chan);
+ } else {
+ log_debug(LD_CHANNEL,
+ "Marking new incoming channel " U64_FORMAT " at %p as remote",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_remote(chan);
+ }
+
channel_mark_incoming(chan);
/* Register it */
@@ -825,8 +847,8 @@ channel_tls_handle_state_change_on_orconn(channel_tls_t *chan,
tor_assert(conn);
tor_assert(conn->chan == chan);
tor_assert(chan->conn == conn);
- /* -Werror appeasement */
- tor_assert(old_state == old_state);
+ /* Shut the compiler up without triggering -Wtautological-compare */
+ (void)old_state;
base_chan = TLS_CHAN_TO_BASE(chan);
@@ -1209,6 +1231,44 @@ channel_tls_handle_var_cell(var_cell_t *var_cell, or_connection_t *conn)
}
/**
+ * Update channel marks after connection_or.c has changed an address
+ *
+ * This is called from connection_or_init_conn_from_address() after the
+ * connection's _base.addr or real_addr fields have potentially been changed
+ * so we can recalculate the local mark. Notably, this happens when incoming
+ * connections are reverse-proxied and we only learn the real address of the
+ * remote router by looking it up in the consensus after we finish the
+ * handshake and know an authenticated identity digest.
+ */
+
+void
+channel_tls_update_marks(or_connection_t *conn)
+{
+ channel_t *chan = NULL;
+
+ tor_assert(conn);
+ tor_assert(conn->chan);
+
+ chan = TLS_CHAN_TO_BASE(conn->chan);
+
+ if (is_local_addr(&(TO_CONN(conn)->addr))) {
+ if (!channel_is_local(chan)) {
+ log_debug(LD_CHANNEL,
+ "Marking channel " U64_FORMAT " at %p as local",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_local(chan);
+ }
+ } else {
+ if (channel_is_local(chan)) {
+ log_debug(LD_CHANNEL,
+ "Marking channel " U64_FORMAT " at %p as remote",
+ U64_PRINTF_ARG(chan->global_identifier), chan);
+ channel_mark_remote(chan);
+ }
+ }
+}
+
+/**
* Check if this cell type is allowed before the handshake is finished
*
* Return true if <b>command</b> is a cell command that's allowed to start a
diff --git a/src/or/channeltls.h b/src/or/channeltls.h
index b4a7e2beac..06be6fa555 100644
--- a/src/or/channeltls.h
+++ b/src/or/channeltls.h
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -49,6 +49,7 @@ void channel_tls_handle_state_change_on_orconn(channel_tls_t *chan,
uint8_t state);
void channel_tls_handle_var_cell(var_cell_t *var_cell,
or_connection_t *conn);
+void channel_tls_update_marks(or_connection_t *conn);
/* Cleanup at shutdown */
void channel_tls_free_all(void);
diff --git a/src/or/circpathbias.c b/src/or/circpathbias.c
index 51a75cf502..a6858a3460 100644
--- a/src/or/circpathbias.c
+++ b/src/or/circpathbias.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -1140,11 +1140,10 @@ pathbias_count_circs_in_states(entry_guard_t *guard,
path_state_t from,
path_state_t to)
{
- circuit_t *circ;
int open_circuits = 0;
/* Count currently open circuits. Give them the benefit of the doubt. */
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
origin_circuit_t *ocirc = NULL;
if (!CIRCUIT_IS_ORIGIN(circ) || /* didn't originate here */
circ->marked_for_close) /* already counted */
@@ -1167,6 +1166,7 @@ pathbias_count_circs_in_states(entry_guard_t *guard,
open_circuits++;
}
}
+ SMARTLIST_FOREACH_END(circ);
return open_circuits;
}
diff --git a/src/or/circpathbias.h b/src/or/circpathbias.h
index c95d801a4b..bb8846353c 100644
--- a/src/or/circpathbias.h
+++ b/src/or/circpathbias.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/circuitbuild.c b/src/or/circuitbuild.c
index 283afee31f..42c4870e87 100644
--- a/src/or/circuitbuild.c
+++ b/src/or/circuitbuild.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -59,9 +59,7 @@ static crypt_path_t *onion_next_hop_in_cpath(crypt_path_t *cpath);
static int onion_extend_cpath(origin_circuit_t *circ);
static int count_acceptable_nodes(smartlist_t *routers);
static int onion_append_hop(crypt_path_t **head_ptr, extend_info_t *choice);
-#ifdef CURVE25519_ENABLED
static int circuits_can_use_ntor(void);
-#endif
/** This function tries to get a channel to the specified endpoint,
* and then calls command_setup_channel() to give it the right
@@ -368,7 +366,6 @@ circuit_rep_hist_note_result(origin_circuit_t *circ)
} while (hop!=circ->cpath);
}
-#ifdef CURVE25519_ENABLED
/** Return 1 iff at least one node in circ's cpath supports ntor. */
static int
circuit_cpath_supports_ntor(const origin_circuit_t *circ)
@@ -388,9 +385,6 @@ circuit_cpath_supports_ntor(const origin_circuit_t *circ)
return 0;
}
-#else
-#define circuit_cpath_supports_ntor(circ) 0
-#endif
/** Pick all the entries in our cpath. Stop and return 0 when we're
* happy, or return -1 if an error occurs. */
@@ -398,11 +392,7 @@ static int
onion_populate_cpath(origin_circuit_t *circ)
{
int n_tries = 0;
-#ifdef CURVE25519_ENABLED
const int using_ntor = circuits_can_use_ntor();
-#else
- const int using_ntor = 0;
-#endif
#define MAX_POPULATE_ATTEMPTS 32
@@ -549,6 +539,7 @@ circuit_handle_first_hop(origin_circuit_t *circ)
log_debug(LD_CIRC,"Conn open. Delivering first onion skin.");
if ((err_reason = circuit_send_next_onion_skin(circ)) < 0) {
log_info(LD_CIRC,"circuit_send_next_onion_skin failed.");
+ circ->base_.n_chan = NULL;
return err_reason;
}
}
@@ -660,18 +651,18 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell,
static ratelim_t circid_warning_limit = RATELIM_INIT(9600);
log_fn_ratelim(&circid_warning_limit, LOG_WARN, LD_CIRC,
"failed to get unique circID.");
- return -1;
+ goto error;
}
- log_debug(LD_CIRC,"Chosen circID %u.", (unsigned)id);
- circuit_set_n_circid_chan(circ, id, circ->n_chan);
memset(&cell, 0, sizeof(cell_t));
r = relayed ? create_cell_format_relayed(&cell, create_cell)
: create_cell_format(&cell, create_cell);
if (r < 0) {
log_warn(LD_CIRC,"Couldn't format create cell");
- return -1;
+ goto error;
}
+ log_debug(LD_CIRC,"Chosen circID %u.", (unsigned)id);
+ circuit_set_n_circid_chan(circ, id, circ->n_chan);
cell.circ_id = circ->n_circ_id;
append_cell_to_circuit_queue(circ, circ->n_chan, &cell,
@@ -695,6 +686,9 @@ circuit_deliver_create_cell(circuit_t *circ, const create_cell_t *create_cell,
}
return 0;
+ error:
+ circ->n_chan = NULL;
+ return -1;
}
/** We've decided to start our reachability testing. If all
@@ -768,7 +762,6 @@ circuit_timeout_want_to_count_circ(origin_circuit_t *circ)
&& circ->build_state->desired_path_len == DEFAULT_ROUTE_LEN;
}
-#ifdef CURVE25519_ENABLED
/** Return true if the ntor handshake is enabled in the configuration, or if
* it's been set to "auto" in the configuration and it's enabled in the
* consensus. */
@@ -780,7 +773,6 @@ circuits_can_use_ntor(void)
return options->UseNTorHandshake;
return networkstatus_get_param(NULL, "UseNTorHandshake", 0, 0, 1);
}
-#endif
/** Decide whether to use a TAP or ntor handshake for connecting to <b>ei</b>
* directly, and set *<b>cell_type_out</b> and *<b>handshake_type_out</b>
@@ -790,7 +782,6 @@ circuit_pick_create_handshake(uint8_t *cell_type_out,
uint16_t *handshake_type_out,
const extend_info_t *ei)
{
-#ifdef CURVE25519_ENABLED
if (!tor_mem_is_zero((const char*)ei->curve25519_onion_key.public_key,
CURVE25519_PUBKEY_LEN) &&
circuits_can_use_ntor()) {
@@ -798,9 +789,6 @@ circuit_pick_create_handshake(uint8_t *cell_type_out,
*handshake_type_out = ONION_HANDSHAKE_TYPE_NTOR;
return;
}
-#else
- (void) ei;
-#endif
*cell_type_out = CELL_CREATE;
*handshake_type_out = ONION_HANDSHAKE_TYPE_TAP;
@@ -1560,7 +1548,7 @@ choose_good_exit_server_general(int need_uptime, int need_capacity)
* -1 means "Don't use this router at all."
*/
the_nodes = nodelist_get_list();
- n_supported = tor_malloc(sizeof(int)*smartlist_len(the_nodes));
+ n_supported = tor_calloc(smartlist_len(the_nodes), sizeof(int));
SMARTLIST_FOREACH_BEGIN(the_nodes, const node_t *, node) {
const int i = node_sl_idx;
if (router_digest_is_me(node->identity)) {
@@ -2194,13 +2182,9 @@ extend_info_new(const char *nickname, const char *digest,
strlcpy(info->nickname, nickname, sizeof(info->nickname));
if (onion_key)
info->onion_key = crypto_pk_dup_key(onion_key);
-#ifdef CURVE25519_ENABLED
if (curve25519_key)
memcpy(&info->curve25519_onion_key, curve25519_key,
sizeof(curve25519_public_key_t));
-#else
- (void)curve25519_key;
-#endif
tor_addr_copy(&info->addr, addr);
info->port = port;
return info;
diff --git a/src/or/circuitbuild.h b/src/or/circuitbuild.h
index 71caea94ed..e70cdc5825 100644
--- a/src/or/circuitbuild.h
+++ b/src/or/circuitbuild.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/circuitlist.c b/src/or/circuitlist.c
index f3a83503ef..d9da1e7f88 100644
--- a/src/or/circuitlist.c
+++ b/src/or/circuitlist.c
@@ -1,7 +1,7 @@
/* Copyright 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -21,6 +21,7 @@
#include "connection_edge.h"
#include "connection_or.h"
#include "control.h"
+#include "main.h"
#include "networkstatus.h"
#include "nodelist.h"
#include "onion.h"
@@ -38,8 +39,7 @@
/********* START VARIABLES **********/
/** A global list of all circuits at this hop. */
-struct global_circuitlist_s global_circuitlist =
- TOR_LIST_HEAD_INITIALIZER(global_circuitlist);
+static smartlist_t *global_circuitlist = NULL;
/** A list of all the circuits in CIRCUIT_STATE_CHAN_WAIT. */
static smartlist_t *circuits_pending_chans = NULL;
@@ -94,9 +94,9 @@ static HT_HEAD(chan_circid_map, chan_circid_circuit_map_t)
chan_circid_map = HT_INITIALIZER();
HT_PROTOTYPE(chan_circid_map, chan_circid_circuit_map_t, node,
chan_circid_entry_hash_, chan_circid_entries_eq_)
-HT_GENERATE(chan_circid_map, chan_circid_circuit_map_t, node,
- chan_circid_entry_hash_, chan_circid_entries_eq_, 0.6,
- malloc, realloc, free)
+HT_GENERATE2(chan_circid_map, chan_circid_circuit_map_t, node,
+ chan_circid_entry_hash_, chan_circid_entries_eq_, 0.6,
+ tor_reallocarray_, tor_free_)
/** The most recently returned entry from circuit_get_by_circid_chan;
* used to improve performance when many cells arrive in a row from the
@@ -451,17 +451,25 @@ circuit_count_pending_on_channel(channel_t *chan)
void
circuit_close_all_marked(void)
{
- circuit_t *circ, *tmp;
- TOR_LIST_FOREACH_SAFE(circ, &global_circuitlist, head, tmp)
- if (circ->marked_for_close)
+ smartlist_t *lst = circuit_get_global_list();
+ SMARTLIST_FOREACH_BEGIN(lst, circuit_t *, circ) {
+ /* Fix up index if SMARTLIST_DEL_CURRENT just moved this one. */
+ circ->global_circuitlist_idx = circ_sl_idx;
+ if (circ->marked_for_close) {
+ circ->global_circuitlist_idx = -1;
circuit_free(circ);
+ SMARTLIST_DEL_CURRENT(lst, circ);
+ }
+ } SMARTLIST_FOREACH_END(circ);
}
/** Return the head of the global linked list of circuits. */
-MOCK_IMPL(struct global_circuitlist_s *,
+MOCK_IMPL(smartlist_t *,
circuit_get_global_list,(void))
{
- return &global_circuitlist;
+ if (NULL == global_circuitlist)
+ global_circuitlist = smartlist_new();
+ return global_circuitlist;
}
/** Function to make circ-\>state human-readable */
@@ -678,7 +686,8 @@ init_circuit_base(circuit_t *circ)
circ->deliver_window = CIRCWINDOW_START;
cell_queue_init(&circ->n_chan_cells);
- TOR_LIST_INSERT_HEAD(&global_circuitlist, circ, head);
+ smartlist_add(circuit_get_global_list(), circ);
+ circ->global_circuitlist_idx = smartlist_len(circuit_get_global_list()) - 1;
}
/** Allocate space for a new circuit, initializing with <b>p_circ_id</b>
@@ -799,7 +808,16 @@ circuit_free(circuit_t *circ)
extend_info_free(circ->n_hop);
tor_free(circ->n_chan_create_cell);
- TOR_LIST_REMOVE(circ, head);
+ if (circ->global_circuitlist_idx != -1) {
+ int idx = circ->global_circuitlist_idx;
+ circuit_t *c2 = smartlist_get(global_circuitlist, idx);
+ tor_assert(c2 == circ);
+ smartlist_del(global_circuitlist, idx);
+ if (idx < smartlist_len(global_circuitlist)) {
+ c2 = smartlist_get(global_circuitlist, idx);
+ c2->global_circuitlist_idx = idx;
+ }
+ }
/* Remove from map. */
circuit_set_n_circid_chan(circ, 0, NULL);
@@ -841,9 +859,9 @@ circuit_clear_cpath(origin_circuit_t *circ)
void
circuit_free_all(void)
{
- circuit_t *tmp, *tmp2;
+ smartlist_t *lst = circuit_get_global_list();
- TOR_LIST_FOREACH_SAFE(tmp, &global_circuitlist, head, tmp2) {
+ SMARTLIST_FOREACH_BEGIN(lst, circuit_t *, tmp) {
if (! CIRCUIT_IS_ORIGIN(tmp)) {
or_circuit_t *or_circ = TO_OR_CIRCUIT(tmp);
while (or_circ->resolving_streams) {
@@ -853,8 +871,13 @@ circuit_free_all(void)
or_circ->resolving_streams = next_conn;
}
}
+ tmp->global_circuitlist_idx = -1;
circuit_free(tmp);
- }
+ SMARTLIST_DEL_CURRENT(lst, tmp);
+ } SMARTLIST_FOREACH_END(tmp);
+
+ smartlist_free(lst);
+ global_circuitlist = NULL;
smartlist_free(circuits_pending_chans);
circuits_pending_chans = NULL;
@@ -932,10 +955,9 @@ circuit_dump_conn_details(int severity,
void
circuit_dump_by_conn(connection_t *conn, int severity)
{
- circuit_t *circ;
edge_connection_t *tmpconn;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
circid_t n_circ_id = circ->n_circ_id, p_circ_id = 0;
if (circ->marked_for_close) {
@@ -966,6 +988,7 @@ circuit_dump_by_conn(connection_t *conn, int severity)
}
}
}
+ SMARTLIST_FOREACH_END(circ);
}
/** Return the circuit whose global ID is <b>id</b>, or NULL if no
@@ -973,8 +996,7 @@ circuit_dump_by_conn(connection_t *conn, int severity)
origin_circuit_t *
circuit_get_by_global_id(uint32_t id)
{
- circuit_t *circ;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (CIRCUIT_IS_ORIGIN(circ) &&
TO_ORIGIN_CIRCUIT(circ)->global_identifier == id) {
if (circ->marked_for_close)
@@ -983,6 +1005,7 @@ circuit_get_by_global_id(uint32_t id)
return TO_ORIGIN_CIRCUIT(circ);
}
}
+ SMARTLIST_FOREACH_END(circ);
return NULL;
}
@@ -1151,17 +1174,17 @@ circuit_unlink_all_from_channel(channel_t *chan, int reason)
#ifdef DEBUG_CIRCUIT_UNLINK_ALL
{
- circuit_t *circ;
smartlist_t *detached_2 = smartlist_new();
int mismatch = 0, badlen = 0;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (circ->n_chan == chan ||
(!CIRCUIT_IS_ORIGIN(circ) &&
TO_OR_CIRCUIT(circ)->p_chan == chan)) {
smartlist_add(detached_2, circ);
}
}
+ SMARTLIST_FOREACH_END(circ);
if (smartlist_len(detached) != smartlist_len(detached_2)) {
log_warn(LD_BUG, "List of detached circuits had the wrong length! "
@@ -1235,8 +1258,7 @@ circuit_unlink_all_from_channel(channel_t *chan, int reason)
origin_circuit_t *
circuit_get_ready_rend_circ_by_rend_data(const rend_data_t *rend_data)
{
- circuit_t *circ;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!circ->marked_for_close &&
circ->purpose == CIRCUIT_PURPOSE_C_REND_READY) {
origin_circuit_t *ocirc = TO_ORIGIN_CIRCUIT(circ);
@@ -1249,6 +1271,7 @@ circuit_get_ready_rend_circ_by_rend_data(const rend_data_t *rend_data)
return ocirc;
}
}
+ SMARTLIST_FOREACH_END(circ);
return NULL;
}
@@ -1261,14 +1284,17 @@ origin_circuit_t *
circuit_get_next_by_pk_and_purpose(origin_circuit_t *start,
const char *digest, uint8_t purpose)
{
- circuit_t *circ;
+ int idx;
+ smartlist_t *lst = circuit_get_global_list();
tor_assert(CIRCUIT_PURPOSE_IS_ORIGIN(purpose));
if (start == NULL)
- circ = TOR_LIST_FIRST(&global_circuitlist);
+ idx = 0;
else
- circ = TOR_LIST_NEXT(TO_CIRCUIT(start), head);
+ idx = TO_CIRCUIT(start)->global_circuitlist_idx + 1;
+
+ for ( ; idx < smartlist_len(lst); ++idx) {
+ circuit_t *circ = smartlist_get(lst, idx);
- for ( ; circ; circ = TOR_LIST_NEXT(circ, head)) {
if (circ->marked_for_close)
continue;
if (circ->purpose != purpose)
@@ -1469,7 +1495,6 @@ origin_circuit_t *
circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
int flags)
{
- circuit_t *circ_;
origin_circuit_t *best=NULL;
int need_uptime = (flags & CIRCLAUNCH_NEED_UPTIME) != 0;
int need_capacity = (flags & CIRCLAUNCH_NEED_CAPACITY) != 0;
@@ -1485,7 +1510,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
"capacity %d, internal %d",
purpose, need_uptime, need_capacity, internal);
- TOR_LIST_FOREACH(circ_, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ_) {
if (CIRCUIT_IS_ORIGIN(circ_) &&
circ_->state == CIRCUIT_STATE_OPEN &&
!circ_->marked_for_close &&
@@ -1535,6 +1560,7 @@ circuit_find_to_cannibalize(uint8_t purpose, extend_info_t *info,
}
}
}
+ SMARTLIST_FOREACH_END(circ_);
return best;
}
@@ -1574,13 +1600,13 @@ circuit_get_cpath_hop(origin_circuit_t *circ, int hopnum)
void
circuit_mark_all_unused_circs(void)
{
- circuit_t *circ;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (CIRCUIT_IS_ORIGIN(circ) &&
!circ->marked_for_close &&
!circ->timestamp_dirty)
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
}
+ SMARTLIST_FOREACH_END(circ);
}
/** Go through the circuitlist; for each circuit that starts at us
@@ -1593,14 +1619,14 @@ circuit_mark_all_unused_circs(void)
void
circuit_mark_all_dirty_circs_as_unusable(void)
{
- circuit_t *circ;
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (CIRCUIT_IS_ORIGIN(circ) &&
!circ->marked_for_close &&
circ->timestamp_dirty) {
mark_circuit_unusable_for_new_conns(TO_ORIGIN_CIRCUIT(circ));
}
}
+ SMARTLIST_FOREACH_END(circ);
}
/** Mark <b>circ</b> to be closed next time we call
@@ -1799,6 +1825,29 @@ marked_circuit_free_cells(circuit_t *circ)
cell_queue_clear(& TO_OR_CIRCUIT(circ)->p_chan_cells);
}
+static size_t
+single_conn_free_bytes(connection_t *conn)
+{
+ size_t result = 0;
+ if (conn->inbuf) {
+ result += buf_allocation(conn->inbuf);
+ buf_clear(conn->inbuf);
+ }
+ if (conn->outbuf) {
+ result += buf_allocation(conn->outbuf);
+ buf_clear(conn->outbuf);
+ }
+ if (conn->type == CONN_TYPE_DIR) {
+ dir_connection_t *dir_conn = TO_DIR_CONN(conn);
+ if (dir_conn->zlib_state) {
+ result += tor_zlib_state_size(dir_conn->zlib_state);
+ tor_zlib_free(dir_conn->zlib_state);
+ dir_conn->zlib_state = NULL;
+ }
+ }
+ return result;
+}
+
/** Aggressively free buffer contents on all the buffers of all streams in the
* list starting at <b>stream</b>. Return the number of bytes recovered. */
static size_t
@@ -1807,13 +1856,9 @@ marked_circuit_streams_free_bytes(edge_connection_t *stream)
size_t result = 0;
for ( ; stream; stream = stream->next_stream) {
connection_t *conn = TO_CONN(stream);
- if (conn->inbuf) {
- result += buf_allocation(conn->inbuf);
- buf_clear(conn->inbuf);
- }
- if (conn->outbuf) {
- result += buf_allocation(conn->outbuf);
- buf_clear(conn->outbuf);
+ result += single_conn_free_bytes(conn);
+ if (conn->linked_conn) {
+ result += single_conn_free_bytes(conn->linked_conn);
}
}
return result;
@@ -1871,6 +1916,28 @@ circuit_max_queued_cell_age(const circuit_t *c, uint32_t now)
return age;
}
+/** Return the age in milliseconds of the oldest buffer chunk on <b>conn</b>,
+ * where age is taken in milliseconds before the time <b>now</b> (in truncated
+ * milliseconds since the epoch). If the connection has no data, treat
+ * it as having age zero.
+ **/
+static uint32_t
+conn_get_buffer_age(const connection_t *conn, uint32_t now)
+{
+ uint32_t age = 0, age2;
+ if (conn->outbuf) {
+ age2 = buf_get_oldest_chunk_timestamp(conn->outbuf, now);
+ if (age2 > age)
+ age = age2;
+ }
+ if (conn->inbuf) {
+ age2 = buf_get_oldest_chunk_timestamp(conn->inbuf, now);
+ if (age2 > age)
+ age = age2;
+ }
+ return age;
+}
+
/** Return the age in milliseconds of the oldest buffer chunk on any stream in
* the linked list <b>stream</b>, where age is taken in milliseconds before
* the time <b>now</b> (in truncated milliseconds since the epoch). */
@@ -1880,18 +1947,15 @@ circuit_get_streams_max_data_age(const edge_connection_t *stream, uint32_t now)
uint32_t age = 0, age2;
for (; stream; stream = stream->next_stream) {
const connection_t *conn = TO_CONN(stream);
- if (conn->outbuf) {
- age2 = buf_get_oldest_chunk_timestamp(conn->outbuf, now);
- if (age2 > age)
- age = age2;
- }
- if (conn->inbuf) {
- age2 = buf_get_oldest_chunk_timestamp(conn->inbuf, now);
+ age2 = conn_get_buffer_age(conn, now);
+ if (age2 > age)
+ age = age2;
+ if (conn->linked_conn) {
+ age2 = conn_get_buffer_age(conn->linked_conn, now);
if (age2 > age)
age = age2;
}
}
-
return age;
}
@@ -1942,6 +2006,26 @@ circuits_compare_by_oldest_queued_item_(const void **a_, const void **b_)
return -1;
}
+static uint32_t now_ms_for_buf_cmp;
+
+/** Helper to sort a list of circuit_t by age of oldest item, in descending
+ * order. */
+static int
+conns_compare_by_buffer_age_(const void **a_, const void **b_)
+{
+ const connection_t *a = *a_;
+ const connection_t *b = *b_;
+ time_t age_a = conn_get_buffer_age(a, now_ms_for_buf_cmp);
+ time_t age_b = conn_get_buffer_age(b, now_ms_for_buf_cmp);
+
+ if (age_a < age_b)
+ return 1;
+ else if (age_a == age_b)
+ return 0;
+ else
+ return -1;
+}
+
#define FRACTION_OF_DATA_TO_RETAIN_ON_OOM 0.90
/** We're out of memory for cells, having allocated <b>current_allocation</b>
@@ -1950,12 +2034,13 @@ circuits_compare_by_oldest_queued_item_(const void **a_, const void **b_)
void
circuits_handle_oom(size_t current_allocation)
{
- /* Let's hope there's enough slack space for this allocation here... */
- smartlist_t *circlist = smartlist_new();
- circuit_t *circ;
+ smartlist_t *circlist;
+ smartlist_t *connection_array = get_connection_array();
+ int conn_idx;
size_t mem_to_recover;
size_t mem_recovered=0;
int n_circuits_killed=0;
+ int n_dirconns_killed=0;
struct timeval now;
uint32_t now_ms;
log_notice(LD_GENERAL, "We're low on memory. Killing circuits with "
@@ -1984,22 +2069,61 @@ circuits_handle_oom(size_t current_allocation)
tor_gettimeofday_cached_monotonic(&now);
now_ms = (uint32_t)tv_to_msec(&now);
- /* This algorithm itself assumes that you've got enough memory slack
- * to actually run it. */
- TOR_LIST_FOREACH(circ, &global_circuitlist, head) {
+ circlist = circuit_get_global_list();
+ SMARTLIST_FOREACH_BEGIN(circlist, circuit_t *, circ) {
circ->age_tmp = circuit_max_queued_item_age(circ, now_ms);
- smartlist_add(circlist, circ);
- }
+ } SMARTLIST_FOREACH_END(circ);
/* This is O(n log n); there are faster algorithms we could use instead.
* Let's hope this doesn't happen enough to be in the critical path. */
smartlist_sort(circlist, circuits_compare_by_oldest_queued_item_);
- /* Okay, now the worst circuits are at the front of the list. Let's mark
- * them, and reclaim their storage aggressively. */
+ /* Fix up the indices before we run into trouble */
SMARTLIST_FOREACH_BEGIN(circlist, circuit_t *, circ) {
- size_t n = n_cells_in_circ_queues(circ);
+ circ->global_circuitlist_idx = circ_sl_idx;
+ } SMARTLIST_FOREACH_END(circ);
+
+ /* Now sort the connection array ... */
+ now_ms_for_buf_cmp = now_ms;
+ smartlist_sort(connection_array, conns_compare_by_buffer_age_);
+ now_ms_for_buf_cmp = 0;
+
+ /* Fix up the connection array to its new order. */
+ SMARTLIST_FOREACH_BEGIN(connection_array, connection_t *, conn) {
+ conn->conn_array_index = conn_sl_idx;
+ } SMARTLIST_FOREACH_END(conn);
+
+ /* Okay, now the worst circuits and connections are at the front of their
+ * respective lists. Let's mark them, and reclaim their storage
+ * aggressively. */
+ conn_idx = 0;
+ SMARTLIST_FOREACH_BEGIN(circlist, circuit_t *, circ) {
+ size_t n;
size_t freed;
+
+ /* Free storage in any non-linked directory connections that have buffered
+ * data older than this circuit. */
+ while (conn_idx < smartlist_len(connection_array)) {
+ connection_t *conn = smartlist_get(connection_array, conn_idx);
+ uint32_t conn_age = conn_get_buffer_age(conn, now_ms);
+ if (conn_age < circ->age_tmp) {
+ break;
+ }
+ if (conn->type == CONN_TYPE_DIR && conn->linked_conn == NULL) {
+ if (!conn->marked_for_close)
+ connection_mark_for_close(conn);
+ mem_recovered += single_conn_free_bytes(conn);
+
+ ++n_dirconns_killed;
+
+ if (mem_recovered >= mem_to_recover)
+ goto done_recovering_mem;
+ }
+ ++conn_idx;
+ }
+
+ /* Now, kill the circuit. */
+ n = n_cells_in_circ_queues(circ);
if (! circ->marked_for_close) {
circuit_mark_for_close(circ, END_CIRC_REASON_RESOURCELIMIT);
}
@@ -2012,9 +2136,11 @@ circuits_handle_oom(size_t current_allocation)
mem_recovered += freed;
if (mem_recovered >= mem_to_recover)
- break;
+ goto done_recovering_mem;
} SMARTLIST_FOREACH_END(circ);
+ done_recovering_mem:
+
#ifdef ENABLE_MEMPOOLS
clean_cell_pool(); /* In case this helps. */
#endif /* ENABLE_MEMPOOLS */
@@ -2022,12 +2148,12 @@ circuits_handle_oom(size_t current_allocation)
chunks. */
log_notice(LD_GENERAL, "Removed "U64_FORMAT" bytes by killing %d circuits; "
- "%d circuits remain alive.",
+ "%d circuits remain alive. Also killed %d non-linked directory "
+ "connections.",
U64_PRINTF_ARG(mem_recovered),
n_circuits_killed,
- smartlist_len(circlist) - n_circuits_killed);
-
- smartlist_free(circlist);
+ smartlist_len(circlist) - n_circuits_killed,
+ n_dirconns_killed);
}
/** Verify that cpath layer <b>cp</b> has all of its invariants
diff --git a/src/or/circuitlist.h b/src/or/circuitlist.h
index d48d7c3963..addaa725d4 100644
--- a/src/or/circuitlist.h
+++ b/src/or/circuitlist.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -14,9 +14,7 @@
#include "testsupport.h"
-TOR_LIST_HEAD(global_circuitlist_s, circuit_t);
-
-MOCK_DECL(struct global_circuitlist_s*, circuit_get_global_list, (void));
+MOCK_DECL(smartlist_t *, circuit_get_global_list, (void));
const char *circuit_state_to_string(int state);
const char *circuit_purpose_to_controller_string(uint8_t purpose);
const char *circuit_purpose_to_controller_hs_state_string(uint8_t purpose);
diff --git a/src/or/circuitmux.c b/src/or/circuitmux.c
index 55580d5c29..663711c6c0 100644
--- a/src/or/circuitmux.c
+++ b/src/or/circuitmux.c
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -363,9 +363,9 @@ HT_HEAD(chanid_circid_muxinfo_map, chanid_circid_muxinfo_t);
/* Emit a bunch of hash table stuff */
HT_PROTOTYPE(chanid_circid_muxinfo_map, chanid_circid_muxinfo_t, node,
chanid_circid_entry_hash, chanid_circid_entries_eq);
-HT_GENERATE(chanid_circid_muxinfo_map, chanid_circid_muxinfo_t, node,
- chanid_circid_entry_hash, chanid_circid_entries_eq, 0.6,
- malloc, realloc, free);
+HT_GENERATE2(chanid_circid_muxinfo_map, chanid_circid_muxinfo_t, node,
+ chanid_circid_entry_hash, chanid_circid_entries_eq, 0.6,
+ tor_reallocarray_, tor_free_)
/*
* Circuitmux alloc/free functions
@@ -1092,8 +1092,11 @@ circuitmux_detach_circuit,(circuitmux_t *cmux, circuit_t *circ))
/*
* Use this to keep track of whether we found it for n_chan or
* p_chan for consistency checking.
+ *
+ * The 0 initializer is not a valid cell_direction_t value.
+ * We assert that it has been replaced with a valid value before it is used.
*/
- cell_direction_t last_searched_direction;
+ cell_direction_t last_searched_direction = 0;
tor_assert(cmux);
tor_assert(cmux->chanid_circid_map);
@@ -1123,6 +1126,9 @@ circuitmux_detach_circuit,(circuitmux_t *cmux, circuit_t *circ))
}
}
+ tor_assert(last_searched_direction == CELL_DIRECTION_OUT
+ || last_searched_direction == CELL_DIRECTION_IN);
+
/*
* If hashent isn't NULL, we have a circuit to detach; don't remove it from
* the map until later of circuitmux_make_circuit_inactive() breaks.
diff --git a/src/or/circuitmux.h b/src/or/circuitmux.h
index 2b5fb7e51e..eade2486a2 100644
--- a/src/or/circuitmux.h
+++ b/src/or/circuitmux.h
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/circuitmux_ewma.c b/src/or/circuitmux_ewma.c
index 3f37d7b9a0..49d899e5e7 100644
--- a/src/or/circuitmux_ewma.c
+++ b/src/or/circuitmux_ewma.c
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -273,8 +273,8 @@ ewma_alloc_circ_data(circuitmux_t *cmux,
tor_assert(circ);
tor_assert(direction == CELL_DIRECTION_OUT ||
direction == CELL_DIRECTION_IN);
- /* Shut the compiler up */
- tor_assert(cell_count == cell_count);
+ /* Shut the compiler up without triggering -Wtautological-compare */
+ (void)cell_count;
cdata = tor_malloc_zero(sizeof(*cdata));
cdata->base_.magic = EWMA_POL_CIRC_DATA_MAGIC;
diff --git a/src/or/circuitmux_ewma.h b/src/or/circuitmux_ewma.h
index a512745c77..ce78a8ef0d 100644
--- a/src/or/circuitmux_ewma.h
+++ b/src/or/circuitmux_ewma.h
@@ -1,4 +1,4 @@
-/* * Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* * Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/circuitstats.c b/src/or/circuitstats.c
index e362b1b49e..a136278e58 100644
--- a/src/or/circuitstats.c
+++ b/src/or/circuitstats.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define CIRCUITSTATS_PRIVATE
@@ -404,7 +404,7 @@ circuit_build_times_new_consensus_params(circuit_build_times_t *cbt,
* distress anyway, so memory correctness here is paramount over
* doing acrobatics to preserve the array.
*/
- recent_circs = tor_malloc_zero(sizeof(int8_t)*num);
+ recent_circs = tor_calloc(num, sizeof(int8_t));
if (cbt->liveness.timeouts_after_firsthop &&
cbt->liveness.num_recent_circs > 0) {
memcpy(recent_circs, cbt->liveness.timeouts_after_firsthop,
@@ -508,7 +508,7 @@ circuit_build_times_init(circuit_build_times_t *cbt)
cbt->liveness.num_recent_circs =
circuit_build_times_recent_circuit_count(NULL);
cbt->liveness.timeouts_after_firsthop =
- tor_malloc_zero(sizeof(int8_t)*cbt->liveness.num_recent_circs);
+ tor_calloc(cbt->liveness.num_recent_circs, sizeof(int8_t));
} else {
cbt->liveness.num_recent_circs = 0;
cbt->liveness.timeouts_after_firsthop = NULL;
@@ -649,7 +649,7 @@ circuit_build_times_create_histogram(const circuit_build_times_t *cbt,
int i, c;
*nbins = 1 + (max_build_time / CBT_BIN_WIDTH);
- histogram = tor_malloc_zero(*nbins * sizeof(build_time_t));
+ histogram = tor_calloc(*nbins, sizeof(build_time_t));
// calculate histogram
for (i = 0; i < CBT_NCIRCUITS_TO_OBSERVE; i++) {
@@ -691,7 +691,7 @@ circuit_build_times_get_xm(circuit_build_times_t *cbt)
if (cbt->total_build_times < CBT_NCIRCUITS_TO_OBSERVE)
num_modes = 1;
- nth_max_bin = (build_time_t*)tor_malloc_zero(num_modes*sizeof(build_time_t));
+ nth_max_bin = tor_calloc(num_modes, sizeof(build_time_t));
/* Determine the N most common build times */
for (i = 0; i < nbins; i++) {
@@ -873,7 +873,7 @@ circuit_build_times_parse_state(circuit_build_times_t *cbt,
}
/* build_time_t 0 means uninitialized */
- loaded_times = tor_malloc_zero(sizeof(build_time_t)*state->TotalBuildTimes);
+ loaded_times = tor_calloc(state->TotalBuildTimes, sizeof(build_time_t));
for (line = state->BuildtimeHistogram; line; line = line->next) {
smartlist_t *args = smartlist_new();
@@ -1085,7 +1085,21 @@ circuit_build_times_calculate_timeout(circuit_build_times_t *cbt,
tor_assert(1.0-quantile > 0);
tor_assert(cbt->Xm > 0);
- ret = cbt->Xm/pow(1.0-quantile,1.0/cbt->alpha);
+ /* If either alpha or p are 0, we would divide by zero, yielding an
+ * infinite (double) result; which would be clamped to INT32_MAX.
+ * Instead, initialise ret to INT32_MAX, and skip over these
+ * potentially illegal/trapping divides by zero.
+ */
+ ret = INT32_MAX;
+
+ if (cbt->alpha > 0) {
+ double p;
+ p = pow(1.0-quantile,1.0/cbt->alpha);
+ if (p > 0) {
+ ret = cbt->Xm/p;
+ }
+ }
+
if (ret > INT32_MAX) {
ret = INT32_MAX;
}
@@ -1371,10 +1385,11 @@ circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
}
cbt->liveness.after_firsthop_idx = 0;
+#define MAX_TIMEOUT ((int32_t) (INT32_MAX/2))
/* Check to see if this has happened before. If so, double the timeout
* to give people on abysmally bad network connections a shot at access */
if (cbt->timeout_ms >= circuit_build_times_get_initial_timeout()) {
- if (cbt->timeout_ms > INT32_MAX/2 || cbt->close_ms > INT32_MAX/2) {
+ if (cbt->timeout_ms > MAX_TIMEOUT || cbt->close_ms > MAX_TIMEOUT) {
log_warn(LD_CIRC, "Insanely large circuit build timeout value. "
"(timeout = %fmsec, close = %fmsec)",
cbt->timeout_ms, cbt->close_ms);
@@ -1386,6 +1401,7 @@ circuit_build_times_network_check_changed(circuit_build_times_t *cbt)
cbt->close_ms = cbt->timeout_ms
= circuit_build_times_get_initial_timeout();
}
+#undef MAX_TIMEOUT
cbt_control_event_buildtimeout_set(cbt, BUILDTIMEOUT_SET_EVENT_RESET);
diff --git a/src/or/circuitstats.h b/src/or/circuitstats.h
index 3343310b8e..7cef4f7fb1 100644
--- a/src/or/circuitstats.h
+++ b/src/or/circuitstats.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/circuituse.c b/src/or/circuituse.c
index 714754a672..441a8fcbb5 100644
--- a/src/or/circuituse.c
+++ b/src/or/circuituse.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -268,7 +268,6 @@ circuit_get_best(const entry_connection_t *conn,
int must_be_open, uint8_t purpose,
int need_uptime, int need_internal)
{
- circuit_t *circ;
origin_circuit_t *best=NULL;
struct timeval now;
int intro_going_on_but_too_old = 0;
@@ -281,7 +280,7 @@ circuit_get_best(const entry_connection_t *conn,
tor_gettimeofday(&now);
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
origin_circuit_t *origin_circ;
if (!CIRCUIT_IS_ORIGIN(circ))
continue;
@@ -305,6 +304,7 @@ circuit_get_best(const entry_connection_t *conn,
if (!best || circuit_is_better(origin_circ,best,conn))
best = origin_circ;
}
+ SMARTLIST_FOREACH_END(circ);
if (!best && intro_going_on_but_too_old)
log_info(LD_REND|LD_CIRC, "There is an intro circuit being created "
@@ -318,11 +318,9 @@ circuit_get_best(const entry_connection_t *conn,
static int
count_pending_general_client_circuits(void)
{
- const circuit_t *circ;
-
int count = 0;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (circ->marked_for_close ||
circ->state == CIRCUIT_STATE_OPEN ||
circ->purpose != CIRCUIT_PURPOSE_C_GENERAL ||
@@ -331,6 +329,7 @@ count_pending_general_client_circuits(void)
++count;
}
+ SMARTLIST_FOREACH_END(circ);
return count;
}
@@ -370,7 +369,6 @@ circuit_conforms_to_options(const origin_circuit_t *circ,
void
circuit_expire_building(void)
{
- circuit_t *victim, *next_circ;
/* circ_times.timeout_ms and circ_times.close_ms are from
* circuit_build_times_get_initial_timeout() if we haven't computed
* custom timeouts yet */
@@ -388,7 +386,7 @@ circuit_expire_building(void)
* we want to be more lenient with timeouts, in case the
* user has relocated and/or changed network connections.
* See bug #3443. */
- TOR_LIST_FOREACH(next_circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, next_circ) {
if (!CIRCUIT_IS_ORIGIN(next_circ) || /* didn't originate here */
next_circ->marked_for_close) { /* don't mess with marked circs */
continue;
@@ -402,7 +400,7 @@ circuit_expire_building(void)
any_opened_circs = 1;
break;
}
- }
+ } SMARTLIST_FOREACH_END(next_circ);
#define SET_CUTOFF(target, msec) do { \
long ms = tor_lround(msec); \
@@ -473,9 +471,8 @@ circuit_expire_building(void)
MAX(get_circuit_build_close_time_ms()*2 + 1000,
options->SocksTimeout * 1000));
- TOR_LIST_FOREACH(next_circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *,victim) {
struct timeval cutoff;
- victim = next_circ;
if (!CIRCUIT_IS_ORIGIN(victim) || /* didn't originate here */
victim->marked_for_close) /* don't mess with marked circs */
continue;
@@ -780,7 +777,7 @@ circuit_expire_building(void)
circuit_mark_for_close(victim, END_CIRC_REASON_TIMEOUT);
pathbias_count_timeout(TO_ORIGIN_CIRCUIT(victim));
- }
+ } SMARTLIST_FOREACH_END(victim);
}
/** For debugging #8387: track when we last called
@@ -800,9 +797,8 @@ circuit_log_ancient_one_hop_circuits(int age)
time_t cutoff = now - age;
int n_found = 0;
smartlist_t *log_these = smartlist_new();
- const circuit_t *circ;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
const origin_circuit_t *ocirc;
if (! CIRCUIT_IS_ORIGIN(circ))
continue;
@@ -817,6 +813,7 @@ circuit_log_ancient_one_hop_circuits(int age)
smartlist_add(log_these, (origin_circuit_t*) ocirc);
}
}
+ SMARTLIST_FOREACH_END(circ);
if (n_found == 0)
goto done;
@@ -831,7 +828,7 @@ circuit_log_ancient_one_hop_circuits(int age)
int stream_num;
const edge_connection_t *conn;
char *dirty = NULL;
- circ = TO_CIRCUIT(ocirc);
+ const circuit_t *circ = TO_CIRCUIT(ocirc);
format_local_iso_time(created,
(time_t)circ->timestamp_created.tv_sec);
@@ -938,7 +935,6 @@ int
circuit_stream_is_being_handled(entry_connection_t *conn,
uint16_t port, int min)
{
- circuit_t *circ;
const node_t *exitnode;
int num=0;
time_t now = time(NULL);
@@ -946,7 +942,7 @@ circuit_stream_is_being_handled(entry_connection_t *conn,
get_options()->LongLivedPorts,
conn ? conn->socks_request->port : port);
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (CIRCUIT_IS_ORIGIN(circ) &&
!circ->marked_for_close &&
circ->purpose == CIRCUIT_PURPOSE_C_GENERAL &&
@@ -976,6 +972,7 @@ circuit_stream_is_being_handled(entry_connection_t *conn,
}
}
}
+ SMARTLIST_FOREACH_END(circ);
return 0;
}
@@ -989,7 +986,6 @@ circuit_stream_is_being_handled(entry_connection_t *conn,
static void
circuit_predict_and_launch_new(void)
{
- circuit_t *circ;
int num=0, num_internal=0, num_uptime_internal=0;
int hidserv_needs_uptime=0, hidserv_needs_capacity=1;
int port_needs_uptime=0, port_needs_capacity=1;
@@ -997,7 +993,7 @@ circuit_predict_and_launch_new(void)
int flags = 0;
/* First, count how many of each type of circuit we have already. */
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
cpath_build_state_t *build_state;
origin_circuit_t *origin_circ;
if (!CIRCUIT_IS_ORIGIN(circ))
@@ -1020,6 +1016,7 @@ circuit_predict_and_launch_new(void)
if (build_state->need_uptime && build_state->is_internal)
num_uptime_internal++;
}
+ SMARTLIST_FOREACH_END(circ);
/* If that's enough, then stop now. */
if (num >= MAX_UNUSED_OPEN_CIRCUITS)
@@ -1223,7 +1220,6 @@ circuit_detach_stream(circuit_t *circ, edge_connection_t *conn)
static void
circuit_expire_old_circuits_clientside(void)
{
- circuit_t *circ;
struct timeval cutoff, now;
tor_gettimeofday(&now);
@@ -1239,7 +1235,7 @@ circuit_expire_old_circuits_clientside(void)
cutoff.tv_sec -= get_options()->CircuitIdleTimeout;
}
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (circ->marked_for_close || !CIRCUIT_IS_ORIGIN(circ))
continue;
/* If the circuit has been dirty for too long, and there are no streams
@@ -1291,7 +1287,7 @@ circuit_expire_old_circuits_clientside(void)
}
}
}
- }
+ } SMARTLIST_FOREACH_END(circ);
}
/** How long do we wait before killing circuits with the properties
@@ -1318,11 +1314,10 @@ circuit_expire_old_circuits_clientside(void)
void
circuit_expire_old_circuits_serverside(time_t now)
{
- circuit_t *circ;
or_circuit_t *or_circ;
time_t cutoff = now - IDLE_ONE_HOP_CIRC_TIMEOUT;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (circ->marked_for_close || CIRCUIT_IS_ORIGIN(circ))
continue;
or_circ = TO_OR_CIRCUIT(circ);
@@ -1339,6 +1334,7 @@ circuit_expire_old_circuits_serverside(time_t now)
circuit_mark_for_close(circ, END_CIRC_REASON_FINISHED);
}
}
+ SMARTLIST_FOREACH_END(circ);
}
/** Number of testing circuits we want open before testing our bandwidth. */
@@ -1363,18 +1359,18 @@ reset_bandwidth_test(void)
int
circuit_enough_testing_circs(void)
{
- circuit_t *circ;
int num = 0;
if (have_performed_bandwidth_test)
return 1;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!circ->marked_for_close && CIRCUIT_IS_ORIGIN(circ) &&
circ->purpose == CIRCUIT_PURPOSE_TESTING &&
circ->state == CIRCUIT_STATE_OPEN)
num++;
}
+ SMARTLIST_FOREACH_END(circ);
return num >= NUM_PARALLEL_TESTING_CIRCS;
}
@@ -2074,7 +2070,7 @@ static void
link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
crypt_path_t *cpath)
{
- const node_t *exitnode;
+ const node_t *exitnode = NULL;
/* add it into the linked list of streams on this circuit */
log_debug(LD_APP|LD_CIRC, "attaching new conn to circ. n_circ_id %u.",
@@ -2108,23 +2104,25 @@ link_apconn_to_circ(entry_connection_t *apconn, origin_circuit_t *circ,
circ->isolation_any_streams_attached = 1;
connection_edge_update_circuit_isolation(apconn, circ, 0);
+ /* Compute the exitnode if possible, for logging below */
+ if (cpath->extend_info)
+ exitnode = node_get_by_id(cpath->extend_info->identity_digest);
+
/* See if we can use optimistic data on this circuit */
- if (cpath->extend_info &&
- (exitnode = node_get_by_id(cpath->extend_info->identity_digest)) &&
- exitnode->rs) {
- /* Okay; we know what exit node this is. */
- if (optimistic_data_enabled() &&
- circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL &&
- exitnode->rs->version_supports_optimistic_data)
- apconn->may_use_optimistic_data = 1;
- else
- apconn->may_use_optimistic_data = 0;
- log_info(LD_APP, "Looks like completed circuit to %s %s allow "
- "optimistic data for connection to %s",
- safe_str_client(node_describe(exitnode)),
- apconn->may_use_optimistic_data ? "does" : "doesn't",
- safe_str_client(apconn->socks_request->address));
- }
+ if (optimistic_data_enabled() &&
+ (circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL ||
+ circ->base_.purpose == CIRCUIT_PURPOSE_C_REND_JOINED))
+ apconn->may_use_optimistic_data = 1;
+ else
+ apconn->may_use_optimistic_data = 0;
+ log_info(LD_APP, "Looks like completed circuit to %s %s allow "
+ "optimistic data for connection to %s",
+ circ->base_.purpose == CIRCUIT_PURPOSE_C_GENERAL ?
+ /* node_describe() does the right thing if exitnode is NULL */
+ safe_str_client(node_describe(exitnode)) :
+ "hidden service",
+ apconn->may_use_optimistic_data ? "does" : "doesn't",
+ safe_str_client(apconn->socks_request->address));
}
/** Return true iff <b>address</b> is matched by one of the entries in
diff --git a/src/or/circuituse.h b/src/or/circuituse.h
index 4c5977bee0..ce044d30dc 100644
--- a/src/or/circuituse.h
+++ b/src/or/circuituse.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/command.c b/src/or/command.c
index fa2a0e74e7..268c495371 100644
--- a/src/or/command.c
+++ b/src/or/command.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -474,10 +474,22 @@ command_process_relay_cell(cell_t *cell, channel_t *chan)
* gotten no more than MAX_RELAY_EARLY_CELLS_PER_CIRCUIT of them. */
if (cell->command == CELL_RELAY_EARLY) {
if (direction == CELL_DIRECTION_IN) {
- /* Allow an unlimited number of inbound relay_early cells,
- * for hidden service compatibility. There isn't any way to make
- * a long circuit through inbound relay_early cells anyway. See
- * bug 1038. -RD */
+ /* Inbound early cells could once be encountered as a result of
+ * bug 1038; but relays running versions before 0.2.1.19 are long
+ * gone from the network, so any such cells now are surprising. */
+ log_warn(LD_OR,
+ "Received an inbound RELAY_EARLY cell on circuit %u."
+ " Closing circuit. Please report this event,"
+ " along with the following message.",
+ (unsigned)cell->circ_id);
+ if (CIRCUIT_IS_ORIGIN(circ)) {
+ circuit_log_path(LOG_WARN, LD_OR, TO_ORIGIN_CIRCUIT(circ));
+ } else if (circ->n_chan) {
+ log_warn(LD_OR, " upstream=%s",
+ channel_get_actual_remote_descr(circ->n_chan));
+ }
+ circuit_mark_for_close(circ, END_CIRC_REASON_TORPROTOCOL);
+ return;
} else {
or_circuit_t *or_circ = TO_OR_CIRCUIT(circ);
if (or_circ->remaining_relay_early_cells == 0) {
diff --git a/src/or/command.h b/src/or/command.h
index adea6adeaa..509b4a0e9f 100644
--- a/src/or/command.h
+++ b/src/or/command.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/config.c b/src/or/config.c
index 10b118c9ab..cb27dac3c0 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -99,8 +99,6 @@ static config_abbrev_t option_abbrevs_[] = {
{ "PreferTunnelledDirConns", "PreferTunneledDirConns", 0, 0},
{ "BridgeAuthoritativeDirectory", "BridgeAuthoritativeDir", 0, 0},
{ "HashedControlPassword", "__HashedControlSessionPassword", 1, 0},
- { "StrictEntryNodes", "StrictNodes", 0, 1},
- { "StrictExitNodes", "StrictNodes", 0, 1},
{ "VirtualAddrNetwork", "VirtualAddrNetworkIPv4", 0, 0},
{ "_UseFilteringSSLBufferevents", "UseFilteringSSLBufferevents", 0, 1},
{ NULL, NULL, 0, 0},
@@ -127,8 +125,8 @@ static config_abbrev_t option_abbrevs_[] = {
* be chosen first.
*/
static config_var_t option_vars_[] = {
- OBSOLETE("AccountingMaxKB"),
V(AccountingMax, MEMUNIT, "0 bytes"),
+ VAR("AccountingRule", STRING, AccountingRule_option, "max"),
V(AccountingStart, STRING, NULL),
V(Address, STRING, NULL),
V(AllowDotExit, BOOL, "0"),
@@ -140,18 +138,18 @@ static config_var_t option_vars_[] = {
V(AlternateDirAuthority, LINELIST, NULL),
OBSOLETE("AlternateHSAuthority"),
V(AssumeReachable, BOOL, "0"),
- V(AuthDirBadDir, LINELIST, NULL),
- V(AuthDirBadDirCCs, CSV, ""),
+ OBSOLETE("AuthDirBadDir"),
+ OBSOLETE("AuthDirBadDirCCs"),
V(AuthDirBadExit, LINELIST, NULL),
V(AuthDirBadExitCCs, CSV, ""),
V(AuthDirInvalid, LINELIST, NULL),
V(AuthDirInvalidCCs, CSV, ""),
V(AuthDirFastGuarantee, MEMUNIT, "100 KB"),
- V(AuthDirGuardBWGuarantee, MEMUNIT, "250 KB"),
+ V(AuthDirGuardBWGuarantee, MEMUNIT, "2 MB"),
V(AuthDirReject, LINELIST, NULL),
V(AuthDirRejectCCs, CSV, ""),
- V(AuthDirRejectUnlisted, BOOL, "0"),
- V(AuthDirListBadDirs, BOOL, "0"),
+ OBSOLETE("AuthDirRejectUnlisted"),
+ OBSOLETE("AuthDirListBadDirs"),
V(AuthDirListBadExits, BOOL, "0"),
V(AuthDirMaxServersPerAddr, UINT, "2"),
V(AuthDirMaxServersPerAuthAddr,UINT, "5"),
@@ -196,21 +194,14 @@ static config_var_t option_vars_[] = {
V(CookieAuthFile, STRING, NULL),
V(CountPrivateBandwidth, BOOL, "0"),
V(DataDirectory, FILENAME, NULL),
- OBSOLETE("DebugLogFile"),
V(DisableNetwork, BOOL, "0"),
V(DirAllowPrivateAddresses, BOOL, "0"),
V(TestingAuthDirTimeToLearnReachability, INTERVAL, "30 minutes"),
V(DirListenAddress, LINELIST, NULL),
- OBSOLETE("DirFetchPeriod"),
V(DirPolicy, LINELIST, NULL),
VPORT(DirPort, LINELIST, NULL),
V(DirPortFrontPage, FILENAME, NULL),
- OBSOLETE("DirPostPeriod"),
- OBSOLETE("DirRecordUsageByCountry"),
- OBSOLETE("DirRecordUsageGranularity"),
- OBSOLETE("DirRecordUsageRetainIPs"),
- OBSOLETE("DirRecordUsageSaveInterval"),
- V(DirReqStatistics, BOOL, "1"),
+ VAR("DirReqStatistics", BOOL, DirReqStatistics_option, "1"),
VAR("DirAuthority", LINELIST, DirAuthorities, NULL),
V(DirAuthorityFallbackRate, DOUBLE, "1.0"),
V(DisableAllSwap, BOOL, "0"),
@@ -238,6 +229,7 @@ static config_var_t option_vars_[] = {
V(ExtendAllowPrivateAddresses, BOOL, "0"),
VPORT(ExtORPort, LINELIST, NULL),
V(ExtORPortCookieAuthFile, STRING, NULL),
+ V(ExtORPortCookieAuthFileGroupReadable, BOOL, "0"),
V(ExtraInfoStatistics, BOOL, "1"),
V(FallbackDir, LINELIST, NULL),
@@ -261,7 +253,6 @@ static config_var_t option_vars_[] = {
V(GeoIPv6File, FILENAME,
SHARE_DATADIR PATH_SEPARATOR "tor" PATH_SEPARATOR "geoip6"),
#endif
- OBSOLETE("GiveGuardFlagTo_CVE_2011_2768_VulnerableRelays"),
OBSOLETE("Group"),
V(GuardLifetime, INTERVAL, "0 minutes"),
V(HardwareAccel, BOOL, "0"),
@@ -271,15 +262,11 @@ static config_var_t option_vars_[] = {
V(HashedControlPassword, LINELIST, NULL),
V(HidServDirectoryV2, BOOL, "1"),
VAR("HiddenServiceDir", LINELIST_S, RendConfigLines, NULL),
- OBSOLETE("HiddenServiceExcludeNodes"),
- OBSOLETE("HiddenServiceNodes"),
VAR("HiddenServiceOptions",LINELIST_V, RendConfigLines, NULL),
VAR("HiddenServicePort", LINELIST_S, RendConfigLines, NULL),
VAR("HiddenServiceVersion",LINELIST_S, RendConfigLines, NULL),
VAR("HiddenServiceAuthorizeClient",LINELIST_S,RendConfigLines, NULL),
V(HidServAuth, LINELIST, NULL),
- OBSOLETE("HSAuthoritativeDir"),
- OBSOLETE("HSAuthorityRecordStats"),
V(CloseHSClientCircuitsImmediatelyOnTimeout, BOOL, "0"),
V(CloseHSServiceRendCircuitsImmediatelyOnTimeout, BOOL, "0"),
V(HTTPProxy, STRING, NULL),
@@ -294,13 +281,9 @@ static config_var_t option_vars_[] = {
V(Socks5Proxy, STRING, NULL),
V(Socks5ProxyUsername, STRING, NULL),
V(Socks5ProxyPassword, STRING, NULL),
- OBSOLETE("IgnoreVersion"),
V(KeepalivePeriod, INTERVAL, "5 minutes"),
VAR("Log", LINELIST, Logs, NULL),
V(LogMessageDomains, BOOL, "0"),
- OBSOLETE("LinkPadding"),
- OBSOLETE("LogLevel"),
- OBSOLETE("LogFile"),
V(LogTimeGranularity, MSEC_INTERVAL, "1 second"),
V(TruncateLogFile, BOOL, "0"),
V(LongLivedPorts, CSV,
@@ -313,20 +296,18 @@ static config_var_t option_vars_[] = {
OBSOLETE("MaxOnionsPending"),
V(MaxOnionQueueDelay, MSEC_INTERVAL, "1750 msec"),
V(MinMeasuredBWsForAuthToIgnoreAdvertised, INT, "500"),
- OBSOLETE("MonthlyAccountingStart"),
V(MyFamily, STRING, NULL),
V(NewCircuitPeriod, INTERVAL, "30 seconds"),
- VAR("NamingAuthoritativeDirectory",BOOL, NamingAuthoritativeDir, "0"),
+ OBSOLETE("NamingAuthoritativeDirectory"),
V(NATDListenAddress, LINELIST, NULL),
VPORT(NATDPort, LINELIST, NULL),
V(Nickname, STRING, NULL),
V(PredictedPortsRelevanceTime, INTERVAL, "1 hour"),
V(WarnUnsafeSocks, BOOL, "1"),
- OBSOLETE("NoPublish"),
VAR("NodeFamily", LINELIST, NodeFamilies, NULL),
V(NumCPUs, UINT, "0"),
V(NumDirectoryGuards, UINT, "0"),
- V(NumEntryGuards, UINT, "3"),
+ V(NumEntryGuards, UINT, "0"),
V(ORListenAddress, LINELIST, NULL),
VPORT(ORPort, LINELIST, NULL),
V(OutboundBindAddress, LINELIST, NULL),
@@ -348,7 +329,6 @@ static config_var_t option_vars_[] = {
V(PathBiasScaleUseThreshold, INT, "-1"),
V(PathsNeededToBuildCircuits, DOUBLE, "-1"),
- OBSOLETE("PathlenCoinWeight"),
V(PerConnBWBurst, MEMUNIT, "0"),
V(PerConnBWRate, MEMUNIT, "0"),
V(PidFile, STRING, NULL),
@@ -368,18 +348,13 @@ static config_var_t option_vars_[] = {
V(RecommendedVersions, LINELIST, NULL),
V(RecommendedClientVersions, LINELIST, NULL),
V(RecommendedServerVersions, LINELIST, NULL),
- OBSOLETE("RedirectExit"),
V(RefuseUnknownExits, AUTOBOOL, "auto"),
V(RejectPlaintextPorts, CSV, ""),
V(RelayBandwidthBurst, MEMUNIT, "0"),
V(RelayBandwidthRate, MEMUNIT, "0"),
- OBSOLETE("RendExcludeNodes"),
- OBSOLETE("RendNodes"),
V(RendPostPeriod, INTERVAL, "1 hour"),
V(RephistTrackTime, INTERVAL, "24 hours"),
- OBSOLETE("RouterFile"),
V(RunAsDaemon, BOOL, "0"),
-// V(RunTesting, BOOL, "0"),
OBSOLETE("RunTesting"), // currently unused
V(Sandbox, BOOL, "0"),
V(SafeLogging, STRING, "1"),
@@ -398,18 +373,16 @@ static config_var_t option_vars_[] = {
VPORT(SocksPort, LINELIST, NULL),
V(SocksTimeout, INTERVAL, "2 minutes"),
V(SSLKeyLifetime, INTERVAL, "0"),
- OBSOLETE("StatusFetchPeriod"),
+ OBSOLETE("StrictEntryNodes"),
+ OBSOLETE("StrictExitNodes"),
V(StrictNodes, BOOL, "0"),
V(Support022HiddenServices, AUTOBOOL, "auto"),
- OBSOLETE("SysLog"),
V(TestSocks, BOOL, "0"),
- OBSOLETE("TestVia"),
V(TokenBucketRefillInterval, MSEC_INTERVAL, "100 msec"),
V(Tor2webMode, BOOL, "0"),
V(TLSECGroup, STRING, NULL),
V(TrackHostExits, CSV, NULL),
V(TrackHostExitsExpire, INTERVAL, "30 minutes"),
- OBSOLETE("TrafficShaping"),
V(TransListenAddress, LINELIST, NULL),
VPORT(TransPort, LINELIST, NULL),
V(TransProxyType, STRING, "default"),
@@ -466,6 +439,7 @@ static config_var_t option_vars_[] = {
V(TestingDescriptorMaxDownloadTries, UINT, "8"),
V(TestingMicrodescMaxDownloadTries, UINT, "8"),
V(TestingCertMaxDownloadTries, UINT, "8"),
+ V(TestingDirAuthVoteExit, ROUTERSET, NULL),
V(TestingDirAuthVoteGuard, ROUTERSET, NULL),
VAR("___UsingTestNetworkDefaults", BOOL, UsingTestNetworkDefaults_, "0"),
@@ -838,7 +812,9 @@ escaped_safe_str(const char *address)
}
/** Add the default directory authorities directly into the trusted dir list,
- * but only add them insofar as they share bits with <b>type</b>. */
+ * but only add them insofar as they share bits with <b>type</b>.
+ * Each authority's bits are restricted to the bits shared with <b>type</b>.
+ * If <b>type</b> is ALL_DIRINFO or NO_DIRINFO (zero), add all authorities. */
static void
add_default_trusted_dir_authorities(dirinfo_type_t type)
{
@@ -858,7 +834,7 @@ add_default_trusted_dir_authorities(dirinfo_type_t type)
"76.73.17.194:9030 F397 038A DC51 3361 35E7 B80B D99C A384 4360 292B",
"gabelmoo orport=443 "
"v3ident=ED03BB616EB2F60BEC80151114BB25CEF515B226 "
- "212.112.245.170:80 F204 4413 DAC2 E02E 3D6B CF47 35A1 9BCA 1DE9 7281",
+ "131.188.40.189:80 F204 4413 DAC2 E02E 3D6B CF47 35A1 9BCA 1DE9 7281",
"dannenberg orport=443 "
"v3ident=585769C78764D58426B8B52B6651A5A71137189A "
"193.23.244.244:80 7BE6 83E6 5D48 1413 21C5 ED92 F075 C553 64AC 7123",
@@ -980,7 +956,10 @@ consider_adding_dir_servers(const or_options_t *options,
type |= BRIDGE_DIRINFO;
if (!options->AlternateDirAuthority)
type |= V3_DIRINFO | EXTRAINFO_DIRINFO | MICRODESC_DIRINFO;
- add_default_trusted_dir_authorities(type);
+ /* if type == NO_DIRINFO, we don't want to add any of the
+ * default authorities, because we've replaced them all */
+ if (type != NO_DIRINFO)
+ add_default_trusted_dir_authorities(type);
}
if (!options->FallbackDir)
add_default_fallback_dir_servers();
@@ -1016,7 +995,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
int running_tor = options->command == CMD_RUN_TOR;
int set_conn_limit = 0;
int r = -1;
- int logs_marked = 0;
+ int logs_marked = 0, logs_initialized = 0;
int old_min_log_level = get_min_log_level();
/* Daemonize _first_, since we only want to open most of this stuff in
@@ -1146,6 +1125,7 @@ options_act_reversible(const or_options_t *old_options, char **msg)
*msg = tor_strdup("Failed to init Log options. See logs for details.");
goto rollback;
}
+ logs_initialized = 1;
commit:
r = 0;
@@ -1158,6 +1138,9 @@ options_act_reversible(const or_options_t *old_options, char **msg)
tor_free(severity);
tor_log_update_sigsafe_err_fds();
}
+ if (logs_initialized) {
+ flush_log_messages_from_startup();
+ }
{
const char *badness = NULL;
@@ -1421,24 +1404,26 @@ options_act(const or_options_t *old_options)
mark_transport_list();
pt_prepare_proxy_list_for_config_read();
- if (options->ClientTransportPlugin) {
- for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
- if (parse_transport_line(options, cl->value, 0, 0) < 0) {
- log_warn(LD_BUG,
- "Previously validated ClientTransportPlugin line "
- "could not be added!");
- return -1;
+ if (!options->DisableNetwork) {
+ if (options->ClientTransportPlugin) {
+ for (cl = options->ClientTransportPlugin; cl; cl = cl->next) {
+ if (parse_transport_line(options, cl->value, 0, 0) < 0) {
+ log_warn(LD_BUG,
+ "Previously validated ClientTransportPlugin line "
+ "could not be added!");
+ return -1;
+ }
}
}
- }
- if (options->ServerTransportPlugin && server_mode(options)) {
- for (cl = options->ServerTransportPlugin; cl; cl = cl->next) {
- if (parse_transport_line(options, cl->value, 0, 1) < 0) {
- log_warn(LD_BUG,
- "Previously validated ServerTransportPlugin line "
- "could not be added!");
- return -1;
+ if (options->ServerTransportPlugin && server_mode(options)) {
+ for (cl = options->ServerTransportPlugin; cl; cl = cl->next) {
+ if (parse_transport_line(options, cl->value, 0, 1) < 0) {
+ log_warn(LD_BUG,
+ "Previously validated ServerTransportPlugin line "
+ "could not be added!");
+ return -1;
+ }
}
}
}
@@ -1698,6 +1683,10 @@ options_act(const or_options_t *old_options)
connection_or_update_token_buckets(get_connection_array(), options);
}
+ /* Only collect directory-request statistics on relays and bridges. */
+ options->DirReqStatistics = options->DirReqStatistics_option &&
+ server_mode(options);
+
if (options->CellStatistics || options->DirReqStatistics ||
options->EntryStatistics || options->ExitPortStatistics ||
options->ConnDirectionStatistics ||
@@ -1705,11 +1694,6 @@ options_act(const or_options_t *old_options)
time_t now = time(NULL);
int print_notice = 0;
- /* Only collect directory-request statistics on relays and bridges. */
- if (!server_mode(options)) {
- options->DirReqStatistics = 0;
- }
-
/* Only collect other relay-only statistics on relays. */
if (!public_server_mode(options)) {
options->CellStatistics = 0;
@@ -1728,8 +1712,8 @@ options_act(const or_options_t *old_options)
geoip_dirreq_stats_init(now);
print_notice = 1;
} else {
+ /* disable statistics collection since we have no geoip file */
options->DirReqStatistics = 0;
- /* Don't warn Tor clients, they don't use statistics */
if (options->ORPort_set)
log_notice(LD_CONFIG, "Configured to measure directory request "
"statistics, but no GeoIP database found. "
@@ -1928,7 +1912,8 @@ config_parse_commandline(int argc, char **argv, int ignore_errors,
}
param = tor_malloc_zero(sizeof(config_line_t));
- param->key = is_cmdline ? tor_strdup(argv[i]) : tor_strdup(s);
+ param->key = is_cmdline ? tor_strdup(argv[i]) :
+ tor_strdup(config_expand_abbrev(&options_format, s, 1, 1));
param->value = arg;
param->command = command;
param->next = NULL;
@@ -2024,7 +2009,7 @@ print_usage(void)
printf(
"Copyright (c) 2001-2004, Roger Dingledine\n"
"Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson\n"
-"Copyright (c) 2007-2013, The Tor Project, Inc.\n\n"
+"Copyright (c) 2007-2014, The Tor Project, Inc.\n\n"
"tor -f <torrc> [args]\n"
"See man page for options, or https://www.torproject.org/ for "
"documentation.\n");
@@ -2056,6 +2041,13 @@ get_last_resolved_addr(void)
return last_resolved_addr;
}
+/** Reset last_resolved_addr from outside this file. */
+void
+reset_last_resolved_addr(void)
+{
+ last_resolved_addr = 0;
+}
+
/**
* Use <b>options-\>Address</b> to guess our public IP address.
*
@@ -2560,6 +2552,13 @@ options_validate(or_options_t *old_options, or_options_t *options,
REJECT("Can't use a relative path to torrc when RunAsDaemon is set.");
#endif
+ if (server_mode(options) && options->RendConfigLines)
+ log_warn(LD_CONFIG,
+ "Tor is currently configured as a relay and a hidden service. "
+ "That's not very secure: you should probably run your hidden service "
+ "in a separate Tor process, at least -- see "
+ "https://trac.torproject.org/8742");
+
/* XXXX require that the only port not be DirPort? */
/* XXXX require that at least one port be listened-upon. */
if (n_ports == 0 && !options->RendConfigLines)
@@ -3124,6 +3123,16 @@ options_validate(or_options_t *old_options, or_options_t *options,
}
}
+ options->AccountingRule = ACCT_MAX;
+ if (options->AccountingRule_option) {
+ if (!strcmp(options->AccountingRule_option, "sum"))
+ options->AccountingRule = ACCT_SUM;
+ else if (!strcmp(options->AccountingRule_option, "max"))
+ options->AccountingRule = ACCT_MAX;
+ else
+ REJECT("AccountingRule must be 'sum' or 'max'");
+ }
+
if (options->HTTPProxy) { /* parse it now */
if (tor_addr_port_lookup(options->HTTPProxy,
&options->HTTPProxyAddr, &options->HTTPProxyPort) < 0)
@@ -3172,11 +3181,11 @@ options_validate(or_options_t *old_options, or_options_t *options,
}
}
- /* Check if more than one proxy type has been enabled. */
+ /* Check if more than one exclusive proxy type has been enabled. */
if (!!options->Socks4Proxy + !!options->Socks5Proxy +
- !!options->HTTPSProxy + !!options->ClientTransportPlugin > 1)
+ !!options->HTTPSProxy > 1)
REJECT("You have configured more than one proxy type. "
- "(Socks4Proxy|Socks5Proxy|HTTPSProxy|ClientTransportPlugin)");
+ "(Socks4Proxy|Socks5Proxy|HTTPSProxy)");
/* Check if the proxies will give surprising behavior. */
if (options->HTTPProxy && !(options->Socks4Proxy ||
@@ -3249,9 +3258,6 @@ options_validate(or_options_t *old_options, or_options_t *options,
"have it group-readable.");
}
- if (options->UseEntryGuards && ! options->NumEntryGuards)
- REJECT("Cannot enable UseEntryGuards with NumEntryGuards set to 0");
-
if (options->MyFamily && options->BridgeRelay) {
log_warn(LD_CONFIG, "Listing a family for a bridge relay is not "
"supported: it can reveal bridge fingerprints to censors. "
@@ -4850,10 +4856,10 @@ parse_transport_line(const or_options_t *options,
/* managed */
if (!server && !validate_only && is_useless_proxy) {
- log_notice(LD_GENERAL,
- "Pluggable transport proxy (%s) does not provide "
- "any needed transports and will not be launched.",
- line);
+ log_info(LD_GENERAL,
+ "Pluggable transport proxy (%s) does not provide "
+ "any needed transports and will not be launched.",
+ line);
}
/*
@@ -4865,7 +4871,7 @@ parse_transport_line(const or_options_t *options,
if (!validate_only && (server || !is_useless_proxy)) {
proxy_argc = line_length - 2;
tor_assert(proxy_argc > 0);
- proxy_argv = tor_malloc_zero(sizeof(char *) * (proxy_argc + 1));
+ proxy_argv = tor_calloc((proxy_argc + 1), sizeof(char *));
tmp = proxy_argv;
for (i = 0; i < proxy_argc; i++) {
@@ -4885,6 +4891,14 @@ parse_transport_line(const or_options_t *options,
} else {
/* external */
+ /* ClientTransportPlugins connecting through a proxy is managed only. */
+ if (!server &&
+ (options->Socks4Proxy || options->Socks5Proxy || options->HTTPSProxy)) {
+ log_warn(LD_CONFIG, "You have configured an external proxy with another "
+ "proxy type. (Socks4Proxy|Socks5Proxy|HTTPSProxy)");
+ goto err;
+ }
+
if (smartlist_len(transport_list) != 1) {
log_warn(LD_CONFIG,
"You can't have an external proxy with more than "
@@ -5090,8 +5104,9 @@ get_options_for_server_transport(const char *transport)
/** Read the contents of a DirAuthority line from <b>line</b>. If
* <b>validate_only</b> is 0, and the line is well-formed, and it
* shares any bits with <b>required_type</b> or <b>required_type</b>
- * is 0, then add the dirserver described in the line (minus whatever
- * bits it's missing) as a valid authority. Return 0 on success,
+ * is NO_DIRINFO (zero), then add the dirserver described in the line
+ * (minus whatever bits it's missing) as a valid authority.
+ * Return 0 on success or filtering out by type,
* or -1 if the line isn't well-formed or if we can't add it. */
static int
parse_dir_authority_line(const char *line, dirinfo_type_t required_type,
@@ -6748,11 +6763,14 @@ config_maybe_load_geoip_files_(const or_options_t *options,
* in <b>cookie_out</b>.
* Then write it down to <b>fname</b> and prepend it with <b>header</b>.
*
+ * If <b>group_readable</b> is set, set <b>fname</b> to be readable
+ * by the default GID.
+ *
* If the whole procedure was successful, set
* <b>cookie_is_set_out</b> to True. */
int
init_cookie_authentication(const char *fname, const char *header,
- int cookie_len,
+ int cookie_len, int group_readable,
uint8_t **cookie_out, int *cookie_is_set_out)
{
char cookie_file_str_len = strlen(header) + cookie_len;
@@ -6785,6 +6803,16 @@ init_cookie_authentication(const char *fname, const char *header,
goto done;
}
+#ifndef _WIN32
+ if (group_readable) {
+ if (chmod(fname, 0640)) {
+ log_warn(LD_FS,"Unable to make %s group-readable.", escaped(fname));
+ }
+ }
+#else
+ (void) group_readable;
+#endif
+
/* Success! */
log_info(LD_GENERAL, "Generated auth cookie file in '%s'.", escaped(fname));
*cookie_is_set_out = 1;
diff --git a/src/or/config.h b/src/or/config.h
index 4097d37714..6cc81ab948 100644
--- a/src/or/config.h
+++ b/src/or/config.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -29,6 +29,7 @@ setopt_err_t options_trial_assign(config_line_t *list, int use_defaults,
int clear_first, char **msg);
uint32_t get_last_resolved_addr(void);
+void reset_last_resolved_addr(void);
int resolve_my_address(int warn_severity, const or_options_t *options,
uint32_t *addr_out,
const char **method_out, char **hostname_out);
@@ -97,7 +98,7 @@ uint32_t get_effective_bwburst(const or_options_t *options);
char *get_transport_bindaddr_from_config(const char *transport);
int init_cookie_authentication(const char *fname, const char *header,
- int cookie_len,
+ int cookie_len, int group_readable,
uint8_t **cookie_out, int *cookie_is_set_out);
or_options_t *options_new(void);
diff --git a/src/or/confparse.c b/src/or/confparse.c
index c5400a6512..8ee985c92a 100644
--- a/src/or/confparse.c
+++ b/src/or/confparse.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
diff --git a/src/or/confparse.h b/src/or/confparse.h
index 2cd6c49a2a..3712924ac7 100644
--- a/src/or/confparse.h
+++ b/src/or/confparse.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_CONFPARSE_H
diff --git a/src/or/connection.c b/src/or/connection.c
index 4d7cec7f9a..c9c371c001 100644
--- a/src/or/connection.c
+++ b/src/or/connection.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -894,9 +894,9 @@ create_unix_sockaddr(const char *listenaddress, char **readable_address,
}
#endif /* HAVE_SYS_UN_H */
-/** Warn that an accept or a connect has failed because we're running up
- * against our ulimit. Rate-limit these warnings so that we don't spam
- * the log. */
+/** Warn that an accept or a connect has failed because we're running out of
+ * TCP sockets we can use on current system. Rate-limit these warnings so
+ * that we don't spam the log. */
static void
warn_too_many_conns(void)
{
@@ -906,7 +906,7 @@ warn_too_many_conns(void)
if ((m = rate_limit_log(&last_warned, approx_time()))) {
int n_conns = get_n_open_sockets();
log_warn(LD_NET,"Failing because we have %d connections already. Please "
- "raise your ulimit -n.%s", n_conns, m);
+ "read doc/TUNING for guidance.%s", n_conns, m);
tor_free(m);
control_event_general_status(LOG_WARN, "TOO_MANY_CONNECTIONS CURRENT=%d",
n_conns);
@@ -1613,6 +1613,7 @@ connection_connect(connection_t *conn, const char *address,
}
}
+ tor_assert(options);
if (options->ConstrainedSockets)
set_constrained_socket_buffers(s, (int)options->ConstrainedSockSize);
@@ -1687,14 +1688,14 @@ get_proxy_type(void)
{
const or_options_t *options = get_options();
- if (options->HTTPSProxy)
+ if (options->ClientTransportPlugin)
+ return PROXY_PLUGGABLE;
+ else if (options->HTTPSProxy)
return PROXY_CONNECT;
else if (options->Socks4Proxy)
return PROXY_SOCKS4;
else if (options->Socks5Proxy)
return PROXY_SOCKS5;
- else if (options->ClientTransportPlugin)
- return PROXY_PLUGGABLE;
else
return PROXY_NONE;
}
@@ -4385,6 +4386,8 @@ client_check_address_changed(tor_socket_t sock)
SMARTLIST_FOREACH(outgoing_addrs, tor_addr_t*, a_ptr, tor_free(a_ptr));
smartlist_clear(outgoing_addrs);
smartlist_add(outgoing_addrs, tor_memdup(&out_addr, sizeof(tor_addr_t)));
+ /* We'll need to resolve ourselves again. */
+ reset_last_resolved_addr();
/* Okay, now change our keys. */
ip_address_changed(1);
}
@@ -4786,6 +4789,27 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
{
const or_options_t *options = get_options();
+ /* Client Transport Plugins can use another proxy, but that should be hidden
+ * from the rest of tor (as the plugin is responsible for dealing with the
+ * proxy), check it first, then check the rest of the proxy types to allow
+ * the config to have unused ClientTransportPlugin entries.
+ */
+ if (options->ClientTransportPlugin) {
+ const transport_t *transport = NULL;
+ int r;
+ r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
+ if (r<0)
+ return -1;
+ if (transport) { /* transport found */
+ tor_addr_copy(addr, &transport->addr);
+ *port = transport->port;
+ *proxy_type = transport->socks_version;
+ return 0;
+ }
+
+ /* Unused ClientTransportPlugin. */
+ }
+
if (options->HTTPSProxy) {
tor_addr_copy(addr, &options->HTTPSProxyAddr);
*port = options->HTTPSProxyPort;
@@ -4801,19 +4825,6 @@ get_proxy_addrport(tor_addr_t *addr, uint16_t *port, int *proxy_type,
*port = options->Socks5ProxyPort;
*proxy_type = PROXY_SOCKS5;
return 0;
- } else if (options->ClientTransportPlugin ||
- options->Bridges) {
- const transport_t *transport = NULL;
- int r;
- r = get_transport_by_bridge_addrport(&conn->addr, conn->port, &transport);
- if (r<0)
- return -1;
- if (transport) { /* transport found */
- tor_addr_copy(addr, &transport->addr);
- *port = transport->port;
- *proxy_type = transport->socks_version;
- return 0;
- }
}
tor_addr_make_unspec(addr);
@@ -4837,7 +4848,7 @@ log_failed_proxy_connection(connection_t *conn)
log_warn(LD_NET,
"The connection to the %s proxy server at %s just failed. "
"Make sure that the proxy server is up and running.",
- proxy_type_to_string(get_proxy_type()),
+ proxy_type_to_string(proxy_type),
fmt_addrport(&proxy_addr, proxy_port));
}
diff --git a/src/or/connection.h b/src/or/connection.h
index 13dcbcd919..7cdfd3e253 100644
--- a/src/or/connection.h
+++ b/src/or/connection.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -189,7 +189,8 @@ dir_connection_t *connection_dir_get_by_purpose_and_resource(
int any_other_active_or_conns(const or_connection_t *this_conn);
-#define connection_speaks_cells(conn) ((conn)->type == CONN_TYPE_OR)
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define connection_speaks_cells(conn) (((conn)->type == CONN_TYPE_OR) || 0)
int connection_is_listener(connection_t *conn);
int connection_state_is_open(connection_t *conn);
int connection_state_is_connecting(connection_t *conn);
diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c
index 49f9ba4978..14b391180e 100644
--- a/src/or/connection_edge.c
+++ b/src/or/connection_edge.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -1767,7 +1767,8 @@ connection_ap_supports_optimistic_data(const entry_connection_t *conn)
general circuit. */
if (edge_conn->on_circuit == NULL ||
edge_conn->on_circuit->state != CIRCUIT_STATE_OPEN ||
- edge_conn->on_circuit->purpose != CIRCUIT_PURPOSE_C_GENERAL)
+ (edge_conn->on_circuit->purpose != CIRCUIT_PURPOSE_C_GENERAL &&
+ edge_conn->on_circuit->purpose != CIRCUIT_PURPOSE_C_REND_JOINED))
return 0;
return conn->may_use_optimistic_data;
@@ -2764,7 +2765,6 @@ connection_exit_connect(edge_connection_t *edge_conn)
/* also, deliver a 'connected' cell back through the circuit. */
if (connection_edge_is_rendezvous_stream(edge_conn)) {
- /* rendezvous stream */
/* don't send an address back! */
connection_edge_send_command(edge_conn,
RELAY_COMMAND_CONNECTED,
diff --git a/src/or/connection_edge.h b/src/or/connection_edge.h
index 3c0e30a973..5071086a41 100644
--- a/src/or/connection_edge.h
+++ b/src/or/connection_edge.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/connection_or.c b/src/or/connection_or.c
index 16f87349fc..29b88041b7 100644
--- a/src/or/connection_or.c
+++ b/src/or/connection_or.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -908,21 +908,23 @@ connection_or_init_conn_from_address(or_connection_t *conn,
tor_free(conn->base_.address);
conn->base_.address = tor_dup_addr(&node_ap.addr);
} else {
- const char *n;
- /* If we're an authoritative directory server, we may know a
- * nickname for this router. */
- n = dirserv_get_nickname_by_digest(id_digest);
- if (n) {
- conn->nickname = tor_strdup(n);
- } else {
- conn->nickname = tor_malloc(HEX_DIGEST_LEN+2);
- conn->nickname[0] = '$';
- base16_encode(conn->nickname+1, HEX_DIGEST_LEN+1,
- conn->identity_digest, DIGEST_LEN);
- }
+ conn->nickname = tor_malloc(HEX_DIGEST_LEN+2);
+ conn->nickname[0] = '$';
+ base16_encode(conn->nickname+1, HEX_DIGEST_LEN+1,
+ conn->identity_digest, DIGEST_LEN);
+
tor_free(conn->base_.address);
conn->base_.address = tor_dup_addr(addr);
}
+
+ /*
+ * We have to tell channeltls.c to update the channel marks (local, in
+ * particular), since we may have changed the address.
+ */
+
+ if (conn->chan) {
+ channel_tls_update_marks(conn);
+ }
}
/** These just pass all the is_bad_for_new_circs manipulation on to
diff --git a/src/or/connection_or.h b/src/or/connection_or.h
index 143540edd9..1ceabdaa4b 100644
--- a/src/or/connection_or.h
+++ b/src/or/connection_or.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/control.c b/src/or/control.c
index 21504e685e..e3f913177b 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -47,6 +47,7 @@
#include <sys/resource.h>
#endif
+#include "crypto_s2k.h"
#include "procmon.h"
/** Yield true iff <b>s</b> is the state of a control_connection_t that has
@@ -194,14 +195,14 @@ log_severity_to_event(int severity)
static void
clear_circ_bw_fields(void)
{
- circuit_t *circ;
origin_circuit_t *ocirc;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!CIRCUIT_IS_ORIGIN(circ))
continue;
ocirc = TO_ORIGIN_CIRCUIT(circ);
ocirc->n_written_circ_bw = ocirc->n_read_circ_bw = 0;
}
+ SMARTLIST_FOREACH_END(circ);
}
/** Set <b>global_event_mask*</b> to the bitwise OR of each live control
@@ -582,7 +583,7 @@ send_control_event_string,(uint16_t event, event_format_t which,
conn->state == CONTROL_CONN_STATE_OPEN) {
control_connection_t *control_conn = TO_CONTROL_CONN(conn);
- if (control_conn->event_mask & (1<<event)) {
+ if (control_conn->event_mask & (((event_mask_t)1)<<event)) {
int is_err = 0;
connection_write_to_buf(msg, strlen(msg), TO_CONN(control_conn));
if (event == EVENT_ERR_MSG)
@@ -949,8 +950,8 @@ static int
handle_control_setevents(control_connection_t *conn, uint32_t len,
const char *body)
{
- int event_code = -1;
- uint32_t event_mask = 0;
+ int event_code;
+ event_mask_t event_mask = 0;
smartlist_t *events = smartlist_new();
(void) len;
@@ -963,6 +964,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
continue;
} else {
int i;
+ event_code = -1;
+
for (i = 0; control_event_table[i].event_name != NULL; ++i) {
if (!strcasecmp(ev, control_event_table[i].event_name)) {
event_code = control_event_table[i].event_code;
@@ -978,7 +981,7 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
return 0;
}
}
- event_mask |= (1 << event_code);
+ event_mask |= (((event_mask_t)1) << event_code);
}
SMARTLIST_FOREACH_END(ev);
SMARTLIST_FOREACH(events, char *, e, tor_free(e));
@@ -993,7 +996,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len,
/** Decode the hashed, base64'd passwords stored in <b>passwords</b>.
* Return a smartlist of acceptable passwords (unterminated strings of
- * length S2K_SPECIFIER_LEN+DIGEST_LEN) on success, or NULL on failure.
+ * length S2K_RFC2440_SPECIFIER_LEN+DIGEST_LEN) on success, or NULL on
+ * failure.
*/
smartlist_t *
decode_hashed_passwords(config_line_t *passwords)
@@ -1009,16 +1013,17 @@ decode_hashed_passwords(config_line_t *passwords)
if (!strcmpstart(hashed, "16:")) {
if (base16_decode(decoded, sizeof(decoded), hashed+3, strlen(hashed+3))<0
- || strlen(hashed+3) != (S2K_SPECIFIER_LEN+DIGEST_LEN)*2) {
+ || strlen(hashed+3) != (S2K_RFC2440_SPECIFIER_LEN+DIGEST_LEN)*2) {
goto err;
}
} else {
if (base64_decode(decoded, sizeof(decoded), hashed, strlen(hashed))
- != S2K_SPECIFIER_LEN+DIGEST_LEN) {
+ != S2K_RFC2440_SPECIFIER_LEN+DIGEST_LEN) {
goto err;
}
}
- smartlist_add(sl, tor_memdup(decoded, S2K_SPECIFIER_LEN+DIGEST_LEN));
+ smartlist_add(sl,
+ tor_memdup(decoded, S2K_RFC2440_SPECIFIER_LEN+DIGEST_LEN));
}
return sl;
@@ -1039,7 +1044,7 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
{
int used_quoted_string = 0;
const or_options_t *options = get_options();
- const char *errstr = NULL;
+ const char *errstr = "Unknown error";
char *password;
size_t password_len;
const char *cp;
@@ -1160,22 +1165,27 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
}
if (bad) {
if (!also_cookie) {
- log_warn(LD_CONTROL,
+ log_warn(LD_BUG,
"Couldn't decode HashedControlPassword: invalid base16");
errstr="Couldn't decode HashedControlPassword value in configuration.";
+ goto err;
}
bad_password = 1;
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_free(sl);
+ sl = NULL;
} else {
SMARTLIST_FOREACH(sl, char *, expected,
{
- secret_to_key(received,DIGEST_LEN,password,password_len,expected);
- if (tor_memeq(expected+S2K_SPECIFIER_LEN, received, DIGEST_LEN))
+ secret_to_key_rfc2440(received,DIGEST_LEN,
+ password,password_len,expected);
+ if (tor_memeq(expected + S2K_RFC2440_SPECIFIER_LEN,
+ received, DIGEST_LEN))
goto ok;
});
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_free(sl);
+ sl = NULL;
if (used_quoted_string)
errstr = "Password did not match HashedControlPassword value from "
@@ -1198,9 +1208,12 @@ handle_control_authenticate(control_connection_t *conn, uint32_t len,
err:
tor_free(password);
- connection_printf_to_buf(conn, "515 Authentication failed: %s\r\n",
- errstr ? errstr : "Unknown reason.");
+ connection_printf_to_buf(conn, "515 Authentication failed: %s\r\n", errstr);
connection_mark_for_close(TO_CONN(conn));
+ if (sl) { /* clean up */
+ SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
+ smartlist_free(sl);
+ }
return 0;
ok:
log_info(LD_CONTROL, "Authenticated control connection ("TOR_SOCKET_T_FORMAT
@@ -1879,9 +1892,8 @@ getinfo_helper_events(control_connection_t *control_conn,
{
(void) control_conn;
if (!strcmp(question, "circuit-status")) {
- circuit_t *circ_;
smartlist_t *status = smartlist_new();
- TOR_LIST_FOREACH(circ_, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ_) {
origin_circuit_t *circ;
char *circdesc;
const char *state;
@@ -1903,6 +1915,7 @@ getinfo_helper_events(control_connection_t *control_conn,
state, *circdesc ? " " : "", circdesc);
tor_free(circdesc);
}
+ SMARTLIST_FOREACH_END(circ_);
*answer = smartlist_join_strings(status, "\r\n", 0, NULL);
SMARTLIST_FOREACH(status, char *, cp, tor_free(cp));
smartlist_free(status);
@@ -2464,7 +2477,7 @@ handle_control_extendcircuit(control_connection_t *conn, uint32_t len,
goto done;
}
if (!node_has_descriptor(node)) {
- connection_printf_to_buf(conn, "552 descriptor for \"%s\"\r\n", n);
+ connection_printf_to_buf(conn, "552 No descriptor for \"%s\"\r\n", n);
goto done;
}
smartlist_add(nodes, (void*)node);
@@ -2639,7 +2652,7 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len,
/* Is this a single hop circuit? */
if (circ && (circuit_get_cpath_len(circ)<2 || hop==1)) {
const node_t *node = NULL;
- char *exit_digest;
+ char *exit_digest = NULL;
if (circ->build_state &&
circ->build_state->chosen_exit &&
!tor_digest_is_zero(circ->build_state->chosen_exit->identity_digest)) {
@@ -2654,6 +2667,7 @@ handle_control_attachstream(control_connection_t *conn, uint32_t len,
"551 Can't attach stream to this one-hop circuit.\r\n", conn);
return 0;
}
+ tor_assert(exit_digest);
ap_conn->chosen_exit_name = tor_strdup(hex_str(exit_digest, DIGEST_LEN));
}
@@ -2879,7 +2893,7 @@ handle_control_resolve(control_connection_t *conn, uint32_t len,
int is_reverse = 0;
(void) len; /* body is nul-terminated; it's safe to ignore the length */
- if (!(conn->event_mask & ((uint32_t)1L<<EVENT_ADDRMAP))) {
+ if (!(conn->event_mask & (((event_mask_t)1)<<EVENT_ADDRMAP))) {
log_warn(LD_CONTROL, "Controller asked us to resolve an address, but "
"isn't listening for ADDRMAP events. It probably won't see "
"the answer.");
@@ -3908,12 +3922,11 @@ control_event_stream_bandwidth_used(void)
int
control_event_circ_bandwidth_used(void)
{
- circuit_t *circ;
origin_circuit_t *ocirc;
if (!EVENT_IS_INTERESTING(EVENT_CIRC_BANDWIDTH_USED))
return 0;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!CIRCUIT_IS_ORIGIN(circ))
continue;
ocirc = TO_ORIGIN_CIRCUIT(circ);
@@ -3926,6 +3939,7 @@ control_event_circ_bandwidth_used(void)
(unsigned long)ocirc->n_written_circ_bw);
ocirc->n_written_circ_bw = ocirc->n_read_circ_bw = 0;
}
+ SMARTLIST_FOREACH_END(circ);
return 0;
}
@@ -4090,14 +4104,13 @@ format_cell_stats(char **event_string, circuit_t *circ,
int
control_event_circuit_cell_stats(void)
{
- circuit_t *circ;
cell_stats_t *cell_stats;
char *event_string;
if (!get_options()->TestingEnableCellStatsEvent ||
!EVENT_IS_INTERESTING(EVENT_CELL_STATS))
return 0;
cell_stats = tor_malloc(sizeof(cell_stats_t));;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!circ->testing_cell_stats)
continue;
sum_up_cell_stats_by_command(circ, cell_stats);
@@ -4106,6 +4119,7 @@ control_event_circuit_cell_stats(void)
"650 CELL_STATS %s\r\n", event_string);
tor_free(event_string);
}
+ SMARTLIST_FOREACH_END(circ);
tor_free(cell_stats);
return 0;
}
@@ -4666,6 +4680,7 @@ init_control_cookie_authentication(int enabled)
fname = get_controller_cookie_file_name();
retval = init_cookie_authentication(fname, "", /* no header */
AUTHENTICATION_COOKIE_LEN,
+ get_options()->CookieAuthFileGroupReadable,
&authentication_cookie,
&authentication_cookie_is_set);
tor_free(fname);
@@ -4920,7 +4935,7 @@ MOCK_IMPL(void,
or_connection_t *or_conn))
{
int status = bootstrap_percent;
- const char *tag, *summary;
+ const char *tag = "", *summary = "";
char buf[BOOTSTRAP_MSG_LEN];
const char *recommendation = "ignore";
int severity;
diff --git a/src/or/control.h b/src/or/control.h
index 68a6c244d0..0c92d5503d 100644
--- a/src/or/control.h
+++ b/src/or/control.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -156,8 +156,8 @@ void control_free_all(void);
#define EVENT_TRANSPORT_LAUNCHED 0x0020
#define EVENT_HS_DESC 0x0021
#define EVENT_MAX_ 0x0021
-/* If EVENT_MAX_ ever hits 0x0040, we need to make the mask into a
- * different structure. */
+/* If EVENT_MAX_ ever hits 0x003F, we need to make the mask into a
+ * different structure, as it can only handle a maximum left shift of 1<<63. */
/* Used only by control.c and test.c */
STATIC size_t write_escaped_data(const char *data, size_t len, char **out);
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c
index 62af8e2f50..568d9e42d8 100644
--- a/src/or/cpuworker.c
+++ b/src/or/cpuworker.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -510,7 +510,7 @@ spawn_cpuworker(void)
connection_t *conn;
int err;
- fdarray = tor_malloc(sizeof(tor_socket_t)*2);
+ fdarray = tor_calloc(2, sizeof(tor_socket_t));
if ((err = tor_socketpair(AF_UNIX, SOCK_STREAM, 0, fdarray)) < 0) {
log_warn(LD_NET, "Couldn't construct socketpair for cpuworker: %s",
tor_socket_strerror(-err));
diff --git a/src/or/cpuworker.h b/src/or/cpuworker.h
index 317cef43ba..f7f1d8346b 100644
--- a/src/or/cpuworker.h
+++ b/src/or/cpuworker.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/directory.c b/src/or/directory.c
index 77f8f310b1..df9e7f8ad3 100644
--- a/src/or/directory.c
+++ b/src/or/directory.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -349,7 +349,7 @@ should_use_directory_guards(const or_options_t *options)
return 1;
}
-/** Pick an unconsetrained directory server from among our guards, the latest
+/** Pick an unconstrained directory server from among our guards, the latest
* networkstatus, or the fallback dirservers, for use in downloading
* information of type <b>type</b>, and return its routerstatus. */
static const routerstatus_t *
@@ -452,7 +452,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
return;
if (!get_via_tor) {
- if (options->UseBridges && type != BRIDGE_DIRINFO) {
+ if (options->UseBridges && !(type & BRIDGE_DIRINFO)) {
/* We want to ask a running bridge for which we have a descriptor.
*
* When we ask choose_random_entry() for a bridge, we specify what
@@ -479,7 +479,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
"nodes are available yet.");
return;
} else {
- if (prefer_authority || type == BRIDGE_DIRINFO) {
+ if (prefer_authority || (type & BRIDGE_DIRINFO)) {
/* only ask authdirservers, and don't ask myself */
rs = router_pick_trusteddirserver(type, pds_flags);
if (rs == NULL && (pds_flags & (PDS_NO_EXISTING_SERVERDESC_FETCH|
@@ -506,7 +506,7 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
return;
}
}
- if (!rs && type != BRIDGE_DIRINFO) {
+ if (!rs && !(type & BRIDGE_DIRINFO)) {
/* */
rs = directory_pick_generic_dirserver(type, pds_flags,
dir_purpose);
@@ -523,12 +523,12 @@ directory_get_from_dirserver(uint8_t dir_purpose, uint8_t router_purpose,
/* anybody with a non-zero dirport will do. Disregard firewalls. */
pds_flags |= PDS_IGNORE_FASCISTFIREWALL;
rs = router_pick_directory_server(type, pds_flags);
- /* If we have any hope of building an indirect conn, we know some router
- * descriptors. If (rs==NULL), we can't build circuits anyway, so
- * there's no point in falling back to the authorities in this case. */
}
}
+ /* If we have any hope of building an indirect conn, we know some router
+ * descriptors. If (rs==NULL), we can't build circuits anyway, so
+ * there's no point in falling back to the authorities in this case. */
if (rs) {
const dir_indirection_t indirection =
get_via_tor ? DIRIND_ANONYMOUS : DIRIND_ONEHOP;
@@ -2082,7 +2082,8 @@ connection_dir_client_reached_eof(dir_connection_t *conn)
(int)body_len, status_code, escaped(reason));
switch (status_code) {
case 200:
- switch (rend_cache_store_v2_desc_as_client(body, conn->rend_data)) {
+ switch (rend_cache_store_v2_desc_as_client(body,
+ conn->requested_resource, conn->rend_data)) {
case RCS_BADDESC:
case RCS_NOTDIR: /* Impossible */
log_warn(LD_REND,"Fetching v2 rendezvous descriptor failed. "
@@ -2497,7 +2498,7 @@ client_likes_consensus(networkstatus_t *v, const char *want_url)
if (base16_decode(want_digest, DIGEST_LEN, d, want_len*2) < 0) {
log_fn(LOG_PROTOCOL_WARN, LD_DIR,
- "Failed to decode requested authority digest %s.", d);
+ "Failed to decode requested authority digest %s.", escaped(d));
continue;
};
@@ -2557,7 +2558,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
* act as if no If-Modified-Since header had been given. */
tor_free(header);
}
- log_debug(LD_DIRSERV,"rewritten url as '%s'.", url);
+ log_debug(LD_DIRSERV,"rewritten url as '%s'.", escaped(url));
url_mem = url;
url_len = strlen(url);
@@ -3006,7 +3007,7 @@ directory_handle_command_get(dir_connection_t *conn, const char *headers,
const char *query = url + strlen("/tor/rendezvous2/");
if (strlen(query) == REND_DESC_ID_V2_LEN_BASE32) {
log_info(LD_REND, "Got a v2 rendezvous descriptor request for ID '%s'",
- safe_str(query));
+ safe_str(escaped(query)));
switch (rend_cache_lookup_v2_desc_as_dir(query, &descp)) {
case 1: /* valid */
write_http_response_header(conn, strlen(descp), 0, 0);
@@ -3140,7 +3141,7 @@ directory_handle_command_post(dir_connection_t *conn, const char *headers,
write_http_status_line(conn, 400, "Bad request");
return 0;
}
- log_debug(LD_DIRSERV,"rewritten url as '%s'.", url);
+ log_debug(LD_DIRSERV,"rewritten url as '%s'.", escaped(url));
/* Handle v2 rendezvous service publish request. */
if (options->HidServDirectoryV2 &&
@@ -3273,7 +3274,9 @@ directory_handle_command(dir_connection_t *conn)
}
http_set_address_origin(headers, TO_CONN(conn));
- //log_debug(LD_DIRSERV,"headers %s, body %s.", headers, body);
+ // we should escape headers here as well,
+ // but we can't call escaped() twice, as it uses the same buffer
+ //log_debug(LD_DIRSERV,"headers %s, body %s.", headers, escaped(body));
if (!strncasecmp(headers,"GET",3))
r = directory_handle_command_get(conn, headers, body, body_len);
@@ -3440,6 +3443,9 @@ download_status_increment_failure(download_status_t *dls, int status_code,
void
download_status_reset(download_status_t *dls)
{
+ if (dls->n_download_failures == IMPOSSIBLE_TO_DOWNLOAD)
+ return; /* Don't reset this. */
+
const smartlist_t *schedule = find_dl_schedule_and_len(
dls, get_options()->DirPort_set);
diff --git a/src/or/directory.h b/src/or/directory.h
index bc200797d4..d78046912c 100644
--- a/src/or/directory.h
+++ b/src/or/directory.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/dirserv.c b/src/or/dirserv.c
index a033f8be6d..730f005a96 100644
--- a/src/or/dirserv.c
+++ b/src/or/dirserv.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define DIRSERV_PRIVATE
@@ -56,13 +56,11 @@ static int routers_with_measured_bw = 0;
static void directory_remove_invalid(void);
static char *format_versions_list(config_line_t *ln);
struct authdir_config_t;
-static int add_fingerprint_to_dir(const char *nickname, const char *fp,
- struct authdir_config_t *list);
static uint32_t
dirserv_get_status_impl(const char *fp, const char *nickname,
uint32_t addr, uint16_t or_port,
- const char *platform, const char *contact,
- const char **msg, int should_log);
+ const char *platform, const char **msg,
+ int should_log);
static void clear_cached_dir(cached_dir_t *d);
static const signed_descriptor_t *get_signed_descriptor_by_fp(
const char *fp,
@@ -75,19 +73,19 @@ static uint32_t dirserv_get_credible_bandwidth_kb(const routerinfo_t *ri);
/************** Fingerprint handling code ************/
-#define FP_NAMED 1 /**< Listed in fingerprint file. */
+/* 1 Historically used to indicate Named */
#define FP_INVALID 2 /**< Believed invalid. */
#define FP_REJECT 4 /**< We will not publish this router. */
-#define FP_BADDIR 8 /**< We'll tell clients to avoid using this as a dir. */
+/* 8 Historically used to avoid using this as a dir. */
#define FP_BADEXIT 16 /**< We'll tell clients not to use this as an exit. */
-#define FP_UNNAMED 32 /**< Another router has this name in fingerprint file. */
+/* 32 Historically used to indicade Unnamed */
-/** Encapsulate a nickname and an FP_* status; target of status_by_digest
- * map. */
-typedef struct router_status_t {
- char nickname[MAX_NICKNAME_LEN+1];
- uint32_t status;
-} router_status_t;
+/** Target of status_by_digest map. */
+typedef uint32_t router_status_t;
+
+static void add_fingerprint_to_dir(const char *fp,
+ struct authdir_config_t *list,
+ router_status_t add_status);
/** List of nickname-\>identity fingerprint mappings for all the routers
* that we name. Used to prevent router impersonation. */
@@ -109,18 +107,17 @@ authdir_config_new(void)
return list;
}
-/** Add the fingerprint <b>fp</b> for <b>nickname</b> to
- * the smartlist of fingerprint_entry_t's <b>list</b>. Return 0 if it's
- * new, or 1 if we replaced the old value.
+/** Add the fingerprint <b>fp</b> to the smartlist of fingerprint_entry_t's
+ * <b>list</b>, or-ing the currently set status flags with
+ * <b>add_status</b>.
*/
-/* static */ int
-add_fingerprint_to_dir(const char *nickname, const char *fp,
- authdir_config_t *list)
+/* static */ void
+add_fingerprint_to_dir(const char *fp, authdir_config_t *list,
+ router_status_t add_status)
{
char *fingerprint;
char d[DIGEST_LEN];
router_status_t *status;
- tor_assert(nickname);
tor_assert(fp);
tor_assert(list);
@@ -130,14 +127,7 @@ add_fingerprint_to_dir(const char *nickname, const char *fp,
log_warn(LD_DIRSERV, "Couldn't decode fingerprint \"%s\"",
escaped(fp));
tor_free(fingerprint);
- return 0;
- }
-
- if (!strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {
- log_warn(LD_DIRSERV, "Tried to add a mapping for reserved nickname %s",
- UNNAMED_ROUTER_NICKNAME);
- tor_free(fingerprint);
- return 0;
+ return;
}
status = digestmap_get(list->status_by_digest, d);
@@ -146,35 +136,15 @@ add_fingerprint_to_dir(const char *nickname, const char *fp,
digestmap_set(list->status_by_digest, d, status);
}
- if (nickname[0] != '!') {
- char *old_fp = strmap_get_lc(list->fp_by_name, nickname);
- if (old_fp && !strcasecmp(fingerprint, old_fp)) {
- tor_free(fingerprint);
- } else {
- tor_free(old_fp);
- strmap_set_lc(list->fp_by_name, nickname, fingerprint);
- }
- status->status |= FP_NAMED;
- strlcpy(status->nickname, nickname, sizeof(status->nickname));
- } else {
- tor_free(fingerprint);
- if (!strcasecmp(nickname, "!reject")) {
- status->status |= FP_REJECT;
- } else if (!strcasecmp(nickname, "!invalid")) {
- status->status |= FP_INVALID;
- } else if (!strcasecmp(nickname, "!baddir")) {
- status->status |= FP_BADDIR;
- } else if (!strcasecmp(nickname, "!badexit")) {
- status->status |= FP_BADEXIT;
- }
- }
- return 0;
+ tor_free(fingerprint);
+ *status |= add_status;
+ return;
}
-/** Add the nickname and fingerprint for this OR to the
- * global list of recognized identity key fingerprints. */
+/** Add the fingerprint for this OR to the global list of recognized
+ * identity key fingerprints. */
int
-dirserv_add_own_fingerprint(const char *nickname, crypto_pk_t *pk)
+dirserv_add_own_fingerprint(crypto_pk_t *pk)
{
char fp[FINGERPRINT_LEN+1];
if (crypto_pk_get_fingerprint(pk, fp, 0)<0) {
@@ -183,7 +153,7 @@ dirserv_add_own_fingerprint(const char *nickname, crypto_pk_t *pk)
}
if (!fingerprint_list)
fingerprint_list = authdir_config_new();
- add_fingerprint_to_dir(nickname, fp, fingerprint_list);
+ add_fingerprint_to_dir(fp, fingerprint_list, 0);
return 0;
}
@@ -201,7 +171,6 @@ dirserv_load_fingerprint_file(void)
authdir_config_t *fingerprint_list_new;
int result;
config_line_t *front=NULL, *list;
- const or_options_t *options = get_options();
fname = get_datadir_fname("approved-routers");
log_info(LD_GENERAL,
@@ -209,15 +178,9 @@ dirserv_load_fingerprint_file(void)
cf = read_file_to_str(fname, RFTS_IGNORE_MISSING, NULL);
if (!cf) {
- if (options->NamingAuthoritativeDir) {
- log_warn(LD_FS, "Cannot open fingerprint file '%s'. Failing.", fname);
- tor_free(fname);
- return -1;
- } else {
- log_info(LD_FS, "Cannot open fingerprint file '%s'. That's ok.", fname);
- tor_free(fname);
- return 0;
- }
+ log_warn(LD_FS, "Cannot open fingerprint file '%s'. That's ok.", fname);
+ tor_free(fname);
+ return 0;
}
tor_free(fname);
@@ -232,22 +195,8 @@ dirserv_load_fingerprint_file(void)
for (list=front; list; list=list->next) {
char digest_tmp[DIGEST_LEN];
+ router_status_t add_status = 0;
nickname = list->key; fingerprint = list->value;
- if (strlen(nickname) > MAX_NICKNAME_LEN) {
- log_notice(LD_CONFIG,
- "Nickname '%s' too long in fingerprint file. Skipping.",
- nickname);
- continue;
- }
- if (!is_legal_nickname(nickname) &&
- strcasecmp(nickname, "!reject") &&
- strcasecmp(nickname, "!invalid") &&
- strcasecmp(nickname, "!badexit")) {
- log_notice(LD_CONFIG,
- "Invalid nickname '%s' in fingerprint file. Skipping.",
- nickname);
- continue;
- }
tor_strstrip(fingerprint, " "); /* remove spaces */
if (strlen(fingerprint) != HEX_DIGEST_LEN ||
base16_decode(digest_tmp, sizeof(digest_tmp),
@@ -258,26 +207,14 @@ dirserv_load_fingerprint_file(void)
nickname, fingerprint);
continue;
}
- if (0==strcasecmp(nickname, DEFAULT_CLIENT_NICKNAME)) {
- /* If you approved an OR called "client", then clients who use
- * the default nickname could all be rejected. That's no good. */
- log_notice(LD_CONFIG,
- "Authorizing nickname '%s' would break "
- "many clients; skipping.",
- DEFAULT_CLIENT_NICKNAME);
- continue;
- }
- if (0==strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {
- /* If you approved an OR called "unnamed", then clients will be
- * confused. */
- log_notice(LD_CONFIG,
- "Authorizing nickname '%s' is not allowed; skipping.",
- UNNAMED_ROUTER_NICKNAME);
- continue;
+ if (!strcasecmp(nickname, "!reject")) {
+ add_status = FP_REJECT;
+ } else if (!strcasecmp(nickname, "!badexit")) {
+ add_status = FP_BADEXIT;
+ } else if (!strcasecmp(nickname, "!invalid")) {
+ add_status = FP_INVALID;
}
- if (add_fingerprint_to_dir(nickname, fingerprint, fingerprint_list_new)
- != 0)
- log_notice(LD_CONFIG, "Duplicate nickname '%s'.", nickname);
+ add_fingerprint_to_dir(fingerprint, fingerprint_list_new, add_status);
}
config_free_lines(front);
@@ -308,8 +245,7 @@ dirserv_router_get_status(const routerinfo_t *router, const char **msg)
return dirserv_get_status_impl(d, router->nickname,
router->addr, router->or_port,
- router->platform, router->contact_info,
- msg, 1);
+ router->platform, msg, 1);
}
/** Return true if there is no point in downloading the router described by
@@ -321,37 +257,14 @@ dirserv_would_reject_router(const routerstatus_t *rs)
res = dirserv_get_status_impl(rs->identity_digest, rs->nickname,
rs->addr, rs->or_port,
- NULL, NULL,
- NULL, 0);
+ NULL, NULL, 0);
return (res & FP_REJECT) != 0;
}
-/** Helper: Based only on the ID/Nickname combination,
- * return FP_UNNAMED (unnamed), FP_NAMED (named), or 0 (neither).
- */
-static uint32_t
-dirserv_get_name_status(const char *id_digest, const char *nickname)
-{
- char fp[HEX_DIGEST_LEN+1];
- char *fp_by_name;
-
- base16_encode(fp, sizeof(fp), id_digest, DIGEST_LEN);
-
- if ((fp_by_name =
- strmap_get_lc(fingerprint_list->fp_by_name, nickname))) {
- if (!strcasecmp(fp, fp_by_name)) {
- return FP_NAMED;
- } else {
- return FP_UNNAMED; /* Wrong fingerprint. */
- }
- }
- return 0;
-}
-
/** Helper: As dirserv_router_get_status, but takes the router fingerprint
* (hex, no spaces), nickname, address (used for logging only), IP address, OR
- * port, platform (logging only) and contact info (logging only) as arguments.
+ * port and platform (logging only) as arguments.
*
* If should_log is false, do not log messages. (There's not much point in
* logging that we're rejecting servers we'll not download.)
@@ -359,11 +272,9 @@ dirserv_get_name_status(const char *id_digest, const char *nickname)
static uint32_t
dirserv_get_status_impl(const char *id_digest, const char *nickname,
uint32_t addr, uint16_t or_port,
- const char *platform, const char *contact,
- const char **msg, int should_log)
+ const char *platform, const char **msg, int should_log)
{
- int reject_unlisted = get_options()->AuthDirRejectUnlisted;
- uint32_t result;
+ uint32_t result = 0;
router_status_t *status_by_digest;
if (!fingerprint_list)
@@ -381,43 +292,11 @@ dirserv_get_status_impl(const char *id_digest, const char *nickname,
*msg = "Tor version is insecure or unsupported. Please upgrade!";
return FP_REJECT;
}
-#if 0
- else if (platform && tor_version_as_new_as(platform,"0.2.3.0-alpha")) {
- /* Versions from 0.2.3-alpha...0.2.3.9-alpha have known security
- * issues that make them unusable for the current network */
- if (!tor_version_as_new_as(platform, "0.2.3.10-alpha")) {
- if (msg)
- *msg = "Tor version is insecure or unsupported. Please upgrade!";
- return FP_REJECT;
- }
- }
-#endif
-
- result = dirserv_get_name_status(id_digest, nickname);
- if (result & FP_NAMED) {
- if (should_log)
- log_debug(LD_DIRSERV,"Good fingerprint for '%s'",nickname);
- }
- if (result & FP_UNNAMED) {
- if (should_log) {
- char *esc_contact = esc_for_log(contact);
- log_info(LD_DIRSERV,
- "Mismatched fingerprint for '%s'. "
- "ContactInfo '%s', platform '%s'.)",
- nickname,
- esc_contact,
- platform ? escaped(platform) : "");
- tor_free(esc_contact);
- }
- if (msg)
- *msg = "Rejected: There is already a named server with this nickname "
- "and a different fingerprint.";
- }
status_by_digest = digestmap_get(fingerprint_list->status_by_digest,
id_digest);
if (status_by_digest)
- result |= (status_by_digest->status & ~FP_NAMED);
+ result |= *status_by_digest;
if (result & FP_REJECT) {
if (msg)
@@ -428,14 +307,6 @@ dirserv_get_status_impl(const char *id_digest, const char *nickname,
*msg = "Fingerprint is marked invalid";
}
- if (authdir_policy_baddir_address(addr, or_port)) {
- if (should_log)
- log_info(LD_DIRSERV,
- "Marking '%s' as bad directory because of address '%s'",
- nickname, fmt_addr32(addr));
- result |= FP_BADDIR;
- }
-
if (authdir_policy_badexit_address(addr, or_port)) {
if (should_log)
log_info(LD_DIRSERV, "Marking '%s' as bad exit because of address '%s'",
@@ -443,46 +314,24 @@ dirserv_get_status_impl(const char *id_digest, const char *nickname,
result |= FP_BADEXIT;
}
- if (!(result & FP_NAMED)) {
- if (!authdir_policy_permits_address(addr, or_port)) {
- if (should_log)
- log_info(LD_DIRSERV, "Rejecting '%s' because of address '%s'",
- nickname, fmt_addr32(addr));
- if (msg)
- *msg = "Authdir is rejecting routers in this range.";
- return FP_REJECT;
- }
- if (!authdir_policy_valid_address(addr, or_port)) {
- if (should_log)
- log_info(LD_DIRSERV, "Not marking '%s' valid because of address '%s'",
- nickname, fmt_addr32(addr));
- result |= FP_INVALID;
- }
- if (reject_unlisted) {
- if (msg)
- *msg = "Authdir rejects unknown routers.";
- return FP_REJECT;
- }
+ if (!authdir_policy_permits_address(addr, or_port)) {
+ if (should_log)
+ log_info(LD_DIRSERV, "Rejecting '%s' because of address '%s'",
+ nickname, fmt_addr32(addr));
+ if (msg)
+ *msg = "Authdir is rejecting routers in this range.";
+ return FP_REJECT;
+ }
+ if (!authdir_policy_valid_address(addr, or_port)) {
+ if (should_log)
+ log_info(LD_DIRSERV, "Not marking '%s' valid because of address '%s'",
+ nickname, fmt_addr32(addr));
+ result |= FP_INVALID;
}
return result;
}
-/** If we are an authoritative dirserver, and the list of approved
- * servers contains one whose identity key digest is <b>digest</b>,
- * return that router's nickname. Otherwise return NULL. */
-const char *
-dirserv_get_nickname_by_digest(const char *digest)
-{
- router_status_t *status;
- if (!fingerprint_list)
- return NULL;
- tor_assert(digest);
-
- status = digestmap_get(fingerprint_list->status_by_digest, digest);
- return status ? status->nickname : NULL;
-}
-
/** Clear the current fingerprint list. */
void
dirserv_free_fingerprint_list(void)
@@ -519,7 +368,7 @@ dirserv_router_has_valid_address(routerinfo_t *ri)
}
/** Check whether we, as a directory server, want to accept <b>ri</b>. If so,
- * set its is_valid,named,running fields and return 0. Otherwise, return -1.
+ * set its is_valid,running fields and return 0. Otherwise, return -1.
*
* If the router is rejected, set *<b>msg</b> to an explanation of why.
*
@@ -584,7 +433,6 @@ dirserv_set_node_flags_from_authoritative_status(node_t *node,
uint32_t authstatus)
{
node->is_valid = (authstatus & FP_INVALID) ? 0 : 1;
- node->is_bad_directory = (authstatus & FP_BADDIR) ? 1 : 0;
node->is_bad_exit = (authstatus & FP_BADEXIT) ? 1 : 0;
}
@@ -630,7 +478,7 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
s = desc;
list = smartlist_new();
if (!router_parse_list_from_string(&s, NULL, list, SAVED_NOWHERE, 0, 0,
- annotation_buf)) {
+ annotation_buf, NULL)) {
SMARTLIST_FOREACH(list, routerinfo_t *, ri, {
msg_out = NULL;
tor_assert(ri->purpose == purpose);
@@ -646,7 +494,7 @@ dirserv_add_multiple_descriptors(const char *desc, uint8_t purpose,
s = desc;
if (!router_parse_list_from_string(&s, NULL, list, SAVED_NOWHERE, 1, 0,
- NULL)) {
+ NULL, NULL)) {
SMARTLIST_FOREACH(list, extrainfo_t *, ei, {
msg_out = NULL;
@@ -816,7 +664,7 @@ directory_remove_invalid(void)
smartlist_add_all(nodes, nodelist_get_list());
SMARTLIST_FOREACH_BEGIN(nodes, node_t *, node) {
- const char *msg;
+ const char *msg = NULL;
routerinfo_t *ent = node->ri;
char description[NODE_DESC_BUF_LEN];
uint32_t r;
@@ -830,30 +678,11 @@ directory_remove_invalid(void)
routerlist_remove(rl, ent, 0, time(NULL));
continue;
}
-#if 0
- if (bool_neq((r & FP_NAMED), ent->auth_says_is_named)) {
- log_info(LD_DIRSERV,
- "Router %s is now %snamed.", description,
- (r&FP_NAMED)?"":"un");
- ent->is_named = (r&FP_NAMED)?1:0;
- }
- if (bool_neq((r & FP_UNNAMED), ent->auth_says_is_unnamed)) {
- log_info(LD_DIRSERV,
- "Router '%s' is now %snamed. (FP_UNNAMED)", description,
- (r&FP_NAMED)?"":"un");
- ent->is_named = (r&FP_NUNAMED)?0:1;
- }
-#endif
if (bool_neq((r & FP_INVALID), !node->is_valid)) {
log_info(LD_DIRSERV, "Router '%s' is now %svalid.", description,
(r&FP_INVALID) ? "in" : "");
node->is_valid = (r&FP_INVALID)?0:1;
}
- if (bool_neq((r & FP_BADDIR), node->is_bad_directory)) {
- log_info(LD_DIRSERV, "Router '%s' is now a %s directory", description,
- (r & FP_BADDIR) ? "bad" : "good");
- node->is_bad_directory = (r&FP_BADDIR) ? 1: 0;
- }
if (bool_neq((r & FP_BADEXIT), node->is_bad_exit)) {
log_info(LD_DIRSERV, "Router '%s' is now a %s exit", description,
(r & FP_BADEXIT) ? "bad" : "good");
@@ -1051,7 +880,8 @@ format_versions_list(config_line_t *ln)
}
/** Return 1 if <b>ri</b>'s descriptor is "active" -- running, valid,
- * not hibernating, and not too old. Else return 0.
+ * not hibernating, having observed bw greater 0, and not too old. Else
+ * return 0.
*/
static int
router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
@@ -1061,6 +891,8 @@ router_is_active(const routerinfo_t *ri, const node_t *node, time_t now)
return 0;
if (!node->is_running || !node->is_valid || ri->is_hibernating)
return 0;
+ if (!ri->bandwidthcapacity)
+ return 0;
return 1;
}
@@ -1537,18 +1369,18 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
* sort them and use that to compute thresholds. */
n_active = n_active_nonexit = 0;
/* Uptime for every active router. */
- uptimes = tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+ uptimes = tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
/* Bandwidth for every active router. */
- bandwidths_kb = tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+ bandwidths_kb = tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
/* Bandwidth for every active non-exit router. */
bandwidths_excluding_exits_kb =
- tor_malloc(sizeof(uint32_t)*smartlist_len(rl->routers));
+ tor_calloc(smartlist_len(rl->routers), sizeof(uint32_t));
/* Weighted mean time between failure for each active router. */
- mtbfs = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
+ mtbfs = tor_calloc(smartlist_len(rl->routers), sizeof(double));
/* Time-known for each active router. */
- tks = tor_malloc(sizeof(long)*smartlist_len(rl->routers));
+ tks = tor_calloc(smartlist_len(rl->routers), sizeof(long));
/* Weighted fractional uptime for each active router. */
- wfus = tor_malloc(sizeof(double)*smartlist_len(rl->routers));
+ wfus = tor_calloc(smartlist_len(rl->routers), sizeof(double));
nodelist_assert_ok();
@@ -1563,6 +1395,8 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
routerinfo_t *ri = node->ri;
const char *id = node->identity;
uint32_t bw_kb;
+ /* resolve spurious clang shallow analysis null pointer errors */
+ tor_assert(ri);
node->is_exit = (!router_exit_policy_rejects_all(ri) &&
exit_policy_is_general_exit(ri->exit_policy));
uptimes[n_active] = (uint32_t)real_uptime(ri, now);
@@ -1588,7 +1422,8 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
/* (Now bandwidths is sorted.) */
if (fast_bandwidth_kb < ROUTER_REQUIRED_MIN_BANDWIDTH/(2 * 1000))
fast_bandwidth_kb = bandwidths_kb[n_active/4];
- guard_bandwidth_including_exits_kb = bandwidths_kb[(n_active-1)/2];
+ guard_bandwidth_including_exits_kb =
+ third_quartile_uint32(bandwidths_kb, n_active);
guard_tk = find_nth_long(tks, n_active, n_active/8);
}
@@ -1646,7 +1481,8 @@ dirserv_compute_performance_thresholds(routerlist_t *rl,
if (n_active_nonexit) {
guard_bandwidth_excluding_exits_kb =
- median_uint32(bandwidths_excluding_exits_kb, n_active_nonexit);
+ find_nth_uint32(bandwidths_excluding_exits_kb,
+ n_active_nonexit, n_active_nonexit*3/4);
}
log_info(LD_DIRSERV,
@@ -1958,13 +1794,12 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
char published[ISO_TIME_LEN+1];
char identity64[BASE64_DIGEST_LEN+1];
char digest64[BASE64_DIGEST_LEN+1];
- smartlist_t *chunks = NULL;
+ smartlist_t *chunks = smartlist_new();
format_iso_time(published, rs->published_on);
digest_to_base64(identity64, rs->identity_digest);
digest_to_base64(digest64, rs->descriptor_digest);
- chunks = smartlist_new();
smartlist_add_asprintf(chunks,
"r %s %s %s%s%s %s %d %d\n",
rs->nickname,
@@ -1995,19 +1830,16 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
goto done;
smartlist_add_asprintf(chunks,
- "s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+ "s%s%s%s%s%s%s%s%s%s%s\n",
/* These must stay in alphabetical order. */
rs->is_authority?" Authority":"",
- rs->is_bad_directory?" BadDirectory":"",
rs->is_bad_exit?" BadExit":"",
rs->is_exit?" Exit":"",
rs->is_fast?" Fast":"",
rs->is_possible_guard?" Guard":"",
rs->is_hs_dir?" HSDir":"",
- rs->is_named?" Named":"",
rs->is_flagged_running?" Running":"",
rs->is_stable?" Stable":"",
- rs->is_unnamed?" Unnamed":"",
(rs->dir_port!=0)?" V2Dir":"",
rs->is_valid?" Valid":"");
@@ -2089,10 +1921,8 @@ routerstatus_format_entry(const routerstatus_t *rs, const char *version,
result = smartlist_join_strings(chunks, "", 0, NULL);
err:
- if (chunks) {
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
- smartlist_free(chunks);
- }
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
return result;
}
@@ -2198,78 +2028,8 @@ get_possible_sybil_list(const smartlist_t *routers)
return omit_as_sybil;
}
-/** Return non-zero iff a relay running the Tor version specified in
- * <b>platform</b> is suitable for use as a potential entry guard. */
-static int
-is_router_version_good_for_possible_guard(const char *platform)
-{
- static int parsed_versions_initialized = 0;
- static tor_version_t first_good_0_2_1_guard_version;
- static tor_version_t first_good_0_2_2_guard_version;
- static tor_version_t first_good_later_guard_version;
-
- tor_version_t router_version;
-
- /* XXX024 This block should be extracted into its own function. */
- /* XXXX Begin code copied from tor_version_as_new_as (in routerparse.c) */
- {
- char *s, *s2, *start;
- char tmp[128];
-
- tor_assert(platform);
-
- /* nonstandard Tor; be safe and say yes */
- if (strcmpstart(platform,"Tor "))
- return 1;
-
- start = (char *)eat_whitespace(platform+3);
- if (!*start) return 0;
- s = (char *)find_whitespace(start); /* also finds '\0', which is fine */
- s2 = (char*)eat_whitespace(s);
- if (!strcmpstart(s2, "(r") || !strcmpstart(s2, "(git-"))
- s = (char*)find_whitespace(s2);
-
- if ((size_t)(s-start+1) >= sizeof(tmp)) /* too big, no */
- return 0;
- strlcpy(tmp, start, s-start+1);
-
- if (tor_version_parse(tmp, &router_version)<0) {
- log_info(LD_DIR,"Router version '%s' unparseable.",tmp);
- return 1; /* be safe and say yes */
- }
- }
- /* XXXX End code copied from tor_version_as_new_as (in routerparse.c) */
-
- if (!parsed_versions_initialized) {
- /* CVE-2011-2769 was fixed on the relay side in Tor versions
- * 0.2.1.31, 0.2.2.34, and 0.2.3.6-alpha. */
- tor_assert(tor_version_parse("0.2.1.31",
- &first_good_0_2_1_guard_version)>=0);
- tor_assert(tor_version_parse("0.2.2.34",
- &first_good_0_2_2_guard_version)>=0);
- tor_assert(tor_version_parse("0.2.3.6-alpha",
- &first_good_later_guard_version)>=0);
-
- /* Don't parse these constant version strings once for every relay
- * for every vote. */
- parsed_versions_initialized = 1;
- }
-
- return ((tor_version_same_series(&first_good_0_2_1_guard_version,
- &router_version) &&
- tor_version_compare(&first_good_0_2_1_guard_version,
- &router_version) <= 0) ||
- (tor_version_same_series(&first_good_0_2_2_guard_version,
- &router_version) &&
- tor_version_compare(&first_good_0_2_2_guard_version,
- &router_version) <= 0) ||
- (tor_version_compare(&first_good_later_guard_version,
- &router_version) <= 0));
-}
-
/** Extract status information from <b>ri</b> and from other authority
- * functions and store it in <b>rs</b>>. If <b>naming</b>, consider setting
- * the named flag in <b>rs</b>.
+ * functions and store it in <b>rs</b>>.
*
* We assume that ri-\>is_running has already been set, e.g. by
* dirserv_set_router_is_running(ri, now);
@@ -2279,8 +2039,8 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
node_t *node,
routerinfo_t *ri,
time_t now,
- int naming, int listbadexits,
- int listbaddirs, int vote_on_hsdirs)
+ int listbadexits,
+ int vote_on_hsdirs)
{
const or_options_t *options = get_options();
uint32_t routerbw_kb = dirserv_get_credible_bandwidth_kb(ri);
@@ -2300,20 +2060,13 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
!dirserv_thinks_router_is_unreliable(now, ri, 0, 1);
rs->is_flagged_running = node->is_running; /* computed above */
- if (naming) {
- uint32_t name_status = dirserv_get_name_status(
- node->identity, ri->nickname);
- rs->is_named = (naming && (name_status & FP_NAMED)) ? 1 : 0;
- rs->is_unnamed = (naming && (name_status & FP_UNNAMED)) ? 1 : 0;
- }
rs->is_valid = node->is_valid;
if (node->is_fast &&
((options->AuthDirGuardBWGuarantee &&
routerbw_kb >= options->AuthDirGuardBWGuarantee/1000) ||
routerbw_kb >= MIN(guard_bandwidth_including_exits_kb,
- guard_bandwidth_excluding_exits_kb)) &&
- is_router_version_good_for_possible_guard(ri->platform)) {
+ guard_bandwidth_excluding_exits_kb))) {
long tk = rep_hist_get_weighted_time_known(
node->identity, now);
double wfu = rep_hist_get_weighted_fractional_uptime(
@@ -2322,19 +2075,12 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
} else {
rs->is_possible_guard = 0;
}
- if (options->TestingTorNetwork &&
- routerset_contains_routerstatus(options->TestingDirAuthVoteGuard,
- rs, 0)) {
- rs->is_possible_guard = 1;
- }
- rs->is_bad_directory = listbaddirs && node->is_bad_directory;
rs->is_bad_exit = listbadexits && node->is_bad_exit;
node->is_hs_dir = dirserv_thinks_router_is_hs_dir(ri, node, now);
rs->is_hs_dir = vote_on_hsdirs && node->is_hs_dir;
- if (!strcasecmp(ri->nickname, UNNAMED_ROUTER_NICKNAME))
- rs->is_named = rs->is_unnamed = 0;
+ rs->is_named = rs->is_unnamed = 0;
rs->published_on = ri->cache_info.published_on;
memcpy(rs->identity_digest, node->identity, DIGEST_LEN);
@@ -2352,6 +2098,21 @@ set_routerstatus_from_routerinfo(routerstatus_t *rs,
tor_addr_copy(&rs->ipv6_addr, &ri->ipv6_addr);
rs->ipv6_orport = ri->ipv6_orport;
}
+
+ /* Iff we are in a testing network, use TestingDirAuthVoteExit to
+ give out Exit flags, and TestingDirAuthVoteGuard to
+ give out Guard flags. */
+ if (options->TestingTorNetwork) {
+ if (routerset_contains_routerstatus(options->TestingDirAuthVoteExit,
+ rs, 0)) {
+ rs->is_exit = 1;
+ }
+
+ if (routerset_contains_routerstatus(options->TestingDirAuthVoteGuard,
+ rs, 0)) {
+ rs->is_possible_guard = 1;
+ }
+ }
}
/** Routerstatus <b>rs</b> is part of a group of routers that are on
@@ -2363,8 +2124,7 @@ clear_status_flags_on_sybil(routerstatus_t *rs)
{
rs->is_authority = rs->is_exit = rs->is_stable = rs->is_fast =
rs->is_flagged_running = rs->is_named = rs->is_valid =
- rs->is_hs_dir = rs->is_possible_guard = rs->is_bad_exit =
- rs->is_bad_directory = 0;
+ rs->is_hs_dir = rs->is_possible_guard = rs->is_bad_exit = 0;
/* FFFF we might want some mechanism to check later on if we
* missed zeroing any flags: it's easy to add a new flag but
* forget to add it to this clause. */
@@ -2562,9 +2322,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
smartlist_t *routers, *routerstatuses;
char identity_digest[DIGEST_LEN];
char signing_key_digest[DIGEST_LEN];
- int naming = options->NamingAuthoritativeDir;
int listbadexits = options->AuthDirListBadExits;
- int listbaddirs = options->AuthDirListBadDirs;
int vote_on_hsdirs = options->VoteOnHidServDirectoriesV2;
routerlist_t *rl = router_get_routerlist();
time_t now = time(NULL);
@@ -2656,7 +2414,7 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
vrs = tor_malloc_zero(sizeof(vote_routerstatus_t));
rs = &vrs->status;
set_routerstatus_from_routerinfo(rs, node, ri, now,
- naming, listbadexits, listbaddirs,
+ listbadexits,
vote_on_hsdirs);
if (digestmap_get(omit_as_sybil, ri->cache_info.identity_digest))
@@ -2738,14 +2496,8 @@ dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
0, SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
if (vote_on_reachability)
smartlist_add(v3_out->known_flags, tor_strdup("Running"));
- if (listbaddirs)
- smartlist_add(v3_out->known_flags, tor_strdup("BadDirectory"));
if (listbadexits)
smartlist_add(v3_out->known_flags, tor_strdup("BadExit"));
- if (naming) {
- smartlist_add(v3_out->known_flags, tor_strdup("Named"));
- smartlist_add(v3_out->known_flags, tor_strdup("Unnamed"));
- }
if (vote_on_hsdirs)
smartlist_add(v3_out->known_flags, tor_strdup("HSDir"));
smartlist_sort_strings(v3_out->known_flags);
diff --git a/src/or/dirserv.h b/src/or/dirserv.h
index 858e6e3a07..57cec3401f 100644
--- a/src/or/dirserv.h
+++ b/src/or/dirserv.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -34,10 +34,9 @@
int connection_dirserv_flushed_some(dir_connection_t *conn);
-int dirserv_add_own_fingerprint(const char *nickname, crypto_pk_t *pk);
+int dirserv_add_own_fingerprint(crypto_pk_t *pk);
int dirserv_load_fingerprint_file(void);
void dirserv_free_fingerprint_list(void);
-const char *dirserv_get_nickname_by_digest(const char *digest);
enum was_router_added_t dirserv_add_multiple_descriptors(
const char *desc, uint8_t purpose,
const char *source,
diff --git a/src/or/dirvote.c b/src/or/dirvote.c
index c7be343ca2..39505a4f9e 100644
--- a/src/or/dirvote.c
+++ b/src/or/dirvote.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define DIRVOTE_PRIVATE
@@ -64,7 +64,7 @@ STATIC char *
format_networkstatus_vote(crypto_pk_t *private_signing_key,
networkstatus_t *v3_ns)
{
- smartlist_t *chunks;
+ smartlist_t *chunks = smartlist_new();
const char *client_versions = NULL, *server_versions = NULL;
char fingerprint[FINGERPRINT_LEN+1];
char digest[DIGEST_LEN];
@@ -98,7 +98,6 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
server_versions_line = tor_strdup("");
}
- chunks = smartlist_new();
{
char published[ISO_TIME_LEN+1];
char va[ISO_TIME_LEN+1];
@@ -110,7 +109,8 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
char *params;
authority_cert_t *cert = v3_ns->cert;
char *methods =
- make_consensus_method_list(1, MAX_SUPPORTED_CONSENSUS_METHOD, " ");
+ make_consensus_method_list(MIN_SUPPORTED_CONSENSUS_METHOD,
+ MAX_SUPPORTED_CONSENSUS_METHOD, " ");
format_iso_time(published, v3_ns->published);
format_iso_time(va, v3_ns->valid_after);
format_iso_time(fu, v3_ns->fresh_until);
@@ -230,10 +230,9 @@ format_networkstatus_vote(crypto_pk_t *private_signing_key,
done:
tor_free(client_versions_line);
tor_free(server_versions_line);
- if (chunks) {
- SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
- smartlist_free(chunks);
- }
+
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
return status;
}
@@ -335,6 +334,9 @@ static int
compare_vote_rs(const vote_routerstatus_t *a, const vote_routerstatus_t *b)
{
int r;
+ tor_assert(a);
+ tor_assert(b);
+
if ((r = fast_memcmp(a->status.identity_digest, b->status.identity_digest,
DIGEST_LEN)))
return r;
@@ -432,6 +434,7 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
const tor_addr_port_t *most_alt_orport = NULL;
SMARTLIST_FOREACH_BEGIN(votes, vote_routerstatus_t *, rs) {
+ tor_assert(rs);
if (compare_vote_rs(most, rs) == 0 &&
!tor_addr_is_null(&rs->status.ipv6_addr)
&& rs->status.ipv6_orport) {
@@ -454,8 +457,7 @@ compute_routerstatus_consensus(smartlist_t *votes, int consensus_method,
smartlist_free(alt_orports);
}
- if (consensus_method >= MIN_METHOD_FOR_MICRODESC &&
- microdesc_digest256_out) {
+ if (microdesc_digest256_out) {
smartlist_t *digests = smartlist_new();
const char *best_microdesc_digest;
SMARTLIST_FOREACH_BEGIN(votes, vote_routerstatus_t *, rs) {
@@ -537,7 +539,8 @@ compute_consensus_method(smartlist_t *votes)
static int
consensus_method_is_supported(int method)
{
- return (method >= 1) && (method <= MAX_SUPPORTED_CONSENSUS_METHOD);
+ return (method >= MIN_SUPPORTED_CONSENSUS_METHOD) &&
+ (method <= MAX_SUPPORTED_CONSENSUS_METHOD);
}
/** Return a newly allocated string holding the numbers between low and high
@@ -601,13 +604,14 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
const int n_votes = smartlist_len(votes);
smartlist_t *output;
smartlist_t *param_list = smartlist_new();
+ (void) method;
/* We require that the parameter lists in the votes are well-formed: that
is, that their keywords are unique and sorted, and that their values are
between INT32_MIN and INT32_MAX inclusive. This should be guaranteed by
the parsing code. */
- vals = tor_malloc(sizeof(int)*n_votes);
+ vals = tor_calloc(n_votes, sizeof(int));
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
if (!v->net_params)
@@ -643,12 +647,13 @@ dirvote_compute_params(smartlist_t *votes, int method, int total_authorities)
next_param = NULL;
else
next_param = smartlist_get(param_list, param_sl_idx+1);
+ /* resolve spurious clang shallow analysis null pointer errors */
+ tor_assert(param);
if (!next_param || strncmp(next_param, param, cur_param_len)) {
/* We've reached the end of a series. */
/* Make sure enough authorities voted on this param, unless the
* the consensus method we use is too old for that. */
- if (method < MIN_METHOD_FOR_MAJORITY_PARAMS ||
- i > total_authorities/2 ||
+ if (i > total_authorities/2 ||
i >= MIN_VOTES_FOR_PARAM) {
int32_t median = median_int32(vals, i);
char *out_string = tor_malloc(64+cur_param_len);
@@ -1001,300 +1006,6 @@ networkstatus_compute_bw_weights_v10(smartlist_t *chunks, int64_t G,
I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
return 1;
}
-/**
- * This function computes the bandwidth weights for consensus method 9.
- *
- * It has been obsoleted in favor of consensus method 10.
- */
-static void
-networkstatus_compute_bw_weights_v9(smartlist_t *chunks, int64_t G, int64_t M,
- int64_t E, int64_t D, int64_t T,
- int64_t weight_scale)
-{
- int64_t Wgg = -1, Wgd = -1;
- int64_t Wmg = -1, Wme = -1, Wmd = -1;
- int64_t Wed = -1, Wee = -1;
- const char *casename;
-
- if (G <= 0 || M <= 0 || E <= 0 || D <= 0) {
- log_warn(LD_DIR, "Consensus with empty bandwidth: "
- "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
- " D="I64_FORMAT" T="I64_FORMAT,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- return;
- }
-
- /*
- * Computed from cases in 3.4.3 of dir-spec.txt
- *
- * 1. Neither are scarce
- * 2. Both Guard and Exit are scarce
- * a. R+D <= S
- * b. R+D > S
- * 3. One of Guard or Exit is scarce
- * a. S+D < T/3
- * b. S+D >= T/3
- */
- if (3*E >= T && 3*G >= T) { // E >= T/3 && G >= T/3
- bw_weights_error_t berr = 0;
- /* Case 1: Neither are scarce.
- *
- * Attempt to ensure that we have a large amount of exit bandwidth
- * in the middle position.
- */
- casename = "Case 1 (Wme*E = Wmd*D)";
- Wgg = (weight_scale*(D+E+G+M))/(3*G);
- if (D==0) Wmd = 0;
- else Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D);
- Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E);
- Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E);
- Wgd = 0;
- Wmg = weight_scale - Wgg;
- Wed = weight_scale - Wmd;
-
- berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed,
- weight_scale, G, M, E, D, T, 10, 1);
-
- if (berr) {
- log_warn(LD_DIR, "Bw Weights error %d for case %s. "
- "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
- " D="I64_FORMAT" T="I64_FORMAT,
- berr, casename,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- }
- } else if (3*E < T && 3*G < T) { // E < T/3 && G < T/3
- int64_t R = MIN(E, G);
- int64_t S = MAX(E, G);
- /*
- * Case 2: Both Guards and Exits are scarce
- * Balance D between E and G, depending upon
- * D capacity and scarcity.
- */
- if (R+D < S) { // Subcase a
- Wgg = weight_scale;
- Wee = weight_scale;
- Wmg = 0;
- Wme = 0;
- Wmd = 0;
- if (E < G) {
- casename = "Case 2a (E scarce)";
- Wed = weight_scale;
- Wgd = 0;
- } else { /* E >= G */
- casename = "Case 2a (G scarce)";
- Wed = 0;
- Wgd = weight_scale;
- }
- } else { // Subcase b: R+D > S
- bw_weights_error_t berr = 0;
- casename = "Case 2b (Wme*E == Wmd*D)";
- if (D != 0) {
- Wgg = weight_scale;
- Wgd = (weight_scale*(D + E - 2*G + M))/(3*D); // T/3 >= G (Ok)
- Wmd = (weight_scale*(D + E + G - 2*M))/(6*D); // T/3 >= M
- Wme = (weight_scale*(D + E + G - 2*M))/(6*E);
- Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E); // 2E+M >= T/3
- Wmg = 0;
- Wed = weight_scale - Wgd - Wmd;
-
- berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee, Wed,
- weight_scale, G, M, E, D, T, 10, 1);
- }
-
- if (D == 0 || berr) { // Can happen if M > T/3
- casename = "Case 2b (E=G)";
- Wgg = weight_scale;
- Wee = weight_scale;
- Wmg = 0;
- Wme = 0;
- Wmd = 0;
- if (D == 0) Wgd = 0;
- else Wgd = (weight_scale*(D+E-G))/(2*D);
- Wed = weight_scale - Wgd;
- berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
- Wed, weight_scale, G, M, E, D, T, 10, 1);
- }
- if (berr != BW_WEIGHTS_NO_ERROR &&
- berr != BW_WEIGHTS_BALANCE_MID_ERROR) {
- log_warn(LD_DIR, "Bw Weights error %d for case %s. "
- "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT
- " D="I64_FORMAT" T="I64_FORMAT,
- berr, casename,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- }
- }
- } else { // if (E < T/3 || G < T/3) {
- int64_t S = MIN(E, G);
- // Case 3: Exactly one of Guard or Exit is scarce
- if (!(3*E < T || 3*G < T) || !(3*G >= T || 3*E >= T)) {
- log_warn(LD_BUG,
- "Bw-Weights Case 3 but with G="I64_FORMAT" M="
- I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- }
-
- if (3*(S+D) < T) { // Subcase a: S+D < T/3
- if (G < E) {
- casename = "Case 3a (G scarce)";
- Wgg = Wgd = weight_scale;
- Wmd = Wed = Wmg = 0;
- // Minor subcase, if E is more scarce than M,
- // keep its bandwidth in place.
- if (E < M) Wme = 0;
- else Wme = (weight_scale*(E-M))/(2*E);
- Wee = weight_scale-Wme;
- } else { // G >= E
- casename = "Case 3a (E scarce)";
- Wee = Wed = weight_scale;
- Wmd = Wgd = Wme = 0;
- // Minor subcase, if G is more scarce than M,
- // keep its bandwidth in place.
- if (G < M) Wmg = 0;
- else Wmg = (weight_scale*(G-M))/(2*G);
- Wgg = weight_scale-Wmg;
- }
- } else { // Subcase b: S+D >= T/3
- bw_weights_error_t berr = 0;
- // D != 0 because S+D >= T/3
- if (G < E) {
- casename = "Case 3b (G scarce, Wme*E == Wmd*D)";
- Wgd = (weight_scale*(D + E - 2*G + M))/(3*D);
- Wmd = (weight_scale*(D + E + G - 2*M))/(6*D);
- Wme = (weight_scale*(D + E + G - 2*M))/(6*E);
- Wee = (weight_scale*(-D + 5*E - G + 2*M))/(6*E);
- Wgg = weight_scale;
- Wmg = 0;
- Wed = weight_scale - Wgd - Wmd;
-
- berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
- Wed, weight_scale, G, M, E, D, T, 10, 1);
- } else { // G >= E
- casename = "Case 3b (E scarce, Wme*E == Wmd*D)";
- Wgg = (weight_scale*(D + E + G + M))/(3*G);
- Wmd = (weight_scale*(2*D + 2*E - G - M))/(6*D);
- Wme = (weight_scale*(2*D + 2*E - G - M))/(6*E);
- Wee = (weight_scale*(-2*D + 4*E + G + M))/(6*E);
- Wgd = 0;
- Wmg = weight_scale - Wgg;
- Wed = weight_scale - Wmd;
-
- berr = networkstatus_check_weights(Wgg, Wgd, Wmg, Wme, Wmd, Wee,
- Wed, weight_scale, G, M, E, D, T, 10, 1);
- }
- if (berr) {
- log_warn(LD_DIR, "Bw Weights error %d for case %s. "
- "G="I64_FORMAT" M="I64_FORMAT
- " E="I64_FORMAT" D="I64_FORMAT" T="I64_FORMAT,
- berr, casename,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- }
- }
- }
-
- /* We cast down the weights to 32 bit ints on the assumption that
- * weight_scale is ~= 10000. We need to ensure a rogue authority
- * doesn't break this assumption to rig our weights */
- tor_assert(0 < weight_scale && weight_scale <= INT32_MAX);
-
- if (Wgg < 0 || Wgg > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wgg="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wgg),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
-
- Wgg = MAX(MIN(Wgg, weight_scale), 0);
- }
- if (Wgd < 0 || Wgd > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wgd="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wgd),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wgd = MAX(MIN(Wgd, weight_scale), 0);
- }
- if (Wmg < 0 || Wmg > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wmg="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wmg),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wmg = MAX(MIN(Wmg, weight_scale), 0);
- }
- if (Wme < 0 || Wme > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wme="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wme),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wme = MAX(MIN(Wme, weight_scale), 0);
- }
- if (Wmd < 0 || Wmd > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wmd="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wmd),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wmd = MAX(MIN(Wmd, weight_scale), 0);
- }
- if (Wee < 0 || Wee > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wee="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wee),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wee = MAX(MIN(Wee, weight_scale), 0);
- }
- if (Wed < 0 || Wed > weight_scale) {
- log_warn(LD_DIR, "Bw %s: Wed="I64_FORMAT"! G="I64_FORMAT
- " M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename, I64_PRINTF_ARG(Wed),
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
- Wed = MAX(MIN(Wed, weight_scale), 0);
- }
-
- // Add consensus weight keywords
- smartlist_add(chunks, tor_strdup("bandwidth-weights "));
- /*
- * Provide Wgm=Wgg, Wmm=1, Wem=Wee, Weg=Wed. May later determine
- * that middle nodes need different bandwidth weights for dirport traffic,
- * or that weird exit policies need special weight, or that bridges
- * need special weight.
- *
- * NOTE: This list is sorted.
- */
- smartlist_add_asprintf(chunks,
- "Wbd=%d Wbe=%d Wbg=%d Wbm=%d "
- "Wdb=%d "
- "Web=%d Wed=%d Wee=%d Weg=%d Wem=%d "
- "Wgb=%d Wgd=%d Wgg=%d Wgm=%d "
- "Wmb=%d Wmd=%d Wme=%d Wmg=%d Wmm=%d\n",
- (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale,
- (int)weight_scale,
- (int)weight_scale, (int)Wed, (int)Wee, (int)Wed, (int)Wee,
- (int)weight_scale, (int)Wgd, (int)Wgg, (int)Wgg,
- (int)weight_scale, (int)Wmd, (int)Wme, (int)Wmg, (int)weight_scale);
-
- log_notice(LD_CIRC, "Computed bandwidth weights for %s with v9: "
- "G="I64_FORMAT" M="I64_FORMAT" E="I64_FORMAT" D="I64_FORMAT
- " T="I64_FORMAT,
- casename,
- I64_PRINTF_ARG(G), I64_PRINTF_ARG(M), I64_PRINTF_ARG(E),
- I64_PRINTF_ARG(D), I64_PRINTF_ARG(T));
-}
/** Given a list of vote networkstatus_t in <b>votes</b>, our public
* authority <b>identity_key</b>, our private authority <b>signing_key</b>,
@@ -1346,18 +1057,18 @@ networkstatus_compute_consensus(smartlist_t *votes,
log_warn(LD_DIR, "The other authorities will use consensus method %d, "
"which I don't support. Maybe I should upgrade!",
consensus_method);
- consensus_method = 1;
+ consensus_method = MAX_SUPPORTED_CONSENSUS_METHOD;
}
/* Compute medians of time-related things, and figure out how many
* routers we might need to talk about. */
{
int n_votes = smartlist_len(votes);
- time_t *va_times = tor_malloc(n_votes * sizeof(time_t));
- time_t *fu_times = tor_malloc(n_votes * sizeof(time_t));
- time_t *vu_times = tor_malloc(n_votes * sizeof(time_t));
- int *votesec_list = tor_malloc(n_votes * sizeof(int));
- int *distsec_list = tor_malloc(n_votes * sizeof(int));
+ time_t *va_times = tor_calloc(n_votes, sizeof(time_t));
+ time_t *fu_times = tor_calloc(n_votes, sizeof(time_t));
+ time_t *vu_times = tor_calloc(n_votes, sizeof(time_t));
+ int *votesec_list = tor_calloc(n_votes, sizeof(int));
+ int *distsec_list = tor_calloc(n_votes, sizeof(int));
int n_versioning_clients = 0, n_versioning_servers = 0;
smartlist_t *combined_client_versions = smartlist_new();
smartlist_t *combined_server_versions = smartlist_new();
@@ -1437,10 +1148,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
flavor == FLAV_NS ? "" : " ",
flavor == FLAV_NS ? "" : flavor_name);
- if (consensus_method >= 2) {
- smartlist_add_asprintf(chunks, "consensus-method %d\n",
- consensus_method);
- }
+ smartlist_add_asprintf(chunks, "consensus-method %d\n",
+ consensus_method);
smartlist_add_asprintf(chunks,
"valid-after %s\n"
@@ -1457,14 +1166,12 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(flaglist);
}
- if (consensus_method >= MIN_METHOD_FOR_PARAMS) {
- params = dirvote_compute_params(votes, consensus_method,
- total_authorities);
- if (params) {
- smartlist_add(chunks, tor_strdup("params "));
- smartlist_add(chunks, params);
- smartlist_add(chunks, tor_strdup("\n"));
- }
+ params = dirvote_compute_params(votes, consensus_method,
+ total_authorities);
+ if (params) {
+ smartlist_add(chunks, tor_strdup("params "));
+ smartlist_add(chunks, params);
+ smartlist_add(chunks, tor_strdup("\n"));
}
/* Sort the votes. */
@@ -1478,8 +1185,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
e->digest = get_voter(v)->identity_digest;
e->is_legacy = 0;
smartlist_add(dir_sources, e);
- if (consensus_method >= 3 &&
- !tor_digest_is_zero(get_voter(v)->legacy_id_digest)) {
+ if (!tor_digest_is_zero(get_voter(v)->legacy_id_digest)) {
dir_src_ent_t *e_legacy = tor_malloc_zero(sizeof(dir_src_ent_t));
e_legacy->v = v;
e_legacy->digest = get_voter(v)->legacy_id_digest;
@@ -1495,9 +1201,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
networkstatus_t *v = e->v;
networkstatus_voter_info_t *voter = get_voter(v);
- if (e->is_legacy)
- tor_assert(consensus_method >= 2);
-
base16_encode(fingerprint, sizeof(fingerprint), e->digest, DIGEST_LEN);
base16_encode(votedigest, sizeof(votedigest), voter->vote_digest,
DIGEST_LEN);
@@ -1555,10 +1258,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
smartlist_t *chosen_flags = smartlist_new();
smartlist_t *versions = smartlist_new();
smartlist_t *exitsummaries = smartlist_new();
- uint32_t *bandwidths_kb = tor_malloc(sizeof(uint32_t) *
- smartlist_len(votes));
- uint32_t *measured_bws_kb = tor_malloc(sizeof(uint32_t) *
- smartlist_len(votes));
+ uint32_t *bandwidths_kb = tor_calloc(smartlist_len(votes),
+ sizeof(uint32_t));
+ uint32_t *measured_bws_kb = tor_calloc(smartlist_len(votes),
+ sizeof(uint32_t));
int num_bandwidths;
int num_mbws;
@@ -1570,7 +1273,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
* is the same flag as votes[j]->known_flags[b]. */
int *named_flag; /* Index of the flag "Named" for votes[j] */
int *unnamed_flag; /* Index of the flag "Unnamed" for votes[j] */
- int chosen_named_idx;
int n_authorities_measuring_bandwidth;
strmap_t *name_to_id_map = strmap_new();
@@ -1579,16 +1281,15 @@ networkstatus_compute_consensus(smartlist_t *votes,
memset(conflict, 0, sizeof(conflict));
memset(unknown, 0xff, sizeof(conflict));
- index = tor_malloc_zero(sizeof(int)*smartlist_len(votes));
- size = tor_malloc_zero(sizeof(int)*smartlist_len(votes));
- n_voter_flags = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
- n_flag_voters = tor_malloc_zero(sizeof(int) * smartlist_len(flags));
- flag_map = tor_malloc_zero(sizeof(int*) * smartlist_len(votes));
- named_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
- unnamed_flag = tor_malloc_zero(sizeof(int) * smartlist_len(votes));
+ index = tor_calloc(smartlist_len(votes), sizeof(int));
+ size = tor_calloc(smartlist_len(votes), sizeof(int));
+ n_voter_flags = tor_calloc(smartlist_len(votes), sizeof(int));
+ n_flag_voters = tor_calloc(smartlist_len(flags), sizeof(int));
+ flag_map = tor_calloc(smartlist_len(votes), sizeof(int *));
+ named_flag = tor_calloc(smartlist_len(votes), sizeof(int));
+ unnamed_flag = tor_calloc(smartlist_len(votes), sizeof(int));
for (i = 0; i < smartlist_len(votes); ++i)
unnamed_flag[i] = named_flag[i] = -1;
- chosen_named_idx = smartlist_string_pos(flags, "Named");
/* Build the flag indexes. Note that no vote can have more than 64 members
* for known_flags, so no value will be greater than 63, so it's safe to
@@ -1597,8 +1298,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
* that they're actually set before doing U64_LITERAL(1) << index with
* them.*/
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
- flag_map[v_sl_idx] = tor_malloc_zero(
- sizeof(int)*smartlist_len(v->known_flags));
+ flag_map[v_sl_idx] = tor_calloc(smartlist_len(v->known_flags),
+ sizeof(int));
if (smartlist_len(v->known_flags) > MAX_KNOWN_FLAGS_IN_VOTE) {
log_warn(LD_BUG, "Somehow, a vote has %d entries in known_flags",
smartlist_len(v->known_flags));
@@ -1618,7 +1319,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
} SMARTLIST_FOREACH_END(v);
/* Named and Unnamed get treated specially */
- if (consensus_method >= 2) {
+ {
SMARTLIST_FOREACH_BEGIN(votes, networkstatus_t *, v) {
uint64_t nf;
if (named_flag[v_sl_idx]<0)
@@ -1678,7 +1379,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
);
/* Now go through all the votes */
- flag_counts = tor_malloc(sizeof(int) * smartlist_len(flags));
+ flag_counts = tor_calloc(smartlist_len(flags), sizeof(int));
while (1) {
vote_routerstatus_t *rs;
routerstatus_t rs_out;
@@ -1787,10 +1488,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
strlcpy(rs_out.nickname, rs->status.nickname, sizeof(rs_out.nickname));
}
- if (consensus_method == 1) {
- is_named = chosen_named_idx >= 0 &&
- (!naming_conflict && flag_counts[chosen_named_idx]);
- } else {
+ {
const char *d = strmap_get_lc(name_to_id_map, rs_out.nickname);
if (!d) {
is_named = is_unnamed = 0;
@@ -1807,7 +1505,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
if (!strcmp(fl, "Named")) {
if (is_named)
smartlist_add(chosen_flags, (char*)fl);
- } else if (!strcmp(fl, "Unnamed") && consensus_method >= 2) {
+ } else if (!strcmp(fl, "Unnamed")) {
if (is_unnamed)
smartlist_add(chosen_flags, (char*)fl);
} else {
@@ -1827,7 +1525,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
/* Starting with consensus method 4 we do not list servers
* that are not running in a consensus. See Proposal 138 */
- if (consensus_method >= 4 && !is_running)
+ if (!is_running)
continue;
/* Pick the version. */
@@ -1839,11 +1537,11 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
/* Pick a bandwidth */
- if (consensus_method >= 6 && num_mbws > 2) {
+ if (num_mbws > 2) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 0;
rs_out.bandwidth_kb = median_uint32(measured_bws_kb, num_mbws);
- } else if (consensus_method >= 5 && num_bandwidths > 0) {
+ } else if (num_bandwidths > 0) {
rs_out.has_bandwidth = 1;
rs_out.bw_is_unmeasured = 1;
rs_out.bandwidth_kb = median_uint32(bandwidths_kb, num_bandwidths);
@@ -1857,11 +1555,9 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
/* Fix bug 2203: Do not count BadExit nodes as Exits for bw weights */
- if (consensus_method >= MIN_METHOD_TO_CUT_BADEXIT_WEIGHT) {
- is_exit = is_exit && !is_bad_exit;
- }
+ is_exit = is_exit && !is_bad_exit;
- if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS) {
+ {
if (rs_out.has_bandwidth) {
T += rs_out.bandwidth_kb;
if (is_exit && is_guard)
@@ -1892,7 +1588,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
* the policy that was most often listed in votes, again breaking
* ties like in the previous case.
*/
- if (consensus_method >= 5) {
+ {
/* Okay, go through all the votes for this router. We prepared
* that list previously */
const char *chosen_exitsummary = NULL;
@@ -1963,7 +1659,6 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
if (flavor == FLAV_MICRODESC &&
- consensus_method >= MIN_METHOD_FOR_MANDATORY_MICRODESC &&
tor_digest256_is_zero(microdesc_digest)) {
/* With no microdescriptor digest, we omit the entry entirely. */
continue;
@@ -2029,13 +1724,10 @@ networkstatus_compute_consensus(smartlist_t *votes,
tor_free(measured_bws_kb);
}
- if (consensus_method >= MIN_METHOD_FOR_FOOTER) {
- /* Starting with consensus method 9, we clearly mark the directory
- * footer region */
- smartlist_add(chunks, tor_strdup("directory-footer\n"));
- }
+ /* Mark the directory footer region */
+ smartlist_add(chunks, tor_strdup("directory-footer\n"));
- if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS) {
+ {
int64_t weight_scale = BW_WEIGHT_SCALE;
char *bw_weight_param = NULL;
@@ -2068,13 +1760,8 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
}
- if (consensus_method < 10) {
- networkstatus_compute_bw_weights_v9(chunks, G, M, E, D, T, weight_scale);
- added_weights = 1;
- } else {
- added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
- T, weight_scale);
- }
+ added_weights = networkstatus_compute_bw_weights_v10(chunks, G, M, E, D,
+ T, weight_scale);
}
/* Add a signature. */
@@ -2115,7 +1802,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
}
smartlist_add(chunks, signature);
- if (legacy_id_key_digest && legacy_signing_key && consensus_method >= 3) {
+ if (legacy_id_key_digest && legacy_signing_key) {
smartlist_add(chunks, tor_strdup("directory-signature "));
base16_encode(fingerprint, sizeof(fingerprint),
legacy_id_key_digest, DIGEST_LEN);
@@ -2151,7 +1838,7 @@ networkstatus_compute_consensus(smartlist_t *votes,
goto done;
}
// Verify balancing parameters
- if (consensus_method >= MIN_METHOD_FOR_BW_WEIGHTS && added_weights) {
+ if (added_weights) {
networkstatus_verify_bw_weights(c, consensus_method);
}
networkstatus_vote_free(c);
@@ -2275,8 +1962,11 @@ networkstatus_add_detached_signatures(networkstatus_t *target,
if (!sig->good_signature && !sig->bad_signature) {
cert = authority_cert_get_by_digests(sig->identity_digest,
sig->signing_key_digest);
- if (cert)
- networkstatus_check_document_signature(target, sig, cert);
+ if (cert) {
+ /* Not checking the return value here, since we are going to look
+ * at the status of sig->good_signature in a moment. */
+ (void) networkstatus_check_document_signature(target, sig, cert);
+ }
}
/* If this signature is good, or we don't have any signature yet,
@@ -3598,8 +3288,8 @@ dirvote_create_microdescriptor(const routerinfo_t *ri, int consensus_method)
{
smartlist_t *lst = microdescs_parse_from_string(output,
- output+strlen(output), 0,
- SAVED_NOWHERE);
+ output+strlen(output), 0,
+ SAVED_NOWHERE, NULL);
if (smartlist_len(lst) != 1) {
log_warn(LD_DIR, "We generated a microdescriptor we couldn't parse.");
SMARTLIST_FOREACH(lst, microdesc_t *, md, microdesc_free(md));
@@ -3660,7 +3350,7 @@ static const struct consensus_method_range_t {
int low;
int high;
} microdesc_consensus_methods[] = {
- {MIN_METHOD_FOR_MICRODESC, MIN_METHOD_FOR_A_LINES - 1},
+ {MIN_SUPPORTED_CONSENSUS_METHOD, MIN_METHOD_FOR_A_LINES - 1},
{MIN_METHOD_FOR_A_LINES, MIN_METHOD_FOR_P6_LINES - 1},
{MIN_METHOD_FOR_P6_LINES, MIN_METHOD_FOR_NTOR_KEY - 1},
{MIN_METHOD_FOR_NTOR_KEY, MIN_METHOD_FOR_ID_HASH_IN_MD - 1},
diff --git a/src/or/dirvote.h b/src/or/dirvote.h
index 4c57e43661..5d44ba4320 100644
--- a/src/or/dirvote.h
+++ b/src/or/dirvote.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -21,28 +21,12 @@
/** Smallest allowable voting interval. */
#define MIN_VOTE_INTERVAL 300
+/** The lowest consensus method that we currently support. */
+#define MIN_SUPPORTED_CONSENSUS_METHOD 13
+
/** The highest consensus method that we currently support. */
#define MAX_SUPPORTED_CONSENSUS_METHOD 18
-/** Lowest consensus method that contains a 'directory-footer' marker */
-#define MIN_METHOD_FOR_FOOTER 9
-
-/** Lowest consensus method that contains bandwidth weights */
-#define MIN_METHOD_FOR_BW_WEIGHTS 9
-
-/** Lowest consensus method that contains consensus params */
-#define MIN_METHOD_FOR_PARAMS 7
-
-/** Lowest consensus method that generates microdescriptors */
-#define MIN_METHOD_FOR_MICRODESC 8
-
-/** Lowest consensus method that doesn't count bad exits as exits for weight */
-#define MIN_METHOD_TO_CUT_BADEXIT_WEIGHT 11
-
-/** Lowest consensus method that ensures a majority of authorities voted
- * for a param. */
-#define MIN_METHOD_FOR_MAJORITY_PARAMS 12
-
/** Lowest consensus method where microdesc consensuses omit any entry
* with no microdesc. */
#define MIN_METHOD_FOR_MANDATORY_MICRODESC 13
@@ -116,8 +100,8 @@ const cached_dir_t *dirvote_get_vote(const char *fp, int flags);
void set_routerstatus_from_routerinfo(routerstatus_t *rs,
node_t *node,
routerinfo_t *ri, time_t now,
- int naming, int listbadexits,
- int listbaddirs, int vote_on_hsdirs);
+ int listbadexits,
+ int vote_on_hsdirs);
networkstatus_t *
dirserv_generate_networkstatus_vote_obj(crypto_pk_t *private_key,
authority_cert_t *cert);
diff --git a/src/or/dns.c b/src/or/dns.c
index a9c4318651..7bf64dc4ff 100644
--- a/src/or/dns.c
+++ b/src/or/dns.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -244,8 +244,8 @@ cached_resolve_hash(cached_resolve_t *a)
HT_PROTOTYPE(cache_map, cached_resolve_t, node, cached_resolve_hash,
cached_resolves_eq)
-HT_GENERATE(cache_map, cached_resolve_t, node, cached_resolve_hash,
- cached_resolves_eq, 0.6, malloc, realloc, free)
+HT_GENERATE2(cache_map, cached_resolve_t, node, cached_resolve_hash,
+ cached_resolves_eq, 0.6, tor_reallocarray_, tor_free_)
/** Initialize the DNS cache. */
static void
diff --git a/src/or/dns.h b/src/or/dns.h
index 022cd4ac63..cabbb9ba09 100644
--- a/src/or/dns.h
+++ b/src/or/dns.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/dnsserv.c b/src/or/dnsserv.c
index ecd45be77c..3d63874a65 100644
--- a/src/or/dnsserv.c
+++ b/src/or/dnsserv.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/dnsserv.h b/src/or/dnsserv.h
index 687a77e59e..c8074dfaa0 100644
--- a/src/or/dnsserv.h
+++ b/src/or/dnsserv.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/entrynodes.c b/src/or/entrynodes.c
index 8f105c7844..b18aabe1f4 100644
--- a/src/or/entrynodes.c
+++ b/src/or/entrynodes.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -156,21 +156,41 @@ entry_guard_set_status(entry_guard_t *e, const node_t *node,
/** Return true iff enough time has passed since we last tried to connect
* to the unreachable guard <b>e</b> that we're willing to try again. */
-static int
+STATIC int
entry_is_time_to_retry(const entry_guard_t *e, time_t now)
{
- long diff;
+ struct guard_retry_period_s {
+ time_t period_duration;
+ time_t interval_during_period;
+ };
+
+ struct guard_retry_period_s periods[] = {
+ { 6*60*60, 60*60 }, /* For first 6 hrs., retry hourly; */
+ { 3*24*60*60, 4*60*60 }, /* Then retry every 4 hrs. until the
+ 3-day mark; */
+ { 7*24*60*60, 18*60*60 }, /* After 3 days, retry every 18 hours until
+ 1 week mark. */
+ { TIME_MAX, 36*60*60 } /* After 1 week, retry every 36 hours. */
+ };
+
+ time_t ith_deadline_for_retry;
+ time_t unreachable_for;
+ unsigned i;
+
if (e->last_attempted < e->unreachable_since)
return 1;
- diff = now - e->unreachable_since;
- if (diff < 6*60*60)
- return now > (e->last_attempted + 60*60);
- else if (diff < 3*24*60*60)
- return now > (e->last_attempted + 4*60*60);
- else if (diff < 7*24*60*60)
- return now > (e->last_attempted + 18*60*60);
- else
- return now > (e->last_attempted + 36*60*60);
+
+ unreachable_for = now - e->unreachable_since;
+
+ for (i = 0; i < ARRAY_LENGTH(periods); i++) {
+ if (unreachable_for <= periods[i].period_duration) {
+ ith_deadline_for_retry = e->last_attempted +
+ periods[i].interval_during_period;
+
+ return (now > ith_deadline_for_retry);
+ }
+ }
+ return 0;
}
/** Return the node corresponding to <b>e</b>, if <b>e</b> is
@@ -453,9 +473,20 @@ add_an_entry_guard(const node_t *chosen, int reset_status, int prepend,
STATIC int
decide_num_guards(const or_options_t *options, int for_directory)
{
- if (for_directory && options->NumDirectoryGuards != 0)
- return options->NumDirectoryGuards;
- return options->NumEntryGuards;
+ if (for_directory) {
+ int answer;
+ if (options->NumDirectoryGuards != 0)
+ return options->NumDirectoryGuards;
+ answer = networkstatus_get_param(NULL, "NumDirectoryGuards", 0, 0, 10);
+ if (answer) /* non-zero means use the consensus value */
+ return answer;
+ }
+
+ if (options->NumEntryGuards)
+ return options->NumEntryGuards;
+
+ /* Use the value from the consensus, or 3 if no guidance. */
+ return networkstatus_get_param(NULL, "NumEntryGuards", 3, 1, 10);
}
/** If the use of entry guards is configured, choose more entry guards
@@ -856,6 +887,7 @@ entry_guards_set_from_config(const or_options_t *options)
{
smartlist_t *entry_nodes, *worse_entry_nodes, *entry_fps;
smartlist_t *old_entry_guards_on_list, *old_entry_guards_not_on_list;
+ const int numentryguards = decide_num_guards(options, 0);
tor_assert(entry_guards);
should_add_entry_nodes = 0;
@@ -924,7 +956,7 @@ entry_guards_set_from_config(const or_options_t *options)
/* Next, the rest of EntryNodes */
SMARTLIST_FOREACH_BEGIN(entry_nodes, const node_t *, node) {
add_an_entry_guard(node, 0, 0, 1, 0);
- if (smartlist_len(entry_guards) > options->NumEntryGuards * 10)
+ if (smartlist_len(entry_guards) > numentryguards * 10)
break;
} SMARTLIST_FOREACH_END(node);
log_notice(LD_GENERAL, "%d entries in guards", smartlist_len(entry_guards));
@@ -971,7 +1003,8 @@ node_understands_microdescriptors(const node_t *node)
}
/** Return true iff <b>node</b> is able to answer directory questions
- * of type <b>dirinfo</b>. */
+ * of type <b>dirinfo</b>. Always returns true if <b>dirinfo</b> is
+ * NO_DIRINFO (zero). */
static int
node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
{
@@ -993,13 +1026,13 @@ node_can_handle_dirinfo(const node_t *node, dirinfo_type_t dirinfo)
* <b>state</b> is non-NULL, this is for a specific circuit --
* make sure not to pick this circuit's exit or any node in the
* exit's family. If <b>state</b> is NULL, we're looking for a random
- * guard (likely a bridge). If <b>dirinfo</b> is not NO_DIRINFO, then
- * only select from nodes that know how to answer directory questions
+ * guard (likely a bridge). If <b>dirinfo</b> is not NO_DIRINFO (zero),
+ * then only select from nodes that know how to answer directory questions
* of that type. */
const node_t *
choose_random_entry(cpath_build_state_t *state)
{
- return choose_random_entry_impl(state, 0, 0, NULL);
+ return choose_random_entry_impl(state, 0, NO_DIRINFO, NULL);
}
/** Pick a live (up and listed) directory guard from entry_guards for
@@ -1107,7 +1140,9 @@ populate_live_entry_guards(smartlist_t *live_entry_guards,
* If <b>for_directory</b> is set, we are looking for a directory guard.
*
* <b>dirinfo_type</b> contains the kind of directory information we
- * are looking for in our node.
+ * are looking for in our node, or NO_DIRINFO (zero) if we are not
+ * looking for any particular directory information (when set to
+ * NO_DIRINFO, the <b>dirinfo_type</b> filter is ignored).
*
* If <b>n_options_out</b> is set, we set it to the number of
* candidate guard nodes we had before picking a specific guard node.
@@ -2259,6 +2294,13 @@ learned_bridge_descriptor(routerinfo_t *ri, int from_cache)
node = node_get_mutable_by_id(ri->cache_info.identity_digest);
tor_assert(node);
rewrite_node_address_for_bridge(bridge, node);
+ if (tor_digest_is_zero(bridge->identity)) {
+ memcpy(bridge->identity,ri->cache_info.identity_digest, DIGEST_LEN);
+ log_notice(LD_DIR, "Learned identity %s for bridge at %s:%d",
+ hex_str(bridge->identity, DIGEST_LEN),
+ fmt_and_decorate_addr(&bridge->addr),
+ (int) bridge->port);
+ }
add_an_entry_guard(node, 1, 1, 0, 0);
log_notice(LD_DIR, "new bridge descriptor '%s' (%s): %s", ri->nickname,
diff --git a/src/or/entrynodes.h b/src/or/entrynodes.h
index 8b5ffba7b1..5416398430 100644
--- a/src/or/entrynodes.h
+++ b/src/or/entrynodes.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -104,6 +104,9 @@ typedef enum {
STATIC const node_t *entry_is_live(const entry_guard_t *e,
entry_is_live_flags_t flags,
const char **msg);
+
+STATIC int entry_is_time_to_retry(const entry_guard_t *e, time_t now);
+
#endif
void remove_all_entry_guards(void);
diff --git a/src/or/eventdns_tor.h b/src/or/eventdns_tor.h
index 69662281bc..b135a534fc 100644
--- a/src/or/eventdns_tor.h
+++ b/src/or/eventdns_tor.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_EVENTDNS_TOR_H
diff --git a/src/or/ext_orport.c b/src/or/ext_orport.c
index 0d28a9199a..9b550ee90e 100644
--- a/src/or/ext_orport.c
+++ b/src/or/ext_orport.c
@@ -143,6 +143,7 @@ init_ext_or_cookie_authentication(int is_enabled)
fname = get_ext_or_auth_cookie_file_name();
retval = init_cookie_authentication(fname, EXT_OR_PORT_AUTH_COOKIE_HEADER,
EXT_OR_PORT_AUTH_COOKIE_HEADER_LEN,
+ get_options()->ExtORPortCookieAuthFileGroupReadable,
&ext_or_auth_cookie,
&ext_or_auth_cookie_is_set);
tor_free(fname);
diff --git a/src/or/ext_orport.h b/src/or/ext_orport.h
index ce45e5f418..277bbfdbcf 100644
--- a/src/or/ext_orport.h
+++ b/src/or/ext_orport.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef EXT_ORPORT_H
diff --git a/src/or/fp_pair.c b/src/or/fp_pair.c
index 55e4c89a42..fc7d107ba7 100644
--- a/src/or/fp_pair.c
+++ b/src/or/fp_pair.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -42,9 +42,9 @@ fp_pair_map_entry_hash(const fp_pair_map_entry_t *a)
HT_PROTOTYPE(fp_pair_map_impl, fp_pair_map_entry_s, node,
fp_pair_map_entry_hash, fp_pair_map_entries_eq)
-HT_GENERATE(fp_pair_map_impl, fp_pair_map_entry_s, node,
- fp_pair_map_entry_hash, fp_pair_map_entries_eq,
- 0.6, tor_malloc, tor_realloc, tor_free)
+HT_GENERATE2(fp_pair_map_impl, fp_pair_map_entry_s, node,
+ fp_pair_map_entry_hash, fp_pair_map_entries_eq,
+ 0.6, tor_reallocarray_, tor_free_)
/** Constructor to create a new empty map from fp_pair_t to void *
*/
diff --git a/src/or/fp_pair.h b/src/or/fp_pair.h
index 89f664a813..67b94fb6b4 100644
--- a/src/or/fp_pair.h
+++ b/src/or/fp_pair.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/geoip.c b/src/or/geoip.c
index f722bac468..c02343d489 100644
--- a/src/or/geoip.c
+++ b/src/or/geoip.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -58,8 +58,8 @@ static char geoip6_digest[DIGEST_LEN];
/** Return the index of the <b>country</b>'s entry in the GeoIP
* country list if it is a valid 2-letter country code, otherwise
* return -1. */
-country_t
-geoip_get_country(const char *country)
+MOCK_IMPL(country_t,
+geoip_get_country,(const char *country))
{
void *idxplus1_;
intptr_t idx;
@@ -396,8 +396,8 @@ geoip_get_country_by_ipv6(const struct in6_addr *addr)
* the 'unknown country'. The return value will always be less than
* geoip_get_n_countries(). To decode it, call geoip_get_country_name().
*/
-int
-geoip_get_country_by_addr(const tor_addr_t *addr)
+MOCK_IMPL(int,
+geoip_get_country_by_addr,(const tor_addr_t *addr))
{
if (tor_addr_family(addr) == AF_INET) {
return geoip_get_country_by_ipv4(tor_addr_to_ipv4h(addr));
@@ -409,8 +409,8 @@ geoip_get_country_by_addr(const tor_addr_t *addr)
}
/** Return the number of countries recognized by the GeoIP country list. */
-int
-geoip_get_n_countries(void)
+MOCK_IMPL(int,
+geoip_get_n_countries,(void))
{
if (!geoip_countries)
init_geoip_countries();
@@ -430,8 +430,8 @@ geoip_get_country_name(country_t num)
}
/** Return true iff we have loaded a GeoIP database.*/
-int
-geoip_is_loaded(sa_family_t family)
+MOCK_IMPL(int,
+geoip_is_loaded,(sa_family_t family))
{
tor_assert(family == AF_INET || family == AF_INET6);
if (geoip_countries == NULL)
@@ -506,8 +506,8 @@ clientmap_entries_eq(const clientmap_entry_t *a, const clientmap_entry_t *b)
HT_PROTOTYPE(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
clientmap_entries_eq);
-HT_GENERATE(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
- clientmap_entries_eq, 0.6, malloc, realloc, free);
+HT_GENERATE2(clientmap, clientmap_entry_t, node, clientmap_entry_hash,
+ clientmap_entries_eq, 0.6, tor_reallocarray_, tor_free_)
/** Free all storage held by <b>ent</b>. */
static void
@@ -720,8 +720,8 @@ dirreq_map_ent_hash(const dirreq_map_entry_t *entry)
HT_PROTOTYPE(dirreqmap, dirreq_map_entry_t, node, dirreq_map_ent_hash,
dirreq_map_ent_eq);
-HT_GENERATE(dirreqmap, dirreq_map_entry_t, node, dirreq_map_ent_hash,
- dirreq_map_ent_eq, 0.6, malloc, realloc, free);
+HT_GENERATE2(dirreqmap, dirreq_map_entry_t, node, dirreq_map_ent_hash,
+ dirreq_map_ent_eq, 0.6, tor_reallocarray_, tor_free_)
/** Helper: Put <b>entry</b> into map of directory requests using
* <b>type</b> and <b>dirreq_id</b> as key parts. If there is
@@ -963,7 +963,7 @@ geoip_get_dirreq_history(dirreq_type_t type)
/* We may have rounded 'completed' up. Here we want to use the
* real value. */
complete = smartlist_len(dirreq_completed);
- dltimes = tor_malloc_zero(sizeof(uint32_t) * complete);
+ dltimes = tor_calloc(complete, sizeof(uint32_t));
SMARTLIST_FOREACH_BEGIN(dirreq_completed, dirreq_map_entry_t *, ent) {
uint32_t bytes_per_second;
uint32_t time_diff = (uint32_t) tv_mdiff(&ent->request_time,
@@ -1033,7 +1033,7 @@ geoip_get_client_history(geoip_client_action_t action,
if (!geoip_is_loaded(AF_INET) && !geoip_is_loaded(AF_INET6))
return -1;
- counts = tor_malloc_zero(sizeof(unsigned)*n_countries);
+ counts = tor_calloc(n_countries, sizeof(unsigned));
HT_FOREACH(ent, clientmap, &client_history) {
int country;
if ((*ent)->action != (int)action)
diff --git a/src/or/geoip.h b/src/or/geoip.h
index b9b53c3006..cec19ea564 100644
--- a/src/or/geoip.h
+++ b/src/or/geoip.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -21,12 +21,12 @@ STATIC int geoip_get_country_by_ipv6(const struct in6_addr *addr);
#endif
int should_record_bridge_info(const or_options_t *options);
int geoip_load_file(sa_family_t family, const char *filename);
-int geoip_get_country_by_addr(const tor_addr_t *addr);
-int geoip_get_n_countries(void);
+MOCK_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr));
+MOCK_DECL(int, geoip_get_n_countries, (void));
const char *geoip_get_country_name(country_t num);
-int geoip_is_loaded(sa_family_t family);
+MOCK_DECL(int, geoip_is_loaded, (sa_family_t family));
const char *geoip_db_digest(sa_family_t family);
-country_t geoip_get_country(const char *countrycode);
+MOCK_DECL(country_t, geoip_get_country, (const char *countrycode));
void geoip_note_client_seen(geoip_client_action_t action,
const tor_addr_t *addr, const char *transport_name,
diff --git a/src/or/hibernate.c b/src/or/hibernate.c
index c433ac1be9..4f0660c2dc 100644
--- a/src/or/hibernate.c
+++ b/src/or/hibernate.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -410,6 +410,17 @@ configure_accounting(time_t now)
accounting_set_wakeup_time();
}
+/** Return the relevant number of bytes sent/received this interval
+ * based on the set AccountingRule */
+static uint64_t
+get_accounting_bytes(void)
+{
+ if (get_options()->AccountingRule == ACCT_SUM)
+ return n_bytes_read_in_interval+n_bytes_written_in_interval;
+ else
+ return MAX(n_bytes_read_in_interval, n_bytes_written_in_interval);
+}
+
/** Set expected_bandwidth_usage based on how much we sent/received
* per minute last interval (if we were up for at least 30 minutes),
* or based on our declared bandwidth otherwise. */
@@ -421,6 +432,11 @@ update_expected_bandwidth(void)
uint64_t max_configured = (options->RelayBandwidthRate > 0 ?
options->RelayBandwidthRate :
options->BandwidthRate) * 60;
+ /* max_configured is the larger of bytes read and bytes written
+ * If we are accounting based on sum, worst case is both are
+ * at max, doubling the expected sum of bandwidth */
+ if (get_options()->AccountingRule == ACCT_SUM)
+ max_configured *= 2;
#define MIN_TIME_FOR_MEASUREMENT (1800)
@@ -439,8 +455,7 @@ update_expected_bandwidth(void)
* doesn't know to store soft-limit info. Just take rate at which
* we were reading/writing in the last interval as our expected rate.
*/
- uint64_t used = MAX(n_bytes_written_in_interval,
- n_bytes_read_in_interval);
+ uint64_t used = get_accounting_bytes();
expected = used / (n_seconds_active_in_interval / 60);
} else {
/* If we haven't gotten enough data last interval, set 'expected'
@@ -715,8 +730,7 @@ hibernate_hard_limit_reached(void)
uint64_t hard_limit = get_options()->AccountingMax;
if (!hard_limit)
return 0;
- return n_bytes_read_in_interval >= hard_limit
- || n_bytes_written_in_interval >= hard_limit;
+ return get_accounting_bytes() >= hard_limit;
}
/** Return true iff we have sent/received almost all the bytes we are willing
@@ -747,8 +761,7 @@ hibernate_soft_limit_reached(void)
if (!soft_limit)
return 0;
- return n_bytes_read_in_interval >= soft_limit
- || n_bytes_written_in_interval >= soft_limit;
+ return get_accounting_bytes() >= soft_limit;
}
/** Called when we get a SIGINT, or when bandwidth soft limit is
@@ -772,8 +785,7 @@ hibernate_begin(hibernate_state_t new_state, time_t now)
hibernate_state == HIBERNATE_STATE_LIVE) {
soft_limit_hit_at = now;
n_seconds_to_hit_soft_limit = n_seconds_active_in_interval;
- n_bytes_at_soft_limit = MAX(n_bytes_read_in_interval,
- n_bytes_written_in_interval);
+ n_bytes_at_soft_limit = get_accounting_bytes();
}
/* close listeners. leave control listener(s). */
@@ -1003,13 +1015,22 @@ getinfo_helper_accounting(control_connection_t *conn,
U64_PRINTF_ARG(n_bytes_written_in_interval));
} else if (!strcmp(question, "accounting/bytes-left")) {
uint64_t limit = get_options()->AccountingMax;
- uint64_t read_left = 0, write_left = 0;
- if (n_bytes_read_in_interval < limit)
- read_left = limit - n_bytes_read_in_interval;
- if (n_bytes_written_in_interval < limit)
- write_left = limit - n_bytes_written_in_interval;
- tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
- U64_PRINTF_ARG(read_left), U64_PRINTF_ARG(write_left));
+ if (get_options()->AccountingRule == ACCT_SUM) {
+ uint64_t total_left = 0;
+ uint64_t total_bytes = get_accounting_bytes();
+ if (total_bytes < limit)
+ total_left = limit - total_bytes;
+ tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
+ U64_PRINTF_ARG(total_left), U64_PRINTF_ARG(total_left));
+ } else {
+ uint64_t read_left = 0, write_left = 0;
+ if (n_bytes_read_in_interval < limit)
+ read_left = limit - n_bytes_read_in_interval;
+ if (n_bytes_written_in_interval < limit)
+ write_left = limit - n_bytes_written_in_interval;
+ tor_asprintf(answer, U64_FORMAT" "U64_FORMAT,
+ U64_PRINTF_ARG(read_left), U64_PRINTF_ARG(write_left));
+ }
} else if (!strcmp(question, "accounting/interval-start")) {
*answer = tor_malloc(ISO_TIME_LEN+1);
format_iso_time(*answer, interval_start_time);
diff --git a/src/or/hibernate.h b/src/or/hibernate.h
index 38ecb75129..0616e11c57 100644
--- a/src/or/hibernate.h
+++ b/src/or/hibernate.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -28,6 +28,7 @@ void consider_hibernation(time_t now);
int getinfo_helper_accounting(control_connection_t *conn,
const char *question, char **answer,
const char **errmsg);
+uint64_t get_accounting_max_total(void);
#ifdef HIBERNATE_PRIVATE
/** Possible values of hibernate_state */
diff --git a/src/or/include.am b/src/or/include.am
index 47bdd09901..0f53f007f0 100644
--- a/src/or/include.am
+++ b/src/or/include.am
@@ -23,12 +23,6 @@ else
evdns_source=src/ext/eventdns.c
endif
-if CURVE25519_ENABLED
-onion_ntor_source=src/or/onion_ntor.c
-else
-onion_ntor_source=
-endif
-
LIBTOR_A_SOURCES = \
src/or/addressmap.c \
src/or/buffers.c \
@@ -82,9 +76,9 @@ LIBTOR_A_SOURCES = \
src/or/routerset.c \
src/or/statefile.c \
src/or/status.c \
+ src/or/onion_ntor.c \
$(evdns_source) \
$(tor_platform_source) \
- $(onion_ntor_source) \
src/or/config_codedigest.c
src_or_libtor_a_SOURCES = $(LIBTOR_A_SOURCES)
diff --git a/src/or/main.c b/src/or/main.c
index c7b532bbab..5a4e0a3e2d 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -28,6 +28,7 @@
#include "connection_or.h"
#include "control.h"
#include "cpuworker.h"
+#include "crypto_s2k.h"
#include "directory.h"
#include "dirserv.h"
#include "dirvote.h"
@@ -2674,11 +2675,11 @@ do_hash_password(void)
{
char output[256];
- char key[S2K_SPECIFIER_LEN+DIGEST_LEN];
+ char key[S2K_RFC2440_SPECIFIER_LEN+DIGEST_LEN];
- crypto_rand(key, S2K_SPECIFIER_LEN-1);
- key[S2K_SPECIFIER_LEN-1] = (uint8_t)96; /* Hash 64 K of data. */
- secret_to_key(key+S2K_SPECIFIER_LEN, DIGEST_LEN,
+ crypto_rand(key, S2K_RFC2440_SPECIFIER_LEN-1);
+ key[S2K_RFC2440_SPECIFIER_LEN-1] = (uint8_t)96; /* Hash 64 K of data. */
+ secret_to_key_rfc2440(key+S2K_RFC2440_SPECIFIER_LEN, DIGEST_LEN,
get_options()->command_arg, strlen(get_options()->command_arg),
key);
base16_encode(output, sizeof(output), key, sizeof(key));
@@ -2733,43 +2734,47 @@ sandbox_init_filter(void)
sandbox_cfg_allow_openat_filename(&cfg,
get_datadir_fname("cached-status"));
- sandbox_cfg_allow_open_filename_array(&cfg,
- get_datadir_fname("cached-certs"),
- get_datadir_fname("cached-certs.tmp"),
- get_datadir_fname("cached-consensus"),
- get_datadir_fname("cached-consensus.tmp"),
- get_datadir_fname("unverified-consensus"),
- get_datadir_fname("unverified-consensus.tmp"),
- get_datadir_fname("unverified-microdesc-consensus"),
- get_datadir_fname("unverified-microdesc-consensus.tmp"),
- get_datadir_fname("cached-microdesc-consensus"),
- get_datadir_fname("cached-microdesc-consensus.tmp"),
- get_datadir_fname("cached-microdescs"),
- get_datadir_fname("cached-microdescs.tmp"),
- get_datadir_fname("cached-microdescs.new"),
- get_datadir_fname("cached-microdescs.new.tmp"),
- get_datadir_fname("cached-descriptors"),
- get_datadir_fname("cached-descriptors.new"),
- get_datadir_fname("cached-descriptors.tmp"),
- get_datadir_fname("cached-descriptors.new.tmp"),
- get_datadir_fname("cached-descriptors.tmp.tmp"),
- get_datadir_fname("cached-extrainfo"),
- get_datadir_fname("cached-extrainfo.new"),
- get_datadir_fname("cached-extrainfo.tmp"),
- get_datadir_fname("cached-extrainfo.new.tmp"),
- get_datadir_fname("cached-extrainfo.tmp.tmp"),
- get_datadir_fname("state.tmp"),
- get_datadir_fname("unparseable-desc.tmp"),
- get_datadir_fname("unparseable-desc"),
- get_datadir_fname("v3-status-votes"),
- get_datadir_fname("v3-status-votes.tmp"),
- tor_strdup("/dev/srandom"),
- tor_strdup("/dev/urandom"),
- tor_strdup("/dev/random"),
- tor_strdup("/etc/hosts"),
- tor_strdup("/proc/meminfo"),
- NULL, 0
- );
+#define OPEN(name) \
+ sandbox_cfg_allow_open_filename(&cfg, tor_strdup(name))
+
+#define OPEN_DATADIR(name) \
+ sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname(name))
+
+#define OPEN_DATADIR2(name, name2) \
+ sandbox_cfg_allow_open_filename(&cfg, get_datadir_fname2((name), (name2)))
+
+#define OPEN_DATADIR_SUFFIX(name, suffix) do { \
+ OPEN_DATADIR(name); \
+ OPEN_DATADIR(name suffix); \
+ } while (0)
+
+#define OPEN_DATADIR2_SUFFIX(name, name2, suffix) do { \
+ OPEN_DATADIR2(name, name2); \
+ OPEN_DATADIR2(name, name2 suffix); \
+ } while (0)
+
+ OPEN_DATADIR_SUFFIX("cached-certs", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-consensus", ".tmp");
+ OPEN_DATADIR_SUFFIX("unverified-consensus", ".tmp");
+ OPEN_DATADIR_SUFFIX("unverified-microdesc-consensus", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-microdesc-consensus", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-microdescs", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-microdescs.new", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-descriptors", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-descriptors.new", ".tmp");
+ OPEN_DATADIR("cached-descriptors.tmp.tmp");
+ OPEN_DATADIR_SUFFIX("cached-extrainfo", ".tmp");
+ OPEN_DATADIR_SUFFIX("cached-extrainfo.new", ".tmp");
+ OPEN_DATADIR("cached-extrainfo.tmp.tmp");
+ OPEN_DATADIR_SUFFIX("state", ".tmp");
+ OPEN_DATADIR_SUFFIX("unparseable-desc", ".tmp");
+ OPEN_DATADIR_SUFFIX("v3-status-votes", ".tmp");
+ OPEN("/dev/srandom");
+ OPEN("/dev/urandom");
+ OPEN("/dev/random");
+ OPEN("/etc/hosts");
+ OPEN("/proc/meminfo");
+
if (options->ServerDNSResolvConfFile)
sandbox_cfg_allow_open_filename(&cfg,
tor_strdup(options->ServerDNSResolvConfFile));
@@ -2810,14 +2815,17 @@ sandbox_init_filter(void)
RENAME_SUFFIX("unparseable-desc", ".tmp");
RENAME_SUFFIX("v3-status-votes", ".tmp");
- sandbox_cfg_allow_stat_filename_array(&cfg,
- get_datadir_fname(NULL),
- get_datadir_fname("lock"),
- get_datadir_fname("state"),
- get_datadir_fname("router-stability"),
- get_datadir_fname("cached-extrainfo.new"),
- NULL, 0
- );
+#define STAT_DATADIR(name) \
+ sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname(name))
+
+#define STAT_DATADIR2(name, name2) \
+ sandbox_cfg_allow_stat_filename(&cfg, get_datadir_fname2((name), (name2)))
+
+ STAT_DATADIR(NULL);
+ STAT_DATADIR("lock");
+ STAT_DATADIR("state");
+ STAT_DATADIR("router-stability");
+ STAT_DATADIR("cached-extrainfo.new");
{
smartlist_t *files = smartlist_new();
@@ -2839,7 +2847,8 @@ sandbox_init_filter(void)
sandbox_cfg_allow_rename(&cfg,
tor_strdup(tmp_name), tor_strdup(file_name));
/* steals references */
- sandbox_cfg_allow_open_filename_array(&cfg, file_name, tmp_name, NULL);
+ sandbox_cfg_allow_open_filename(&cfg, file_name);
+ sandbox_cfg_allow_open_filename(&cfg, tmp_name);
});
SMARTLIST_FOREACH(dirs, char *, dir, {
/* steals reference */
@@ -2866,38 +2875,28 @@ sandbox_init_filter(void)
// orport
if (server_mode(get_options())) {
- sandbox_cfg_allow_open_filename_array(&cfg,
- get_datadir_fname2("keys", "secret_id_key"),
- get_datadir_fname2("keys", "secret_onion_key"),
- get_datadir_fname2("keys", "secret_onion_key_ntor"),
- get_datadir_fname2("keys", "secret_onion_key_ntor.tmp"),
- get_datadir_fname2("keys", "secret_id_key.old"),
- get_datadir_fname2("keys", "secret_onion_key.old"),
- get_datadir_fname2("keys", "secret_onion_key_ntor.old"),
- get_datadir_fname2("keys", "secret_onion_key.tmp"),
- get_datadir_fname2("keys", "secret_id_key.tmp"),
- get_datadir_fname2("stats", "bridge-stats"),
- get_datadir_fname2("stats", "bridge-stats.tmp"),
- get_datadir_fname2("stats", "dirreq-stats"),
- get_datadir_fname2("stats", "dirreq-stats.tmp"),
- get_datadir_fname2("stats", "entry-stats"),
- get_datadir_fname2("stats", "entry-stats.tmp"),
- get_datadir_fname2("stats", "exit-stats"),
- get_datadir_fname2("stats", "exit-stats.tmp"),
- get_datadir_fname2("stats", "buffer-stats"),
- get_datadir_fname2("stats", "buffer-stats.tmp"),
- get_datadir_fname2("stats", "conn-stats"),
- get_datadir_fname2("stats", "conn-stats.tmp"),
- get_datadir_fname("approved-routers"),
- get_datadir_fname("fingerprint"),
- get_datadir_fname("fingerprint.tmp"),
- get_datadir_fname("hashed-fingerprint"),
- get_datadir_fname("hashed-fingerprint.tmp"),
- get_datadir_fname("router-stability"),
- get_datadir_fname("router-stability.tmp"),
- tor_strdup("/etc/resolv.conf"),
- NULL, 0
- );
+
+ OPEN_DATADIR2_SUFFIX("keys", "secret_id_key", "tmp");
+ OPEN_DATADIR2_SUFFIX("keys", "secret_onion_key", ".tmp");
+ OPEN_DATADIR2_SUFFIX("keys", "secret_onion_key_ntor", ".tmp");
+ OPEN_DATADIR2("keys", "secret_id_key.old");
+ OPEN_DATADIR2("keys", "secret_onion_key.old");
+ OPEN_DATADIR2("keys", "secret_onion_key_ntor.old");
+
+ OPEN_DATADIR2_SUFFIX("stats", "bridge-stats", ".tmp");
+ OPEN_DATADIR2_SUFFIX("stats", "dirreq-stats", ".tmp");
+
+ OPEN_DATADIR2_SUFFIX("stats", "entry-stats", ".tmp");
+ OPEN_DATADIR2_SUFFIX("stats", "exit-stats", ".tmp");
+ OPEN_DATADIR2_SUFFIX("stats", "buffer-stats", ".tmp");
+ OPEN_DATADIR2_SUFFIX("stats", "conn-stats", ".tmp");
+
+ OPEN_DATADIR("approved-routers");
+ OPEN_DATADIR_SUFFIX("fingerprint", ".tmp");
+ OPEN_DATADIR_SUFFIX("hashed-fingerprint", ".tmp");
+ OPEN_DATADIR_SUFFIX("router-stability", ".tmp");
+
+ OPEN("/etc/resolv.conf");
RENAME_SUFFIX("fingerprint", ".tmp");
RENAME_SUFFIX2("keys", "secret_onion_key_ntor", ".tmp");
@@ -2921,12 +2920,9 @@ sandbox_init_filter(void)
get_datadir_fname2("keys", "secret_onion_key_ntor"),
get_datadir_fname2("keys", "secret_onion_key_ntor.old"));
- sandbox_cfg_allow_stat_filename_array(&cfg,
- get_datadir_fname("keys"),
- get_datadir_fname("stats"),
- get_datadir_fname2("stats", "dirreq-stats"),
- NULL, 0
- );
+ STAT_DATADIR("keys");
+ STAT_DATADIR("stats");
+ STAT_DATADIR2("stats", "dirreq-stats");
}
init_addrinfo();
@@ -2959,7 +2955,7 @@ tor_main(int argc, char *argv[])
update_approx_time(time(NULL));
tor_threads_init();
- init_logging();
+ init_logging(0);
#ifdef USE_DMALLOC
{
/* Instruct OpenSSL to use our internal wrappers for malloc,
diff --git a/src/or/main.h b/src/or/main.h
index a3bce3486f..e918517b82 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index fdb549a9ac..7b826008b5 100644
--- a/src/or/microdesc.c
+++ b/src/or/microdesc.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2009-2013, The Tor Project, Inc. */
+/* Copyright (c) 2009-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -57,9 +57,9 @@ microdesc_eq_(microdesc_t *a, microdesc_t *b)
HT_PROTOTYPE(microdesc_map, microdesc_t, node,
microdesc_hash_, microdesc_eq_);
-HT_GENERATE(microdesc_map, microdesc_t, node,
+HT_GENERATE2(microdesc_map, microdesc_t, node,
microdesc_hash_, microdesc_eq_, 0.6,
- malloc, realloc, free);
+ tor_reallocarray_, tor_free_)
/** Write the body of <b>md</b> into <b>f</b>, with appropriate annotations.
* On success, return the total number of bytes written, and set
@@ -147,39 +147,81 @@ microdescs_add_to_cache(microdesc_cache_t *cache,
int no_save, time_t listed_at,
smartlist_t *requested_digests256)
{
+ void * const DIGEST_REQUESTED = (void*)1;
+ void * const DIGEST_RECEIVED = (void*)2;
+ void * const DIGEST_INVALID = (void*)3;
+
smartlist_t *descriptors, *added;
const int allow_annotations = (where != SAVED_NOWHERE);
+ smartlist_t *invalid_digests = smartlist_new();
descriptors = microdescs_parse_from_string(s, eos,
allow_annotations,
- where);
+ where, invalid_digests);
if (listed_at != (time_t)-1) {
SMARTLIST_FOREACH(descriptors, microdesc_t *, md,
md->last_listed = listed_at);
}
if (requested_digests256) {
- digestmap_t *requested; /* XXXX actually we should just use a
- digest256map */
- requested = digestmap_new();
- SMARTLIST_FOREACH(requested_digests256, const char *, cp,
- digestmap_set(requested, cp, (void*)1));
+ digest256map_t *requested;
+ requested = digest256map_new();
+ /* Set requested[d] to DIGEST_REQUESTED for every md we requested. */
+ SMARTLIST_FOREACH(requested_digests256, const uint8_t *, cp,
+ digest256map_set(requested, cp, DIGEST_REQUESTED));
+ /* Set requested[d] to DIGEST_INVALID for every md we requested which we
+ * will never be able to parse. Remove the ones we didn't request from
+ * invalid_digests.
+ */
+ SMARTLIST_FOREACH_BEGIN(invalid_digests, uint8_t *, cp) {
+ if (digest256map_get(requested, cp)) {
+ digest256map_set(requested, cp, DIGEST_INVALID);
+ } else {
+ tor_free(cp);
+ SMARTLIST_DEL_CURRENT(invalid_digests, cp);
+ }
+ } SMARTLIST_FOREACH_END(cp);
+ /* Update requested[d] to 2 for the mds we asked for and got. Delete the
+ * ones we never requested from the 'descriptors' smartlist.
+ */
SMARTLIST_FOREACH_BEGIN(descriptors, microdesc_t *, md) {
- if (digestmap_get(requested, md->digest)) {
- digestmap_set(requested, md->digest, (void*)2);
+ if (digest256map_get(requested, (const uint8_t*)md->digest)) {
+ digest256map_set(requested, (const uint8_t*)md->digest,
+ DIGEST_RECEIVED);
} else {
log_fn(LOG_PROTOCOL_WARN, LD_DIR, "Received non-requested microdesc");
microdesc_free(md);
SMARTLIST_DEL_CURRENT(descriptors, md);
}
} SMARTLIST_FOREACH_END(md);
- SMARTLIST_FOREACH_BEGIN(requested_digests256, char *, cp) {
- if (digestmap_get(requested, cp) == (void*)2) {
+ /* Remove the ones we got or the invalid ones from requested_digests256.
+ */
+ SMARTLIST_FOREACH_BEGIN(requested_digests256, uint8_t *, cp) {
+ void *status = digest256map_get(requested, cp);
+ if (status == DIGEST_RECEIVED || status == DIGEST_INVALID) {
tor_free(cp);
SMARTLIST_DEL_CURRENT(requested_digests256, cp);
}
} SMARTLIST_FOREACH_END(cp);
- digestmap_free(requested, NULL);
+ digest256map_free(requested, NULL);
+ }
+
+ /* For every requested microdescriptor that was unparseable, mark it
+ * as not to be retried. */
+ if (smartlist_len(invalid_digests)) {
+ networkstatus_t *ns =
+ networkstatus_get_latest_consensus_by_flavor(FLAV_MICRODESC);
+ if (ns) {
+ SMARTLIST_FOREACH_BEGIN(invalid_digests, char *, d) {
+ routerstatus_t *rs =
+ router_get_mutable_consensus_status_by_descriptor_digest(ns, d);
+ if (rs && tor_memeq(d, rs->descriptor_digest, DIGEST256_LEN)) {
+ download_status_mark_impossible(&rs->dl_status);
+ }
+ } SMARTLIST_FOREACH_END(d);
+ }
}
+ SMARTLIST_FOREACH(invalid_digests, uint8_t *, d, tor_free(d));
+ smartlist_free(invalid_digests);
added = microdescs_add_list_to_cache(cache, descriptors, where, no_save);
smartlist_free(descriptors);
@@ -576,6 +618,7 @@ microdesc_cache_rebuild(microdesc_cache_t *cache, int force)
microdesc_wipe_body(md);
}
}
+ smartlist_free(wrote);
return -1;
}
@@ -751,7 +794,7 @@ microdesc_average_size(microdesc_cache_t *cache)
* smartlist. Omit all microdescriptors whose digest appear in <b>skip</b>. */
smartlist_t *
microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache,
- int downloadable_only, digestmap_t *skip)
+ int downloadable_only, digest256map_t *skip)
{
smartlist_t *result = smartlist_new();
time_t now = time(NULL);
@@ -763,7 +806,7 @@ microdesc_list_missing_digest256(networkstatus_t *ns, microdesc_cache_t *cache,
!download_status_is_ready(&rs->dl_status, now,
get_options()->TestingMicrodescMaxDownloadTries))
continue;
- if (skip && digestmap_get(skip, rs->descriptor_digest))
+ if (skip && digest256map_get(skip, (const uint8_t*)rs->descriptor_digest))
continue;
if (tor_mem_is_zero(rs->descriptor_digest, DIGEST256_LEN))
continue;
@@ -788,7 +831,7 @@ update_microdesc_downloads(time_t now)
const or_options_t *options = get_options();
networkstatus_t *consensus;
smartlist_t *missing;
- digestmap_t *pending;
+ digest256map_t *pending;
if (should_delay_dir_fetches(options, NULL))
return;
@@ -802,14 +845,14 @@ update_microdesc_downloads(time_t now)
if (!we_fetch_microdescriptors(options))
return;
- pending = digestmap_new();
+ pending = digest256map_new();
list_pending_microdesc_downloads(pending);
missing = microdesc_list_missing_digest256(consensus,
get_microdesc_cache(),
1,
pending);
- digestmap_free(pending, NULL);
+ digest256map_free(pending, NULL);
launch_descriptor_downloads(DIR_PURPOSE_FETCH_MICRODESC,
missing, NULL, now);
diff --git a/src/or/microdesc.h b/src/or/microdesc.h
index 7adb8c68af..fdfe8922ab 100644
--- a/src/or/microdesc.h
+++ b/src/or/microdesc.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -37,7 +37,7 @@ size_t microdesc_average_size(microdesc_cache_t *cache);
smartlist_t *microdesc_list_missing_digest256(networkstatus_t *ns,
microdesc_cache_t *cache,
int downloadable_only,
- digestmap_t *skip);
+ digest256map_t *skip);
void microdesc_free_(microdesc_t *md, const char *fname, int line);
#define microdesc_free(md) \
diff --git a/src/or/networkstatus.c b/src/or/networkstatus.c
index 890da0ad17..21efdd129d 100644
--- a/src/or/networkstatus.c
+++ b/src/or/networkstatus.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -83,7 +83,11 @@ static consensus_waiting_for_certs_t
* before the current consensus becomes invalid. */
static time_t time_to_download_next_consensus[N_CONSENSUS_FLAVORS];
/** Download status for the current consensus networkstatus. */
-static download_status_t consensus_dl_status[N_CONSENSUS_FLAVORS];
+static download_status_t consensus_dl_status[N_CONSENSUS_FLAVORS] =
+ {
+ { 0, 0, DL_SCHED_CONSENSUS },
+ { 0, 0, DL_SCHED_CONSENSUS },
+ };
/** True iff we have logged a warning about this OR's version being older than
* listed by the authorities. */
@@ -591,10 +595,10 @@ networkstatus_vote_find_entry_idx(networkstatus_t *ns,
/** As router_get_consensus_status_by_descriptor_digest, but does not return
* a const pointer. */
-routerstatus_t *
-router_get_mutable_consensus_status_by_descriptor_digest(
+MOCK_IMPL(routerstatus_t *,
+router_get_mutable_consensus_status_by_descriptor_digest,(
networkstatus_t *consensus,
- const char *digest)
+ const char *digest))
{
if (!consensus)
consensus = current_consensus;
@@ -624,8 +628,8 @@ router_get_consensus_status_by_descriptor_digest(networkstatus_t *consensus,
/** Given the digest of a router descriptor, return its current download
* status, or NULL if the digest is unrecognized. */
-download_status_t *
-router_get_dl_status_by_descriptor_digest(const char *d)
+MOCK_IMPL(download_status_t *,
+router_get_dl_status_by_descriptor_digest,(const char *d))
{
routerstatus_t *rs;
if (!current_ns_consensus)
@@ -754,6 +758,9 @@ update_consensus_networkstatus_downloads(time_t now)
resource = networkstatus_get_flavor_name(i);
+ /* Let's make sure we remembered to update consensus_dl_status */
+ tor_assert(consensus_dl_status[i].schedule == DL_SCHED_CONSENSUS);
+
if (!download_status_is_ready(&consensus_dl_status[i], now,
options->TestingConsensusMaxDownloadTries))
continue; /* We failed downloading a consensus too recently. */
@@ -988,8 +995,8 @@ networkstatus_get_latest_consensus(void)
/** Return the latest consensus we have whose flavor matches <b>f</b>, or NULL
* if we don't have one. */
-networkstatus_t *
-networkstatus_get_latest_consensus_by_flavor(consensus_flavor_t f)
+MOCK_IMPL(networkstatus_t *,
+networkstatus_get_latest_consensus_by_flavor,(consensus_flavor_t f))
{
if (f == FLAV_NS)
return current_ns_consensus;
@@ -1055,7 +1062,6 @@ routerstatus_has_changed(const routerstatus_t *a, const routerstatus_t *b)
a->is_valid != b->is_valid ||
a->is_possible_guard != b->is_possible_guard ||
a->is_bad_exit != b->is_bad_exit ||
- a->is_bad_directory != b->is_bad_directory ||
a->is_hs_dir != b->is_hs_dir ||
a->version_known != b->version_known;
}
@@ -1117,7 +1123,7 @@ networkstatus_copy_old_consensus_info(networkstatus_t *new_c,
rs_new->last_dir_503_at = rs_old->last_dir_503_at;
if (tor_memeq(rs_old->descriptor_digest, rs_new->descriptor_digest,
- DIGEST_LEN)) {
+ DIGEST256_LEN)) {
/* And the same descriptor too! */
memcpy(&rs_new->dl_status, &rs_old->dl_status,sizeof(download_status_t));
}
@@ -1655,7 +1661,7 @@ networkstatus_getinfo_by_purpose(const char *purpose_string, time_t now)
if (bridge_auth && ri->purpose == ROUTER_PURPOSE_BRIDGE)
dirserv_set_router_is_running(ri, now);
/* then generate and write out status lines for each of them */
- set_routerstatus_from_routerinfo(&rs, node, ri, now, 0, 0, 0, 0);
+ set_routerstatus_from_routerinfo(&rs, node, ri, now, 0, 0);
smartlist_add(statuses, networkstatus_getinfo_helper_single(&rs));
} SMARTLIST_FOREACH_END(ri);
@@ -1672,17 +1678,22 @@ networkstatus_dump_bridge_status_to_file(time_t now)
char *status = networkstatus_getinfo_by_purpose("bridge", now);
const or_options_t *options = get_options();
char *fname = NULL;
- char *thresholds = NULL, *thresholds_and_status = NULL;
+ char *thresholds = NULL;
+ char *published_thresholds_and_status = NULL;
routerlist_t *rl = router_get_routerlist();
+ char published[ISO_TIME_LEN+1];
+
+ format_iso_time(published, now);
dirserv_compute_bridge_flag_thresholds(rl);
thresholds = dirserv_get_flag_thresholds_line();
- tor_asprintf(&thresholds_and_status, "flag-thresholds %s\n%s",
- thresholds, status);
+ tor_asprintf(&published_thresholds_and_status,
+ "published %s\nflag-thresholds %s\n%s",
+ published, thresholds, status);
tor_asprintf(&fname, "%s"PATH_SEPARATOR"networkstatus-bridges",
options->DataDirectory);
- write_str_to_file(fname,thresholds_and_status,0);
+ write_str_to_file(fname,published_thresholds_and_status,0);
tor_free(thresholds);
- tor_free(thresholds_and_status);
+ tor_free(published_thresholds_and_status);
tor_free(fname);
tor_free(status);
}
diff --git a/src/or/networkstatus.h b/src/or/networkstatus.h
index be0a86cdd8..a087a79ac3 100644
--- a/src/or/networkstatus.h
+++ b/src/or/networkstatus.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -12,6 +12,8 @@
#ifndef TOR_NETWORKSTATUS_H
#define TOR_NETWORKSTATUS_H
+#include "testsupport.h"
+
void networkstatus_reset_warnings(void);
void networkstatus_reset_download_failures(void);
int router_reload_consensus_networkstatus(void);
@@ -35,16 +37,19 @@ routerstatus_t *networkstatus_vote_find_mutable_entry(networkstatus_t *ns,
const char *digest);
int networkstatus_vote_find_entry_idx(networkstatus_t *ns,
const char *digest, int *found_out);
-download_status_t *router_get_dl_status_by_descriptor_digest(const char *d);
+
+MOCK_DECL(download_status_t *,router_get_dl_status_by_descriptor_digest,
+ (const char *d));
+
const routerstatus_t *router_get_consensus_status_by_id(const char *digest);
routerstatus_t *router_get_mutable_consensus_status_by_id(
const char *digest);
const routerstatus_t *router_get_consensus_status_by_descriptor_digest(
networkstatus_t *consensus,
const char *digest);
-routerstatus_t *router_get_mutable_consensus_status_by_descriptor_digest(
- networkstatus_t *consensus,
- const char *digest);
+MOCK_DECL(routerstatus_t *,
+ router_get_mutable_consensus_status_by_descriptor_digest,
+ (networkstatus_t *consensus, const char *digest));
const routerstatus_t *router_get_consensus_status_by_nickname(
const char *nickname,
int warn_if_unnamed);
@@ -60,8 +65,8 @@ int consensus_is_waiting_for_certs(void);
int client_would_use_router(const routerstatus_t *rs, time_t now,
const or_options_t *options);
networkstatus_t *networkstatus_get_latest_consensus(void);
-networkstatus_t *networkstatus_get_latest_consensus_by_flavor(
- consensus_flavor_t f);
+MOCK_DECL(networkstatus_t *,networkstatus_get_latest_consensus_by_flavor,
+ (consensus_flavor_t f));
networkstatus_t *networkstatus_get_live_consensus(time_t now);
networkstatus_t *networkstatus_get_reasonably_live_consensus(time_t now,
int flavor);
diff --git a/src/or/nodelist.c b/src/or/nodelist.c
index 8f870816d2..53abc820f5 100644
--- a/src/or/nodelist.c
+++ b/src/or/nodelist.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -53,8 +53,8 @@ node_id_eq(const node_t *node1, const node_t *node2)
}
HT_PROTOTYPE(nodelist_map, node_t, ht_ent, node_id_hash, node_id_eq);
-HT_GENERATE(nodelist_map, node_t, ht_ent, node_id_hash, node_id_eq,
- 0.6, malloc, realloc, free);
+HT_GENERATE2(nodelist_map, node_t, ht_ent, node_id_hash, node_id_eq,
+ 0.6, tor_reallocarray_, tor_free_)
/** The global nodelist. */
static nodelist_t *the_nodelist=NULL;
@@ -241,7 +241,6 @@ nodelist_set_consensus(networkstatus_t *ns)
node->is_stable = rs->is_stable;
node->is_possible_guard = rs->is_possible_guard;
node->is_exit = rs->is_exit;
- node->is_bad_directory = rs->is_bad_directory;
node->is_bad_exit = rs->is_bad_exit;
node->is_hs_dir = rs->is_hs_dir;
node->ipv6_preferred = 0;
@@ -267,8 +266,7 @@ nodelist_set_consensus(networkstatus_t *ns)
node->is_valid = node->is_running = node->is_hs_dir =
node->is_fast = node->is_stable =
node->is_possible_guard = node->is_exit =
- node->is_bad_exit = node->is_bad_directory =
- node->ipv6_preferred = 0;
+ node->is_bad_exit = node->ipv6_preferred = 0;
}
}
} SMARTLIST_FOREACH_END(node);
@@ -474,8 +472,8 @@ nodelist_assert_ok(void)
/** Return a list of a node_t * for every node we know about. The caller
* MUST NOT modify the list. (You can set and clear flags in the nodes if
* you must, but you must not add or remove nodes.) */
-smartlist_t *
-nodelist_get_list(void)
+MOCK_IMPL(smartlist_t *,
+nodelist_get_list,(void))
{
init_nodelist();
return the_nodelist->nodes;
@@ -517,8 +515,8 @@ node_get_by_hex_id(const char *hex_id)
* the corresponding node_t, or NULL if none exists. Warn the user if
* <b>warn_if_unnamed</b> is set, and they have specified a router by
* nickname, but the Named flag isn't set for that router. */
-const node_t *
-node_get_by_nickname(const char *nickname, int warn_if_unnamed)
+MOCK_IMPL(const node_t *,
+node_get_by_nickname,(const char *nickname, int warn_if_unnamed))
{
const node_t *node;
if (!the_nodelist)
@@ -1275,10 +1273,21 @@ static char dir_info_status[256] = "";
int
router_have_minimum_dir_info(void)
{
+ static int logged_delay=0;
+ const char *delay_fetches_msg = NULL;
+ if (should_delay_dir_fetches(get_options(), &delay_fetches_msg)) {
+ if (!logged_delay)
+ log_notice(LD_DIR, "Delaying directory fetches: %s", delay_fetches_msg);
+ logged_delay=1;
+ strlcpy(dir_info_status, delay_fetches_msg, sizeof(dir_info_status));
+ return 0;
+ }
+ logged_delay = 0; /* reset it if we get this far */
+
if (PREDICT_UNLIKELY(need_to_update_have_min_dir_info)) {
update_router_have_minimum_dir_info();
- need_to_update_have_min_dir_info = 0;
}
+
return have_min_dir_info;
}
@@ -1498,7 +1507,6 @@ update_router_have_minimum_dir_info(void)
const networkstatus_t *consensus =
networkstatus_get_reasonably_live_consensus(now,usable_consensus_flavor());
int using_md;
- const char *delay_fetches_msg = NULL;
if (!consensus) {
if (!networkstatus_get_latest_consensus())
@@ -1511,13 +1519,6 @@ update_router_have_minimum_dir_info(void)
goto done;
}
- if (should_delay_dir_fetches(get_options(), &delay_fetches_msg)) {
- log_notice(LD_DIR, "Delaying directory fetches: %s", delay_fetches_msg);
- strlcpy(dir_info_status, delay_fetches_msg, sizeof(dir_info_status));
- res = 0;
- goto done;
- }
-
using_md = consensus->flavor == FLAV_MICRODESC;
{
diff --git a/src/or/nodelist.h b/src/or/nodelist.h
index 8e719e012d..48b0e94be0 100644
--- a/src/or/nodelist.h
+++ b/src/or/nodelist.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -31,7 +31,8 @@ smartlist_t *nodelist_find_nodes_with_microdesc(const microdesc_t *md);
void nodelist_free_all(void);
void nodelist_assert_ok(void);
-const node_t *node_get_by_nickname(const char *nickname, int warn_if_unnamed);
+MOCK_DECL(const node_t *, node_get_by_nickname,
+ (const char *nickname, int warn_if_unnamed));
void node_get_verbose_nickname(const node_t *node,
char *verbose_name_out);
void node_get_verbose_nickname_by_id(const char *id_digest,
@@ -60,7 +61,7 @@ void node_get_pref_orport(const node_t *node, tor_addr_port_t *ap_out);
void node_get_pref_ipv6_orport(const node_t *node, tor_addr_port_t *ap_out);
int node_has_curve25519_onion_key(const node_t *node);
-smartlist_t *nodelist_get_list(void);
+MOCK_DECL(smartlist_t *, nodelist_get_list, (void));
/* Temporary during transition to multiple addresses. */
void node_get_addr(const node_t *node, tor_addr_t *addr_out);
diff --git a/src/or/ntmain.c b/src/or/ntmain.c
index e848314043..ea6ec3b03e 100644
--- a/src/or/ntmain.c
+++ b/src/or/ntmain.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
diff --git a/src/or/ntmain.h b/src/or/ntmain.h
index d09a413aee..68565e17ca 100644
--- a/src/or/ntmain.h
+++ b/src/or/ntmain.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/onion.c b/src/or/onion.c
index ae39f451f4..b8f85f9194 100644
--- a/src/or/onion.c
+++ b/src/or/onion.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -111,15 +111,11 @@ have_room_for_onionskin(uint16_t type)
(uint64_t)options->MaxOnionQueueDelay)
return 0;
-#ifdef CURVE25519_ENABLED
/* If we support the ntor handshake, then don't let TAP handshakes use
* more than 2/3 of the space on the queue. */
if (type == ONION_HANDSHAKE_TYPE_TAP &&
tap_usec / 1000 > (uint64_t)options->MaxOnionQueueDelay * 2 / 3)
return 0;
-#else
- (void) type;
-#endif
return 1;
}
@@ -353,11 +349,9 @@ setup_server_onion_keys(server_onion_keys_t *keys)
memset(keys, 0, sizeof(server_onion_keys_t));
memcpy(keys->my_identity, router_get_my_id_digest(), DIGEST_LEN);
dup_onion_keys(&keys->onion_key, &keys->last_onion_key);
-#ifdef CURVE25519_ENABLED
keys->curve25519_key_map = construct_ntor_key_map();
keys->junk_keypair = tor_malloc_zero(sizeof(curve25519_keypair_t));
curve25519_keypair_generate(keys->junk_keypair, 0);
-#endif
}
/** Release all storage held in <b>keys</b>, but do not free <b>keys</b>
@@ -370,10 +364,8 @@ release_server_onion_keys(server_onion_keys_t *keys)
crypto_pk_free(keys->onion_key);
crypto_pk_free(keys->last_onion_key);
-#ifdef CURVE25519_ENABLED
ntor_key_map_free(keys->curve25519_key_map);
tor_free(keys->junk_keypair);
-#endif
memset(keys, 0, sizeof(server_onion_keys_t));
}
@@ -391,12 +383,10 @@ onion_handshake_state_release(onion_handshake_state_t *state)
fast_handshake_state_free(state->u.fast);
state->u.fast = NULL;
break;
-#ifdef CURVE25519_ENABLED
case ONION_HANDSHAKE_TYPE_NTOR:
ntor_handshake_state_free(state->u.ntor);
state->u.ntor = NULL;
break;
-#endif
default:
log_warn(LD_BUG, "called with unknown handshake state type %d",
(int)state->tag);
@@ -436,7 +426,6 @@ onion_skin_create(int type,
r = CREATE_FAST_LEN;
break;
case ONION_HANDSHAKE_TYPE_NTOR:
-#ifdef CURVE25519_ENABLED
if (tor_mem_is_zero((const char*)node->curve25519_onion_key.public_key,
CURVE25519_PUBKEY_LEN))
return -1;
@@ -447,9 +436,6 @@ onion_skin_create(int type,
return -1;
r = NTOR_ONIONSKIN_LEN;
-#else
- return -1;
-#endif
break;
default:
log_warn(LD_BUG, "called with unknown handshake state type %d", type);
@@ -501,7 +487,6 @@ onion_skin_server_handshake(int type,
memcpy(rend_nonce_out, reply_out+DIGEST_LEN, DIGEST_LEN);
break;
case ONION_HANDSHAKE_TYPE_NTOR:
-#ifdef CURVE25519_ENABLED
if (onionskin_len < NTOR_ONIONSKIN_LEN)
return -1;
{
@@ -522,9 +507,6 @@ onion_skin_server_handshake(int type,
tor_free(keys_tmp);
r = NTOR_REPLY_LEN;
}
-#else
- return -1;
-#endif
break;
default:
log_warn(LD_BUG, "called with unknown handshake state type %d", type);
@@ -577,7 +559,6 @@ onion_skin_client_handshake(int type,
memcpy(rend_authenticator_out, reply+DIGEST_LEN, DIGEST_LEN);
return 0;
-#ifdef CURVE25519_ENABLED
case ONION_HANDSHAKE_TYPE_NTOR:
if (reply_len < NTOR_REPLY_LEN) {
log_warn(LD_CIRC, "ntor reply was not of the correct length.");
@@ -598,7 +579,6 @@ onion_skin_client_handshake(int type,
tor_free(keys_tmp);
}
return 0;
-#endif
default:
log_warn(LD_BUG, "called with unknown handshake state type %d", type);
tor_fragile_assert();
@@ -637,12 +617,10 @@ check_create_cell(const create_cell_t *cell, int unknown_ok)
if (cell->handshake_len != CREATE_FAST_LEN)
return -1;
break;
-#ifdef CURVE25519_ENABLED
case ONION_HANDSHAKE_TYPE_NTOR:
if (cell->handshake_len != NTOR_ONIONSKIN_LEN)
return -1;
break;
-#endif
default:
if (! unknown_ok)
return -1;
diff --git a/src/or/onion.h b/src/or/onion.h
index d62f032b87..2fd86206e4 100644
--- a/src/or/onion.h
+++ b/src/or/onion.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -23,10 +23,8 @@ typedef struct server_onion_keys_t {
uint8_t my_identity[DIGEST_LEN];
crypto_pk_t *onion_key;
crypto_pk_t *last_onion_key;
-#ifdef CURVE25519_ENABLED
di_digest256_map_t *curve25519_key_map;
curve25519_keypair_t *junk_keypair;
-#endif
} server_onion_keys_t;
#define MAX_ONIONSKIN_CHALLENGE_LEN 255
diff --git a/src/or/onion_fast.c b/src/or/onion_fast.c
index 38b62decc3..0ca3e3a5a0 100644
--- a/src/or/onion_fast.c
+++ b/src/or/onion_fast.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/onion_fast.h b/src/or/onion_fast.h
index 8c078378d2..2fc605fc42 100644
--- a/src/or/onion_fast.h
+++ b/src/or/onion_fast.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/onion_ntor.c b/src/or/onion_ntor.c
index ef501f69da..c028ed0ff9 100644
--- a/src/or/onion_ntor.c
+++ b/src/or/onion_ntor.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
diff --git a/src/or/onion_ntor.h b/src/or/onion_ntor.h
index c942e6e0f0..29178e942d 100644
--- a/src/or/onion_ntor.h
+++ b/src/or/onion_ntor.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_ONION_NTOR_H
@@ -17,7 +17,6 @@ typedef struct ntor_handshake_state_t ntor_handshake_state_t;
/** Length of an ntor reply, as sent from server to client. */
#define NTOR_REPLY_LEN 64
-#ifdef CURVE25519_ENABLED
void ntor_handshake_state_free(ntor_handshake_state_t *state);
int onion_skin_ntor_create(const uint8_t *router_id,
@@ -59,5 +58,3 @@ struct ntor_handshake_state_t {
#endif
-#endif
-
diff --git a/src/or/onion_tap.c b/src/or/onion_tap.c
index 9a9f374b93..b3b2a008bc 100644
--- a/src/or/onion_tap.c
+++ b/src/or/onion_tap.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -122,8 +122,9 @@ onion_skin_TAP_server_handshake(
"Couldn't decrypt onionskin: client may be using old onion key");
goto err;
} else if (len != DH_KEY_LEN) {
- log_warn(LD_PROTOCOL, "Unexpected onionskin length after decryption: %ld",
- (long)len);
+ log_fn(LOG_PROTOCOL_WARN, LD_PROTOCOL,
+ "Unexpected onionskin length after decryption: %ld",
+ (long)len);
goto err;
}
diff --git a/src/or/onion_tap.h b/src/or/onion_tap.h
index b978b66737..36fb649d60 100644
--- a/src/or/onion_tap.h
+++ b/src/or/onion_tap.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/or.h b/src/or/or.h
index 0419111a4e..6170c2119c 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -14,7 +14,7 @@
#include "orconfig.h"
-#ifdef __COVERITY__
+#if defined(__clang_analyzer__) || defined(__COVERITY__)
/* If we're building for a static analysis, turn on all the off-by-default
* features. */
#ifndef INSTRUMENT_DOWNLOADS
@@ -241,7 +241,7 @@ typedef enum {
#define PROXY_CONNECT 1
#define PROXY_SOCKS4 2
#define PROXY_SOCKS5 3
-/* !!!! If there is ever a PROXY_* type over 2, we must grow the proxy_type
+/* !!!! If there is ever a PROXY_* type over 3, we must grow the proxy_type
* field in or_connection_t */
/* Pluggable transport proxy type. Don't use this in or_connection_t,
@@ -1737,8 +1737,9 @@ typedef struct dir_connection_t {
typedef struct control_connection_t {
connection_t base_;
- uint32_t event_mask; /**< Bitfield: which events does this controller
- * care about? */
+ uint64_t event_mask; /**< Bitfield: which events does this controller
+ * care about?
+ * EVENT_MAX_ is >31, so we need a 64 bit mask */
/** True if we have sent a protocolinfo reply on this connection. */
unsigned int have_sent_protocolinfo:1;
@@ -1957,6 +1958,7 @@ typedef struct download_status_t {
uint8_t n_download_failures; /**< Number of failures trying to download the
* most recent descriptor. */
download_schedule_bitfield_t schedule : 8;
+
} download_status_t;
/** If n_download_failures is this high, the download can never happen. */
@@ -2138,8 +2140,6 @@ typedef struct routerstatus_t {
* choice as an entry guard. */
unsigned int is_bad_exit:1; /**< True iff this node is a bad choice for
* an exit node. */
- unsigned int is_bad_directory:1; /**< Do we think this directory is junky,
- * underpowered, or otherwise useless? */
unsigned int is_hs_dir:1; /**< True iff this router is a v2-or-later hidden
* service directory. */
/** True iff we know version info for this router. (i.e., a "v" entry was
@@ -2150,9 +2150,6 @@ typedef struct routerstatus_t {
/** True iff this router is a version that, if it caches directory info,
* we can get microdescriptors from. */
unsigned int version_supports_microdesc_cache:1;
- /** True iff this router is a version that allows DATA cells to arrive on
- * a stream before it has sent a CONNECTED cell. */
- unsigned int version_supports_optimistic_data:1;
/** True iff this router has a version that allows it to accept EXTEND2
* cells */
unsigned int version_supports_extend2_cells:1;
@@ -2299,8 +2296,6 @@ typedef struct node_t {
unsigned int is_exit:1; /**< Do we think this is an OK exit? */
unsigned int is_bad_exit:1; /**< Do we think this exit is censored, borked,
* or otherwise nasty? */
- unsigned int is_bad_directory:1; /**< Do we think this directory is junky,
- * underpowered, or otherwise useless? */
unsigned int is_hs_dir:1; /**< True iff this router is a hidden service
* directory according to the authorities. */
@@ -2559,9 +2554,7 @@ typedef struct extend_info_t {
uint16_t port; /**< OR port. */
tor_addr_t addr; /**< IP address. */
crypto_pk_t *onion_key; /**< Current onionskin key. */
-#ifdef CURVE25519_ENABLED
curve25519_public_key_t curve25519_onion_key;
-#endif
} extend_info_t;
/** Certificate for v3 directory protocol: binds long-term authority identity
@@ -2864,8 +2857,8 @@ typedef struct circuit_t {
/** Unique ID for measuring tunneled network status requests. */
uint64_t dirreq_id;
- /** Next circuit in linked list of all circuits (global_circuitlist). */
- TOR_LIST_ENTRY(circuit_t) head;
+ /** Index in smartlist of all circuits (global_circuitlist). */
+ int global_circuitlist_idx;
/** Next circuit in the doubly-linked ring of circuits waiting to add
* cells to n_conn. NULL if we have no cells pending, or if we're not
@@ -3235,6 +3228,14 @@ static const or_circuit_t *CONST_TO_OR_CIRCUIT(const circuit_t *);
static origin_circuit_t *TO_ORIGIN_CIRCUIT(circuit_t *);
static const origin_circuit_t *CONST_TO_ORIGIN_CIRCUIT(const circuit_t *);
+/** Return 1 iff <b>node</b> has Exit flag and no BadExit flag.
+ * Otherwise, return 0.
+ */
+static INLINE int node_is_good_exit(const node_t *node)
+{
+ return node->is_exit && ! node->is_bad_exit;
+}
+
static INLINE or_circuit_t *TO_OR_CIRCUIT(circuit_t *x)
{
tor_assert(x->magic == OR_CIRCUIT_MAGIC);
@@ -3532,8 +3533,6 @@ typedef struct {
int AuthoritativeDir; /**< Boolean: is this an authoritative directory? */
int V3AuthoritativeDir; /**< Boolean: is this an authoritative directory
* for version 3 directories? */
- int NamingAuthoritativeDir; /**< Boolean: is this an authoritative directory
- * that's willing to bind names? */
int VersioningAuthoritativeDir; /**< Boolean: is this an authoritative
* directory that's willing to recommend
* versions? */
@@ -3743,8 +3742,6 @@ typedef struct {
config_line_t *NodeFamilies; /**< List of config lines for
* node families */
smartlist_t *NodeFamilySets; /**< List of parsed NodeFamilies values. */
- config_line_t *AuthDirBadDir; /**< Address policy for descriptors to
- * mark as bad dir mirrors. */
config_line_t *AuthDirBadExit; /**< Address policy for descriptors to
* mark as bad exits. */
config_line_t *AuthDirReject; /**< Address policy for descriptors to
@@ -3753,23 +3750,18 @@ typedef struct {
* never mark as valid. */
/** @name AuthDir...CC
*
- * Lists of country codes to mark as BadDir, BadExit, or Invalid, or to
+ * Lists of country codes to mark as BadExit, or Invalid, or to
* reject entirely.
*
* @{
*/
- smartlist_t *AuthDirBadDirCCs;
smartlist_t *AuthDirBadExitCCs;
smartlist_t *AuthDirInvalidCCs;
smartlist_t *AuthDirRejectCCs;
/**@}*/
- int AuthDirListBadDirs; /**< True iff we should list bad dirs,
- * and vote for all other dir mirrors as good. */
int AuthDirListBadExits; /**< True iff we should list bad exits,
* and vote for all other exits as good. */
- int AuthDirRejectUnlisted; /**< Boolean: do we reject all routers that
- * aren't named in our fingerprint file? */
int AuthDirMaxServersPerAddr; /**< Do not permit more than this
* number of servers per IP address. */
int AuthDirMaxServersPerAuthAddr; /**< Do not permit more than this
@@ -3790,6 +3782,11 @@ typedef struct {
uint64_t AccountingMax; /**< How many bytes do we allow per accounting
* interval before hibernation? 0 for "never
* hibernate." */
+ /** How do we determine when our AccountingMax has been reached?
+ * "max" for when in or out reaches AccountingMax
+ * "sum for when in plus out reaches AccountingMax */
+ char *AccountingRule_option;
+ enum { ACCT_MAX, ACCT_SUM } AccountingRule;
/** Base64-encoded hash of accepted passwords for the control system. */
config_line_t *HashedControlPassword;
@@ -3803,6 +3800,8 @@ typedef struct {
char *ExtORPortCookieAuthFile; /**< Filesystem location of Extended
* ORPort authentication cookie. */
int CookieAuthFileGroupReadable; /**< Boolean: Is the CookieAuthFile g+r? */
+ int ExtORPortCookieAuthFileGroupReadable; /**< Boolean: Is the
+ * ExtORPortCookieAuthFile g+r? */
int LeaveStreamsUnattached; /**< Boolean: Does Tor attach new streams to
* circuits itself (0), or does it expect a controller
* to cope? (1) */
@@ -3920,8 +3919,11 @@ typedef struct {
* instead of a hostname. */
int WarnUnsafeSocks;
- /** If true, the user wants us to collect statistics on clients
+ /** If true, we're configured to collect statistics on clients
* requesting network statuses from us as directory. */
+ int DirReqStatistics_option;
+ /** Internal variable to remember whether we're actually acting on
+ * DirReqStatistics_option -- yes if it's set and we're a server, else no. */
int DirReqStatistics;
/** If true, the user wants us to collect statistics on port usage. */
@@ -4061,6 +4063,10 @@ typedef struct {
/** Minimum value for the Fast flag threshold on testing networks. */
uint64_t TestingMinFastFlagThreshold;
+ /** Relays in a testing network which should be voted Exit
+ * regardless of exit policy. */
+ routerset_t *TestingDirAuthVoteExit;
+
/** Relays in a testing network which should be voted Guard
* regardless of uptime and bandwidth. */
routerset_t *TestingDirAuthVoteGuard;
@@ -4311,7 +4317,8 @@ static INLINE void or_state_mark_dirty(or_state_t *state, time_t when)
/** Please turn this IP address into an FQDN, privately. */
#define SOCKS_COMMAND_RESOLVE_PTR 0xF1
-#define SOCKS_COMMAND_IS_CONNECT(c) ((c)==SOCKS_COMMAND_CONNECT)
+/* || 0 is for -Wparentheses-equality (-Wall?) appeasement under clang */
+#define SOCKS_COMMAND_IS_CONNECT(c) (((c)==SOCKS_COMMAND_CONNECT) || 0)
#define SOCKS_COMMAND_IS_RESOLVE(c) ((c)==SOCKS_COMMAND_RESOLVE || \
(c)==SOCKS_COMMAND_RESOLVE_PTR)
@@ -4998,7 +5005,8 @@ typedef enum was_router_added_t {
ROUTER_NOT_IN_CONSENSUS = -3,
ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS = -4,
ROUTER_AUTHDIR_REJECTS = -5,
- ROUTER_WAS_NOT_WANTED = -6
+ ROUTER_WAS_NOT_WANTED = -6,
+ ROUTER_WAS_TOO_OLD = -7,
} was_router_added_t;
/********************************* routerparse.c ************************/
diff --git a/src/or/policies.c b/src/or/policies.c
index 8a91509a77..d10bebd79a 100644
--- a/src/or/policies.c
+++ b/src/or/policies.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -29,9 +29,6 @@ static smartlist_t *authdir_reject_policy = NULL;
* to be marked as valid in our networkstatus. */
static smartlist_t *authdir_invalid_policy = NULL;
/** Policy that addresses for incoming router descriptors must <b>not</b>
- * match in order to not be marked as BadDirectory. */
-static smartlist_t *authdir_baddir_policy = NULL;
-/** Policy that addresses for incoming router descriptors must <b>not</b>
* match in order to not be marked as BadExit. */
static smartlist_t *authdir_badexit_policy = NULL;
@@ -65,6 +62,13 @@ static const char *private_nets[] = {
NULL
};
+static int policies_parse_exit_policy_internal(config_line_t *cfg,
+ smartlist_t **dest,
+ int ipv6_exit,
+ int rejectprivate,
+ uint32_t local_address,
+ int add_default_policy);
+
/** Replace all "private" entries in *<b>policy</b> with their expanded
* equivalents. */
void
@@ -400,17 +404,6 @@ authdir_policy_valid_address(uint32_t addr, uint16_t port)
return !addr_is_in_cc_list(addr, get_options()->AuthDirInvalidCCs);
}
-/** Return 1 if <b>addr</b>:<b>port</b> should be marked as a bad dir,
- * based on <b>authdir_baddir_policy</b>. Else return 0.
- */
-int
-authdir_policy_baddir_address(uint32_t addr, uint16_t port)
-{
- if (! addr_policy_permits_address(addr, port, authdir_baddir_policy))
- return 1;
- return addr_is_in_cc_list(addr, get_options()->AuthDirBadDirCCs);
-}
-
/** Return 1 if <b>addr</b>:<b>port</b> should be marked as a bad exit,
* based on <b>authdir_badexit_policy</b>. Else return 0.
*/
@@ -437,11 +430,9 @@ validate_addr_policies(const or_options_t *options, char **msg)
smartlist_t *addr_policy=NULL;
*msg = NULL;
- if (policies_parse_exit_policy(options->ExitPolicy, &addr_policy,
- options->IPv6Exit,
- options->ExitPolicyRejectPrivate, 0,
- !options->BridgeRelay))
+ if (policies_parse_exit_policy_from_options(options,0,&addr_policy)) {
REJECT("Error in ExitPolicy entry.");
+ }
/* The rest of these calls *append* to addr_policy. So don't actually
* use the results for anything other than checking if they parse! */
@@ -455,9 +446,6 @@ validate_addr_policies(const or_options_t *options, char **msg)
if (parse_addr_policy(options->AuthDirInvalid, &addr_policy,
ADDR_POLICY_REJECT))
REJECT("Error in AuthDirInvalid entry.");
- if (parse_addr_policy(options->AuthDirBadDir, &addr_policy,
- ADDR_POLICY_REJECT))
- REJECT("Error in AuthDirBadDir entry.");
if (parse_addr_policy(options->AuthDirBadExit, &addr_policy,
ADDR_POLICY_REJECT))
REJECT("Error in AuthDirBadExit entry.");
@@ -535,9 +523,6 @@ policies_parse_from_options(const or_options_t *options)
if (load_policy_from_option(options->AuthDirInvalid, "AuthDirInvalid",
&authdir_invalid_policy, ADDR_POLICY_REJECT) < 0)
ret = -1;
- if (load_policy_from_option(options->AuthDirBadDir, "AuthDirBadDir",
- &authdir_baddir_policy, ADDR_POLICY_REJECT) < 0)
- ret = -1;
if (load_policy_from_option(options->AuthDirBadExit, "AuthDirBadExit",
&authdir_badexit_policy, ADDR_POLICY_REJECT) < 0)
ret = -1;
@@ -629,8 +614,8 @@ policy_hash(const policy_map_ent_t *ent)
HT_PROTOTYPE(policy_map, policy_map_ent_t, node, policy_hash,
policy_eq)
-HT_GENERATE(policy_map, policy_map_ent_t, node, policy_hash,
- policy_eq, 0.6, malloc, realloc, free)
+HT_GENERATE2(policy_map, policy_map_ent_t, node, policy_hash,
+ policy_eq, 0.6, tor_reallocarray_, tor_free_)
/** Given a pointer to an addr_policy_t, return a copy of the pointer to the
* "canonical" copy of that addr_policy_t; the canonical copy is a single
@@ -769,9 +754,9 @@ compare_unknown_tor_addr_to_addr_policy(uint16_t port,
* We could do better by assuming that some ranges never match typical
* addresses (127.0.0.1, and so on). But we'll try this for now.
*/
-addr_policy_result_t
-compare_tor_addr_to_addr_policy(const tor_addr_t *addr, uint16_t port,
- const smartlist_t *policy)
+MOCK_IMPL(addr_policy_result_t,
+compare_tor_addr_to_addr_policy,(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy))
{
if (!policy) {
/* no policy? accept all. */
@@ -968,11 +953,12 @@ exit_policy_remove_redundancies(smartlist_t *dest)
* the functions used to parse the exit policy from a router descriptor,
* see router_add_exit_policy.
*/
-int
-policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
- int ipv6_exit,
- int rejectprivate, uint32_t local_address,
- int add_default_policy)
+static int
+policies_parse_exit_policy_internal(config_line_t *cfg, smartlist_t **dest,
+ int ipv6_exit,
+ int rejectprivate,
+ uint32_t local_address,
+ int add_default_policy)
{
if (!ipv6_exit) {
append_exit_policy_string(dest, "reject *6:*");
@@ -998,6 +984,68 @@ policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
return 0;
}
+/** Parse exit policy in <b>cfg</b> into <b>dest</b> smartlist.
+ *
+ * Add entry that rejects all IPv6 destinations unless
+ * <b>EXIT_POLICY_IPV6_ENABLED</b> bit is set in <b>options</b> bitmask.
+ *
+ * If <b>EXIT_POLICY_REJECT_PRIVATE</b> bit is set in <b>options</b>,
+ * do add entry that rejects all destinations in private subnetwork
+ * Tor is running in.
+ *
+ * Respectively, if <b>EXIT_POLICY_ADD_DEFAULT</b> bit is set, add
+ * default exit policy entries to <b>result</b> smartlist.
+ */
+int
+policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
+ exit_policy_parser_cfg_t options,
+ uint32_t local_address)
+{
+ int ipv6_enabled = (options & EXIT_POLICY_IPV6_ENABLED) ? 1 : 0;
+ int reject_private = (options & EXIT_POLICY_REJECT_PRIVATE) ? 1 : 0;
+ int add_default = (options & EXIT_POLICY_ADD_DEFAULT) ? 1 : 0;
+
+ return policies_parse_exit_policy_internal(cfg,dest,ipv6_enabled,
+ reject_private,
+ local_address,
+ add_default);
+}
+
+/** Parse <b>ExitPolicy</b> member of <b>or_options</b> into <b>result</b>
+ * smartlist.
+ * If <b>or_options->IPv6Exit</b> is false, add an entry that
+ * rejects all IPv6 destinations.
+ *
+ * If <b>or_options->ExitPolicyRejectPrivate</b> is true, add entry that
+ * rejects all destinations in the private subnetwork of machine Tor
+ * instance is running in.
+ *
+ * If <b>or_options->BridgeRelay</b> is false, add entries of default
+ * Tor exit policy into <b>result</b> smartlist.
+ */
+int
+policies_parse_exit_policy_from_options(const or_options_t *or_options,
+ uint32_t local_address,
+ smartlist_t **result)
+{
+ exit_policy_parser_cfg_t parser_cfg = 0;
+
+ if (or_options->IPv6Exit) {
+ parser_cfg |= EXIT_POLICY_IPV6_ENABLED;
+ }
+
+ if (or_options->ExitPolicyRejectPrivate) {
+ parser_cfg |= EXIT_POLICY_REJECT_PRIVATE;
+ }
+
+ if (!or_options->BridgeRelay) {
+ parser_cfg |= EXIT_POLICY_ADD_DEFAULT;
+ }
+
+ return policies_parse_exit_policy(or_options->ExitPolicy,result,
+ parser_cfg,local_address);
+}
+
/** Add "reject *:*" to the end of the policy in *<b>dest</b>, allocating
* *<b>dest</b> as needed. */
void
@@ -1334,9 +1382,9 @@ policy_summary_add_item(smartlist_t *summary, addr_policy_t *p)
* The summary will either be an "accept" plus a comma-separated list of port
* ranges or a "reject" plus port-ranges, depending on which is shorter.
*
- * If no exits are allowed at all then NULL is returned, if no ports
- * are blocked instead of "reject " we return "accept 1-65535" (this
- * is an exception to the shorter-representation-wins rule).
+ * If no exits are allowed at all then "reject 1-65535" is returned. If no
+ * ports are blocked instead of "reject " we return "accept 1-65535". (These
+ * are an exception to the shorter-representation-wins rule).
*/
char *
policy_summarize(smartlist_t *policy, sa_family_t family)
@@ -1766,8 +1814,6 @@ policies_free_all(void)
authdir_reject_policy = NULL;
addr_policy_list_free(authdir_invalid_policy);
authdir_invalid_policy = NULL;
- addr_policy_list_free(authdir_baddir_policy);
- authdir_baddir_policy = NULL;
addr_policy_list_free(authdir_badexit_policy);
authdir_badexit_policy = NULL;
diff --git a/src/or/policies.h b/src/or/policies.h
index 91ac427492..90d94190dd 100644
--- a/src/or/policies.h
+++ b/src/or/policies.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -18,6 +18,12 @@
*/
#define POLICY_BUF_LEN 72
+#define EXIT_POLICY_IPV6_ENABLED (1 << 0)
+#define EXIT_POLICY_REJECT_PRIVATE (1 << 1)
+#define EXIT_POLICY_ADD_DEFAULT (1 << 2)
+
+typedef int exit_policy_parser_cfg_t;
+
int firewall_is_fascist_or(void);
int fascist_firewall_allows_address_or(const tor_addr_t *addr, uint16_t port);
int fascist_firewall_allows_or(const routerinfo_t *ri);
@@ -27,7 +33,6 @@ int dir_policy_permits_address(const tor_addr_t *addr);
int socks_policy_permits_address(const tor_addr_t *addr);
int authdir_policy_permits_address(uint32_t addr, uint16_t port);
int authdir_policy_valid_address(uint32_t addr, uint16_t port);
-int authdir_policy_baddir_address(uint32_t addr, uint16_t port);
int authdir_policy_badexit_address(uint32_t addr, uint16_t port);
int validate_addr_policies(const or_options_t *options, char **msg);
@@ -37,16 +42,24 @@ int policies_parse_from_options(const or_options_t *options);
addr_policy_t *addr_policy_get_canonical_entry(addr_policy_t *ent);
int cmp_addr_policies(smartlist_t *a, smartlist_t *b);
-addr_policy_result_t compare_tor_addr_to_addr_policy(const tor_addr_t *addr,
- uint16_t port, const smartlist_t *policy);
+MOCK_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
addr_policy_result_t compare_tor_addr_to_node_policy(const tor_addr_t *addr,
uint16_t port, const node_t *node);
+/*
int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
int ipv6exit,
int rejectprivate, uint32_t local_address,
int add_default_policy);
+*/
+int policies_parse_exit_policy_from_options(const or_options_t *or_options,
+ uint32_t local_address,
+ smartlist_t **result);
+int policies_parse_exit_policy(config_line_t *cfg, smartlist_t **dest,
+ exit_policy_parser_cfg_t options,
+ uint32_t local_address);
void policies_exit_policy_append_reject_star(smartlist_t **dest);
void addr_policy_append_reject_addr(smartlist_t **dest,
const tor_addr_t *addr);
diff --git a/src/or/reasons.c b/src/or/reasons.c
index 750e89bbe7..b0f1b65131 100644
--- a/src/or/reasons.c
+++ b/src/or/reasons.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -367,7 +367,7 @@ circuit_end_reason_to_control_string(int reason)
}
}
-/** Return a string corresponding to a SOCKS4 reponse code. */
+/** Return a string corresponding to a SOCKS4 response code. */
const char *
socks4_response_code_to_string(uint8_t code)
{
@@ -385,7 +385,7 @@ socks4_response_code_to_string(uint8_t code)
}
}
-/** Return a string corresponding to a SOCKS5 reponse code. */
+/** Return a string corresponding to a SOCKS5 response code. */
const char *
socks5_response_code_to_string(uint8_t code)
{
diff --git a/src/or/reasons.h b/src/or/reasons.h
index fe7e67722a..8b3694b05a 100644
--- a/src/or/reasons.h
+++ b/src/or/reasons.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/relay.c b/src/or/relay.c
index f42602d412..05c7b3c955 100644
--- a/src/or/relay.c
+++ b/src/or/relay.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -523,6 +523,7 @@ relay_header_unpack(relay_header_t *dest, const uint8_t *src)
static const char *
relay_command_to_string(uint8_t command)
{
+ static char buf[64];
switch (command) {
case RELAY_COMMAND_BEGIN: return "BEGIN";
case RELAY_COMMAND_DATA: return "DATA";
@@ -547,7 +548,12 @@ relay_command_to_string(uint8_t command)
case RELAY_COMMAND_RENDEZVOUS_ESTABLISHED:
return "RENDEZVOUS_ESTABLISHED";
case RELAY_COMMAND_INTRODUCE_ACK: return "INTRODUCE_ACK";
- default: return "(unrecognized)";
+ case RELAY_COMMAND_EXTEND2: return "EXTEND2";
+ case RELAY_COMMAND_EXTENDED2: return "EXTENDED2";
+ default:
+ tor_snprintf(buf, sizeof(buf), "Unrecognized relay command %u",
+ (unsigned)command);
+ return buf;
}
}
@@ -1712,7 +1718,7 @@ connection_edge_process_relay_cell(cell_t *cell, circuit_t *circ,
if (circ->package_window + CIRCWINDOW_INCREMENT >
CIRCWINDOW_START_MAX) {
static struct ratelim_t client_warn_ratelim = RATELIM_INIT(600);
- log_fn_ratelim(&client_warn_ratelim, LOG_WARN, LD_PROTOCOL,
+ log_fn_ratelim(&client_warn_ratelim,LOG_PROTOCOL_WARN, LD_PROTOCOL,
"Unexpected sendme cell from client. "
"Closing circ (window %d).",
circ->package_window);
@@ -2322,15 +2328,15 @@ packed_cell_free(packed_cell_t *cell)
void
dump_cell_pool_usage(int severity)
{
- circuit_t *c;
int n_circs = 0;
int n_cells = 0;
- TOR_LIST_FOREACH(c, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, c) {
n_cells += c->n_chan_cells.n;
if (!CIRCUIT_IS_ORIGIN(c))
n_cells += TO_OR_CIRCUIT(c)->p_chan_cells.n;
++n_circs;
}
+ SMARTLIST_FOREACH_END(c);
tor_log(severity, LD_MM,
"%d cells allocated on %d circuits. %d cells leaked.",
n_cells, n_circs, (int)total_cells_allocated - n_cells);
@@ -2433,6 +2439,7 @@ cell_queues_check_size(void)
{
size_t alloc = cell_queues_get_total_allocation();
alloc += buf_get_total_allocation();
+ alloc += tor_zlib_get_total_allocation();
if (alloc >= get_options()->MaxMemInQueues) {
circuits_handle_oom(alloc);
return 1;
diff --git a/src/or/relay.h b/src/or/relay.h
index 969c6fb61d..73c399154d 100644
--- a/src/or/relay.h
+++ b/src/or/relay.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/rendclient.c b/src/or/rendclient.c
index d42024010d..10d13a37bb 100644
--- a/src/or/rendclient.c
+++ b/src/or/rendclient.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -271,7 +271,7 @@ rend_client_send_introduction(origin_circuit_t *introcirc,
extend_info_t *extend_info = rendcirc->build_state->chosen_exit;
int klen;
/* nul pads */
- set_uint32(tmp+v3_shift+1, tor_addr_to_ipv4h(&extend_info->addr));
+ set_uint32(tmp+v3_shift+1, tor_addr_to_ipv4n(&extend_info->addr));
set_uint16(tmp+v3_shift+5, htons(extend_info->port));
memcpy(tmp+v3_shift+7, extend_info->identity_digest, DIGEST_LEN);
klen = crypto_pk_asn1_encode(extend_info->onion_key,
@@ -376,9 +376,8 @@ rend_client_rendcirc_has_opened(origin_circuit_t *circ)
static void
rend_client_close_other_intros(const char *onion_address)
{
- circuit_t *c;
/* abort parallel intro circs, if any */
- TOR_LIST_FOREACH(c, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, c) {
if ((c->purpose == CIRCUIT_PURPOSE_C_INTRODUCING ||
c->purpose == CIRCUIT_PURPOSE_C_INTRODUCE_ACK_WAIT) &&
!c->marked_for_close && CIRCUIT_IS_ORIGIN(c)) {
@@ -393,6 +392,7 @@ rend_client_close_other_intros(const char *onion_address)
}
}
}
+ SMARTLIST_FOREACH_END(c);
}
/** Called when get an ACK or a NAK for a REND_INTRODUCE1 cell.
diff --git a/src/or/rendclient.h b/src/or/rendclient.h
index 1f731d0ae5..40d388c489 100644
--- a/src/or/rendclient.h
+++ b/src/or/rendclient.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/rendcommon.c b/src/or/rendcommon.c
index a664b5d501..df74b745a2 100644
--- a/src/or/rendcommon.c
+++ b/src/or/rendcommon.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -155,7 +155,7 @@ rend_compute_v2_desc_id(char *desc_id_out, const char *service_id,
}
/* Calculate current time-period. */
time_period = get_time_period(now, 0, service_id_binary);
- /* Calculate secret-id-part = h(time-period + replica). */
+ /* Calculate secret-id-part = h(time-period | replica). */
get_secret_id_part_bytes(secret_id_part, time_period, descriptor_cookie,
replica);
/* Calculate descriptor ID. */
@@ -528,7 +528,7 @@ rend_encode_v2_descriptors(smartlist_t *descs_out,
return -1;
}
/* Base64-encode introduction points. */
- ipos_base64 = tor_malloc_zero(ipos_len * 2);
+ ipos_base64 = tor_calloc(ipos_len, 2);
if (base64_encode(ipos_base64, ipos_len * 2, ipos, ipos_len)<0) {
log_warn(LD_REND, "Could not encode introduction point string to "
"base64. length=%d", (int)ipos_len);
@@ -556,7 +556,7 @@ rend_encode_v2_descriptors(smartlist_t *descs_out,
char desc_digest[DIGEST_LEN];
rend_encoded_v2_service_descriptor_t *enc =
tor_malloc_zero(sizeof(rend_encoded_v2_service_descriptor_t));
- /* Calculate secret-id-part = h(time-period + cookie + replica). */
+ /* Calculate secret-id-part = h(time-period | cookie | replica). */
get_secret_id_part_bytes(secret_id_part, time_period, descriptor_cookie,
k);
base32_encode(secret_id_part_base32, sizeof(secret_id_part_base32),
@@ -1034,10 +1034,14 @@ rend_cache_store_v2_desc_as_dir(const char *desc)
* If the descriptor's service ID does not match
* <b>rend_query</b>-\>onion_address, reject it.
*
+ * If the descriptor's descriptor ID doesn't match <b>desc_id_base32</b>,
+ * reject it.
+ *
* Return an appropriate rend_cache_store_status_t.
*/
rend_cache_store_status_t
rend_cache_store_v2_desc_as_client(const char *desc,
+ const char *desc_id_base32,
const rend_data_t *rend_query)
{
/*XXXX this seems to have a bit of duplicate code with
@@ -1064,10 +1068,19 @@ rend_cache_store_v2_desc_as_client(const char *desc,
time_t now = time(NULL);
char key[REND_SERVICE_ID_LEN_BASE32+2];
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
+ char want_desc_id[DIGEST_LEN];
rend_cache_entry_t *e;
rend_cache_store_status_t retval = RCS_BADDESC;
tor_assert(rend_cache);
tor_assert(desc);
+ tor_assert(desc_id_base32);
+ memset(want_desc_id, 0, sizeof(want_desc_id));
+ if (base32_decode(want_desc_id, sizeof(want_desc_id),
+ desc_id_base32, strlen(desc_id_base32)) != 0) {
+ log_warn(LD_BUG, "Couldn't decode base32 %s for descriptor id.",
+ escaped_safe_str_client(desc_id_base32));
+ goto err;
+ }
/* Parse the descriptor. */
if (rend_parse_v2_service_descriptor(&parsed, desc_id, &intro_content,
&intro_size, &encoded_size,
@@ -1086,6 +1099,12 @@ rend_cache_store_v2_desc_as_client(const char *desc,
service_id, safe_str(rend_query->onion_address));
goto err;
}
+ if (tor_memneq(desc_id, want_desc_id, DIGEST_LEN)) {
+ log_warn(LD_REND, "Received service descriptor for %s with incorrect "
+ "descriptor ID.", service_id);
+ goto err;
+ }
+
/* Decode/decrypt introduction points. */
if (intro_content) {
int n_intro_points;
diff --git a/src/or/rendcommon.h b/src/or/rendcommon.h
index 07a47accfe..186326a0c1 100644
--- a/src/or/rendcommon.h
+++ b/src/or/rendcommon.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -49,6 +49,7 @@ typedef enum {
rend_cache_store_status_t rend_cache_store_v2_desc_as_dir(const char *desc);
rend_cache_store_status_t rend_cache_store_v2_desc_as_client(const char *desc,
+ const char *desc_id_base32,
const rend_data_t *rend_query);
int rend_encode_v2_descriptors(smartlist_t *descs_out,
diff --git a/src/or/rendmid.c b/src/or/rendmid.c
index 1103816806..6a701e7a77 100644
--- a/src/or/rendmid.c
+++ b/src/or/rendmid.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -188,7 +188,7 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
"Unable to send INTRODUCE2 cell to Tor client.");
goto err;
}
- /* And sent an ack down Alice's circuit. Empty body means succeeded. */
+ /* And send an ack down Alice's circuit. Empty body means succeeded. */
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_INTRODUCE_ACK,
NULL,0,NULL)) {
@@ -199,7 +199,7 @@ rend_mid_introduce(or_circuit_t *circ, const uint8_t *request,
return 0;
err:
- /* Send the client an NACK */
+ /* Send the client a NACK */
nak_body[0] = 1;
if (relay_send_command_from_edge(0,TO_CIRCUIT(circ),
RELAY_COMMAND_INTRODUCE_ACK,
@@ -224,9 +224,16 @@ rend_mid_establish_rendezvous(or_circuit_t *circ, const uint8_t *request,
log_info(LD_REND, "Received an ESTABLISH_RENDEZVOUS request on circuit %u",
(unsigned)circ->p_circ_id);
- if (circ->base_.purpose != CIRCUIT_PURPOSE_OR || circ->base_.n_chan) {
+ if (circ->base_.purpose != CIRCUIT_PURPOSE_OR) {
+ log_warn(LD_PROTOCOL,
+ "Tried to establish rendezvous on non-OR circuit with purpose %s",
+ circuit_purpose_to_string(circ->base_.purpose));
+ goto err;
+ }
+
+ if (circ->base_.n_chan) {
log_warn(LD_PROTOCOL,
- "Tried to establish rendezvous on non-OR or non-edge circuit.");
+ "Tried to establish rendezvous on non-edge circuit");
goto err;
}
diff --git a/src/or/rendmid.h b/src/or/rendmid.h
index 310276ac96..25c711fa7b 100644
--- a/src/or/rendmid.h
+++ b/src/or/rendmid.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/rendservice.c b/src/or/rendservice.c
index a7c1e32f15..c586132995 100644
--- a/src/or/rendservice.c
+++ b/src/or/rendservice.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -524,7 +524,6 @@ rend_config_services(const or_options_t *options, int validate_only)
* other ones. */
if (old_service_list && !validate_only) {
smartlist_t *surviving_services = smartlist_new();
- circuit_t *circ;
/* Copy introduction points to new services. */
/* XXXX This is O(n^2), but it's only called on reconfigure, so it's
@@ -544,7 +543,7 @@ rend_config_services(const or_options_t *options, int validate_only)
/* XXXX it would be nicer if we had a nicer abstraction to use here,
* so we could just iterate over the list of services to close, but
* once again, this isn't critical-path code. */
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!circ->marked_for_close &&
circ->state == CIRCUIT_STATE_OPEN &&
(circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
@@ -569,6 +568,7 @@ rend_config_services(const or_options_t *options, int validate_only)
/* XXXX Is there another reason we should use here? */
}
}
+ SMARTLIST_FOREACH_END(circ);
smartlist_free(surviving_services);
SMARTLIST_FOREACH(old_service_list, rend_service_t *, ptr,
rend_service_free(ptr));
@@ -1446,10 +1446,7 @@ rend_service_introduce(origin_circuit_t *circuit, const uint8_t *request,
memwipe(hexcookie, 0, sizeof(hexcookie));
/* Free the parsed cell */
- if (parsed_req) {
- rend_service_free_intro(parsed_req);
- parsed_req = NULL;
- }
+ rend_service_free_intro(parsed_req);
/* Free rp if we must */
if (need_rp_free) extend_info_free(rp);
@@ -1539,7 +1536,6 @@ void
rend_service_free_intro(rend_intro_cell_t *request)
{
if (!request) {
- log_info(LD_BUG, "rend_service_free_intro() called with NULL request!");
return;
}
@@ -1648,8 +1644,9 @@ rend_service_begin_parse_intro(const uint8_t *request,
goto done;
err:
- if (rv) rend_service_free_intro(rv);
+ rend_service_free_intro(rv);
rv = NULL;
+
if (err_msg_out && !err_msg) {
tor_asprintf(&err_msg,
"unknown INTRODUCE%d error",
@@ -1757,7 +1754,7 @@ rend_service_parse_intro_for_v2(
/*
* We accept version 3 too so that the v3 parser can call this with
- * and adjusted buffer for the latter part of a v3 cell, which is
+ * an adjusted buffer for the latter part of a v3 cell, which is
* identical to a v2 cell.
*/
if (!(intro->version == 2 ||
@@ -1985,7 +1982,7 @@ rend_service_decrypt_intro(
char service_id[REND_SERVICE_ID_LEN_BASE32+1];
ssize_t key_len;
uint8_t buf[RELAY_PAYLOAD_SIZE];
- int result, status = 0;
+ int result, status = -1;
if (!intro || !key) {
if (err_msg_out) {
@@ -2064,6 +2061,8 @@ rend_service_decrypt_intro(
intro->plaintext = tor_malloc(intro->plaintext_len);
memcpy(intro->plaintext, buf, intro->plaintext_len);
+ status = 0;
+
goto done;
err:
@@ -2072,7 +2071,6 @@ rend_service_decrypt_intro(
"unknown INTRODUCE%d error decrypting encrypted part",
intro ? (int)(intro->type) : -1);
}
- if (status >= 0) status = -1;
done:
if (err_msg_out) *err_msg_out = err_msg;
@@ -2099,7 +2097,7 @@ rend_service_parse_intro_plaintext(
char *err_msg = NULL;
ssize_t ver_specific_len, ver_invariant_len;
uint8_t version;
- int status = 0;
+ int status = -1;
if (!intro) {
if (err_msg_out) {
@@ -2158,6 +2156,7 @@ rend_service_parse_intro_plaintext(
(int)(intro->type),
(long)(intro->plaintext_len));
status = -6;
+ goto err;
} else {
memcpy(intro->rc,
intro->plaintext + ver_specific_len,
@@ -2170,6 +2169,7 @@ rend_service_parse_intro_plaintext(
/* Flag it as being fully parsed */
intro->parsed = 1;
+ status = 0;
goto done;
err:
@@ -2178,7 +2178,6 @@ rend_service_parse_intro_plaintext(
"unknown INTRODUCE%d error parsing encrypted part",
intro ? (int)(intro->type) : -1);
}
- if (status >= 0) status = -1;
done:
if (err_msg_out) *err_msg_out = err_msg;
@@ -2384,8 +2383,7 @@ static int
count_established_intro_points(const char *query)
{
int num_ipos = 0;
- circuit_t *circ;
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
if (!circ->marked_for_close &&
circ->state == CIRCUIT_STATE_OPEN &&
(circ->purpose == CIRCUIT_PURPOSE_S_ESTABLISH_INTRO ||
@@ -2396,6 +2394,7 @@ count_established_intro_points(const char *query)
num_ipos++;
}
}
+ SMARTLIST_FOREACH_END(circ);
return num_ipos;
}
@@ -3029,15 +3028,16 @@ rend_services_introduce(void)
int intro_point_set_changed, prev_intro_nodes;
unsigned int n_intro_points_unexpired;
unsigned int n_intro_points_to_open;
- smartlist_t *intro_nodes;
time_t now;
const or_options_t *options = get_options();
+ /* List of nodes we need to _exclude_ when choosing a new node to establish
+ * an intro point to. */
+ smartlist_t *exclude_nodes = smartlist_new();
- intro_nodes = smartlist_new();
now = time(NULL);
for (i=0; i < smartlist_len(rend_service_list); ++i) {
- smartlist_clear(intro_nodes);
+ smartlist_clear(exclude_nodes);
service = smartlist_get(rend_service_list, i);
tor_assert(service);
@@ -3136,8 +3136,10 @@ rend_services_introduce(void)
if (intro != NULL && intro->time_expiring == -1)
++n_intro_points_unexpired;
+ /* Add the valid node to the exclusion list so we don't try to establish
+ * an introduction point to it again. */
if (node)
- smartlist_add(intro_nodes, (void*)node);
+ smartlist_add(exclude_nodes, (void*)node);
} SMARTLIST_FOREACH_END(intro);
if (!intro_point_set_changed &&
@@ -3173,7 +3175,7 @@ rend_services_introduce(void)
router_crn_flags_t flags = CRN_NEED_UPTIME|CRN_NEED_DESC;
if (get_options()->AllowInvalid_ & ALLOW_INVALID_INTRODUCTION)
flags |= CRN_ALLOW_INVALID;
- node = router_choose_random_node(intro_nodes,
+ node = router_choose_random_node(exclude_nodes,
options->ExcludeNodes, flags);
if (!node) {
log_warn(LD_REND,
@@ -3184,7 +3186,9 @@ rend_services_introduce(void)
break;
}
intro_point_set_changed = 1;
- smartlist_add(intro_nodes, (void*)node);
+ /* Add the choosen node to the exclusion list in order to avoid to pick
+ * it again in the next iteration. */
+ smartlist_add(exclude_nodes, (void*)node);
intro = tor_malloc_zero(sizeof(rend_intro_point_t));
intro->extend_info = extend_info_from_node(node, 0);
intro->intro_key = crypto_pk_new();
@@ -3213,7 +3217,7 @@ rend_services_introduce(void)
}
}
}
- smartlist_free(intro_nodes);
+ smartlist_free(exclude_nodes);
}
/** Regenerate and upload rendezvous service descriptors for all
diff --git a/src/or/rendservice.h b/src/or/rendservice.h
index 40198b07ec..c2342ef573 100644
--- a/src/or/rendservice.h
+++ b/src/or/rendservice.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/rephist.c b/src/or/rephist.c
index 5446c25e36..f1e882729b 100644
--- a/src/or/rephist.c
+++ b/src/or/rephist.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -1570,7 +1570,7 @@ rep_hist_load_bwhist_state_section(bw_array_t *b,
time_t start;
uint64_t v, mv;
- int i,ok,ok_m;
+ int i,ok,ok_m = 0;
int have_maxima = s_maxima && s_values &&
(smartlist_len(s_values) == smartlist_len(s_maxima));
@@ -1998,12 +1998,9 @@ void
rep_hist_exit_stats_init(time_t now)
{
start_of_exit_stats_interval = now;
- exit_bytes_read = tor_malloc_zero(EXIT_STATS_NUM_PORTS *
- sizeof(uint64_t));
- exit_bytes_written = tor_malloc_zero(EXIT_STATS_NUM_PORTS *
- sizeof(uint64_t));
- exit_streams = tor_malloc_zero(EXIT_STATS_NUM_PORTS *
- sizeof(uint32_t));
+ exit_bytes_read = tor_calloc(EXIT_STATS_NUM_PORTS, sizeof(uint64_t));
+ exit_bytes_written = tor_calloc(EXIT_STATS_NUM_PORTS, sizeof(uint64_t));
+ exit_streams = tor_calloc(EXIT_STATS_NUM_PORTS, sizeof(uint32_t));
}
/** Reset counters for exit port statistics. */
@@ -2474,7 +2471,6 @@ rep_hist_format_buffer_stats(time_t now)
time_t
rep_hist_buffer_stats_write(time_t now)
{
- circuit_t *circ;
char *str = NULL;
if (!start_of_buffer_stats_interval)
@@ -2483,9 +2479,10 @@ rep_hist_buffer_stats_write(time_t now)
goto done; /* Not ready to write */
/* Add open circuits to the history. */
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head) {
+ SMARTLIST_FOREACH_BEGIN(circuit_get_global_list(), circuit_t *, circ) {
rep_hist_buffer_stats_add_circ(circ, now);
}
+ SMARTLIST_FOREACH_END(circ);
/* Generate history string. */
str = rep_hist_format_buffer_stats(now);
@@ -2572,7 +2569,7 @@ rep_hist_format_desc_stats(time_t now)
size = digestmap_size(served_descs);
if (size > 0) {
- vals = tor_malloc(size * sizeof(int));
+ vals = tor_calloc(size, sizeof(int));
for (iter = digestmap_iter_init(served_descs);
!digestmap_iter_done(iter);
iter = digestmap_iter_next(served_descs, iter)) {
@@ -2727,8 +2724,8 @@ bidi_map_ent_hash(const bidi_map_entry_t *entry)
HT_PROTOTYPE(bidimap, bidi_map_entry_t, node, bidi_map_ent_hash,
bidi_map_ent_eq);
-HT_GENERATE(bidimap, bidi_map_entry_t, node, bidi_map_ent_hash,
- bidi_map_ent_eq, 0.6, malloc, realloc, free);
+HT_GENERATE2(bidimap, bidi_map_entry_t, node, bidi_map_ent_hash,
+ bidi_map_ent_eq, 0.6, tor_reallocarray_, tor_free_)
/* DOCDOC bidi_map_free */
static void
diff --git a/src/or/rephist.h b/src/or/rephist.h
index cd6231e6e4..d853fe2e00 100644
--- a/src/or/rephist.h
+++ b/src/or/rephist.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/replaycache.c b/src/or/replaycache.c
index 90f87c12d5..6d1b59101d 100644
--- a/src/or/replaycache.c
+++ b/src/or/replaycache.c
@@ -1,4 +1,4 @@
- /* Copyright (c) 2012-2013, The Tor Project, Inc. */
+ /* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/*
diff --git a/src/or/replaycache.h b/src/or/replaycache.h
index cd713fe891..904fd45ff1 100644
--- a/src/or/replaycache.h
+++ b/src/or/replaycache.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/or/router.c b/src/or/router.c
index 4fcd4a5b89..01838b4b3e 100644
--- a/src/or/router.c
+++ b/src/or/router.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define ROUTER_PRIVATE
@@ -55,13 +55,11 @@ static crypto_pk_t *onionkey=NULL;
/** Previous private onionskin decryption key: used to decode CREATE cells
* generated by clients that have an older version of our descriptor. */
static crypto_pk_t *lastonionkey=NULL;
-#ifdef CURVE25519_ENABLED
/** Current private ntor secret key: used to perform the ntor handshake. */
static curve25519_keypair_t curve25519_onion_key;
/** Previous private ntor secret key: used to perform the ntor handshake
* with clients that have an older version of our descriptor. */
static curve25519_keypair_t last_curve25519_onion_key;
-#endif
/** Private server "identity key": used to sign directory info and TLS
* certificates. Never changes. */
static crypto_pk_t *server_identitykey=NULL;
@@ -134,7 +132,6 @@ dup_onion_keys(crypto_pk_t **key, crypto_pk_t **last)
tor_mutex_release(key_lock);
}
-#ifdef CURVE25519_ENABLED
/** Return the current secret onion key for the ntor handshake. Must only
* be called from the main thread. */
static const curve25519_keypair_t *
@@ -181,7 +178,6 @@ ntor_key_map_free(di_digest256_map_t *map)
return;
dimap_free(map, ntor_key_map_free_helper);
}
-#endif
/** Return the time when the onion key was last set. This is either the time
* when the process launched, or the time of the most recent key rotation since
@@ -313,9 +309,7 @@ rotate_onion_key(void)
char *fname, *fname_prev;
crypto_pk_t *prkey = NULL;
or_state_t *state = get_or_state();
-#ifdef CURVE25519_ENABLED
curve25519_keypair_t new_curve25519_keypair;
-#endif
time_t now;
fname = get_datadir_fname2("keys", "secret_onion_key");
fname_prev = get_datadir_fname2("keys", "secret_onion_key.old");
@@ -335,7 +329,6 @@ rotate_onion_key(void)
log_err(LD_FS,"Couldn't write generated onion key to \"%s\".", fname);
goto error;
}
-#ifdef CURVE25519_ENABLED
tor_free(fname);
tor_free(fname_prev);
fname = get_datadir_fname2("keys", "secret_onion_key_ntor");
@@ -351,18 +344,15 @@ rotate_onion_key(void)
log_err(LD_FS,"Couldn't write curve25519 onion key to \"%s\".",fname);
goto error;
}
-#endif
log_info(LD_GENERAL, "Rotating onion key");
tor_mutex_acquire(key_lock);
crypto_pk_free(lastonionkey);
lastonionkey = onionkey;
onionkey = prkey;
-#ifdef CURVE25519_ENABLED
memcpy(&last_curve25519_onion_key, &curve25519_onion_key,
sizeof(curve25519_keypair_t));
memcpy(&curve25519_onion_key, &new_curve25519_keypair,
sizeof(curve25519_keypair_t));
-#endif
now = time(NULL);
state->LastRotatedOnionKey = onionkey_set_at = now;
tor_mutex_release(key_lock);
@@ -374,13 +364,31 @@ rotate_onion_key(void)
if (prkey)
crypto_pk_free(prkey);
done:
-#ifdef CURVE25519_ENABLED
memwipe(&new_curve25519_keypair, 0, sizeof(new_curve25519_keypair));
-#endif
tor_free(fname);
tor_free(fname_prev);
}
+/** Log greeting message that points to new relay lifecycle document the
+ * first time this function has been called.
+ */
+static void
+log_new_relay_greeting(void)
+{
+ static int already_logged = 0;
+
+ if (already_logged)
+ return;
+
+ tor_log(LOG_NOTICE, LD_GENERAL, "You are running a new relay. "
+ "Thanks for helping the Tor network! If you wish to know "
+ "what will happen in the upcoming weeks regarding its usage, "
+ "have a look at https://blog.torproject.org/blog/lifecycle-of"
+ "-a-new-relay");
+
+ already_logged = 1;
+}
+
/** Try to read an RSA key from <b>fname</b>. If <b>fname</b> doesn't exist
* and <b>generate</b> is true, create a new RSA key and save it in
* <b>fname</b>. Return the read/created key, or NULL on error. Log all
@@ -425,6 +433,7 @@ init_key_from_file(const char *fname, int generate, int severity)
goto error;
}
log_info(LD_GENERAL, "Generated key seems valid");
+ log_new_relay_greeting();
if (crypto_pk_write_private_key_to_filename(prkey, fname)) {
tor_log(severity, LD_FS,
"Couldn't write generated key to \"%s\".", fname);
@@ -450,7 +459,6 @@ init_key_from_file(const char *fname, int generate, int severity)
return NULL;
}
-#ifdef CURVE25519_ENABLED
/** Load a curve25519 keypair from the file <b>fname</b>, writing it into
* <b>keys_out</b>. If the file isn't found and <b>generate</b> is true,
* create a new keypair and write it into the file. If there are errors, log
@@ -488,7 +496,7 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
if (curve25519_keypair_write_to_file(keys_out, fname, tag)<0) {
tor_log(severity, LD_FS,
"Couldn't write generated key to \"%s\".", fname);
- memset(keys_out, 0, sizeof(*keys_out));
+ memwipe(keys_out, 0, sizeof(*keys_out));
goto error;
}
} else {
@@ -519,7 +527,6 @@ init_curve25519_keypair_from_file(curve25519_keypair_t *keys_out,
error:
return -1;
}
-#endif
/** Try to load the vote-signing private key and certificate for being a v3
* directory authority, and make sure they match. If <b>legacy</b>, load a
@@ -875,7 +882,6 @@ init_keys(void)
}
tor_free(keydir);
-#ifdef CURVE25519_ENABLED
{
/* 2b. Load curve25519 onion keys. */
int r;
@@ -896,7 +902,6 @@ init_keys(void)
}
tor_free(keydir);
}
-#endif
/* 3. Initialize link key and TLS context. */
if (router_initialize_tls_context() < 0) {
@@ -911,14 +916,13 @@ init_keys(void)
const char *m = NULL;
routerinfo_t *ri;
/* We need to add our own fingerprint so it gets recognized. */
- if (dirserv_add_own_fingerprint(options->Nickname,
- get_server_identity_key())) {
- log_err(LD_GENERAL,"Error adding own fingerprint to approved set");
+ if (dirserv_add_own_fingerprint(get_server_identity_key())) {
+ log_err(LD_GENERAL,"Error adding own fingerprint to set of relays");
return -1;
}
if (mydesc) {
was_router_added_t added;
- ri = router_parse_entry_from_string(mydesc, NULL, 1, 0, NULL);
+ ri = router_parse_entry_from_string(mydesc, NULL, 1, 0, NULL, NULL);
if (!ri) {
log_err(LD_GENERAL,"Generated a routerinfo we couldn't parse.");
return -1;
@@ -1081,6 +1085,7 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
* they're confused or to get statistics. */
int interval_length = accounting_get_interval_length();
uint32_t effective_bw = get_effective_bwrate(options);
+ uint64_t acc_bytes;
if (!interval_length) {
log_warn(LD_BUG, "An accounting interval is not allowed to be zero "
"seconds long. Raising to 1.");
@@ -1091,8 +1096,12 @@ decide_to_advertise_dirport(const or_options_t *options, uint16_t dir_port)
"accounting interval length %d", effective_bw,
U64_PRINTF_ARG(options->AccountingMax),
interval_length);
+
+ acc_bytes = options->AccountingMax;
+ if (get_options()->AccountingRule == ACCT_SUM)
+ acc_bytes /= 2;
if (effective_bw >=
- options->AccountingMax / interval_length) {
+ acc_bytes / interval_length) {
new_choice = 0;
reason = "AccountingMax enabled";
}
@@ -1802,11 +1811,9 @@ router_rebuild_descriptor(int force)
ri->cache_info.published_on = time(NULL);
ri->onion_pkey = crypto_pk_dup_key(get_onion_key()); /* must invoke from
* main thread */
-#ifdef CURVE25519_ENABLED
ri->onion_curve25519_pkey =
tor_memdup(&get_current_curve25519_keypair()->pubkey,
sizeof(curve25519_public_key_t));
-#endif
/* For now, at most one IPv6 or-address is being advertised. */
{
@@ -1856,10 +1863,8 @@ router_rebuild_descriptor(int force)
/* DNS is screwed up; don't claim to be an exit. */
policies_exit_policy_append_reject_star(&ri->exit_policy);
} else {
- policies_parse_exit_policy(options->ExitPolicy, &ri->exit_policy,
- options->IPv6Exit,
- options->ExitPolicyRejectPrivate,
- ri->addr, !options->BridgeRelay);
+ policies_parse_exit_policy_from_options(options,ri->addr,
+ &ri->exit_policy);
}
ri->policy_is_reject_star =
policy_is_reject_star(ri->exit_policy, AF_INET) &&
@@ -1879,7 +1884,7 @@ router_rebuild_descriptor(int force)
family = smartlist_new();
ri->declared_family = smartlist_new();
smartlist_split_string(family, options->MyFamily, ",",
- SPLIT_SKIP_SPACE|SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
+ SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK|SPLIT_STRIP_SPACE, 0);
SMARTLIST_FOREACH_BEGIN(family, char *, name) {
const node_t *member;
if (!strcasecmp(name, options->Nickname))
@@ -2063,7 +2068,8 @@ mark_my_descriptor_dirty(const char *reason)
}
/** How frequently will we republish our descriptor because of large (factor
- * of 2) shifts in estimated bandwidth? */
+ * of 2) shifts in estimated bandwidth? Note: We don't use this constant
+ * if our previous bandwidth estimate was exactly 0. */
#define MAX_BANDWIDTH_CHANGE_FREQ (20*60)
/** Check whether bandwidth has changed a lot since the last time we announced
@@ -2081,7 +2087,7 @@ check_descriptor_bandwidth_changed(time_t now)
if ((prev != cur && (!prev || !cur)) ||
cur > prev*2 ||
cur < prev/2) {
- if (last_changed+MAX_BANDWIDTH_CHANGE_FREQ < now) {
+ if (last_changed+MAX_BANDWIDTH_CHANGE_FREQ < now || !prev) {
log_info(LD_GENERAL,
"Measured bandwidth has changed; rebuilding descriptor.");
mark_my_descriptor_dirty("bandwidth has changed");
@@ -2386,7 +2392,6 @@ router_dump_router_to_string(routerinfo_t *router,
smartlist_add_asprintf(chunks, "contact %s\n", ci);
}
-#ifdef CURVE25519_ENABLED
if (router->onion_curve25519_pkey) {
char kbuf[128];
base64_encode(kbuf, sizeof(kbuf),
@@ -2394,7 +2399,6 @@ router_dump_router_to_string(routerinfo_t *router,
CURVE25519_PUBKEY_LEN);
smartlist_add_asprintf(chunks, "ntor-onion-key %s", kbuf);
}
-#endif
/* Write the exit policy to the end of 's'. */
if (!router->exit_policy || !smartlist_len(router->exit_policy)) {
@@ -2444,7 +2448,7 @@ router_dump_router_to_string(routerinfo_t *router,
const char *cp;
routerinfo_t *ri_tmp;
cp = s_dup = tor_strdup(output);
- ri_tmp = router_parse_entry_from_string(cp, NULL, 1, 0, NULL);
+ ri_tmp = router_parse_entry_from_string(cp, NULL, 1, 0, NULL, NULL);
if (!ri_tmp) {
log_err(LD_BUG,
"We just generated a router descriptor we can't parse.");
@@ -2726,7 +2730,7 @@ extrainfo_dump_to_string(char **s_out, extrainfo_t *extrainfo,
s = smartlist_join_strings(chunks, "", 0, NULL);
cp = s_dup = tor_strdup(s);
- ei_tmp = extrainfo_parse_entry_from_string(cp, NULL, 1, NULL);
+ ei_tmp = extrainfo_parse_entry_from_string(cp, NULL, 1, NULL, NULL);
if (!ei_tmp) {
if (write_stats_to_extrainfo) {
log_warn(LD_GENERAL, "We just generated an extra-info descriptor "
@@ -3070,10 +3074,8 @@ router_free_all(void)
crypto_pk_free(legacy_signing_key);
authority_cert_free(legacy_key_certificate);
-#ifdef CURVE25519_ENABLED
memwipe(&curve25519_onion_key, 0, sizeof(curve25519_onion_key));
memwipe(&last_curve25519_onion_key, 0, sizeof(last_curve25519_onion_key));
-#endif
if (warned_nonexistent_family) {
SMARTLIST_FOREACH(warned_nonexistent_family, char *, cp, tor_free(cp));
diff --git a/src/or/router.h b/src/or/router.h
index d18ff065ea..16d3845be1 100644
--- a/src/or/router.h
+++ b/src/or/router.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -32,10 +32,8 @@ crypto_pk_t *init_key_from_file(const char *fname, int generate,
int severity);
void v3_authority_check_key_expiry(void);
-#ifdef CURVE25519_ENABLED
di_digest256_map_t *construct_ntor_key_map(void);
void ntor_key_map_free(di_digest256_map_t *map);
-#endif
int router_initialize_tls_context(void);
int init_keys(void);
diff --git a/src/or/routerlist.c b/src/or/routerlist.c
index 5bad2b2e5c..d81dae4676 100644
--- a/src/or/routerlist.c
+++ b/src/or/routerlist.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -79,6 +79,7 @@ static const char *signed_descriptor_get_body_impl(
const signed_descriptor_t *desc,
int with_annotations);
static void list_pending_downloads(digestmap_t *result,
+ digest256map_t *result256,
int purpose, const char *prefix);
static void list_pending_fpsk_downloads(fp_pair_map_t *result);
static void launch_dummy_descriptor_download_as_needed(time_t now,
@@ -475,6 +476,8 @@ trusted_dirs_remove_old_certs(void)
time_t cert_published;
if (newest == cert)
continue;
+ /* resolve spurious clang shallow analysis null pointer errors */
+ tor_assert(cert);
expired = now > cert->expires;
cert_published = cert->cache_info.published_on;
/* Store expired certs for 48 hours after a newer arrives;
@@ -715,7 +718,8 @@ authority_certs_fetch_missing(networkstatus_t *status, time_t now)
* First, we get the lists of already pending downloads so we don't
* duplicate effort.
*/
- list_pending_downloads(pending_id, DIR_PURPOSE_FETCH_CERTIFICATE, "fp/");
+ list_pending_downloads(pending_id, NULL,
+ DIR_PURPOSE_FETCH_CERTIFICATE, "fp/");
list_pending_fpsk_downloads(pending_cert);
/*
@@ -1367,7 +1371,7 @@ router_pick_trusteddirserver(dirinfo_type_t type, int flags)
return router_pick_dirserver_generic(trusted_dir_servers, type, flags);
}
-/** Try to find a running fallback directory Flags are as for
+/** Try to find a running fallback directory. Flags are as for
* router_pick_directory_server.
*/
const routerstatus_t *
@@ -1376,7 +1380,7 @@ router_pick_fallback_dirserver(dirinfo_type_t type, int flags)
return router_pick_dirserver_generic(fallback_dir_servers, type, flags);
}
-/** Try to find a running fallback directory Flags are as for
+/** Try to find a running fallback directory. Flags are as for
* router_pick_directory_server.
*/
static const routerstatus_t *
@@ -1450,8 +1454,6 @@ router_pick_directory_server_impl(dirinfo_type_t type, int flags)
if (!node->is_running || !status->dir_port || !node->is_valid)
continue;
- if (node->is_bad_directory)
- continue;
if (requireother && router_digest_is_me(node->identity))
continue;
is_trusted = router_digest_is_trusted_dir(node->identity);
@@ -1534,7 +1536,7 @@ dirserver_choose_by_weight(const smartlist_t *servers, double authority_weight)
u64_dbl_t *weights;
const dir_server_t *ds;
- weights = tor_malloc(sizeof(u64_dbl_t) * n);
+ weights = tor_calloc(n, sizeof(u64_dbl_t));
for (i = 0; i < n; ++i) {
ds = smartlist_get(servers, i);
weights[i].dbl = ds->weight;
@@ -1806,15 +1808,16 @@ scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
uint64_t *total_out)
{
double total = 0.0;
- double scale_factor;
+ double scale_factor = 0.0;
int i;
/* big, but far away from overflowing an int64_t */
-#define SCALE_TO_U64_MAX (INT64_MAX / 4)
+#define SCALE_TO_U64_MAX ((int64_t) (INT64_MAX / 4))
for (i = 0; i < n_entries; ++i)
total += entries[i].dbl;
- scale_factor = SCALE_TO_U64_MAX / total;
+ if (total > 0.0)
+ scale_factor = SCALE_TO_U64_MAX / total;
for (i = 0; i < n_entries; ++i)
entries[i].u64 = tor_llround(entries[i].dbl * scale_factor);
@@ -2042,7 +2045,7 @@ compute_weighted_bandwidths(const smartlist_t *sl,
Web /= weight_scale;
Wdb /= weight_scale;
- bandwidths = tor_malloc_zero(sizeof(u64_dbl_t)*smartlist_len(sl));
+ bandwidths = tor_calloc(smartlist_len(sl), sizeof(u64_dbl_t));
// Cycle through smartlist and total the bandwidth.
SMARTLIST_FOREACH_BEGIN(sl, const node_t *, node) {
@@ -2189,7 +2192,7 @@ smartlist_choose_node_by_bandwidth(const smartlist_t *sl,
/* First count the total bandwidth weight, and make a list
* of each value. We use UINT64_MAX to indicate "unknown". */
- bandwidths = tor_malloc_zero(sizeof(u64_dbl_t)*smartlist_len(sl));
+ bandwidths = tor_calloc(smartlist_len(sl), sizeof(u64_dbl_t));
fast_bits = bitarray_init_zero(smartlist_len(sl));
exit_bits = bitarray_init_zero(smartlist_len(sl));
guard_bits = bitarray_init_zero(smartlist_len(sl));
@@ -2201,7 +2204,7 @@ smartlist_choose_node_by_bandwidth(const smartlist_t *sl,
uint32_t this_bw = 0;
i = node_sl_idx;
- is_exit = node->is_exit;
+ is_exit = node_is_good_exit(node);
is_guard = node->is_possible_guard;
if (node->rs) {
if (node->rs->has_bandwidth) {
@@ -2533,7 +2536,7 @@ router_is_named(const routerinfo_t *router)
/** Return true iff <b>digest</b> is the digest of the identity key of a
* trusted directory matching at least one bit of <b>type</b>. If <b>type</b>
- * is zero, any authority is okay. */
+ * is zero (NO_DIRINFO), or ALL_DIRINFO, any authority is okay. */
int
router_digest_is_trusted_dir_type(const char *digest, dirinfo_type_t type)
{
@@ -2614,8 +2617,8 @@ router_get_by_descriptor_digest(const char *digest)
/** Return the signed descriptor for the router in our routerlist whose
* 20-byte extra-info digest is <b>digest</b>. Return NULL if no such router
* is known. */
-signed_descriptor_t *
-router_get_by_extrainfo_digest(const char *digest)
+MOCK_IMPL(signed_descriptor_t *,
+router_get_by_extrainfo_digest,(const char *digest))
{
tor_assert(digest);
@@ -2936,12 +2939,12 @@ routerlist_insert(routerlist_t *rl, routerinfo_t *ri)
}
/** Adds the extrainfo_t <b>ei</b> to the routerlist <b>rl</b>, if there is a
- * corresponding router in rl-\>routers or rl-\>old_routers. Return true iff
- * we actually inserted <b>ei</b>. Free <b>ei</b> if it isn't inserted. */
-static int
-extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
+ * corresponding router in rl-\>routers or rl-\>old_routers. Return the status
+ * of inserting <b>ei</b>. Free <b>ei</b> if it isn't inserted. */
+MOCK_IMPL(STATIC was_router_added_t,
+extrainfo_insert,(routerlist_t *rl, extrainfo_t *ei))
{
- int r = 0;
+ was_router_added_t r;
routerinfo_t *ri = rimap_get(rl->identity_map,
ei->cache_info.identity_digest);
signed_descriptor_t *sd =
@@ -2955,9 +2958,12 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
if (!ri) {
/* This router is unknown; we can't even verify the signature. Give up.*/
+ r = ROUTER_NOT_IN_CONSENSUS;
goto done;
}
if (routerinfo_incompatible_with_extrainfo(ri, ei, sd, NULL)) {
+ r = (ri->cache_info.extrainfo_is_bogus) ?
+ ROUTER_BAD_EI : ROUTER_NOT_IN_CONSENSUS;
goto done;
}
@@ -2967,7 +2973,7 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
ei_tmp = eimap_set(rl->extra_info_map,
ei->cache_info.signed_descriptor_digest,
ei);
- r = 1;
+ r = ROUTER_ADDED_SUCCESSFULLY;
if (ei_tmp) {
rl->extrainfo_store.bytes_dropped +=
ei_tmp->cache_info.signed_descriptor_len;
@@ -2975,7 +2981,7 @@ extrainfo_insert(routerlist_t *rl, extrainfo_t *ei)
}
done:
- if (r == 0)
+ if (r != ROUTER_ADDED_SUCCESSFULLY)
extrainfo_free(ei);
#ifdef DEBUG_ROUTERLIST
@@ -3250,7 +3256,7 @@ routerlist_reparse_old(routerlist_t *rl, signed_descriptor_t *sd)
ri = router_parse_entry_from_string(body,
body+sd->signed_descriptor_len+sd->annotations_len,
- 0, 1, NULL);
+ 0, 1, NULL, NULL);
if (!ri)
return NULL;
memcpy(&ri->cache_info, sd, sizeof(signed_descriptor_t));
@@ -3301,7 +3307,7 @@ routerlist_reset_warnings(void)
MOCK_IMPL(int,
router_descriptor_is_older_than,(const routerinfo_t *router, int seconds))
{
- return router->cache_info.published_on < time(NULL) - seconds;
+ return router->cache_info.published_on < approx_time() - seconds;
}
/** Add <b>router</b> to the routerlist, if we don't already have it. Replace
@@ -3476,7 +3482,7 @@ router_add_to_routerlist(routerinfo_t *router, const char **msg,
router_descriptor_is_older_than(router, OLD_ROUTER_DESC_MAX_AGE)) {
*msg = "Router descriptor was really old.";
routerinfo_free(router);
- return ROUTER_WAS_NOT_NEW;
+ return ROUTER_WAS_TOO_OLD;
}
/* We haven't seen a router with this identity before. Add it to the end of
@@ -3497,21 +3503,18 @@ was_router_added_t
router_add_extrainfo_to_routerlist(extrainfo_t *ei, const char **msg,
int from_cache, int from_fetch)
{
- int inserted;
+ was_router_added_t inserted;
(void)from_fetch;
if (msg) *msg = NULL;
/*XXXX023 Do something with msg */
inserted = extrainfo_insert(router_get_routerlist(), ei);
- if (inserted && !from_cache)
+ if (WRA_WAS_ADDED(inserted) && !from_cache)
signed_desc_append_to_journal(&ei->cache_info,
&routerlist->extrainfo_store);
- if (inserted)
- return ROUTER_ADDED_SUCCESSFULLY;
- else
- return ROUTER_BAD_EI;
+ return inserted;
}
/** Sorting helper: return &lt;0, 0, or &gt;0 depending on whether the
@@ -3581,9 +3584,9 @@ routerlist_remove_old_cached_routers_with_id(time_t now,
n_extra = n - mdpr;
}
- lifespans = tor_malloc_zero(sizeof(struct duration_idx_t)*n);
- rmv = tor_malloc_zero(sizeof(uint8_t)*n);
- must_keep = tor_malloc_zero(sizeof(uint8_t)*n);
+ lifespans = tor_calloc(n, sizeof(struct duration_idx_t));
+ rmv = tor_calloc(n, sizeof(uint8_t));
+ must_keep = tor_calloc(n, sizeof(uint8_t));
/* Set lifespans to contain the lifespan and index of each server. */
/* Set rmv[i-lo]=1 if we're going to remove a server for being too old. */
for (i = lo; i <= hi; ++i) {
@@ -3806,7 +3809,8 @@ router_load_single_router(const char *s, uint8_t purpose, int cache,
"@source controller\n"
"@purpose %s\n", router_purpose_to_string(purpose));
- if (!(ri = router_parse_entry_from_string(s, NULL, 1, 0, annotation_buf))) {
+ if (!(ri = router_parse_entry_from_string(s, NULL, 1, 0,
+ annotation_buf, NULL))) {
log_warn(LD_DIR, "Error parsing router descriptor; dropping.");
*msg = "Couldn't parse router descriptor.";
return -1;
@@ -3870,9 +3874,11 @@ router_load_routers_from_string(const char *s, const char *eos,
int from_cache = (saved_location != SAVED_NOWHERE);
int allow_annotations = (saved_location != SAVED_NOWHERE);
int any_changed = 0;
+ smartlist_t *invalid_digests = smartlist_new();
router_parse_list_from_string(&s, eos, routers, saved_location, 0,
- allow_annotations, prepend_annotations);
+ allow_annotations, prepend_annotations,
+ invalid_digests);
routers_update_status_from_consensus_networkstatus(routers, !from_cache);
@@ -3908,7 +3914,7 @@ router_load_routers_from_string(const char *s, const char *eos,
smartlist_add(changed, ri);
routerlist_descriptors_added(changed, from_cache);
smartlist_clear(changed);
- } else if (WRA_WAS_REJECTED(r)) {
+ } else if (WRA_NEVER_DOWNLOADABLE(r)) {
download_status_t *dl_status;
dl_status = router_get_dl_status_by_descriptor_digest(d);
if (dl_status) {
@@ -3919,6 +3925,27 @@ router_load_routers_from_string(const char *s, const char *eos,
}
} SMARTLIST_FOREACH_END(ri);
+ SMARTLIST_FOREACH_BEGIN(invalid_digests, const uint8_t *, bad_digest) {
+ /* This digest is never going to be parseable. */
+ base16_encode(fp, sizeof(fp), (char*)bad_digest, DIGEST_LEN);
+ if (requested_fingerprints && descriptor_digests) {
+ if (! smartlist_contains_string(requested_fingerprints, fp)) {
+ /* But we didn't ask for it, so we should assume shennanegans. */
+ continue;
+ }
+ smartlist_string_remove(requested_fingerprints, fp);
+ }
+ download_status_t *dls;
+ dls = router_get_dl_status_by_descriptor_digest((char*)bad_digest);
+ if (dls) {
+ log_info(LD_GENERAL, "Marking router with descriptor %s as unparseable, "
+ "and therefore undownloadable", fp);
+ download_status_mark_impossible(dls);
+ }
+ } SMARTLIST_FOREACH_END(bad_digest);
+ SMARTLIST_FOREACH(invalid_digests, uint8_t *, d, tor_free(d));
+ smartlist_free(invalid_digests);
+
routerlist_assert_ok(routerlist);
if (any_changed)
@@ -3942,13 +3969,16 @@ router_load_extrainfo_from_string(const char *s, const char *eos,
smartlist_t *extrainfo_list = smartlist_new();
const char *msg;
int from_cache = (saved_location != SAVED_NOWHERE);
+ smartlist_t *invalid_digests = smartlist_new();
router_parse_list_from_string(&s, eos, extrainfo_list, saved_location, 1, 0,
- NULL);
+ NULL, invalid_digests);
log_info(LD_DIR, "%d elements to add", smartlist_len(extrainfo_list));
SMARTLIST_FOREACH_BEGIN(extrainfo_list, extrainfo_t *, ei) {
+ uint8_t d[DIGEST_LEN];
+ memcpy(d, ei->cache_info.signed_descriptor_digest, DIGEST_LEN);
was_router_added_t added =
router_add_extrainfo_to_routerlist(ei, &msg, from_cache, !from_cache);
if (WRA_WAS_ADDED(added) && requested_fingerprints) {
@@ -3962,9 +3992,39 @@ router_load_extrainfo_from_string(const char *s, const char *eos,
* so long as we would have wanted them anyway. Since we always fetch
* all the extrainfos we want, and we never actually act on them
* inside Tor, this should be harmless. */
+ } else if (WRA_NEVER_DOWNLOADABLE(added)) {
+ signed_descriptor_t *sd = router_get_by_extrainfo_digest((char*)d);
+ if (sd) {
+ log_info(LD_GENERAL, "Marking extrainfo with descriptor %s as "
+ "unparseable, and therefore undownloadable",
+ hex_str((char*)d,DIGEST_LEN));
+ download_status_mark_impossible(&sd->ei_dl_status);
+ }
}
} SMARTLIST_FOREACH_END(ei);
+ SMARTLIST_FOREACH_BEGIN(invalid_digests, const uint8_t *, bad_digest) {
+ /* This digest is never going to be parseable. */
+ char fp[HEX_DIGEST_LEN+1];
+ base16_encode(fp, sizeof(fp), (char*)bad_digest, DIGEST_LEN);
+ if (requested_fingerprints) {
+ if (! smartlist_contains_string(requested_fingerprints, fp)) {
+ /* But we didn't ask for it, so we should assume shennanegans. */
+ continue;
+ }
+ smartlist_string_remove(requested_fingerprints, fp);
+ }
+ signed_descriptor_t *sd =
+ router_get_by_extrainfo_digest((char*)bad_digest);
+ if (sd) {
+ log_info(LD_GENERAL, "Marking extrainfo with descriptor %s as "
+ "unparseable, and therefore undownloadable", fp);
+ download_status_mark_impossible(&sd->ei_dl_status);
+ }
+ } SMARTLIST_FOREACH_END(bad_digest);
+ SMARTLIST_FOREACH(invalid_digests, uint8_t *, d, tor_free(d));
+ smartlist_free(invalid_digests);
+
routerlist_assert_ok(routerlist);
router_rebuild_store(0, &router_get_routerlist()->extrainfo_store);
@@ -4210,7 +4270,7 @@ clear_dir_servers(void)
* corresponding elements of <b>result</b> to a nonzero value.
*/
static void
-list_pending_downloads(digestmap_t *result,
+list_pending_downloads(digestmap_t *result, digest256map_t *result256,
int purpose, const char *prefix)
{
const size_t p_len = strlen(prefix);
@@ -4220,7 +4280,7 @@ list_pending_downloads(digestmap_t *result,
if (purpose == DIR_PURPOSE_FETCH_MICRODESC)
flags = DSR_DIGEST256|DSR_BASE64;
- tor_assert(result);
+ tor_assert(result || result256);
SMARTLIST_FOREACH_BEGIN(conns, connection_t *, conn) {
if (conn->type == CONN_TYPE_DIR &&
@@ -4233,11 +4293,19 @@ list_pending_downloads(digestmap_t *result,
}
} SMARTLIST_FOREACH_END(conn);
- SMARTLIST_FOREACH(tmp, char *, d,
+ if (result) {
+ SMARTLIST_FOREACH(tmp, char *, d,
{
digestmap_set(result, d, (void*)1);
tor_free(d);
});
+ } else if (result256) {
+ SMARTLIST_FOREACH(tmp, uint8_t *, d,
+ {
+ digest256map_set(result256, d, (void*)1);
+ tor_free(d);
+ });
+ }
smartlist_free(tmp);
}
@@ -4249,20 +4317,16 @@ list_pending_descriptor_downloads(digestmap_t *result, int extrainfo)
{
int purpose =
extrainfo ? DIR_PURPOSE_FETCH_EXTRAINFO : DIR_PURPOSE_FETCH_SERVERDESC;
- list_pending_downloads(result, purpose, "d/");
+ list_pending_downloads(result, NULL, purpose, "d/");
}
/** For every microdescriptor we are currently downloading by descriptor
- * digest, set result[d] to (void*)1. (Note that microdescriptor digests
- * are 256-bit, and digestmap_t only holds 160-bit digests, so we're only
- * getting the first 20 bytes of each digest here.)
- *
- * XXXX Let there be a digestmap256_t, and use that instead.
+ * digest, set result[d] to (void*)1.
*/
void
-list_pending_microdesc_downloads(digestmap_t *result)
+list_pending_microdesc_downloads(digest256map_t *result)
{
- list_pending_downloads(result, DIR_PURPOSE_FETCH_MICRODESC, "d/");
+ list_pending_downloads(NULL, result, DIR_PURPOSE_FETCH_MICRODESC, "d/");
}
/** For every certificate we are currently downloading by (identity digest,
@@ -4950,7 +5014,7 @@ routerlist_assert_ok(const routerlist_t *rl)
} SMARTLIST_FOREACH_END(r);
SMARTLIST_FOREACH_BEGIN(rl->old_routers, signed_descriptor_t *, sd) {
r2 = rimap_get(rl->identity_map, sd->identity_digest);
- tor_assert(sd != &(r2->cache_info));
+ tor_assert(!r2 || sd != &(r2->cache_info));
sd2 = sdmap_get(rl->desc_digest_map, sd->signed_descriptor_digest);
tor_assert(sd == sd2);
tor_assert(sd->routerlist_index == sd_sl_idx);
diff --git a/src/or/routerlist.h b/src/or/routerlist.h
index 52f2303c7c..c6151deb49 100644
--- a/src/or/routerlist.h
+++ b/src/or/routerlist.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -82,7 +82,8 @@ int hexdigest_to_digest(const char *hexdigest, char *digest);
const routerinfo_t *router_get_by_id_digest(const char *digest);
routerinfo_t *router_get_mutable_by_digest(const char *digest);
signed_descriptor_t *router_get_by_descriptor_digest(const char *digest);
-signed_descriptor_t *router_get_by_extrainfo_digest(const char *digest);
+MOCK_DECL(signed_descriptor_t *,router_get_by_extrainfo_digest,
+ (const char *digest));
signed_descriptor_t *extrainfo_get_by_descriptor_digest(const char *digest);
const char *signed_descriptor_get_body(const signed_descriptor_t *desc);
const char *signed_descriptor_get_annotations(const signed_descriptor_t *desc);
@@ -99,6 +100,7 @@ void routerlist_reset_warnings(void);
static int WRA_WAS_ADDED(was_router_added_t s);
static int WRA_WAS_OUTDATED(was_router_added_t s);
static int WRA_WAS_REJECTED(was_router_added_t s);
+static int WRA_NEVER_DOWNLOADABLE(was_router_added_t s);
/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
* was added. It might still be necessary to check whether the descriptor
* generator should be notified.
@@ -115,7 +117,8 @@ WRA_WAS_ADDED(was_router_added_t s) {
*/
static INLINE int WRA_WAS_OUTDATED(was_router_added_t s)
{
- return (s == ROUTER_WAS_NOT_NEW ||
+ return (s == ROUTER_WAS_TOO_OLD ||
+ s == ROUTER_WAS_NOT_NEW ||
s == ROUTER_NOT_IN_CONSENSUS ||
s == ROUTER_NOT_IN_CONSENSUS_OR_NETWORKSTATUS);
}
@@ -125,6 +128,14 @@ static INLINE int WRA_WAS_REJECTED(was_router_added_t s)
{
return (s == ROUTER_AUTHDIR_REJECTS);
}
+/** Return true iff the outcome code in <b>s</b> indicates that the descriptor
+ * was flat-out rejected. */
+static INLINE int WRA_NEVER_DOWNLOADABLE(was_router_added_t s)
+{
+ return (s == ROUTER_AUTHDIR_REJECTS ||
+ s == ROUTER_BAD_EI ||
+ s == ROUTER_WAS_TOO_OLD);
+}
was_router_added_t router_add_to_routerlist(routerinfo_t *router,
const char **msg,
int from_cache,
@@ -185,7 +196,7 @@ int hid_serv_get_responsible_directories(smartlist_t *responsible_dirs,
int hid_serv_acting_as_directory(void);
int hid_serv_responsible_for_desc_id(const char *id);
-void list_pending_microdesc_downloads(digestmap_t *result);
+void list_pending_microdesc_downloads(digest256map_t *result);
void launch_descriptor_downloads(int purpose,
smartlist_t *downloadable,
const routerstatus_t *source,
@@ -215,6 +226,9 @@ STATIC void scale_array_elements_to_u64(u64_dbl_t *entries, int n_entries,
MOCK_DECL(int, router_descriptor_is_older_than, (const routerinfo_t *router,
int seconds));
+MOCK_DECL(STATIC was_router_added_t, extrainfo_insert,
+ (routerlist_t *rl, extrainfo_t *ei));
+
#endif
#endif
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 5add728d6d..bc3b00226a 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -911,7 +911,9 @@ find_start_of_next_router_or_extrainfo(const char **s_ptr,
* descriptor in the signed_descriptor_body field of each routerinfo_t. If it
* isn't SAVED_NOWHERE, remember the offset of each descriptor.
*
- * Returns 0 on success and -1 on failure.
+ * Returns 0 on success and -1 on failure. Adds a digest to
+ * <b>invalid_digests_out</b> for every entry that was unparseable or
+ * invalid. (This may cause duplicate entries.)
*/
int
router_parse_list_from_string(const char **s, const char *eos,
@@ -919,11 +921,12 @@ router_parse_list_from_string(const char **s, const char *eos,
saved_location_t saved_location,
int want_extrainfo,
int allow_annotations,
- const char *prepend_annotations)
+ const char *prepend_annotations,
+ smartlist_t *invalid_digests_out)
{
routerinfo_t *router;
extrainfo_t *extrainfo;
- signed_descriptor_t *signed_desc;
+ signed_descriptor_t *signed_desc = NULL;
void *elt;
const char *end, *start;
int have_extrainfo;
@@ -939,6 +942,9 @@ router_parse_list_from_string(const char **s, const char *eos,
tor_assert(eos >= *s);
while (1) {
+ char raw_digest[DIGEST_LEN];
+ int have_raw_digest = 0;
+ int dl_again = 0;
if (find_start_of_next_router_or_extrainfo(s, eos, &have_extrainfo) < 0)
break;
@@ -955,18 +961,20 @@ router_parse_list_from_string(const char **s, const char *eos,
if (have_extrainfo && want_extrainfo) {
routerlist_t *rl = router_get_routerlist();
+ have_raw_digest = router_get_extrainfo_hash(*s, end-*s, raw_digest) == 0;
extrainfo = extrainfo_parse_entry_from_string(*s, end,
saved_location != SAVED_IN_CACHE,
- rl->identity_map);
+ rl->identity_map, &dl_again);
if (extrainfo) {
signed_desc = &extrainfo->cache_info;
elt = extrainfo;
}
} else if (!have_extrainfo && !want_extrainfo) {
+ have_raw_digest = router_get_router_hash(*s, end-*s, raw_digest) == 0;
router = router_parse_entry_from_string(*s, end,
saved_location != SAVED_IN_CACHE,
allow_annotations,
- prepend_annotations);
+ prepend_annotations, &dl_again);
if (router) {
log_debug(LD_DIR, "Read router '%s', purpose '%s'",
router_describe(router),
@@ -975,11 +983,15 @@ router_parse_list_from_string(const char **s, const char *eos,
elt = router;
}
}
+ if (! elt && ! dl_again && have_raw_digest && invalid_digests_out) {
+ smartlist_add(invalid_digests_out, tor_memdup(raw_digest, DIGEST_LEN));
+ }
if (!elt) {
*s = end;
continue;
}
if (saved_location != SAVED_NOWHERE) {
+ tor_assert(signed_desc);
signed_desc->saved_location = saved_location;
signed_desc->saved_offset = *s - start;
}
@@ -1067,11 +1079,17 @@ find_single_ipv6_orport(const smartlist_t *list,
* around when caching the router.
*
* Only one of allow_annotations and prepend_annotations may be set.
+ *
+ * If <b>can_dl_again_out</b> is provided, set *<b>can_dl_again_out</b> to 1
+ * if it's okay to try to download a descriptor with this same digest again,
+ * and 0 if it isn't. (It might not be okay to download it again if part of
+ * the part covered by the digest is invalid.)
*/
routerinfo_t *
router_parse_entry_from_string(const char *s, const char *end,
int cache_copy, int allow_annotations,
- const char *prepend_annotations)
+ const char *prepend_annotations,
+ int *can_dl_again_out)
{
routerinfo_t *router = NULL;
char digest[128];
@@ -1082,6 +1100,9 @@ router_parse_entry_from_string(const char *s, const char *end,
size_t prepend_len = prepend_annotations ? strlen(prepend_annotations) : 0;
int ok = 1;
memarea_t *area = NULL;
+ /* Do not set this to '1' until we have parsed everything that we intend to
+ * parse that's covered by the hash. */
+ int can_dl_again = 0;
tor_assert(!allow_annotations || !prepend_annotations);
@@ -1388,19 +1409,21 @@ router_parse_entry_from_string(const char *s, const char *end,
verified_digests = digestmap_new();
digestmap_set(verified_digests, signed_digest, (void*)(uintptr_t)1);
#endif
- if (check_signature_token(digest, DIGEST_LEN, tok, router->identity_pkey, 0,
- "router descriptor") < 0)
- goto err;
if (!router->or_port) {
log_warn(LD_DIR,"or_port unreadable or 0. Failing.");
goto err;
}
+ /* We've checked everything that's covered by the hash. */
+ can_dl_again = 1;
+ if (check_signature_token(digest, DIGEST_LEN, tok, router->identity_pkey, 0,
+ "router descriptor") < 0)
+ goto err;
+
if (!router->platform) {
router->platform = tor_strdup("<unknown>");
}
-
goto done;
err:
@@ -1417,6 +1440,8 @@ router_parse_entry_from_string(const char *s, const char *end,
DUMP_AREA(area, "routerinfo");
memarea_drop_all(area);
}
+ if (can_dl_again_out)
+ *can_dl_again_out = can_dl_again;
return router;
}
@@ -1425,10 +1450,16 @@ router_parse_entry_from_string(const char *s, const char *end,
* <b>cache_copy</b> is true, make a copy of the extra-info document in the
* cache_info fields of the result. If <b>routermap</b> is provided, use it
* as a map from router identity to routerinfo_t when looking up signing keys.
+ *
+ * If <b>can_dl_again_out</b> is provided, set *<b>can_dl_again_out</b> to 1
+ * if it's okay to try to download an extrainfo with this same digest again,
+ * and 0 if it isn't. (It might not be okay to download it again if part of
+ * the part covered by the digest is invalid.)
*/
extrainfo_t *
extrainfo_parse_entry_from_string(const char *s, const char *end,
- int cache_copy, struct digest_ri_map_t *routermap)
+ int cache_copy, struct digest_ri_map_t *routermap,
+ int *can_dl_again_out)
{
extrainfo_t *extrainfo = NULL;
char digest[128];
@@ -1438,6 +1469,9 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
routerinfo_t *router = NULL;
memarea_t *area = NULL;
const char *s_dup = s;
+ /* Do not set this to '1' until we have parsed everything that we intend to
+ * parse that's covered by the hash. */
+ int can_dl_again = 0;
if (!end) {
end = s + strlen(s);
@@ -1497,6 +1531,9 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
goto err;
}
+ /* We've checked everything that's covered by the hash. */
+ can_dl_again = 1;
+
if (routermap &&
(router = digestmap_get((digestmap_t*)routermap,
extrainfo->cache_info.identity_digest))) {
@@ -1539,6 +1576,8 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
DUMP_AREA(area, "extrainfo");
memarea_drop_all(area);
}
+ if (can_dl_again_out)
+ *can_dl_again_out = can_dl_again;
return extrainfo;
}
@@ -1899,8 +1938,6 @@ routerstatus_parse_entry_from_string(memarea_t *area,
rs->is_possible_guard = 1;
else if (!strcmp(tok->args[i], "BadExit"))
rs->is_bad_exit = 1;
- else if (!strcmp(tok->args[i], "BadDirectory"))
- rs->is_bad_directory = 1;
else if (!strcmp(tok->args[i], "Authority"))
rs->is_authority = 1;
else if (!strcmp(tok->args[i], "Unnamed") &&
@@ -1917,12 +1954,9 @@ routerstatus_parse_entry_from_string(memarea_t *area,
rs->version_known = 1;
if (strcmpstart(tok->args[0], "Tor ")) {
rs->version_supports_microdesc_cache = 1;
- rs->version_supports_optimistic_data = 1;
} else {
rs->version_supports_microdesc_cache =
tor_version_supports_microdescriptors(tok->args[0]);
- rs->version_supports_optimistic_data =
- tor_version_as_new_as(tok->args[0], "0.2.3.1-alpha");
rs->version_supports_extend2_cells =
tor_version_as_new_as(tok->args[0], "0.2.4.8-alpha");
}
@@ -2047,6 +2081,7 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
double Gtotal=0, Mtotal=0, Etotal=0;
const char *casename = NULL;
int valid = 1;
+ (void) consensus_method;
weight_scale = networkstatus_get_weight_scale_param(ns);
Wgg = networkstatus_get_bw_weight(ns, "Wgg", -1);
@@ -2126,12 +2161,8 @@ networkstatus_verify_bw_weights(networkstatus_t *ns, int consensus_method)
// Then, gather G, M, E, D, T to determine case
SMARTLIST_FOREACH_BEGIN(ns->routerstatus_list, routerstatus_t *, rs) {
int is_exit = 0;
- if (consensus_method >= MIN_METHOD_TO_CUT_BADEXIT_WEIGHT) {
- /* Bug #2203: Don't count bad exits as exits for balancing */
- is_exit = rs->is_exit && !rs->is_bad_exit;
- } else {
- is_exit = rs->is_exit;
- }
+ /* Bug #2203: Don't count bad exits as exits for balancing */
+ is_exit = rs->is_exit && !rs->is_bad_exit;
if (rs->has_bandwidth) {
T += rs->bandwidth_kb;
if (is_exit && rs->is_possible_guard) {
@@ -3246,8 +3277,8 @@ networkstatus_parse_detached_signatures(const char *s, const char *eos)
* AF_UNSPEC for '*'. Use policy_expand_unspec() to turn this into a pair
* of AF_INET and AF_INET6 items.
*/
-addr_policy_t *
-router_parse_addr_policy_item_from_string(const char *s, int assume_action)
+MOCK_IMPL(addr_policy_t *,
+router_parse_addr_policy_item_from_string,(const char *s, int assume_action))
{
directory_token_t *tok = NULL;
const char *cp, *eos;
@@ -4013,12 +4044,15 @@ find_start_of_next_microdesc(const char *s, const char *eos)
* If <b>saved_location</b> isn't SAVED_IN_CACHE, make a local copy of each
* descriptor in the body field of each microdesc_t.
*
- * Return all newly
- * parsed microdescriptors in a newly allocated smartlist_t. */
+ * Return all newly parsed microdescriptors in a newly allocated
+ * smartlist_t. If <b>invalid_disgests_out</b> is provided, add a SHA256
+ * microdesc digest to it for every microdesc that we found to be badly
+ * formed. (This may cause duplicates) */
smartlist_t *
microdescs_parse_from_string(const char *s, const char *eos,
int allow_annotations,
- saved_location_t where)
+ saved_location_t where,
+ smartlist_t *invalid_digests_out)
{
smartlist_t *tokens;
smartlist_t *result;
@@ -4040,16 +4074,12 @@ microdescs_parse_from_string(const char *s, const char *eos,
tokens = smartlist_new();
while (s < eos) {
+ int okay = 0;
+
start_of_next_microdesc = find_start_of_next_microdesc(s, eos);
if (!start_of_next_microdesc)
start_of_next_microdesc = eos;
- if (tokenize_string(area, s, start_of_next_microdesc, tokens,
- microdesc_token_table, flags)) {
- log_warn(LD_DIR, "Unparseable microdescriptor");
- goto next;
- }
-
md = tor_malloc_zero(sizeof(microdesc_t));
{
const char *cp = tor_memstr(s, start_of_next_microdesc-s,
@@ -4064,6 +4094,13 @@ microdescs_parse_from_string(const char *s, const char *eos,
md->body = (char*)cp;
md->off = cp - start;
}
+ crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256);
+
+ if (tokenize_string(area, s, start_of_next_microdesc, tokens,
+ microdesc_token_table, flags)) {
+ log_warn(LD_DIR, "Unparseable microdescriptor");
+ goto next;
+ }
if ((tok = find_opt_by_keyword(tokens, A_LAST_LISTED))) {
if (parse_iso_time(tok->args[0], &md->last_listed)) {
@@ -4120,12 +4157,15 @@ microdescs_parse_from_string(const char *s, const char *eos,
md->ipv6_exit_policy = parse_short_policy(tok->args[0]);
}
- crypto_digest256(md->digest, md->body, md->bodylen, DIGEST_SHA256);
-
smartlist_add(result, md);
+ okay = 1;
md = NULL;
next:
+ if (! okay && invalid_digests_out) {
+ smartlist_add(invalid_digests_out,
+ tor_memdup(md->digest, DIGEST256_LEN));
+ }
microdesc_free(md);
md = NULL;
diff --git a/src/or/routerparse.h b/src/or/routerparse.h
index 5d5d9e59ef..e950548f8c 100644
--- a/src/or/routerparse.h
+++ b/src/or/routerparse.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -29,16 +29,19 @@ int router_parse_list_from_string(const char **s, const char *eos,
saved_location_t saved_location,
int is_extrainfo,
int allow_annotations,
- const char *prepend_annotations);
+ const char *prepend_annotations,
+ smartlist_t *invalid_digests_out);
routerinfo_t *router_parse_entry_from_string(const char *s, const char *end,
int cache_copy,
int allow_annotations,
- const char *prepend_annotations);
+ const char *prepend_annotations,
+ int *can_dl_again_out);
extrainfo_t *extrainfo_parse_entry_from_string(const char *s, const char *end,
- int cache_copy, struct digest_ri_map_t *routermap);
-addr_policy_t *router_parse_addr_policy_item_from_string(const char *s,
- int assume_action);
+ int cache_copy, struct digest_ri_map_t *routermap,
+ int *can_dl_again_out);
+MOCK_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
+ (const char *s, int assume_action));
version_status_t tor_version_is_obsolete(const char *myversion,
const char *versionlist);
int tor_version_supports_microdescriptors(const char *platform);
@@ -60,7 +63,8 @@ ns_detached_signatures_t *networkstatus_parse_detached_signatures(
smartlist_t *microdescs_parse_from_string(const char *s, const char *eos,
int allow_annotations,
- saved_location_t where);
+ saved_location_t where,
+ smartlist_t *invalid_digests_out);
authority_cert_t *authority_cert_parse_from_string(const char *s,
const char **end_of_string);
diff --git a/src/or/routerset.c b/src/or/routerset.c
index 7aee90d6db..38aed77ee9 100644
--- a/src/or/routerset.c
+++ b/src/or/routerset.c
@@ -1,9 +1,11 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
+#define ROUTERSET_PRIVATE
+
#include "or.h"
#include "geoip.h"
#include "nodelist.h"
@@ -12,39 +14,6 @@
#include "routerparse.h"
#include "routerset.h"
-/** A routerset specifies constraints on a set of possible routerinfos, based
- * on their names, identities, or addresses. It is optimized for determining
- * whether a router is a member or not, in O(1+P) time, where P is the number
- * of address policy constraints. */
-struct routerset_t {
- /** A list of strings for the elements of the policy. Each string is either
- * a nickname, a hexadecimal identity fingerprint, or an address policy. A
- * router belongs to the set if its nickname OR its identity OR its address
- * matches an entry here. */
- smartlist_t *list;
- /** A map from lowercase nicknames of routers in the set to (void*)1 */
- strmap_t *names;
- /** A map from identity digests routers in the set to (void*)1 */
- digestmap_t *digests;
- /** An address policy for routers in the set. For implementation reasons,
- * a router belongs to the set if it is _rejected_ by this policy. */
- smartlist_t *policies;
-
- /** A human-readable description of what this routerset is for. Used in
- * log messages. */
- char *description;
-
- /** A list of the country codes in this set. */
- smartlist_t *country_names;
- /** Total number of countries we knew about when we built <b>countries</b>.*/
- int n_countries;
- /** Bit array mapping the return value of geoip_get_country() to 1 iff the
- * country is a member of this routerset. Note that we MUST call
- * routerset_refresh_countries() whenever the geoip country list is
- * reloaded. */
- bitarray_t *countries;
-};
-
/** Return a new empty routerset. */
routerset_t *
routerset_new(void)
@@ -60,7 +29,7 @@ routerset_new(void)
/** If <b>c</b> is a country code in the form {cc}, return a newly allocated
* string holding the "cc" part. Else, return NULL. */
-static char *
+STATIC char *
routerset_get_countryname(const char *c)
{
char *country;
@@ -200,7 +169,7 @@ routerset_is_empty(const routerset_t *set)
*
* (If country is -1, then we take the country
* from addr.) */
-static int
+STATIC int
routerset_contains(const routerset_t *set, const tor_addr_t *addr,
uint16_t orport,
const char *nickname, const char *id_digest,
diff --git a/src/or/routerset.h b/src/or/routerset.h
index 8261c7fb09..a741eb5fda 100644
--- a/src/or/routerset.h
+++ b/src/or/routerset.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -39,5 +39,45 @@ char *routerset_to_string(const routerset_t *routerset);
int routerset_equal(const routerset_t *old, const routerset_t *new);
void routerset_free(routerset_t *routerset);
+#ifdef ROUTERSET_PRIVATE
+STATIC char * routerset_get_countryname(const char *c);
+STATIC int routerset_contains(const routerset_t *set, const tor_addr_t *addr,
+ uint16_t orport,
+ const char *nickname, const char *id_digest,
+ country_t country);
+
+/** A routerset specifies constraints on a set of possible routerinfos, based
+ * on their names, identities, or addresses. It is optimized for determining
+ * whether a router is a member or not, in O(1+P) time, where P is the number
+ * of address policy constraints. */
+struct routerset_t {
+ /** A list of strings for the elements of the policy. Each string is either
+ * a nickname, a hexadecimal identity fingerprint, or an address policy. A
+ * router belongs to the set if its nickname OR its identity OR its address
+ * matches an entry here. */
+ smartlist_t *list;
+ /** A map from lowercase nicknames of routers in the set to (void*)1 */
+ strmap_t *names;
+ /** A map from identity digests routers in the set to (void*)1 */
+ digestmap_t *digests;
+ /** An address policy for routers in the set. For implementation reasons,
+ * a router belongs to the set if it is _rejected_ by this policy. */
+ smartlist_t *policies;
+
+ /** A human-readable description of what this routerset is for. Used in
+ * log messages. */
+ char *description;
+
+ /** A list of the country codes in this set. */
+ smartlist_t *country_names;
+ /** Total number of countries we knew about when we built <b>countries</b>.*/
+ int n_countries;
+ /** Bit array mapping the return value of geoip_get_country() to 1 iff the
+ * country is a member of this routerset. Note that we MUST call
+ * routerset_refresh_countries() whenever the geoip country list is
+ * reloaded. */
+ bitarray_t *countries;
+};
+#endif
#endif
diff --git a/src/or/statefile.c b/src/or/statefile.c
index 7b9998fc1a..2ce53fdfca 100644
--- a/src/or/statefile.c
+++ b/src/or/statefile.c
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define STATEFILE_PRIVATE
diff --git a/src/or/statefile.h b/src/or/statefile.h
index 15bb0b4aae..1f3aebee4f 100644
--- a/src/or/statefile.h
+++ b/src/or/statefile.h
@@ -1,7 +1,7 @@
/* Copyright (c) 2001 Matej Pfajfar.
* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_STATEFILE_H
diff --git a/src/or/status.c b/src/or/status.c
index afaa9de840..c11d99ba7f 100644
--- a/src/or/status.c
+++ b/src/or/status.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2013, The Tor Project, Inc. */
+/* Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -28,13 +28,7 @@ static void log_accounting(const time_t now, const or_options_t *options);
STATIC int
count_circuits(void)
{
- circuit_t *circ;
- int nr=0;
-
- TOR_LIST_FOREACH(circ, circuit_get_global_list(), head)
- nr++;
-
- return nr;
+ return smartlist_len(circuit_get_global_list());
}
/** Take seconds <b>secs</b> and return a newly allocated human-readable
@@ -151,10 +145,14 @@ log_accounting(const time_t now, const or_options_t *options)
or_state_t *state = get_or_state();
char *acc_rcvd = bytes_to_usage(state->AccountingBytesReadInInterval);
char *acc_sent = bytes_to_usage(state->AccountingBytesWrittenInInterval);
- char *acc_max = bytes_to_usage(options->AccountingMax);
+ uint64_t acc_bytes = options->AccountingMax;
+ char *acc_max;
time_t interval_end = accounting_get_end_time();
char end_buf[ISO_TIME_LEN + 1];
char *remaining = NULL;
+ if (options->AccountingRule == ACCT_SUM)
+ acc_bytes *= 2;
+ acc_max = bytes_to_usage(acc_bytes);
format_local_iso_time(end_buf, interval_end);
remaining = secs_to_uptime(interval_end - now);
diff --git a/src/or/status.h b/src/or/status.h
index 13458ea476..451f343963 100644
--- a/src/or/status.h
+++ b/src/or/status.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2013, The Tor Project, Inc. */
+/* Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_STATUS_H
diff --git a/src/or/tor_main.c b/src/or/tor_main.c
index 05dc0bf0bf..9489cdca7f 100644
--- a/src/or/tor_main.c
+++ b/src/or/tor_main.c
@@ -1,6 +1,6 @@
/* Copyright 2001-2004 Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/** String describing which Tor Git repository version the source was
diff --git a/src/or/transports.c b/src/or/transports.c
index 0fb5926681..2623f807d0 100644
--- a/src/or/transports.c
+++ b/src/or/transports.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -124,6 +124,8 @@ static INLINE void free_execve_args(char **arg);
#define PROTO_SMETHOD_ERROR "SMETHOD-ERROR"
#define PROTO_CMETHODS_DONE "CMETHODS DONE"
#define PROTO_SMETHODS_DONE "SMETHODS DONE"
+#define PROTO_PROXY_DONE "PROXY DONE"
+#define PROTO_PROXY_ERROR "PROXY-ERROR"
/** The first and only supported - at the moment - configuration
protocol version. */
@@ -439,6 +441,17 @@ add_transport_to_proxy(const char *transport, managed_proxy_t *mp)
static int
proxy_needs_restart(const managed_proxy_t *mp)
{
+ int ret = 1;
+ char* proxy_uri;
+
+ /* If the PT proxy config has changed, then all existing pluggable transports
+ * should be restarted.
+ */
+
+ proxy_uri = get_pt_proxy_uri();
+ if (strcmp_opt(proxy_uri, mp->proxy_uri) != 0)
+ goto needs_restart;
+
/* mp->transport_to_launch is populated with the names of the
transports that must be launched *after* the SIGHUP.
mp->transports is populated with the transports that were
@@ -459,10 +472,10 @@ proxy_needs_restart(const managed_proxy_t *mp)
} SMARTLIST_FOREACH_END(t);
- return 0;
-
+ ret = 0;
needs_restart:
- return 1;
+ tor_free(proxy_uri);
+ return ret;
}
/** Managed proxy <b>mp</b> must be restarted. Do all the necessary
@@ -493,6 +506,11 @@ proxy_prepare_for_restart(managed_proxy_t *mp)
SMARTLIST_FOREACH(mp->transports, transport_t *, t, transport_free(t));
smartlist_clear(mp->transports);
+ /* Reset the proxy's HTTPS/SOCKS proxy */
+ tor_free(mp->proxy_uri);
+ mp->proxy_uri = get_pt_proxy_uri();
+ mp->proxy_supported = 0;
+
/* flag it as an infant proxy so that it gets launched on next tick */
mp->conf_state = PT_PROTO_INFANT;
unconfigured_proxies_n++;
@@ -727,12 +745,54 @@ managed_proxy_destroy(managed_proxy_t *mp,
/* free the argv */
free_execve_args(mp->argv);
+ /* free the outgoing proxy URI */
+ tor_free(mp->proxy_uri);
+
tor_process_handle_destroy(mp->process_handle, also_terminate_process);
mp->process_handle = NULL;
tor_free(mp);
}
+/** Convert the tor proxy options to a URI suitable for TOR_PT_PROXY.
+ * Return a newly allocated string containing the URI, or NULL if no
+ * proxy is set. */
+STATIC char *
+get_pt_proxy_uri(void)
+{
+ const or_options_t *options = get_options();
+ char *uri = NULL;
+
+ if (options->Socks4Proxy || options->Socks5Proxy || options->HTTPSProxy) {
+ char addr[TOR_ADDR_BUF_LEN+1];
+
+ if (options->Socks4Proxy) {
+ tor_addr_to_str(addr, &options->Socks4ProxyAddr, sizeof(addr), 1);
+ tor_asprintf(&uri, "socks4a://%s:%d", addr, options->Socks4ProxyPort);
+ } else if (options->Socks5Proxy) {
+ tor_addr_to_str(addr, &options->Socks5ProxyAddr, sizeof(addr), 1);
+ if (!options->Socks5ProxyUsername && !options->Socks5ProxyPassword) {
+ tor_asprintf(&uri, "socks5://%s:%d", addr, options->Socks5ProxyPort);
+ } else {
+ tor_asprintf(&uri, "socks5://%s:%s@%s:%d",
+ options->Socks5ProxyUsername,
+ options->Socks5ProxyPassword,
+ addr, options->Socks5ProxyPort);
+ }
+ } else if (options->HTTPSProxy) {
+ tor_addr_to_str(addr, &options->HTTPSProxyAddr, sizeof(addr), 1);
+ if (!options->HTTPSProxyAuthenticator) {
+ tor_asprintf(&uri, "http://%s:%d", addr, options->HTTPSProxyPort);
+ } else {
+ tor_asprintf(&uri, "http://%s@%s:%d", options->HTTPSProxyAuthenticator,
+ addr, options->HTTPSProxyPort);
+ }
+ }
+ }
+
+ return uri;
+}
+
/** Handle a configured or broken managed proxy <b>mp</b>. */
static void
handle_finished_proxy(managed_proxy_t *mp)
@@ -745,6 +805,13 @@ handle_finished_proxy(managed_proxy_t *mp)
managed_proxy_destroy(mp, 0); /* destroy it but don't terminate */
break;
case PT_PROTO_CONFIGURED: /* if configured correctly: */
+ if (mp->proxy_uri && !mp->proxy_supported) {
+ log_warn(LD_CONFIG, "Managed proxy '%s' did not configure the "
+ "specified outgoing proxy and will be terminated.",
+ mp->argv[0]);
+ managed_proxy_destroy(mp, 1); /* annihilate it. */
+ break;
+ }
register_proxy(mp); /* register its transports */
mp->conf_state = PT_PROTO_COMPLETED; /* and mark it as completed. */
break;
@@ -862,6 +929,22 @@ handle_proxy_line(const char *line, managed_proxy_t *mp)
goto err;
return;
+ } else if (!strcmpstart(line, PROTO_PROXY_DONE)) {
+ if (mp->conf_state != PT_PROTO_ACCEPTING_METHODS)
+ goto err;
+
+ if (mp->proxy_uri) {
+ mp->proxy_supported = 1;
+ return;
+ }
+
+ /* No proxy was configured, this should log */
+ } else if (!strcmpstart(line, PROTO_PROXY_ERROR)) {
+ if (mp->conf_state != PT_PROTO_ACCEPTING_METHODS)
+ goto err;
+
+ parse_proxy_error(line);
+ goto err;
} else if (!strcmpstart(line, SPAWN_ERROR_MESSAGE)) {
/* managed proxy launch failed: parse error message to learn why. */
int retval, child_state, saved_errno;
@@ -1128,6 +1211,21 @@ parse_cmethod_line(const char *line, managed_proxy_t *mp)
return r;
}
+/** Parses an PROXY-ERROR <b>line</b> and warns the user accordingly. */
+STATIC void
+parse_proxy_error(const char *line)
+{
+ /* (Length of the protocol string) plus (a space) and (the first char of
+ the error message) */
+ if (strlen(line) < (strlen(PROTO_PROXY_ERROR) + 2))
+ log_notice(LD_CONFIG, "Managed proxy sent us an %s without an error "
+ "message.", PROTO_PROXY_ERROR);
+
+ log_warn(LD_CONFIG, "Managed proxy failed to configure the "
+ "pluggable transport's outgoing proxy. (%s)",
+ line+strlen(PROTO_PROXY_ERROR)+1);
+}
+
/** Return a newly allocated string that tor should place in
* TOR_PT_SERVER_TRANSPORT_OPTIONS while configuring the server
* manged proxy in <b>mp</b>. Return NULL if no such options are found. */
@@ -1292,6 +1390,14 @@ create_managed_proxy_environment(const managed_proxy_t *mp)
} else {
smartlist_add_asprintf(envs, "TOR_PT_EXTENDED_SERVER_PORT=");
}
+ } else {
+ /* If ClientTransportPlugin has a HTTPS/SOCKS proxy configured, set the
+ * TOR_PT_PROXY line.
+ */
+
+ if (mp->proxy_uri) {
+ smartlist_add_asprintf(envs, "TOR_PT_PROXY=%s", mp->proxy_uri);
+ }
}
SMARTLIST_FOREACH_BEGIN(envs, const char *, env_var) {
@@ -1324,6 +1430,7 @@ managed_proxy_create(const smartlist_t *transport_list,
mp->is_server = is_server;
mp->argv = proxy_argv;
mp->transports = smartlist_new();
+ mp->proxy_uri = get_pt_proxy_uri();
mp->transports_to_launch = smartlist_new();
SMARTLIST_FOREACH(transport_list, const char *, transport,
diff --git a/src/or/transports.h b/src/or/transports.h
index deacdcdd68..2958d5e187 100644
--- a/src/or/transports.h
+++ b/src/or/transports.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2003-2004, Roger Dingledine
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -83,6 +83,9 @@ typedef struct {
char **argv; /* the cli arguments of this proxy */
int conf_protocol; /* the configuration protocol version used */
+ char *proxy_uri; /* the outgoing proxy in TOR_PT_PROXY URI format */
+ unsigned int proxy_supported : 1; /* the proxy honors TOR_PT_PROXY */
+
int is_server; /* is it a server proxy? */
/* A pointer to the process handle of this managed proxy. */
@@ -114,6 +117,7 @@ STATIC int parse_smethod_line(const char *line, managed_proxy_t *mp);
STATIC int parse_version(const char *line, managed_proxy_t *mp);
STATIC void parse_env_error(const char *line);
+STATIC void parse_proxy_error(const char *line);
STATIC void handle_proxy_line(const char *line, managed_proxy_t *mp);
STATIC char *get_transport_options_for_server_proxy(const managed_proxy_t *mp);
@@ -125,6 +129,8 @@ STATIC managed_proxy_t *managed_proxy_create(const smartlist_t *transport_list,
STATIC int configure_proxy(managed_proxy_t *mp);
+STATIC char* get_pt_proxy_uri(void);
+
#endif
#endif
diff --git a/src/test/bench.c b/src/test/bench.c
index f6c33626f2..74af06c6e6 100644
--- a/src/test/bench.c
+++ b/src/test/bench.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Ordinarily defined in tor_main.c; this bit is just here to provide one
@@ -26,10 +26,9 @@ const char tor_git_revision[] = "";
#endif
#include "config.h"
-#ifdef CURVE25519_ENABLED
#include "crypto_curve25519.h"
#include "onion_ntor.h"
-#endif
+#include "crypto_ed25519.h"
#if defined(HAVE_CLOCK_GETTIME) && defined(CLOCK_PROCESS_CPUTIME_ID)
static uint64_t nanostart;
@@ -79,6 +78,9 @@ perftime(void)
#define NANOCOUNT(start,end,iters) \
( ((double)((end)-(start))) / (iters) )
+#define MICROCOUNT(start,end,iters) \
+ ( NANOCOUNT((start), (end), (iters)) / 1000.0 )
+
/** Run AES performance benchmarks. */
static void
bench_aes(void)
@@ -175,7 +177,6 @@ bench_onion_TAP(void)
crypto_pk_free(key2);
}
-#ifdef CURVE25519_ENABLED
static void
bench_onion_ntor(void)
{
@@ -232,7 +233,63 @@ bench_onion_ntor(void)
ntor_handshake_state_free(state);
dimap_free(keymap, NULL);
}
-#endif
+
+static void
+bench_ed25519(void)
+{
+ uint64_t start, end;
+ const int iters = 1<<12;
+ int i;
+ const uint8_t msg[] = "but leaving, could not tell what they had heard";
+ ed25519_signature_t sig;
+ ed25519_keypair_t kp;
+ curve25519_keypair_t curve_kp;
+ ed25519_public_key_t pubkey_tmp;
+
+ ed25519_secret_key_generate(&kp.seckey, 0);
+ start = perftime();
+ for (i = 0; i < iters; ++i) {
+ ed25519_public_key_generate(&kp.pubkey, &kp.seckey);
+ }
+ end = perftime();
+ printf("Generate public key: %.2f usec\n",
+ MICROCOUNT(start, end, iters));
+
+ start = perftime();
+ for (i = 0; i < iters; ++i) {
+ ed25519_sign(&sig, msg, sizeof(msg), &kp);
+ }
+ end = perftime();
+ printf("Sign a short message: %.2f usec\n",
+ MICROCOUNT(start, end, iters));
+
+ start = perftime();
+ for (i = 0; i < iters; ++i) {
+ ed25519_checksig(&sig, msg, sizeof(msg), &kp.pubkey);
+ }
+ end = perftime();
+ printf("Verify signature: %.2f usec\n",
+ MICROCOUNT(start, end, iters));
+
+ curve25519_keypair_generate(&curve_kp, 0);
+ start = perftime();
+ for (i = 0; i < iters; ++i) {
+ ed25519_public_key_from_curve25519_public_key(&pubkey_tmp,
+ &curve_kp.pubkey, 1);
+ }
+ end = perftime();
+ printf("Convert public point from curve25519: %.2f usec\n",
+ MICROCOUNT(start, end, iters));
+
+ curve25519_keypair_generate(&curve_kp, 0);
+ start = perftime();
+ for (i = 0; i < iters; ++i) {
+ ed25519_public_blind(&pubkey_tmp, &kp.pubkey, msg);
+ }
+ end = perftime();
+ printf("Blind a public key: %.2f usec\n",
+ MICROCOUNT(start, end, iters));
+}
static void
bench_cell_aes(void)
@@ -512,9 +569,9 @@ static struct benchmark_t benchmarks[] = {
ENT(siphash),
ENT(aes),
ENT(onion_TAP),
-#ifdef CURVE25519_ENABLED
ENT(onion_ntor),
-#endif
+ ENT(ed25519),
+
ENT(cell_aes),
ENT(cell_ops),
ENT(dh),
@@ -569,7 +626,7 @@ main(int argc, const char **argv)
crypto_seed_rng(1);
crypto_init_siphash_key();
options = options_new();
- init_logging();
+ init_logging(1);
options->command = CMD_RUN_UNITTESTS;
options->DataDirectory = tor_strdup("");
options_init(options);
diff --git a/src/test/ed25519_exts_ref.py b/src/test/ed25519_exts_ref.py
new file mode 100644
index 0000000000..93dc49ee93
--- /dev/null
+++ b/src/test/ed25519_exts_ref.py
@@ -0,0 +1,234 @@
+#!/usr/bin/python
+# Copyright 2014, The Tor Project, Inc
+# See LICENSE for licensing information
+
+"""
+ Reference implementations for the ed25519 tweaks that Tor uses.
+
+ Includes self-tester and test vector generator.
+"""
+
+import slow_ed25519
+from slow_ed25519 import *
+
+import os
+import random
+import slownacl_curve25519
+import unittest
+import binascii
+import textwrap
+
+#define a synonym that doesn't look like 1
+ell = l
+
+# This replaces expmod above and makes it go a lot faster.
+slow_ed25519.expmod = pow
+
+def curve25519ToEd25519(c, sign):
+ u = decodeint(c)
+ y = ((u - 1) * inv(u + 1)) % q
+ x = xrecover(y)
+ if x & 1 != sign: x = q-x
+ return encodepoint([x,y])
+
+def blindESK(esk, param):
+ h = H("Derive temporary signing key" + param)
+ mult = 2**(b-2) + sum(2**i * bit(h,i) for i in range(3,b-2))
+ s = decodeint(esk[:32])
+ s_prime = (s * mult) % ell
+ k = esk[32:]
+ assert(len(k) == 32)
+ k_prime = H("Derive temporary signing key hash input" + k)[:32]
+ return encodeint(s_prime) + k_prime
+
+def blindPK(pk, param):
+ h = H("Derive temporary signing key" + param)
+ mult = 2**(b-2) + sum(2**i * bit(h,i) for i in range(3,b-2))
+ P = decodepoint(pk)
+ return encodepoint(scalarmult(P, mult))
+
+def expandSK(sk):
+ h = H(sk)
+ a = 2**(b-2) + sum(2**i * bit(h,i) for i in range(3,b-2))
+ k = ''.join([h[i] for i in range(b/8,b/4)])
+ assert len(k) == 32
+ return encodeint(a)+k
+
+def publickeyFromESK(h):
+ a = decodeint(h[:32])
+ A = scalarmult(B,a)
+ return encodepoint(A)
+
+def signatureWithESK(m,h,pk):
+ a = decodeint(h[:32])
+ r = Hint(''.join([h[i] for i in range(b/8,b/4)]) + m)
+ R = scalarmult(B,r)
+ S = (r + Hint(encodepoint(R) + pk + m) * a) % l
+ return encodepoint(R) + encodeint(S)
+
+def newSK():
+ return os.urandom(32)
+
+# ------------------------------------------------------------
+
+MSG = "This is extremely silly. But it is also incredibly serious business!"
+
+class SelfTest(unittest.TestCase):
+
+ def _testSignatures(self, esk, pk):
+ sig = signatureWithESK(MSG, esk, pk)
+ checkvalid(sig, MSG, pk)
+ bad = False
+ try:
+ checkvalid(sig, MSG*2, pk)
+ bad = True
+ except Exception:
+ pass
+
+ self.failIf(bad)
+
+ def testExpand(self):
+ sk = newSK()
+ pk = publickey(sk)
+ esk = expandSK(sk)
+ sig1 = signature(MSG, sk, pk)
+ sig2 = signatureWithESK(MSG, esk, pk)
+ self.assertEquals(sig1, sig2)
+
+ def testSignatures(self):
+ sk = newSK()
+ esk = expandSK(sk)
+ pk = publickeyFromESK(esk)
+ pk2 = publickey(sk)
+ self.assertEquals(pk, pk2)
+
+ self._testSignatures(esk, pk)
+
+ def testDerivation(self):
+ priv = slownacl_curve25519.Private()
+ pub = priv.get_public()
+
+ ed_pub0 = publickeyFromESK(priv.private)
+ sign = (ord(ed_pub0[31]) & 255) >> 7
+ ed_pub1 = curve25519ToEd25519(pub.public, sign)
+
+ self.assertEquals(ed_pub0, ed_pub1)
+
+ def testBlinding(self):
+ sk = newSK()
+ esk = expandSK(sk)
+ pk = publickeyFromESK(esk)
+ param = os.urandom(32)
+ besk = blindESK(esk, param)
+ bpk = blindPK(pk, param)
+ bpk2 = publickeyFromESK(besk)
+ self.assertEquals(bpk, bpk2)
+
+ self._testSignatures(besk, bpk)
+
+# ------------------------------------------------------------
+
+# From pprint.pprint([ binascii.b2a_hex(os.urandom(32)) for _ in xrange(8) ])
+RAND_INPUTS = [
+ '26c76712d89d906e6672dafa614c42e5cb1caac8c6568e4d2493087db51f0d36',
+ 'fba7a5366b5cb98c2667a18783f5cf8f4f8d1a2ce939ad22a6e685edde85128d',
+ '67e3aa7a14fac8445d15e45e38a523481a69ae35513c9e4143eb1c2196729a0e',
+ 'd51385942033a76dc17f089a59e6a5a7fe80d9c526ae8ddd8c3a506b99d3d0a6',
+ '5c8eac469bb3f1b85bc7cd893f52dc42a9ab66f1b02b5ce6a68e9b175d3bb433',
+ 'eda433d483059b6d1ff8b7cfbd0fe406bfb23722c8f3c8252629284573b61b86',
+ '4377c40431c30883c5fbd9bc92ae48d1ed8a47b81d13806beac5351739b5533d',
+ 'c6bbcce615839756aed2cc78b1de13884dd3618f48367a17597a16c1cd7a290b']
+
+# From pprint.pprint([ binascii.b2a_hex(os.urandom(32)) for _ in xrange(8) ])
+BLINDING_PARAMS = [
+ '54a513898b471d1d448a2f3c55c1de2c0ef718c447b04497eeb999ed32027823',
+ '831e9b5325b5d31b7ae6197e9c7a7baf2ec361e08248bce055908971047a2347',
+ 'ac78a1d46faf3bfbbdc5af5f053dc6dc9023ed78236bec1760dadfd0b2603760',
+ 'f9c84dc0ac31571507993df94da1b3d28684a12ad14e67d0a068aba5c53019fc',
+ 'b1fe79d1dec9bc108df69f6612c72812755751f21ecc5af99663b30be8b9081f',
+ '81f1512b63ab5fb5c1711a4ec83d379c420574aedffa8c3368e1c3989a3a0084',
+ '97f45142597c473a4b0e9a12d64561133ad9e1155fe5a9807fe6af8a93557818',
+ '3f44f6a5a92cde816635dfc12ade70539871078d2ff097278be2a555c9859cd0']
+
+PREFIX = "ED25519_"
+
+def writeArray(name, array):
+ print "static const char *{prefix}{name}[] = {{".format(
+ prefix=PREFIX,name=name)
+ for a in array:
+ h = binascii.b2a_hex(a)
+ if len(h) > 70:
+ h1 = h[:70]
+ h2 = h[70:]
+ print ' "{0}"\n "{1}",'.format(h1,h2)
+ else:
+ print ' "{0}",'.format(h)
+ print "};\n"
+
+def comment(text, initial="/**"):
+ print initial
+ print textwrap.fill(text,initial_indent=" * ",subsequent_indent=" * ")
+ print " */"
+
+def makeTestVectors():
+ comment("""Test vectors for our ed25519 implementation and related
+ functions. These were automatically generated by the
+ ed25519_exts_ref.py script.""", initial="/*")
+
+
+ comment("""Secret key seeds used as inputs for the ed25519 test vectors.
+ Randomly generated. """)
+ secretKeys = [ binascii.a2b_hex(r) for r in RAND_INPUTS ]
+ writeArray("SECRET_KEYS", secretKeys)
+
+ comment("""Secret ed25519 keys after expansion from seeds. This is how Tor
+ represents them internally.""")
+ expandedSecretKeys = [ expandSK(sk) for sk in secretKeys ]
+ writeArray("EXPANDED_SECRET_KEYS", expandedSecretKeys)
+
+ comment("""Public keys derived from the above secret keys""")
+ publicKeys = [ publickey(sk) for sk in secretKeys ]
+ writeArray("PUBLIC_KEYS", publicKeys)
+
+ comment("""The curve25519 public keys from which the ed25519 keys can be
+ derived. Used to test our 'derive ed25519 from curve25519'
+ code.""")
+ writeArray("CURVE25519_PUBLIC_KEYS",
+ (slownacl_curve25519.smult_curve25519_base(sk[:32])
+ for sk in expandedSecretKeys))
+
+ comment("""Parameters used for key blinding tests. Randomly generated.""")
+ blindingParams = [ binascii.a2b_hex(r) for r in BLINDING_PARAMS ]
+ writeArray("BLINDING_PARAMS", blindingParams)
+
+ comment("""Blinded secret keys for testing key blinding. The nth blinded
+ key corresponds to the nth secret key blidned with the nth
+ blinding parameter.""")
+ writeArray("BLINDED_SECRET_KEYS",
+ (blindESK(expandSK(sk), bp)
+ for sk,bp in zip(secretKeys,blindingParams)))
+
+ comment("""Blinded public keys for testing key blinding. The nth blinded
+ key corresponds to the nth public key blidned with the nth
+ blinding parameter.""")
+ writeArray("BLINDED_PUBLIC_KEYS",
+ (blindPK(pk, bp) for pk,bp in zip(publicKeys,blindingParams)))
+
+ comment("""Signatures of the public keys, made with their corresponding
+ secret keys.""")
+ writeArray("SELF_SIGNATURES",
+ (signature(pk, sk, pk) for pk,sk in zip(publicKeys,secretKeys)))
+
+
+
+if __name__ == '__main__':
+ import sys
+ if len(sys.argv) == 1 or sys.argv[1] not in ("SelfTest", "MakeVectors"):
+ print "You should specify one of 'SelfTest' or 'MakeVectors'"
+ sys.exit(1)
+ if sys.argv[1] == 'SelfTest':
+ unittest.main()
+ else:
+ makeTestVectors()
+
+
diff --git a/src/test/ed25519_vectors.inc b/src/test/ed25519_vectors.inc
new file mode 100644
index 0000000000..760bafb971
--- /dev/null
+++ b/src/test/ed25519_vectors.inc
@@ -0,0 +1,150 @@
+/*
+ * Test vectors for our ed25519 implementation and related
+ * functions. These were automatically generated by the
+ * ed25519_exts_ref.py script.
+ */
+/**
+ * Secret key seeds used as inputs for the ed25519 test vectors.
+ * Randomly generated.
+ */
+static const char *ED25519_SECRET_KEYS[] = {
+ "26c76712d89d906e6672dafa614c42e5cb1caac8c6568e4d2493087db51f0d36",
+ "fba7a5366b5cb98c2667a18783f5cf8f4f8d1a2ce939ad22a6e685edde85128d",
+ "67e3aa7a14fac8445d15e45e38a523481a69ae35513c9e4143eb1c2196729a0e",
+ "d51385942033a76dc17f089a59e6a5a7fe80d9c526ae8ddd8c3a506b99d3d0a6",
+ "5c8eac469bb3f1b85bc7cd893f52dc42a9ab66f1b02b5ce6a68e9b175d3bb433",
+ "eda433d483059b6d1ff8b7cfbd0fe406bfb23722c8f3c8252629284573b61b86",
+ "4377c40431c30883c5fbd9bc92ae48d1ed8a47b81d13806beac5351739b5533d",
+ "c6bbcce615839756aed2cc78b1de13884dd3618f48367a17597a16c1cd7a290b",
+};
+
+/**
+ * Secret ed25519 keys after expansion from seeds. This is how Tor
+ * represents them internally.
+ */
+static const char *ED25519_EXPANDED_SECRET_KEYS[] = {
+ "c0a4de23cc64392d85aa1da82b3defddbea946d13bb053bf8489fa9296281f495022f1"
+ "f7ec0dcf52f07d4c7965c4eaed121d5d88d0a8ff546b06116a20e97755",
+ "18a8a69a06790dac778e882f7e868baacfa12521a5c058f5194f3a729184514a2a656f"
+ "e7799c3e41f43d756da8d9cd47a061316cfe6147e23ea2f90d1ca45f30",
+ "58d84f8862d2ecfa30eb491a81c36d05b574310ea69dae18ecb57e992a896656b98218"
+ "7ee96c15bf4caeeab2d0b0ae4cd0b8d17470fc7efa98bb26428f4ef36d",
+ "50702d20b3550c6e16033db5ad4fba16436f1ecc7485be6af62b0732ceb5d173c47ccd"
+ "9d044b6ea99dd99256adcc9c62191be194e7cb1a5b58ddcec85d876a2b",
+ "7077464c864c2ed5ed21c9916dc3b3ba6256f8b742fec67658d8d233dadc8d5a7a82c3"
+ "71083cc86892c2c8782dda2a09b6baf016aec51b689183ae59ce932ff2",
+ "8883c1387a6c86fc0bd7b9f157b4e4cd83f6885bf55e2706d2235d4527a2f05311a359"
+ "5953282e436df0349e1bb313a19b3ddbf7a7b91ecce8a2c34abadb38b3",
+ "186791ac8d03a3ac8efed6ac360467edd5a3bed2d02b3be713ddd5be53b3287ee37436"
+ "e5fd7ac43794394507ad440ecfdf59c4c255f19b768a273109e06d7d8e",
+ "b003077c1e52a62308eef7950b2d532e1d4a7eea50ad22d8ac11b892851f1c40ffb9c9"
+ "ff8dcd0c6c233f665a2e176324d92416bfcfcd1f787424c0c667452d86",
+};
+
+/**
+ * Public keys derived from the above secret keys
+ */
+static const char *ED25519_PUBLIC_KEYS[] = {
+ "c2247870536a192d142d056abefca68d6193158e7c1a59c1654c954eccaff894",
+ "1519a3b15816a1aafab0b213892026ebf5c0dc232c58b21088d88cb90e9b940d",
+ "081faa81992e360ea22c06af1aba096e7a73f1c665bc8b3e4e531c46455fd1dd",
+ "73cfa1189a723aad7966137cbffa35140bb40d7e16eae4c40b79b5f0360dd65a",
+ "66c1a77104d86461b6f98f73acf3cd229c80624495d2d74d6fda1e940080a96b",
+ "d21c294db0e64cb2d8976625786ede1d9754186ae8197a64d72f68c792eecc19",
+ "c4d58b4cf85a348ff3d410dd936fa460c4f18da962c01b1963792b9dcc8a6ea6",
+ "95126f14d86494020665face03f2d42ee2b312a85bc729903eb17522954a1c4a",
+};
+
+/**
+ * The curve25519 public keys from which the ed25519 keys can be
+ * derived. Used to test our 'derive ed25519 from curve25519'
+ * code.
+ */
+static const char *ED25519_CURVE25519_PUBLIC_KEYS[] = {
+ "17ba77846e04c7ee5ca17cade774ac1884408f9701f439d4df32cbd8736c6a1f",
+ "022be2124bc1899a78ba2b4167d191af3b59cadf94f0382bc31ce183a117f161",
+ "bf4fd38ef22f718f03c0a12ba5127bd1e3afd494793753f519728b29cc577571",
+ "56c493e490261cef31633efd2461d2b896908e90459e4eecde950a895aef681d",
+ "089675a3e8ff2a7d8b2844a79269c95b7f97a4b8b5ea0cbeec669c6f2dea9b39",
+ "59e20dcb691c4a345fe86c8a79ac817e5b514d84bbf0512a842a08e43f7f087e",
+ "9e43b820b320eda35f66f122c155b2bf8e2192c468617b7115bf067d19e08369",
+ "861f33296cb57f8f01e4a5e8a7e5d5d7043a6247586ab36dea8a1a3c4403ee30",
+};
+
+/**
+ * Parameters used for key blinding tests. Randomly generated.
+ */
+static const char *ED25519_BLINDING_PARAMS[] = {
+ "54a513898b471d1d448a2f3c55c1de2c0ef718c447b04497eeb999ed32027823",
+ "831e9b5325b5d31b7ae6197e9c7a7baf2ec361e08248bce055908971047a2347",
+ "ac78a1d46faf3bfbbdc5af5f053dc6dc9023ed78236bec1760dadfd0b2603760",
+ "f9c84dc0ac31571507993df94da1b3d28684a12ad14e67d0a068aba5c53019fc",
+ "b1fe79d1dec9bc108df69f6612c72812755751f21ecc5af99663b30be8b9081f",
+ "81f1512b63ab5fb5c1711a4ec83d379c420574aedffa8c3368e1c3989a3a0084",
+ "97f45142597c473a4b0e9a12d64561133ad9e1155fe5a9807fe6af8a93557818",
+ "3f44f6a5a92cde816635dfc12ade70539871078d2ff097278be2a555c9859cd0",
+};
+
+/**
+ * Blinded secret keys for testing key blinding. The nth blinded
+ * key corresponds to the nth secret key blidned with the nth
+ * blinding parameter.
+ */
+static const char *ED25519_BLINDED_SECRET_KEYS[] = {
+ "014e83abadb2ca9a27e0ffe23920333d817729f48700e97656ec2823d694050e171d43"
+ "f24e3f53e70ec7ac280044ac77d4942dee5d6807118a59bdf3ee647e89",
+ "fad8cca0b4335847795288b1452508752b253e64e6c7c78d4a02dbbd7d46aa0eb8ceff"
+ "20dfcf53eb52b891fc078c934efbf0353af7242e7dc51bb32a093afa29",
+ "116eb0ae0a4a91763365bdf86db427b00862db448487808788cc339ac10e5e089217f5"
+ "2e92797462bd890fc274672e05c98f2c82970d640084781334aae0f940",
+ "bd1fbb0ee5acddc4adbcf5f33e95d9445f40326ce579fdd764a24483a9ccb20f509ece"
+ "e77082ce088f7c19d5a00e955eeef8df6fa41686abc1030c2d76807733",
+ "237f5345cefe8573ce9fa7e216381a1172796c9e3f70668ab503b1352952530fb57b95"
+ "a440570659a440a3e4771465022a8e67af86bdf2d0990c54e7bb87ff9a",
+ "ba8ff23bc4ad2b739e1ccffc9fbc7837053ea81cdfdb15073f56411cfbae1d0ec492fc"
+ "87d5ec2a1b185ca5a40541fdef0b1e128fd5c2380c888bfa924711bcab",
+ "0fa68f969de038c7a90a4a74ee6167c77582006f2dedecc1956501ba6b6fb10391b476"
+ "8f8e556d78f4bdcb9a13b6f6066fe81d3134ae965dc48cd0785b3af2b8",
+ "deaa3456d1c21944d5dcd361a646858c6cf9336b0a6851d925717eb1ae186902053d9c"
+ "00c81e1331c06ab50087be8cfc7dc11691b132614474f1aa9c2503cccd",
+};
+
+/**
+ * Blinded public keys for testing key blinding. The nth blinded
+ * key corresponds to the nth public key blidned with the nth
+ * blinding parameter.
+ */
+static const char *ED25519_BLINDED_PUBLIC_KEYS[] = {
+ "722d6da6348e618967ef782e71061e27163a8b35f21856475d9d2023f65b6495",
+ "1dffa0586da6cbfcff2024eedf4fc6c818242d9a82dbbe635d6da1b975a1160d",
+ "5ed81f98fed5a6acda4ea6da2c34fab0ab359d950c510c256473f1f33ff438b4",
+ "6e6f92a54fb282120c46d9603df41135f025bc1f58f283809d04be96aeb04040",
+ "cda236f28edc4c7e02d18007b8dab49d669265b0f7aefb1824d7cc8e73a2cd63",
+ "367b03b17b67ca7329b89a520bdab91782402a41cd67264e34b5541a4b3f875b",
+ "8d486b03ac4e3b486b7a1d563706c7fdac75aee789a7cf6f22789eedeff61a31",
+ "9f297ff0aa2ceda91c5ab1b6446f12533d145940de6d850dc323417afde0cb78",
+};
+
+/**
+ * Signatures of the public keys, made with their corresponding
+ * secret keys.
+ */
+static const char *ED25519_SELF_SIGNATURES[] = {
+ "d23188eac3773a316d46006fa59c095060be8b1a23582a0dd99002a82a0662bd246d84"
+ "49e172e04c5f46ac0d1404cebe4aabd8a75a1457aa06cae41f3334f104",
+ "3a785ac1201c97ee5f6f0d99323960d5f264c7825e61aa7cc81262f15bef75eb4fa572"
+ "3add9b9d45b12311b6d403eb3ac79ff8e4e631fc3cd51e4ad2185b200b",
+ "cf431fd0416bfbd20c9d95ef9b723e2acddffb33900edc72195dea95965d52d888d30b"
+ "7b8a677c0bd8ae1417b1e1a0ec6700deadd5d8b54b6689275e04a04509",
+ "2375380cd72d1a6c642aeddff862be8a5804b916acb72c02d9ed052c1561881aa658a5"
+ "af856fcd6d43113e42f698cd6687c99efeef7f2ce045824440d26c5d00",
+ "2385a472f599ca965bbe4d610e391cdeabeba9c336694b0d6249e551458280be122c24"
+ "41dd9746a81bbfb9cd619364bab0df37ff4ceb7aefd24469c39d3bc508",
+ "e500cd0b8cfff35442f88008d894f3a2fa26ef7d3a0ca5714ae0d3e2d40caae58ba7cd"
+ "f69dd126994dad6be536fcda846d89dd8138d1683cc144c8853dce7607",
+ "d187b9e334b0050154de10bf69b3e4208a584e1a65015ec28b14bcc252cf84b8baa9c9"
+ "4867daa60f2a82d09ba9652d41e8dde292b624afc8d2c26441b95e3c0e",
+ "815213640a643d198bd056e02bba74e1c8d2d931643e84497adf3347eb485079c9afe0"
+ "afce9284cdc084946b561abbb214f1304ca11228ff82702185cf28f60d",
+};
+
diff --git a/src/test/example_extrainfo.inc b/src/test/example_extrainfo.inc
new file mode 100644
index 0000000000..606279a765
--- /dev/null
+++ b/src/test/example_extrainfo.inc
@@ -0,0 +1,192 @@
+static const char EX_EI_MINIMAL[] =
+ "extra-info bob 3E1B2DC141F2B7C6A0F3C4ED9A14A9C35762E24B\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "K5GAkVjpUlofL78NIOE1VDxFn8yYbHK50rVuZG2HxqG/727bon+uMprv4MHjfDcP\n"
+ "V3l9u1uUdGiUPOl8j+hRNw4z/ODeCj/24r2+L32MTjyfUhK49Ld2IlK9iZKlgKYi\n"
+ "zyoatxdAjU8Xc5WPX692HO4/R9CGLsUfYcEEFU2R3EA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_MINIMAL_FP[] = "3E1B2DC141F2B7C6A0F3C4ED9A14A9C35762E24B";
+static const char EX_EI_MINIMAL_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALSppIF3t3wOAm4fzxRvK+q/wh1gGAWwS0JEn8d+c/x+rt1oQabGkqsB\n"
+ "GU6rz1z1AN02W0P2+EcyJQVBjGR3gHQNoDGx0KIdnr3caGAw3XmQXrJLPaViEk28\n"
+ "RJMxx6umpP27YKSyEMHgVTDXblKImT0mE7fVOx8tD0EWRYazmp4NAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+static const char EX_EI_MAXIMAL[] =
+ "extra-info bob FF8248FE780A7236D3FA5D62DEA642055135F942\n"
+ "published 2014-10-05 20:07:00\n"
+ "opt foobarbaz\n"
+ "read-history 900 1,2,3\n"
+ "write-history 900 1,2,3\n"
+ "dirreq-v2-ips 1\n"
+ "dirreq-v3-ips 100\n"
+ "dirreq-v3-reqs blahblah\n"
+ "dirreq-v2-share blahblah\n"
+ "dirreq-v3-share blahblah\n"
+ "dirreq-v2-resp djfkdj\n"
+ "dirreq-v3-resp djfkdj\n"
+ "dirreq-v2-direct-dl djfkdj\n"
+ "dirreq-v3-direct-dl djfkdj\n"
+ "dirreq-v2-tunneled-dl djfkdj\n"
+ "dirreq-v3-tunneled-dl djfkdj\n"
+ "dirreq-stats-end foobar\n"
+ "entry-ips jfsdfds\n"
+ "entry-stats-end ksdflkjfdkf\n"
+ "cell-stats-end FOO\n"
+ "cell-processed-cells FOO\n"
+ "cell-queued-cells FOO\n"
+ "cell-time-in-queue FOO\n"
+ "cell-circuits-per-decile FOO\n"
+ "exit-stats-end FOO\n"
+ "exit-kibibytes-written FOO\n"
+ "exit-kibibytes-read FOO\n"
+ "exit-streams-opened FOO\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "ZO79bLlWVNIruCnWW9duDcOKydPWbL5DfrpUv5IRLF4MMFoacMUdJPDUs9e+wY2C\n"
+ "zndHe6i2JK7yKJj+uCOSC8cx61OLG+kVxMLJ/qhA4H5thrYb+GpzMKwbHzQc3PTH\n"
+ "zHRzj041iWXTL7/DMaQlpJOBoac/wTSIKzoV2B00jBw=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_MAXIMAL_FP[] = "FF8248FE780A7236D3FA5D62DEA642055135F942";
+static const char EX_EI_MAXIMAL_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANSpkYhHUW1EqodY4d3JRbvEM1vjjR/vEE8gjONiJ5t2Sten53jzt8bh\n"
+ "8/VJn7pQGs8zR5CIxCw4P68xMtZJJedS3hhjqubheOE/yW1DtpkiCf+zVEaLpeA8\n"
+ "fYQChkRICnR/BZd4W9bbohLVII5ym2PaJt2ihB3FeVZIsGXm4wxhAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+static const char EX_EI_BAD_SIG1[] =
+ "extra-info bob 3E1B2DC141F2B7C6A0F3C4ED9A14A9C35762E24B\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "K5GAkVjpUlofL78NIOE1VDxFn8yYbHK50rVuZG2HxqG/727bon+uMprv4MHjfDcP\n"
+ "V3l9u1uUdGiUPOl8j+hXXw4z/ODeCj/24r2+L32MTjyfUhK49Ld2IlK9iZKlgKYi\n"
+ "zyoatxdAjU8Xc5WPX692HO4/R9CGLsUfYcEEFU2R3EA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_SIG2[] =
+ "extra-info bob 3E1B2DC141F2B7C6A0F3C4ED9A14A9C35762E24B\n"
+ "published 2014-10-06 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "K5GAkVjpUlofL78NIOE1VDxFn8yYbHK50rVuZG2HxqG/727bon+uMprv4MHjfDcP\n"
+ "V3l9u1uUdGiUPOl8j+hRNw4z/ODeCj/24r2+L32MTjyfUhK49Ld2IlK9iZKlgKYi\n"
+ "zyoatxdAjU8Xc5WPX692HO4/R9CGLsUfYcEEFU2R3EA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_SIG3[] =
+ "extra-info bob 3E1B2DC141F2B7C6A0F3C4ED9A14A9C35762E24B\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "K5GAkVjpUlofL78NIOE1VDxFn8yYbHK50rVuZG2HxqG/727bon+uMprv4MHjfDcP\n"
+ "V3l9u1uUdGiUPOl8j+hRNw4z/ODeCj/24r2+L32MTjyfUhK49Ld2IlK9iZKlgKYi\n"
+ "zyoatxdAjU8Xc5WPX692HO4/R9CGLsUfYcEEFU2=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_FP[] =
+ "extra-info bob C34293303F0F1E42CB14E593717B834E8E53797D8888\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "IDA8ryUYeMx7+Au/xQmX7Y8fXksoHUOXmePND2JYM4rPfishQJ1LpQ15KrolOZDH\n"
+ "FVIk3RmCefNlJeS1/UgWPcU8u2nGw1YQuRBHF4ViTmZ0OevI1pTsSApl4+oIx2dy\n"
+ "DGgCQmKfMbaOixIK8Ioh1Z2NUfMkjbUUE2WWgFTAsac=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_FP_FP[] = "C34293303F0F1E42CB14E593717B834E8E53797D";
+static const char EX_EI_BAD_FP_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKXMSbif4fG+BW/5lIq5V1tMRondIUfKiNizp0E6EcBw5LvYfQV6zrj8\n"
+ "HmMFbB/WGf9XGVMxIBzxzeQBRvCQJh+0QH7+ju5/isIHJZsACMILepr6ywmCcjVU\n"
+ "iYRtC8zGQLqfkf2cNoo7AhcI5i/YzyW2u1zmbPX5J+8sUErfxydbAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+static const char EX_EI_BAD_NICKNAME[] =
+ "extra-info bobhasaverylongnameandidontthinkweshouldlethim A4EA2389A52459B3F7C7121A46012F098BDFC2A4\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "e2wLJFThRMGawxKrQPuH2XCLek/LJsg4XOB8waAjE0xdHOrzjur9x1jIxy7DVU6t\n"
+ "z1edbIoL24qucMJvFy2xjSQhFRX4OsyNc0nWr3LfJnTW9aEmxuwXM+mltUD2uFN1\n"
+ "2vYOIQjUmJwS2yfeSKnhXEl2PWVUmgzYL3r4S5kHco4=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_NICKNAME_FP[] = "A4EA2389A52459B3F7C7121A46012F098BDFC2A4";
+static const char EX_EI_BAD_NICKNAME_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKfq7oxD1kMu1+zeG2UVXN4vOu6FDp0V/olA3ttmXpUCgCiBxWTgtwNl\n"
+ "nPf0HcKMaCp/0D9XrbhvIoOsg0OTf1TcJfGsA/zPG7jrWYa4xhD50KYvty9EINK9\n"
+ "/UBWNSyXCFDMqnddb/LZ8+VgttmxfYkpeRzSSmDijN3RbOvYJhhBAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+const char EX_EI_BAD_TOKENS[] =
+ "extra-info bob 6F314FB01A31162BD5E473D4977AC570DC5B86BB\n"
+ "published 2014-10-05 20:07:00\n"
+ "published 2014-10-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "lhRIafrkKoQmnUoBLiq4XC8XKXrleGJZ5vefkLcgjOJ5IffsvVdIA7Vqq/ISbPrG\n"
+ "b/Zs0sJNL6naHPxJBglgHJqksSyiYHaeOetXg2Rb+vZ1v2S5BrVgk1nPMDhyIzqc\n"
+ "zU7eCxFf/1sXKtWlEKxGdX4LmVfnIln5aI31Bc4xRrE=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+const char EX_EI_BAD_TOKENS_FP[] = "6F314FB01A31162BD5E473D4977AC570DC5B86BB";
+const char EX_EI_BAD_TOKENS_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAL7Z8tz45Tb4tnEFS2sAyjubBV/giSfZdmXRkDV8Jo4xqWqhWFJn7+zN\n"
+ "AXBWBThGeVH2WXrpz5seNJXgZJPxMTMsrnSCGcRXZw0Npti2MkLuQ6+prZa+OPwE\n"
+ "OyC6jivtAaY/o9iYQjDC2avLXD3N4LvoygyF418KnNcjbzuFygffAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+static const char EX_EI_BAD_START[] =
+ "published 2014-10-05 20:07:00\n"
+ "extra-info bob 5CCCACE71A9BDB5E8E0C942AB3407452350434C0\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "BOiWgexqCAMZ8uyJ7jwBwRkz7Ox8cT4BImkmkV3bQiZgcWvPiYA3EnCm2ye48Ldg\n"
+ "zBST2p6zJM5o4MEDYGMxfViS86Abj/z7DOY1gtLhjmAaVjIIpXc3koxEZtzCecqy\n"
+ "JQz6xEg9/KoEuoT0DRrfYQ+KtQfzBDWrotfOvEa1rvc=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_START_FP[] = "5CCCACE71A9BDB5E8E0C942AB3407452350434C0";
+static const char EX_EI_BAD_START_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAK2OCIfM6Cin/lq99Z3w9tl6HeyGlkBZu9MQEPHxqGIHTq78lIC1UkrC\n"
+ "6NTqlrHBV9dmfzdwJn4GgMWsCZafL0FPIH3HNyNKUxLgyjixyKljHx2rfErSfOxI\n"
+ "bMoOGBKv7m1EZZ0O5uG9ly9MBiNGdJyLdlnVvH7wSCnYciizpO4lAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
+
+static const char EX_EI_BAD_PUBLISHED[] =
+ "extra-info bob E67C477E3536BDE348BD407426D9679E5AE0BC16\n"
+ "published 2014-99-05 20:07:00\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "l45IziBaXRKIjPAIUogMFNjQgH6k6Vm0+6r5+oByr4sP+B3ufNdUA6+WqBs43F0Z\n"
+ "IqcJiT9nFn0DuNd/liOyOCixppDLx5h5NrhoGqcT3ySADEEXhzjlmc35TI3YBNVO\n"
+ "v98fotmwIEg9YRWVGPg6XuIn2PRyiboFyjUpaYGCV0Q=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_EI_BAD_PUBLISHED_FP[] = "E67C477E3536BDE348BD407426D9679E5AE0BC16";
+static const char EX_EI_BAD_PUBLISHED_KEY[] =
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAL7q8GEI18iv8Fo0QbNHmFatQ2FNacalPldpmKUdMJYEVZtdOR0nhcrY\n"
+ "BvG6303md3INygg+KP49RvWEJR/cU4RZ9QfHpORxH2OocMyRedw2rLex2E7jNNSi\n"
+ "52yd1sHFYI8ZQ4aff+ZHUjJUGKRyqpbc8okVbq/Rl7vug0dd12eHAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n";
diff --git a/src/test/failing_routerdescs.inc b/src/test/failing_routerdescs.inc
new file mode 100644
index 0000000000..b49d59fd8a
--- /dev/null
+++ b/src/test/failing_routerdescs.inc
@@ -0,0 +1,668 @@
+/* This one actually succeeds */
+static const char EX_RI_MINIMAL[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAObzT4opT9uaThByupbb96tYxVpGxzL9CRPKUcU0beGpHyognD9USHWc\n"
+ "SpSpKfBL5P3xr2i/XTs34M4UTbT9PE7bVyxv7RD/BZmI4gc8R3PMU77xxbpEU5bK\n"
+ "LF3QUPpuB88m/2fXUGgMNVDc5MIq6pod2NRoDpeU7WA8T3ewXzK5AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM1QKsQiup9DNMCgNeE2FkAhCWzpMZKCn1nNlZbDGfE3Z22ex6bdWWY6\n"
+ "ocEZ3JZDsZsnaZrdYxrL3Mquq7MbHdfx90EdlOvDRP1SAIbZ55mLR77fZTu4BKd/\n"
+ "h9BC6I26uZE0QavFq3+BhoVVhVn5Mqv05nR9CeUMSSZLxw/RJm4DAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Ft/y3JXowjItgfTHwYcZzuUgXrskluoINW5sr+GQoNYE2F4sT8o0tBBJwqJ6FwKd\n"
+ "fkIprv9UXqkv5iY+pXSYSI12mY1K5GMNkXiObk46NjuoNNP9l8oidhO6eNfcE+k3\n"
+ "CRIYS4FbBaD0fWUSwgMuo0Bp83/Wzp3B9ytEBh0/624=\n"
+ "-----END SIGNATURE-----\n";
+
+/* So does this, and it's bigger. */
+static const char EX_RI_MAXIMAL[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANNI56H+b7SW5LMzvXyY5NJzXszsHZZ4O1CPm4CePhBsAz1r0s1JYJ1F\n"
+ "Anrc0mEcLtmj0c5+HnhPBNrfpjO6G94Wp3NZMVykHDhfNVDBRyFZMroG8/GlysYB\n"
+ "MQPGQYR0xBgiuclNHoyk/vygQhZekumamu2O86EIPcfg9LhGIgEbAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALvuNVSmg6R9USFbQcNbRjMCJAV0Rwdv0DlS6Rl02ibJgb01G7v391xE\n"
+ "d9Njzgf93n8gOrE195bkUbvS6k/DM3HFGgArq6q9AZ2LTbu3KbAYy1YPsSIh07kB\n"
+ "/8kkvRRGx37X9WGZU3j5VUEuzqI//xDE9lbanlnnFXpnb6ymehDJAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject 127.0.0.1:*\n"
+ "accept *:80\n"
+ "reject *:*\n"
+ "ipv6-policy accept 80,100,101\n"
+ "ntor-onion-key s7rSohmz9SXn8WWh1EefTHIsWePthsEntQi0WL+ScVw\n"
+ "uptime 1000\n"
+ "hibernating 0\n"
+ "unrecognized-keywords are just dandy in this format\n"
+ "platform Tor 0.2.4.23 on a Banana PC Jr 6000 Series\n"
+ "contact O.W.Jones\n"
+ "fingerprint CC43 DC8E 8C9E 3E6D 59CD 0399 2491 0C8C E1E4 50D2\n"
+ "read-history 900 1,2,3,4\n"
+ "write-history 900 1,2,3,4\n"
+ "extra-info-digest AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\n"
+ "hidden-service-dir\n"
+ "allow-single-hop-exits\n"
+ "family $AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA $BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB\n"
+ "caches-extra-info\n"
+ "or-address [::1:2:3:4]:9999\n"
+ "or-address 127.0.0.99:10000\n"
+ "opt fred is a fine router\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "x5cxL2h2UsEKk2OVnCTxOF8a89HAe/HwQnSlrBy8+l0YdVCcePDJhm1WyWU7ToHZ\n"
+ "K8auwreuw+u/n14sQHPYrM9NQE689hP4LC9AYOnrCnMHysfVqKuou+DSKYYRgs0D\n"
+ "ySCmJ9p+xekfmms+JBmS5o5DVo48VGlG0VksegoB264=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+/* I've messed with 12 bits of the signature on this one */
+static const char EX_RI_BAD_SIG1[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAObzT4opT9uaThByupbb96tYxVpGxzL9CRPKUcU0beGpHyognD9USHWc\n"
+ "SpSpKfBL5P3xr2i/XTs34M4UTbT9PE7bVyxv7RD/BZmI4gc8R3PMU77xxbpEU5bK\n"
+ "LF3QUPpuB88m/2fXUGgMNVDc5MIq6pod2NRoDpeU7WA8T3ewXzK5AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM1QKsQiup9DNMCgNeE2FkAhCWzpMZKCn1nNlZbDGfE3Z22ex6bdWWY6\n"
+ "ocEZ3JZDsZsnaZrdYxrL3Mquq7MbHdfx90EdlOvDRP1SAIbZ55mLR77fZTu4BKd/\n"
+ "h9BC6I26uZE0QavFq3+BhoVVhVn5Mqv05nR9CeUMSSZLxw/RJm4DAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Ft/y3JXowjItgfTHwYcZzuUgXrskluoINW5sr+GQoNYE2F4sT8o0tBBJwqJ6FwKd\n"
+ "fkIprv9UXqkv5iY+pXSYXX12mY1K5GMNkXiObk46NjuoNNP9l8oidhO6eNfcE+k3\n"
+ "CRIYS4FbBaD0fWUSwgMuo0Bp83/Wzp3B9ytEBh0/624=\n"
+ "-----END SIGNATURE-----\n";
+
+/* This is a good signature of the wrong data: I changed 'published' */
+static const char EX_RI_BAD_SIG2[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAObzT4opT9uaThByupbb96tYxVpGxzL9CRPKUcU0beGpHyognD9USHWc\n"
+ "SpSpKfBL5P3xr2i/XTs34M4UTbT9PE7bVyxv7RD/BZmI4gc8R3PMU77xxbpEU5bK\n"
+ "LF3QUPpuB88m/2fXUGgMNVDc5MIq6pod2NRoDpeU7WA8T3ewXzK5AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM1QKsQiup9DNMCgNeE2FkAhCWzpMZKCn1nNlZbDGfE3Z22ex6bdWWY6\n"
+ "ocEZ3JZDsZsnaZrdYxrL3Mquq7MbHdfx90EdlOvDRP1SAIbZ55mLR77fZTu4BKd/\n"
+ "h9BC6I26uZE0QavFq3+BhoVVhVn5Mqv05nR9CeUMSSZLxw/RJm4DAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:01\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Ft/y3JXowjItgfTHwYcZzuUgXrskluoINW5sr+GQoNYE2F4sT8o0tBBJwqJ6FwKd\n"
+ "fkIprv9UXqkv5iY+pXSYSI12mY1K5GMNkXiObk46NjuoNNP9l8oidhO6eNfcE+k3\n"
+ "CRIYS4FbBaD0fWUSwgMuo0Bp83/Wzp3B9ytEBh0/624=\n"
+ "-----END SIGNATURE-----\n";
+
+/* This one will fail while tokenizing the first line. */
+static const char EX_RI_BAD_TOKENS[] =
+ "router bob\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANGCgvZc+JRtAzuzk3gBD2rH9SHrXzjJ1wqdU3tLKr7FamKCMI2pLwSA\n"
+ "FZUpTuSqB9wJ/iVcYws+/kA3FjLqgPtzJFI0SVLvQcz5oIC1rEWpuP6t88duMlO9\n"
+ "flOUzmYu29sBffrXkQr8pesYvakyXArOJVeRR7fSvouneV5aDYWrAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAML+pYZoYc+whKLijupd63xn0gzlEQqe7k07x/lWMqWFT37FfG6YeNr5\n"
+ "fpFoo77FDfuFaL+VfPfI8i88g157hcPKBVX6OyRH54+l5By0tN91S0H+abXjXQpv\n"
+ "U/Bvmul+5QpUeVJa1nPg71HRIauoDnBNexUQ7Xf/Bwb2xCt+IJ6DAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "tbxtYYzyVqi6w6jz1k8NPjFvZaSNR0WzixVTTvKKGoMPx/6+Z8QAFK1ILzRUVucB\n"
+ "nRhmZMFaPr3vREMErLRE47ODAzwoBCE9C+vYFvROhgfzuQ3cYXla+4sMaRXYZzjH\n"
+ "PQ82bTwvSbHsR8fTTgePD/Ac082WxXTGpx6HOLBfNsQ=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_RI_BAD_PUBLISHED[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMoipSwZgTG6SpSOm6ENbyALS1Ljqqa1LSGmtHSRfGYgUQGWZXERXKQj\n"
+ "P5ql6o7EbGr1wnispGW/KB8Age09jGDvd/oGhQ9TDFluhLZon3obkZSFw7f9iA7Q\n"
+ "s29rNxoeXXLZVyS7+sux70b8x2Dt4CeG8GA8nQLljy1euwU+qYYJAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAPzfzQ+2WFMUvnB3z0xD+zwczWcFyYYNW8Lj7/aRGSNN2DICp5uzSjKq\n"
+ "qkYQ+C8jG21+MR2PE+ZBmq6CL5mvlFKlWKouXUlN7BejwWf2gw0UYag0SYctae1b\n"
+ "bu8NuUEvdeGWg5Odgs+abH7U9S0hEtjKrmE5vvJS5L841IcaPLCFAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 99:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "G92pnwCIXGJ9Q0fI9y4m/fHpWCsD0Hnk81/6T4TmRH3jt77fc0uRdomUOC5id4kz\n"
+ "J2M4vqXwRs5OK+eaPbtxf8Yv6FPmB3OBNCIhwNHIIqzKQStHUhPxD3P6j8uJFwot\n"
+ "/CNGciDN+owZ2DzwrXpszDfzcyp/nmwhApbi3W601vY=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+/* Bandwidth field isn't an integer. */
+static const char EX_RI_BAD_BANDWIDTH[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAN32LAvXQaq0p554FcL4LVwnxyiZvscfuFnfpXwWTDRJJHd2+JCttWIx\n"
+ "v+eW7dNq+rq/tzSzaZwnp8b4V2skLRojSt6UUHD234eZcsPwUNhSr0y1eMuoZbnV\n"
+ "UBBPevpuXea85aSFEXXRlIpQfvFc43y3/UFoRzo5iMPqReo2uQ4BAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMBuF1GvOyVcRDNjzlEmGHJkTA7qkaWgTp33NSY/DPEJoahg0Qswuh2w\n"
+ "1YCBqem6Txp+/Vl9hoUoUGwb7Vwq0+YDMSyr0z3Ih2NcNjOMZPVtjJuv+3wXrQC8\n"
+ "LPpCpfU9m9QvhQ7f9zprEqUHOQTT0v5j2a5bpfd++6LFxrMUNwbfAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth hello world today\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "svABTGDNJOgaiPLqDlkRU6ldYJcoEe2qHlr4O30lVM2hS3Gg6o4QARL7QRt7VepT\n"
+ "SruR6pE83xOr7/5Ijq5PlamS4WtODMJSH3DXT2hM5dYYrEX5jsJNZTQ+cYwPQI3y\n"
+ "ykuvQIutH6ipz5MYc9n0GWAzDjLq1G8wlcEfFXQLD10=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+/* Onion key is actually a signature. */
+static const char EX_RI_BAD_ONIONKEY1[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANByIdFOKA3r2nnWyLjdZE8oGHqJE62T1zjW/nsCzCJQ8/kBMRYeGDu4\n"
+ "SeUJJ2rsh2t3PNzkqJM14f4DKmc2q76STsOW0Zcj70Bjhxb9r/OfyELVsi+x3CsE\n"
+ "Zo/W4JtdlVFjqevhODJdyFNLKOvqwG7sZo/K++Hx01Iu0zXLeg8nAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "svABTGDNJOgaiPLqDlkRU6ldYJcoEe2qHlr4O30lVM2hS3Gg6o4QARL7QRt7VepT\n"
+ "SruR6pE83xOr7/5Ijq5PlamS4WtODMJSH3DXT2hM5dYYrEX5jsJNZTQ+cYwPQI3y\n"
+ "ykuvQIutH6ipz5MYc9n0GWAzDjLq1G8wlcEfFXQLD10=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Cc/Y22KFvxXPXZtjvGIyQdjm4EMhXVXJEBwt8PvK7qlO1AgiVjEBPkUrTQQ/paLQ\n"
+ "lmeCN6jEVcZ8lNiVZgzRQ/2mTO3xLBPj26UNSDuouUwZ01tZ4wPENylNYnLKv5hg\n"
+ "gYARg/nXEJiTVe9LHl99Hr9EWWruRG2wFQjjTILaWzI=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+/* Onion key has exponent 3 */
+static const char EX_RI_BAD_ONIONKEY2[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKP1kWHsH/BZhNSZmn0FyzIrAHtMl1IVPzc7ABbx+kK+IIEMD9k1fy2h\n"
+ "AP2JTm2UmJDUwutVxPsxmndI+9QsRDpu33E5Ai4U1Rb6Qu+2BRj43YAyg414caIu\n"
+ "J5LLn6bOzt7gtz0+q69WHbnwgI4zUgUbwYpwoB7k0dRY97xip9fHAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGHAoGBANBKlyoqApWzG7UzmXcxhXM4T370FbN1edPbw4WAczBDXJslXCU9Xk1r\n"
+ "fKfoi/+WiTGvH7RcZWPm7wnThq2u2EAO/IPPcLE9cshLBkK28EvDg5K/WsYedbY9\n"
+ "1Gou+7ZSwMEPv2b13c7eWnSW1YvFa64pVDKu2sKnIjX6Bm0HZGbXAgED\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "cYcBOlapA+R4xq3nn5CjpnzNXdDArMlHuXv4MairjleF1n755ecH8A/R8YIc2ioV\n"
+ "n/C1TACzFVQ12Q9P3iikVOjIXNxYzaz4Lm/L/Lq4sEOPRJC38QEXeIHEaeM51lE6\n"
+ "p6kCqXcGu/51p5vAFCSiXI1ciucmx93N+TH1yGKRLV0=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_RI_BAD_PORTS[] =
+ "router fred 127.0.0.1 900001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANVi/MVWhzT5uo3Jxw4ElS7UGmA24dnckdkCLetMhZOcE9e9mg4WcImL\n"
+ "NuBe2L/9YaL4PFVchCGlq73phKG6yFdqJdjDV8Qh9MJdAYWW2ORrjRvCrspPaYPN\n"
+ "BGJrkD2Gd4u3sq7f26TIkzmBx0Acd/FD4PQf8+XOt9YYd36ooS4vAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALtP4cIpAYp9nqo1ak4SxALcndFw4o51U36R4oa+uJS/lYQPHkMMOj6K\n"
+ "+AVnj9sxkDJ1POaU5lsCQ5JPG1t+Tkh7vDlJb6RCUy25vJOuaQCb9GVVY7KQTJqA\n"
+ "E0fU73JdKACNjMlbF36aliQhrG4Fq2Uv+y7yp8qsRxQ8jvzEMES/AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "xzu2T+pMZtdsS5q1cwXM2hMIH2c8mpAV31G2hKIuiQRwtPD1ne4iJsnoVCXhFakd\n"
+ "QTq7eTXM174fGWyIT93wvQx/Uqnp29dGZp/VaNOsxHFdYVB4VIVqkBh757h+PSJ+\n"
+ "VNV5JUm4XQ1QbmniJGdTQp4PLBM++fOXMR3ZNd6rt4o=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_NEG_BANDWIDTH[] =
+ "router fred 100.127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMCG/ZCXNCF02uXRSCP7qWBN75jDMQZ363ubnQWhF9KDDNWWiwj3UiZR\n"
+ "zqsM4zKRgjtarWZvp2qxKABFAODd+j9iq5DvUGRbbXv+aR8TT/ifMtwwxHZQBk1F\n"
+ "1hbsLdwWzGIiyz5k2MVhXnt6JTlklH2hgT++gt9YTHYKxkssaq5TAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM3vk/4kOTB1VXrve29JeHOzNUsPwKruBcjxJf+aatxjf6KO2/RW41bM\n"
+ "gRYq9V7VAYeZTsbS727fy03F5rk3QIBhMJxm9FHatQ6rT/iEDD4Q1UZQsNtm+OLf\n"
+ "/TkZZhgfB3MiDQ4ld/+GKd7qww8HXTE+m/g1rXNyZPKozn8K7YUHAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 -1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "bUBBZYZWqCbsH4/7fNXtC/HgIZNGOfDF9v4d9YfKaDs5xDYf2o67hRcwx5imhrgC\n"
+ "IU7n9AI4AGxkFoN6g3Y/t4pqebxdkF678rRDCtrlwwreAiUktgrwnetp9Tpo16xj\n"
+ "V7Uf6LcqQdvu78lRh1dsrY78sf7sb90vusFMPLXGUKM=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_IP[] =
+ "router fred 100.127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMtMrM24AJpJCevxnseIpRlSuAIMksfkfky2+noe7Rok8xn6AMQzMrwx\n"
+ "AiCJ8Jy4DBzIKUiJK4/y1FimyM08qZGR0xeqblCxZ1lbSiXv6OYxoaD2xmWw8zEP\n"
+ "Zgu4jKReHh+gan1D+XpAbFNY0KrANhjRo96ZZ3AQsZQcWBiPKCynAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAOPclmBO/amw1RWTSI1y80qY/EPjc0I+sk9HKr0BQOovxqJ0lmy9Gaue\n"
+ "y+MOejQ9H2hNev0nd7z1fPxEogt7SCe22qJHHX3xDf+D9RpKsvVzDYZsk7hVL7T1\n"
+ "mwHzuiV/dtRa7yAMp7+q0vTUGesU2PYFYMOyPvz5skNLSWrXOm05AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "g6besL/zxOp0N6Q5/7QZgai2kmCU5EAWJlvZrf5jyrjKhsv2a4LDkap07m9QRFqW\n"
+ "GGe7g5iiABIqnl0kzv7NLX7ah+d/xxv+IILXyZfVTxSw0e+zFb3uPlQ7f9JsGJ8i\n"
+ "a+w8wyyDBpOAmi8Ny866Cnp9ojVzCyIErUYHFaPvKao=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_RI_BAD_DIRPORT[] =
+ "router fred 127.0.0.1 9001 0 bob\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANKcD6DJ16X3yvdq05jatdwgjO+hyoIpckW9sV/OkdfIZwf+S6Q4pZGC\n"
+ "doMw5XeOM52gjpx42kUp6M2WlTGDFEpaNU0VyeZYG/M1CM1xvfj3+1PoebioAGdf\n"
+ "GuhNBCHZdaYNiOGnh9t2GgUomgpE6njdS/lovSrDeTL469hfcUghAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANWeGHig5wE9UijaNnEW5au3B3hZKSlzCi+T6MYDPbbYhm8qJaVoXUXF\n"
+ "EP1EUgzDcX3dPEo9upUA1+91GkjGQCo9eOYlqGib8kHIwKnHZK+hernBc/DnOeUp\n"
+ "Wyk9SW5s+fi12OQhr3NGjbSn76FMY9XU3Qt7m3EviTwWpI3Jr5eRAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "t77wEoLjyfMf9LKgBfjveosgwvJ8Go0nb27Ae3Ng9tGtR4qaJQfmwZ5fOOuVU9QC\n"
+ "3s8ww3aY91KD3NTcN3v3FKngxWtRM8AIfwh4pqT3zW6OSP4+nO3xml7ql0Zf6wfj\n"
+ "TPFV2941O3yplAsmBJ41sRSWizF04wTtZAIgzY7dMLA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_NAME2[] =
+ "router verylongnamethatnevereverendsandgoesontoolong 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAL0mcUxg7GJ6oxgciLiBCbo+NuZ/OVKRrERCSM6j6iHERcB9+ciSRgQ5\n"
+ "H6o6FUX2LoRmHYzBk1x7kIjHa9kx9g6CAbBamdZrQbdVnc1y2NrdHB/jvwLj3C48\n"
+ "PgzFIrLg9OlkuoWck/E+YpPllONfF65e0+ualgVjPgpQpXwmz+ktAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAOgHvvTAxyjJtHx9W2X7aOI05H9sYDDY+sxhovT/8EpAHrioex54tsMT\n"
+ "ifgtoXTjGIBEOTDi/1ry39nEW5WPbowqvyzRfR2M43pc96WV7e1nhmD/JrnTYgtR\n"
+ "5/15KxcMJxoDhod7WZ/wlXBnHc2VevX8JTaeOe9KYORCj5iNbtVZAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "j/nFT5gyj20cLHWv94O1jmnqy3n6qkO8Av0OdvvfNeXsMK2UHxk84vzFvEwpUF/Y\n"
+ "i+VR3LXY4CjTpuliMtjt7BQGtmJSvB8W0CeIUenIGzfwDxW9dG2o7spDldKDB/OU\n"
+ "C1wyHvKaA6Yss/02RIDa4AxyjsfbgdJ91qK+aAnYAtA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_BANDWIDTH2[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALQDCm9VEopiYILmt4X9kP6DQazfgKnLXv+6rHbc4qtmvQQD3TVYbxMP\n"
+ "F4sEUaz+YHAPnomfDVW3a0YFRYXwDzUm1n47YYCyhUzEaD2f69Mcl/gLpKdg+QOy\n"
+ "boGB1oD4CStWL3y05KhxxTNiTrg+veMzXTqNwryCYm+GoihIAM9fAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALYHwdx6bmYy09AW5ElN/DWh0fHh3mBK97ryiIMi8FImYfzbw2BR6xuT\n"
+ "aQT5omqS3PNJJcNWZt5gOyDtA9kLh03cch7t1PenXSYJshbME2bDrZDJKVJMN6vV\n"
+ "B1v/9HjXsVF50jBzZsJo3j26XCPT5s6u9wqUFWW09QR3E/1HInHVAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 -1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "p09ijyuvcW+WKRj4mJA/nkLCvZkRcMzykAWheJi1IHCoqhXFdkFLiIRqjaeDVHRr\n"
+ "zBtD+YCQiGvFcaQJ9IUhh7IleHcyyljmDYlvuBAxWiKvVZstJac0kclCU4W+g8yK\n"
+ "0Qug3PmGKk115x2TllHaCZqMo5OkK4I/WAsKp+DnJ1A=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_UPTIME[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMM0Nubr1VXQ/FcgIQTFxZpZDlAEh2XN8FoJ8d+X5S46VDGijmMoYmyN\n"
+ "oLXqMTGmOaR0RGZOeGLgDzeY8tLrfF821IjfkXeAANZibUjdsHwqHO3wlWD2v+GN\n"
+ "0GBocWXEdAp/os229mQQKgYAATJ0Ib3jKhBdtgm5R444u8VX5XnbAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMpyOr4kEtSTZw4H9eSkH2+WmwIlO4VBpY2HkPS00l6L5fM2REjt50Xi\n"
+ "lsNOz8Q6mAn5cMYmsGlv61kg01mCvYc7Z715jGh+1hhVAxMaNS3ED/nSPnslyjhq\n"
+ "BUm51LhYNHD4ktISIqPMurx6aC8B68UYgKzLgCYNzkathFXSBpjRAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "uptime forever-and-a-day\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "NHYeiQOu0nZdrhSy31Xz4F0T6OTU23hPQDzoLax1/zq6iTVrz9xi3HGm7HhOMW1j\n"
+ "YgFGK3+Xm4iJL+DwriunsAIuL5axr3z2hlmFDQHYItP//KyPpOqSrfEOhwcuj/PE\n"
+ "VbWsiVYwz9VJLO8SfHoBeHI6PsjQRQFt2REBKZhYdxA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+
+static const char EX_RI_BAD_BANDWIDTH3[] =
+ "router lucy 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAO6HrITQTEjV/v/rInQ2REmCFZa4dZg8zIh6+B51U/I6hDiZaKGwpNey\n"
+ "9OfjoRqT2DwyLEe3ORm9A2RAz2twLBixrpt5IvC0sbGustmW964BHW7k9VvRupwl\n"
+ "ovujHpLIj5dkLxD15jGXHoTp1yHUVk9NkMGN+ahg6y+QhTbIrWbRAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAOEpciJFXauEqs31GMTUTzu6edBj9WtV+sIflhGKvU1KKRfwCgOcuKMx\n"
+ "QiLHHD9AjhMAFGT/qtNbPFkzfYxHKLHw+NLJsxmNtdkYM26FX3ButPiX+69sq9fI\n"
+ "PCHqQy6z/A7hHwtEk6niWgK2PLhAZCg9duAv+mqFVXe2QEBjax/lAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 electric\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Jk0Xk1RMJSjEflNRcp4qznaHKcfe2r0kOc7TdLAnM8zyNDVj6+Bn8HWmyp/oFmf6\n"
+ "xtWKKgkKxriAVIJgqZMchPbr9RuZS+i+cad++FCwpTVkyBP920XWC47jA3ZXSBee\n"
+ "HK6FaoK5LfmUm8XEU9BVhiwISXaUfTdkR8HfzugFbWk=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_NTOR_KEY[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKYDCSr0Jh9d/mJKjnGYAHKNBcxR3EJk6GGLwKUrRpN8z/aHRxdWlZF2\n"
+ "lBml6yQNK/VPftcvOekxrKq3/dISrIFBzFYj6XHNtg31d09UgitVkk0VfRarZiGu\n"
+ "O6Yv55GSJ9a3AZDE4YmIp5eBjVuChyVkeDFYKVn0ed4sj9gg35rjAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALXdUQuq1pYHyYP0qU6Ik+oOmwl0eOsuwiLWf9Vd+dsgEszICX4DRWPx\n"
+ "syDxfxyA/g9FEPvlI7Nglx6cKe2MT0AutSRLbbML4smfuRZNIF35Cnfu5qTGVVzL\n"
+ "GWVSA2Ip7p+9S9xLhLBdc6qmrxEXCPL6anEhCR4f8AeybXAsz2JLAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "ntor-onion-key s7rSohmz9SXn8WWh1EefTHIsWePthsEntQi0WL+ScVfjdklsdfjkf\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Yf9axWyzPudnRvQstNdbtBYo7pGpUEIdECMGcJtFb6v/00pxk4Tt3RiOKa84cOBV\n"
+ "7V9NjOLdqlx88pGz0DNCJKqToIrwjZDeQ8Q1yi9XClLDkC32fQRX4y6vNBZ3LXLe\n"
+ "ayVrdRrb41/DP+E7FP4RNPA5czujTfs8xLBMbGew8AA=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_FINGERPRINT[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM0wDWF2dBLzsmoIDHRugzosCSR9TSvEE0TkvKu6+agfogGtkQJwQ5zO\n"
+ "sGzZbRR+okO7d+QCED2i3rUs1iikoMUT+pwgvOm8Bxg9R64GK7fl9K5WuAiG11Uj\n"
+ "DQAfSx5Fo30+rhOhe16c9CT7xJhj//ZKDbXUW7BrJI8zpuOnvgD5AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKACg1nWM/WjpUiGwlLQsY3Tq1h0RTz/HmOMx/6rTRxS5HLz0KnLg5zV\n"
+ "dvmfhxqQVKBkt1N2+y+qO7x71oFzIsFMfHYWSxOCEo8Nkff1BqAPqxxUHvM0HwJo\n"
+ "d7lswJ/UT1j4+WZNZ4sFIujsIW2/zZqKlxG9xaw0GXJ082Cj9XkPAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "fingerprint 5555\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "mlqyJ/ZGBINKwSNEi7GpNBCMqIVbL0pGAOBYHJF1GbRlU28uRyNyeELIxIK5ZIet\n"
+ "ZzKr7KPvlBxlyolScPhTJfP98TFSubrwYz7NnQv0vLI0bD0OyoBf/9/1GYlzgTso\n"
+ "3mKfnV7THUalpxe9EjQ/x61Yqf26Co0+jYpt8/Ck6tg=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_MISMATCHED_FINGERPRINT[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANUAvwbpGbsAyA+mBwjFkvurtRzdw9btDqNKtPImufIE+q+AFTaCnwPr\n"
+ "kA7vm/O6h6OhgfdYEC2GfYJfwPGM7MDuz+NnuKxUb3qb2DQN2laqow6qWs9La/if\n"
+ "oHKUjC5mNeAgHcbWapx9CygwaFeVW6FBPl6Db6GIRAlywPSX+XMJAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANlSGd+Vm9nLiUk6zgu8dPnSFfw4F0R2GYfmzncIGJWtRFTF9ThW/0av\n"
+ "/9vZAWyVBjjtnpAP5R1BzdJYV2RwimC/6tqoHtkSbCBhdq5Cb/EHG7Xgb8KwNWVJ\n"
+ "NV1EESDwvWnRfSPGTreRw9+2LkdXri17FhDo2GjRxAq/N7YkLK5hAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "fingerprint CC43 DC8E 8C9E 3E6D 59CD 0399 2491 0C8C E1E4 50D2\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Y8MwYBeEfMhoAABK/FgpVRYolZ7jQ2BJL+8Lb6i4yAuk+HeVmPKTX7MqQoekUuin\n"
+ "/HdPKP+g/9HPMS5pCiW4FMwnXAF0ZocPXF0ndmsTuh0/7VWVOUGgvBpPbIW6guvt\n"
+ "sLLQ3Cq9a4Kwmd+koatfLB6xSZjhXmOn7nRy7gOdwJ8=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_HAS_ACCEPT6[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAJfPJNA3zZ77v2nlX2j5dXImcB/NhRtkG8XQgF7z+3H17sqoXgBgZ1dq\n"
+ "IbyJmAy2Lrvk/8VkXNFrT5/ErThn1B98V/PsJOOW1x7jGcix6X4zDYn/MvwC+AxA\n"
+ "zNP0ozNcVZ6BzVYq8w4I1V4O3Cd6VJesxRVX6mUeSeNawOb7fBY7AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKBzfB4mDEJjFTnmtqZxDG8G1yAiccVgAtq9ECEREL/BOQyukixUBeBe\n"
+ "j/FgXzbMJ7DZAuopuJZU2ma6h14G63fZs7eNFceDtmdLpuCOsFuvJ5Mlkf3hDZ1u\n"
+ "1KK5q+tiG7MKxgnGrqjPBUO2uubs2Cpx0HmsqBNUalXd/KAkFJbXAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "accept6 *:80\n"
+ "reject6 *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "Dp9dLgs9s5beMPxfD0m96as9gNBvlmKhH1RQ/kcOKscia4R8Q42CnUtIqLkCdjOu\n"
+ "zErc2Vj9QzjKOvlqUqHxP+J+l+ZJez6F+E1tcmK/Ydz3exL8cg9f4sAOCSXcpBey\n"
+ "llTFDibz6GkQ2j3/Uc4bN/uLzoyZKunpJbSKZP5nt8Q=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_NO_EXIT_POLICY[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAK4fbjTKYqv2fygfjzY53sVTdtbNMjq293/uffKKxFYnOVvPzrHlP6Go\n"
+ "2S19ZcyDxOuH1unbBChPnV0GpxXX6+bgfDkaFh7+jef0RQ3fpJl84hSvdM8J8SCt\n"
+ "Q/F4Oqk3NeKKs+zAHDjhAU1G4LkF9/SZ9WZVXlH4a4pf7xgQtaShAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKahvyDkmh33ob/bLVO1icgz2ntOZN6ZQUfgpMU4Cd6DQtOEwFUGhbVt\n"
+ "gvtMHv2+VbxM31ZfUsyBqJ1rJBLpOqlPvSoYwSac2+twa+w/qjfGqcJYhBjP9TV9\n"
+ "n9y8DzBX85p6vRcCzcuZ4qUJ2nRzdLHwjdgzeLmmCHuPO2dQxQhXAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "ntgCtMC0VrsY42dKts8igGQ2Nu1BpuzUltisIsJz75dDx2LCqTn7p4VpWbTrj1sH\n"
+ "MRNOvEPFxVMs0Lu50ZUGRzeV6GrHmzIRnOIWanb3I/jyrJLM0jTIjCOLwdMRA298\n"
+ "tw8Y9Hnwj4K7K6VvgU8LP4l7MAJNfR6UT46AJ6vkgL0=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_IPV6_EXIT_POLICY[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKHJKLHqjYoW9M+1q0CGHJRT5u2CnZWb8Qr1DpLkkusQ6ru+cDAG12so\n"
+ "IpDQh7IyB2JosVJi9ogekYxJ3O1p5WlFUi0X19DMoer9FJ9J7/3s4enGJ/yMBeuu\n"
+ "jLVRkjMJhsfhj3Cykon+8Rrf520wSmBg1dpJQCXTwtb7DARgYRpZAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAPJH61Ir6XSu9/Q9tXGaINbXO1GWQQUXtwh6TX9lxnaCNDLGnxiY+ZZw\n"
+ "+Vqj3LAQoMrz1PpPsF5e0VIxok10Vc8y4cWC+kIitcecut4vWC5FYTtVVP9wtlyg\n"
+ "YCcVOVhtFQxtLiGqprl84+EVxrR7RQVCMLNDUXIgxAfdnS24eBPDAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "ipv6-policy kfdslfdfj sdjfk sdfjsdf\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "XWorzVT5Owg+QcsBtksiUNtpQQ5+IdvbsN+0O9FbFtGZeaeBAbPJ3Poz+KFCUjZY\n"
+ "DeDAiu1cVgODx2St+99LpwEuIBx78HaD8RYU8tHx8LoA+mGC43ogQQS9lmfxzvP5\n"
+ "eT5WXhkOS5AZ8LZOCOmT+tj/LkSXev2x/NC9+Vc1HPo=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_FAMILY[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM62QoRxSPnm+ZM4fv9p03Qqbz5SzhXYSNjKWqylBruaofTw6oIM8DtX\n"
+ "7QnrEe/ou/WtfB+swV/2rt/r0EzmeWBWuDmuSUrN5TC2AdOi9brSJMgXVW6VW77X\n"
+ "fuIlLd5DVSId2zs3cKLDqp36CUsooA9sS6I5HrvW9QDf3VS3pGBtAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANg1trpnRzkCi4t4Z4qnBKF612H5A3Zrjg7Jo2b3ajUnON/KEuLPTc3t\n"
+ "PPN0W4qqeCMmVQEuxf3DRbTPS20ycy4B/JDWYfxCNwuj5YAx04REf7T0Hlx7Aee/\n"
+ "sHEQBhIBfasA2idhTh3cAm4DMYn+00BqjxF6jmyRA0hyntEABabrAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "family aaaa,bbbb\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "xOgP3liKF/WEvwbbGzUUVRZ5WPrOI7jex8pZU/02UEnHjit7vCf9fsUcvkeo0xjz\n"
+ "n3FQHIO1iAJS7dEaEM4nz6wtPUb2iXSU9QajkGBkJ9/V7NHMFIU3FGfP47PIJJkd\n"
+ "nz5INoS+AsE7PmnDjUMm1H45TCCl8N8y4FO6TtN7p8I=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_BAD_EI_DIGEST[] =
+ "router fred 127.0.0.1 9001 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAJ8Sn8AxBRbeIAHUvaKjqmcYOvXz7YFlpYFiVHp/cn+l+KUkIYTOFQXf\n"
+ "K8AtwjmJ4R2qJIbNlY/6oZGFbizt/B+WPuWsTj+8ACEEDlxx0ibg3EJRB8AZYiWv\n"
+ "0zC/loiUvHm6fXF5ghvDr9BQzEUo9kBk5haoHwROtGawr1+vOEiNAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMzok3ZJtLjXOC8RKltXI8xulwn/ctCvQFHImR0+ccA1uBxaZNYgiIcc\n"
+ "q8XngROfV8xEgDbYPiWiLXJOMSwOd7hfs3YzRWF+LKftYs8PuRyMJcCoBjOPZ4QX\n"
+ "HRfTetEvu2SijZMby+lkqpZg2nuF/ipsXUjrabRZdNiIGhC451vdAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "extra-info-digest not-a-digest\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "c/6zAxO04izQvqdM4bZVGE+ak0nna5pz9XZizFkieZEDWGzWQuVMhXyL5sbsFbsx\n"
+ "6Hn7DvNRYR/2nA0teDeRyIHMoMHi76te5X9OFDgaeUVCbyJ8h/KZYfPnN86IDbsR\n"
+ "dCSmj9kX55keu64ccCAH1CqwcN/UsbplXiJJVG5pTfI=\n"
+ "-----END SIGNATURE-----\n"
+ ;
+static const char EX_RI_ZERO_ORPORT[] =
+ "router fred 127.0.0.1 0 0 9002\n"
+ "signing-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMc4MOhLG3PKPgc+xYVf4eScWzeOf8wq7Cb/JxZm50G0LuvVbhHtHEZX\n"
+ "VOSHI7mLE1ifakJvCFJRLobMU7lU0yhn18/nKl2Cu5NfFHHeF/NieUBSxBGb2wD6\n"
+ "aM1azheXrRqvDVVfbI0DLc/XfQC/YNiohOsQ/c9C6wuffA4+Sg85AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALBWdl9/Vft+NQKQlg5kgvZo+krnhNTRVQojWtUEzom4TFIT+NNKJyMG\n"
+ "reQXcNdzNptTB0aOBGGwqAesqzsZ2Hje699NsDe7hdl7Sb5yhKDqtdQY6yDXJUFt\n"
+ "zqpAUkmYMLe2p3kPiWefNso56KYXrZrlNAiIS/FhQ5cmuMC2jPydAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "published 2014-10-05 12:00:00\n"
+ "bandwidth 1000 1000 1000\n"
+ "reject *:*\n"
+ "router-signature\n"
+ "-----BEGIN SIGNATURE-----\n"
+ "gFg08P9A6QNQjURlebfdhU3DSV0BeM0j2SFza1jF9JcBOWDRmT8FvYFK1B3js6jK\n"
+ "8LNV8JOUssv14z5CnUY9CO1BD0xSl+vGlSS4VOXD7rxui8IoWgnqnZsitq+Qzs95\n"
+ "wgFKhHI/49NHyWHX5IMQpeicg0T7Qa6qwnUvspH62p8=\n"
+ "-----END SIGNATURE-----\n"
+ ;
diff --git a/src/test/include.am b/src/test/include.am
index d5163aac2f..d0f3224dc5 100644
--- a/src/test/include.am
+++ b/src/test/include.am
@@ -34,6 +34,7 @@ src_test_test_SOURCES = \
src/test/test_logging.c \
src/test/test_microdesc.c \
src/test/test_oom.c \
+ src/test/test_accounting.c \
src/test/test_options.c \
src/test/test_pt.c \
src/test/test_relaycell.c \
@@ -46,6 +47,7 @@ src_test_test_SOURCES = \
src/test/test_nodelist.c \
src/test/test_policy.c \
src/test/test_status.c \
+ src/test/test_routerset.c \
src/ext/tinytest.c
src_test_test_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
@@ -59,7 +61,7 @@ src_test_test_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@ \
@TOR_LDFLAGS_libevent@
src_test_test_LDADD = src/or/libtor-testing.a src/common/libor-testing.a \
src/common/libor-crypto-testing.a $(LIBDONNA) \
- src/common/libor-event-testing.a \
+ src/common/libor-event-testing.a src/trunnel/libor-trunnel-testing.a \
@TOR_ZLIB_LIBS@ @TOR_LIB_MATH@ @TOR_LIBEVENT_LIBS@ \
@TOR_OPENSSL_LIBS@ @TOR_LIB_WS32@ @TOR_LIB_GDI@ @CURVE25519_LIBS@
@@ -73,9 +75,11 @@ src_test_bench_LDADD = src/or/libtor.a src/common/libor.a \
noinst_HEADERS+= \
src/test/test.h \
- src/test/test_descriptors.inc
+ src/test/test_descriptors.inc \
+ src/test/example_extrainfo.inc \
+ src/test/failing_routerdescs.inc \
+ src/test/ed25519_vectors.inc
-if CURVE25519_ENABLED
noinst_PROGRAMS+= src/test/test-ntor-cl
src_test_test_ntor_cl_SOURCES = src/test/test_ntor_cl.c
src_test_test_ntor_cl_LDFLAGS = @TOR_LDFLAGS_zlib@ @TOR_LDFLAGS_openssl@
@@ -86,9 +90,6 @@ src_test_test_ntor_cl_LDADD = src/or/libtor.a src/common/libor.a \
src_test_test_ntor_cl_AM_CPPFLAGS = \
-I"$(top_srcdir)/src/or"
NTOR_TEST_DEPS=src/test/test-ntor-cl
-else
-NTOR_TEST_DEPS=
-endif
if COVERAGE_ENABLED
CMDLINE_TEST_TOR = ./src/or/tor-cov
@@ -108,10 +109,8 @@ src_test_test_bt_cl_CPPFLAGS= $(src_test_AM_CPPFLAGS)
check-local: $(NTOR_TEST_DEPS) $(CMDLINE_TEST_TOR)
if USEPYTHON
$(PYTHON) $(top_srcdir)/src/test/test_cmdline_args.py $(CMDLINE_TEST_TOR) "${top_srcdir}"
-if CURVE25519_ENABLED
$(PYTHON) $(top_srcdir)/src/test/ntor_ref.py test-tor
$(PYTHON) $(top_srcdir)/src/test/ntor_ref.py self-test
-endif
./src/test/test-bt-cl assert | $(PYTHON) $(top_srcdir)/src/test/bt_test.py
./src/test/test-bt-cl crash | $(PYTHON) $(top_srcdir)/src/test/bt_test.py
endif
diff --git a/src/test/slow_ed25519.py b/src/test/slow_ed25519.py
new file mode 100644
index 0000000000..f44708b200
--- /dev/null
+++ b/src/test/slow_ed25519.py
@@ -0,0 +1,115 @@
+# This is the ed25519 implementation from
+# http://ed25519.cr.yp.to/python/ed25519.py .
+# It is in the public domain.
+#
+# It isn't constant-time. Don't use it except for testing. Also, see
+# warnings about how very slow it is. Only use this for generating
+# test vectors, I'd suggest.
+#
+# Don't edit this file. Mess with ed25519_ref.py
+
+import hashlib
+
+b = 256
+q = 2**255 - 19
+l = 2**252 + 27742317777372353535851937790883648493
+
+def H(m):
+ return hashlib.sha512(m).digest()
+
+def expmod(b,e,m):
+ if e == 0: return 1
+ t = expmod(b,e/2,m)**2 % m
+ if e & 1: t = (t*b) % m
+ return t
+
+def inv(x):
+ return expmod(x,q-2,q)
+
+d = -121665 * inv(121666)
+I = expmod(2,(q-1)/4,q)
+
+def xrecover(y):
+ xx = (y*y-1) * inv(d*y*y+1)
+ x = expmod(xx,(q+3)/8,q)
+ if (x*x - xx) % q != 0: x = (x*I) % q
+ if x % 2 != 0: x = q-x
+ return x
+
+By = 4 * inv(5)
+Bx = xrecover(By)
+B = [Bx % q,By % q]
+
+def edwards(P,Q):
+ x1 = P[0]
+ y1 = P[1]
+ x2 = Q[0]
+ y2 = Q[1]
+ x3 = (x1*y2+x2*y1) * inv(1+d*x1*x2*y1*y2)
+ y3 = (y1*y2+x1*x2) * inv(1-d*x1*x2*y1*y2)
+ return [x3 % q,y3 % q]
+
+def scalarmult(P,e):
+ if e == 0: return [0,1]
+ Q = scalarmult(P,e/2)
+ Q = edwards(Q,Q)
+ if e & 1: Q = edwards(Q,P)
+ return Q
+
+def encodeint(y):
+ bits = [(y >> i) & 1 for i in range(b)]
+ return ''.join([chr(sum([bits[i * 8 + j] << j for j in range(8)])) for i in range(b/8)])
+
+def encodepoint(P):
+ x = P[0]
+ y = P[1]
+ bits = [(y >> i) & 1 for i in range(b - 1)] + [x & 1]
+ return ''.join([chr(sum([bits[i * 8 + j] << j for j in range(8)])) for i in range(b/8)])
+
+def bit(h,i):
+ return (ord(h[i/8]) >> (i%8)) & 1
+
+def publickey(sk):
+ h = H(sk)
+ a = 2**(b-2) + sum(2**i * bit(h,i) for i in range(3,b-2))
+ A = scalarmult(B,a)
+ return encodepoint(A)
+
+def Hint(m):
+ h = H(m)
+ return sum(2**i * bit(h,i) for i in range(2*b))
+
+def signature(m,sk,pk):
+ h = H(sk)
+ a = 2**(b-2) + sum(2**i * bit(h,i) for i in range(3,b-2))
+ r = Hint(''.join([h[i] for i in range(b/8,b/4)]) + m)
+ R = scalarmult(B,r)
+ S = (r + Hint(encodepoint(R) + pk + m) * a) % l
+ return encodepoint(R) + encodeint(S)
+
+def isoncurve(P):
+ x = P[0]
+ y = P[1]
+ return (-x*x + y*y - 1 - d*x*x*y*y) % q == 0
+
+def decodeint(s):
+ return sum(2**i * bit(s,i) for i in range(0,b))
+
+def decodepoint(s):
+ y = sum(2**i * bit(s,i) for i in range(0,b-1))
+ x = xrecover(y)
+ if x & 1 != bit(s,b-1): x = q-x
+ P = [x,y]
+ if not isoncurve(P): raise Exception("decoding point that is not on curve")
+ return P
+
+def checkvalid(s,m,pk):
+ if len(s) != b/4: raise Exception("signature length is wrong")
+ if len(pk) != b/8: raise Exception("public-key length is wrong")
+ R = decodepoint(s[0:b/8])
+ A = decodepoint(pk)
+ S = decodeint(s[b/8:b/4])
+ h = Hint(encodepoint(R) + pk + m)
+ if scalarmult(B,S) != edwards(R,scalarmult(A,h)):
+ raise Exception("signature does not pass verification")
+
diff --git a/src/test/test-child.c b/src/test/test-child.c
index 756782e70b..91ae5a66a5 100644
--- a/src/test/test-child.c
+++ b/src/test/test-child.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2013, The Tor Project, Inc. */
+/* Copyright (c) 2011-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include <stdio.h>
diff --git a/src/test/test-network.sh b/src/test/test-network.sh
index 7b59864166..d28fbde80f 100755
--- a/src/test/test-network.sh
+++ b/src/test/test-network.sh
@@ -1,5 +1,7 @@
#! /bin/sh
+ECHO_N="/bin/echo -n"
+
until [ -z $1 ]
do
case $1 in
@@ -15,6 +17,10 @@ do
export NETWORK_FLAVOUR="$2"
shift
;;
+ --delay|--sleep|--bootstrap-time|--time)
+ export BOOTSTRAP_TIME="$2"
+ shift
+ ;;
*)
echo "Sorry, I don't know what to do with '$1'."
exit 2
@@ -39,9 +45,14 @@ PATH="$TOR_DIR/src/or:$TOR_DIR/src/tools:$PATH"
# Sleep some, waiting for the network to bootstrap.
# TODO: Add chutney command 'bootstrap-status' and use that instead.
-BOOTSTRAP_TIME=18
-echo -n "$myname: sleeping for $BOOTSTRAP_TIME seconds"
+BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-18}
+$ECHO_N "$myname: sleeping for $BOOTSTRAP_TIME seconds"
n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do
- sleep 1; n=$(expr $n - 1); echo -n .
+ sleep 1; n=$(expr $n - 1); $ECHO_N .
done; echo ""
./chutney verify $CHUTNEY_NETWORK
+VERIFY_EXIT_STATUS=$?
+# work around a bug/feature in make -j2 (or more)
+# where make hangs if any child processes are still alive
+./chutney stop $CHUTNEY_NETWORK
+exit $VERIFY_EXIT_STATUS
diff --git a/src/test/test.c b/src/test/test.c
index 5786f3ca54..0511eb4054 100644
--- a/src/test/test.c
+++ b/src/test/test.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Ordinarily defined in tor_main.c; this bit is just here to provide one
@@ -43,6 +43,7 @@ long int lround(double x);
double fabs(double x);
#include "or.h"
+#include "backtrace.h"
#include "buffers.h"
#include "circuitlist.h"
#include "circuitstats.h"
@@ -63,10 +64,8 @@ double fabs(double x);
#include "rephist.h"
#include "routerparse.h"
#include "statefile.h"
-#ifdef CURVE25519_ENABLED
#include "crypto_curve25519.h"
#include "onion_ntor.h"
-#endif
#ifdef USE_DMALLOC
#include <dmalloc.h>
@@ -191,7 +190,7 @@ remove_directory(void)
#undef CACHE_GENERATED_KEYS
static crypto_pk_t *pregen_keys[5] = {NULL, NULL, NULL, NULL, NULL};
-#define N_PREGEN_KEYS ((int)(sizeof(pregen_keys)/sizeof(pregen_keys[0])))
+#define N_PREGEN_KEYS ARRAY_LENGTH(pregen_keys)
/** Generate and return a new keypair for use in unit tests. If we're using
* the key cache optimization, we might reuse keys: we only guarantee that
@@ -231,7 +230,7 @@ free_pregenerated_keys(void)
/** Run unit tests for the onion handshake code. */
static void
-test_onion_handshake(void)
+test_onion_handshake(void *arg)
{
/* client-side */
crypto_dh_t *c_dh = NULL;
@@ -244,12 +243,13 @@ test_onion_handshake(void)
/* shared */
crypto_pk_t *pk = NULL, *pk2 = NULL;
+ (void)arg;
pk = pk_generate(0);
pk2 = pk_generate(1);
/* client handshake 1. */
memset(c_buf, 0, TAP_ONIONSKIN_CHALLENGE_LEN);
- test_assert(! onion_skin_TAP_create(pk, &c_dh, c_buf));
+ tt_assert(! onion_skin_TAP_create(pk, &c_dh, c_buf));
for (i = 1; i <= 3; ++i) {
crypto_pk_t *k1, *k2;
@@ -266,16 +266,16 @@ test_onion_handshake(void)
memset(s_buf, 0, TAP_ONIONSKIN_REPLY_LEN);
memset(s_keys, 0, 40);
- test_assert(! onion_skin_TAP_server_handshake(c_buf, k1, k2,
+ tt_assert(! onion_skin_TAP_server_handshake(c_buf, k1, k2,
s_buf, s_keys, 40));
/* client handshake 2 */
memset(c_keys, 0, 40);
- test_assert(! onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
+ tt_assert(! onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
- test_memeq(c_keys, s_keys, 40);
+ tt_mem_op(c_keys,==, s_keys, 40);
memset(s_buf, 0, 40);
- test_memneq(c_keys, s_buf, 40);
+ tt_mem_op(c_keys,!=, s_buf, 40);
}
done:
crypto_dh_free(c_dh);
@@ -322,7 +322,7 @@ test_bad_onion_handshake(void *arg)
/* client handshake 1: do it straight. */
memset(c_buf, 0, TAP_ONIONSKIN_CHALLENGE_LEN);
- test_assert(! onion_skin_TAP_create(pk, &c_dh, c_buf));
+ tt_assert(! onion_skin_TAP_create(pk, &c_dh, c_buf));
/* Server: Case 3: we just don't have the right key. */
tt_int_op(-1, ==,
@@ -350,7 +350,7 @@ test_bad_onion_handshake(void *arg)
/* Let the client finish; make sure it can. */
tt_int_op(0, ==,
onion_skin_TAP_client_handshake(c_dh, s_buf, c_keys, 40));
- test_memeq(s_keys, c_keys, 40);
+ tt_mem_op(s_keys,==, c_keys, 40);
/* Client: Case 2: The server sent back a degenerate DH. */
memset(s_buf, 0, sizeof(s_buf));
@@ -363,7 +363,6 @@ test_bad_onion_handshake(void *arg)
crypto_pk_free(pk2);
}
-#ifdef CURVE25519_ENABLED
static void
test_ntor_handshake(void *arg)
{
@@ -407,19 +406,18 @@ test_ntor_handshake(void *arg)
tt_int_op(0, ==, onion_skin_ntor_client_handshake(c_state, s_buf,
c_keys, 400));
- test_memeq(c_keys, s_keys, 400);
+ tt_mem_op(c_keys,==, s_keys, 400);
memset(s_buf, 0, 40);
- test_memneq(c_keys, s_buf, 40);
+ tt_mem_op(c_keys,!=, s_buf, 40);
done:
ntor_handshake_state_free(c_state);
dimap_free(s_keymap, NULL);
}
-#endif
/** Run unit tests for the onion queues. */
static void
-test_onion_queues(void)
+test_onion_queues(void *arg)
{
uint8_t buf1[TAP_ONIONSKIN_CHALLENGE_LEN] = {0};
uint8_t buf2[NTOR_ONIONSKIN_LEN] = {0};
@@ -430,6 +428,7 @@ test_onion_queues(void)
create_cell_t *onionskin = NULL, *create2_ptr;
create_cell_t *create1 = tor_malloc_zero(sizeof(create_cell_t));
create_cell_t *create2 = tor_malloc_zero(sizeof(create_cell_t));
+ (void)arg;
create2_ptr = create2; /* remember, but do not free */
create_cell_init(create1, CELL_CREATE, ONION_HANDSHAKE_TYPE_TAP,
@@ -437,24 +436,24 @@ test_onion_queues(void)
create_cell_init(create2, CELL_CREATE, ONION_HANDSHAKE_TYPE_NTOR,
NTOR_ONIONSKIN_LEN, buf2);
- test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
- test_eq(0, onion_pending_add(circ1, create1));
+ tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
+ tt_int_op(0,==, onion_pending_add(circ1, create1));
create1 = NULL;
- test_eq(1, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
+ tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
- test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
- test_eq(0, onion_pending_add(circ2, create2));
+ tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
+ tt_int_op(0,==, onion_pending_add(circ2, create2));
create2 = NULL;
- test_eq(1, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
+ tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
- test_eq_ptr(circ2, onion_next_task(&onionskin));
- test_eq(1, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
- test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
+ tt_ptr_op(circ2,==, onion_next_task(&onionskin));
+ tt_int_op(1,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
+ tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
tt_ptr_op(onionskin, ==, create2_ptr);
clear_pending_onions();
- test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
- test_eq(0, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
+ tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_TAP));
+ tt_int_op(0,==, onion_num_pending(ONION_HANDSHAKE_TYPE_NTOR));
done:
circuit_free(TO_CIRCUIT(circ1));
@@ -465,7 +464,7 @@ test_onion_queues(void)
}
static void
-test_circuit_timeout(void)
+test_circuit_timeout(void *arg)
{
/* Plan:
* 1. Generate 1000 samples
@@ -483,6 +482,7 @@ test_circuit_timeout(void)
or_state_t *state=NULL;
int i, runs;
double close_ms;
+ (void)arg;
circuit_build_times_init(&initial);
circuit_build_times_init(&estimate);
circuit_build_times_init(&final);
@@ -517,11 +517,11 @@ test_circuit_timeout(void)
} while (fabs(circuit_build_times_cdf(&initial, timeout0) -
circuit_build_times_cdf(&initial, timeout1)) > 0.02);
- test_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE);
+ tt_assert(estimate.total_build_times <= CBT_NCIRCUITS_TO_OBSERVE);
circuit_build_times_update_state(&estimate, state);
circuit_build_times_free_timeouts(&final);
- test_assert(circuit_build_times_parse_state(&final, state) == 0);
+ tt_assert(circuit_build_times_parse_state(&final, state) == 0);
circuit_build_times_update_alpha(&final);
timeout2 = circuit_build_times_calculate_timeout(&final,
@@ -531,7 +531,7 @@ test_circuit_timeout(void)
log_notice(LD_CIRC, "Timeout2 is %f, Xm is %d", timeout2, final.Xm);
/* 5% here because some accuracy is lost due to histogram conversion */
- test_assert(fabs(circuit_build_times_cdf(&initial, timeout0) -
+ tt_assert(fabs(circuit_build_times_cdf(&initial, timeout0) -
circuit_build_times_cdf(&initial, timeout2)) < 0.05);
for (runs = 0; runs < 50; runs++) {
@@ -554,8 +554,8 @@ test_circuit_timeout(void)
CBT_DEFAULT_QUANTILE_CUTOFF/100.0));
}
- test_assert(!circuit_build_times_network_check_changed(&estimate));
- test_assert(!circuit_build_times_network_check_changed(&final));
+ tt_assert(!circuit_build_times_network_check_changed(&estimate));
+ tt_assert(!circuit_build_times_network_check_changed(&final));
/* Reset liveness to be non-live */
final.liveness.network_last_live = 0;
@@ -564,27 +564,27 @@ test_circuit_timeout(void)
build_times_idx = estimate.build_times_idx;
total_build_times = estimate.total_build_times;
- test_assert(circuit_build_times_network_check_live(&estimate));
- test_assert(circuit_build_times_network_check_live(&final));
+ tt_assert(circuit_build_times_network_check_live(&estimate));
+ tt_assert(circuit_build_times_network_check_live(&final));
circuit_build_times_count_close(&estimate, 0,
(time_t)(approx_time()-estimate.close_ms/1000.0-1));
circuit_build_times_count_close(&final, 0,
(time_t)(approx_time()-final.close_ms/1000.0-1));
- test_assert(!circuit_build_times_network_check_live(&estimate));
- test_assert(!circuit_build_times_network_check_live(&final));
+ tt_assert(!circuit_build_times_network_check_live(&estimate));
+ tt_assert(!circuit_build_times_network_check_live(&final));
log_info(LD_CIRC, "idx: %d %d, tot: %d %d",
build_times_idx, estimate.build_times_idx,
total_build_times, estimate.total_build_times);
/* Check rollback index. Should match top of loop. */
- test_assert(build_times_idx == estimate.build_times_idx);
+ tt_assert(build_times_idx == estimate.build_times_idx);
// This can fail if estimate.total_build_times == 1000, because
// in that case, rewind actually causes us to lose timeouts
if (total_build_times != CBT_NCIRCUITS_TO_OBSERVE)
- test_assert(total_build_times == estimate.total_build_times);
+ tt_assert(total_build_times == estimate.total_build_times);
/* Now simulate that the network has become live and we need
* a change */
@@ -599,12 +599,12 @@ test_circuit_timeout(void)
}
}
- test_assert(estimate.liveness.after_firsthop_idx == 0);
- test_assert(final.liveness.after_firsthop_idx ==
+ tt_assert(estimate.liveness.after_firsthop_idx == 0);
+ tt_assert(final.liveness.after_firsthop_idx ==
CBT_DEFAULT_MAX_RECENT_TIMEOUT_COUNT-1);
- test_assert(circuit_build_times_network_check_live(&estimate));
- test_assert(circuit_build_times_network_check_live(&final));
+ tt_assert(circuit_build_times_network_check_live(&estimate));
+ tt_assert(circuit_build_times_network_check_live(&final));
circuit_build_times_count_timeout(&final, 1);
}
@@ -618,7 +618,7 @@ test_circuit_timeout(void)
/** Test encoding and parsing of rendezvous service descriptors. */
static void
-test_rend_fns(void)
+test_rend_fns(void *arg)
{
rend_service_descriptor_t *generated = NULL, *parsed = NULL;
char service_id[DIGEST_LEN];
@@ -641,16 +641,17 @@ test_rend_fns(void)
char address6[] = "foo.bar.abcdefghijklmnop.onion";
char address7[] = ".abcdefghijklmnop.onion";
- test_assert(BAD_HOSTNAME == parse_extended_hostname(address1));
- test_assert(ONION_HOSTNAME == parse_extended_hostname(address2));
- test_streq(address2, "aaaaaaaaaaaaaaaa");
- test_assert(EXIT_HOSTNAME == parse_extended_hostname(address3));
- test_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4));
- test_assert(ONION_HOSTNAME == parse_extended_hostname(address5));
- test_streq(address5, "abcdefghijklmnop");
- test_assert(ONION_HOSTNAME == parse_extended_hostname(address6));
- test_streq(address6, "abcdefghijklmnop");
- test_assert(BAD_HOSTNAME == parse_extended_hostname(address7));
+ (void)arg;
+ tt_assert(BAD_HOSTNAME == parse_extended_hostname(address1));
+ tt_assert(ONION_HOSTNAME == parse_extended_hostname(address2));
+ tt_str_op(address2,==, "aaaaaaaaaaaaaaaa");
+ tt_assert(EXIT_HOSTNAME == parse_extended_hostname(address3));
+ tt_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4));
+ tt_assert(ONION_HOSTNAME == parse_extended_hostname(address5));
+ tt_str_op(address5,==, "abcdefghijklmnop");
+ tt_assert(ONION_HOSTNAME == parse_extended_hostname(address6));
+ tt_str_op(address6,==, "abcdefghijklmnop");
+ tt_assert(BAD_HOSTNAME == parse_extended_hostname(address7));
pk1 = pk_generate(0);
pk2 = pk_generate(1);
@@ -683,40 +684,41 @@ test_rend_fns(void)
intro->intro_key = crypto_pk_dup_key(pk2);
smartlist_add(generated->intro_nodes, intro);
}
- test_assert(rend_encode_v2_descriptors(descs, generated, now, 0,
+ tt_assert(rend_encode_v2_descriptors(descs, generated, now, 0,
REND_NO_AUTH, NULL, NULL) > 0);
- test_assert(rend_compute_v2_desc_id(computed_desc_id, service_id_base32,
+ tt_assert(rend_compute_v2_desc_id(computed_desc_id, service_id_base32,
NULL, now, 0) == 0);
- test_memeq(((rend_encoded_v2_service_descriptor_t *)
- smartlist_get(descs, 0))->desc_id, computed_desc_id, DIGEST_LEN);
- test_assert(rend_parse_v2_service_descriptor(&parsed, parsed_desc_id,
+ tt_mem_op(((rend_encoded_v2_service_descriptor_t *)
+ smartlist_get(descs, 0))->desc_id, ==,
+ computed_desc_id, DIGEST_LEN);
+ tt_assert(rend_parse_v2_service_descriptor(&parsed, parsed_desc_id,
&intro_points_encrypted,
&intro_points_size,
&encoded_size,
&next_desc,
((rend_encoded_v2_service_descriptor_t *)
smartlist_get(descs, 0))->desc_str) == 0);
- test_assert(parsed);
- test_memeq(((rend_encoded_v2_service_descriptor_t *)
- smartlist_get(descs, 0))->desc_id, parsed_desc_id, DIGEST_LEN);
- test_eq(rend_parse_introduction_points(parsed, intro_points_encrypted,
- intro_points_size), 3);
- test_assert(!crypto_pk_cmp_keys(generated->pk, parsed->pk));
- test_eq(parsed->timestamp, now);
- test_eq(parsed->version, 2);
- test_eq(parsed->protocols, 42);
- test_eq(smartlist_len(parsed->intro_nodes), 3);
+ tt_assert(parsed);
+ tt_mem_op(((rend_encoded_v2_service_descriptor_t *)
+ smartlist_get(descs, 0))->desc_id,==, parsed_desc_id, DIGEST_LEN);
+ tt_int_op(rend_parse_introduction_points(parsed, intro_points_encrypted,
+ intro_points_size),==, 3);
+ tt_assert(!crypto_pk_cmp_keys(generated->pk, parsed->pk));
+ tt_int_op(parsed->timestamp,==, now);
+ tt_int_op(parsed->version,==, 2);
+ tt_int_op(parsed->protocols,==, 42);
+ tt_int_op(smartlist_len(parsed->intro_nodes),==, 3);
for (i = 0; i < smartlist_len(parsed->intro_nodes); i++) {
rend_intro_point_t *par_intro = smartlist_get(parsed->intro_nodes, i),
*gen_intro = smartlist_get(generated->intro_nodes, i);
extend_info_t *par_info = par_intro->extend_info;
extend_info_t *gen_info = gen_intro->extend_info;
- test_assert(!crypto_pk_cmp_keys(gen_info->onion_key, par_info->onion_key));
- test_memeq(gen_info->identity_digest, par_info->identity_digest,
+ tt_assert(!crypto_pk_cmp_keys(gen_info->onion_key, par_info->onion_key));
+ tt_mem_op(gen_info->identity_digest,==, par_info->identity_digest,
DIGEST_LEN);
- test_streq(gen_info->nickname, par_info->nickname);
- test_assert(tor_addr_eq(&gen_info->addr, &par_info->addr));
- test_eq(gen_info->port, par_info->port);
+ tt_str_op(gen_info->nickname,==, par_info->nickname);
+ tt_assert(tor_addr_eq(&gen_info->addr, &par_info->addr));
+ tt_int_op(gen_info->port,==, par_info->port);
}
rend_service_descriptor_free(parsed);
@@ -760,17 +762,17 @@ test_rend_fns(void)
} while (0)
#define CHECK_COUNTRY(country, val) do { \
/* test ipv4 country lookup */ \
- test_streq(country, \
+ tt_str_op(country, ==, \
geoip_get_country_name(geoip_get_country_by_ipv4(val))); \
/* test ipv6 country lookup */ \
SET_TEST_IPV6(val); \
- test_streq(country, \
+ tt_str_op(country, ==, \
geoip_get_country_name(geoip_get_country_by_ipv6(&in6))); \
} while (0)
/** Run unit tests for GeoIP code. */
static void
-test_geoip(void)
+test_geoip(void *arg)
{
int i, j;
time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */
@@ -824,23 +826,24 @@ test_geoip(void)
/* Populate the DB a bit. Add these in order, since we can't do the final
* 'sort' step. These aren't very good IP addresses, but they're perfectly
* fine uint32_t values. */
- test_eq(0, geoip_parse_entry("10,50,AB", AF_INET));
- test_eq(0, geoip_parse_entry("52,90,XY", AF_INET));
- test_eq(0, geoip_parse_entry("95,100,AB", AF_INET));
- test_eq(0, geoip_parse_entry("\"105\",\"140\",\"ZZ\"", AF_INET));
- test_eq(0, geoip_parse_entry("\"150\",\"190\",\"XY\"", AF_INET));
- test_eq(0, geoip_parse_entry("\"200\",\"250\",\"AB\"", AF_INET));
+ (void)arg;
+ tt_int_op(0,==, geoip_parse_entry("10,50,AB", AF_INET));
+ tt_int_op(0,==, geoip_parse_entry("52,90,XY", AF_INET));
+ tt_int_op(0,==, geoip_parse_entry("95,100,AB", AF_INET));
+ tt_int_op(0,==, geoip_parse_entry("\"105\",\"140\",\"ZZ\"", AF_INET));
+ tt_int_op(0,==, geoip_parse_entry("\"150\",\"190\",\"XY\"", AF_INET));
+ tt_int_op(0,==, geoip_parse_entry("\"200\",\"250\",\"AB\"", AF_INET));
/* Populate the IPv6 DB equivalently with fake IPs in the same range */
- test_eq(0, geoip_parse_entry("::a,::32,AB", AF_INET6));
- test_eq(0, geoip_parse_entry("::34,::5a,XY", AF_INET6));
- test_eq(0, geoip_parse_entry("::5f,::64,AB", AF_INET6));
- test_eq(0, geoip_parse_entry("::69,::8c,ZZ", AF_INET6));
- test_eq(0, geoip_parse_entry("::96,::be,XY", AF_INET6));
- test_eq(0, geoip_parse_entry("::c8,::fa,AB", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::a,::32,AB", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::34,::5a,XY", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::5f,::64,AB", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::69,::8c,ZZ", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::96,::be,XY", AF_INET6));
+ tt_int_op(0,==, geoip_parse_entry("::c8,::fa,AB", AF_INET6));
/* We should have 4 countries: ??, ab, xy, zz. */
- test_eq(4, geoip_get_n_countries());
+ tt_int_op(4,==, geoip_get_n_countries());
memset(&in6, 0, sizeof(in6));
CHECK_COUNTRY("??", 3);
@@ -851,9 +854,9 @@ test_geoip(void)
CHECK_COUNTRY("xy", 190);
CHECK_COUNTRY("??", 2000);
- test_eq(0, geoip_get_country_by_ipv4(3));
+ tt_int_op(0,==, geoip_get_country_by_ipv4(3));
SET_TEST_IPV6(3);
- test_eq(0, geoip_get_country_by_ipv6(&in6));
+ tt_int_op(0,==, geoip_get_country_by_ipv6(&in6));
get_options_mutable()->BridgeRelay = 1;
get_options_mutable()->BridgeRecordUsageByCountry = 1;
@@ -876,41 +879,41 @@ test_geoip(void)
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
}
geoip_get_client_history(GEOIP_CLIENT_CONNECT, &s, &v);
- test_assert(s);
- test_assert(v);
- test_streq("zz=24,ab=16,xy=8", s);
- test_streq("v4=16,v6=16", v);
+ tt_assert(s);
+ tt_assert(v);
+ tt_str_op("zz=24,ab=16,xy=8",==, s);
+ tt_str_op("v4=16,v6=16",==, v);
tor_free(s);
tor_free(v);
/* Now clear out all the AB observations. */
geoip_remove_old_clients(now-6000);
geoip_get_client_history(GEOIP_CLIENT_CONNECT, &s, &v);
- test_assert(s);
- test_assert(v);
- test_streq("zz=24,xy=8", s);
- test_streq("v4=16,v6=16", v);
+ tt_assert(s);
+ tt_assert(v);
+ tt_str_op("zz=24,xy=8",==, s);
+ tt_str_op("v4=16,v6=16",==, v);
tor_free(s);
tor_free(v);
/* Start testing bridge statistics by making sure that we don't output
* bridge stats without initializing them. */
s = geoip_format_bridge_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats and generate the bridge-stats history string out of
* the connecting clients added above. */
geoip_bridge_stats_init(now);
s = geoip_format_bridge_stats(now + 86400);
- test_assert(s);
- test_streq(bridge_stats_1, s);
+ tt_assert(s);
+ tt_str_op(bridge_stats_1,==, s);
tor_free(s);
/* Stop collecting bridge stats and make sure we don't write a history
* string anymore. */
geoip_bridge_stats_term();
s = geoip_format_bridge_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Stop being a bridge and start being a directory mirror that gathers
* directory request statistics. */
@@ -924,7 +927,7 @@ test_geoip(void)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
s = geoip_format_dirreq_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats, note one connecting client, and generate the
* dirreq-stats history string. */
@@ -932,7 +935,7 @@ test_geoip(void)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
s = geoip_format_dirreq_stats(now + 86400);
- test_streq(dirreq_stats_1, s);
+ tt_str_op(dirreq_stats_1,==, s);
tor_free(s);
/* Stop collecting stats, add another connecting client, and ensure we
@@ -941,7 +944,7 @@ test_geoip(void)
SET_TEST_ADDRESS(101);
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
s = geoip_format_dirreq_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Re-start stats, add a connecting client, reset stats, and make sure
* that we get an all empty history string. */
@@ -950,20 +953,20 @@ test_geoip(void)
geoip_note_client_seen(GEOIP_CLIENT_NETWORKSTATUS, &addr, NULL, now);
geoip_reset_dirreq_stats(now);
s = geoip_format_dirreq_stats(now + 86400);
- test_streq(dirreq_stats_2, s);
+ tt_str_op(dirreq_stats_2,==, s);
tor_free(s);
/* Note a successful network status response and make sure that it
* appears in the history string. */
geoip_note_ns_response(GEOIP_SUCCESS);
s = geoip_format_dirreq_stats(now + 86400);
- test_streq(dirreq_stats_3, s);
+ tt_str_op(dirreq_stats_3,==, s);
tor_free(s);
/* Start a tunneled directory request. */
geoip_start_dirreq((uint64_t) 1, 1024, DIRREQ_TUNNELED);
s = geoip_format_dirreq_stats(now + 86400);
- test_streq(dirreq_stats_4, s);
+ tt_str_op(dirreq_stats_4,==, s);
tor_free(s);
/* Stop collecting directory request statistics and start gathering
@@ -977,7 +980,7 @@ test_geoip(void)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
s = geoip_format_entry_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats, note one connecting client, and generate the
* entry-stats history string. */
@@ -985,7 +988,7 @@ test_geoip(void)
SET_TEST_ADDRESS(100);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
s = geoip_format_entry_stats(now + 86400);
- test_streq(entry_stats_1, s);
+ tt_str_op(entry_stats_1,==, s);
tor_free(s);
/* Stop collecting stats, add another connecting client, and ensure we
@@ -994,7 +997,7 @@ test_geoip(void)
SET_TEST_ADDRESS(101);
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
s = geoip_format_entry_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Re-start stats, add a connecting client, reset stats, and make sure
* that we get an all empty history string. */
@@ -1003,7 +1006,7 @@ test_geoip(void)
geoip_note_client_seen(GEOIP_CLIENT_CONNECT, &addr, NULL, now);
geoip_reset_entry_stats(now);
s = geoip_format_entry_stats(now + 86400);
- test_streq(entry_stats_2, s);
+ tt_str_op(entry_stats_2,==, s);
tor_free(s);
/* Stop collecting entry statistics. */
@@ -1016,7 +1019,7 @@ test_geoip(void)
}
static void
-test_geoip_with_pt(void)
+test_geoip_with_pt(void *arg)
{
time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */
char *s = NULL;
@@ -1024,6 +1027,7 @@ test_geoip_with_pt(void)
tor_addr_t addr;
struct in6_addr in6;
+ (void)arg;
get_options_mutable()->BridgeRelay = 1;
get_options_mutable()->BridgeRecordUsageByCountry = 1;
@@ -1075,7 +1079,7 @@ test_geoip_with_pt(void)
/* Test the transport history string. */
s = geoip_get_transport_history();
tor_assert(s);
- test_streq(s, "<OR>=8,alpha=16,beta=8,charlie=16,ddr=136,"
+ tt_str_op(s,==, "<OR>=8,alpha=16,beta=8,charlie=16,ddr=136,"
"entropy=8,fire=8,google=8");
/* Stop collecting entry statistics. */
@@ -1092,7 +1096,7 @@ test_geoip_with_pt(void)
/** Run unit tests for stats code. */
static void
-test_stats(void)
+test_stats(void *arg)
{
time_t now = 1281533250; /* 2010-08-11 13:27:30 UTC */
char *s = NULL;
@@ -1100,10 +1104,11 @@ test_stats(void)
/* Start with testing exit port statistics; we shouldn't collect exit
* stats without initializing them. */
+ (void)arg;
rep_hist_note_exit_stream_opened(80);
rep_hist_note_exit_bytes(80, 100, 10000);
s = rep_hist_format_exit_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats, note some streams and bytes, and generate history
* string. */
@@ -1114,10 +1119,10 @@ test_stats(void)
rep_hist_note_exit_bytes(443, 100, 10000);
rep_hist_note_exit_bytes(443, 100, 10000);
s = rep_hist_format_exit_stats(now + 86400);
- test_streq("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"exit-kibibytes-written 80=1,443=1,other=0\n"
"exit-kibibytes-read 80=10,443=20,other=0\n"
- "exit-streams-opened 80=4,443=4,other=0\n", s);
+ "exit-streams-opened 80=4,443=4,other=0\n",==, s);
tor_free(s);
/* Add a few bytes on 10 more ports and ensure that only the top 10
@@ -1127,13 +1132,13 @@ test_stats(void)
rep_hist_note_exit_stream_opened(i);
}
s = rep_hist_format_exit_stats(now + 86400);
- test_streq("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"exit-kibibytes-written 52=1,53=1,54=1,55=1,56=1,57=1,58=1,"
"59=1,80=1,443=1,other=1\n"
"exit-kibibytes-read 52=1,53=1,54=1,55=1,56=1,57=1,58=1,"
"59=1,80=10,443=20,other=1\n"
"exit-streams-opened 52=4,53=4,54=4,55=4,56=4,57=4,58=4,"
- "59=4,80=4,443=4,other=4\n", s);
+ "59=4,80=4,443=4,other=4\n",==, s);
tor_free(s);
/* Stop collecting stats, add some bytes, and ensure we don't generate
@@ -1141,7 +1146,7 @@ test_stats(void)
rep_hist_exit_stats_term();
rep_hist_note_exit_bytes(80, 100, 10000);
s = rep_hist_format_exit_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Re-start stats, add some bytes, reset stats, and see what history we
* get when observing no streams or bytes at all. */
@@ -1150,17 +1155,17 @@ test_stats(void)
rep_hist_note_exit_bytes(80, 100, 10000);
rep_hist_reset_exit_stats(now);
s = rep_hist_format_exit_stats(now + 86400);
- test_streq("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("exit-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"exit-kibibytes-written other=0\n"
"exit-kibibytes-read other=0\n"
- "exit-streams-opened other=0\n", s);
+ "exit-streams-opened other=0\n",==, s);
tor_free(s);
/* Continue with testing connection statistics; we shouldn't collect
* conn stats without initializing them. */
rep_hist_note_or_conn_bytes(1, 20, 400, now);
s = rep_hist_format_conn_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats, note bytes, and generate history string. */
rep_hist_conn_stats_init(now);
@@ -1169,7 +1174,7 @@ test_stats(void)
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 10);
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
s = rep_hist_format_conn_stats(now + 86400);
- test_streq("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n", s);
+ tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,1,0\n",==, s);
tor_free(s);
/* Stop collecting stats, add some bytes, and ensure we don't generate
@@ -1177,7 +1182,7 @@ test_stats(void)
rep_hist_conn_stats_term();
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
s = rep_hist_format_conn_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Re-start stats, add some bytes, reset stats, and see what history we
* get when observing no bytes at all. */
@@ -1188,26 +1193,26 @@ test_stats(void)
rep_hist_note_or_conn_bytes(2, 400000, 30000, now + 15);
rep_hist_reset_conn_stats(now);
s = rep_hist_format_conn_stats(now + 86400);
- test_streq("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n", s);
+ tt_str_op("conn-bi-direct 2010-08-12 13:27:30 (86400 s) 0,0,0,0\n",==, s);
tor_free(s);
/* Continue with testing buffer statistics; we shouldn't collect buffer
* stats without initializing them. */
rep_hist_add_buffer_stats(2.0, 2.0, 20);
s = rep_hist_format_buffer_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Initialize stats, add statistics for a single circuit, and generate
* the history string. */
rep_hist_buffer_stats_init(now);
rep_hist_add_buffer_stats(2.0, 2.0, 20);
s = rep_hist_format_buffer_stats(now + 86400);
- test_streq("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"cell-processed-cells 20,0,0,0,0,0,0,0,0,0\n"
"cell-queued-cells 2.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"
"0.00,0.00\n"
"cell-time-in-queue 2,0,0,0,0,0,0,0,0,0\n"
- "cell-circuits-per-decile 1\n", s);
+ "cell-circuits-per-decile 1\n",==, s);
tor_free(s);
/* Add nineteen more circuit statistics to the one that's already in the
@@ -1217,12 +1222,12 @@ test_stats(void)
for (i = 20; i < 30; i++)
rep_hist_add_buffer_stats(3.5, 3.5, i);
s = rep_hist_format_buffer_stats(now + 86400);
- test_streq("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"cell-processed-cells 29,28,27,26,25,24,23,22,21,20\n"
"cell-queued-cells 2.75,2.75,2.75,2.75,2.75,2.75,2.75,2.75,"
"2.75,2.75\n"
"cell-time-in-queue 3,3,3,3,3,3,3,3,3,3\n"
- "cell-circuits-per-decile 2\n", s);
+ "cell-circuits-per-decile 2\n",==, s);
tor_free(s);
/* Stop collecting stats, add statistics for one circuit, and ensure we
@@ -1230,7 +1235,7 @@ test_stats(void)
rep_hist_buffer_stats_term();
rep_hist_add_buffer_stats(2.0, 2.0, 20);
s = rep_hist_format_buffer_stats(now + 86400);
- test_assert(!s);
+ tt_assert(!s);
/* Re-start stats, add statistics for one circuit, reset stats, and make
* sure that the history has all zeros. */
@@ -1238,54 +1243,27 @@ test_stats(void)
rep_hist_add_buffer_stats(2.0, 2.0, 20);
rep_hist_reset_buffer_stats(now);
s = rep_hist_format_buffer_stats(now + 86400);
- test_streq("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
+ tt_str_op("cell-stats-end 2010-08-12 13:27:30 (86400 s)\n"
"cell-processed-cells 0,0,0,0,0,0,0,0,0,0\n"
"cell-queued-cells 0.00,0.00,0.00,0.00,0.00,0.00,0.00,0.00,"
"0.00,0.00\n"
"cell-time-in-queue 0,0,0,0,0,0,0,0,0,0\n"
- "cell-circuits-per-decile 0\n", s);
+ "cell-circuits-per-decile 0\n",==, s);
done:
tor_free(s);
}
-static void *
-legacy_test_setup(const struct testcase_t *testcase)
-{
- return testcase->setup_data;
-}
-
-void
-legacy_test_helper(void *data)
-{
- void (*fn)(void) = data;
- fn();
-}
-
-static int
-legacy_test_cleanup(const struct testcase_t *testcase, void *ptr)
-{
- (void)ptr;
- (void)testcase;
- return 1;
-}
-
-const struct testcase_setup_t legacy_setup = {
- legacy_test_setup, legacy_test_cleanup
-};
-
#define ENT(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_ ## name }
+ { #name, test_ ## name , 0, NULL, NULL }
#define FORK(name) \
- { #name, legacy_test_helper, TT_FORK, &legacy_setup, test_ ## name }
+ { #name, test_ ## name , TT_FORK, NULL, NULL }
static struct testcase_t test_array[] = {
ENT(onion_handshake),
{ "bad_onion_handshake", test_bad_onion_handshake, 0, NULL, NULL },
ENT(onion_queues),
-#ifdef CURVE25519_ENABLED
{ "ntor_handshake", test_ntor_handshake, 0, NULL, NULL },
-#endif
ENT(circuit_timeout),
ENT(rend_fns),
ENT(geoip),
@@ -1321,8 +1299,10 @@ extern struct testcase_t hs_tests[];
extern struct testcase_t nodelist_tests[];
extern struct testcase_t routerkeys_tests[];
extern struct testcase_t oom_tests[];
+extern struct testcase_t accounting_tests[];
extern struct testcase_t policy_tests[];
extern struct testcase_t status_tests[];
+extern struct testcase_t routerset_tests[];
static struct testgroup_t testgroups[] = {
{ "", test_array },
@@ -1352,8 +1332,10 @@ static struct testgroup_t testgroups[] = {
{ "nodelist/", nodelist_tests },
{ "routerkeys/", routerkeys_tests },
{ "oom/", oom_tests },
+ { "accounting/", accounting_tests },
{ "policy/" , policy_tests },
{ "status/" , status_tests },
+ { "routerset/" , routerset_tests },
END_OF_GROUPS
};
@@ -1378,7 +1360,8 @@ main(int c, const char **v)
update_approx_time(time(NULL));
options = options_new();
tor_threads_init();
- init_logging();
+ init_logging(1);
+ configure_backtrace_handler(get_version());
for (i_out = i = 1; i < c; ++i) {
if (!strcmp(v[i], "--warn")) {
diff --git a/src/test/test.h b/src/test/test.h
index 861ce5ac3e..db07e4b706 100644
--- a/src/test/test.h
+++ b/src/test/test.h
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2003, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#ifndef TOR_TEST_H
@@ -22,25 +22,6 @@
#define PRETTY_FUNCTION ""
#endif
-#define test_fail_msg(msg) TT_DIE((msg))
-
-#define test_fail() test_fail_msg("Assertion failed.")
-
-#define test_assert(expr) tt_assert(expr)
-
-#define test_eq(expr1, expr2) tt_int_op((expr1), ==, (expr2))
-#define test_eq_ptr(expr1, expr2) tt_ptr_op((expr1), ==, (expr2))
-#define test_neq(expr1, expr2) tt_int_op((expr1), !=, (expr2))
-#define test_neq_ptr(expr1, expr2) tt_ptr_op((expr1), !=, (expr2))
-#define test_streq(expr1, expr2) tt_str_op((expr1), ==, (expr2))
-#define test_strneq(expr1, expr2) tt_str_op((expr1), !=, (expr2))
-
-#define test_mem_op(expr1, op, expr2, len) \
- tt_mem_op((expr1), op, (expr2), (len))
-
-#define test_memeq(expr1, expr2, len) test_mem_op((expr1), ==, (expr2), len)
-#define test_memneq(expr1, expr2, len) test_mem_op((expr1), !=, (expr2), len)
-
/* As test_mem_op, but decodes 'hex' before comparing. There must be a
* local char* variable called mem_op_hex_tmp for this to work. */
#define test_mem_op_hex(expr1, op, hex) \
@@ -50,7 +31,7 @@
mem_op_hex_tmp = tor_malloc(length/2); \
tor_assert((length&1)==0); \
base16_decode(mem_op_hex_tmp, length/2, hex, length); \
- test_mem_op(expr1, op, mem_op_hex_tmp, length/2); \
+ tt_mem_op(expr1, op, mem_op_hex_tmp, length/2); \
STMT_END
#define test_memeq_hex(expr1, hex) test_mem_op_hex(expr1, ==, hex)
@@ -61,7 +42,7 @@
#ifdef _MSC_VER
#define U64_PRINTF_TYPE uint64_t
-#define U64_PRINTF_TYPE int64_t
+#define I64_PRINTF_TYPE int64_t
#else
#define U64_PRINTF_TYPE unsigned long long
#define I64_PRINTF_TYPE long long
@@ -85,9 +66,6 @@
const char *get_fname(const char *name);
crypto_pk_t *pk_generate(int idx);
-void legacy_test_helper(void *data);
-extern const struct testcase_setup_t legacy_setup;
-
#define US2_CONCAT_2__(a, b) a ## __ ## b
#define US_CONCAT_2__(a, b) a ## _ ## b
#define US_CONCAT_3__(a, b, c) a ## _ ## b ## _ ## c
diff --git a/src/test/test_accounting.c b/src/test/test_accounting.c
new file mode 100644
index 0000000000..25908e942c
--- /dev/null
+++ b/src/test/test_accounting.c
@@ -0,0 +1,76 @@
+#include "or.h"
+#include "test.h"
+#define HIBERNATE_PRIVATE
+#include "hibernate.h"
+#include "config.h"
+#define STATEFILE_PRIVATE
+#include "statefile.h"
+
+#define NS_MODULE accounting
+
+#define NS_SUBMODULE limits
+
+/*
+ * Test to make sure accounting triggers hibernation
+ * correctly with both sum or max rules set
+ */
+
+static or_state_t *or_state;
+NS_DECL(or_state_t *, get_or_state, (void));
+static or_state_t *
+NS(get_or_state)(void)
+{
+ return or_state;
+}
+
+static void
+test_accounting_limits(void *arg)
+{
+ or_options_t *options = get_options_mutable();
+ time_t fake_time = time(NULL);
+ (void) arg;
+
+ NS_MOCK(get_or_state);
+ or_state = or_state_new();
+
+ options->AccountingMax = 100;
+ options->AccountingRule = ACCT_MAX;
+
+ tor_assert(accounting_is_enabled(options));
+ configure_accounting(fake_time);
+
+ accounting_add_bytes(10, 0, 1);
+ fake_time += 1;
+ consider_hibernation(fake_time);
+ tor_assert(we_are_hibernating() == 0);
+
+ accounting_add_bytes(90, 0, 1);
+ fake_time += 1;
+ consider_hibernation(fake_time);
+ tor_assert(we_are_hibernating() == 1);
+
+ options->AccountingMax = 200;
+ options->AccountingRule = ACCT_SUM;
+
+ accounting_add_bytes(0, 10, 1);
+ fake_time += 1;
+ consider_hibernation(fake_time);
+ tor_assert(we_are_hibernating() == 0);
+
+ accounting_add_bytes(0, 90, 1);
+ fake_time += 1;
+ consider_hibernation(fake_time);
+ tor_assert(we_are_hibernating() == 1);
+ goto done;
+ done:
+ NS_UNMOCK(get_or_state);
+ or_state_free(or_state);
+}
+
+#undef NS_SUBMODULE
+
+struct testcase_t accounting_tests[] = {
+ { "bwlimits", test_accounting_limits, TT_FORK, NULL, NULL },
+ END_OF_TESTCASES
+};
+
diff --git a/src/test/test_addr.c b/src/test/test_addr.c
index 50011e606b..e9fe3038b8 100644
--- a/src/test/test_addr.c
+++ b/src/test/test_addr.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define ADDRESSMAP_PRIVATE
@@ -10,49 +10,50 @@
#include "addressmap.h"
static void
-test_addr_basic(void)
+test_addr_basic(void *arg)
{
uint32_t u32;
uint16_t u16;
char *cp;
/* Test addr_port_lookup */
+ (void)arg;
cp = NULL; u32 = 3; u16 = 3;
- test_assert(!addr_port_lookup(LOG_WARN, "1.2.3.4", &cp, &u32, &u16));
- test_streq(cp, "1.2.3.4");
- test_eq(u32, 0x01020304u);
- test_eq(u16, 0);
+ tt_assert(!addr_port_lookup(LOG_WARN, "1.2.3.4", &cp, &u32, &u16));
+ tt_str_op(cp,==, "1.2.3.4");
+ tt_int_op(u32,==, 0x01020304u);
+ tt_int_op(u16,==, 0);
tor_free(cp);
- test_assert(!addr_port_lookup(LOG_WARN, "4.3.2.1:99", &cp, &u32, &u16));
- test_streq(cp, "4.3.2.1");
- test_eq(u32, 0x04030201u);
- test_eq(u16, 99);
+ tt_assert(!addr_port_lookup(LOG_WARN, "4.3.2.1:99", &cp, &u32, &u16));
+ tt_str_op(cp,==, "4.3.2.1");
+ tt_int_op(u32,==, 0x04030201u);
+ tt_int_op(u16,==, 99);
tor_free(cp);
- test_assert(!addr_port_lookup(LOG_WARN, "nonexistent.address:4040",
+ tt_assert(!addr_port_lookup(LOG_WARN, "nonexistent.address:4040",
&cp, NULL, &u16));
- test_streq(cp, "nonexistent.address");
- test_eq(u16, 4040);
+ tt_str_op(cp,==, "nonexistent.address");
+ tt_int_op(u16,==, 4040);
tor_free(cp);
- test_assert(!addr_port_lookup(LOG_WARN, "localhost:9999", &cp, &u32, &u16));
- test_streq(cp, "localhost");
- test_eq(u32, 0x7f000001u);
- test_eq(u16, 9999);
+ tt_assert(!addr_port_lookup(LOG_WARN, "localhost:9999", &cp, &u32, &u16));
+ tt_str_op(cp,==, "localhost");
+ tt_int_op(u32,==, 0x7f000001u);
+ tt_int_op(u16,==, 9999);
tor_free(cp);
u32 = 3;
- test_assert(!addr_port_lookup(LOG_WARN, "localhost", NULL, &u32, &u16));
- test_eq_ptr(cp, NULL);
- test_eq(u32, 0x7f000001u);
- test_eq(u16, 0);
+ tt_assert(!addr_port_lookup(LOG_WARN, "localhost", NULL, &u32, &u16));
+ tt_ptr_op(cp,==, NULL);
+ tt_int_op(u32,==, 0x7f000001u);
+ tt_int_op(u16,==, 0);
tor_free(cp);
- test_assert(addr_port_lookup(LOG_WARN, "localhost:3", &cp, &u32, NULL));
+ tt_assert(addr_port_lookup(LOG_WARN, "localhost:3", &cp, &u32, NULL));
tor_free(cp);
- test_eq(0, addr_mask_get_bits(0x0u));
- test_eq(32, addr_mask_get_bits(0xFFFFFFFFu));
- test_eq(16, addr_mask_get_bits(0xFFFF0000u));
- test_eq(31, addr_mask_get_bits(0xFFFFFFFEu));
- test_eq(1, addr_mask_get_bits(0x80000000u));
+ tt_int_op(0,==, addr_mask_get_bits(0x0u));
+ tt_int_op(32,==, addr_mask_get_bits(0xFFFFFFFFu));
+ tt_int_op(16,==, addr_mask_get_bits(0xFFFF0000u));
+ tt_int_op(31,==, addr_mask_get_bits(0xFFFFFFFEu));
+ tt_int_op(1,==, addr_mask_get_bits(0x80000000u));
/* Test inet_ntop */
{
@@ -61,15 +62,15 @@ test_addr_basic(void)
struct in_addr in;
/* good round trip */
- test_eq(tor_inet_pton(AF_INET, ip, &in), 1);
- test_eq_ptr(tor_inet_ntop(AF_INET, &in, tmpbuf, sizeof(tmpbuf)), &tmpbuf);
- test_streq(tmpbuf, ip);
+ tt_int_op(tor_inet_pton(AF_INET, ip, &in),==, 1);
+ tt_ptr_op(tor_inet_ntop(AF_INET, &in, tmpbuf, sizeof(tmpbuf)),==, &tmpbuf);
+ tt_str_op(tmpbuf,==, ip);
/* just enough buffer length */
- test_streq(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip) + 1), ip);
+ tt_str_op(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip) + 1),==, ip);
/* too short buffer */
- test_eq_ptr(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip)), NULL);
+ tt_ptr_op(tor_inet_ntop(AF_INET, &in, tmpbuf, strlen(ip)),==, NULL);
}
done:
@@ -96,67 +97,68 @@ test_addr_basic(void)
/** Helper: Assert that two strings both decode as IPv6 addresses with
* tor_inet_pton(), and both decode to the same address. */
-#define test_pton6_same(a,b) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \
- test_eq(tor_inet_pton(AF_INET6, b, &a2), 1); \
- test_op_ip6_(&a1,==,&a2,#a,#b); \
+#define test_pton6_same(a,b) STMT_BEGIN \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &a1), ==, 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, b, &a2), ==, 1); \
+ test_op_ip6_(&a1,==,&a2,#a,#b); \
STMT_END
/** Helper: Assert that <b>a</b> is recognized as a bad IPv6 address by
* tor_inet_pton(). */
#define test_pton6_bad(a) \
- test_eq(0, tor_inet_pton(AF_INET6, a, &a1))
+ tt_int_op(0, ==, tor_inet_pton(AF_INET6, a, &a1))
/** Helper: assert that <b>a</b>, when parsed by tor_inet_pton() and displayed
* with tor_inet_ntop(), yields <b>b</b>. Also assert that <b>b</b> parses to
* the same value as <b>a</b>. */
-#define test_ntop6_reduces(a,b) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &a1), 1); \
- test_streq(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf)), b); \
- test_eq(tor_inet_pton(AF_INET6, b, &a2), 1); \
- test_op_ip6_(&a1, ==, &a2, a, b); \
+#define test_ntop6_reduces(a,b) STMT_BEGIN \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &a1), ==, 1); \
+ tt_str_op(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf)), ==, b); \
+ tt_int_op(tor_inet_pton(AF_INET6, b, &a2), ==, 1); \
+ test_op_ip6_(&a1, ==, &a2, a, b); \
STMT_END
/** Helper: assert that <b>a</b> parses by tor_inet_pton() into a address that
* passes tor_addr_is_internal() with <b>for_listening</b>. */
#define test_internal_ip(a,for_listening) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), ==, 1); \
t1.family = AF_INET6; \
if (!tor_addr_is_internal(&t1, for_listening)) \
- test_fail_msg( a "was not internal."); \
+ TT_DIE(("%s was not internal", a)); \
STMT_END
/** Helper: assert that <b>a</b> parses by tor_inet_pton() into a address that
* does not pass tor_addr_is_internal() with <b>for_listening</b>. */
#define test_external_ip(a,for_listening) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), ==, 1); \
t1.family = AF_INET6; \
if (tor_addr_is_internal(&t1, for_listening)) \
- test_fail_msg(a "was not external."); \
+ TT_DIE(("%s was not internal", a)); \
STMT_END
/** Helper: Assert that <b>a</b> and <b>b</b>, when parsed by
* tor_inet_pton(), give addresses that compare in the order defined by
* <b>op</b> with tor_addr_compare(). */
#define test_addr_compare(a, op, b) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
- test_eq(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), ==, 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), ==, 1); \
t1.family = t2.family = AF_INET6; \
r = tor_addr_compare(&t1,&t2,CMP_SEMANTIC); \
if (!(r op 0)) \
- test_fail_msg("failed: tor_addr_compare("a","b") "#op" 0"); \
+ TT_DIE(("Failed: tor_addr_compare(%s,%s) %s 0", a, b, #op));\
STMT_END
/** Helper: Assert that <b>a</b> and <b>b</b>, when parsed by
* tor_inet_pton(), give addresses that compare in the order defined by
* <b>op</b> with tor_addr_compare_masked() with <b>m</b> masked. */
#define test_addr_compare_masked(a, op, b, m) STMT_BEGIN \
- test_eq(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), 1); \
- test_eq(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, a, &t1.addr.in6_addr), ==, 1); \
+ tt_int_op(tor_inet_pton(AF_INET6, b, &t2.addr.in6_addr), ==, 1); \
t1.family = t2.family = AF_INET6; \
r = tor_addr_compare_masked(&t1,&t2,m,CMP_SEMANTIC); \
if (!(r op 0)) \
- test_fail_msg("failed: tor_addr_compare_masked("a","b","#m") "#op" 0"); \
+ TT_DIE(("Failed: tor_addr_compare_masked(%s,%s,%d) %s 0", \
+ a, b, m, #op)); \
STMT_END
/** Helper: assert that <b>xx</b> is parseable as a masked IPv6 address with
@@ -165,21 +167,21 @@ test_addr_basic(void)
* as <b>pt1..pt2</b>. */
#define test_addr_mask_ports_parse(xx, f, ip1, ip2, ip3, ip4, mm, pt1, pt2) \
STMT_BEGIN \
- test_eq(tor_addr_parse_mask_ports(xx, 0, &t1, &mask, &port1, &port2), \
- f); \
+ tt_int_op(tor_addr_parse_mask_ports(xx, 0, &t1, &mask, &port1, &port2), \
+ ==, f); \
p1=tor_inet_ntop(AF_INET6, &t1.addr.in6_addr, bug, sizeof(bug)); \
- test_eq(htonl(ip1), tor_addr_to_in6_addr32(&t1)[0]); \
- test_eq(htonl(ip2), tor_addr_to_in6_addr32(&t1)[1]); \
- test_eq(htonl(ip3), tor_addr_to_in6_addr32(&t1)[2]); \
- test_eq(htonl(ip4), tor_addr_to_in6_addr32(&t1)[3]); \
- test_eq(mask, mm); \
- test_eq(port1, pt1); \
- test_eq(port2, pt2); \
+ tt_int_op(htonl(ip1), ==, tor_addr_to_in6_addr32(&t1)[0]); \
+ tt_int_op(htonl(ip2), ==, tor_addr_to_in6_addr32(&t1)[1]); \
+ tt_int_op(htonl(ip3), ==, tor_addr_to_in6_addr32(&t1)[2]); \
+ tt_int_op(htonl(ip4), ==, tor_addr_to_in6_addr32(&t1)[3]); \
+ tt_int_op(mask, ==, mm); \
+ tt_uint_op(port1, ==, pt1); \
+ tt_uint_op(port2, ==, pt2); \
STMT_END
/** Run unit tests for IPv6 encoding/decoding/manipulation functions. */
static void
-test_addr_ip6_helpers(void)
+test_addr_ip6_helpers(void *arg)
{
char buf[TOR_ADDR_BUF_LEN], bug[TOR_ADDR_BUF_LEN];
char rbuf[REVERSE_LOOKUP_NAME_BUF_LEN];
@@ -194,28 +196,29 @@ test_addr_ip6_helpers(void)
struct sockaddr_in6 *sin6;
/* Test tor_inet_ntop and tor_inet_pton: IPv6 */
+ (void)arg;
{
const char *ip = "2001::1234";
const char *ip_ffff = "::ffff:192.168.1.2";
/* good round trip */
- test_eq(tor_inet_pton(AF_INET6, ip, &a1), 1);
- test_eq_ptr(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf)), &buf);
- test_streq(buf, ip);
+ tt_int_op(tor_inet_pton(AF_INET6, ip, &a1),==, 1);
+ tt_ptr_op(tor_inet_ntop(AF_INET6, &a1, buf, sizeof(buf)),==, &buf);
+ tt_str_op(buf,==, ip);
/* good round trip - ::ffff:0:0 style */
- test_eq(tor_inet_pton(AF_INET6, ip_ffff, &a2), 1);
- test_eq_ptr(tor_inet_ntop(AF_INET6, &a2, buf, sizeof(buf)), &buf);
- test_streq(buf, ip_ffff);
+ tt_int_op(tor_inet_pton(AF_INET6, ip_ffff, &a2),==, 1);
+ tt_ptr_op(tor_inet_ntop(AF_INET6, &a2, buf, sizeof(buf)),==, &buf);
+ tt_str_op(buf,==, ip_ffff);
/* just long enough buffer (remember \0) */
- test_streq(tor_inet_ntop(AF_INET6, &a1, buf, strlen(ip)+1), ip);
- test_streq(tor_inet_ntop(AF_INET6, &a2, buf, strlen(ip_ffff)+1),
+ tt_str_op(tor_inet_ntop(AF_INET6, &a1, buf, strlen(ip)+1),==, ip);
+ tt_str_op(tor_inet_ntop(AF_INET6, &a2, buf, strlen(ip_ffff)+1),==,
ip_ffff);
/* too short buffer (remember \0) */
- test_eq_ptr(tor_inet_ntop(AF_INET6, &a1, buf, strlen(ip)), NULL);
- test_eq_ptr(tor_inet_ntop(AF_INET6, &a2, buf, strlen(ip_ffff)), NULL);
+ tt_ptr_op(tor_inet_ntop(AF_INET6, &a1, buf, strlen(ip)),==, NULL);
+ tt_ptr_op(tor_inet_ntop(AF_INET6, &a2, buf, strlen(ip_ffff)),==, NULL);
}
/* ==== Converting to and from sockaddr_t. */
@@ -224,16 +227,16 @@ test_addr_ip6_helpers(void)
sin->sin_port = htons(9090);
sin->sin_addr.s_addr = htonl(0x7f7f0102); /*127.127.1.2*/
tor_addr_from_sockaddr(&t1, (struct sockaddr *)sin, &port1);
- test_eq(tor_addr_family(&t1), AF_INET);
- test_eq(tor_addr_to_ipv4h(&t1), 0x7f7f0102);
+ tt_int_op(tor_addr_family(&t1),==, AF_INET);
+ tt_int_op(tor_addr_to_ipv4h(&t1),==, 0x7f7f0102);
tt_int_op(port1, ==, 9090);
memset(&sa_storage, 0, sizeof(sa_storage));
- test_eq(sizeof(struct sockaddr_in),
+ tt_int_op(sizeof(struct sockaddr_in),==,
tor_addr_to_sockaddr(&t1, 1234, (struct sockaddr *)&sa_storage,
sizeof(sa_storage)));
- test_eq(1234, ntohs(sin->sin_port));
- test_eq(0x7f7f0102, ntohl(sin->sin_addr.s_addr));
+ tt_int_op(1234,==, ntohs(sin->sin_port));
+ tt_int_op(0x7f7f0102,==, ntohl(sin->sin_addr.s_addr));
memset(&sa_storage, 0, sizeof(sa_storage));
sin6 = (struct sockaddr_in6 *)&sa_storage;
@@ -241,37 +244,37 @@ test_addr_ip6_helpers(void)
sin6->sin6_port = htons(7070);
sin6->sin6_addr.s6_addr[0] = 128;
tor_addr_from_sockaddr(&t1, (struct sockaddr *)sin6, &port1);
- test_eq(tor_addr_family(&t1), AF_INET6);
+ tt_int_op(tor_addr_family(&t1),==, AF_INET6);
tt_int_op(port1, ==, 7070);
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 0);
- test_streq(p1, "8000::");
+ tt_str_op(p1,==, "8000::");
memset(&sa_storage, 0, sizeof(sa_storage));
- test_eq(sizeof(struct sockaddr_in6),
+ tt_int_op(sizeof(struct sockaddr_in6),==,
tor_addr_to_sockaddr(&t1, 9999, (struct sockaddr *)&sa_storage,
sizeof(sa_storage)));
- test_eq(AF_INET6, sin6->sin6_family);
- test_eq(9999, ntohs(sin6->sin6_port));
- test_eq(0x80000000, ntohl(S6_ADDR32(sin6->sin6_addr)[0]));
+ tt_int_op(AF_INET6,==, sin6->sin6_family);
+ tt_int_op(9999,==, ntohs(sin6->sin6_port));
+ tt_int_op(0x80000000,==, ntohl(S6_ADDR32(sin6->sin6_addr)[0]));
/* ==== tor_addr_lookup: static cases. (Can't test dns without knowing we
* have a good resolver. */
- test_eq(0, tor_addr_lookup("127.128.129.130", AF_UNSPEC, &t1));
- test_eq(AF_INET, tor_addr_family(&t1));
- test_eq(tor_addr_to_ipv4h(&t1), 0x7f808182);
+ tt_int_op(0,==, tor_addr_lookup("127.128.129.130", AF_UNSPEC, &t1));
+ tt_int_op(AF_INET,==, tor_addr_family(&t1));
+ tt_int_op(tor_addr_to_ipv4h(&t1),==, 0x7f808182);
- test_eq(0, tor_addr_lookup("9000::5", AF_UNSPEC, &t1));
- test_eq(AF_INET6, tor_addr_family(&t1));
- test_eq(0x90, tor_addr_to_in6_addr8(&t1)[0]);
- test_assert(tor_mem_is_zero((char*)tor_addr_to_in6_addr8(&t1)+1, 14));
- test_eq(0x05, tor_addr_to_in6_addr8(&t1)[15]);
+ tt_int_op(0,==, tor_addr_lookup("9000::5", AF_UNSPEC, &t1));
+ tt_int_op(AF_INET6,==, tor_addr_family(&t1));
+ tt_int_op(0x90,==, tor_addr_to_in6_addr8(&t1)[0]);
+ tt_assert(tor_mem_is_zero((char*)tor_addr_to_in6_addr8(&t1)+1, 14));
+ tt_int_op(0x05,==, tor_addr_to_in6_addr8(&t1)[15]);
/* === Test pton: valid af_inet6 */
/* Simple, valid parsing. */
r = tor_inet_pton(AF_INET6,
"0102:0304:0506:0708:090A:0B0C:0D0E:0F10", &a1);
- test_assert(r==1);
- for (i=0;i<16;++i) { test_eq(i+1, (int)a1.s6_addr[i]); }
+ tt_int_op(r, ==, 1);
+ for (i=0;i<16;++i) { tt_int_op(i+1,==, (int)a1.s6_addr[i]); }
/* ipv4 ending. */
test_pton6_same("0102:0304:0506:0708:090A:0B0C:0D0E:0F10",
"0102:0304:0506:0708:090A:0B0C:13.14.15.16");
@@ -311,7 +314,7 @@ test_addr_ip6_helpers(void)
"1000:1:0:7::");
/* Bad af param */
- test_eq(tor_inet_pton(AF_UNSPEC, 0, 0), -1);
+ tt_int_op(tor_inet_pton(AF_UNSPEC, 0, 0),==, -1);
/* === Test pton: invalid in6. */
test_pton6_bad("foobar.");
@@ -414,10 +417,10 @@ test_addr_ip6_helpers(void)
test_addr_compare("0::ffff:5.2.2.1", <, "::ffff:6.0.0.0"); /* XXXX wrong. */
tor_addr_parse_mask_ports("[::ffff:2.3.4.5]", 0, &t1, NULL, NULL, NULL);
tor_addr_parse_mask_ports("2.3.4.5", 0, &t2, NULL, NULL, NULL);
- test_assert(tor_addr_compare(&t1, &t2, CMP_SEMANTIC) == 0);
+ tt_assert(tor_addr_compare(&t1, &t2, CMP_SEMANTIC) == 0);
tor_addr_parse_mask_ports("[::ffff:2.3.4.4]", 0, &t1, NULL, NULL, NULL);
tor_addr_parse_mask_ports("2.3.4.5", 0, &t2, NULL, NULL, NULL);
- test_assert(tor_addr_compare(&t1, &t2, CMP_SEMANTIC) < 0);
+ tt_assert(tor_addr_compare(&t1, &t2, CMP_SEMANTIC) < 0);
/* test compare_masked */
test_addr_compare_masked("ffff::", ==, "ffff::0", 128);
@@ -426,113 +429,113 @@ test_addr_ip6_helpers(void)
test_addr_compare_masked("0::2:2:1", ==, "0::8000:2:1", 80);
/* Test undecorated tor_addr_to_str */
- test_eq(AF_INET6, tor_addr_parse(&t1, "[123:45:6789::5005:11]"));
+ tt_int_op(AF_INET6,==, tor_addr_parse(&t1, "[123:45:6789::5005:11]"));
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 0);
- test_streq(p1, "123:45:6789::5005:11");
- test_eq(AF_INET, tor_addr_parse(&t1, "18.0.0.1"));
+ tt_str_op(p1,==, "123:45:6789::5005:11");
+ tt_int_op(AF_INET,==, tor_addr_parse(&t1, "18.0.0.1"));
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 0);
- test_streq(p1, "18.0.0.1");
+ tt_str_op(p1,==, "18.0.0.1");
/* Test decorated tor_addr_to_str */
- test_eq(AF_INET6, tor_addr_parse(&t1, "[123:45:6789::5005:11]"));
+ tt_int_op(AF_INET6,==, tor_addr_parse(&t1, "[123:45:6789::5005:11]"));
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 1);
- test_streq(p1, "[123:45:6789::5005:11]");
- test_eq(AF_INET, tor_addr_parse(&t1, "18.0.0.1"));
+ tt_str_op(p1,==, "[123:45:6789::5005:11]");
+ tt_int_op(AF_INET,==, tor_addr_parse(&t1, "18.0.0.1"));
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 1);
- test_streq(p1, "18.0.0.1");
+ tt_str_op(p1,==, "18.0.0.1");
/* Test buffer bounds checking of tor_addr_to_str */
- test_eq(AF_INET6, tor_addr_parse(&t1, "::")); /* 2 + \0 */
- test_eq_ptr(tor_addr_to_str(buf, &t1, 2, 0), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 3, 0), "::");
- test_eq_ptr(tor_addr_to_str(buf, &t1, 4, 1), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 5, 1), "[::]");
-
- test_eq(AF_INET6, tor_addr_parse(&t1, "2000::1337")); /* 10 + \0 */
- test_eq_ptr(tor_addr_to_str(buf, &t1, 10, 0), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 11, 0), "2000::1337");
- test_eq_ptr(tor_addr_to_str(buf, &t1, 12, 1), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 13, 1), "[2000::1337]");
-
- test_eq(AF_INET, tor_addr_parse(&t1, "1.2.3.4")); /* 7 + \0 */
- test_eq_ptr(tor_addr_to_str(buf, &t1, 7, 0), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 8, 0), "1.2.3.4");
-
- test_eq(AF_INET, tor_addr_parse(&t1, "255.255.255.255")); /* 15 + \0 */
- test_eq_ptr(tor_addr_to_str(buf, &t1, 15, 0), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 16, 0), "255.255.255.255");
- test_eq_ptr(tor_addr_to_str(buf, &t1, 15, 1), NULL); /* too short buf */
- test_streq(tor_addr_to_str(buf, &t1, 16, 1), "255.255.255.255");
+ tt_int_op(AF_INET6,==, tor_addr_parse(&t1, "::")); /* 2 + \0 */
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 2, 0),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 3, 0),==, "::");
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 4, 1),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 5, 1),==, "[::]");
+
+ tt_int_op(AF_INET6,==, tor_addr_parse(&t1, "2000::1337")); /* 10 + \0 */
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 10, 0),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 11, 0),==, "2000::1337");
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 12, 1),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 13, 1),==, "[2000::1337]");
+
+ tt_int_op(AF_INET,==, tor_addr_parse(&t1, "1.2.3.4")); /* 7 + \0 */
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 7, 0),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 8, 0),==, "1.2.3.4");
+
+ tt_int_op(AF_INET,==, tor_addr_parse(&t1, "255.255.255.255")); /* 15 + \0 */
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 15, 0),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 16, 0),==, "255.255.255.255");
+ tt_ptr_op(tor_addr_to_str(buf, &t1, 15, 1),==, NULL); /* too short buf */
+ tt_str_op(tor_addr_to_str(buf, &t1, 16, 1),==, "255.255.255.255");
t1.family = AF_UNSPEC;
- test_eq_ptr(tor_addr_to_str(buf, &t1, sizeof(buf), 0), NULL);
+ tt_ptr_op(tor_addr_to_str(buf, &t1, sizeof(buf), 0),==, NULL);
/* Test tor_addr_parse_PTR_name */
i = tor_addr_parse_PTR_name(&t1, "Foobar.baz", AF_UNSPEC, 0);
- test_eq(0, i);
+ tt_int_op(0,==, i);
i = tor_addr_parse_PTR_name(&t1, "Foobar.baz", AF_UNSPEC, 1);
- test_eq(0, i);
+ tt_int_op(0,==, i);
i = tor_addr_parse_PTR_name(&t1, "9999999999999999999999999999.in-addr.arpa",
AF_UNSPEC, 1);
- test_eq(-1, i);
+ tt_int_op(-1,==, i);
i = tor_addr_parse_PTR_name(&t1, "1.0.168.192.in-addr.arpa",
AF_UNSPEC, 1);
- test_eq(1, i);
- test_eq(tor_addr_family(&t1), AF_INET);
+ tt_int_op(1,==, i);
+ tt_int_op(tor_addr_family(&t1),==, AF_INET);
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 1);
- test_streq(p1, "192.168.0.1");
+ tt_str_op(p1,==, "192.168.0.1");
i = tor_addr_parse_PTR_name(&t1, "192.168.0.99", AF_UNSPEC, 0);
- test_eq(0, i);
+ tt_int_op(0,==, i);
i = tor_addr_parse_PTR_name(&t1, "192.168.0.99", AF_UNSPEC, 1);
- test_eq(1, i);
+ tt_int_op(1,==, i);
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 1);
- test_streq(p1, "192.168.0.99");
+ tt_str_op(p1,==, "192.168.0.99");
memset(&t1, 0, sizeof(t1));
i = tor_addr_parse_PTR_name(&t1,
"0.1.2.3.4.5.6.7.8.9.a.b.c.d.e.f."
"f.e.e.b.1.e.b.e.e.f.f.e.e.e.d.9."
"ip6.ARPA",
AF_UNSPEC, 0);
- test_eq(1, i);
+ tt_int_op(1,==, i);
p1 = tor_addr_to_str(buf, &t1, sizeof(buf), 1);
- test_streq(p1, "[9dee:effe:ebe1:beef:fedc:ba98:7654:3210]");
+ tt_str_op(p1,==, "[9dee:effe:ebe1:beef:fedc:ba98:7654:3210]");
/* Failing cases. */
i = tor_addr_parse_PTR_name(&t1,
"6.7.8.9.a.b.c.d.e.f."
"f.e.e.b.1.e.b.e.e.f.f.e.e.e.d.9."
"ip6.ARPA",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1,
"6.7.8.9.a.b.c.d.e.f.a.b.c.d.e.f.0."
"f.e.e.b.1.e.b.e.e.f.f.e.e.e.d.9."
"ip6.ARPA",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1,
"6.7.8.9.a.b.c.d.e.f.X.0.0.0.0.9."
"f.e.e.b.1.e.b.e.e.f.f.e.e.e.d.9."
"ip6.ARPA",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1, "32.1.1.in-addr.arpa",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1, ".in-addr.arpa",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1, "1.2.3.4.5.in-addr.arpa",
AF_UNSPEC, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1, "1.2.3.4.5.in-addr.arpa",
AF_INET6, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
i = tor_addr_parse_PTR_name(&t1,
"6.7.8.9.a.b.c.d.e.f.a.b.c.d.e.0."
"f.e.e.b.1.e.b.e.e.f.f.e.e.e.d.9."
"ip6.ARPA",
AF_INET, 0);
- test_eq(i, -1);
+ tt_int_op(i,==, -1);
/* === Test tor_addr_to_PTR_name */
@@ -544,19 +547,19 @@ test_addr_ip6_helpers(void)
tor_addr_from_sockaddr(&t1, (struct sockaddr *)sin, NULL);
/* Check IPv4 PTR - too short buffer */
- test_eq(tor_addr_to_PTR_name(rbuf, 1, &t1), -1);
- test_eq(tor_addr_to_PTR_name(rbuf,
+ tt_int_op(tor_addr_to_PTR_name(rbuf, 1, &t1),==, -1);
+ tt_int_op(tor_addr_to_PTR_name(rbuf,
strlen("3.2.1.127.in-addr.arpa") - 1,
- &t1), -1);
+ &t1),==, -1);
/* Check IPv4 PTR - valid addr */
- test_eq(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1),
+ tt_int_op(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1),==,
strlen("3.2.1.127.in-addr.arpa"));
- test_streq(rbuf, "3.2.1.127.in-addr.arpa");
+ tt_str_op(rbuf,==, "3.2.1.127.in-addr.arpa");
/* Invalid addr family */
t1.family = AF_UNSPEC;
- test_eq(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1), -1);
+ tt_int_op(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1),==, -1);
/* Stage IPv6 addr */
memset(&sa_storage, 0, sizeof(sa_storage));
@@ -573,114 +576,114 @@ test_addr_ip6_helpers(void)
"0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.ip6.arpa";
/* Check IPv6 PTR - too short buffer */
- test_eq(tor_addr_to_PTR_name(rbuf, 0, &t1), -1);
- test_eq(tor_addr_to_PTR_name(rbuf, strlen(addr_PTR) - 1, &t1), -1);
+ tt_int_op(tor_addr_to_PTR_name(rbuf, 0, &t1),==, -1);
+ tt_int_op(tor_addr_to_PTR_name(rbuf, strlen(addr_PTR) - 1, &t1),==, -1);
/* Check IPv6 PTR - valid addr */
- test_eq(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1),
+ tt_int_op(tor_addr_to_PTR_name(rbuf, sizeof(rbuf), &t1),==,
strlen(addr_PTR));
- test_streq(rbuf, addr_PTR);
+ tt_str_op(rbuf,==, addr_PTR);
}
/* XXXX turn this into a separate function; it's not all IPv6. */
/* test tor_addr_parse_mask_ports */
test_addr_mask_ports_parse("[::f]/17:47-95", AF_INET6,
0, 0, 0, 0x0000000f, 17, 47, 95);
- test_streq(p1, "::f");
+ tt_str_op(p1,==, "::f");
//test_addr_parse("[::fefe:4.1.1.7/120]:999-1000");
//test_addr_parse_check("::fefe:401:107", 120, 999, 1000);
test_addr_mask_ports_parse("[::ffff:4.1.1.7]/120:443", AF_INET6,
0, 0, 0x0000ffff, 0x04010107, 120, 443, 443);
- test_streq(p1, "::ffff:4.1.1.7");
+ tt_str_op(p1,==, "::ffff:4.1.1.7");
test_addr_mask_ports_parse("[abcd:2::44a:0]:2-65000", AF_INET6,
0xabcd0002, 0, 0, 0x044a0000, 128, 2, 65000);
- test_streq(p1, "abcd:2::44a:0");
+ tt_str_op(p1,==, "abcd:2::44a:0");
/* Try some long addresses. */
r=tor_addr_parse_mask_ports("[ffff:1111:1111:1111:1111:1111:1111:1111]",
0, &t1, NULL, NULL, NULL);
- test_assert(r == AF_INET6);
+ tt_assert(r == AF_INET6);
r=tor_addr_parse_mask_ports("[ffff:1111:1111:1111:1111:1111:1111:11111]",
0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[ffff:1111:1111:1111:1111:1111:1111:1111:1]",
0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports(
"[ffff:1111:1111:1111:1111:1111:1111:ffff:"
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:"
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:"
"ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff]",
0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Try some failing cases. */
r=tor_addr_parse_mask_ports("[fefef::]/112", 0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[fefe::/112", 0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[fefe::", 0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[fefe::X]", 0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("efef::/112", 0, &t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f::]",0,&t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[::f:f:f:f:f:f:f:f]",0,&t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[f:f:f:f:f:f:f:f:f]",0,&t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[f:f:f:f:f::]/fred",0,&t1,&mask, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("[f:f:f:f:f::]/255.255.0.0",
0,&t1, NULL, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* This one will get rejected because it isn't a pure prefix. */
r=tor_addr_parse_mask_ports("1.1.2.3/255.255.64.0",0,&t1, &mask,NULL,NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Test for V4-mapped address with mask < 96. (arguably not valid) */
r=tor_addr_parse_mask_ports("[::ffff:1.1.2.2/33]",0,&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("1.1.2.2/33",0,&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Try extended wildcard addresses with out TAPMP_EXTENDED_STAR*/
r=tor_addr_parse_mask_ports("*4",0,&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r=tor_addr_parse_mask_ports("*6",0,&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
#if 0
/* Try a mask with a wildcard. */
r=tor_addr_parse_mask_ports("*/16",0,&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_assert(r == -1);
r=tor_addr_parse_mask_ports("*4/16",TAPMP_EXTENDED_STAR,
&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_assert(r == -1);
r=tor_addr_parse_mask_ports("*6/30",TAPMP_EXTENDED_STAR,
&t1, &mask, NULL, NULL);
- test_assert(r == -1);
+ tt_assert(r == -1);
#endif
/* Basic mask tests*/
r=tor_addr_parse_mask_ports("1.1.2.2/31",0,&t1, &mask, NULL, NULL);
- test_assert(r == AF_INET);
+ tt_assert(r == AF_INET);
tt_int_op(mask,==,31);
tt_int_op(tor_addr_family(&t1),==,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),==,0x01010202);
r=tor_addr_parse_mask_ports("3.4.16.032:1-2",0,&t1, &mask, &port1, &port2);
- test_assert(r == AF_INET);
+ tt_assert(r == AF_INET);
tt_int_op(mask,==,32);
tt_int_op(tor_addr_family(&t1),==,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),==,0x03041020);
- test_assert(port1 == 1);
- test_assert(port2 == 2);
+ tt_assert(port1 == 1);
+ tt_assert(port2 == 2);
r=tor_addr_parse_mask_ports("1.1.2.3/255.255.128.0",0,&t1, &mask,NULL,NULL);
- test_assert(r == AF_INET);
+ tt_assert(r == AF_INET);
tt_int_op(mask,==,17);
tt_int_op(tor_addr_family(&t1),==,AF_INET);
tt_int_op(tor_addr_to_ipv4h(&t1),==,0x01010203);
r=tor_addr_parse_mask_ports("[efef::]/112",0,&t1, &mask, &port1, &port2);
- test_assert(r == AF_INET6);
- test_assert(port1 == 1);
- test_assert(port2 == 65535);
+ tt_assert(r == AF_INET6);
+ tt_assert(port1 == 1);
+ tt_assert(port2 == 65535);
/* Try regular wildcard behavior without TAPMP_EXTENDED_STAR */
r=tor_addr_parse_mask_ports("*:80-443",0,&t1,&mask,&port1,&port2);
tt_int_op(r,==,AF_INET); /* Old users of this always get inet */
@@ -715,11 +718,11 @@ test_addr_ip6_helpers(void)
tt_int_op(port2,==,65535);
/* make sure inet address lengths >= max */
- test_assert(INET_NTOA_BUF_LEN >= sizeof("255.255.255.255"));
- test_assert(TOR_ADDR_BUF_LEN >=
+ tt_assert(INET_NTOA_BUF_LEN >= sizeof("255.255.255.255"));
+ tt_assert(TOR_ADDR_BUF_LEN >=
sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"));
- test_assert(sizeof(tor_addr_t) >= sizeof(struct in6_addr));
+ tt_assert(sizeof(tor_addr_t) >= sizeof(struct in6_addr));
/* get interface addresses */
r = get_interface_address6(LOG_DEBUG, AF_INET, &t1);
@@ -736,7 +739,7 @@ test_addr_ip6_helpers(void)
/** Test tor_addr_port_parse(). */
static void
-test_addr_parse(void)
+test_addr_parse(void *arg)
{
int r;
tor_addr_t addr;
@@ -744,89 +747,90 @@ test_addr_parse(void)
uint16_t port = 0;
/* Correct call. */
+ (void)arg;
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.1:1234",
&addr, &port, -1);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tor_addr_to_str(buf, &addr, sizeof(buf), 0);
- test_streq(buf, "192.0.2.1");
- test_eq(port, 1234);
+ tt_str_op(buf,==, "192.0.2.1");
+ tt_int_op(port,==, 1234);
r= tor_addr_port_parse(LOG_DEBUG,
"[::1]:1234",
&addr, &port, -1);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tor_addr_to_str(buf, &addr, sizeof(buf), 0);
- test_streq(buf, "::1");
- test_eq(port, 1234);
+ tt_str_op(buf,==, "::1");
+ tt_int_op(port,==, 1234);
/* Domain name. */
r= tor_addr_port_parse(LOG_DEBUG,
"torproject.org:1234",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Only IP. */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2",
&addr, &port, 200);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tt_int_op(port,==,200);
r= tor_addr_port_parse(LOG_DEBUG,
"[::1]",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r= tor_addr_port_parse(LOG_DEBUG,
"[::1]",
&addr, &port, 400);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tt_int_op(port,==,400);
/* Bad port. */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2:66666",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2:66666",
&addr, &port, 200);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Only domain name */
r= tor_addr_port_parse(LOG_DEBUG,
"torproject.org",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
r= tor_addr_port_parse(LOG_DEBUG,
"torproject.org",
&addr, &port, 200);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Bad IP address */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2:1234",
&addr, &port, -1);
- test_assert(r == -1);
+ tt_int_op(r, ==, -1);
/* Make sure that the default port has lower priority than the real
one */
r= tor_addr_port_parse(LOG_DEBUG,
"192.0.2.2:1337",
&addr, &port, 200);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tt_int_op(port,==,1337);
r= tor_addr_port_parse(LOG_DEBUG,
"[::1]:1369",
&addr, &port, 200);
- test_assert(r == 0);
+ tt_int_op(r, ==, 0);
tt_int_op(port,==,1369);
done:
@@ -1047,7 +1051,7 @@ test_addr_make_null(void *data)
}
#define ADDR_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_addr_ ## name }
+ { #name, test_addr_ ## name , 0, NULL, NULL }
struct testcase_t addr_tests[] = {
ADDR_LEGACY(basic),
diff --git a/src/test/test_bt_cl.c b/src/test/test_bt_cl.c
index 45ae82fb85..c0c334656d 100644
--- a/src/test/test_bt_cl.c
+++ b/src/test/test_bt_cl.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -30,7 +30,12 @@ int
crash(int x)
{
if (crashtype == 0) {
+#if defined(__clang_analyzer__) || defined(__COVERITY__)
+ tor_assert(1 == 0); /* Avert your eyes, clangalyzer and coverity! You
+ * don't need to see us dereference NULL. */
+#else
*(volatile int *)0 = 0;
+#endif
} else if (crashtype == 1) {
tor_assert(1 == 0);
} else if (crashtype == -1) {
@@ -91,7 +96,7 @@ main(int argc, char **argv)
return 1;
}
- init_logging();
+ init_logging(1);
set_log_severity_config(LOG_WARN, LOG_ERR, &severity);
add_stream_log(&severity, "stdout", STDOUT_FILENO);
tor_log_update_sigsafe_err_fds();
diff --git a/src/test/test_buffers.c b/src/test/test_buffers.c
index 61ac5bc36b..cea719077c 100644
--- a/src/test/test_buffers.c
+++ b/src/test/test_buffers.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define BUFFERS_PRIVATE
@@ -27,10 +27,10 @@ test_buffers_basic(void *arg)
* buf_new
****/
if (!(buf = buf_new()))
- test_fail();
+ TT_DIE(("Assertion failed."));
//test_eq(buf_capacity(buf), 4096);
- test_eq(buf_datalen(buf), 0);
+ tt_int_op(buf_datalen(buf),==, 0);
/****
* General pointer frobbing
@@ -40,16 +40,16 @@ test_buffers_basic(void *arg)
}
write_to_buf(str, 256, buf);
write_to_buf(str, 256, buf);
- test_eq(buf_datalen(buf), 512);
+ tt_int_op(buf_datalen(buf),==, 512);
fetch_from_buf(str2, 200, buf);
- test_memeq(str, str2, 200);
- test_eq(buf_datalen(buf), 312);
+ tt_mem_op(str,==, str2, 200);
+ tt_int_op(buf_datalen(buf),==, 312);
memset(str2, 0, sizeof(str2));
fetch_from_buf(str2, 256, buf);
- test_memeq(str+200, str2, 56);
- test_memeq(str, str2+56, 200);
- test_eq(buf_datalen(buf), 56);
+ tt_mem_op(str+200,==, str2, 56);
+ tt_mem_op(str,==, str2+56, 200);
+ tt_int_op(buf_datalen(buf),==, 56);
memset(str2, 0, sizeof(str2));
/* Okay, now we should be 512 bytes into the 4096-byte buffer. If we add
* another 3584 bytes, we hit the end. */
@@ -57,16 +57,16 @@ test_buffers_basic(void *arg)
write_to_buf(str, 256, buf);
}
assert_buf_ok(buf);
- test_eq(buf_datalen(buf), 3896);
+ tt_int_op(buf_datalen(buf),==, 3896);
fetch_from_buf(str2, 56, buf);
- test_eq(buf_datalen(buf), 3840);
- test_memeq(str+200, str2, 56);
+ tt_int_op(buf_datalen(buf),==, 3840);
+ tt_mem_op(str+200,==, str2, 56);
for (j=0;j<15;++j) {
memset(str2, 0, sizeof(str2));
fetch_from_buf(str2, 256, buf);
- test_memeq(str, str2, 256);
+ tt_mem_op(str,==, str2, 256);
}
- test_eq(buf_datalen(buf), 0);
+ tt_int_op(buf_datalen(buf),==, 0);
buf_free(buf);
buf = NULL;
@@ -76,7 +76,7 @@ test_buffers_basic(void *arg)
write_to_buf(str+1, 255, buf);
//test_eq(buf_capacity(buf), 256);
fetch_from_buf(str2, 254, buf);
- test_memeq(str+1, str2, 254);
+ tt_mem_op(str+1,==, str2, 254);
//test_eq(buf_capacity(buf), 256);
assert_buf_ok(buf);
write_to_buf(str, 32, buf);
@@ -85,15 +85,15 @@ test_buffers_basic(void *arg)
write_to_buf(str, 256, buf);
assert_buf_ok(buf);
//test_eq(buf_capacity(buf), 512);
- test_eq(buf_datalen(buf), 33+256);
+ tt_int_op(buf_datalen(buf),==, 33+256);
fetch_from_buf(str2, 33, buf);
- test_eq(*str2, str[255]);
+ tt_int_op(*str2,==, str[255]);
- test_memeq(str2+1, str, 32);
+ tt_mem_op(str2+1,==, str, 32);
//test_eq(buf_capacity(buf), 512);
- test_eq(buf_datalen(buf), 256);
+ tt_int_op(buf_datalen(buf),==, 256);
fetch_from_buf(str2, 256, buf);
- test_memeq(str, str2, 256);
+ tt_mem_op(str,==, str2, 256);
/* now try shrinking: case 1. */
buf_free(buf);
@@ -102,10 +102,10 @@ test_buffers_basic(void *arg)
write_to_buf(str,255, buf);
}
//test_eq(buf_capacity(buf), 33668);
- test_eq(buf_datalen(buf), 17085);
+ tt_int_op(buf_datalen(buf),==, 17085);
for (j=0; j < 40; ++j) {
fetch_from_buf(str2, 255,buf);
- test_memeq(str2, str, 255);
+ tt_mem_op(str2,==, str, 255);
}
/* now try shrinking: case 2. */
@@ -116,7 +116,7 @@ test_buffers_basic(void *arg)
}
for (j=0; j < 20; ++j) {
fetch_from_buf(str2, 255,buf);
- test_memeq(str2, str, 255);
+ tt_mem_op(str2,==, str, 255);
}
for (j=0;j<80;++j) {
write_to_buf(str,255, buf);
@@ -124,7 +124,7 @@ test_buffers_basic(void *arg)
//test_eq(buf_capacity(buf),33668);
for (j=0; j < 120; ++j) {
fetch_from_buf(str2, 255,buf);
- test_memeq(str2, str, 255);
+ tt_mem_op(str2,==, str, 255);
}
/* Move from buf to buf. */
@@ -133,27 +133,27 @@ test_buffers_basic(void *arg)
buf2 = buf_new_with_capacity(4096);
for (j=0;j<100;++j)
write_to_buf(str, 255, buf);
- test_eq(buf_datalen(buf), 25500);
+ tt_int_op(buf_datalen(buf),==, 25500);
for (j=0;j<100;++j) {
r = 10;
move_buf_to_buf(buf2, buf, &r);
- test_eq(r, 0);
+ tt_int_op(r,==, 0);
}
- test_eq(buf_datalen(buf), 24500);
- test_eq(buf_datalen(buf2), 1000);
+ tt_int_op(buf_datalen(buf),==, 24500);
+ tt_int_op(buf_datalen(buf2),==, 1000);
for (j=0;j<3;++j) {
fetch_from_buf(str2, 255, buf2);
- test_memeq(str2, str, 255);
+ tt_mem_op(str2,==, str, 255);
}
r = 8192; /*big move*/
move_buf_to_buf(buf2, buf, &r);
- test_eq(r, 0);
+ tt_int_op(r,==, 0);
r = 30000; /* incomplete move */
move_buf_to_buf(buf2, buf, &r);
- test_eq(r, 13692);
+ tt_int_op(r,==, 13692);
for (j=0;j<97;++j) {
fetch_from_buf(str2, 255, buf2);
- test_memeq(str2, str, 255);
+ tt_mem_op(str2,==, str, 255);
}
buf_free(buf);
buf_free(buf2);
@@ -163,16 +163,16 @@ test_buffers_basic(void *arg)
cp = "Testing. This is a moderately long Testing string.";
for (j = 0; cp[j]; j++)
write_to_buf(cp+j, 1, buf);
- test_eq(0, buf_find_string_offset(buf, "Testing", 7));
- test_eq(1, buf_find_string_offset(buf, "esting", 6));
- test_eq(1, buf_find_string_offset(buf, "est", 3));
- test_eq(39, buf_find_string_offset(buf, "ing str", 7));
- test_eq(35, buf_find_string_offset(buf, "Testing str", 11));
- test_eq(32, buf_find_string_offset(buf, "ng ", 3));
- test_eq(43, buf_find_string_offset(buf, "string.", 7));
- test_eq(-1, buf_find_string_offset(buf, "shrdlu", 6));
- test_eq(-1, buf_find_string_offset(buf, "Testing thing", 13));
- test_eq(-1, buf_find_string_offset(buf, "ngx", 3));
+ tt_int_op(0,==, buf_find_string_offset(buf, "Testing", 7));
+ tt_int_op(1,==, buf_find_string_offset(buf, "esting", 6));
+ tt_int_op(1,==, buf_find_string_offset(buf, "est", 3));
+ tt_int_op(39,==, buf_find_string_offset(buf, "ing str", 7));
+ tt_int_op(35,==, buf_find_string_offset(buf, "Testing str", 11));
+ tt_int_op(32,==, buf_find_string_offset(buf, "ng ", 3));
+ tt_int_op(43,==, buf_find_string_offset(buf, "string.", 7));
+ tt_int_op(-1,==, buf_find_string_offset(buf, "shrdlu", 6));
+ tt_int_op(-1,==, buf_find_string_offset(buf, "Testing thing", 13));
+ tt_int_op(-1,==, buf_find_string_offset(buf, "ngx", 3));
buf_free(buf);
buf = NULL;
@@ -240,16 +240,16 @@ test_buffer_pullup(void *arg)
/* Make room for 3000 bytes in the first chunk, so that the pullup-move code
* can get tested. */
tt_int_op(fetch_from_buf(tmp, 3000, buf), ==, 3000);
- test_memeq(tmp, stuff, 3000);
+ tt_mem_op(tmp,==, stuff, 3000);
buf_pullup(buf, 2048, 0);
assert_buf_ok(buf);
buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, !=, NULL);
tt_int_op(sz, >=, 2048);
- test_memeq(cp, stuff+3000, 2048);
+ tt_mem_op(cp,==, stuff+3000, 2048);
tt_int_op(3000, ==, buf_datalen(buf));
tt_int_op(fetch_from_buf(tmp, 3000, buf), ==, 0);
- test_memeq(tmp, stuff+3000, 2048);
+ tt_mem_op(tmp,==, stuff+3000, 2048);
buf_free(buf);
@@ -269,16 +269,16 @@ test_buffer_pullup(void *arg)
buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, !=, NULL);
tt_int_op(sz, >=, 12500);
- test_memeq(cp, stuff, 12500);
+ tt_mem_op(cp,==, stuff, 12500);
tt_int_op(buf_datalen(buf), ==, 16000);
fetch_from_buf(tmp, 12400, buf);
- test_memeq(tmp, stuff, 12400);
+ tt_mem_op(tmp,==, stuff, 12400);
tt_int_op(buf_datalen(buf), ==, 3600);
fetch_from_buf(tmp, 3500, buf);
- test_memeq(tmp, stuff+12400, 3500);
+ tt_mem_op(tmp,==, stuff+12400, 3500);
fetch_from_buf(tmp, 100, buf);
- test_memeq(tmp, stuff+15900, 10);
+ tt_mem_op(tmp,==, stuff+15900, 10);
buf_free(buf);
@@ -292,7 +292,7 @@ test_buffer_pullup(void *arg)
buf_get_first_chunk_data(buf, &cp, &sz);
tt_ptr_op(cp, !=, NULL);
tt_int_op(sz, ==, 7900);
- test_memeq(cp, stuff+100, 7900);
+ tt_mem_op(cp,==, stuff+100, 7900);
buf_free(buf);
buf = NULL;
@@ -335,14 +335,14 @@ test_buffer_copy(void *arg)
tt_int_op(0, ==, generic_buffer_set_to_copy(&buf2, buf));
tt_int_op(len, ==, generic_buffer_len(buf2));
generic_buffer_get(buf2, b, len);
- test_mem_op(b, ==, s, len);
+ tt_mem_op(b, ==, s, len);
/* Now free buf2 and retry so we can test allocating */
generic_buffer_free(buf2);
buf2 = NULL;
tt_int_op(0, ==, generic_buffer_set_to_copy(&buf2, buf));
tt_int_op(len, ==, generic_buffer_len(buf2));
generic_buffer_get(buf2, b, len);
- test_mem_op(b, ==, s, len);
+ tt_mem_op(b, ==, s, len);
/* Clear buf for next test */
generic_buffer_get(buf, b, len);
tt_int_op(generic_buffer_len(buf),==,0);
@@ -362,7 +362,7 @@ test_buffer_copy(void *arg)
for (i = 0; i < 256; ++i) {
generic_buffer_get(buf2, b, len+1);
tt_int_op((unsigned char)b[0],==,i);
- test_mem_op(b+1, ==, s, len);
+ tt_mem_op(b+1, ==, s, len);
}
done:
@@ -410,7 +410,7 @@ test_buffer_ext_or_cmd(void *arg)
tt_ptr_op(NULL, !=, cmd);
tt_int_op(0x1021, ==, cmd->cmd);
tt_int_op(6, ==, cmd->len);
- test_mem_op("abcdef", ==, cmd->body, 6);
+ tt_mem_op("abcdef", ==, cmd->body, 6);
tt_int_op(0, ==, generic_buffer_len(buf));
ext_or_cmd_free(cmd);
cmd = NULL;
@@ -422,7 +422,7 @@ test_buffer_ext_or_cmd(void *arg)
tt_ptr_op(NULL, !=, cmd);
tt_int_op(0xffff, ==, cmd->cmd);
tt_int_op(10, ==, cmd->len);
- test_mem_op("loremipsum", ==, cmd->body, 10);
+ tt_mem_op("loremipsum", ==, cmd->body, 10);
tt_int_op(4, ==, generic_buffer_len(buf));
ext_or_cmd_free(cmd);
cmd = NULL;
@@ -436,7 +436,7 @@ test_buffer_ext_or_cmd(void *arg)
tt_ptr_op(NULL, !=, cmd);
tt_int_op(0x1000, ==, cmd->cmd);
tt_int_op(0xffff, ==, cmd->len);
- test_mem_op(tmp, ==, cmd->body, 65535);
+ tt_mem_op(tmp, ==, cmd->body, 65535);
tt_int_op(0, ==, generic_buffer_len(buf));
ext_or_cmd_free(cmd);
cmd = NULL;
@@ -684,14 +684,11 @@ test_buffers_zlib_fin_at_chunk_end(void *arg)
headerjunk = buf->head->memlen - 7;
write_to_buf(msg, headerjunk-1, buf);
tt_uint_op(buf->head->datalen, ==, headerjunk);
- printf("<%u>\n", (unsigned)buf_datalen(buf));
tt_uint_op(buf_datalen(buf), ==, headerjunk);
/* Write an empty string, with finalization on. */
zlib_state = tor_zlib_new(1, ZLIB_METHOD);
tt_int_op(write_to_buf_zlib(buf, zlib_state, "", 0, 1), ==, 0);
- printf("<%u>\n", (unsigned)buf_datalen(buf));
-
in_len = buf_datalen(buf);
contents = tor_malloc(in_len);
diff --git a/src/test/test_cell_formats.c b/src/test/test_cell_formats.c
index d7f60680c2..19ecedc8ac 100644
--- a/src/test/test_cell_formats.c
+++ b/src/test/test_cell_formats.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -35,11 +35,11 @@ test_cfmt_relay_header(void *arg)
tt_int_op(rh.command, ==, 3);
tt_int_op(rh.recognized, ==, 0);
tt_int_op(rh.stream_id, ==, 0x2122);
- test_mem_op(rh.integrity, ==, "ABCD", 4);
+ tt_mem_op(rh.integrity, ==, "ABCD", 4);
tt_int_op(rh.length, ==, 0x103);
relay_header_pack(hdr_out, &rh);
- test_mem_op(hdr_out, ==, hdr_1, RELAY_HEADER_SIZE);
+ tt_mem_op(hdr_out, ==, hdr_1, RELAY_HEADER_SIZE);
done:
;
@@ -402,10 +402,10 @@ test_cfmt_create_cells(void *arg)
tt_int_op(CELL_CREATE, ==, cc.cell_type);
tt_int_op(ONION_HANDSHAKE_TYPE_TAP, ==, cc.handshake_type);
tt_int_op(TAP_ONIONSKIN_CHALLENGE_LEN, ==, cc.handshake_len);
- test_memeq(cc.onionskin, b, TAP_ONIONSKIN_CHALLENGE_LEN + 10);
+ tt_mem_op(cc.onionskin,==, b, TAP_ONIONSKIN_CHALLENGE_LEN + 10);
tt_int_op(0, ==, create_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A valid create_fast cell. */
memset(&cell, 0, sizeof(cell));
@@ -417,10 +417,10 @@ test_cfmt_create_cells(void *arg)
tt_int_op(CELL_CREATE_FAST, ==, cc.cell_type);
tt_int_op(ONION_HANDSHAKE_TYPE_FAST, ==, cc.handshake_type);
tt_int_op(CREATE_FAST_LEN, ==, cc.handshake_len);
- test_memeq(cc.onionskin, b, CREATE_FAST_LEN + 10);
+ tt_mem_op(cc.onionskin,==, b, CREATE_FAST_LEN + 10);
tt_int_op(0, ==, create_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A valid create2 cell with a TAP payload */
memset(&cell, 0, sizeof(cell));
@@ -433,10 +433,10 @@ test_cfmt_create_cells(void *arg)
tt_int_op(CELL_CREATE2, ==, cc.cell_type);
tt_int_op(ONION_HANDSHAKE_TYPE_TAP, ==, cc.handshake_type);
tt_int_op(TAP_ONIONSKIN_CHALLENGE_LEN, ==, cc.handshake_len);
- test_memeq(cc.onionskin, b, TAP_ONIONSKIN_CHALLENGE_LEN + 10);
+ tt_mem_op(cc.onionskin,==, b, TAP_ONIONSKIN_CHALLENGE_LEN + 10);
tt_int_op(0, ==, create_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A valid create2 cell with an ntor payload */
memset(&cell, 0, sizeof(cell));
@@ -445,18 +445,14 @@ test_cfmt_create_cells(void *arg)
cell.command = CELL_CREATE2;
memcpy(cell.payload, "\x00\x02\x00\x54", 4); /* ntor, 84 bytes long */
memcpy(cell.payload+4, b, NTOR_ONIONSKIN_LEN);
-#ifdef CURVE25519_ENABLED
tt_int_op(0, ==, create_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATE2, ==, cc.cell_type);
tt_int_op(ONION_HANDSHAKE_TYPE_NTOR, ==, cc.handshake_type);
tt_int_op(NTOR_ONIONSKIN_LEN, ==, cc.handshake_len);
- test_memeq(cc.onionskin, b, NTOR_ONIONSKIN_LEN + 10);
+ tt_mem_op(cc.onionskin,==, b, NTOR_ONIONSKIN_LEN + 10);
tt_int_op(0, ==, create_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
-#else
- tt_int_op(-1, ==, create_cell_parse(&cc, &cell));
-#endif
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A valid create cell with an ntor payload, in legacy format. */
memset(&cell, 0, sizeof(cell));
@@ -465,18 +461,14 @@ test_cfmt_create_cells(void *arg)
cell.command = CELL_CREATE;
memcpy(cell.payload, "ntorNTORntorNTOR", 16);
memcpy(cell.payload+16, b, NTOR_ONIONSKIN_LEN);
-#ifdef CURVE25519_ENABLED
tt_int_op(0, ==, create_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATE, ==, cc.cell_type);
tt_int_op(ONION_HANDSHAKE_TYPE_NTOR, ==, cc.handshake_type);
tt_int_op(NTOR_ONIONSKIN_LEN, ==, cc.handshake_len);
- test_memeq(cc.onionskin, b, NTOR_ONIONSKIN_LEN + 10);
+ tt_mem_op(cc.onionskin,==, b, NTOR_ONIONSKIN_LEN + 10);
tt_int_op(0, ==, create_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
-#else
- tt_int_op(-1, ==, create_cell_parse(&cc, &cell));
-#endif
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* == Okay, now let's try to parse some impossible stuff. */
@@ -527,10 +519,10 @@ test_cfmt_created_cells(void *arg)
tt_int_op(0, ==, created_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATED, ==, cc.cell_type);
tt_int_op(TAP_ONIONSKIN_REPLY_LEN, ==, cc.handshake_len);
- test_memeq(cc.reply, b, TAP_ONIONSKIN_REPLY_LEN + 10);
+ tt_mem_op(cc.reply,==, b, TAP_ONIONSKIN_REPLY_LEN + 10);
tt_int_op(0, ==, created_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A good CREATED_FAST cell */
memset(&cell, 0, sizeof(cell));
@@ -541,10 +533,10 @@ test_cfmt_created_cells(void *arg)
tt_int_op(0, ==, created_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATED_FAST, ==, cc.cell_type);
tt_int_op(CREATED_FAST_LEN, ==, cc.handshake_len);
- test_memeq(cc.reply, b, CREATED_FAST_LEN + 10);
+ tt_mem_op(cc.reply,==, b, CREATED_FAST_LEN + 10);
tt_int_op(0, ==, created_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A good CREATED2 cell with short reply */
memset(&cell, 0, sizeof(cell));
@@ -556,10 +548,10 @@ test_cfmt_created_cells(void *arg)
tt_int_op(0, ==, created_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATED2, ==, cc.cell_type);
tt_int_op(64, ==, cc.handshake_len);
- test_memeq(cc.reply, b, 80);
+ tt_mem_op(cc.reply,==, b, 80);
tt_int_op(0, ==, created_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* A good CREATED2 cell with maximal reply */
memset(&cell, 0, sizeof(cell));
@@ -571,10 +563,10 @@ test_cfmt_created_cells(void *arg)
tt_int_op(0, ==, created_cell_parse(&cc, &cell));
tt_int_op(CELL_CREATED2, ==, cc.cell_type);
tt_int_op(496, ==, cc.handshake_len);
- test_memeq(cc.reply, b, 496);
+ tt_mem_op(cc.reply,==, b, 496);
tt_int_op(0, ==, created_cell_format(&cell2, &cc));
tt_int_op(cell.command, ==, cell2.command);
- test_memeq(cell.payload, cell2.payload, CELL_PAYLOAD_SIZE);
+ tt_mem_op(cell.payload,==, cell2.payload, CELL_PAYLOAD_SIZE);
/* Bogus CREATED2 cell: too long! */
memset(&cell, 0, sizeof(cell));
@@ -620,15 +612,15 @@ test_cfmt_extend_cells(void *arg)
tt_str_op("18.244.0.1", ==, fmt_addr(&ec.orport_ipv4.addr));
tt_int_op(258, ==, ec.orport_ipv4.port);
tt_int_op(AF_UNSPEC, ==, tor_addr_family(&ec.orport_ipv6.addr));
- test_memeq(ec.node_id, "electroencephalogram", 20);
+ tt_mem_op(ec.node_id,==, "electroencephalogram", 20);
tt_int_op(cc->cell_type, ==, CELL_CREATE);
tt_int_op(cc->handshake_type, ==, ONION_HANDSHAKE_TYPE_TAP);
tt_int_op(cc->handshake_len, ==, TAP_ONIONSKIN_CHALLENGE_LEN);
- test_memeq(cc->onionskin, b, TAP_ONIONSKIN_CHALLENGE_LEN+20);
+ tt_mem_op(cc->onionskin,==, b, TAP_ONIONSKIN_CHALLENGE_LEN+20);
tt_int_op(0, ==, extend_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(p2_cmd, ==, RELAY_COMMAND_EXTEND);
tt_int_op(p2_len, ==, 26+TAP_ONIONSKIN_CHALLENGE_LEN);
- test_memeq(p2, p, RELAY_PAYLOAD_SIZE);
+ tt_mem_op(p2,==, p, RELAY_PAYLOAD_SIZE);
/* Let's do an ntor stuffed in a legacy EXTEND cell */
memset(p, 0, sizeof(p));
@@ -644,15 +636,15 @@ test_cfmt_extend_cells(void *arg)
tt_str_op("18.244.0.1", ==, fmt_addr(&ec.orport_ipv4.addr));
tt_int_op(258, ==, ec.orport_ipv4.port);
tt_int_op(AF_UNSPEC, ==, tor_addr_family(&ec.orport_ipv6.addr));
- test_memeq(ec.node_id, "electroencephalogram", 20);
+ tt_mem_op(ec.node_id,==, "electroencephalogram", 20);
tt_int_op(cc->cell_type, ==, CELL_CREATE2);
tt_int_op(cc->handshake_type, ==, ONION_HANDSHAKE_TYPE_NTOR);
tt_int_op(cc->handshake_len, ==, NTOR_ONIONSKIN_LEN);
- test_memeq(cc->onionskin, b, NTOR_ONIONSKIN_LEN+20);
+ tt_mem_op(cc->onionskin,==, b, NTOR_ONIONSKIN_LEN+20);
tt_int_op(0, ==, extend_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(p2_cmd, ==, RELAY_COMMAND_EXTEND);
tt_int_op(p2_len, ==, 26+TAP_ONIONSKIN_CHALLENGE_LEN);
- test_memeq(p2, p, RELAY_PAYLOAD_SIZE);
+ tt_mem_op(p2,==, p, RELAY_PAYLOAD_SIZE);
tt_int_op(0, ==, create_cell_format_relayed(&cell, cc));
/* Now let's do a minimal ntor EXTEND2 cell. */
@@ -673,15 +665,15 @@ test_cfmt_extend_cells(void *arg)
tt_str_op("18.244.0.1", ==, fmt_addr(&ec.orport_ipv4.addr));
tt_int_op(61681, ==, ec.orport_ipv4.port);
tt_int_op(AF_UNSPEC, ==, tor_addr_family(&ec.orport_ipv6.addr));
- test_memeq(ec.node_id, "anarchoindividualist", 20);
+ tt_mem_op(ec.node_id,==, "anarchoindividualist", 20);
tt_int_op(cc->cell_type, ==, CELL_CREATE2);
tt_int_op(cc->handshake_type, ==, ONION_HANDSHAKE_TYPE_NTOR);
tt_int_op(cc->handshake_len, ==, NTOR_ONIONSKIN_LEN);
- test_memeq(cc->onionskin, b, NTOR_ONIONSKIN_LEN+20);
+ tt_mem_op(cc->onionskin,==, b, NTOR_ONIONSKIN_LEN+20);
tt_int_op(0, ==, extend_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(p2_cmd, ==, RELAY_COMMAND_EXTEND2);
tt_int_op(p2_len, ==, 35+NTOR_ONIONSKIN_LEN);
- test_memeq(p2, p, RELAY_PAYLOAD_SIZE);
+ tt_mem_op(p2,==, p, RELAY_PAYLOAD_SIZE);
/* Now let's do a fanciful EXTEND2 cell. */
memset(&ec, 0xff, sizeof(ec));
@@ -706,11 +698,11 @@ test_cfmt_extend_cells(void *arg)
tt_int_op(61681, ==, ec.orport_ipv4.port);
tt_str_op("2002::f0:c51e", ==, fmt_addr(&ec.orport_ipv6.addr));
tt_int_op(4370, ==, ec.orport_ipv6.port);
- test_memeq(ec.node_id, "anthropomorphization", 20);
+ tt_mem_op(ec.node_id,==, "anthropomorphization", 20);
tt_int_op(cc->cell_type, ==, CELL_CREATE2);
tt_int_op(cc->handshake_type, ==, 0x105);
tt_int_op(cc->handshake_len, ==, 99);
- test_memeq(cc->onionskin, b, 99+20);
+ tt_mem_op(cc->onionskin,==, b, 99+20);
tt_int_op(0, ==, extend_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(p2_cmd, ==, RELAY_COMMAND_EXTEND2);
/* We'll generate it minus the IPv6 address and minus the konami code */
@@ -722,7 +714,7 @@ test_cfmt_extend_cells(void *arg)
"0214616e7468726f706f6d6f727068697a6174696f6e"
/* Now the handshake prologue */
"01050063");
- test_memeq(p2+1+8+22+4, b, 99+20);
+ tt_mem_op(p2+1+8+22+4,==, b, 99+20);
tt_int_op(0, ==, create_cell_format_relayed(&cell, cc));
/* == Now try parsing some junk */
@@ -836,11 +828,11 @@ test_cfmt_extended_cells(void *arg)
tt_int_op(RELAY_COMMAND_EXTENDED, ==, ec.cell_type);
tt_int_op(cc->cell_type, ==, CELL_CREATED);
tt_int_op(cc->handshake_len, ==, TAP_ONIONSKIN_REPLY_LEN);
- test_memeq(cc->reply, b, TAP_ONIONSKIN_REPLY_LEN);
+ tt_mem_op(cc->reply,==, b, TAP_ONIONSKIN_REPLY_LEN);
tt_int_op(0, ==, extended_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(RELAY_COMMAND_EXTENDED, ==, p2_cmd);
tt_int_op(TAP_ONIONSKIN_REPLY_LEN, ==, p2_len);
- test_memeq(p2, p, sizeof(p2));
+ tt_mem_op(p2,==, p, sizeof(p2));
/* Try an EXTENDED2 cell */
memset(&ec, 0xff, sizeof(ec));
@@ -853,11 +845,11 @@ test_cfmt_extended_cells(void *arg)
tt_int_op(RELAY_COMMAND_EXTENDED2, ==, ec.cell_type);
tt_int_op(cc->cell_type, ==, CELL_CREATED2);
tt_int_op(cc->handshake_len, ==, 42);
- test_memeq(cc->reply, b, 42+10);
+ tt_mem_op(cc->reply,==, b, 42+10);
tt_int_op(0, ==, extended_cell_format(&p2_cmd, &p2_len, p2, &ec));
tt_int_op(RELAY_COMMAND_EXTENDED2, ==, p2_cmd);
tt_int_op(2+42, ==, p2_len);
- test_memeq(p2, p, sizeof(p2));
+ tt_mem_op(p2,==, p, sizeof(p2));
/* Try an almost-too-long EXTENDED2 cell */
memcpy(p, "\x01\xf0", 2);
diff --git a/src/test/test_cell_queue.c b/src/test/test_cell_queue.c
index 92629823ec..e43c100f17 100644
--- a/src/test/test_cell_queue.c
+++ b/src/test/test_cell_queue.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define CIRCUITLIST_PRIVATE
@@ -69,15 +69,15 @@ test_cq_manip(void *arg)
pc_tmp = cell_queue_pop(&cq);
tt_int_op(cq.n, ==, 1);
tt_ptr_op(pc_tmp, !=, NULL);
- test_mem_op(pc_tmp->body, ==, "\x12\x34\x56\x78\x0a", 5);
- test_mem_op(pc_tmp->body+5, ==, cell.payload, sizeof(cell.payload));
+ tt_mem_op(pc_tmp->body, ==, "\x12\x34\x56\x78\x0a", 5);
+ tt_mem_op(pc_tmp->body+5, ==, cell.payload, sizeof(cell.payload));
packed_cell_free(pc_tmp);
pc_tmp = cell_queue_pop(&cq);
tt_int_op(cq.n, ==, 0);
tt_ptr_op(pc_tmp, !=, NULL);
- test_mem_op(pc_tmp->body, ==, "\x20\x13\x0a", 3);
- test_mem_op(pc_tmp->body+3, ==, cell.payload, sizeof(cell.payload));
+ tt_mem_op(pc_tmp->body, ==, "\x20\x13\x0a", 3);
+ tt_mem_op(pc_tmp->body+3, ==, cell.payload, sizeof(cell.payload));
packed_cell_free(pc_tmp);
pc_tmp = NULL;
diff --git a/src/test/test_circuitlist.c b/src/test/test_circuitlist.c
index b19edd1fd4..fb5488b627 100644
--- a/src/test/test_circuitlist.c
+++ b/src/test/test_circuitlist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define TOR_CHANNEL_INTERNAL_
@@ -79,9 +79,13 @@ test_clist_maps(void *arg)
memset(&cam, 0, sizeof(cam));
memset(&cdm, 0, sizeof(cdm));
- ch1->cmux = (void*)0x1001;
- ch2->cmux = (void*)0x1002;
- ch3->cmux = (void*)0x1003;
+ tt_assert(ch1);
+ tt_assert(ch2);
+ tt_assert(ch3);
+
+ ch1->cmux = tor_malloc(1);
+ ch2->cmux = tor_malloc(1);
+ ch3->cmux = tor_malloc(1);
or_c1 = or_circuit_new(100, ch2);
tt_assert(or_c1);
@@ -156,6 +160,12 @@ test_clist_maps(void *arg)
circuit_free(TO_CIRCUIT(or_c1));
if (or_c2)
circuit_free(TO_CIRCUIT(or_c2));
+ if (ch1)
+ tor_free(ch1->cmux);
+ if (ch2)
+ tor_free(ch2->cmux);
+ if (ch3)
+ tor_free(ch3->cmux);
tor_free(ch1);
tor_free(ch2);
tor_free(ch3);
@@ -241,7 +251,7 @@ test_rend_token_maps(void *arg)
tt_ptr_op(c3->rendinfo, ==, NULL);
tt_ptr_op(c4->rendinfo, !=, NULL);
- test_mem_op(c4->rendinfo, ==, tok3, REND_TOKEN_LEN);
+ tt_mem_op(c4->rendinfo, ==, tok3, REND_TOKEN_LEN);
/* Now clear c4's cookie. */
circuit_set_intro_point_digest(c4, NULL);
diff --git a/src/test/test_circuitmux.c b/src/test/test_circuitmux.c
index b9c0436ebf..446fc88b3c 100644
--- a/src/test/test_circuitmux.c
+++ b/src/test/test_circuitmux.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define TOR_CHANNEL_INTERNAL_
@@ -65,7 +65,7 @@ test_cmux_destroy_cell_queue(void *arg)
pc = cell_queue_pop(cq);
tt_assert(pc);
- test_mem_op(pc->body, ==, "\x00\x00\x00\x64\x04\x0a\x00\x00\x00", 9);
+ tt_mem_op(pc->body, ==, "\x00\x00\x00\x64\x04\x0a\x00\x00\x00", 9);
packed_cell_free(pc);
pc = NULL;
diff --git a/src/test/test_config.c b/src/test/test_config.c
index ae01facec7..1ecb816352 100644
--- a/src/test/test_config.c
+++ b/src/test/test_config.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -55,57 +55,57 @@ test_config_addressmap(void *arg)
/* MapAddress .invalidwildcard.com .torserver.exit - no match */
strlcpy(address, "www.invalidwildcard.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
/* MapAddress *invalidasterisk.com .torserver.exit - no match */
strlcpy(address, "www.invalidasterisk.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
/* Where no mapping for FQDN match on top-level domain */
/* MapAddress .google.com .torserver.exit */
strlcpy(address, "reader.google.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "reader.torserver.exit");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "reader.torserver.exit");
/* MapAddress *.yahoo.com *.google.com.torserver.exit */
strlcpy(address, "reader.yahoo.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "reader.google.com.torserver.exit");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "reader.google.com.torserver.exit");
/*MapAddress *.cnn.com www.cnn.com */
strlcpy(address, "cnn.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "www.cnn.com");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "www.cnn.com");
/* MapAddress .cn.com www.cnn.com */
strlcpy(address, "www.cn.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "www.cnn.com");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "www.cnn.com");
/* MapAddress ex.com www.cnn.com - no match */
strlcpy(address, "www.ex.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
/* MapAddress ey.com *.cnn.com - invalid expression */
strlcpy(address, "ey.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
/* Where mapping for FQDN match on FQDN */
strlcpy(address, "www.google.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "3.3.3.3");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "3.3.3.3");
strlcpy(address, "www.torproject.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "1.1.1.1");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "1.1.1.1");
strlcpy(address, "other.torproject.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "this.torproject.org.otherserver.exit");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "this.torproject.org.otherserver.exit");
strlcpy(address, "test.torproject.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "2.2.2.2");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "2.2.2.2");
/* Test a chain of address mappings and the order in which they were added:
"MapAddress www.example.org 4.4.4.4"
@@ -113,17 +113,17 @@ test_config_addressmap(void *arg)
"MapAddress 4.4.4.4 5.5.5.5"
*/
strlcpy(address, "www.example.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "5.5.5.5");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "5.5.5.5");
/* Test infinite address mapping results in no change */
strlcpy(address, "www.infiniteloop.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "www.infiniteloop.org");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "www.infiniteloop.org");
/* Test we don't find false positives */
strlcpy(address, "www.example.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
/* Test top-level-domain matching a bit harder */
config_free_lines(get_options_mutable()->AddressMap);
@@ -136,24 +136,24 @@ test_config_addressmap(void *arg)
config_register_addressmaps(get_options());
strlcpy(address, "www.abc.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "www.abc.torserver.exit");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "www.abc.torserver.exit");
strlcpy(address, "www.def.com", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "www.def.torserver.exit");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "www.def.torserver.exit");
strlcpy(address, "www.torproject.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "1.1.1.1");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "1.1.1.1");
strlcpy(address, "test.torproject.org", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "1.1.1.1");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "1.1.1.1");
strlcpy(address, "torproject.net", sizeof(address));
- test_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
- test_streq(address, "2.2.2.2");
+ tt_assert(addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_str_op(address,==, "2.2.2.2");
/* We don't support '*' as a mapping directive */
config_free_lines(get_options_mutable()->AddressMap);
@@ -163,13 +163,13 @@ test_config_addressmap(void *arg)
config_register_addressmaps(get_options());
strlcpy(address, "www.abc.com", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
strlcpy(address, "www.def.net", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
strlcpy(address, "www.torproject.org", sizeof(address));
- test_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
+ tt_assert(!addressmap_rewrite(address, sizeof(address), &expires, NULL));
#undef addressmap_rewrite
@@ -222,13 +222,13 @@ test_config_check_or_create_data_subdir(void *arg)
// The subdirectory shouldn't exist yet,
// but should be created by the call to check_or_create_data_subdir.
- test_assert(r && (errno == ENOENT));
- test_assert(!check_or_create_data_subdir(subdir));
- test_assert(is_private_dir(subpath));
+ tt_assert(r && (errno == ENOENT));
+ tt_assert(!check_or_create_data_subdir(subdir));
+ tt_assert(is_private_dir(subpath));
// The check should return 0, if the directory already exists
// and is private to the user.
- test_assert(!check_or_create_data_subdir(subdir));
+ tt_assert(!check_or_create_data_subdir(subdir));
r = stat(subpath, &st);
if (r) {
@@ -245,9 +245,9 @@ test_config_check_or_create_data_subdir(void *arg)
// If the directory exists, but its mode is too permissive
// a call to check_or_create_data_subdir should reset the mode.
- test_assert(!is_private_dir(subpath));
- test_assert(!check_or_create_data_subdir(subdir));
- test_assert(is_private_dir(subpath));
+ tt_assert(!is_private_dir(subpath));
+ tt_assert(!check_or_create_data_subdir(subdir));
+ tt_assert(is_private_dir(subpath));
#endif
done:
@@ -293,20 +293,20 @@ test_config_write_to_data_subdir(void *arg)
#endif
// Write attempt shoudl fail, if subdirectory doesn't exist.
- test_assert(write_to_data_subdir(subdir, fname, str, NULL));
- test_assert(! check_or_create_data_subdir(subdir));
+ tt_assert(write_to_data_subdir(subdir, fname, str, NULL));
+ tt_assert(! check_or_create_data_subdir(subdir));
// Content of file after write attempt should be
// equal to the original string.
- test_assert(!write_to_data_subdir(subdir, fname, str, NULL));
+ tt_assert(!write_to_data_subdir(subdir, fname, str, NULL));
cp = read_file_to_str(filepath, 0, NULL);
- test_streq(cp, str);
+ tt_str_op(cp,==, str);
tor_free(cp);
// A second write operation should overwrite the old content.
- test_assert(!write_to_data_subdir(subdir, fname, str, NULL));
+ tt_assert(!write_to_data_subdir(subdir, fname, str, NULL));
cp = read_file_to_str(filepath, 0, NULL);
- test_streq(cp, str);
+ tt_str_op(cp,==, str);
tor_free(cp);
done:
@@ -327,48 +327,48 @@ good_bridge_line_test(const char *string, const char *test_addrport,
{
char *tmp = NULL;
bridge_line_t *bridge_line = parse_bridge_line(string);
- test_assert(bridge_line);
+ tt_assert(bridge_line);
/* test addrport */
tmp = tor_strdup(fmt_addrport(&bridge_line->addr, bridge_line->port));
- test_streq(test_addrport, tmp);
+ tt_str_op(test_addrport,==, tmp);
tor_free(tmp);
/* If we were asked to validate a digest, but we did not get a
digest after parsing, we failed. */
if (test_digest && tor_digest_is_zero(bridge_line->digest))
- test_assert(0);
+ tt_assert(0);
/* If we were not asked to validate a digest, and we got a digest
after parsing, we failed again. */
if (!test_digest && !tor_digest_is_zero(bridge_line->digest))
- test_assert(0);
+ tt_assert(0);
/* If we were asked to validate a digest, and we got a digest after
parsing, make sure it's correct. */
if (test_digest) {
tmp = tor_strdup(hex_str(bridge_line->digest, DIGEST_LEN));
tor_strlower(tmp);
- test_streq(test_digest, tmp);
+ tt_str_op(test_digest,==, tmp);
tor_free(tmp);
}
/* If we were asked to validate a transport name, make sure tha it
matches with the transport name that was parsed. */
if (test_transport && !bridge_line->transport_name)
- test_assert(0);
+ tt_assert(0);
if (!test_transport && bridge_line->transport_name)
- test_assert(0);
+ tt_assert(0);
if (test_transport)
- test_streq(test_transport, bridge_line->transport_name);
+ tt_str_op(test_transport,==, bridge_line->transport_name);
/* Validate the SOCKS argument smartlist. */
if (test_socks_args && !bridge_line->socks_args)
- test_assert(0);
+ tt_assert(0);
if (!test_socks_args && bridge_line->socks_args)
- test_assert(0);
+ tt_assert(0);
if (test_socks_args)
- test_assert(smartlist_strings_eq(test_socks_args,
+ tt_assert(smartlist_strings_eq(test_socks_args,
bridge_line->socks_args));
done:
@@ -384,7 +384,7 @@ bad_bridge_line_test(const char *string)
bridge_line_t *bridge_line = parse_bridge_line(string);
if (bridge_line)
TT_FAIL(("%s was supposed to fail, but it didn't.", string));
- test_assert(!bridge_line);
+ tt_assert(!bridge_line);
done:
bridge_line_free(bridge_line);
@@ -492,18 +492,18 @@ test_config_parse_transport_options_line(void *arg)
{ /* too small line */
options_sl = get_options_from_transport_options_line("valley", NULL);
- test_assert(!options_sl);
+ tt_assert(!options_sl);
}
{ /* no k=v values */
options_sl = get_options_from_transport_options_line("hit it!", NULL);
- test_assert(!options_sl);
+ tt_assert(!options_sl);
}
{ /* correct line, but wrong transport specified */
options_sl =
get_options_from_transport_options_line("trebuchet k=v", "rook");
- test_assert(!options_sl);
+ tt_assert(!options_sl);
}
{ /* correct -- no transport specified */
@@ -514,8 +514,8 @@ test_config_parse_transport_options_line(void *arg)
options_sl =
get_options_from_transport_options_line("rook ladi=dadi weliketo=party",
NULL);
- test_assert(options_sl);
- test_assert(smartlist_strings_eq(options_sl, sl_tmp));
+ tt_assert(options_sl);
+ tt_assert(smartlist_strings_eq(options_sl, sl_tmp));
SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
smartlist_free(sl_tmp);
@@ -533,8 +533,8 @@ test_config_parse_transport_options_line(void *arg)
options_sl =
get_options_from_transport_options_line("rook ladi=dadi weliketo=party",
"rook");
- test_assert(options_sl);
- test_assert(smartlist_strings_eq(options_sl, sl_tmp));
+ tt_assert(options_sl);
+ tt_assert(smartlist_strings_eq(options_sl, sl_tmp));
SMARTLIST_FOREACH(sl_tmp, char *, s, tor_free(s));
smartlist_free(sl_tmp);
sl_tmp = NULL;
@@ -609,84 +609,84 @@ test_config_parse_transport_plugin_line(void *arg)
/* Bad transport lines - too short */
r = parse_transport_line(options, "bad", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options, "bad", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options, "bad bad", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options, "bad bad", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
/* Test transport list parsing */
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 0);
- test_assert(r == 0);
+ tt_assert(r == 0);
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 1);
- test_assert(r == 0);
+ tt_assert(r == 0);
r = parse_transport_line(options,
"transport_1,transport_2 exec /usr/bin/fake-transport", 1, 0);
- test_assert(r == 0);
+ tt_assert(r == 0);
r = parse_transport_line(options,
"transport_1,transport_2 exec /usr/bin/fake-transport", 1, 1);
- test_assert(r == 0);
+ tt_assert(r == 0);
/* Bad transport identifiers */
r = parse_transport_line(options,
"transport_* exec /usr/bin/fake-transport", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_* exec /usr/bin/fake-transport", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
/* Check SOCKS cases for client transport */
r = parse_transport_line(options,
"transport_1 socks4 1.2.3.4:567", 1, 0);
- test_assert(r == 0);
+ tt_assert(r == 0);
r = parse_transport_line(options,
"transport_1 socks5 1.2.3.4:567", 1, 0);
- test_assert(r == 0);
+ tt_assert(r == 0);
/* Proxy case for server transport */
r = parse_transport_line(options,
"transport_1 proxy 1.2.3.4:567", 1, 1);
- test_assert(r == 0);
+ tt_assert(r == 0);
/* Multiple-transport error exit */
r = parse_transport_line(options,
"transport_1,transport_2 socks5 1.2.3.4:567", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_1,transport_2 proxy 1.2.3.4:567", 1, 1);
/* No port error exit */
r = parse_transport_line(options,
"transport_1 socks5 1.2.3.4", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_1 proxy 1.2.3.4", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
/* Unparsable address error exit */
r = parse_transport_line(options,
"transport_1 socks5 1.2.3:6x7", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_1 proxy 1.2.3:6x7", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
/* "Strange {Client|Server}TransportPlugin field" error exit */
r = parse_transport_line(options,
"transport_1 foo bar", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_1 foo bar", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
/* No sandbox mode error exit */
tmp = options->Sandbox;
options->Sandbox = 1;
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 0);
- test_assert(r < 0);
+ tt_assert(r < 0);
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 1, 1);
- test_assert(r < 0);
+ tt_assert(r < 0);
options->Sandbox = tmp;
/*
@@ -698,15 +698,15 @@ test_config_parse_transport_plugin_line(void *arg)
pt_kickstart_proxy_mock_call_count;
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 0, 1);
- test_assert(r == 0);
- test_assert(pt_kickstart_proxy_mock_call_count ==
+ tt_assert(r == 0);
+ tt_assert(pt_kickstart_proxy_mock_call_count ==
old_pt_kickstart_proxy_mock_call_count + 1);
UNMOCK(pt_kickstart_proxy);
/* This one hits a log line in the !validate_only case only */
r = parse_transport_line(options,
"transport_1 proxy 1.2.3.4:567", 0, 1);
- test_assert(r == 0);
+ tt_assert(r == 0);
/* Check mocked client transport cases */
MOCK(pt_kickstart_proxy, pt_kickstart_proxy_mock);
@@ -724,17 +724,17 @@ test_config_parse_transport_plugin_line(void *arg)
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 0, 0);
/* Should have succeeded */
- test_assert(r == 0);
+ tt_assert(r == 0);
/* transport_is_needed() should have been called */
- test_assert(transport_is_needed_mock_call_count ==
+ tt_assert(transport_is_needed_mock_call_count ==
old_transport_is_needed_mock_call_count + 1);
/*
* pt_kickstart_proxy() and transport_add_from_config() should
* not have been called.
*/
- test_assert(pt_kickstart_proxy_mock_call_count ==
+ tt_assert(pt_kickstart_proxy_mock_call_count ==
old_pt_kickstart_proxy_mock_call_count);
- test_assert(transport_add_from_config_mock_call_count ==
+ tt_assert(transport_add_from_config_mock_call_count ==
old_transport_add_from_config_mock_call_count);
/* Necessary transport case */
@@ -748,17 +748,17 @@ test_config_parse_transport_plugin_line(void *arg)
r = parse_transport_line(options,
"transport_1 exec /usr/bin/fake-transport", 0, 0);
/* Should have succeeded */
- test_assert(r == 0);
+ tt_assert(r == 0);
/*
* transport_is_needed() and pt_kickstart_proxy() should have been
* called.
*/
- test_assert(pt_kickstart_proxy_mock_call_count ==
+ tt_assert(pt_kickstart_proxy_mock_call_count ==
old_pt_kickstart_proxy_mock_call_count + 1);
- test_assert(transport_is_needed_mock_call_count ==
+ tt_assert(transport_is_needed_mock_call_count ==
old_transport_is_needed_mock_call_count + 1);
/* transport_add_from_config() should not have been called. */
- test_assert(transport_add_from_config_mock_call_count ==
+ tt_assert(transport_add_from_config_mock_call_count ==
old_transport_add_from_config_mock_call_count);
/* proxy case */
@@ -772,17 +772,17 @@ test_config_parse_transport_plugin_line(void *arg)
r = parse_transport_line(options,
"transport_1 socks5 1.2.3.4:567", 0, 0);
/* Should have succeeded */
- test_assert(r == 0);
+ tt_assert(r == 0);
/*
* transport_is_needed() and transport_add_from_config() should have
* been called.
*/
- test_assert(transport_add_from_config_mock_call_count ==
+ tt_assert(transport_add_from_config_mock_call_count ==
old_transport_add_from_config_mock_call_count + 1);
- test_assert(transport_is_needed_mock_call_count ==
+ tt_assert(transport_is_needed_mock_call_count ==
old_transport_is_needed_mock_call_count + 1);
/* pt_kickstart_proxy() should not have been called. */
- test_assert(pt_kickstart_proxy_mock_call_count ==
+ tt_assert(pt_kickstart_proxy_mock_call_count ==
old_pt_kickstart_proxy_mock_call_count);
/* Done with mocked client transport cases */
@@ -823,7 +823,7 @@ test_config_fix_my_family(void *arg)
TT_FAIL(("options_validate failed: %s", err));
}
- test_streq(options->MyFamily, "$1111111111111111111111111111111111111111, "
+ tt_str_op(options->MyFamily,==, "$1111111111111111111111111111111111111111, "
"$1111111111111111111111111111111111111112, "
"$1111111111111111111111111111111111111113");
diff --git a/src/test/test_containers.c b/src/test/test_containers.c
index 067c4c1907..d0972dd126 100644
--- a/src/test/test_containers.c
+++ b/src/test/test_containers.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -29,7 +29,7 @@ compare_strs_for_bsearch_(const void *a, const void **b)
/** Helper: return a tristate based on comparing the strings in *<b>a</b> and
* *<b>b</b>, excluding a's first character, and ignoring case. */
static int
-compare_without_first_ch_(const void *a, const void **b)
+cmp_without_first_(const void *a, const void **b)
{
const char *s1 = a, *s2 = *b;
return strcasecmp(s1+1, s2);
@@ -37,237 +37,256 @@ compare_without_first_ch_(const void *a, const void **b)
/** Run unit tests for basic dynamic-sized array functionality. */
static void
-test_container_smartlist_basic(void)
+test_container_smartlist_basic(void *arg)
{
smartlist_t *sl;
+ char *v0 = tor_strdup("v0");
+ char *v1 = tor_strdup("v1");
+ char *v2 = tor_strdup("v2");
+ char *v3 = tor_strdup("v3");
+ char *v4 = tor_strdup("v4");
+ char *v22 = tor_strdup("v22");
+ char *v99 = tor_strdup("v99");
+ char *v555 = tor_strdup("v555");
/* XXXX test sort_digests, uniq_strings, uniq_digests */
/* Test smartlist add, del_keeporder, insert, get. */
+ (void)arg;
sl = smartlist_new();
- smartlist_add(sl, (void*)1);
- smartlist_add(sl, (void*)2);
- smartlist_add(sl, (void*)3);
- smartlist_add(sl, (void*)4);
+ smartlist_add(sl, v1);
+ smartlist_add(sl, v2);
+ smartlist_add(sl, v3);
+ smartlist_add(sl, v4);
smartlist_del_keeporder(sl, 1);
- smartlist_insert(sl, 1, (void*)22);
- smartlist_insert(sl, 0, (void*)0);
- smartlist_insert(sl, 5, (void*)555);
- test_eq_ptr((void*)0, smartlist_get(sl,0));
- test_eq_ptr((void*)1, smartlist_get(sl,1));
- test_eq_ptr((void*)22, smartlist_get(sl,2));
- test_eq_ptr((void*)3, smartlist_get(sl,3));
- test_eq_ptr((void*)4, smartlist_get(sl,4));
- test_eq_ptr((void*)555, smartlist_get(sl,5));
+ smartlist_insert(sl, 1, v22);
+ smartlist_insert(sl, 0, v0);
+ smartlist_insert(sl, 5, v555);
+ tt_ptr_op(v0,==, smartlist_get(sl,0));
+ tt_ptr_op(v1,==, smartlist_get(sl,1));
+ tt_ptr_op(v22,==, smartlist_get(sl,2));
+ tt_ptr_op(v3,==, smartlist_get(sl,3));
+ tt_ptr_op(v4,==, smartlist_get(sl,4));
+ tt_ptr_op(v555,==, smartlist_get(sl,5));
/* Try deleting in the middle. */
smartlist_del(sl, 1);
- test_eq_ptr((void*)555, smartlist_get(sl, 1));
+ tt_ptr_op(v555,==, smartlist_get(sl, 1));
/* Try deleting at the end. */
smartlist_del(sl, 4);
- test_eq(4, smartlist_len(sl));
+ tt_int_op(4,==, smartlist_len(sl));
/* test isin. */
- test_assert(smartlist_contains(sl, (void*)3));
- test_assert(!smartlist_contains(sl, (void*)99));
+ tt_assert(smartlist_contains(sl, v3));
+ tt_assert(!smartlist_contains(sl, v99));
done:
smartlist_free(sl);
+ tor_free(v0);
+ tor_free(v1);
+ tor_free(v2);
+ tor_free(v3);
+ tor_free(v4);
+ tor_free(v22);
+ tor_free(v99);
+ tor_free(v555);
}
/** Run unit tests for smartlist-of-strings functionality. */
static void
-test_container_smartlist_strings(void)
+test_container_smartlist_strings(void *arg)
{
smartlist_t *sl = smartlist_new();
char *cp=NULL, *cp_alloc=NULL;
size_t sz;
/* Test split and join */
- test_eq(0, smartlist_len(sl));
+ (void)arg;
+ tt_int_op(0,==, smartlist_len(sl));
smartlist_split_string(sl, "abc", ":", 0, 0);
- test_eq(1, smartlist_len(sl));
- test_streq("abc", smartlist_get(sl, 0));
+ tt_int_op(1,==, smartlist_len(sl));
+ tt_str_op("abc",==, smartlist_get(sl, 0));
smartlist_split_string(sl, "a::bc::", "::", 0, 0);
- test_eq(4, smartlist_len(sl));
- test_streq("a", smartlist_get(sl, 1));
- test_streq("bc", smartlist_get(sl, 2));
- test_streq("", smartlist_get(sl, 3));
+ tt_int_op(4,==, smartlist_len(sl));
+ tt_str_op("a",==, smartlist_get(sl, 1));
+ tt_str_op("bc",==, smartlist_get(sl, 2));
+ tt_str_op("",==, smartlist_get(sl, 3));
cp_alloc = smartlist_join_strings(sl, "", 0, NULL);
- test_streq(cp_alloc, "abcabc");
+ tt_str_op(cp_alloc,==, "abcabc");
tor_free(cp_alloc);
cp_alloc = smartlist_join_strings(sl, "!", 0, NULL);
- test_streq(cp_alloc, "abc!a!bc!");
+ tt_str_op(cp_alloc,==, "abc!a!bc!");
tor_free(cp_alloc);
cp_alloc = smartlist_join_strings(sl, "XY", 0, NULL);
- test_streq(cp_alloc, "abcXYaXYbcXY");
+ tt_str_op(cp_alloc,==, "abcXYaXYbcXY");
tor_free(cp_alloc);
cp_alloc = smartlist_join_strings(sl, "XY", 1, NULL);
- test_streq(cp_alloc, "abcXYaXYbcXYXY");
+ tt_str_op(cp_alloc,==, "abcXYaXYbcXYXY");
tor_free(cp_alloc);
cp_alloc = smartlist_join_strings(sl, "", 1, NULL);
- test_streq(cp_alloc, "abcabc");
+ tt_str_op(cp_alloc,==, "abcabc");
tor_free(cp_alloc);
smartlist_split_string(sl, "/def/ /ghijk", "/", 0, 0);
- test_eq(8, smartlist_len(sl));
- test_streq("", smartlist_get(sl, 4));
- test_streq("def", smartlist_get(sl, 5));
- test_streq(" ", smartlist_get(sl, 6));
- test_streq("ghijk", smartlist_get(sl, 7));
+ tt_int_op(8,==, smartlist_len(sl));
+ tt_str_op("",==, smartlist_get(sl, 4));
+ tt_str_op("def",==, smartlist_get(sl, 5));
+ tt_str_op(" ",==, smartlist_get(sl, 6));
+ tt_str_op("ghijk",==, smartlist_get(sl, 7));
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
smartlist_split_string(sl, "a,bbd,cdef", ",", SPLIT_SKIP_SPACE, 0);
- test_eq(3, smartlist_len(sl));
- test_streq("a", smartlist_get(sl,0));
- test_streq("bbd", smartlist_get(sl,1));
- test_streq("cdef", smartlist_get(sl,2));
+ tt_int_op(3,==, smartlist_len(sl));
+ tt_str_op("a",==, smartlist_get(sl,0));
+ tt_str_op("bbd",==, smartlist_get(sl,1));
+ tt_str_op("cdef",==, smartlist_get(sl,2));
smartlist_split_string(sl, " z <> zhasd <> <> bnud<> ", "<>",
SPLIT_SKIP_SPACE, 0);
- test_eq(8, smartlist_len(sl));
- test_streq("z", smartlist_get(sl,3));
- test_streq("zhasd", smartlist_get(sl,4));
- test_streq("", smartlist_get(sl,5));
- test_streq("bnud", smartlist_get(sl,6));
- test_streq("", smartlist_get(sl,7));
+ tt_int_op(8,==, smartlist_len(sl));
+ tt_str_op("z",==, smartlist_get(sl,3));
+ tt_str_op("zhasd",==, smartlist_get(sl,4));
+ tt_str_op("",==, smartlist_get(sl,5));
+ tt_str_op("bnud",==, smartlist_get(sl,6));
+ tt_str_op("",==, smartlist_get(sl,7));
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
smartlist_split_string(sl, " ab\tc \td ef ", NULL,
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- test_eq(4, smartlist_len(sl));
- test_streq("ab", smartlist_get(sl,0));
- test_streq("c", smartlist_get(sl,1));
- test_streq("d", smartlist_get(sl,2));
- test_streq("ef", smartlist_get(sl,3));
+ tt_int_op(4,==, smartlist_len(sl));
+ tt_str_op("ab",==, smartlist_get(sl,0));
+ tt_str_op("c",==, smartlist_get(sl,1));
+ tt_str_op("d",==, smartlist_get(sl,2));
+ tt_str_op("ef",==, smartlist_get(sl,3));
smartlist_split_string(sl, "ghi\tj", NULL,
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- test_eq(6, smartlist_len(sl));
- test_streq("ghi", smartlist_get(sl,4));
- test_streq("j", smartlist_get(sl,5));
+ tt_int_op(6,==, smartlist_len(sl));
+ tt_str_op("ghi",==, smartlist_get(sl,4));
+ tt_str_op("j",==, smartlist_get(sl,5));
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
cp_alloc = smartlist_join_strings(sl, "XY", 0, NULL);
- test_streq(cp_alloc, "");
+ tt_str_op(cp_alloc,==, "");
tor_free(cp_alloc);
cp_alloc = smartlist_join_strings(sl, "XY", 1, NULL);
- test_streq(cp_alloc, "XY");
+ tt_str_op(cp_alloc,==, "XY");
tor_free(cp_alloc);
smartlist_split_string(sl, " z <> zhasd <> <> bnud<> ", "<>",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- test_eq(3, smartlist_len(sl));
- test_streq("z", smartlist_get(sl, 0));
- test_streq("zhasd", smartlist_get(sl, 1));
- test_streq("bnud", smartlist_get(sl, 2));
+ tt_int_op(3,==, smartlist_len(sl));
+ tt_str_op("z",==, smartlist_get(sl, 0));
+ tt_str_op("zhasd",==, smartlist_get(sl, 1));
+ tt_str_op("bnud",==, smartlist_get(sl, 2));
smartlist_split_string(sl, " z <> zhasd <> <> bnud<> ", "<>",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 2);
- test_eq(5, smartlist_len(sl));
- test_streq("z", smartlist_get(sl, 3));
- test_streq("zhasd <> <> bnud<>", smartlist_get(sl, 4));
+ tt_int_op(5,==, smartlist_len(sl));
+ tt_str_op("z",==, smartlist_get(sl, 3));
+ tt_str_op("zhasd <> <> bnud<>",==, smartlist_get(sl, 4));
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
smartlist_split_string(sl, "abcd\n", "\n",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- test_eq(1, smartlist_len(sl));
- test_streq("abcd", smartlist_get(sl, 0));
+ tt_int_op(1,==, smartlist_len(sl));
+ tt_str_op("abcd",==, smartlist_get(sl, 0));
smartlist_split_string(sl, "efgh", "\n",
SPLIT_SKIP_SPACE|SPLIT_IGNORE_BLANK, 0);
- test_eq(2, smartlist_len(sl));
- test_streq("efgh", smartlist_get(sl, 1));
+ tt_int_op(2,==, smartlist_len(sl));
+ tt_str_op("efgh",==, smartlist_get(sl, 1));
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
/* Test swapping, shuffling, and sorting. */
smartlist_split_string(sl, "the,onion,router,by,arma,and,nickm", ",", 0, 0);
- test_eq(7, smartlist_len(sl));
+ tt_int_op(7,==, smartlist_len(sl));
smartlist_sort(sl, compare_strs_);
cp_alloc = smartlist_join_strings(sl, ",", 0, NULL);
- test_streq(cp_alloc,"and,arma,by,nickm,onion,router,the");
+ tt_str_op(cp_alloc,==, "and,arma,by,nickm,onion,router,the");
tor_free(cp_alloc);
smartlist_swap(sl, 1, 5);
cp_alloc = smartlist_join_strings(sl, ",", 0, NULL);
- test_streq(cp_alloc,"and,router,by,nickm,onion,arma,the");
+ tt_str_op(cp_alloc,==, "and,router,by,nickm,onion,arma,the");
tor_free(cp_alloc);
smartlist_shuffle(sl);
- test_eq(7, smartlist_len(sl));
- test_assert(smartlist_contains_string(sl, "and"));
- test_assert(smartlist_contains_string(sl, "router"));
- test_assert(smartlist_contains_string(sl, "by"));
- test_assert(smartlist_contains_string(sl, "nickm"));
- test_assert(smartlist_contains_string(sl, "onion"));
- test_assert(smartlist_contains_string(sl, "arma"));
- test_assert(smartlist_contains_string(sl, "the"));
+ tt_int_op(7,==, smartlist_len(sl));
+ tt_assert(smartlist_contains_string(sl, "and"));
+ tt_assert(smartlist_contains_string(sl, "router"));
+ tt_assert(smartlist_contains_string(sl, "by"));
+ tt_assert(smartlist_contains_string(sl, "nickm"));
+ tt_assert(smartlist_contains_string(sl, "onion"));
+ tt_assert(smartlist_contains_string(sl, "arma"));
+ tt_assert(smartlist_contains_string(sl, "the"));
/* Test bsearch. */
smartlist_sort(sl, compare_strs_);
- test_streq("nickm", smartlist_bsearch(sl, "zNicKM",
- compare_without_first_ch_));
- test_streq("and", smartlist_bsearch(sl, " AND", compare_without_first_ch_));
- test_eq_ptr(NULL, smartlist_bsearch(sl, " ANz", compare_without_first_ch_));
+ tt_str_op("nickm",==, smartlist_bsearch(sl, "zNicKM",
+ cmp_without_first_));
+ tt_str_op("and",==,
+ smartlist_bsearch(sl, " AND", cmp_without_first_));
+ tt_ptr_op(NULL,==, smartlist_bsearch(sl, " ANz", cmp_without_first_));
/* Test bsearch_idx */
{
int f;
smartlist_t *tmp = NULL;
- test_eq(0, smartlist_bsearch_idx(sl," aaa",compare_without_first_ch_,&f));
- test_eq(f, 0);
- test_eq(0, smartlist_bsearch_idx(sl," and",compare_without_first_ch_,&f));
- test_eq(f, 1);
- test_eq(1, smartlist_bsearch_idx(sl," arm",compare_without_first_ch_,&f));
- test_eq(f, 0);
- test_eq(1, smartlist_bsearch_idx(sl," arma",compare_without_first_ch_,&f));
- test_eq(f, 1);
- test_eq(2, smartlist_bsearch_idx(sl," armb",compare_without_first_ch_,&f));
- test_eq(f, 0);
- test_eq(7, smartlist_bsearch_idx(sl," zzzz",compare_without_first_ch_,&f));
- test_eq(f, 0);
+ tt_int_op(0,==,smartlist_bsearch_idx(sl," aaa",cmp_without_first_,&f));
+ tt_int_op(f,==, 0);
+ tt_int_op(0,==, smartlist_bsearch_idx(sl," and",cmp_without_first_,&f));
+ tt_int_op(f,==, 1);
+ tt_int_op(1,==, smartlist_bsearch_idx(sl," arm",cmp_without_first_,&f));
+ tt_int_op(f,==, 0);
+ tt_int_op(1,==, smartlist_bsearch_idx(sl," arma",cmp_without_first_,&f));
+ tt_int_op(f,==, 1);
+ tt_int_op(2,==, smartlist_bsearch_idx(sl," armb",cmp_without_first_,&f));
+ tt_int_op(f,==, 0);
+ tt_int_op(7,==, smartlist_bsearch_idx(sl," zzzz",cmp_without_first_,&f));
+ tt_int_op(f,==, 0);
/* Test trivial cases for list of length 0 or 1 */
tmp = smartlist_new();
- test_eq(0, smartlist_bsearch_idx(tmp, "foo",
+ tt_int_op(0,==, smartlist_bsearch_idx(tmp, "foo",
compare_strs_for_bsearch_, &f));
- test_eq(f, 0);
+ tt_int_op(f,==, 0);
smartlist_insert(tmp, 0, (void *)("bar"));
- test_eq(1, smartlist_bsearch_idx(tmp, "foo",
+ tt_int_op(1,==, smartlist_bsearch_idx(tmp, "foo",
compare_strs_for_bsearch_, &f));
- test_eq(f, 0);
- test_eq(0, smartlist_bsearch_idx(tmp, "aaa",
+ tt_int_op(f,==, 0);
+ tt_int_op(0,==, smartlist_bsearch_idx(tmp, "aaa",
compare_strs_for_bsearch_, &f));
- test_eq(f, 0);
- test_eq(0, smartlist_bsearch_idx(tmp, "bar",
+ tt_int_op(f,==, 0);
+ tt_int_op(0,==, smartlist_bsearch_idx(tmp, "bar",
compare_strs_for_bsearch_, &f));
- test_eq(f, 1);
+ tt_int_op(f,==, 1);
/* ... and one for length 2 */
smartlist_insert(tmp, 1, (void *)("foo"));
- test_eq(1, smartlist_bsearch_idx(tmp, "foo",
+ tt_int_op(1,==, smartlist_bsearch_idx(tmp, "foo",
compare_strs_for_bsearch_, &f));
- test_eq(f, 1);
- test_eq(2, smartlist_bsearch_idx(tmp, "goo",
+ tt_int_op(f,==, 1);
+ tt_int_op(2,==, smartlist_bsearch_idx(tmp, "goo",
compare_strs_for_bsearch_, &f));
- test_eq(f, 0);
+ tt_int_op(f,==, 0);
smartlist_free(tmp);
}
/* Test reverse() and pop_last() */
smartlist_reverse(sl);
cp_alloc = smartlist_join_strings(sl, ",", 0, NULL);
- test_streq(cp_alloc,"the,router,onion,nickm,by,arma,and");
+ tt_str_op(cp_alloc,==, "the,router,onion,nickm,by,arma,and");
tor_free(cp_alloc);
cp_alloc = smartlist_pop_last(sl);
- test_streq(cp_alloc, "and");
+ tt_str_op(cp_alloc,==, "and");
tor_free(cp_alloc);
- test_eq(smartlist_len(sl), 6);
+ tt_int_op(smartlist_len(sl),==, 6);
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
cp_alloc = smartlist_pop_last(sl);
- test_eq_ptr(cp_alloc, NULL);
+ tt_ptr_op(cp_alloc,==, NULL);
/* Test uniq() */
smartlist_split_string(sl,
@@ -276,16 +295,16 @@ test_container_smartlist_strings(void)
smartlist_sort(sl, compare_strs_);
smartlist_uniq(sl, compare_strs_, tor_free_);
cp_alloc = smartlist_join_strings(sl, ",", 0, NULL);
- test_streq(cp_alloc, "50,a,canal,man,noon,panama,plan,radar");
+ tt_str_op(cp_alloc,==, "50,a,canal,man,noon,panama,plan,radar");
tor_free(cp_alloc);
/* Test contains_string, contains_string_case and contains_int_as_string */
- test_assert(smartlist_contains_string(sl, "noon"));
- test_assert(!smartlist_contains_string(sl, "noonoon"));
- test_assert(smartlist_contains_string_case(sl, "nOOn"));
- test_assert(!smartlist_contains_string_case(sl, "nooNooN"));
- test_assert(smartlist_contains_int_as_string(sl, 50));
- test_assert(!smartlist_contains_int_as_string(sl, 60));
+ tt_assert(smartlist_contains_string(sl, "noon"));
+ tt_assert(!smartlist_contains_string(sl, "noonoon"));
+ tt_assert(smartlist_contains_string_case(sl, "nOOn"));
+ tt_assert(!smartlist_contains_string_case(sl, "nooNooN"));
+ tt_assert(smartlist_contains_int_as_string(sl, 50));
+ tt_assert(!smartlist_contains_int_as_string(sl, 60));
/* Test smartlist_choose */
{
@@ -293,7 +312,7 @@ test_container_smartlist_strings(void)
int allsame = 1;
int allin = 1;
void *first = smartlist_choose(sl);
- test_assert(smartlist_contains(sl, first));
+ tt_assert(smartlist_contains(sl, first));
for (i = 0; i < 100; ++i) {
void *second = smartlist_choose(sl);
if (second != first)
@@ -301,8 +320,8 @@ test_container_smartlist_strings(void)
if (!smartlist_contains(sl, second))
allin = 0;
}
- test_assert(!allsame);
- test_assert(allin);
+ tt_assert(!allsame);
+ tt_assert(allin);
}
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
smartlist_clear(sl);
@@ -312,17 +331,17 @@ test_container_smartlist_strings(void)
"Some say the Earth will end in ice and some in fire",
" ", 0, 0);
cp = smartlist_get(sl, 4);
- test_streq(cp, "will");
+ tt_str_op(cp,==, "will");
smartlist_add(sl, cp);
smartlist_remove(sl, cp);
tor_free(cp);
cp_alloc = smartlist_join_strings(sl, ",", 0, NULL);
- test_streq(cp_alloc, "Some,say,the,Earth,fire,end,in,ice,and,some,in");
+ tt_str_op(cp_alloc,==, "Some,say,the,Earth,fire,end,in,ice,and,some,in");
tor_free(cp_alloc);
smartlist_string_remove(sl, "in");
cp_alloc = smartlist_join_strings2(sl, "+XX", 1, 0, &sz);
- test_streq(cp_alloc, "Some+say+the+Earth+fire+end+some+ice+and");
- test_eq((int)sz, 40);
+ tt_str_op(cp_alloc,==, "Some+say+the+Earth+fire+end+some+ice+and");
+ tt_int_op((int)sz,==, 40);
done:
@@ -333,7 +352,7 @@ test_container_smartlist_strings(void)
/** Run unit tests for smartlist set manipulation functions. */
static void
-test_container_smartlist_overlap(void)
+test_container_smartlist_overlap(void *arg)
{
smartlist_t *sl = smartlist_new();
smartlist_t *ints = smartlist_new();
@@ -341,6 +360,7 @@ test_container_smartlist_overlap(void)
smartlist_t *evens = smartlist_new();
smartlist_t *primes = smartlist_new();
int i;
+ (void)arg;
for (i=1; i < 10; i += 2)
smartlist_add(odds, (void*)(uintptr_t)i);
for (i=0; i < 10; i += 2)
@@ -349,7 +369,7 @@ test_container_smartlist_overlap(void)
/* add_all */
smartlist_add_all(ints, odds);
smartlist_add_all(ints, evens);
- test_eq(smartlist_len(ints), 10);
+ tt_int_op(smartlist_len(ints),==, 10);
smartlist_add(primes, (void*)2);
smartlist_add(primes, (void*)3);
@@ -357,24 +377,24 @@ test_container_smartlist_overlap(void)
smartlist_add(primes, (void*)7);
/* overlap */
- test_assert(smartlist_overlap(ints, odds));
- test_assert(smartlist_overlap(odds, primes));
- test_assert(smartlist_overlap(evens, primes));
- test_assert(!smartlist_overlap(odds, evens));
+ tt_assert(smartlist_overlap(ints, odds));
+ tt_assert(smartlist_overlap(odds, primes));
+ tt_assert(smartlist_overlap(evens, primes));
+ tt_assert(!smartlist_overlap(odds, evens));
/* intersect */
smartlist_add_all(sl, odds);
smartlist_intersect(sl, primes);
- test_eq(smartlist_len(sl), 3);
- test_assert(smartlist_contains(sl, (void*)3));
- test_assert(smartlist_contains(sl, (void*)5));
- test_assert(smartlist_contains(sl, (void*)7));
+ tt_int_op(smartlist_len(sl),==, 3);
+ tt_assert(smartlist_contains(sl, (void*)3));
+ tt_assert(smartlist_contains(sl, (void*)5));
+ tt_assert(smartlist_contains(sl, (void*)7));
/* subtract */
smartlist_add_all(sl, primes);
smartlist_subtract(sl, odds);
- test_eq(smartlist_len(sl), 1);
- test_assert(smartlist_contains(sl, (void*)2));
+ tt_int_op(smartlist_len(sl),==, 1);
+ tt_assert(smartlist_contains(sl, (void*)2));
done:
smartlist_free(odds);
@@ -386,31 +406,32 @@ test_container_smartlist_overlap(void)
/** Run unit tests for smartlist-of-digests functions. */
static void
-test_container_smartlist_digests(void)
+test_container_smartlist_digests(void *arg)
{
smartlist_t *sl = smartlist_new();
/* contains_digest */
+ (void)arg;
smartlist_add(sl, tor_memdup("AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN));
smartlist_add(sl, tor_memdup("\00090AAB2AAAAaasdAAAAA", DIGEST_LEN));
smartlist_add(sl, tor_memdup("\00090AAB2AAAAaasdAAAAA", DIGEST_LEN));
- test_eq(0, smartlist_contains_digest(NULL, "AAAAAAAAAAAAAAAAAAAA"));
- test_assert(smartlist_contains_digest(sl, "AAAAAAAAAAAAAAAAAAAA"));
- test_assert(smartlist_contains_digest(sl, "\00090AAB2AAAAaasdAAAAA"));
- test_eq(0, smartlist_contains_digest(sl, "\00090AAB2AAABaasdAAAAA"));
+ tt_int_op(0,==, smartlist_contains_digest(NULL, "AAAAAAAAAAAAAAAAAAAA"));
+ tt_assert(smartlist_contains_digest(sl, "AAAAAAAAAAAAAAAAAAAA"));
+ tt_assert(smartlist_contains_digest(sl, "\00090AAB2AAAAaasdAAAAA"));
+ tt_int_op(0,==, smartlist_contains_digest(sl, "\00090AAB2AAABaasdAAAAA"));
/* sort digests */
smartlist_sort_digests(sl);
- test_memeq(smartlist_get(sl, 0), "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
- test_memeq(smartlist_get(sl, 1), "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
- test_memeq(smartlist_get(sl, 2), "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN);
- test_eq(3, smartlist_len(sl));
+ tt_mem_op(smartlist_get(sl, 0),==, "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
+ tt_mem_op(smartlist_get(sl, 1),==, "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
+ tt_mem_op(smartlist_get(sl, 2),==, "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN);
+ tt_int_op(3,==, smartlist_len(sl));
/* uniq_digests */
smartlist_uniq_digests(sl);
- test_eq(2, smartlist_len(sl));
- test_memeq(smartlist_get(sl, 0), "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
- test_memeq(smartlist_get(sl, 1), "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN);
+ tt_int_op(2,==, smartlist_len(sl));
+ tt_mem_op(smartlist_get(sl, 0),==, "\00090AAB2AAAAaasdAAAAA", DIGEST_LEN);
+ tt_mem_op(smartlist_get(sl, 1),==, "AAAAAAAAAAAAAAAAAAAA", DIGEST_LEN);
done:
SMARTLIST_FOREACH(sl, char *, cp, tor_free(cp));
@@ -419,13 +440,14 @@ test_container_smartlist_digests(void)
/** Run unit tests for concatenate-a-smartlist-of-strings functions. */
static void
-test_container_smartlist_join(void)
+test_container_smartlist_join(void *arg)
{
smartlist_t *sl = smartlist_new();
smartlist_t *sl2 = smartlist_new(), *sl3 = smartlist_new(),
*sl4 = smartlist_new();
char *joined=NULL;
/* unique, sorted. */
+ (void)arg;
smartlist_split_string(sl,
"Abashments Ambush Anchorman Bacon Banks Borscht "
"Bunks Inhumane Insurance Knish Know Manners "
@@ -441,21 +463,21 @@ test_container_smartlist_join(void)
sl2, char *, cp2,
strcmp(cp1,cp2),
smartlist_add(sl3, cp2)) {
- test_streq(cp1, cp2);
+ tt_str_op(cp1,==, cp2);
smartlist_add(sl4, cp1);
} SMARTLIST_FOREACH_JOIN_END(cp1, cp2);
SMARTLIST_FOREACH(sl3, const char *, cp,
- test_assert(smartlist_contains(sl2, cp) &&
+ tt_assert(smartlist_contains(sl2, cp) &&
!smartlist_contains_string(sl, cp)));
SMARTLIST_FOREACH(sl4, const char *, cp,
- test_assert(smartlist_contains(sl, cp) &&
+ tt_assert(smartlist_contains(sl, cp) &&
smartlist_contains_string(sl2, cp)));
joined = smartlist_join_strings(sl3, ",", 0, NULL);
- test_streq(joined, "Anemias,Anemias,Crossbowmen,Work");
+ tt_str_op(joined,==, "Anemias,Anemias,Crossbowmen,Work");
tor_free(joined);
joined = smartlist_join_strings(sl4, ",", 0, NULL);
- test_streq(joined, "Ambush,Anchorman,Anchorman,Bacon,Inhumane,Insurance,"
+ tt_str_op(joined,==, "Ambush,Anchorman,Anchorman,Bacon,Inhumane,Insurance,"
"Knish,Know,Manners,Manners,Maraschinos,Wombats,Wombats");
tor_free(joined);
@@ -516,18 +538,19 @@ test_container_smartlist_ints_eq(void *arg)
/** Run unit tests for bitarray code */
static void
-test_container_bitarray(void)
+test_container_bitarray(void *arg)
{
bitarray_t *ba = NULL;
int i, j, ok=1;
+ (void)arg;
ba = bitarray_init_zero(1);
- test_assert(ba);
- test_assert(! bitarray_is_set(ba, 0));
+ tt_assert(ba);
+ tt_assert(! bitarray_is_set(ba, 0));
bitarray_set(ba, 0);
- test_assert(bitarray_is_set(ba, 0));
+ tt_assert(bitarray_is_set(ba, 0));
bitarray_clear(ba, 0);
- test_assert(! bitarray_is_set(ba, 0));
+ tt_assert(! bitarray_is_set(ba, 0));
bitarray_free(ba);
ba = bitarray_init_zero(1023);
@@ -542,7 +565,7 @@ test_container_bitarray(void)
if (!bool_eq(bitarray_is_set(ba, j), j%i))
ok = 0;
}
- test_assert(ok);
+ tt_assert(ok);
if (i < 7)
++i;
else if (i == 28)
@@ -559,7 +582,7 @@ test_container_bitarray(void)
/** Run unit tests for digest set code (implemented as a hashtable or as a
* bloom filter) */
static void
-test_container_digestset(void)
+test_container_digestset(void *arg)
{
smartlist_t *included = smartlist_new();
char d[DIGEST_LEN];
@@ -568,6 +591,7 @@ test_container_digestset(void)
int false_positives = 0;
digestset_t *set = NULL;
+ (void)arg;
for (i = 0; i < 1000; ++i) {
crypto_rand(d, DIGEST_LEN);
smartlist_add(included, tor_memdup(d, DIGEST_LEN));
@@ -576,19 +600,19 @@ test_container_digestset(void)
SMARTLIST_FOREACH(included, const char *, cp,
if (digestset_contains(set, cp))
ok = 0);
- test_assert(ok);
+ tt_assert(ok);
SMARTLIST_FOREACH(included, const char *, cp,
digestset_add(set, cp));
SMARTLIST_FOREACH(included, const char *, cp,
if (!digestset_contains(set, cp))
ok = 0);
- test_assert(ok);
+ tt_assert(ok);
for (i = 0; i < 1000; ++i) {
crypto_rand(d, DIGEST_LEN);
if (digestset_contains(set, d))
++false_positives;
}
- test_assert(false_positives < 50); /* Should be far lower. */
+ tt_int_op(50, >, false_positives); /* Should be far lower. */
done:
if (set)
@@ -612,7 +636,7 @@ compare_strings_for_pqueue_(const void *p1, const void *p2)
/** Run unit tests for heap-based priority queue functions. */
static void
-test_container_pqueue(void)
+test_container_pqueue(void *arg)
{
smartlist_t *sl = smartlist_new();
int (*cmp)(const void *, const void*);
@@ -634,6 +658,8 @@ test_container_pqueue(void)
#define OK() smartlist_pqueue_assert_ok(sl, cmp, offset)
+ (void)arg;
+
cmp = compare_strings_for_pqueue_;
smartlist_pqueue_add(sl, cmp, offset, &cows);
smartlist_pqueue_add(sl, cmp, offset, &zebras);
@@ -649,31 +675,31 @@ test_container_pqueue(void)
OK();
- test_eq(smartlist_len(sl), 11);
- test_eq_ptr(smartlist_get(sl, 0), &apples);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &apples);
- test_eq(smartlist_len(sl), 10);
+ tt_int_op(smartlist_len(sl),==, 11);
+ tt_ptr_op(smartlist_get(sl, 0),==, &apples);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &apples);
+ tt_int_op(smartlist_len(sl),==, 10);
OK();
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &cows);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &daschunds);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &cows);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &daschunds);
smartlist_pqueue_add(sl, cmp, offset, &chinchillas);
OK();
smartlist_pqueue_add(sl, cmp, offset, &fireflies);
OK();
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &chinchillas);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &eggplants);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &fireflies);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &chinchillas);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &eggplants);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &fireflies);
OK();
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &fish);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &frogs);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &lobsters);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &roquefort);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &fish);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &frogs);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &lobsters);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &roquefort);
OK();
- test_eq(smartlist_len(sl), 3);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &squid);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &weissbier);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &zebras);
- test_eq(smartlist_len(sl), 0);
+ tt_int_op(smartlist_len(sl),==, 3);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &squid);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &weissbier);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &zebras);
+ tt_int_op(smartlist_len(sl),==, 0);
OK();
/* Now test remove. */
@@ -683,21 +709,21 @@ test_container_pqueue(void)
smartlist_pqueue_add(sl, cmp, offset, &apples);
smartlist_pqueue_add(sl, cmp, offset, &squid);
smartlist_pqueue_add(sl, cmp, offset, &zebras);
- test_eq(smartlist_len(sl), 6);
+ tt_int_op(smartlist_len(sl),==, 6);
OK();
smartlist_pqueue_remove(sl, cmp, offset, &zebras);
- test_eq(smartlist_len(sl), 5);
+ tt_int_op(smartlist_len(sl),==, 5);
OK();
smartlist_pqueue_remove(sl, cmp, offset, &cows);
- test_eq(smartlist_len(sl), 4);
+ tt_int_op(smartlist_len(sl),==, 4);
OK();
smartlist_pqueue_remove(sl, cmp, offset, &apples);
- test_eq(smartlist_len(sl), 3);
+ tt_int_op(smartlist_len(sl),==, 3);
OK();
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &fish);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &frogs);
- test_eq_ptr(smartlist_pqueue_pop(sl, cmp, offset), &squid);
- test_eq(smartlist_len(sl), 0);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &fish);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &frogs);
+ tt_ptr_op(smartlist_pqueue_pop(sl, cmp, offset),==, &squid);
+ tt_int_op(smartlist_len(sl),==, 0);
OK();
#undef OK
@@ -709,7 +735,7 @@ test_container_pqueue(void)
/** Run unit tests for string-to-void* map functions */
static void
-test_container_strmap(void)
+test_container_strmap(void *arg)
{
strmap_t *map;
strmap_iter_t *iter;
@@ -717,36 +743,45 @@ test_container_strmap(void)
void *v;
char *visited = NULL;
smartlist_t *found_keys = NULL;
+ char *v1 = tor_strdup("v1");
+ char *v99 = tor_strdup("v99");
+ char *v100 = tor_strdup("v100");
+ char *v101 = tor_strdup("v101");
+ char *v102 = tor_strdup("v102");
+ char *v103 = tor_strdup("v103");
+ char *v104 = tor_strdup("v104");
+ char *v105 = tor_strdup("v105");
+ (void)arg;
map = strmap_new();
- test_assert(map);
- test_eq(strmap_size(map), 0);
- test_assert(strmap_isempty(map));
- v = strmap_set(map, "K1", (void*)99);
- test_eq_ptr(v, NULL);
- test_assert(!strmap_isempty(map));
- v = strmap_set(map, "K2", (void*)101);
- test_eq_ptr(v, NULL);
- v = strmap_set(map, "K1", (void*)100);
- test_eq_ptr(v, (void*)99);
- test_eq_ptr(strmap_get(map,"K1"), (void*)100);
- test_eq_ptr(strmap_get(map,"K2"), (void*)101);
- test_eq_ptr(strmap_get(map,"K-not-there"), NULL);
+ tt_assert(map);
+ tt_int_op(strmap_size(map),==, 0);
+ tt_assert(strmap_isempty(map));
+ v = strmap_set(map, "K1", v99);
+ tt_ptr_op(v,==, NULL);
+ tt_assert(!strmap_isempty(map));
+ v = strmap_set(map, "K2", v101);
+ tt_ptr_op(v,==, NULL);
+ v = strmap_set(map, "K1", v100);
+ tt_ptr_op(v,==, v99);
+ tt_ptr_op(strmap_get(map,"K1"),==, v100);
+ tt_ptr_op(strmap_get(map,"K2"),==, v101);
+ tt_ptr_op(strmap_get(map,"K-not-there"),==, NULL);
strmap_assert_ok(map);
v = strmap_remove(map,"K2");
strmap_assert_ok(map);
- test_eq_ptr(v, (void*)101);
- test_eq_ptr(strmap_get(map,"K2"), NULL);
- test_eq_ptr(strmap_remove(map,"K2"), NULL);
-
- strmap_set(map, "K2", (void*)101);
- strmap_set(map, "K3", (void*)102);
- strmap_set(map, "K4", (void*)103);
- test_eq(strmap_size(map), 4);
+ tt_ptr_op(v,==, v101);
+ tt_ptr_op(strmap_get(map,"K2"),==, NULL);
+ tt_ptr_op(strmap_remove(map,"K2"),==, NULL);
+
+ strmap_set(map, "K2", v101);
+ strmap_set(map, "K3", v102);
+ strmap_set(map, "K4", v103);
+ tt_int_op(strmap_size(map),==, 4);
strmap_assert_ok(map);
- strmap_set(map, "K5", (void*)104);
- strmap_set(map, "K6", (void*)105);
+ strmap_set(map, "K5", v104);
+ strmap_set(map, "K6", v105);
strmap_assert_ok(map);
/* Test iterator. */
@@ -755,7 +790,7 @@ test_container_strmap(void)
while (!strmap_iter_done(iter)) {
strmap_iter_get(iter,&k,&v);
smartlist_add(found_keys, tor_strdup(k));
- test_eq_ptr(v, strmap_get(map, k));
+ tt_ptr_op(v,==, strmap_get(map, k));
if (!strcmp(k, "K2")) {
iter = strmap_iter_next_rmv(map,iter);
@@ -765,12 +800,12 @@ test_container_strmap(void)
}
/* Make sure we removed K2, but not the others. */
- test_eq_ptr(strmap_get(map, "K2"), NULL);
- test_eq_ptr(strmap_get(map, "K5"), (void*)104);
+ tt_ptr_op(strmap_get(map, "K2"),==, NULL);
+ tt_ptr_op(strmap_get(map, "K5"),==, v104);
/* Make sure we visited everyone once */
smartlist_sort_strings(found_keys);
visited = smartlist_join_strings(found_keys, ":", 0, NULL);
- test_streq(visited, "K1:K2:K3:K4:K5:K6");
+ tt_str_op(visited,==, "K1:K2:K3:K4:K5:K6");
strmap_assert_ok(map);
/* Clean up after ourselves. */
@@ -779,14 +814,14 @@ test_container_strmap(void)
/* Now try some lc functions. */
map = strmap_new();
- strmap_set_lc(map,"Ab.C", (void*)1);
- test_eq_ptr(strmap_get(map,"ab.c"), (void*)1);
+ strmap_set_lc(map,"Ab.C", v1);
+ tt_ptr_op(strmap_get(map,"ab.c"),==, v1);
strmap_assert_ok(map);
- test_eq_ptr(strmap_get_lc(map,"AB.C"), (void*)1);
- test_eq_ptr(strmap_get(map,"AB.C"), NULL);
- test_eq_ptr(strmap_remove_lc(map,"aB.C"), (void*)1);
+ tt_ptr_op(strmap_get_lc(map,"AB.C"),==, v1);
+ tt_ptr_op(strmap_get(map,"AB.C"),==, NULL);
+ tt_ptr_op(strmap_remove_lc(map,"aB.C"),==, v1);
strmap_assert_ok(map);
- test_eq_ptr(strmap_get_lc(map,"AB.C"), NULL);
+ tt_ptr_op(strmap_get_lc(map,"AB.C"),==, NULL);
done:
if (map)
@@ -796,34 +831,66 @@ test_container_strmap(void)
smartlist_free(found_keys);
}
tor_free(visited);
+ tor_free(v1);
+ tor_free(v99);
+ tor_free(v100);
+ tor_free(v101);
+ tor_free(v102);
+ tor_free(v103);
+ tor_free(v104);
+ tor_free(v105);
}
/** Run unit tests for getting the median of a list. */
static void
-test_container_order_functions(void)
+test_container_order_functions(void *arg)
{
int lst[25], n = 0;
+ unsigned int lst2[25];
// int a=12,b=24,c=25,d=60,e=77;
#define median() median_int(lst, n)
+ (void)arg;
lst[n++] = 12;
- test_eq(12, median()); /* 12 */
+ tt_int_op(12,==, median()); /* 12 */
lst[n++] = 77;
//smartlist_shuffle(sl);
- test_eq(12, median()); /* 12, 77 */
+ tt_int_op(12,==, median()); /* 12, 77 */
lst[n++] = 77;
//smartlist_shuffle(sl);
- test_eq(77, median()); /* 12, 77, 77 */
+ tt_int_op(77,==, median()); /* 12, 77, 77 */
lst[n++] = 24;
- test_eq(24, median()); /* 12,24,77,77 */
+ tt_int_op(24,==, median()); /* 12,24,77,77 */
lst[n++] = 60;
lst[n++] = 12;
lst[n++] = 25;
//smartlist_shuffle(sl);
- test_eq(25, median()); /* 12,12,24,25,60,77,77 */
+ tt_int_op(25,==, median()); /* 12,12,24,25,60,77,77 */
#undef median
+#define third_quartile() third_quartile_uint32(lst2, n)
+
+ n = 0;
+ lst2[n++] = 1;
+ tt_int_op(1,==, third_quartile()); /* ~1~ */
+ lst2[n++] = 2;
+ tt_int_op(2,==, third_quartile()); /* 1, ~2~ */
+ lst2[n++] = 3;
+ lst2[n++] = 4;
+ lst2[n++] = 5;
+ tt_int_op(4,==, third_quartile()); /* 1, 2, 3, ~4~, 5 */
+ lst2[n++] = 6;
+ lst2[n++] = 7;
+ lst2[n++] = 8;
+ lst2[n++] = 9;
+ tt_int_op(7,==, third_quartile()); /* 1, 2, 3, 4, 5, 6, ~7~, 8, 9 */
+ lst2[n++] = 10;
+ lst2[n++] = 11;
+ tt_int_op(9,==, third_quartile()); /* 1, 2, 3, 4, 5, 6, 7, 8, ~9~, 10, 11 */
+
+#undef third_quartile
+
done:
;
}
@@ -874,18 +941,26 @@ test_container_di_map(void *arg)
/** Run unit tests for fp_pair-to-void* map functions */
static void
-test_container_fp_pair_map(void)
+test_container_fp_pair_map(void *arg)
{
fp_pair_map_t *map;
fp_pair_t fp1, fp2, fp3, fp4, fp5, fp6;
void *v;
fp_pair_map_iter_t *iter;
fp_pair_t k;
+ char *v99 = tor_strdup("99");
+ char *v100 = tor_strdup("v100");
+ char *v101 = tor_strdup("v101");
+ char *v102 = tor_strdup("v102");
+ char *v103 = tor_strdup("v103");
+ char *v104 = tor_strdup("v104");
+ char *v105 = tor_strdup("v105");
+ (void)arg;
map = fp_pair_map_new();
- test_assert(map);
- test_eq(fp_pair_map_size(map), 0);
- test_assert(fp_pair_map_isempty(map));
+ tt_assert(map);
+ tt_int_op(fp_pair_map_size(map),==, 0);
+ tt_assert(fp_pair_map_isempty(map));
memset(fp1.first, 0x11, DIGEST_LEN);
memset(fp1.second, 0x12, DIGEST_LEN);
@@ -900,38 +975,38 @@ test_container_fp_pair_map(void)
memset(fp6.first, 0x61, DIGEST_LEN);
memset(fp6.second, 0x62, DIGEST_LEN);
- v = fp_pair_map_set(map, &fp1, (void*)99);
+ v = fp_pair_map_set(map, &fp1, v99);
tt_ptr_op(v, ==, NULL);
- test_assert(!fp_pair_map_isempty(map));
- v = fp_pair_map_set(map, &fp2, (void*)101);
+ tt_assert(!fp_pair_map_isempty(map));
+ v = fp_pair_map_set(map, &fp2, v101);
tt_ptr_op(v, ==, NULL);
- v = fp_pair_map_set(map, &fp1, (void*)100);
- tt_ptr_op(v, ==, (void*)99);
- test_eq_ptr(fp_pair_map_get(map, &fp1), (void*)100);
- test_eq_ptr(fp_pair_map_get(map, &fp2), (void*)101);
- test_eq_ptr(fp_pair_map_get(map, &fp3), NULL);
+ v = fp_pair_map_set(map, &fp1, v100);
+ tt_ptr_op(v, ==, v99);
+ tt_ptr_op(fp_pair_map_get(map, &fp1),==, v100);
+ tt_ptr_op(fp_pair_map_get(map, &fp2),==, v101);
+ tt_ptr_op(fp_pair_map_get(map, &fp3),==, NULL);
fp_pair_map_assert_ok(map);
v = fp_pair_map_remove(map, &fp2);
fp_pair_map_assert_ok(map);
- test_eq_ptr(v, (void*)101);
- test_eq_ptr(fp_pair_map_get(map, &fp2), NULL);
- test_eq_ptr(fp_pair_map_remove(map, &fp2), NULL);
-
- fp_pair_map_set(map, &fp2, (void*)101);
- fp_pair_map_set(map, &fp3, (void*)102);
- fp_pair_map_set(map, &fp4, (void*)103);
- test_eq(fp_pair_map_size(map), 4);
+ tt_ptr_op(v,==, v101);
+ tt_ptr_op(fp_pair_map_get(map, &fp2),==, NULL);
+ tt_ptr_op(fp_pair_map_remove(map, &fp2),==, NULL);
+
+ fp_pair_map_set(map, &fp2, v101);
+ fp_pair_map_set(map, &fp3, v102);
+ fp_pair_map_set(map, &fp4, v103);
+ tt_int_op(fp_pair_map_size(map),==, 4);
fp_pair_map_assert_ok(map);
- fp_pair_map_set(map, &fp5, (void*)104);
- fp_pair_map_set(map, &fp6, (void*)105);
+ fp_pair_map_set(map, &fp5, v104);
+ fp_pair_map_set(map, &fp6, v105);
fp_pair_map_assert_ok(map);
/* Test iterator. */
iter = fp_pair_map_iter_init(map);
while (!fp_pair_map_iter_done(iter)) {
fp_pair_map_iter_get(iter, &k, &v);
- test_eq_ptr(v, fp_pair_map_get(map, &k));
+ tt_ptr_op(v,==, fp_pair_map_get(map, &k));
if (tor_memeq(&fp2, &k, sizeof(fp2))) {
iter = fp_pair_map_iter_next_rmv(map, iter);
@@ -941,8 +1016,8 @@ test_container_fp_pair_map(void)
}
/* Make sure we removed fp2, but not the others. */
- test_eq_ptr(fp_pair_map_get(map, &fp2), NULL);
- test_eq_ptr(fp_pair_map_get(map, &fp5), (void*)104);
+ tt_ptr_op(fp_pair_map_get(map, &fp2),==, NULL);
+ tt_ptr_op(fp_pair_map_get(map, &fp5),==, v104);
fp_pair_map_assert_ok(map);
/* Clean up after ourselves. */
@@ -952,10 +1027,17 @@ test_container_fp_pair_map(void)
done:
if (map)
fp_pair_map_free(map, NULL);
+ tor_free(v99);
+ tor_free(v100);
+ tor_free(v101);
+ tor_free(v102);
+ tor_free(v103);
+ tor_free(v104);
+ tor_free(v105);
}
#define CONTAINER_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_container_ ## name }
+ { #name, test_container_ ## name , 0, NULL, NULL }
#define CONTAINER(name, flags) \
{ #name, test_container_ ## name, (flags), NULL, NULL }
diff --git a/src/test/test_controller_events.c b/src/test/test_controller_events.c
index b45e97a417..4d6077b641 100644
--- a/src/test/test_controller_events.c
+++ b/src/test/test_controller_events.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define CONNECTION_PRIVATE
diff --git a/src/test/test_crypto.c b/src/test/test_crypto.c
index 5d8edb6550..4416134ac4 100644
--- a/src/test/test_crypto.c
+++ b/src/test/test_crypto.c
@@ -1,18 +1,21 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
#define CRYPTO_CURVE25519_PRIVATE
+#define CRYPTO_S2K_PRIVATE
#include "or.h"
#include "test.h"
#include "aes.h"
#include "util.h"
#include "siphash.h"
-#ifdef CURVE25519_ENABLED
#include "crypto_curve25519.h"
-#endif
+#include "crypto_ed25519.h"
+#include "ed25519_vectors.inc"
+#include "crypto_s2k.h"
+#include "crypto_pwbox.h"
extern const char AUTHORITY_SIGNKEY_3[];
extern const char AUTHORITY_SIGNKEY_A_DIGEST[];
@@ -20,7 +23,7 @@ extern const char AUTHORITY_SIGNKEY_A_DIGEST256[];
/** Run unit tests for Diffie-Hellman functionality. */
static void
-test_crypto_dh(void)
+test_crypto_dh(void *arg)
{
crypto_dh_t *dh1 = crypto_dh_new(DH_TYPE_CIRCUIT);
crypto_dh_t *dh2 = crypto_dh_new(DH_TYPE_CIRCUIT);
@@ -30,24 +33,25 @@ test_crypto_dh(void)
char s2[DH_BYTES];
ssize_t s1len, s2len;
- test_eq(crypto_dh_get_bytes(dh1), DH_BYTES);
- test_eq(crypto_dh_get_bytes(dh2), DH_BYTES);
+ (void)arg;
+ tt_int_op(crypto_dh_get_bytes(dh1),==, DH_BYTES);
+ tt_int_op(crypto_dh_get_bytes(dh2),==, DH_BYTES);
memset(p1, 0, DH_BYTES);
memset(p2, 0, DH_BYTES);
- test_memeq(p1, p2, DH_BYTES);
- test_assert(! crypto_dh_get_public(dh1, p1, DH_BYTES));
- test_memneq(p1, p2, DH_BYTES);
- test_assert(! crypto_dh_get_public(dh2, p2, DH_BYTES));
- test_memneq(p1, p2, DH_BYTES);
+ tt_mem_op(p1,==, p2, DH_BYTES);
+ tt_assert(! crypto_dh_get_public(dh1, p1, DH_BYTES));
+ tt_mem_op(p1,!=, p2, DH_BYTES);
+ tt_assert(! crypto_dh_get_public(dh2, p2, DH_BYTES));
+ tt_mem_op(p1,!=, p2, DH_BYTES);
memset(s1, 0, DH_BYTES);
memset(s2, 0xFF, DH_BYTES);
s1len = crypto_dh_compute_secret(LOG_WARN, dh1, p2, DH_BYTES, s1, 50);
s2len = crypto_dh_compute_secret(LOG_WARN, dh2, p1, DH_BYTES, s2, 50);
- test_assert(s1len > 0);
- test_eq(s1len, s2len);
- test_memeq(s1, s2, s1len);
+ tt_assert(s1len > 0);
+ tt_int_op(s1len,==, s2len);
+ tt_mem_op(s1,==, s2, s1len);
{
/* XXXX Now fabricate some bad values and make sure they get caught,
@@ -63,17 +67,18 @@ test_crypto_dh(void)
/** Run unit tests for our random number generation function and its wrappers.
*/
static void
-test_crypto_rng(void)
+test_crypto_rng(void *arg)
{
int i, j, allok;
char data1[100], data2[100];
double d;
/* Try out RNG. */
- test_assert(! crypto_seed_rng(0));
+ (void)arg;
+ tt_assert(! crypto_seed_rng(0));
crypto_rand(data1, 100);
crypto_rand(data2, 100);
- test_memneq(data1,data2,100);
+ tt_mem_op(data1,!=, data2,100);
allok = 1;
for (i = 0; i < 100; ++i) {
uint64_t big;
@@ -88,8 +93,8 @@ test_crypto_rng(void)
if (big >= 5)
allok = 0;
d = crypto_rand_double();
- test_assert(d >= 0);
- test_assert(d < 1.0);
+ tt_assert(d >= 0);
+ tt_assert(d < 1.0);
host = crypto_random_hostname(3,8,"www.",".onion");
if (strcmpstart(host,"www.") ||
strcmpend(host,".onion") ||
@@ -98,7 +103,7 @@ test_crypto_rng(void)
allok = 0;
tor_free(host);
}
- test_assert(allok);
+ tt_assert(allok);
done:
;
}
@@ -128,15 +133,15 @@ test_crypto_aes(void *arg)
memset(data2, 0, 1024);
memset(data3, 0, 1024);
env1 = crypto_cipher_new(NULL);
- test_neq_ptr(env1, 0);
+ tt_ptr_op(env1, !=, NULL);
env2 = crypto_cipher_new(crypto_cipher_get_key(env1));
- test_neq_ptr(env2, 0);
+ tt_ptr_op(env2, !=, NULL);
/* Try encrypting 512 chars. */
crypto_cipher_encrypt(env1, data2, data1, 512);
crypto_cipher_decrypt(env2, data3, data2, 512);
- test_memeq(data1, data3, 512);
- test_memneq(data1, data2, 512);
+ tt_mem_op(data1,==, data3, 512);
+ tt_mem_op(data1,!=, data2, 512);
/* Now encrypt 1 at a time, and get 1 at a time. */
for (j = 512; j < 560; ++j) {
@@ -145,7 +150,7 @@ test_crypto_aes(void *arg)
for (j = 512; j < 560; ++j) {
crypto_cipher_decrypt(env2, data3+j, data2+j, 1);
}
- test_memeq(data1, data3, 560);
+ tt_mem_op(data1,==, data3, 560);
/* Now encrypt 3 at a time, and get 5 at a time. */
for (j = 560; j < 1024-5; j += 3) {
crypto_cipher_encrypt(env1, data2+j, data1+j, 3);
@@ -153,7 +158,7 @@ test_crypto_aes(void *arg)
for (j = 560; j < 1024-5; j += 5) {
crypto_cipher_decrypt(env2, data3+j, data2+j, 5);
}
- test_memeq(data1, data3, 1024-5);
+ tt_mem_op(data1,==, data3, 1024-5);
/* Now make sure that when we encrypt with different chunk sizes, we get
the same results. */
crypto_cipher_free(env2);
@@ -161,7 +166,7 @@ test_crypto_aes(void *arg)
memset(data3, 0, 1024);
env2 = crypto_cipher_new(crypto_cipher_get_key(env1));
- test_neq_ptr(env2, NULL);
+ tt_ptr_op(env2, !=, NULL);
for (j = 0; j < 1024-16; j += 17) {
crypto_cipher_encrypt(env2, data3+j, data1+j, 17);
}
@@ -170,7 +175,7 @@ test_crypto_aes(void *arg)
printf("%d: %d\t%d\n", j, (int) data2[j], (int) data3[j]);
}
}
- test_memeq(data2, data3, 1024-16);
+ tt_mem_op(data2,==, data3, 1024-16);
crypto_cipher_free(env1);
env1 = NULL;
crypto_cipher_free(env2);
@@ -237,7 +242,7 @@ test_crypto_aes(void *arg)
"\xff\xff\xff\xff\xff\xff\xff\xff"
"\xff\xff\xff\xff\xff\xff\xff\xff");
crypto_cipher_crypt_inplace(env1, data2, 64);
- test_assert(tor_mem_is_zero(data2, 64));
+ tt_assert(tor_mem_is_zero(data2, 64));
done:
tor_free(mem_op_hex_tmp);
@@ -252,7 +257,7 @@ test_crypto_aes(void *arg)
/** Run unit tests for our SHA-1 functionality */
static void
-test_crypto_sha(void)
+test_crypto_sha(void *arg)
{
crypto_digest_t *d1 = NULL, *d2 = NULL;
int i;
@@ -263,6 +268,7 @@ test_crypto_sha(void)
char *mem_op_hex_tmp=NULL;
/* Test SHA-1 with a test vector from the specification. */
+ (void)arg;
i = crypto_digest(data, "abc", 3);
test_memeq_hex(data, "A9993E364706816ABA3E25717850C26C9CD0D89D");
tt_int_op(i, ==, 0);
@@ -277,13 +283,13 @@ test_crypto_sha(void)
/* Case empty (wikipedia) */
crypto_hmac_sha256(digest, "", 0, "", 0);
- test_streq(hex_str(digest, 32),
+ tt_str_op(hex_str(digest, 32),==,
"B613679A0814D9EC772F95D778C35FC5FF1697C493715653C6C712144292C5AD");
/* Case quick-brown (wikipedia) */
crypto_hmac_sha256(digest, "key", 3,
"The quick brown fox jumps over the lazy dog", 43);
- test_streq(hex_str(digest, 32),
+ tt_str_op(hex_str(digest, 32),==,
"F7BC83F430538424B13298E6AA6FB143EF4D59A14946175997479DBC2D1A3CD8");
/* "Test Case 1" from RFC 4231 */
@@ -344,43 +350,43 @@ test_crypto_sha(void)
/* Incremental digest code. */
d1 = crypto_digest_new();
- test_assert(d1);
+ tt_assert(d1);
crypto_digest_add_bytes(d1, "abcdef", 6);
d2 = crypto_digest_dup(d1);
- test_assert(d2);
+ tt_assert(d2);
crypto_digest_add_bytes(d2, "ghijkl", 6);
crypto_digest_get_digest(d2, d_out1, sizeof(d_out1));
crypto_digest(d_out2, "abcdefghijkl", 12);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
crypto_digest_assign(d2, d1);
crypto_digest_add_bytes(d2, "mno", 3);
crypto_digest_get_digest(d2, d_out1, sizeof(d_out1));
crypto_digest(d_out2, "abcdefmno", 9);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
crypto_digest_get_digest(d1, d_out1, sizeof(d_out1));
crypto_digest(d_out2, "abcdef", 6);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
crypto_digest_free(d1);
crypto_digest_free(d2);
/* Incremental digest code with sha256 */
d1 = crypto_digest256_new(DIGEST_SHA256);
- test_assert(d1);
+ tt_assert(d1);
crypto_digest_add_bytes(d1, "abcdef", 6);
d2 = crypto_digest_dup(d1);
- test_assert(d2);
+ tt_assert(d2);
crypto_digest_add_bytes(d2, "ghijkl", 6);
crypto_digest_get_digest(d2, d_out1, sizeof(d_out1));
crypto_digest256(d_out2, "abcdefghijkl", 12, DIGEST_SHA256);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
crypto_digest_assign(d2, d1);
crypto_digest_add_bytes(d2, "mno", 3);
crypto_digest_get_digest(d2, d_out1, sizeof(d_out1));
crypto_digest256(d_out2, "abcdefmno", 9, DIGEST_SHA256);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
crypto_digest_get_digest(d1, d_out1, sizeof(d_out1));
crypto_digest256(d_out2, "abcdef", 6, DIGEST_SHA256);
- test_memeq(d_out1, d_out2, DIGEST_LEN);
+ tt_mem_op(d_out1,==, d_out2, DIGEST_LEN);
done:
if (d1)
@@ -392,7 +398,7 @@ test_crypto_sha(void)
/** Run unit tests for our public key crypto functions */
static void
-test_crypto_pk(void)
+test_crypto_pk(void *arg)
{
crypto_pk_t *pk1 = NULL, *pk2 = NULL;
char *encoded = NULL;
@@ -401,74 +407,83 @@ test_crypto_pk(void)
int i, len;
/* Public-key ciphers */
+ (void)arg;
pk1 = pk_generate(0);
pk2 = crypto_pk_new();
- test_assert(pk1 && pk2);
- test_assert(! crypto_pk_write_public_key_to_string(pk1, &encoded, &size));
- test_assert(! crypto_pk_read_public_key_from_string(pk2, encoded, size));
- test_eq(0, crypto_pk_cmp_keys(pk1, pk2));
+ tt_assert(pk1 && pk2);
+ tt_assert(! crypto_pk_write_public_key_to_string(pk1, &encoded, &size));
+ tt_assert(! crypto_pk_read_public_key_from_string(pk2, encoded, size));
+ tt_int_op(0,==, crypto_pk_cmp_keys(pk1, pk2));
/* comparison between keys and NULL */
tt_int_op(crypto_pk_cmp_keys(NULL, pk1), <, 0);
tt_int_op(crypto_pk_cmp_keys(NULL, NULL), ==, 0);
tt_int_op(crypto_pk_cmp_keys(pk1, NULL), >, 0);
- test_eq(128, crypto_pk_keysize(pk1));
- test_eq(1024, crypto_pk_num_bits(pk1));
- test_eq(128, crypto_pk_keysize(pk2));
- test_eq(1024, crypto_pk_num_bits(pk2));
+ tt_int_op(128,==, crypto_pk_keysize(pk1));
+ tt_int_op(1024,==, crypto_pk_num_bits(pk1));
+ tt_int_op(128,==, crypto_pk_keysize(pk2));
+ tt_int_op(1024,==, crypto_pk_num_bits(pk2));
- test_eq(128, crypto_pk_public_encrypt(pk2, data1, sizeof(data1),
+ tt_int_op(128,==, crypto_pk_public_encrypt(pk2, data1, sizeof(data1),
"Hello whirled.", 15,
PK_PKCS1_OAEP_PADDING));
- test_eq(128, crypto_pk_public_encrypt(pk1, data2, sizeof(data1),
+ tt_int_op(128,==, crypto_pk_public_encrypt(pk1, data2, sizeof(data1),
"Hello whirled.", 15,
PK_PKCS1_OAEP_PADDING));
/* oaep padding should make encryption not match */
- test_memneq(data1, data2, 128);
- test_eq(15, crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data1, 128,
+ tt_mem_op(data1,!=, data2, 128);
+ tt_int_op(15,==,
+ crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data1, 128,
PK_PKCS1_OAEP_PADDING,1));
- test_streq(data3, "Hello whirled.");
+ tt_str_op(data3,==, "Hello whirled.");
memset(data3, 0, 1024);
- test_eq(15, crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data2, 128,
+ tt_int_op(15,==,
+ crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data2, 128,
PK_PKCS1_OAEP_PADDING,1));
- test_streq(data3, "Hello whirled.");
+ tt_str_op(data3,==, "Hello whirled.");
/* Can't decrypt with public key. */
- test_eq(-1, crypto_pk_private_decrypt(pk2, data3, sizeof(data3), data2, 128,
+ tt_int_op(-1,==,
+ crypto_pk_private_decrypt(pk2, data3, sizeof(data3), data2, 128,
PK_PKCS1_OAEP_PADDING,1));
/* Try again with bad padding */
memcpy(data2+1, "XYZZY", 5); /* This has fails ~ once-in-2^40 */
- test_eq(-1, crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data2, 128,
+ tt_int_op(-1,==,
+ crypto_pk_private_decrypt(pk1, data3, sizeof(data3), data2, 128,
PK_PKCS1_OAEP_PADDING,1));
/* File operations: save and load private key */
- test_assert(! crypto_pk_write_private_key_to_filename(pk1,
+ tt_assert(! crypto_pk_write_private_key_to_filename(pk1,
get_fname("pkey1")));
/* failing case for read: can't read. */
- test_assert(crypto_pk_read_private_key_from_filename(pk2,
+ tt_assert(crypto_pk_read_private_key_from_filename(pk2,
get_fname("xyzzy")) < 0);
write_str_to_file(get_fname("xyzzy"), "foobar", 6);
/* Failing case for read: no key. */
- test_assert(crypto_pk_read_private_key_from_filename(pk2,
+ tt_assert(crypto_pk_read_private_key_from_filename(pk2,
get_fname("xyzzy")) < 0);
- test_assert(! crypto_pk_read_private_key_from_filename(pk2,
+ tt_assert(! crypto_pk_read_private_key_from_filename(pk2,
get_fname("pkey1")));
- test_eq(15, crypto_pk_private_decrypt(pk2, data3, sizeof(data3), data1, 128,
+ tt_int_op(15,==,
+ crypto_pk_private_decrypt(pk2, data3, sizeof(data3), data1, 128,
PK_PKCS1_OAEP_PADDING,1));
/* Now try signing. */
strlcpy(data1, "Ossifrage", 1024);
- test_eq(128, crypto_pk_private_sign(pk1, data2, sizeof(data2), data1, 10));
- test_eq(10,
+ tt_int_op(128,==,
+ crypto_pk_private_sign(pk1, data2, sizeof(data2), data1, 10));
+ tt_int_op(10,==,
crypto_pk_public_checksig(pk1, data3, sizeof(data3), data2, 128));
- test_streq(data3, "Ossifrage");
+ tt_str_op(data3,==, "Ossifrage");
/* Try signing digests. */
- test_eq(128, crypto_pk_private_sign_digest(pk1, data2, sizeof(data2),
+ tt_int_op(128,==, crypto_pk_private_sign_digest(pk1, data2, sizeof(data2),
data1, 10));
- test_eq(20,
+ tt_int_op(20,==,
crypto_pk_public_checksig(pk1, data3, sizeof(data3), data2, 128));
- test_eq(0, crypto_pk_public_checksig_digest(pk1, data1, 10, data2, 128));
- test_eq(-1, crypto_pk_public_checksig_digest(pk1, data1, 11, data2, 128));
+ tt_int_op(0,==,
+ crypto_pk_public_checksig_digest(pk1, data1, 10, data2, 128));
+ tt_int_op(-1,==,
+ crypto_pk_public_checksig_digest(pk1, data1, 11, data2, 128));
/*XXXX test failed signing*/
@@ -476,9 +491,9 @@ test_crypto_pk(void)
crypto_pk_free(pk2);
pk2 = NULL;
i = crypto_pk_asn1_encode(pk1, data1, 1024);
- test_assert(i>0);
+ tt_int_op(i, >, 0);
pk2 = crypto_pk_asn1_decode(data1, i);
- test_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
+ tt_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
/* Try with hybrid encryption wrappers. */
crypto_rand(data1, 1024);
@@ -487,19 +502,19 @@ test_crypto_pk(void)
memset(data3,0,1024);
len = crypto_pk_public_hybrid_encrypt(pk1,data2,sizeof(data2),
data1,i,PK_PKCS1_OAEP_PADDING,0);
- test_assert(len>=0);
+ tt_int_op(len, >=, 0);
len = crypto_pk_private_hybrid_decrypt(pk1,data3,sizeof(data3),
data2,len,PK_PKCS1_OAEP_PADDING,1);
- test_eq(len,i);
- test_memeq(data1,data3,i);
+ tt_int_op(len,==, i);
+ tt_mem_op(data1,==, data3,i);
}
/* Try copy_full */
crypto_pk_free(pk2);
pk2 = crypto_pk_copy_full(pk1);
- test_assert(pk2 != NULL);
- test_neq_ptr(pk1, pk2);
- test_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
+ tt_assert(pk2 != NULL);
+ tt_ptr_op(pk1, !=, pk2);
+ tt_assert(crypto_pk_cmp_keys(pk1,pk2) == 0);
done:
if (pk1)
@@ -532,7 +547,7 @@ test_crypto_pk_fingerprints(void *arg)
/* Is digest as expected? */
crypto_digest(d, encoded, n);
tt_int_op(0, ==, crypto_pk_get_digest(pk, d2));
- test_memeq(d, d2, DIGEST_LEN);
+ tt_mem_op(d,==, d2, DIGEST_LEN);
/* Is fingerprint right? */
tt_int_op(0, ==, crypto_pk_get_fingerprint(pk, fingerprint, 0));
@@ -561,28 +576,29 @@ test_crypto_pk_fingerprints(void *arg)
/** Sanity check for crypto pk digests */
static void
-test_crypto_digests(void)
+test_crypto_digests(void *arg)
{
crypto_pk_t *k = NULL;
ssize_t r;
digests_t pkey_digests;
char digest[DIGEST_LEN];
+ (void)arg;
k = crypto_pk_new();
- test_assert(k);
+ tt_assert(k);
r = crypto_pk_read_private_key_from_string(k, AUTHORITY_SIGNKEY_3, -1);
- test_assert(!r);
+ tt_assert(!r);
r = crypto_pk_get_digest(k, digest);
- test_assert(r == 0);
- test_memeq(hex_str(digest, DIGEST_LEN),
+ tt_assert(r == 0);
+ tt_mem_op(hex_str(digest, DIGEST_LEN),==,
AUTHORITY_SIGNKEY_A_DIGEST, HEX_DIGEST_LEN);
r = crypto_pk_get_all_digests(k, &pkey_digests);
- test_memeq(hex_str(pkey_digests.d[DIGEST_SHA1], DIGEST_LEN),
+ tt_mem_op(hex_str(pkey_digests.d[DIGEST_SHA1], DIGEST_LEN),==,
AUTHORITY_SIGNKEY_A_DIGEST, HEX_DIGEST_LEN);
- test_memeq(hex_str(pkey_digests.d[DIGEST_SHA256], DIGEST256_LEN),
+ tt_mem_op(hex_str(pkey_digests.d[DIGEST_SHA256], DIGEST256_LEN),==,
AUTHORITY_SIGNKEY_A_DIGEST256, HEX_DIGEST256_LEN);
done:
crypto_pk_free(k);
@@ -591,58 +607,59 @@ test_crypto_digests(void)
/** Run unit tests for misc crypto formatting functionality (base64, base32,
* fingerprints, etc) */
static void
-test_crypto_formats(void)
+test_crypto_formats(void *arg)
{
char *data1 = NULL, *data2 = NULL, *data3 = NULL;
int i, j, idx;
+ (void)arg;
data1 = tor_malloc(1024);
data2 = tor_malloc(1024);
data3 = tor_malloc(1024);
- test_assert(data1 && data2 && data3);
+ tt_assert(data1 && data2 && data3);
/* Base64 tests */
memset(data1, 6, 1024);
for (idx = 0; idx < 10; ++idx) {
i = base64_encode(data2, 1024, data1, idx);
- test_assert(i >= 0);
+ tt_int_op(i, >=, 0);
j = base64_decode(data3, 1024, data2, i);
- test_eq(j,idx);
- test_memeq(data3, data1, idx);
+ tt_int_op(j,==, idx);
+ tt_mem_op(data3,==, data1, idx);
}
strlcpy(data1, "Test string that contains 35 chars.", 1024);
strlcat(data1, " 2nd string that contains 35 chars.", 1024);
i = base64_encode(data2, 1024, data1, 71);
- test_assert(i >= 0);
+ tt_int_op(i, >=, 0);
j = base64_decode(data3, 1024, data2, i);
- test_eq(j, 71);
- test_streq(data3, data1);
- test_assert(data2[i] == '\0');
+ tt_int_op(j,==, 71);
+ tt_str_op(data3,==, data1);
+ tt_int_op(data2[i], ==, '\0');
crypto_rand(data1, DIGEST_LEN);
memset(data2, 100, 1024);
digest_to_base64(data2, data1);
- test_eq(BASE64_DIGEST_LEN, strlen(data2));
- test_eq(100, data2[BASE64_DIGEST_LEN+2]);
+ tt_int_op(BASE64_DIGEST_LEN,==, strlen(data2));
+ tt_int_op(100,==, data2[BASE64_DIGEST_LEN+2]);
memset(data3, 99, 1024);
- test_eq(digest_from_base64(data3, data2), 0);
- test_memeq(data1, data3, DIGEST_LEN);
- test_eq(99, data3[DIGEST_LEN+1]);
+ tt_int_op(digest_from_base64(data3, data2),==, 0);
+ tt_mem_op(data1,==, data3, DIGEST_LEN);
+ tt_int_op(99,==, data3[DIGEST_LEN+1]);
- test_assert(digest_from_base64(data3, "###") < 0);
+ tt_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]);
+ tt_int_op(BASE64_DIGEST256_LEN,==, strlen(data2));
+ tt_int_op(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]);
+ tt_int_op(digest256_from_base64(data3, data2),==, 0);
+ tt_mem_op(data1,==, data3, DIGEST256_LEN);
+ tt_int_op(99,==, data3[DIGEST256_LEN+1]);
/* Base32 tests */
strlcpy(data1, "5chrs", 1024);
@@ -651,27 +668,27 @@ test_crypto_formats(void)
* By 5s: [00110 10101 10001 10110 10000 11100 10011 10011]
*/
base32_encode(data2, 9, data1, 5);
- test_streq(data2, "gvrwq4tt");
+ tt_str_op(data2,==, "gvrwq4tt");
strlcpy(data1, "\xFF\xF5\x6D\x44\xAE\x0D\x5C\xC9\x62\xC4", 1024);
base32_encode(data2, 30, data1, 10);
- test_streq(data2, "772w2rfobvomsywe");
+ tt_str_op(data2,==, "772w2rfobvomsywe");
/* Base16 tests */
strlcpy(data1, "6chrs\xff", 1024);
base16_encode(data2, 13, data1, 6);
- test_streq(data2, "3663687273FF");
+ tt_str_op(data2,==, "3663687273FF");
strlcpy(data1, "f0d678affc000100", 1024);
i = base16_decode(data2, 8, data1, 16);
- test_eq(i,0);
- test_memeq(data2, "\xf0\xd6\x78\xaf\xfc\x00\x01\x00",8);
+ tt_int_op(i,==, 0);
+ tt_mem_op(data2,==, "\xf0\xd6\x78\xaf\xfc\x00\x01\x00",8);
/* now try some failing base16 decodes */
- test_eq(-1, base16_decode(data2, 8, data1, 15)); /* odd input len */
- test_eq(-1, base16_decode(data2, 7, data1, 16)); /* dest too short */
+ tt_int_op(-1,==, base16_decode(data2, 8, data1, 15)); /* odd input len */
+ tt_int_op(-1,==, base16_decode(data2, 7, data1, 16)); /* dest too short */
strlcpy(data1, "f0dz!8affc000100", 1024);
- test_eq(-1, base16_decode(data2, 8, data1, 16));
+ tt_int_op(-1,==, base16_decode(data2, 8, data1, 16));
tor_free(data1);
tor_free(data2);
@@ -680,10 +697,10 @@ test_crypto_formats(void)
/* Add spaces to fingerprint */
{
data1 = tor_strdup("ABCD1234ABCD56780000ABCD1234ABCD56780000");
- test_eq(strlen(data1), 40);
+ tt_int_op(strlen(data1),==, 40);
data2 = tor_malloc(FINGERPRINT_LEN+1);
crypto_add_spaces_to_fp(data2, FINGERPRINT_LEN+1, data1);
- test_streq(data2, "ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 0000");
+ tt_str_op(data2,==, "ABCD 1234 ABCD 5678 0000 ABCD 1234 ABCD 5678 0000");
tor_free(data1);
tor_free(data2);
}
@@ -696,37 +713,377 @@ test_crypto_formats(void)
/** Run unit tests for our secret-to-key passphrase hashing functionality. */
static void
-test_crypto_s2k(void)
+test_crypto_s2k_rfc2440(void *arg)
{
char buf[29];
char buf2[29];
char *buf3 = NULL;
int i;
+ (void)arg;
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);
+ secret_to_key_rfc2440(buf+9, 20, "", 0, buf);
crypto_digest(buf2+9, buf3, 1024);
- test_memeq(buf, buf2, 29);
+ tt_mem_op(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);
+ secret_to_key_rfc2440(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);
+ tt_mem_op(buf,==, buf2, 29);
done:
tor_free(buf3);
}
+static void
+run_s2k_tests(const unsigned flags, const unsigned type,
+ int speclen, const int keylen, int legacy)
+{
+ uint8_t buf[S2K_MAXLEN], buf2[S2K_MAXLEN], buf3[S2K_MAXLEN];
+ int r;
+ size_t sz;
+ const char pw1[] = "You can't come in here unless you say swordfish!";
+ const char pw2[] = "Now, I give you one more guess.";
+
+ r = secret_to_key_new(buf, sizeof(buf), &sz,
+ pw1, strlen(pw1), flags);
+ tt_int_op(r, ==, S2K_OKAY);
+ tt_int_op(buf[0], ==, type);
+
+ tt_int_op(sz, ==, keylen + speclen);
+
+ if (legacy) {
+ memmove(buf, buf+1, sz-1);
+ --sz;
+ --speclen;
+ }
+
+ tt_int_op(S2K_OKAY, ==,
+ secret_to_key_check(buf, sz, pw1, strlen(pw1)));
+
+ tt_int_op(S2K_BAD_SECRET, ==,
+ secret_to_key_check(buf, sz, pw2, strlen(pw2)));
+
+ /* Move key to buf2, and clear it. */
+ memset(buf3, 0, sizeof(buf3));
+ memcpy(buf2, buf+speclen, keylen);
+ memset(buf+speclen, 0, sz - speclen);
+
+ /* Derivekey should produce the same results. */
+ tt_int_op(S2K_OKAY, ==,
+ secret_to_key_derivekey(buf3, keylen, buf, speclen, pw1, strlen(pw1)));
+
+ tt_mem_op(buf2, ==, buf3, keylen);
+
+ /* Derivekey with a longer output should fill the output. */
+ memset(buf2, 0, sizeof(buf2));
+ tt_int_op(S2K_OKAY, ==,
+ secret_to_key_derivekey(buf2, sizeof(buf2), buf, speclen,
+ pw1, strlen(pw1)));
+
+ tt_mem_op(buf2, !=, buf3, sizeof(buf2));
+
+ memset(buf3, 0, sizeof(buf3));
+ tt_int_op(S2K_OKAY, ==,
+ secret_to_key_derivekey(buf3, sizeof(buf3), buf, speclen,
+ pw1, strlen(pw1)));
+ tt_mem_op(buf2, ==, buf3, sizeof(buf3));
+ tt_assert(!tor_mem_is_zero((char*)buf2+keylen, sizeof(buf2)-keylen));
+
+ done:
+ ;
+}
+
+static void
+test_crypto_s2k_general(void *arg)
+{
+ const char *which = arg;
+
+ if (!strcmp(which, "scrypt")) {
+ run_s2k_tests(0, 2, 19, 32, 0);
+ } else if (!strcmp(which, "scrypt-low")) {
+ run_s2k_tests(S2K_FLAG_LOW_MEM, 2, 19, 32, 0);
+ } else if (!strcmp(which, "pbkdf2")) {
+ run_s2k_tests(S2K_FLAG_USE_PBKDF2, 1, 18, 20, 0);
+ } else if (!strcmp(which, "rfc2440")) {
+ run_s2k_tests(S2K_FLAG_NO_SCRYPT, 0, 10, 20, 0);
+ } else if (!strcmp(which, "rfc2440-legacy")) {
+ run_s2k_tests(S2K_FLAG_NO_SCRYPT, 0, 10, 20, 1);
+ } else {
+ tt_fail();
+ }
+}
+
+static void
+test_crypto_s2k_errors(void *arg)
+{
+ uint8_t buf[S2K_MAXLEN], buf2[S2K_MAXLEN];
+ size_t sz;
+
+ (void)arg;
+
+ /* Bogus specifiers: simple */
+ tt_int_op(S2K_BAD_LEN, ==,
+ secret_to_key_derivekey(buf, sizeof(buf),
+ (const uint8_t*)"", 0, "ABC", 3));
+ tt_int_op(S2K_BAD_ALGORITHM, ==,
+ secret_to_key_derivekey(buf, sizeof(buf),
+ (const uint8_t*)"\x10", 1, "ABC", 3));
+ tt_int_op(S2K_BAD_LEN, ==,
+ secret_to_key_derivekey(buf, sizeof(buf),
+ (const uint8_t*)"\x01\x02", 2, "ABC", 3));
+
+ tt_int_op(S2K_BAD_LEN, ==,
+ secret_to_key_check((const uint8_t*)"", 0, "ABC", 3));
+ tt_int_op(S2K_BAD_ALGORITHM, ==,
+ secret_to_key_check((const uint8_t*)"\x10", 1, "ABC", 3));
+ tt_int_op(S2K_BAD_LEN, ==,
+ secret_to_key_check((const uint8_t*)"\x01\x02", 2, "ABC", 3));
+
+ /* too long gets "BAD_LEN" too */
+ memset(buf, 0, sizeof(buf));
+ buf[0] = 2;
+ tt_int_op(S2K_BAD_LEN, ==,
+ secret_to_key_derivekey(buf2, sizeof(buf2),
+ buf, sizeof(buf), "ABC", 3));
+
+ /* Truncated output */
+#ifdef HAVE_LIBSCRYPT_H
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_new(buf, 50, &sz,
+ "ABC", 3, 0));
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_new(buf, 50, &sz,
+ "ABC", 3, S2K_FLAG_LOW_MEM));
+#endif
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_new(buf, 37, &sz,
+ "ABC", 3, S2K_FLAG_USE_PBKDF2));
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_new(buf, 29, &sz,
+ "ABC", 3, S2K_FLAG_NO_SCRYPT));
+
+#ifdef HAVE_LIBSCRYPT_H
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_make_specifier(buf, 18, 0));
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_make_specifier(buf, 18,
+ S2K_FLAG_LOW_MEM));
+#endif
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_make_specifier(buf, 17,
+ S2K_FLAG_USE_PBKDF2));
+ tt_int_op(S2K_TRUNCATED, ==, secret_to_key_make_specifier(buf, 9,
+ S2K_FLAG_NO_SCRYPT));
+
+ /* Now try using type-specific bogus specifiers. */
+
+ /* It's a bad pbkdf2 buffer if it has an iteration count that would overflow
+ * int32_t. */
+ memset(buf, 0, sizeof(buf));
+ buf[0] = 1; /* pbkdf2 */
+ buf[17] = 100; /* 1<<100 is much bigger than INT32_MAX */
+ tt_int_op(S2K_BAD_PARAMS, ==,
+ secret_to_key_derivekey(buf2, sizeof(buf2),
+ buf, 18, "ABC", 3));
+
+#ifdef HAVE_LIBSCRYPT_H
+ /* It's a bad scrypt buffer if N would overflow uint64 */
+ memset(buf, 0, sizeof(buf));
+ buf[0] = 2; /* scrypt */
+ buf[17] = 100; /* 1<<100 is much bigger than UINT64_MAX */
+ tt_int_op(S2K_BAD_PARAMS, ==,
+ secret_to_key_derivekey(buf2, sizeof(buf2),
+ buf, 19, "ABC", 3));
+#endif
+
+ done:
+ ;
+}
+
+static void
+test_crypto_scrypt_vectors(void *arg)
+{
+ char *mem_op_hex_tmp = NULL;
+ uint8_t spec[64], out[64];
+
+ (void)arg;
+#ifndef HAVE_LIBSCRYPT_H
+ if (1)
+ tt_skip();
+#endif
+
+ /* Test vectors from
+ http://tools.ietf.org/html/draft-josefsson-scrypt-kdf-00 section 11.
+
+ Note that the names of 'r' and 'N' are switched in that section. Or
+ possibly in libscrypt.
+ */
+
+ base16_decode((char*)spec, sizeof(spec),
+ "0400", 4);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(64, ==,
+ secret_to_key_compute_key(out, 64, spec, 2, "", 0, 2));
+ test_memeq_hex(out,
+ "77d6576238657b203b19ca42c18a0497"
+ "f16b4844e3074ae8dfdffa3fede21442"
+ "fcd0069ded0948f8326a753a0fc81f17"
+ "e8d3e0fb2e0d3628cf35e20c38d18906");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "4e61436c" "0A34", 12);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(64, ==,
+ secret_to_key_compute_key(out, 64, spec, 6, "password", 8, 2));
+ test_memeq_hex(out,
+ "fdbabe1c9d3472007856e7190d01e9fe"
+ "7c6ad7cbc8237830e77376634b373162"
+ "2eaf30d92e22a3886ff109279d9830da"
+ "c727afb94a83ee6d8360cbdfa2cc0640");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "536f6469756d43686c6f72696465" "0e30", 32);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(64, ==,
+ secret_to_key_compute_key(out, 64, spec, 16,
+ "pleaseletmein", 13, 2));
+ test_memeq_hex(out,
+ "7023bdcb3afd7348461c06cd81fd38eb"
+ "fda8fbba904f8e3ea9b543f6545da1f2"
+ "d5432955613f0fcf62d49705242a9af9"
+ "e61e85dc0d651e40dfcf017b45575887");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "536f6469756d43686c6f72696465" "1430", 32);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(64, ==,
+ secret_to_key_compute_key(out, 64, spec, 16,
+ "pleaseletmein", 13, 2));
+ test_memeq_hex(out,
+ "2101cb9b6a511aaeaddbbe09cf70f881"
+ "ec568d574a2ffd4dabe5ee9820adaa47"
+ "8e56fd8f4ba5d09ffa1c6d927c40f4c3"
+ "37304049e8a952fbcbf45c6fa77a41a4");
+
+ done:
+ tor_free(mem_op_hex_tmp);
+}
+
+static void
+test_crypto_pbkdf2_vectors(void *arg)
+{
+ char *mem_op_hex_tmp = NULL;
+ uint8_t spec[64], out[64];
+ (void)arg;
+
+ /* Test vectors from RFC6070, section 2 */
+ base16_decode((char*)spec, sizeof(spec),
+ "73616c74" "00" , 10);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(20, ==,
+ secret_to_key_compute_key(out, 20, spec, 5, "password", 8, 1));
+ test_memeq_hex(out, "0c60c80f961f0e71f3a9b524af6012062fe037a6");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "73616c74" "01" , 10);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(20, ==,
+ secret_to_key_compute_key(out, 20, spec, 5, "password", 8, 1));
+ test_memeq_hex(out, "ea6c014dc72d6f8ccd1ed92ace1d41f0d8de8957");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "73616c74" "0C" , 10);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(20, ==,
+ secret_to_key_compute_key(out, 20, spec, 5, "password", 8, 1));
+ test_memeq_hex(out, "4b007901b765489abead49d926f721d065a429c1");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "73616c74" "18" , 10);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(20, ==,
+ secret_to_key_compute_key(out, 20, spec, 5, "password", 8, 1));
+ test_memeq_hex(out, "eefe3d61cd4da4e4e9945b3d6ba2158c2634e984");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "73616c7453414c5473616c7453414c5473616c745"
+ "3414c5473616c7453414c5473616c74" "0C" , 74);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(25, ==,
+ secret_to_key_compute_key(out, 25, spec, 37,
+ "passwordPASSWORDpassword", 24, 1));
+ test_memeq_hex(out, "3d2eec4fe41c849b80c8d83662c0e44a8b291a964cf2f07038");
+
+ base16_decode((char*)spec, sizeof(spec),
+ "7361006c74" "0c" , 12);
+ memset(out, 0x00, sizeof(out));
+ tt_int_op(16, ==,
+ secret_to_key_compute_key(out, 16, spec, 6, "pass\0word", 9, 1));
+ test_memeq_hex(out, "56fa6aa75548099dcc37d7f03425e0c3");
+
+ done:
+ tor_free(mem_op_hex_tmp);
+}
+
+static void
+test_crypto_pwbox(void *arg)
+{
+ uint8_t *boxed=NULL, *decoded=NULL;
+ size_t len, dlen;
+ unsigned i;
+ const char msg[] = "This bunny reminds you that you still have a "
+ "salamander in your sylladex. She is holding the bunny Dave got you. "
+ "It’s sort of uncanny how similar they are, aside from the knitted "
+ "enhancements. Seriously, what are the odds?? So weird.";
+ const char pw[] = "I'm a night owl and a wise bird too";
+
+ const unsigned flags[] = { 0,
+ S2K_FLAG_NO_SCRYPT,
+ S2K_FLAG_LOW_MEM,
+ S2K_FLAG_NO_SCRYPT|S2K_FLAG_LOW_MEM,
+ S2K_FLAG_USE_PBKDF2 };
+ (void)arg;
+
+ for (i = 0; i < ARRAY_LENGTH(flags); ++i) {
+ tt_int_op(0, ==, crypto_pwbox(&boxed, &len,
+ (const uint8_t*)msg, strlen(msg),
+ pw, strlen(pw), flags[i]));
+ tt_assert(boxed);
+ tt_assert(len > 128+32);
+
+ tt_int_op(0, ==, crypto_unpwbox(&decoded, &dlen, boxed, len,
+ pw, strlen(pw)));
+
+ tt_assert(decoded);
+ tt_uint_op(dlen, ==, strlen(msg));
+ tt_mem_op(decoded, ==, msg, dlen);
+
+ tor_free(decoded);
+
+ tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen,
+ boxed, len,
+ pw, strlen(pw)-1));
+ boxed[len-1] ^= 1;
+ tt_int_op(UNPWBOX_BAD_SECRET, ==, crypto_unpwbox(&decoded, &dlen,
+ boxed, len,
+ pw, strlen(pw)));
+ boxed[0] = 255;
+ tt_int_op(UNPWBOX_CORRUPTED, ==, crypto_unpwbox(&decoded, &dlen,
+ boxed, len,
+ pw, strlen(pw)));
+
+ tor_free(boxed);
+ }
+
+ done:
+ tor_free(boxed);
+ tor_free(decoded);
+}
+
/** Test AES-CTR encryption and decryption with IV. */
static void
test_crypto_aes_iv(void *arg)
@@ -757,79 +1114,79 @@ test_crypto_aes_iv(void *arg)
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted1, 16 + 4095,
plain, 4095);
- test_eq(encrypted_size, 16 + 4095);
+ tt_int_op(encrypted_size,==, 16 + 4095);
tt_assert(encrypted_size > 0); /* This is obviously true, since 4111 is
* greater than 0, but its truth is not
* obvious to all analysis tools. */
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 4095,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 4095);
+ tt_int_op(decrypted_size,==, 4095);
tt_assert(decrypted_size > 0);
- test_memeq(plain, decrypted1, 4095);
+ tt_mem_op(plain,==, decrypted1, 4095);
/* Encrypt a second time (with a new random initialization vector). */
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted2, 16 + 4095,
plain, 4095);
- test_eq(encrypted_size, 16 + 4095);
+ tt_int_op(encrypted_size,==, 16 + 4095);
tt_assert(encrypted_size > 0);
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted2, 4095,
encrypted2, encrypted_size);
- test_eq(decrypted_size, 4095);
+ tt_int_op(decrypted_size,==, 4095);
tt_assert(decrypted_size > 0);
- test_memeq(plain, decrypted2, 4095);
- test_memneq(encrypted1, encrypted2, encrypted_size);
+ tt_mem_op(plain,==, decrypted2, 4095);
+ tt_mem_op(encrypted1,!=, encrypted2, encrypted_size);
/* Decrypt with the wrong key. */
decrypted_size = crypto_cipher_decrypt_with_iv(key2, decrypted2, 4095,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 4095);
- test_memneq(plain, decrypted2, decrypted_size);
+ tt_int_op(decrypted_size,==, 4095);
+ tt_mem_op(plain,!=, decrypted2, decrypted_size);
/* Alter the initialization vector. */
encrypted1[0] += 42;
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 4095,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 4095);
- test_memneq(plain, decrypted2, 4095);
+ tt_int_op(decrypted_size,==, 4095);
+ tt_mem_op(plain,!=, decrypted2, 4095);
/* Special length case: 1. */
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted1, 16 + 1,
plain_1, 1);
- test_eq(encrypted_size, 16 + 1);
+ tt_int_op(encrypted_size,==, 16 + 1);
tt_assert(encrypted_size > 0);
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 1,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 1);
+ tt_int_op(decrypted_size,==, 1);
tt_assert(decrypted_size > 0);
- test_memeq(plain_1, decrypted1, 1);
+ tt_mem_op(plain_1,==, decrypted1, 1);
/* Special length case: 15. */
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted1, 16 + 15,
plain_15, 15);
- test_eq(encrypted_size, 16 + 15);
+ tt_int_op(encrypted_size,==, 16 + 15);
tt_assert(encrypted_size > 0);
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 15,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 15);
+ tt_int_op(decrypted_size,==, 15);
tt_assert(decrypted_size > 0);
- test_memeq(plain_15, decrypted1, 15);
+ tt_mem_op(plain_15,==, decrypted1, 15);
/* Special length case: 16. */
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted1, 16 + 16,
plain_16, 16);
- test_eq(encrypted_size, 16 + 16);
+ tt_int_op(encrypted_size,==, 16 + 16);
tt_assert(encrypted_size > 0);
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 16,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 16);
+ tt_int_op(decrypted_size,==, 16);
tt_assert(decrypted_size > 0);
- test_memeq(plain_16, decrypted1, 16);
+ tt_mem_op(plain_16,==, decrypted1, 16);
/* Special length case: 17. */
encrypted_size = crypto_cipher_encrypt_with_iv(key1, encrypted1, 16 + 17,
plain_17, 17);
- test_eq(encrypted_size, 16 + 17);
+ tt_int_op(encrypted_size,==, 16 + 17);
tt_assert(encrypted_size > 0);
decrypted_size = crypto_cipher_decrypt_with_iv(key1, decrypted1, 17,
encrypted1, encrypted_size);
- test_eq(decrypted_size, 17);
+ tt_int_op(decrypted_size,==, 17);
tt_assert(decrypted_size > 0);
- test_memeq(plain_17, decrypted1, 17);
+ tt_mem_op(plain_17,==, decrypted1, 17);
done:
/* Free memory. */
@@ -842,34 +1199,35 @@ test_crypto_aes_iv(void *arg)
/** Test base32 decoding. */
static void
-test_crypto_base32_decode(void)
+test_crypto_base32_decode(void *arg)
{
char plain[60], encoded[96 + 1], decoded[60];
int res;
+ (void)arg;
crypto_rand(plain, 60);
/* Encode and decode a random string. */
base32_encode(encoded, 96 + 1, plain, 60);
res = base32_decode(decoded, 60, encoded, 96);
- test_eq(res, 0);
- test_memeq(plain, decoded, 60);
+ tt_int_op(res,==, 0);
+ tt_mem_op(plain,==, decoded, 60);
/* Encode, uppercase, and decode a random string. */
base32_encode(encoded, 96 + 1, plain, 60);
tor_strupper(encoded);
res = base32_decode(decoded, 60, encoded, 96);
- test_eq(res, 0);
- test_memeq(plain, decoded, 60);
+ tt_int_op(res,==, 0);
+ tt_mem_op(plain,==, decoded, 60);
/* Change encoded string and decode. */
if (encoded[0] == 'A' || encoded[0] == 'a')
encoded[0] = 'B';
else
encoded[0] = 'A';
res = base32_decode(decoded, 60, encoded, 96);
- test_eq(res, 0);
- test_memneq(plain, decoded, 60);
+ tt_int_op(res,==, 0);
+ tt_mem_op(plain,!=, decoded, 60);
/* Bad encodings. */
encoded[0] = '!';
res = base32_decode(decoded, 60, encoded, 96);
- test_assert(res < 0);
+ tt_int_op(0, >, res);
done:
;
@@ -972,7 +1330,6 @@ test_crypto_hkdf_sha256(void *arg)
#undef EXPAND
}
-#ifdef CURVE25519_ENABLED
static void
test_crypto_curve25519_impl(void *arg)
{
@@ -1024,7 +1381,7 @@ test_crypto_curve25519_impl(void *arg)
e2k[31] |= (byte & 0x80);
}
curve25519_impl(e1e2k,e1,e2k);
- test_memeq(e1e2k, e2e1k, 32);
+ tt_mem_op(e1e2k,==, e2e1k, 32);
if (loop == loop_max-1) {
break;
}
@@ -1056,11 +1413,11 @@ test_crypto_curve25519_wrappers(void *arg)
curve25519_secret_key_generate(&seckey2, 1);
curve25519_public_key_generate(&pubkey1, &seckey1);
curve25519_public_key_generate(&pubkey2, &seckey2);
- test_assert(curve25519_public_key_is_ok(&pubkey1));
- test_assert(curve25519_public_key_is_ok(&pubkey2));
+ tt_assert(curve25519_public_key_is_ok(&pubkey1));
+ tt_assert(curve25519_public_key_is_ok(&pubkey2));
curve25519_handshake(output1, &seckey1, &pubkey2);
curve25519_handshake(output2, &seckey2, &pubkey1);
- test_memeq(output1, output2, sizeof(output1));
+ tt_mem_op(output1,==, output2, sizeof(output1));
done:
;
@@ -1081,12 +1438,12 @@ test_crypto_curve25519_encode(void *arg)
tt_int_op(CURVE25519_BASE64_PADDED_LEN, ==, strlen(buf));
tt_int_op(0, ==, curve25519_public_from_base64(&key2, buf));
- test_memeq(key1.public_key, key2.public_key, CURVE25519_PUBKEY_LEN);
+ tt_mem_op(key1.public_key,==, key2.public_key, CURVE25519_PUBKEY_LEN);
buf[CURVE25519_BASE64_PADDED_LEN - 1] = '\0';
tt_int_op(CURVE25519_BASE64_PADDED_LEN-1, ==, strlen(buf));
tt_int_op(0, ==, curve25519_public_from_base64(&key3, buf));
- test_memeq(key1.public_key, key3.public_key, CURVE25519_PUBKEY_LEN);
+ tt_mem_op(key1.public_key,==, key3.public_key, CURVE25519_PUBKEY_LEN);
/* Now try bogus parses. */
strlcpy(buf, "$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$=", sizeof(buf));
@@ -1122,10 +1479,10 @@ test_crypto_curve25519_persist(void *arg)
tt_str_op(tag,==,"testing");
tor_free(tag);
- test_memeq(keypair.pubkey.public_key,
+ tt_mem_op(keypair.pubkey.public_key,==,
keypair2.pubkey.public_key,
CURVE25519_PUBKEY_LEN);
- test_memeq(keypair.seckey.secret_key,
+ tt_mem_op(keypair.seckey.secret_key,==,
keypair2.seckey.secret_key,
CURVE25519_SECKEY_LEN);
@@ -1137,11 +1494,11 @@ test_crypto_curve25519_persist(void *arg)
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,
+ tt_mem_op(keypair.seckey.secret_key,==,
cp,
CURVE25519_SECKEY_LEN);
cp += CURVE25519_SECKEY_LEN;
- test_memeq(keypair.pubkey.public_key,
+ tt_mem_op(keypair.pubkey.public_key,==,
cp,
CURVE25519_SECKEY_LEN);
@@ -1161,7 +1518,361 @@ test_crypto_curve25519_persist(void *arg)
tor_free(tag);
}
-#endif
+static void
+test_crypto_ed25519_simple(void *arg)
+{
+ ed25519_keypair_t kp1, kp2;
+ ed25519_public_key_t pub1, pub2;
+ ed25519_secret_key_t sec1, sec2;
+ ed25519_signature_t sig1, sig2;
+ const uint8_t msg[] =
+ "GNU will be able to run Unix programs, "
+ "but will not be identical to Unix.";
+ const uint8_t msg2[] =
+ "Microsoft Windows extends the features of the DOS operating system, "
+ "yet is compatible with most existing applications that run under DOS.";
+ size_t msg_len = strlen((const char*)msg);
+ size_t msg2_len = strlen((const char*)msg2);
+
+ (void)arg;
+
+ tt_int_op(0, ==, ed25519_secret_key_generate(&sec1, 0));
+ tt_int_op(0, ==, ed25519_secret_key_generate(&sec2, 1));
+
+ tt_int_op(0, ==, ed25519_public_key_generate(&pub1, &sec1));
+ tt_int_op(0, ==, ed25519_public_key_generate(&pub2, &sec1));
+
+ tt_mem_op(pub1.pubkey, ==, pub2.pubkey, sizeof(pub1.pubkey));
+
+ memcpy(&kp1.pubkey, &pub1, sizeof(pub1));
+ memcpy(&kp1.seckey, &sec1, sizeof(sec1));
+ tt_int_op(0, ==, ed25519_sign(&sig1, msg, msg_len, &kp1));
+ tt_int_op(0, ==, ed25519_sign(&sig2, msg, msg_len, &kp1));
+
+ /* Ed25519 signatures are deterministic */
+ tt_mem_op(sig1.sig, ==, sig2.sig, sizeof(sig1.sig));
+
+ /* Basic signature is valid. */
+ tt_int_op(0, ==, ed25519_checksig(&sig1, msg, msg_len, &pub1));
+
+ /* Altered signature doesn't work. */
+ sig1.sig[0] ^= 3;
+ tt_int_op(-1, ==, ed25519_checksig(&sig1, msg, msg_len, &pub1));
+
+ /* Wrong public key doesn't work. */
+ tt_int_op(0, ==, ed25519_public_key_generate(&pub2, &sec2));
+ tt_int_op(-1, ==, ed25519_checksig(&sig2, msg, msg_len, &pub2));
+
+ /* Wrong message doesn't work. */
+ tt_int_op(0, ==, ed25519_checksig(&sig2, msg, msg_len, &pub1));
+ tt_int_op(-1, ==, ed25519_checksig(&sig2, msg, msg_len-1, &pub1));
+ tt_int_op(-1, ==, ed25519_checksig(&sig2, msg2, msg2_len, &pub1));
+
+ /* Batch signature checking works with some bad. */
+ tt_int_op(0, ==, ed25519_keypair_generate(&kp2, 0));
+ tt_int_op(0, ==, ed25519_sign(&sig1, msg, msg_len, &kp2));
+ {
+ ed25519_checkable_t ch[] = {
+ { &pub1, sig2, msg, msg_len }, /*ok*/
+ { &pub1, sig2, msg, msg_len-1 }, /*bad*/
+ { &kp2.pubkey, sig2, msg2, msg2_len }, /*bad*/
+ { &kp2.pubkey, sig1, msg, msg_len }, /*ok*/
+ };
+ int okay[4];
+ tt_int_op(-2, ==, ed25519_checksig_batch(okay, ch, 4));
+ tt_int_op(okay[0], ==, 1);
+ tt_int_op(okay[1], ==, 0);
+ tt_int_op(okay[2], ==, 0);
+ tt_int_op(okay[3], ==, 1);
+ tt_int_op(-2, ==, ed25519_checksig_batch(NULL, ch, 4));
+ }
+
+ /* Batch signature checking works with all good. */
+ {
+ ed25519_checkable_t ch[] = {
+ { &pub1, sig2, msg, msg_len }, /*ok*/
+ { &kp2.pubkey, sig1, msg, msg_len }, /*ok*/
+ };
+ int okay[2];
+ tt_int_op(0, ==, ed25519_checksig_batch(okay, ch, 2));
+ tt_int_op(okay[0], ==, 1);
+ tt_int_op(okay[1], ==, 1);
+ tt_int_op(0, ==, ed25519_checksig_batch(NULL, ch, 2));
+ }
+
+ done:
+ ;
+}
+
+static void
+test_crypto_ed25519_test_vectors(void *arg)
+{
+ char *mem_op_hex_tmp=NULL;
+ int i;
+ struct {
+ const char *sk;
+ const char *pk;
+ const char *sig;
+ const char *msg;
+ } items[] = {
+ /* These test vectors were generated with the "ref" implementation of
+ * ed25519 from SUPERCOP-20130419 */
+ { "4c6574277320686f706520746865726520617265206e6f206275677320696e20",
+ "f3e0e493b30f56e501aeb868fc912fe0c8b76621efca47a78f6d75875193dd87",
+ "b5d7fd6fd3adf643647ce1fe87a2931dedd1a4e38e6c662bedd35cdd80bfac51"
+ "1b2c7d1ee6bd929ac213014e1a8dc5373854c7b25dbe15ec96bf6c94196fae06",
+ "506c6561736520657863757365206d7920667269656e642e2048652069736e2774"
+ "204e554c2d7465726d696e617465642e"
+ },
+
+ { "74686520696d706c656d656e746174696f6e20776869636820617265206e6f74",
+ "407f0025a1e1351a4cb68e92f5c0ebaf66e7aaf93a4006a4d1a66e3ede1cfeac",
+ "02884fde1c3c5944d0ecf2d133726fc820c303aae695adceabf3a1e01e95bf28"
+ "da88c0966f5265e9c6f8edc77b3b96b5c91baec3ca993ccd21a3f64203600601",
+ "506c6561736520657863757365206d7920667269656e642e2048652069736e2774"
+ "204e554c2d7465726d696e617465642e"
+ },
+ { "6578706f73656420627920456e676c697368207465787420617320696e707574",
+ "61681cb5fbd69f9bc5a462a21a7ab319011237b940bc781cdc47fcbe327e7706",
+ "6a127d0414de7510125d4bc214994ffb9b8857a46330832d05d1355e882344ad"
+ "f4137e3ca1f13eb9cc75c887ef2309b98c57528b4acd9f6376c6898889603209",
+ "506c6561736520657863757365206d7920667269656e642e2048652069736e2774"
+ "204e554c2d7465726d696e617465642e"
+ },
+
+ /* These come from "sign.input" in ed25519's page */
+ { "5b5a619f8ce1c66d7ce26e5a2ae7b0c04febcd346d286c929e19d0d5973bfef9",
+ "6fe83693d011d111131c4f3fbaaa40a9d3d76b30012ff73bb0e39ec27ab18257",
+ "0f9ad9793033a2fa06614b277d37381e6d94f65ac2a5a94558d09ed6ce922258"
+ "c1a567952e863ac94297aec3c0d0c8ddf71084e504860bb6ba27449b55adc40e",
+ "5a8d9d0a22357e6655f9c785"
+ },
+ { "940c89fe40a81dafbdb2416d14ae469119869744410c3303bfaa0241dac57800",
+ "a2eb8c0501e30bae0cf842d2bde8dec7386f6b7fc3981b8c57c9792bb94cf2dd",
+ "d8bb64aad8c9955a115a793addd24f7f2b077648714f49c4694ec995b330d09d"
+ "640df310f447fd7b6cb5c14f9fe9f490bcf8cfadbfd2169c8ac20d3b8af49a0c",
+ "b87d3813e03f58cf19fd0b6395"
+ },
+ { "9acad959d216212d789a119252ebfe0c96512a23c73bd9f3b202292d6916a738",
+ "cf3af898467a5b7a52d33d53bc037e2642a8da996903fc252217e9c033e2f291",
+ "6ee3fe81e23c60eb2312b2006b3b25e6838e02106623f844c44edb8dafd66ab0"
+ "671087fd195df5b8f58a1d6e52af42908053d55c7321010092748795ef94cf06",
+ "55c7fa434f5ed8cdec2b7aeac173",
+ },
+ { "d5aeee41eeb0e9d1bf8337f939587ebe296161e6bf5209f591ec939e1440c300",
+ "fd2a565723163e29f53c9de3d5e8fbe36a7ab66e1439ec4eae9c0a604af291a5",
+ "f68d04847e5b249737899c014d31c805c5007a62c0a10d50bb1538c5f3550395"
+ "1fbc1e08682f2cc0c92efe8f4985dec61dcbd54d4b94a22547d24451271c8b00",
+ "0a688e79be24f866286d4646b5d81c"
+ },
+
+ { NULL, NULL, NULL, NULL}
+ };
+
+ (void)arg;
+
+ for (i = 0; items[i].pk; ++i) {
+ ed25519_keypair_t kp;
+ ed25519_signature_t sig;
+ uint8_t sk_seed[32];
+ uint8_t *msg;
+ size_t msg_len;
+ base16_decode((char*)sk_seed, sizeof(sk_seed),
+ items[i].sk, 64);
+ ed25519_secret_key_from_seed(&kp.seckey, sk_seed);
+ tt_int_op(0, ==, ed25519_public_key_generate(&kp.pubkey, &kp.seckey));
+ test_memeq_hex(kp.pubkey.pubkey, items[i].pk);
+
+ msg_len = strlen(items[i].msg) / 2;
+ msg = tor_malloc(msg_len);
+ base16_decode((char*)msg, msg_len, items[i].msg, strlen(items[i].msg));
+
+ tt_int_op(0, ==, ed25519_sign(&sig, msg, msg_len, &kp));
+ test_memeq_hex(sig.sig, items[i].sig);
+
+ tor_free(msg);
+ }
+
+ done:
+ tor_free(mem_op_hex_tmp);
+}
+
+static void
+test_crypto_ed25519_encode(void *arg)
+{
+ char buf[ED25519_BASE64_LEN+1];
+ ed25519_keypair_t kp;
+ ed25519_public_key_t pk;
+ char *mem_op_hex_tmp = NULL;
+ (void) arg;
+
+ /* Test roundtrip. */
+ tt_int_op(0, ==, ed25519_keypair_generate(&kp, 0));
+ tt_int_op(0, ==, ed25519_public_to_base64(buf, &kp.pubkey));
+ tt_int_op(ED25519_BASE64_LEN, ==, strlen(buf));
+ tt_int_op(0, ==, ed25519_public_from_base64(&pk, buf));
+ tt_mem_op(kp.pubkey.pubkey, ==, pk.pubkey, ED25519_PUBKEY_LEN);
+
+ /* Test known value. */
+ tt_int_op(0, ==, ed25519_public_from_base64(&pk,
+ "lVIuIctLjbGZGU5wKMNXxXlSE3cW4kaqkqm04u6pxvM"));
+ test_memeq_hex(pk.pubkey,
+ "95522e21cb4b8db199194e7028c357c57952137716e246aa92a9b4e2eea9c6f3");
+
+ done:
+ tor_free(mem_op_hex_tmp);
+}
+
+static void
+test_crypto_ed25519_convert(void *arg)
+{
+ const uint8_t msg[] =
+ "The eyes are not here / There are no eyes here.";
+ const int N = 30;
+ int i;
+ (void)arg;
+
+ for (i = 0; i < N; ++i) {
+ curve25519_keypair_t curve25519_keypair;
+ ed25519_keypair_t ed25519_keypair;
+ ed25519_public_key_t ed25519_pubkey;
+
+ int bit=0;
+ ed25519_signature_t sig;
+
+ tt_int_op(0,==,curve25519_keypair_generate(&curve25519_keypair, i&1));
+ tt_int_op(0,==,ed25519_keypair_from_curve25519_keypair(
+ &ed25519_keypair, &bit, &curve25519_keypair));
+ tt_int_op(0,==,ed25519_public_key_from_curve25519_public_key(
+ &ed25519_pubkey, &curve25519_keypair.pubkey, bit));
+ tt_mem_op(ed25519_pubkey.pubkey, ==, ed25519_keypair.pubkey.pubkey, 32);
+
+ tt_int_op(0,==,ed25519_sign(&sig, msg, sizeof(msg), &ed25519_keypair));
+ tt_int_op(0,==,ed25519_checksig(&sig, msg, sizeof(msg),
+ &ed25519_pubkey));
+
+ tt_int_op(-1,==,ed25519_checksig(&sig, msg, sizeof(msg)-1,
+ &ed25519_pubkey));
+ sig.sig[0] ^= 15;
+ tt_int_op(-1,==,ed25519_checksig(&sig, msg, sizeof(msg),
+ &ed25519_pubkey));
+ }
+
+ done:
+ ;
+}
+
+static void
+test_crypto_ed25519_blinding(void *arg)
+{
+ const uint8_t msg[] =
+ "Eyes I dare not meet in dreams / In death's dream kingdom";
+
+ const int N = 30;
+ int i;
+ (void)arg;
+
+ for (i = 0; i < N; ++i) {
+ uint8_t blinding[32];
+ ed25519_keypair_t ed25519_keypair;
+ ed25519_keypair_t ed25519_keypair_blinded;
+ ed25519_public_key_t ed25519_pubkey_blinded;
+
+ ed25519_signature_t sig;
+
+ crypto_rand((char*) blinding, sizeof(blinding));
+
+ tt_int_op(0,==,ed25519_keypair_generate(&ed25519_keypair, 0));
+ tt_int_op(0,==,ed25519_keypair_blind(&ed25519_keypair_blinded,
+ &ed25519_keypair, blinding));
+
+ tt_int_op(0,==,ed25519_public_blind(&ed25519_pubkey_blinded,
+ &ed25519_keypair.pubkey, blinding));
+
+ tt_mem_op(ed25519_pubkey_blinded.pubkey, ==,
+ ed25519_keypair_blinded.pubkey.pubkey, 32);
+
+ tt_int_op(0,==,ed25519_sign(&sig, msg, sizeof(msg),
+ &ed25519_keypair_blinded));
+
+ tt_int_op(0,==,ed25519_checksig(&sig, msg, sizeof(msg),
+ &ed25519_pubkey_blinded));
+
+ tt_int_op(-1,==,ed25519_checksig(&sig, msg, sizeof(msg)-1,
+ &ed25519_pubkey_blinded));
+ sig.sig[0] ^= 15;
+ tt_int_op(-1,==,ed25519_checksig(&sig, msg, sizeof(msg),
+ &ed25519_pubkey_blinded));
+ }
+
+ done:
+ ;
+}
+
+static void
+test_crypto_ed25519_testvectors(void *arg)
+{
+ unsigned i;
+ char *mem_op_hex_tmp = NULL;
+ (void)arg;
+
+ for (i = 0; i < ARRAY_LENGTH(ED25519_SECRET_KEYS); ++i) {
+ uint8_t sk[32];
+ ed25519_secret_key_t esk;
+ ed25519_public_key_t pk, blind_pk, pkfromcurve;
+ ed25519_keypair_t keypair, blind_keypair;
+ curve25519_keypair_t curvekp;
+ uint8_t blinding_param[32];
+ ed25519_signature_t sig;
+ int sign;
+
+#define DECODE(p,s) base16_decode((char*)(p),sizeof(p),(s),strlen(s))
+#define EQ(a,h) test_memeq_hex((const char*)(a), (h))
+
+ tt_int_op(0, ==, DECODE(sk, ED25519_SECRET_KEYS[i]));
+ tt_int_op(0, ==, DECODE(blinding_param, ED25519_BLINDING_PARAMS[i]));
+
+ tt_int_op(0, ==, ed25519_secret_key_from_seed(&esk, sk));
+ EQ(esk.seckey, ED25519_EXPANDED_SECRET_KEYS[i]);
+
+ tt_int_op(0, ==, ed25519_public_key_generate(&pk, &esk));
+ EQ(pk.pubkey, ED25519_PUBLIC_KEYS[i]);
+
+ memcpy(&curvekp.seckey.secret_key, esk.seckey, 32);
+ curve25519_public_key_generate(&curvekp.pubkey, &curvekp.seckey);
+
+ tt_int_op(0, ==,
+ ed25519_keypair_from_curve25519_keypair(&keypair, &sign, &curvekp));
+ tt_int_op(0, ==, ed25519_public_key_from_curve25519_public_key(
+ &pkfromcurve, &curvekp.pubkey, sign));
+ tt_mem_op(keypair.pubkey.pubkey, ==, pkfromcurve.pubkey, 32);
+ EQ(curvekp.pubkey.public_key, ED25519_CURVE25519_PUBLIC_KEYS[i]);
+
+ /* Self-signing */
+ memcpy(&keypair.seckey, &esk, sizeof(esk));
+ memcpy(&keypair.pubkey, &pk, sizeof(pk));
+
+ tt_int_op(0, ==, ed25519_sign(&sig, pk.pubkey, 32, &keypair));
+
+ EQ(sig.sig, ED25519_SELF_SIGNATURES[i]);
+
+ /* Blinding */
+ tt_int_op(0, ==,
+ ed25519_keypair_blind(&blind_keypair, &keypair, blinding_param));
+ tt_int_op(0, ==,
+ ed25519_public_blind(&blind_pk, &pk, blinding_param));
+
+ EQ(blind_keypair.seckey.seckey, ED25519_BLINDED_SECRET_KEYS[i]);
+ EQ(blind_pk.pubkey, ED25519_BLINDED_PUBLIC_KEYS[i]);
+
+ tt_mem_op(blind_pk.pubkey, ==, blind_keypair.pubkey.pubkey, 32);
+
+#undef DECODE
+#undef EQ
+ }
+ done:
+ tor_free(mem_op_hex_tmp);
+}
static void
test_crypto_siphash(void *arg)
@@ -1276,7 +1987,7 @@ static const struct testcase_setup_t pass_data = {
};
#define CRYPTO_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_crypto_ ## name }
+ { #name, test_crypto_ ## name , 0, NULL, NULL }
struct testcase_t crypto_tests[] = {
CRYPTO_LEGACY(formats),
@@ -1288,19 +1999,39 @@ struct testcase_t crypto_tests[] = {
{ "pk_fingerprints", test_crypto_pk_fingerprints, TT_FORK, NULL, NULL },
CRYPTO_LEGACY(digests),
CRYPTO_LEGACY(dh),
- CRYPTO_LEGACY(s2k),
+ CRYPTO_LEGACY(s2k_rfc2440),
+#ifdef HAVE_LIBSCRYPT_H
+ { "s2k_scrypt", test_crypto_s2k_general, 0, &pass_data,
+ (void*)"scrypt" },
+ { "s2k_scrypt_low", test_crypto_s2k_general, 0, &pass_data,
+ (void*)"scrypt-low" },
+#endif
+ { "s2k_pbkdf2", test_crypto_s2k_general, 0, &pass_data,
+ (void*)"pbkdf2" },
+ { "s2k_rfc2440_general", test_crypto_s2k_general, 0, &pass_data,
+ (void*)"rfc2440" },
+ { "s2k_rfc2440_legacy", test_crypto_s2k_general, 0, &pass_data,
+ (void*)"rfc2440-legacy" },
+ { "s2k_errors", test_crypto_s2k_errors, 0, NULL, NULL },
+ { "scrypt_vectors", test_crypto_scrypt_vectors, 0, NULL, NULL },
+ { "pbkdf2_vectors", test_crypto_pbkdf2_vectors, 0, NULL, NULL },
+ { "pwbox", test_crypto_pwbox, 0, NULL, NULL },
{ "aes_iv_AES", test_crypto_aes_iv, TT_FORK, &pass_data, (void*)"aes" },
{ "aes_iv_EVP", test_crypto_aes_iv, TT_FORK, &pass_data, (void*)"evp" },
CRYPTO_LEGACY(base32_decode),
{ "kdf_TAP", test_crypto_kdf_TAP, 0, NULL, NULL },
{ "hkdf_sha256", test_crypto_hkdf_sha256, 0, NULL, NULL },
-#ifdef CURVE25519_ENABLED
{ "curve25519_impl", test_crypto_curve25519_impl, 0, NULL, NULL },
{ "curve25519_impl_hibit", test_crypto_curve25519_impl, 0, NULL, (void*)"y"},
{ "curve25519_wrappers", test_crypto_curve25519_wrappers, 0, NULL, NULL },
{ "curve25519_encode", test_crypto_curve25519_encode, 0, NULL, NULL },
{ "curve25519_persist", test_crypto_curve25519_persist, 0, NULL, NULL },
-#endif
+ { "ed25519_simple", test_crypto_ed25519_simple, 0, NULL, NULL },
+ { "ed25519_test_vectors", test_crypto_ed25519_test_vectors, 0, NULL, NULL },
+ { "ed25519_encode", test_crypto_ed25519_encode, 0, NULL, NULL },
+ { "ed25519_convert", test_crypto_ed25519_convert, 0, NULL, NULL },
+ { "ed25519_blinding", test_crypto_ed25519_blinding, 0, NULL, NULL },
+ { "ed25519_testvectors", test_crypto_ed25519_testvectors, 0, NULL, NULL },
{ "siphash", test_crypto_siphash, 0, NULL, NULL },
END_OF_TESTCASES
};
diff --git a/src/test/test_data.c b/src/test/test_data.c
index 0c51c98f1e..0e6f79f33c 100644
--- a/src/test/test_data.c
+++ b/src/test/test_data.c
@@ -1,6 +1,6 @@
/* Copyright 2001-2004 Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/* Our unit test expect that the AUTHORITY_CERT_* public keys will sort
diff --git a/src/test/test_dir.c b/src/test/test_dir.c
index c03b63be27..c7e22d8cec 100644
--- a/src/test/test_dir.c
+++ b/src/test/test_dir.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -25,55 +25,56 @@
#include "test.h"
static void
-test_dir_nicknames(void)
+test_dir_nicknames(void *arg)
{
- test_assert( is_legal_nickname("a"));
- test_assert(!is_legal_nickname(""));
- test_assert(!is_legal_nickname("abcdefghijklmnopqrst")); /* 20 chars */
- test_assert(!is_legal_nickname("hyphen-")); /* bad char */
- test_assert( is_legal_nickname("abcdefghijklmnopqrs")); /* 19 chars */
- test_assert(!is_legal_nickname("$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
+ (void)arg;
+ tt_assert( is_legal_nickname("a"));
+ tt_assert(!is_legal_nickname(""));
+ tt_assert(!is_legal_nickname("abcdefghijklmnopqrst")); /* 20 chars */
+ tt_assert(!is_legal_nickname("hyphen-")); /* bad char */
+ tt_assert( is_legal_nickname("abcdefghijklmnopqrs")); /* 19 chars */
+ tt_assert(!is_legal_nickname("$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
/* valid */
- test_assert( is_legal_nickname_or_hexdigest(
+ tt_assert( is_legal_nickname_or_hexdigest(
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA"));
- test_assert( is_legal_nickname_or_hexdigest(
+ tt_assert( is_legal_nickname_or_hexdigest(
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA=fred"));
- test_assert( is_legal_nickname_or_hexdigest(
+ tt_assert( is_legal_nickname_or_hexdigest(
"$AAAAAAAA01234AAAAAAAAAAAAAAAAAAAAAAAAAAA~fred"));
/* too short */
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
/* illegal char */
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAzAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
/* hex part too long */
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"));
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=fred"));
/* Bad nickname */
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA="));
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~"));
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~hyphen-"));
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~"
"abcdefghijklmnoppqrst"));
/* Bad extra char. */
- test_assert(!is_legal_nickname_or_hexdigest(
+ tt_assert(!is_legal_nickname_or_hexdigest(
"$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA!"));
- test_assert(is_legal_nickname_or_hexdigest("xyzzy"));
- test_assert(is_legal_nickname_or_hexdigest("abcdefghijklmnopqrs"));
- test_assert(!is_legal_nickname_or_hexdigest("abcdefghijklmnopqrst"));
+ tt_assert(is_legal_nickname_or_hexdigest("xyzzy"));
+ tt_assert(is_legal_nickname_or_hexdigest("abcdefghijklmnopqrs"));
+ tt_assert(!is_legal_nickname_or_hexdigest("abcdefghijklmnopqrst"));
done:
;
}
/** Run unit tests for router descriptor generation logic. */
static void
-test_dir_formats(void)
+test_dir_formats(void *arg)
{
char *buf = NULL;
char buf2[8192];
@@ -89,10 +90,11 @@ test_dir_formats(void)
or_options_t *options = get_options_mutable();
const addr_policy_t *p;
+ (void)arg;
pk1 = pk_generate(0);
pk2 = pk_generate(1);
- test_assert(pk1 && pk2);
+ tt_assert(pk1 && pk2);
hibernate_set_state_for_testing_(HIBERNATE_STATE_LIVE);
@@ -140,9 +142,9 @@ test_dir_formats(void)
smartlist_add(r2->exit_policy, ex2);
r2->nickname = tor_strdup("Fred");
- test_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str,
+ tt_assert(!crypto_pk_write_public_key_to_string(pk1, &pk1_str,
&pk1_str_len));
- test_assert(!crypto_pk_write_public_key_to_string(pk2 , &pk2_str,
+ tt_assert(!crypto_pk_write_public_key_to_string(pk2 , &pk2_str,
&pk2_str_len));
/* XXXX025 router_dump_to_string should really take this from ri.*/
@@ -150,7 +152,7 @@ test_dir_formats(void)
"<magri@elsewhere.example.com>");
buf = router_dump_router_to_string(r1, pk2);
tor_free(options->ContactInfo);
- test_assert(buf);
+ tt_assert(buf);
strlcpy(buf2, "router Magri 192.168.0.1 9000 0 9003\n"
"or-address [1:2:3:4::]:9999\n"
@@ -160,7 +162,7 @@ test_dir_formats(void)
"protocols Link 1 2 Circuit 1\n"
"published 1970-01-01 00:00:00\n"
"fingerprint ", sizeof(buf2));
- test_assert(!crypto_pk_get_fingerprint(pk2, fingerprint, 1));
+ tt_assert(!crypto_pk_get_fingerprint(pk2, fingerprint, 1));
strlcat(buf2, fingerprint, sizeof(buf2));
strlcat(buf2, "\nuptime 0\n"
/* XXX the "0" above is hard-coded, but even if we made it reflect
@@ -178,23 +180,23 @@ test_dir_formats(void)
buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
* twice */
- test_streq(buf, buf2);
+ tt_str_op(buf,==, buf2);
tor_free(buf);
buf = router_dump_router_to_string(r1, pk2);
- test_assert(buf);
+ tt_assert(buf);
cp = buf;
- rp1 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL);
- test_assert(rp1);
- test_eq(rp1->addr, r1->addr);
- test_eq(rp1->or_port, r1->or_port);
+ rp1 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
+ tt_assert(rp1);
+ tt_int_op(rp1->addr,==, r1->addr);
+ tt_int_op(rp1->or_port,==, r1->or_port);
//test_eq(rp1->dir_port, r1->dir_port);
- test_eq(rp1->bandwidthrate, r1->bandwidthrate);
- test_eq(rp1->bandwidthburst, r1->bandwidthburst);
- test_eq(rp1->bandwidthcapacity, r1->bandwidthcapacity);
- test_assert(crypto_pk_cmp_keys(rp1->onion_pkey, pk1) == 0);
- test_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0);
- //test_assert(rp1->exit_policy == NULL);
+ tt_int_op(rp1->bandwidthrate,==, r1->bandwidthrate);
+ tt_int_op(rp1->bandwidthburst,==, r1->bandwidthburst);
+ tt_int_op(rp1->bandwidthcapacity,==, r1->bandwidthcapacity);
+ tt_assert(crypto_pk_cmp_keys(rp1->onion_pkey, pk1) == 0);
+ tt_assert(crypto_pk_cmp_keys(rp1->identity_pkey, pk2) == 0);
+ //tt_assert(rp1->exit_policy == NULL);
tor_free(buf);
strlcpy(buf2,
@@ -205,7 +207,7 @@ test_dir_formats(void)
"protocols Link 1 2 Circuit 1\n"
"published 1970-01-01 00:00:05\n"
"fingerprint ", sizeof(buf2));
- test_assert(!crypto_pk_get_fingerprint(pk1, fingerprint, 1));
+ tt_assert(!crypto_pk_get_fingerprint(pk1, fingerprint, 1));
strlcat(buf2, fingerprint, sizeof(buf2));
strlcat(buf2, "\nuptime 0\n"
"bandwidth 3000 3000 3000\n", sizeof(buf2));
@@ -214,61 +216,57 @@ test_dir_formats(void)
strlcat(buf2, "signing-key\n", sizeof(buf2));
strlcat(buf2, pk1_str, sizeof(buf2));
strlcat(buf2, "hidden-service-dir\n", sizeof(buf2));
-#ifdef CURVE25519_ENABLED
strlcat(buf2, "ntor-onion-key "
"skyinAnvardNostarsNomoonNowindormistsorsnow=\n", sizeof(buf2));
-#endif
strlcat(buf2, "accept *:80\nreject 18.0.0.0/8:24\n", sizeof(buf2));
strlcat(buf2, "router-signature\n", sizeof(buf2));
buf = router_dump_router_to_string(r2, pk1);
buf[strlen(buf2)] = '\0'; /* Don't compare the sig; it's never the same
* twice */
- test_streq(buf, buf2);
+ tt_str_op(buf,==, buf2);
tor_free(buf);
buf = router_dump_router_to_string(r2, pk1);
cp = buf;
- rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL);
- test_assert(rp2);
- test_eq(rp2->addr, r2->addr);
- test_eq(rp2->or_port, r2->or_port);
- test_eq(rp2->dir_port, r2->dir_port);
- test_eq(rp2->bandwidthrate, r2->bandwidthrate);
- test_eq(rp2->bandwidthburst, r2->bandwidthburst);
- test_eq(rp2->bandwidthcapacity, r2->bandwidthcapacity);
-#ifdef CURVE25519_ENABLED
- test_memeq(rp2->onion_curve25519_pkey->public_key,
+ rp2 = router_parse_entry_from_string((const char*)cp,NULL,1,0,NULL,NULL);
+ tt_assert(rp2);
+ tt_int_op(rp2->addr,==, r2->addr);
+ tt_int_op(rp2->or_port,==, r2->or_port);
+ tt_int_op(rp2->dir_port,==, r2->dir_port);
+ tt_int_op(rp2->bandwidthrate,==, r2->bandwidthrate);
+ tt_int_op(rp2->bandwidthburst,==, r2->bandwidthburst);
+ tt_int_op(rp2->bandwidthcapacity,==, r2->bandwidthcapacity);
+ tt_mem_op(rp2->onion_curve25519_pkey->public_key,==,
r2->onion_curve25519_pkey->public_key,
CURVE25519_PUBKEY_LEN);
-#endif
- test_assert(crypto_pk_cmp_keys(rp2->onion_pkey, pk2) == 0);
- test_assert(crypto_pk_cmp_keys(rp2->identity_pkey, pk1) == 0);
+ tt_assert(crypto_pk_cmp_keys(rp2->onion_pkey, pk2) == 0);
+ tt_assert(crypto_pk_cmp_keys(rp2->identity_pkey, pk1) == 0);
- test_eq(smartlist_len(rp2->exit_policy), 2);
+ tt_int_op(smartlist_len(rp2->exit_policy),==, 2);
p = smartlist_get(rp2->exit_policy, 0);
- test_eq(p->policy_type, ADDR_POLICY_ACCEPT);
- test_assert(tor_addr_is_null(&p->addr));
- test_eq(p->maskbits, 0);
- test_eq(p->prt_min, 80);
- test_eq(p->prt_max, 80);
+ tt_int_op(p->policy_type,==, ADDR_POLICY_ACCEPT);
+ tt_assert(tor_addr_is_null(&p->addr));
+ tt_int_op(p->maskbits,==, 0);
+ tt_int_op(p->prt_min,==, 80);
+ tt_int_op(p->prt_max,==, 80);
p = smartlist_get(rp2->exit_policy, 1);
- test_eq(p->policy_type, ADDR_POLICY_REJECT);
- test_assert(tor_addr_eq(&p->addr, &ex2->addr));
- test_eq(p->maskbits, 8);
- test_eq(p->prt_min, 24);
- test_eq(p->prt_max, 24);
+ tt_int_op(p->policy_type,==, ADDR_POLICY_REJECT);
+ tt_assert(tor_addr_eq(&p->addr, &ex2->addr));
+ tt_int_op(p->maskbits,==, 8);
+ tt_int_op(p->prt_min,==, 24);
+ tt_int_op(p->prt_max,==, 24);
#if 0
/* Okay, now for the directories. */
{
fingerprint_list = smartlist_new();
crypto_pk_get_fingerprint(pk2, buf, 1);
- add_fingerprint_to_dir("Magri", buf, fingerprint_list);
+ add_fingerprint_to_dir(buf, fingerprint_list, 0);
crypto_pk_get_fingerprint(pk1, buf, 1);
- add_fingerprint_to_dir("Fred", buf, fingerprint_list);
+ add_fingerprint_to_dir(buf, fingerprint_list, 0);
}
#endif
@@ -292,50 +290,551 @@ test_dir_formats(void)
tor_free(dir2); /* And more !*/
}
+#include "failing_routerdescs.inc"
+
+static void
+test_dir_routerparse_bad(void *arg)
+{
+ (void) arg;
+
+ int again;
+ routerinfo_t *ri = NULL;
+
+#define CHECK_OK(s) \
+ do { \
+ routerinfo_free(ri); \
+ ri = router_parse_entry_from_string((s), NULL, 0, 0, NULL, NULL); \
+ tt_assert(ri); \
+ } while (0)
+#define CHECK_FAIL(s, againval) \
+ do { \
+ routerinfo_free(ri); \
+ again = 999; \
+ ri = router_parse_entry_from_string((s), NULL, 0, 0, NULL, &again); \
+ tt_assert(ri == NULL); \
+ tt_int_op(again, ==, (againval)); \
+ } while (0)
+
+ CHECK_OK(EX_RI_MINIMAL);
+ CHECK_OK(EX_RI_MAXIMAL);
+
+ /* good annotations prepended */
+ routerinfo_free(ri);
+ ri = router_parse_entry_from_string(EX_RI_MINIMAL, NULL, 0, 0,
+ "@purpose bridge\n", NULL);
+ tt_assert(ri != NULL);
+ tt_assert(ri->purpose == ROUTER_PURPOSE_BRIDGE);
+ routerinfo_free(ri);
+
+ /* bad annotations prepended. */
+ ri = router_parse_entry_from_string(EX_RI_MINIMAL,
+ NULL, 0, 0, "@purpose\n", NULL);
+ tt_assert(ri == NULL);
+
+ /* bad annotations on router. */
+ ri = router_parse_entry_from_string("@purpose\nrouter x\n", NULL, 0, 1,
+ NULL, NULL);
+ tt_assert(ri == NULL);
+
+ /* unwanted annotations on router. */
+ ri = router_parse_entry_from_string("@purpose foo\nrouter x\n", NULL, 0, 0,
+ NULL, NULL);
+ tt_assert(ri == NULL);
+
+ /* No signature. */
+ ri = router_parse_entry_from_string("router x\n", NULL, 0, 0,
+ NULL, NULL);
+ tt_assert(ri == NULL);
+
+ /* Not a router */
+ routerinfo_free(ri);
+ ri = router_parse_entry_from_string("hello\n", NULL, 0, 0, NULL, NULL);
+ tt_assert(ri == NULL);
+
+ CHECK_FAIL(EX_RI_BAD_SIG1, 1);
+ CHECK_FAIL(EX_RI_BAD_SIG2, 1);
+ CHECK_FAIL(EX_RI_BAD_TOKENS, 0);
+ CHECK_FAIL(EX_RI_BAD_PUBLISHED, 0);
+ CHECK_FAIL(EX_RI_NEG_BANDWIDTH, 0);
+ CHECK_FAIL(EX_RI_BAD_BANDWIDTH, 0);
+ CHECK_FAIL(EX_RI_BAD_BANDWIDTH2, 0);
+ CHECK_FAIL(EX_RI_BAD_ONIONKEY1, 0);
+ CHECK_FAIL(EX_RI_BAD_ONIONKEY2, 0);
+ CHECK_FAIL(EX_RI_BAD_PORTS, 0);
+ CHECK_FAIL(EX_RI_BAD_IP, 0);
+ CHECK_FAIL(EX_RI_BAD_DIRPORT, 0);
+ CHECK_FAIL(EX_RI_BAD_NAME2, 0);
+ CHECK_FAIL(EX_RI_BAD_UPTIME, 0);
+
+ CHECK_FAIL(EX_RI_BAD_BANDWIDTH3, 0);
+ CHECK_FAIL(EX_RI_BAD_NTOR_KEY, 0);
+ CHECK_FAIL(EX_RI_BAD_FINGERPRINT, 0);
+ CHECK_FAIL(EX_RI_MISMATCHED_FINGERPRINT, 0);
+ CHECK_FAIL(EX_RI_BAD_HAS_ACCEPT6, 0);
+ CHECK_FAIL(EX_RI_BAD_NO_EXIT_POLICY, 0);
+ CHECK_FAIL(EX_RI_BAD_IPV6_EXIT_POLICY, 0);
+ CHECK_FAIL(EX_RI_BAD_FAMILY, 0);
+ CHECK_FAIL(EX_RI_ZERO_ORPORT, 0);
+
+ /* This is allowed; we just ignore it. */
+ CHECK_OK(EX_RI_BAD_EI_DIGEST);
+
+#undef CHECK_FAIL
+#undef CHECK_OK
+ done:
+ routerinfo_free(ri);
+}
+
+#include "example_extrainfo.inc"
+
+static void
+test_dir_extrainfo_parsing(void *arg)
+{
+ (void) arg;
+
+#define CHECK_OK(s) \
+ do { \
+ extrainfo_free(ei); \
+ ei = extrainfo_parse_entry_from_string((s), NULL, 0, map, NULL); \
+ tt_assert(ei); \
+ } while (0)
+#define CHECK_FAIL(s, againval) \
+ do { \
+ extrainfo_free(ei); \
+ again = 999; \
+ ei = extrainfo_parse_entry_from_string((s), NULL, 0, map, &again); \
+ tt_assert(ei == NULL); \
+ tt_int_op(again, ==, (againval)); \
+ } while (0)
+#define ADD(name) \
+ do { \
+ ri = tor_malloc_zero(sizeof(routerinfo_t)); \
+ crypto_pk_t *pk = ri->identity_pkey = crypto_pk_new(); \
+ tt_assert(! crypto_pk_read_public_key_from_string(pk, \
+ name##_KEY, strlen(name##_KEY))); \
+ tt_int_op(0,==,base16_decode(d, 20, name##_FP, strlen(name##_FP))); \
+ digestmap_set((digestmap_t*)map, d, ri); \
+ ri = NULL; \
+ } while (0)
+
+ routerinfo_t *ri = NULL;
+ char d[20];
+ struct digest_ri_map_t *map = NULL;
+ extrainfo_t *ei = NULL;
+ int again;
+
+ CHECK_OK(EX_EI_MINIMAL);
+ tt_assert(ei->pending_sig);
+ CHECK_OK(EX_EI_MAXIMAL);
+ tt_assert(ei->pending_sig);
+
+ map = (struct digest_ri_map_t *)digestmap_new();
+ ADD(EX_EI_MINIMAL);
+ ADD(EX_EI_MAXIMAL);
+ ADD(EX_EI_BAD_FP);
+ ADD(EX_EI_BAD_NICKNAME);
+ ADD(EX_EI_BAD_TOKENS);
+ ADD(EX_EI_BAD_START);
+ ADD(EX_EI_BAD_PUBLISHED);
+
+ CHECK_OK(EX_EI_MINIMAL);
+ tt_assert(!ei->pending_sig);
+ CHECK_OK(EX_EI_MAXIMAL);
+ tt_assert(!ei->pending_sig);
+
+ CHECK_FAIL(EX_EI_BAD_SIG1,1);
+ CHECK_FAIL(EX_EI_BAD_SIG2,1);
+ CHECK_FAIL(EX_EI_BAD_SIG3,1);
+ CHECK_FAIL(EX_EI_BAD_FP,0);
+ CHECK_FAIL(EX_EI_BAD_NICKNAME,0);
+ CHECK_FAIL(EX_EI_BAD_TOKENS,0);
+ CHECK_FAIL(EX_EI_BAD_START,0);
+ CHECK_FAIL(EX_EI_BAD_PUBLISHED,0);
+
+#undef CHECK_OK
+#undef CHECK_FAIL
+
+ done:
+ routerinfo_free(ri);
+ /* XXXX elements should get freed too */
+ digestmap_free((digestmap_t*)map, NULL);
+}
+
+static void
+test_dir_parse_router_list(void *arg)
+{
+ (void) arg;
+ smartlist_t *invalid = smartlist_new();
+ smartlist_t *dest = smartlist_new();
+ smartlist_t *chunks = smartlist_new();
+ int dest_has_ri = 1;
+ char *list = NULL;
+ const char *cp;
+ digestmap_t *map = NULL;
+ char *mem_op_hex_tmp = NULL;
+ routerinfo_t *ri = NULL;
+ char d[DIGEST_LEN];
+
+ smartlist_add(chunks, tor_strdup(EX_RI_MINIMAL)); // ri 0
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_PORTS)); // bad ri 0
+ smartlist_add(chunks, tor_strdup(EX_EI_MAXIMAL)); // ei 0
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_SIG2)); // bad ei --
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_NICKNAME));// bad ei 0
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_SIG1)); // bad ri --
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_PUBLISHED)); // bad ei 1
+ smartlist_add(chunks, tor_strdup(EX_RI_MAXIMAL)); // ri 1
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_FAMILY)); // bad ri 1
+ smartlist_add(chunks, tor_strdup(EX_EI_MINIMAL)); // ei 1
+
+ list = smartlist_join_strings(chunks, "", 0, NULL);
+
+ /* First, parse the routers. */
+ cp = list;
+ tt_int_op(0,==,
+ router_parse_list_from_string(&cp, NULL, dest, SAVED_NOWHERE,
+ 0, 0, NULL, invalid));
+ tt_int_op(2, ==, smartlist_len(dest));
+ tt_ptr_op(cp, ==, list + strlen(list));
+
+ routerinfo_t *r = smartlist_get(dest, 0);
+ tt_mem_op(r->cache_info.signed_descriptor_body, ==,
+ EX_RI_MINIMAL, strlen(EX_RI_MINIMAL));
+ r = smartlist_get(dest, 1);
+ tt_mem_op(r->cache_info.signed_descriptor_body, ==,
+ EX_RI_MAXIMAL, strlen(EX_RI_MAXIMAL));
+
+ tt_int_op(2, ==, smartlist_len(invalid));
+ test_memeq_hex(smartlist_get(invalid, 0),
+ "ab9eeaa95e7d45740185b4e519c76ead756277a9");
+ test_memeq_hex(smartlist_get(invalid, 1),
+ "9a651ee03b64325959e8f1b46f2b689b30750b4c");
+
+ /* Now tidy up */
+ SMARTLIST_FOREACH(dest, routerinfo_t *, ri, routerinfo_free(ri));
+ SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d));
+ smartlist_clear(dest);
+ smartlist_clear(invalid);
+
+ /* And check extrainfos. */
+ dest_has_ri = 0;
+ map = (digestmap_t*)router_get_routerlist()->identity_map;
+ ADD(EX_EI_MINIMAL);
+ ADD(EX_EI_MAXIMAL);
+ ADD(EX_EI_BAD_NICKNAME);
+ ADD(EX_EI_BAD_PUBLISHED);
+ cp = list;
+ tt_int_op(0,==,
+ router_parse_list_from_string(&cp, NULL, dest, SAVED_NOWHERE,
+ 1, 0, NULL, invalid));
+ tt_int_op(2, ==, smartlist_len(dest));
+ extrainfo_t *e = smartlist_get(dest, 0);
+ tt_mem_op(e->cache_info.signed_descriptor_body, ==,
+ EX_EI_MAXIMAL, strlen(EX_EI_MAXIMAL));
+ e = smartlist_get(dest, 1);
+ tt_mem_op(e->cache_info.signed_descriptor_body, ==,
+ EX_EI_MINIMAL, strlen(EX_EI_MINIMAL));
+
+ tt_int_op(2, ==, smartlist_len(invalid));
+ test_memeq_hex(smartlist_get(invalid, 0),
+ "d5df4aa62ee9ffc9543d41150c9864908e0390af");
+ test_memeq_hex(smartlist_get(invalid, 1),
+ "f61efd2a7f4531f3687a9043e0de90a862ec64ba");
+
+ done:
+ tor_free(list);
+ if (dest_has_ri)
+ SMARTLIST_FOREACH(dest, routerinfo_t *, rt, routerinfo_free(rt));
+ else
+ SMARTLIST_FOREACH(dest, extrainfo_t *, ei, extrainfo_free(ei));
+ smartlist_free(dest);
+ SMARTLIST_FOREACH(invalid, uint8_t *, d, tor_free(d));
+ smartlist_free(invalid);
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
+ routerinfo_free(ri);
+ /* XXXX this leaks: */
+ if (map) {
+ digestmap_free((digestmap_t*)map, NULL);
+ router_get_routerlist()->identity_map =
+ (struct digest_ri_map_t*)digestmap_new();
+ }
+ tor_free(mem_op_hex_tmp);
+
+#undef ADD
+}
+
+static download_status_t dls_minimal;
+static download_status_t dls_maximal;
+static download_status_t dls_bad_fingerprint;
+static download_status_t dls_bad_sig2;
+static download_status_t dls_bad_ports;
+static download_status_t dls_bad_tokens;
+
+static int mock_router_get_dl_status_unrecognized = 0;
+static int mock_router_get_dl_status_calls = 0;
+
+static download_status_t *
+mock_router_get_dl_status(const char *d)
+{
+ ++mock_router_get_dl_status_calls;
+ char hex[HEX_DIGEST_LEN+1];
+ base16_encode(hex, sizeof(hex), d, DIGEST_LEN);
+ if (!strcmp(hex, "3E31D19A69EB719C00B02EC60D13356E3F7A3452")) {
+ return &dls_minimal;
+ } else if (!strcmp(hex, "581D8A368A0FA854ECDBFAB841D88B3F1B004038")) {
+ return &dls_maximal;
+ } else if (!strcmp(hex, "2578AE227C6116CDE29B3F0E95709B9872DEE5F1")) {
+ return &dls_bad_fingerprint;
+ } else if (!strcmp(hex, "16D387D3A58F7DB3CF46638F8D0B90C45C7D769C")) {
+ return &dls_bad_sig2;
+ } else if (!strcmp(hex, "AB9EEAA95E7D45740185B4E519C76EAD756277A9")) {
+ return &dls_bad_ports;
+ } else if (!strcmp(hex, "A0CC2CEFAD59DBF19F468BFEE60E0868C804B422")) {
+ return &dls_bad_tokens;
+ } else {
+ ++mock_router_get_dl_status_unrecognized;
+ return NULL;
+ }
+}
+
+static void
+test_dir_load_routers(void *arg)
+{
+ (void) arg;
+ smartlist_t *chunks = smartlist_new();
+ smartlist_t *wanted = smartlist_new();
+ char buf[DIGEST_LEN];
+ char *mem_op_hex_tmp = NULL;
+
+#define ADD(str) \
+ do { \
+ tt_int_op(0,==,router_get_router_hash(str, strlen(str), buf)); \
+ smartlist_add(wanted, tor_strdup(hex_str(buf, DIGEST_LEN))); \
+ } while (0)
+
+ MOCK(router_get_dl_status_by_descriptor_digest, mock_router_get_dl_status);
+
+ update_approx_time(1412510400);
+
+ smartlist_add(chunks, tor_strdup(EX_RI_MINIMAL));
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_FINGERPRINT));
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_SIG2));
+ smartlist_add(chunks, tor_strdup(EX_RI_MAXIMAL));
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_PORTS));
+ smartlist_add(chunks, tor_strdup(EX_RI_BAD_TOKENS));
+
+ /* not ADDing MINIMIAL */
+ ADD(EX_RI_MAXIMAL);
+ ADD(EX_RI_BAD_FINGERPRINT);
+ ADD(EX_RI_BAD_SIG2);
+ /* Not ADDing BAD_PORTS */
+ ADD(EX_RI_BAD_TOKENS);
+
+ char *list = smartlist_join_strings(chunks, "", 0, NULL);
+ tt_int_op(1, ==,
+ router_load_routers_from_string(list, NULL, SAVED_IN_JOURNAL,
+ wanted, 1, NULL));
+
+ /* The "maximal" router was added. */
+ /* "minimal" was not. */
+ tt_int_op(smartlist_len(router_get_routerlist()->routers),==,1);
+ routerinfo_t *r = smartlist_get(router_get_routerlist()->routers, 0);
+ test_memeq_hex(r->cache_info.signed_descriptor_digest,
+ "581D8A368A0FA854ECDBFAB841D88B3F1B004038");
+ tt_int_op(dls_minimal.n_download_failures, ==, 0);
+ tt_int_op(dls_maximal.n_download_failures, ==, 0);
+
+ /* "Bad fingerprint" and "Bad tokens" should have gotten marked
+ * non-retriable. */
+ tt_want_int_op(mock_router_get_dl_status_calls, ==, 2);
+ tt_want_int_op(mock_router_get_dl_status_unrecognized, ==, 0);
+ tt_int_op(dls_bad_fingerprint.n_download_failures, ==, 255);
+ tt_int_op(dls_bad_tokens.n_download_failures, ==, 255);
+
+ /* bad_sig2 and bad ports" are retriable -- one since only the signature
+ * was bad, and one because we didn't ask for it. */
+ tt_int_op(dls_bad_sig2.n_download_failures, ==, 0);
+ tt_int_op(dls_bad_ports.n_download_failures, ==, 0);
+
+ /* Wanted still contains "BAD_SIG2" */
+ tt_int_op(smartlist_len(wanted), ==, 1);
+ tt_str_op(smartlist_get(wanted, 0), ==,
+ "E0A3753CEFD54128EAB239F294954121DB23D2EF");
+
+#undef ADD
+
+ done:
+ tor_free(mem_op_hex_tmp);
+ UNMOCK(router_get_dl_status_by_descriptor_digest);
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
+ SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
+ smartlist_free(wanted);
+}
+
+static int mock_get_by_ei_dd_calls = 0;
+static int mock_get_by_ei_dd_unrecognized = 0;
+
+static signed_descriptor_t sd_ei_minimal;
+static signed_descriptor_t sd_ei_bad_nickname;
+static signed_descriptor_t sd_ei_maximal;
+static signed_descriptor_t sd_ei_bad_tokens;
+static signed_descriptor_t sd_ei_bad_sig2;
+
+static signed_descriptor_t *
+mock_get_by_ei_desc_digest(const char *d)
+{
+
+ ++mock_get_by_ei_dd_calls;
+ char hex[HEX_DIGEST_LEN+1];
+ base16_encode(hex, sizeof(hex), d, DIGEST_LEN);
+
+ if (!strcmp(hex, "11E0EDF526950739F7769810FCACAB8C882FAEEE")) {
+ return &sd_ei_minimal;
+ } else if (!strcmp(hex, "47803B02A0E70E9E8BDA226CB1D74DE354D67DFF")) {
+ return &sd_ei_maximal;
+ } else if (!strcmp(hex, "D5DF4AA62EE9FFC9543D41150C9864908E0390AF")) {
+ return &sd_ei_bad_nickname;
+ } else if (!strcmp(hex, "16D387D3A58F7DB3CF46638F8D0B90C45C7D769C")) {
+ return &sd_ei_bad_sig2;
+ } else if (!strcmp(hex, "9D90F8C42955BBC57D54FB05E54A3F083AF42E8B")) {
+ return &sd_ei_bad_tokens;
+ } else {
+ ++mock_get_by_ei_dd_unrecognized;
+ return NULL;
+ }
+}
+
+static smartlist_t *mock_ei_insert_list = NULL;
+static was_router_added_t
+mock_ei_insert(routerlist_t *rl, extrainfo_t *ei)
+{
+ (void) rl;
+ smartlist_add(mock_ei_insert_list, ei);
+ return ROUTER_ADDED_SUCCESSFULLY;
+}
+
+static void
+test_dir_load_extrainfo(void *arg)
+{
+ (void) arg;
+ smartlist_t *chunks = smartlist_new();
+ smartlist_t *wanted = smartlist_new();
+ char buf[DIGEST_LEN];
+ char *mem_op_hex_tmp = NULL;
+
+#define ADD(str) \
+ do { \
+ tt_int_op(0,==,router_get_extrainfo_hash(str, strlen(str), buf)); \
+ smartlist_add(wanted, tor_strdup(hex_str(buf, DIGEST_LEN))); \
+ } while (0)
+
+ mock_ei_insert_list = smartlist_new();
+ MOCK(router_get_by_extrainfo_digest, mock_get_by_ei_desc_digest);
+ MOCK(extrainfo_insert, mock_ei_insert);
+
+ smartlist_add(chunks, tor_strdup(EX_EI_MINIMAL));
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_NICKNAME));
+ smartlist_add(chunks, tor_strdup(EX_EI_MAXIMAL));
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_PUBLISHED));
+ smartlist_add(chunks, tor_strdup(EX_EI_BAD_TOKENS));
+
+ /* not ADDing MINIMIAL */
+ ADD(EX_EI_MAXIMAL);
+ ADD(EX_EI_BAD_NICKNAME);
+ /* Not ADDing BAD_PUBLISHED */
+ ADD(EX_EI_BAD_TOKENS);
+ ADD(EX_EI_BAD_SIG2);
+
+ char *list = smartlist_join_strings(chunks, "", 0, NULL);
+ router_load_extrainfo_from_string(list, NULL, SAVED_IN_JOURNAL, wanted, 1);
+
+ /* The "maximal" router was added. */
+ /* "minimal" was also added, even though we didn't ask for it, since
+ * that's what we do with extrainfos. */
+ tt_int_op(smartlist_len(mock_ei_insert_list),==,2);
+
+ extrainfo_t *e = smartlist_get(mock_ei_insert_list, 0);
+ test_memeq_hex(e->cache_info.signed_descriptor_digest,
+ "11E0EDF526950739F7769810FCACAB8C882FAEEE");
+
+ e = smartlist_get(mock_ei_insert_list, 1);
+ test_memeq_hex(e->cache_info.signed_descriptor_digest,
+ "47803B02A0E70E9E8BDA226CB1D74DE354D67DFF");
+ tt_int_op(dls_minimal.n_download_failures, ==, 0);
+ tt_int_op(dls_maximal.n_download_failures, ==, 0);
+
+ /* "Bad nickname" and "Bad tokens" should have gotten marked
+ * non-retriable. */
+ tt_want_int_op(mock_get_by_ei_dd_calls, ==, 2);
+ tt_want_int_op(mock_get_by_ei_dd_unrecognized, ==, 0);
+ tt_int_op(sd_ei_bad_nickname.ei_dl_status.n_download_failures, ==, 255);
+ tt_int_op(sd_ei_bad_tokens.ei_dl_status.n_download_failures, ==, 255);
+
+ /* bad_ports is retriable -- because we didn't ask for it. */
+ tt_int_op(dls_bad_ports.n_download_failures, ==, 0);
+
+ /* Wanted still contains "BAD_SIG2" */
+ tt_int_op(smartlist_len(wanted), ==, 1);
+ tt_str_op(smartlist_get(wanted, 0), ==,
+ "16D387D3A58F7DB3CF46638F8D0B90C45C7D769C");
+
+#undef ADD
+
+ done:
+ tor_free(mem_op_hex_tmp);
+ UNMOCK(router_get_by_extrainfo_digest);
+ SMARTLIST_FOREACH(chunks, char *, cp, tor_free(cp));
+ smartlist_free(chunks);
+ SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
+ smartlist_free(wanted);
+}
+
static void
-test_dir_versions(void)
+test_dir_versions(void *arg)
{
tor_version_t ver1;
/* Try out version parsing functionality */
- test_eq(0, tor_version_parse("0.3.4pre2-cvs", &ver1));
- test_eq(0, ver1.major);
- test_eq(3, ver1.minor);
- test_eq(4, ver1.micro);
- test_eq(VER_PRE, ver1.status);
- test_eq(2, ver1.patchlevel);
- test_eq(0, tor_version_parse("0.3.4rc1", &ver1));
- test_eq(0, ver1.major);
- test_eq(3, ver1.minor);
- test_eq(4, ver1.micro);
- test_eq(VER_RC, ver1.status);
- test_eq(1, ver1.patchlevel);
- test_eq(0, tor_version_parse("1.3.4", &ver1));
- test_eq(1, ver1.major);
- test_eq(3, ver1.minor);
- test_eq(4, ver1.micro);
- test_eq(VER_RELEASE, ver1.status);
- test_eq(0, ver1.patchlevel);
- test_eq(0, tor_version_parse("1.3.4.999", &ver1));
- test_eq(1, ver1.major);
- test_eq(3, ver1.minor);
- test_eq(4, ver1.micro);
- test_eq(VER_RELEASE, ver1.status);
- test_eq(999, ver1.patchlevel);
- test_eq(0, tor_version_parse("0.1.2.4-alpha", &ver1));
- test_eq(0, ver1.major);
- test_eq(1, ver1.minor);
- test_eq(2, ver1.micro);
- test_eq(4, ver1.patchlevel);
- test_eq(VER_RELEASE, ver1.status);
- test_streq("alpha", ver1.status_tag);
- test_eq(0, tor_version_parse("0.1.2.4", &ver1));
- test_eq(0, ver1.major);
- test_eq(1, ver1.minor);
- test_eq(2, ver1.micro);
- test_eq(4, ver1.patchlevel);
- test_eq(VER_RELEASE, ver1.status);
- test_streq("", ver1.status_tag);
+ (void)arg;
+ tt_int_op(0,==, tor_version_parse("0.3.4pre2-cvs", &ver1));
+ tt_int_op(0,==, ver1.major);
+ tt_int_op(3,==, ver1.minor);
+ tt_int_op(4,==, ver1.micro);
+ tt_int_op(VER_PRE,==, ver1.status);
+ tt_int_op(2,==, ver1.patchlevel);
+ tt_int_op(0,==, tor_version_parse("0.3.4rc1", &ver1));
+ tt_int_op(0,==, ver1.major);
+ tt_int_op(3,==, ver1.minor);
+ tt_int_op(4,==, ver1.micro);
+ tt_int_op(VER_RC,==, ver1.status);
+ tt_int_op(1,==, ver1.patchlevel);
+ tt_int_op(0,==, tor_version_parse("1.3.4", &ver1));
+ tt_int_op(1,==, ver1.major);
+ tt_int_op(3,==, ver1.minor);
+ tt_int_op(4,==, ver1.micro);
+ tt_int_op(VER_RELEASE,==, ver1.status);
+ tt_int_op(0,==, ver1.patchlevel);
+ tt_int_op(0,==, tor_version_parse("1.3.4.999", &ver1));
+ tt_int_op(1,==, ver1.major);
+ tt_int_op(3,==, ver1.minor);
+ tt_int_op(4,==, ver1.micro);
+ tt_int_op(VER_RELEASE,==, ver1.status);
+ tt_int_op(999,==, ver1.patchlevel);
+ tt_int_op(0,==, tor_version_parse("0.1.2.4-alpha", &ver1));
+ tt_int_op(0,==, ver1.major);
+ tt_int_op(1,==, ver1.minor);
+ tt_int_op(2,==, ver1.micro);
+ tt_int_op(4,==, ver1.patchlevel);
+ tt_int_op(VER_RELEASE,==, ver1.status);
+ tt_str_op("alpha",==, ver1.status_tag);
+ tt_int_op(0,==, tor_version_parse("0.1.2.4", &ver1));
+ tt_int_op(0,==, ver1.major);
+ tt_int_op(1,==, ver1.minor);
+ tt_int_op(2,==, ver1.micro);
+ tt_int_op(4,==, ver1.patchlevel);
+ tt_int_op(VER_RELEASE,==, ver1.status);
+ tt_str_op("",==, ver1.status_tag);
#define tt_versionstatus_op(vs1, op, vs2) \
tt_assert_test_type(vs1,vs2,#vs1" "#op" "#vs2,version_status_t, \
@@ -368,53 +867,54 @@ test_dir_versions(void)
/* On list, not newer than any on same series. */
test_v_i_o(VS_UNRECOMMENDED,
"0.1.0.1", "Tor 0.1.0.2,Tor 0.0.9.5,Tor 0.1.1.0");
- test_eq(0, tor_version_as_new_as("Tor 0.0.5", "0.0.9pre1-cvs"));
- test_eq(1, tor_version_as_new_as(
+ tt_int_op(0,==, tor_version_as_new_as("Tor 0.0.5", "0.0.9pre1-cvs"));
+ tt_int_op(1,==, tor_version_as_new_as(
"Tor 0.0.8 on Darwin 64-121-192-100.c3-0."
"sfpo-ubr1.sfrn-sfpo.ca.cable.rcn.com Power Macintosh",
"0.0.8rc2"));
- test_eq(0, tor_version_as_new_as(
+ tt_int_op(0,==, tor_version_as_new_as(
"Tor 0.0.8 on Darwin 64-121-192-100.c3-0."
"sfpo-ubr1.sfrn-sfpo.ca.cable.rcn.com Power Macintosh", "0.0.8.2"));
/* Now try svn revisions. */
- test_eq(1, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
+ tt_int_op(1,==, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
"Tor 0.2.1.0-dev (r99)"));
- test_eq(1, tor_version_as_new_as("Tor 0.2.1.0-dev (r100) on Banana Jr",
+ tt_int_op(1,==, tor_version_as_new_as("Tor 0.2.1.0-dev (r100) on Banana Jr",
"Tor 0.2.1.0-dev (r99) on Hal 9000"));
- test_eq(1, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
+ tt_int_op(1,==, tor_version_as_new_as("Tor 0.2.1.0-dev (r100)",
"Tor 0.2.1.0-dev on Colossus"));
- test_eq(0, tor_version_as_new_as("Tor 0.2.1.0-dev (r99)",
+ tt_int_op(0,==, tor_version_as_new_as("Tor 0.2.1.0-dev (r99)",
"Tor 0.2.1.0-dev (r100)"));
- test_eq(0, tor_version_as_new_as("Tor 0.2.1.0-dev (r99) on MCP",
+ tt_int_op(0,==, tor_version_as_new_as("Tor 0.2.1.0-dev (r99) on MCP",
"Tor 0.2.1.0-dev (r100) on AM"));
- test_eq(0, tor_version_as_new_as("Tor 0.2.1.0-dev",
+ tt_int_op(0,==, tor_version_as_new_as("Tor 0.2.1.0-dev",
"Tor 0.2.1.0-dev (r99)"));
- test_eq(1, tor_version_as_new_as("Tor 0.2.1.1",
+ tt_int_op(1,==, tor_version_as_new_as("Tor 0.2.1.1",
"Tor 0.2.1.0-dev (r99)"));
/* Now try git revisions */
- test_eq(0, tor_version_parse("0.5.6.7 (git-ff00ff)", &ver1));
- test_eq(0, ver1.major);
- test_eq(5, ver1.minor);
- test_eq(6, ver1.micro);
- test_eq(7, ver1.patchlevel);
- test_eq(3, ver1.git_tag_len);
- test_memeq(ver1.git_tag, "\xff\x00\xff", 3);
- test_eq(-1, tor_version_parse("0.5.6.7 (git-ff00xx)", &ver1));
- test_eq(-1, tor_version_parse("0.5.6.7 (git-ff00fff)", &ver1));
- test_eq(0, tor_version_parse("0.5.6.7 (git ff00fff)", &ver1));
+ tt_int_op(0,==, tor_version_parse("0.5.6.7 (git-ff00ff)", &ver1));
+ tt_int_op(0,==, ver1.major);
+ tt_int_op(5,==, ver1.minor);
+ tt_int_op(6,==, ver1.micro);
+ tt_int_op(7,==, ver1.patchlevel);
+ tt_int_op(3,==, ver1.git_tag_len);
+ tt_mem_op(ver1.git_tag,==, "\xff\x00\xff", 3);
+ tt_int_op(-1,==, tor_version_parse("0.5.6.7 (git-ff00xx)", &ver1));
+ tt_int_op(-1,==, tor_version_parse("0.5.6.7 (git-ff00fff)", &ver1));
+ tt_int_op(0,==, tor_version_parse("0.5.6.7 (git ff00fff)", &ver1));
done:
;
}
/** Run unit tests for directory fp_pair functions. */
static void
-test_dir_fp_pairs(void)
+test_dir_fp_pairs(void *arg)
{
smartlist_t *sl = smartlist_new();
fp_pair_t *pair;
+ (void)arg;
dir_split_resource_into_fingerprint_pairs(
/* Two pairs, out of order, with one duplicate. */
"73656372657420646174612E0000000000FFFFFF-"
@@ -424,13 +924,13 @@ test_dir_fp_pairs(void)
"48657861646563696d616c2069736e277420736f-"
"676f6f6420666f7220686964696e6720796f7572.z", sl);
- test_eq(smartlist_len(sl), 2);
+ tt_int_op(smartlist_len(sl),==, 2);
pair = smartlist_get(sl, 0);
- test_memeq(pair->first, "Hexadecimal isn't so", DIGEST_LEN);
- test_memeq(pair->second, "good for hiding your", DIGEST_LEN);
+ tt_mem_op(pair->first,==, "Hexadecimal isn't so", DIGEST_LEN);
+ tt_mem_op(pair->second,==, "good for hiding your", DIGEST_LEN);
pair = smartlist_get(sl, 1);
- test_memeq(pair->first, "secret data.\0\0\0\0\0\xff\xff\xff", DIGEST_LEN);
- test_memeq(pair->second, "Use AES-256 instead.", DIGEST_LEN);
+ tt_mem_op(pair->first,==, "secret data.\0\0\0\0\0\xff\xff\xff", DIGEST_LEN);
+ tt_mem_op(pair->second,==, "Use AES-256 instead.", DIGEST_LEN);
done:
SMARTLIST_FOREACH(sl, fp_pair_t *, pair, tor_free(pair));
@@ -557,7 +1057,7 @@ test_dir_split_fps(void *testdata)
}
static void
-test_dir_measured_bw_kb(void)
+test_dir_measured_bw_kb(void *arg)
{
measured_bw_line_t mbwl;
int i;
@@ -605,16 +1105,17 @@ test_dir_measured_bw_kb(void)
"end"
};
+ (void)arg;
for (i = 0; strcmp(lines_fail[i], "end"); i++) {
//fprintf(stderr, "Testing: %s\n", lines_fail[i]);
- test_assert(measured_bw_line_parse(&mbwl, lines_fail[i]) == -1);
+ tt_assert(measured_bw_line_parse(&mbwl, lines_fail[i]) == -1);
}
for (i = 0; strcmp(lines_pass[i], "end"); i++) {
//fprintf(stderr, "Testing: %s %d\n", lines_pass[i], TOR_ISSPACE('\n'));
- test_assert(measured_bw_line_parse(&mbwl, lines_pass[i]) == 0);
- test_assert(mbwl.bw_kb == 1024);
- test_assert(strcmp(mbwl.node_hex,
+ tt_assert(measured_bw_line_parse(&mbwl, lines_pass[i]) == 0);
+ tt_assert(mbwl.bw_kb == 1024);
+ tt_assert(strcmp(mbwl.node_hex,
"557365204145532d32353620696e73746561642e") == 0);
}
@@ -626,7 +1127,7 @@ test_dir_measured_bw_kb(void)
/** Do the measured bandwidth cache unit test */
static void
-test_dir_measured_bw_kb_cache(void)
+test_dir_measured_bw_kb_cache(void *arg)
{
/* Initial fake time_t for testing */
time_t curr = MBWC_INIT_TIME;
@@ -637,8 +1138,9 @@ test_dir_measured_bw_kb_cache(void)
time_t as_of;
/* First, clear the cache and assert that it's empty */
+ (void)arg;
dirserv_clear_measured_bw_cache();
- test_eq(dirserv_get_measured_bw_cache_size(), 0);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 0);
/*
* Set up test mbwls; none of the dirserv_cache_*() functions care about
* the node_hex field.
@@ -651,56 +1153,56 @@ test_dir_measured_bw_kb_cache(void)
mbwl[2].bw_kb = 80;
/* Try caching something */
dirserv_cache_measured_bw(&(mbwl[0]), curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 1);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 1);
/* Okay, let's see if we can retrieve it */
- test_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, &as_of));
- test_eq(bw, 20);
- test_eq(as_of, MBWC_INIT_TIME);
+ tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, &as_of));
+ tt_int_op(bw,==, 20);
+ tt_int_op(as_of,==, MBWC_INIT_TIME);
/* Try retrieving it without some outputs */
- test_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL, NULL));
- test_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, NULL));
- test_eq(bw, 20);
- test_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL,&as_of));
- test_eq(as_of, MBWC_INIT_TIME);
+ tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL, NULL));
+ tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,&bw, NULL));
+ tt_int_op(bw,==, 20);
+ tt_assert(dirserv_query_measured_bw_cache_kb(mbwl[0].node_id,NULL,&as_of));
+ tt_int_op(as_of,==, MBWC_INIT_TIME);
/* Now expire it */
curr += MAX_MEASUREMENT_AGE + 1;
dirserv_expire_measured_bw_cache(curr);
/* Check that the cache is empty */
- test_eq(dirserv_get_measured_bw_cache_size(), 0);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 0);
/* Check that we can't retrieve it */
- test_assert(!dirserv_query_measured_bw_cache_kb(mbwl[0].node_id, NULL,NULL));
+ tt_assert(!dirserv_query_measured_bw_cache_kb(mbwl[0].node_id, NULL,NULL));
/* Try caching a few things now */
dirserv_cache_measured_bw(&(mbwl[0]), curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 1);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 1);
curr += MAX_MEASUREMENT_AGE / 4;
dirserv_cache_measured_bw(&(mbwl[1]), curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 2);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 2);
curr += MAX_MEASUREMENT_AGE / 4;
dirserv_cache_measured_bw(&(mbwl[2]), curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 3);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 3);
curr += MAX_MEASUREMENT_AGE / 4 + 1;
/* Do an expire that's too soon to get any of them */
dirserv_expire_measured_bw_cache(curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 3);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 3);
/* Push the oldest one off the cliff */
curr += MAX_MEASUREMENT_AGE / 4;
dirserv_expire_measured_bw_cache(curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 2);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 2);
/* And another... */
curr += MAX_MEASUREMENT_AGE / 4;
dirserv_expire_measured_bw_cache(curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 1);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 1);
/* This should empty it out again */
curr += MAX_MEASUREMENT_AGE / 4;
dirserv_expire_measured_bw_cache(curr);
- test_eq(dirserv_get_measured_bw_cache_size(), 0);
+ tt_int_op(dirserv_get_measured_bw_cache_size(),==, 0);
done:
return;
}
static void
-test_dir_param_voting(void)
+test_dir_param_voting(void *arg)
{
networkstatus_t vote1, vote2, vote3, vote4;
smartlist_t *votes = smartlist_new();
@@ -709,6 +1211,7 @@ test_dir_param_voting(void)
/* dirvote_compute_params only looks at the net_params field of the votes,
so that's all we need to set.
*/
+ (void)arg;
memset(&vote1, 0, sizeof(vote1));
memset(&vote2, 0, sizeof(vote2));
memset(&vote3, 0, sizeof(vote3));
@@ -725,87 +1228,71 @@ test_dir_param_voting(void)
"abcd=20 c=60 cw=500 x-yz=-9 zzzzz=101", NULL, 0, 0);
smartlist_split_string(vote4.net_params,
"ab=900 abcd=200 c=1 cw=51 x-yz=100", NULL, 0, 0);
- test_eq(100, networkstatus_get_param(&vote4, "x-yz", 50, 0, 300));
- test_eq(222, networkstatus_get_param(&vote4, "foobar", 222, 0, 300));
- test_eq(80, networkstatus_get_param(&vote4, "ab", 12, 0, 80));
- test_eq(-8, networkstatus_get_param(&vote4, "ab", -12, -100, -8));
- test_eq(0, networkstatus_get_param(&vote4, "foobar", 0, -100, 8));
+ tt_int_op(100,==, networkstatus_get_param(&vote4, "x-yz", 50, 0, 300));
+ tt_int_op(222,==, networkstatus_get_param(&vote4, "foobar", 222, 0, 300));
+ tt_int_op(80,==, networkstatus_get_param(&vote4, "ab", 12, 0, 80));
+ tt_int_op(-8,==, networkstatus_get_param(&vote4, "ab", -12, -100, -8));
+ tt_int_op(0,==, networkstatus_get_param(&vote4, "foobar", 0, -100, 8));
smartlist_add(votes, &vote1);
/* Do the first tests without adding all the other votes, for
* networks without many dirauths. */
- res = dirvote_compute_params(votes, 11, 6);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-99");
- tor_free(res);
-
res = dirvote_compute_params(votes, 12, 2);
- test_streq(res, "");
+ tt_str_op(res,==, "");
tor_free(res);
res = dirvote_compute_params(votes, 12, 1);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-99");
+ tt_str_op(res,==, "ab=90 abcd=20 cw=50 x-yz=-99");
tor_free(res);
smartlist_add(votes, &vote2);
- res = dirvote_compute_params(votes, 11, 2);
- test_streq(res, "ab=27 abcd=20 cw=5 x-yz=-99");
- tor_free(res);
-
res = dirvote_compute_params(votes, 12, 2);
- test_streq(res, "ab=27 cw=5 x-yz=-99");
+ tt_str_op(res,==, "ab=27 cw=5 x-yz=-99");
tor_free(res);
res = dirvote_compute_params(votes, 12, 3);
- test_streq(res, "ab=27 cw=5 x-yz=-99");
+ tt_str_op(res,==, "ab=27 cw=5 x-yz=-99");
tor_free(res);
res = dirvote_compute_params(votes, 12, 6);
- test_streq(res, "");
+ tt_str_op(res,==, "");
tor_free(res);
smartlist_add(votes, &vote3);
- res = dirvote_compute_params(votes, 11, 3);
- test_streq(res, "ab=27 abcd=20 c=60 cw=50 x-yz=-9 zzzzz=101");
- tor_free(res);
-
res = dirvote_compute_params(votes, 12, 3);
- test_streq(res, "ab=27 abcd=20 cw=50 x-yz=-9");
+ tt_str_op(res,==, "ab=27 abcd=20 cw=50 x-yz=-9");
tor_free(res);
res = dirvote_compute_params(votes, 12, 5);
- test_streq(res, "cw=50 x-yz=-9");
+ tt_str_op(res,==, "cw=50 x-yz=-9");
tor_free(res);
res = dirvote_compute_params(votes, 12, 9);
- test_streq(res, "cw=50 x-yz=-9");
+ tt_str_op(res,==, "cw=50 x-yz=-9");
tor_free(res);
smartlist_add(votes, &vote4);
- res = dirvote_compute_params(votes, 11, 4);
- test_streq(res, "ab=90 abcd=20 c=1 cw=50 x-yz=-9 zzzzz=101");
- tor_free(res);
-
res = dirvote_compute_params(votes, 12, 4);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-9");
+ tt_str_op(res,==, "ab=90 abcd=20 cw=50 x-yz=-9");
tor_free(res);
res = dirvote_compute_params(votes, 12, 5);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-9");
+ tt_str_op(res,==, "ab=90 abcd=20 cw=50 x-yz=-9");
tor_free(res);
/* Test that the special-cased "at least three dirauths voted for
* this param" logic works as expected. */
res = dirvote_compute_params(votes, 12, 6);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-9");
+ tt_str_op(res,==, "ab=90 abcd=20 cw=50 x-yz=-9");
tor_free(res);
res = dirvote_compute_params(votes, 12, 10);
- test_streq(res, "ab=90 abcd=20 cw=50 x-yz=-9");
+ tt_str_op(res,==, "ab=90 abcd=20 cw=50 x-yz=-9");
tor_free(res);
done:
@@ -837,14 +1324,14 @@ static void
test_same_voter(networkstatus_voter_info_t *v1,
networkstatus_voter_info_t *v2)
{
- test_streq(v1->nickname, v2->nickname);
- test_memeq(v1->identity_digest, v2->identity_digest, DIGEST_LEN);
- test_streq(v1->address, v2->address);
- test_eq(v1->addr, v2->addr);
- test_eq(v1->dir_port, v2->dir_port);
- test_eq(v1->or_port, v2->or_port);
- test_streq(v1->contact, v2->contact);
- test_memeq(v1->vote_digest, v2->vote_digest, DIGEST_LEN);
+ tt_str_op(v1->nickname,==, v2->nickname);
+ tt_mem_op(v1->identity_digest,==, v2->identity_digest, DIGEST_LEN);
+ tt_str_op(v1->address,==, v2->address);
+ tt_int_op(v1->addr,==, v2->addr);
+ tt_int_op(v1->dir_port,==, v2->dir_port);
+ tt_int_op(v1->or_port,==, v2->or_port);
+ tt_str_op(v1->contact,==, v2->contact);
+ tt_mem_op(v1->vote_digest,==, v2->vote_digest, DIGEST_LEN);
done:
;
}
@@ -981,7 +1468,7 @@ gen_routerstatus_for_v3ns(int idx, time_t now)
break;
default:
/* Shouldn't happen */
- test_assert(0);
+ tt_assert(0);
}
if (vrs) {
vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
@@ -1002,14 +1489,14 @@ vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
vote_routerstatus_t *vrs;
const char *msg = NULL;
- test_assert(v);
+ tt_assert(v);
(void)now;
if (voter == 1) {
measured_bw_line_t mbw;
memset(mbw.node_id, 33, sizeof(mbw.node_id));
mbw.bw_kb = 1024;
- test_assert(measured_bw_line_apply(&mbw,
+ tt_assert(measured_bw_line_apply(&mbw,
v->routerstatus_list) == 1);
} else if (voter == 2 || voter == 3) {
/* Monkey around with the list a bit */
@@ -1025,7 +1512,7 @@ vote_tweaks_for_v3ns(networkstatus_t *v, int voter, time_t now)
vote_routerstatus_free(vrs);
vrs = smartlist_get(v->routerstatus_list, 0);
memset(vrs->status.descriptor_digest, (int)'Z', DIGEST_LEN);
- test_assert(router_add_to_routerlist(
+ tt_assert(router_add_to_routerlist(
generate_ri_from_rs(vrs), &msg,0,0) >= 0);
}
}
@@ -1043,9 +1530,9 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
routerstatus_t *rs;
tor_addr_t addr_ipv6;
- test_assert(vrs);
+ tt_assert(vrs);
rs = &(vrs->status);
- test_assert(rs);
+ tt_assert(rs);
/* Split out by digests to test */
if (tor_memeq(rs->identity_digest,
@@ -1054,17 +1541,17 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
DIGEST_LEN) &&
(voter == 1)) {
/* Check the first routerstatus. */
- test_streq(vrs->version, "0.1.2.14");
- test_eq(rs->published_on, now-1500);
- test_streq(rs->nickname, "router2");
- test_memeq(rs->identity_digest,
+ tt_str_op(vrs->version,==, "0.1.2.14");
+ tt_int_op(rs->published_on,==, now-1500);
+ tt_str_op(rs->nickname,==, "router2");
+ tt_mem_op(rs->identity_digest,==,
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
"\x3\x3\x3\x3",
DIGEST_LEN);
- test_memeq(rs->descriptor_digest, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
- test_eq(rs->addr, 0x99008801);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 8000);
+ tt_mem_op(rs->descriptor_digest,==, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
+ tt_int_op(rs->addr,==, 0x99008801);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 8000);
/* no flags except "running" (16) and "v2dir" (64) */
tt_u64_op(vrs->flags, ==, U64_LITERAL(80));
} else if (tor_memeq(rs->identity_digest,
@@ -1072,24 +1559,24 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
"\x5\x5\x5\x5",
DIGEST_LEN) &&
(voter == 1 || voter == 2)) {
- test_memeq(rs->identity_digest,
+ tt_mem_op(rs->identity_digest,==,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5",
DIGEST_LEN);
if (voter == 1) {
/* Check the second routerstatus. */
- test_streq(vrs->version, "0.2.0.5");
- test_eq(rs->published_on, now-1000);
- test_streq(rs->nickname, "router1");
+ tt_str_op(vrs->version,==, "0.2.0.5");
+ tt_int_op(rs->published_on,==, now-1000);
+ tt_str_op(rs->nickname,==, "router1");
}
- test_memeq(rs->descriptor_digest, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
- test_eq(rs->addr, 0x99009901);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 0);
+ tt_mem_op(rs->descriptor_digest,==, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
+ tt_int_op(rs->addr,==, 0x99009901);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 0);
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
- test_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
- test_eq(rs->ipv6_orport, 4711);
+ tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
+ tt_int_op(rs->ipv6_orport,==, 4711);
if (voter == 1) {
/* all except "authority" (1) and "v2dir" (64) */
tt_u64_op(vrs->flags, ==, U64_LITERAL(190));
@@ -1103,14 +1590,14 @@ test_vrs_for_v3ns(vote_routerstatus_t *vrs, int voter, time_t now)
DIGEST_LEN) &&
(voter == 1 || voter == 2)) {
/* Check the measured bandwidth bits */
- test_assert(vrs->has_measured_bw &&
+ tt_assert(vrs->has_measured_bw &&
vrs->measured_bw_kb == 1024);
} else {
/*
* Didn't expect this, but the old unit test only checked some of them,
* so don't assert.
*/
- /* test_assert(0); */
+ /* tt_assert(0); */
}
done:
@@ -1125,9 +1612,9 @@ test_consensus_for_v3ns(networkstatus_t *con, time_t now)
{
(void)now;
- test_assert(con);
- test_assert(!con->cert);
- test_eq(2, smartlist_len(con->routerstatus_list));
+ tt_assert(con);
+ tt_assert(!con->cert);
+ tt_int_op(2,==, smartlist_len(con->routerstatus_list));
/* There should be two listed routers: one with identity 3, one with
* identity 5. */
@@ -1143,7 +1630,7 @@ test_routerstatus_for_v3ns(routerstatus_t *rs, time_t now)
{
tor_addr_t addr_ipv6;
- test_assert(rs);
+ tt_assert(rs);
/* There should be two listed routers: one with identity 3, one with
* identity 5. */
@@ -1152,49 +1639,49 @@ test_routerstatus_for_v3ns(routerstatus_t *rs, time_t now)
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
"\x3\x3",
DIGEST_LEN)) {
- test_memeq(rs->identity_digest,
+ tt_mem_op(rs->identity_digest,==,
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
DIGEST_LEN);
- test_memeq(rs->descriptor_digest, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
- test_assert(!rs->is_authority);
- test_assert(!rs->is_exit);
- test_assert(!rs->is_fast);
- test_assert(!rs->is_possible_guard);
- test_assert(!rs->is_stable);
+ tt_mem_op(rs->descriptor_digest,==, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
+ tt_assert(!rs->is_authority);
+ tt_assert(!rs->is_exit);
+ tt_assert(!rs->is_fast);
+ tt_assert(!rs->is_possible_guard);
+ tt_assert(!rs->is_stable);
/* (If it wasn't running it wouldn't be here) */
- test_assert(rs->is_flagged_running);
- test_assert(!rs->is_valid);
- test_assert(!rs->is_named);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(!rs->is_valid);
+ tt_assert(!rs->is_named);
/* XXXX check version */
} else if (tor_memeq(rs->identity_digest,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5",
DIGEST_LEN)) {
/* This one showed up in 3 digests. Twice with ID 'M', once with 'Z'. */
- test_memeq(rs->identity_digest,
+ tt_mem_op(rs->identity_digest,==,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
DIGEST_LEN);
- test_streq(rs->nickname, "router1");
- test_memeq(rs->descriptor_digest, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
- test_eq(rs->published_on, now-1000);
- test_eq(rs->addr, 0x99009901);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 0);
+ tt_str_op(rs->nickname,==, "router1");
+ tt_mem_op(rs->descriptor_digest,==, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
+ tt_int_op(rs->published_on,==, now-1000);
+ tt_int_op(rs->addr,==, 0x99009901);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 0);
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
- test_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
- test_eq(rs->ipv6_orport, 4711);
- test_assert(!rs->is_authority);
- test_assert(rs->is_exit);
- test_assert(rs->is_fast);
- test_assert(rs->is_possible_guard);
- test_assert(rs->is_stable);
- test_assert(rs->is_flagged_running);
- test_assert(rs->is_valid);
- test_assert(!rs->is_named);
+ tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
+ tt_int_op(rs->ipv6_orport,==, 4711);
+ tt_assert(!rs->is_authority);
+ tt_assert(rs->is_exit);
+ tt_assert(rs->is_fast);
+ tt_assert(rs->is_possible_guard);
+ tt_assert(rs->is_stable);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(rs->is_valid);
+ tt_assert(!rs->is_named);
/* XXXX check version */
} else {
/* Weren't expecting this... */
- test_assert(0);
+ tt_assert(0);
}
done:
@@ -1242,31 +1729,31 @@ test_a_networkstatus(
networkstatus_t *con2=NULL, *con_md2=NULL, *con3=NULL, *con_md3=NULL;
ns_detached_signatures_t *dsig1=NULL, *dsig2=NULL;
- test_assert(vrs_gen);
- test_assert(rs_test);
- test_assert(vrs_test);
+ tt_assert(vrs_gen);
+ tt_assert(rs_test);
+ tt_assert(vrs_test);
/* Parse certificates and keys. */
cert1 = authority_cert_parse_from_string(AUTHORITY_CERT_1, NULL);
- test_assert(cert1);
+ tt_assert(cert1);
cert2 = authority_cert_parse_from_string(AUTHORITY_CERT_2, NULL);
- test_assert(cert2);
+ tt_assert(cert2);
cert3 = authority_cert_parse_from_string(AUTHORITY_CERT_3, NULL);
- test_assert(cert3);
+ tt_assert(cert3);
sign_skey_1 = crypto_pk_new();
sign_skey_2 = crypto_pk_new();
sign_skey_3 = crypto_pk_new();
sign_skey_leg1 = pk_generate(4);
- test_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
+ tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_1,
AUTHORITY_SIGNKEY_1, -1));
- test_assert(!crypto_pk_read_private_key_from_string(sign_skey_2,
+ tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_2,
AUTHORITY_SIGNKEY_2, -1));
- test_assert(!crypto_pk_read_private_key_from_string(sign_skey_3,
+ tt_assert(!crypto_pk_read_private_key_from_string(sign_skey_3,
AUTHORITY_SIGNKEY_3, -1));
- test_assert(!crypto_pk_cmp_keys(sign_skey_1, cert1->signing_key));
- test_assert(!crypto_pk_cmp_keys(sign_skey_2, cert2->signing_key));
+ tt_assert(!crypto_pk_cmp_keys(sign_skey_1, cert1->signing_key));
+ tt_assert(!crypto_pk_cmp_keys(sign_skey_2, cert2->signing_key));
/*
* Set up a vote; generate it; try to parse it.
@@ -1308,7 +1795,7 @@ test_a_networkstatus(
vrs = vrs_gen(idx, now);
if (vrs) {
smartlist_add(vote->routerstatus_list, vrs);
- test_assert(router_add_to_routerlist(generate_ri_from_rs(vrs),
+ tt_assert(router_add_to_routerlist(generate_ri_from_rs(vrs),
&msg,0,0)>=0);
++idx;
}
@@ -1317,41 +1804,41 @@ test_a_networkstatus(
/* dump the vote and try to parse it. */
v1_text = format_networkstatus_vote(sign_skey_1, vote);
- test_assert(v1_text);
+ tt_assert(v1_text);
v1 = networkstatus_parse_vote_from_string(v1_text, NULL, NS_TYPE_VOTE);
- test_assert(v1);
+ tt_assert(v1);
/* Make sure the parsed thing was right. */
- test_eq(v1->type, NS_TYPE_VOTE);
- test_eq(v1->published, vote->published);
- test_eq(v1->valid_after, vote->valid_after);
- test_eq(v1->fresh_until, vote->fresh_until);
- test_eq(v1->valid_until, vote->valid_until);
- test_eq(v1->vote_seconds, vote->vote_seconds);
- test_eq(v1->dist_seconds, vote->dist_seconds);
- test_streq(v1->client_versions, vote->client_versions);
- test_streq(v1->server_versions, vote->server_versions);
- test_assert(v1->voters && smartlist_len(v1->voters));
+ tt_int_op(v1->type,==, NS_TYPE_VOTE);
+ tt_int_op(v1->published,==, vote->published);
+ tt_int_op(v1->valid_after,==, vote->valid_after);
+ tt_int_op(v1->fresh_until,==, vote->fresh_until);
+ tt_int_op(v1->valid_until,==, vote->valid_until);
+ tt_int_op(v1->vote_seconds,==, vote->vote_seconds);
+ tt_int_op(v1->dist_seconds,==, vote->dist_seconds);
+ tt_str_op(v1->client_versions,==, vote->client_versions);
+ tt_str_op(v1->server_versions,==, vote->server_versions);
+ tt_assert(v1->voters && smartlist_len(v1->voters));
voter = smartlist_get(v1->voters, 0);
- test_streq(voter->nickname, "Voter1");
- test_streq(voter->address, "1.2.3.4");
- test_eq(voter->addr, 0x01020304);
- test_eq(voter->dir_port, 80);
- test_eq(voter->or_port, 9000);
- test_streq(voter->contact, "voter@example.com");
- test_assert(v1->cert);
- test_assert(!crypto_pk_cmp_keys(sign_skey_1, v1->cert->signing_key));
+ tt_str_op(voter->nickname,==, "Voter1");
+ tt_str_op(voter->address,==, "1.2.3.4");
+ tt_int_op(voter->addr,==, 0x01020304);
+ tt_int_op(voter->dir_port,==, 80);
+ tt_int_op(voter->or_port,==, 9000);
+ tt_str_op(voter->contact,==, "voter@example.com");
+ tt_assert(v1->cert);
+ tt_assert(!crypto_pk_cmp_keys(sign_skey_1, v1->cert->signing_key));
cp = smartlist_join_strings(v1->known_flags, ":", 0, NULL);
- test_streq(cp, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
+ tt_str_op(cp,==, "Authority:Exit:Fast:Guard:Running:Stable:V2Dir:Valid");
tor_free(cp);
- test_eq(smartlist_len(v1->routerstatus_list), n_vrs);
+ tt_int_op(smartlist_len(v1->routerstatus_list),==, n_vrs);
if (vote_tweaks) params_tweaked += vote_tweaks(v1, 1, now);
/* Check the routerstatuses. */
for (idx = 0; idx < n_vrs; ++idx) {
vrs = smartlist_get(v1->routerstatus_list, idx);
- test_assert(vrs);
+ tt_assert(vrs);
vrs_test(vrs, 1, now);
}
@@ -1381,15 +1868,15 @@ test_a_networkstatus(
/* generate and parse v2. */
v2_text = format_networkstatus_vote(sign_skey_2, vote);
- test_assert(v2_text);
+ tt_assert(v2_text);
v2 = networkstatus_parse_vote_from_string(v2_text, NULL, NS_TYPE_VOTE);
- test_assert(v2);
+ tt_assert(v2);
if (vote_tweaks) params_tweaked += vote_tweaks(v2, 2, now);
/* Check that flags come out right.*/
cp = smartlist_join_strings(v2->known_flags, ":", 0, NULL);
- test_streq(cp, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
+ tt_str_op(cp,==, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
"Running:Stable:V2Dir:Valid");
tor_free(cp);
@@ -1397,7 +1884,7 @@ test_a_networkstatus(
n_vrs = smartlist_len(v2->routerstatus_list);
for (idx = 0; idx < n_vrs; ++idx) {
vrs = smartlist_get(v2->routerstatus_list, idx);
- test_assert(vrs);
+ tt_assert(vrs);
vrs_test(vrs, 2, now);
}
@@ -1425,10 +1912,10 @@ test_a_networkstatus(
memset(voter->legacy_id_digest, (int)'A', DIGEST_LEN);
v3_text = format_networkstatus_vote(sign_skey_3, vote);
- test_assert(v3_text);
+ tt_assert(v3_text);
v3 = networkstatus_parse_vote_from_string(v3_text, NULL, NS_TYPE_VOTE);
- test_assert(v3);
+ tt_assert(v3);
if (vote_tweaks) params_tweaked += vote_tweaks(v3, 3, now);
@@ -1442,10 +1929,10 @@ test_a_networkstatus(
"AAAAAAAAAAAAAAAAAAAA",
sign_skey_leg1,
FLAV_NS);
- test_assert(consensus_text);
+ tt_assert(consensus_text);
con = networkstatus_parse_vote_from_string(consensus_text, NULL,
NS_TYPE_CONSENSUS);
- test_assert(con);
+ tt_assert(con);
//log_notice(LD_GENERAL, "<<%s>>\n<<%s>>\n<<%s>>\n",
// v1_text, v2_text, v3_text);
consensus_text_md = networkstatus_compute_consensus(votes, 3,
@@ -1454,38 +1941,38 @@ test_a_networkstatus(
"AAAAAAAAAAAAAAAAAAAA",
sign_skey_leg1,
FLAV_MICRODESC);
- test_assert(consensus_text_md);
+ tt_assert(consensus_text_md);
con_md = networkstatus_parse_vote_from_string(consensus_text_md, NULL,
NS_TYPE_CONSENSUS);
- test_assert(con_md);
- test_eq(con_md->flavor, FLAV_MICRODESC);
+ tt_assert(con_md);
+ tt_int_op(con_md->flavor,==, FLAV_MICRODESC);
/* Check consensus contents. */
- test_assert(con->type == NS_TYPE_CONSENSUS);
- test_eq(con->published, 0); /* this field only appears in votes. */
- test_eq(con->valid_after, now+1000);
- test_eq(con->fresh_until, now+2003); /* median */
- test_eq(con->valid_until, now+3000);
- test_eq(con->vote_seconds, 100);
- test_eq(con->dist_seconds, 250); /* median */
- test_streq(con->client_versions, "0.1.2.14");
- test_streq(con->server_versions, "0.1.2.15,0.1.2.16");
+ tt_assert(con->type == NS_TYPE_CONSENSUS);
+ tt_int_op(con->published,==, 0); /* this field only appears in votes. */
+ tt_int_op(con->valid_after,==, now+1000);
+ tt_int_op(con->fresh_until,==, now+2003); /* median */
+ tt_int_op(con->valid_until,==, now+3000);
+ tt_int_op(con->vote_seconds,==, 100);
+ tt_int_op(con->dist_seconds,==, 250); /* median */
+ tt_str_op(con->client_versions,==, "0.1.2.14");
+ tt_str_op(con->server_versions,==, "0.1.2.15,0.1.2.16");
cp = smartlist_join_strings(v2->known_flags, ":", 0, NULL);
- test_streq(cp, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
+ tt_str_op(cp,==, "Authority:Exit:Fast:Guard:MadeOfCheese:MadeOfTin:"
"Running:Stable:V2Dir:Valid");
tor_free(cp);
if (!params_tweaked) {
/* Skip this one if vote_tweaks() messed with the param lists */
cp = smartlist_join_strings(con->net_params, ":", 0, NULL);
- test_streq(cp, "circuitwindow=80:foo=660");
+ tt_str_op(cp,==, "circuitwindow=80:foo=660");
tor_free(cp);
}
- test_eq(4, smartlist_len(con->voters)); /*3 voters, 1 legacy key.*/
+ tt_int_op(4,==, smartlist_len(con->voters)); /*3 voters, 1 legacy key.*/
/* The voter id digests should be in this order. */
- test_assert(memcmp(cert2->cache_info.identity_digest,
+ tt_assert(memcmp(cert2->cache_info.identity_digest,
cert1->cache_info.identity_digest,DIGEST_LEN)<0);
- test_assert(memcmp(cert1->cache_info.identity_digest,
+ tt_assert(memcmp(cert1->cache_info.identity_digest,
cert3->cache_info.identity_digest,DIGEST_LEN)<0);
test_same_voter(smartlist_get(con->voters, 1),
smartlist_get(v2->voters, 0));
@@ -1500,26 +1987,26 @@ test_a_networkstatus(
n_rs = smartlist_len(con->routerstatus_list);
for (idx = 0; idx < n_rs; ++idx) {
rs = smartlist_get(con->routerstatus_list, idx);
- test_assert(rs);
+ tt_assert(rs);
rs_test(rs, now);
}
/* Check signatures. the first voter is a pseudo-entry with a legacy key.
* The second one hasn't signed. The fourth one has signed: validate it. */
voter = smartlist_get(con->voters, 1);
- test_eq(smartlist_len(voter->sigs), 0);
+ tt_int_op(smartlist_len(voter->sigs),==, 0);
voter = smartlist_get(con->voters, 3);
- test_eq(smartlist_len(voter->sigs), 1);
+ tt_int_op(smartlist_len(voter->sigs),==, 1);
sig = smartlist_get(voter->sigs, 0);
- test_assert(sig->signature);
- test_assert(!sig->good_signature);
- test_assert(!sig->bad_signature);
+ tt_assert(sig->signature);
+ tt_assert(!sig->good_signature);
+ tt_assert(!sig->bad_signature);
- test_assert(!networkstatus_check_document_signature(con, sig, cert3));
- test_assert(sig->signature);
- test_assert(sig->good_signature);
- test_assert(!sig->bad_signature);
+ tt_assert(!networkstatus_check_document_signature(con, sig, cert3));
+ tt_assert(sig->signature);
+ tt_assert(sig->good_signature);
+ tt_assert(!sig->bad_signature);
{
const char *msg=NULL;
@@ -1542,10 +2029,10 @@ test_a_networkstatus(
cert1->identity_key,
sign_skey_1, NULL,NULL,
FLAV_MICRODESC);
- test_assert(consensus_text2);
- test_assert(consensus_text3);
- test_assert(consensus_text_md2);
- test_assert(consensus_text_md3);
+ tt_assert(consensus_text2);
+ tt_assert(consensus_text3);
+ tt_assert(consensus_text_md2);
+ tt_assert(consensus_text_md3);
con2 = networkstatus_parse_vote_from_string(consensus_text2, NULL,
NS_TYPE_CONSENSUS);
con3 = networkstatus_parse_vote_from_string(consensus_text3, NULL,
@@ -1554,17 +2041,17 @@ test_a_networkstatus(
NS_TYPE_CONSENSUS);
con_md3 = networkstatus_parse_vote_from_string(consensus_text_md3, NULL,
NS_TYPE_CONSENSUS);
- test_assert(con2);
- test_assert(con3);
- test_assert(con_md2);
- test_assert(con_md3);
+ tt_assert(con2);
+ tt_assert(con3);
+ tt_assert(con_md2);
+ tt_assert(con_md3);
/* All three should have the same digest. */
- test_memeq(&con->digests, &con2->digests, sizeof(digests_t));
- test_memeq(&con->digests, &con3->digests, sizeof(digests_t));
+ tt_mem_op(&con->digests,==, &con2->digests, sizeof(digests_t));
+ tt_mem_op(&con->digests,==, &con3->digests, sizeof(digests_t));
- test_memeq(&con_md->digests, &con_md2->digests, sizeof(digests_t));
- test_memeq(&con_md->digests, &con_md3->digests, sizeof(digests_t));
+ tt_mem_op(&con_md->digests,==, &con_md2->digests, sizeof(digests_t));
+ tt_mem_op(&con_md->digests,==, &con_md3->digests, sizeof(digests_t));
/* Extract a detached signature from con3. */
detached_text1 = get_detached_sigs(con3, con_md3);
@@ -1574,50 +2061,51 @@ test_a_networkstatus(
tt_assert(dsig1);
/* Are parsed values as expected? */
- test_eq(dsig1->valid_after, con3->valid_after);
- test_eq(dsig1->fresh_until, con3->fresh_until);
- test_eq(dsig1->valid_until, con3->valid_until);
+ tt_int_op(dsig1->valid_after,==, con3->valid_after);
+ tt_int_op(dsig1->fresh_until,==, con3->fresh_until);
+ tt_int_op(dsig1->valid_until,==, con3->valid_until);
{
digests_t *dsig_digests = strmap_get(dsig1->digests, "ns");
- test_assert(dsig_digests);
- test_memeq(dsig_digests->d[DIGEST_SHA1], con3->digests.d[DIGEST_SHA1],
+ tt_assert(dsig_digests);
+ tt_mem_op(dsig_digests->d[DIGEST_SHA1],==, con3->digests.d[DIGEST_SHA1],
DIGEST_LEN);
dsig_digests = strmap_get(dsig1->digests, "microdesc");
- test_assert(dsig_digests);
- test_memeq(dsig_digests->d[DIGEST_SHA256],
+ tt_assert(dsig_digests);
+ tt_mem_op(dsig_digests->d[DIGEST_SHA256],==,
con_md3->digests.d[DIGEST_SHA256],
DIGEST256_LEN);
}
{
smartlist_t *dsig_signatures = strmap_get(dsig1->signatures, "ns");
- test_assert(dsig_signatures);
- test_eq(1, smartlist_len(dsig_signatures));
+ tt_assert(dsig_signatures);
+ tt_int_op(1,==, smartlist_len(dsig_signatures));
sig = smartlist_get(dsig_signatures, 0);
- test_memeq(sig->identity_digest, cert1->cache_info.identity_digest,
+ tt_mem_op(sig->identity_digest,==, cert1->cache_info.identity_digest,
DIGEST_LEN);
- test_eq(sig->alg, DIGEST_SHA1);
+ tt_int_op(sig->alg,==, DIGEST_SHA1);
dsig_signatures = strmap_get(dsig1->signatures, "microdesc");
- test_assert(dsig_signatures);
- test_eq(1, smartlist_len(dsig_signatures));
+ tt_assert(dsig_signatures);
+ tt_int_op(1,==, smartlist_len(dsig_signatures));
sig = smartlist_get(dsig_signatures, 0);
- test_memeq(sig->identity_digest, cert1->cache_info.identity_digest,
+ tt_mem_op(sig->identity_digest,==, cert1->cache_info.identity_digest,
DIGEST_LEN);
- test_eq(sig->alg, DIGEST_SHA256);
+ tt_int_op(sig->alg,==, DIGEST_SHA256);
}
/* Try adding it to con2. */
detached_text2 = get_detached_sigs(con2,con_md2);
- test_eq(1, networkstatus_add_detached_signatures(con2, dsig1, "test",
+ tt_int_op(1,==, networkstatus_add_detached_signatures(con2, dsig1, "test",
LOG_INFO, &msg));
tor_free(detached_text2);
- test_eq(1, networkstatus_add_detached_signatures(con_md2, dsig1, "test",
+ tt_int_op(1,==,
+ networkstatus_add_detached_signatures(con_md2, dsig1, "test",
LOG_INFO, &msg));
tor_free(detached_text2);
detached_text2 = get_detached_sigs(con2,con_md2);
//printf("\n<%s>\n", detached_text2);
dsig2 = networkstatus_parse_detached_signatures(detached_text2, NULL);
- test_assert(dsig2);
+ tt_assert(dsig2);
/*
printf("\n");
SMARTLIST_FOREACH(dsig2->signatures, networkstatus_voter_info_t *, vi, {
@@ -1626,28 +2114,28 @@ test_a_networkstatus(
printf("%s\n", hd);
});
*/
- test_eq(2,
+ tt_int_op(2,==,
smartlist_len((smartlist_t*)strmap_get(dsig2->signatures, "ns")));
- test_eq(2,
+ tt_int_op(2,==,
smartlist_len((smartlist_t*)strmap_get(dsig2->signatures,
"microdesc")));
/* Try adding to con2 twice; verify that nothing changes. */
- test_eq(0, networkstatus_add_detached_signatures(con2, dsig1, "test",
+ tt_int_op(0,==, networkstatus_add_detached_signatures(con2, dsig1, "test",
LOG_INFO, &msg));
/* Add to con. */
- test_eq(2, networkstatus_add_detached_signatures(con, dsig2, "test",
+ tt_int_op(2,==, networkstatus_add_detached_signatures(con, dsig2, "test",
LOG_INFO, &msg));
/* Check signatures */
voter = smartlist_get(con->voters, 1);
sig = smartlist_get(voter->sigs, 0);
- test_assert(sig);
- test_assert(!networkstatus_check_document_signature(con, sig, cert2));
+ tt_assert(sig);
+ tt_assert(!networkstatus_check_document_signature(con, sig, cert2));
voter = smartlist_get(con->voters, 2);
sig = smartlist_get(voter->sigs, 0);
- test_assert(sig);
- test_assert(!networkstatus_check_document_signature(con, sig, cert1));
+ tt_assert(sig);
+ tt_assert(!networkstatus_check_document_signature(con, sig, cert1));
}
done:
@@ -1709,8 +2197,9 @@ test_a_networkstatus(
/** Run unit tests for generating and parsing V3 consensus networkstatus
* documents. */
static void
-test_dir_v3_networkstatus(void)
+test_dir_v3_networkstatus(void *arg)
{
+ (void)arg;
test_a_networkstatus(gen_routerstatus_for_v3ns,
vote_tweaks_for_v3ns,
test_vrs_for_v3ns,
@@ -1749,10 +2238,37 @@ test_dir_scale_bw(void *testdata)
tt_assert(total <= (U64_LITERAL(1)<<62));
for (i=0; i<8; ++i) {
+ /* vals[2].u64 is the scaled value of 1.0 */
double ratio = ((double)vals[i].u64) / vals[2].u64;
tt_double_op(fabs(ratio - v[i]), <, .00001);
}
+ /* test handling of no entries */
+ total = 1;
+ scale_array_elements_to_u64(vals, 0, &total);
+ tt_assert(total == 0);
+
+ /* make sure we don't read the array when we have no entries
+ * may require compiler flags to catch NULL dereferences */
+ total = 1;
+ scale_array_elements_to_u64(NULL, 0, &total);
+ tt_assert(total == 0);
+
+ scale_array_elements_to_u64(NULL, 0, NULL);
+
+ /* test handling of zero totals */
+ total = 1;
+ vals[0].dbl = 0.0;
+ scale_array_elements_to_u64(vals, 1, &total);
+ tt_assert(total == 0);
+ tt_assert(vals[0].u64 == 0);
+
+ vals[0].dbl = 0.0;
+ vals[1].dbl = 0.0;
+ scale_array_elements_to_u64(vals, 2, NULL);
+ tt_assert(vals[0].u64 == 0);
+ tt_assert(vals[1].u64 == 0);
+
done:
;
}
@@ -1958,7 +2474,7 @@ gen_routerstatus_for_umbw(int idx, time_t now)
break;
default:
/* Shouldn't happen */
- test_assert(0);
+ tt_assert(0);
}
if (vrs) {
vrs->microdesc = tor_malloc_zero(sizeof(vote_microdesc_hash_t));
@@ -1980,11 +2496,11 @@ vote_tweaks_for_umbw(networkstatus_t *v, int voter, time_t now)
char *maxbw_param = NULL;
int rv = 0;
- test_assert(v);
+ tt_assert(v);
(void)voter;
(void)now;
- test_assert(v->supported_methods);
+ tt_assert(v->supported_methods);
SMARTLIST_FOREACH(v->supported_methods, char *, c, tor_free(c));
smartlist_clear(v->supported_methods);
/* Method 17 is MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB */
@@ -1994,7 +2510,7 @@ vote_tweaks_for_umbw(networkstatus_t *v, int voter, time_t now)
/* If we're using a non-default clip bandwidth, add it to net_params */
if (alternate_clip_bw > 0) {
tor_asprintf(&maxbw_param, "maxunmeasuredbw=%u", alternate_clip_bw);
- test_assert(maxbw_param);
+ tt_assert(maxbw_param);
if (maxbw_param) {
smartlist_add(v->net_params, maxbw_param);
rv = 1;
@@ -2017,9 +2533,9 @@ test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
alternate_clip_bw : DEFAULT_MAX_UNMEASURED_BW_KB;
(void)voter;
- test_assert(vrs);
+ tt_assert(vrs);
rs = &(vrs->status);
- test_assert(rs);
+ tt_assert(rs);
/* Split out by digests to test */
if (tor_memeq(rs->identity_digest,
@@ -2030,21 +2546,21 @@ test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
* Check the first routerstatus - measured bandwidth below the clip
* cutoff.
*/
- test_streq(vrs->version, "0.1.2.14");
- test_eq(rs->published_on, now-1500);
- test_streq(rs->nickname, "router2");
- test_memeq(rs->identity_digest,
+ tt_str_op(vrs->version,==, "0.1.2.14");
+ tt_int_op(rs->published_on,==, now-1500);
+ tt_str_op(rs->nickname,==, "router2");
+ tt_mem_op(rs->identity_digest,==,
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
DIGEST_LEN);
- test_memeq(rs->descriptor_digest, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
- test_eq(rs->addr, 0x99008801);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 8000);
- test_assert(rs->has_bandwidth);
- test_assert(vrs->has_measured_bw);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb / 2);
- test_eq(vrs->measured_bw_kb, max_unmeasured_bw_kb / 2);
+ tt_mem_op(rs->descriptor_digest,==, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
+ tt_int_op(rs->addr,==, 0x99008801);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 8000);
+ tt_assert(rs->has_bandwidth);
+ tt_assert(vrs->has_measured_bw);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb / 2);
+ tt_int_op(vrs->measured_bw_kb,==, max_unmeasured_bw_kb / 2);
} else if (tor_memeq(rs->identity_digest,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
@@ -2054,24 +2570,24 @@ test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
* Check the second routerstatus - measured bandwidth above the clip
* cutoff.
*/
- test_streq(vrs->version, "0.2.0.5");
- test_eq(rs->published_on, now-1000);
- test_streq(rs->nickname, "router1");
- test_memeq(rs->identity_digest,
+ tt_str_op(vrs->version,==, "0.2.0.5");
+ tt_int_op(rs->published_on,==, now-1000);
+ tt_str_op(rs->nickname,==, "router1");
+ tt_mem_op(rs->identity_digest,==,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
DIGEST_LEN);
- test_memeq(rs->descriptor_digest, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
- test_eq(rs->addr, 0x99009901);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 0);
+ tt_mem_op(rs->descriptor_digest,==, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
+ tt_int_op(rs->addr,==, 0x99009901);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 0);
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
- test_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
- test_eq(rs->ipv6_orport, 4711);
- test_assert(rs->has_bandwidth);
- test_assert(vrs->has_measured_bw);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb * 2);
- test_eq(vrs->measured_bw_kb, max_unmeasured_bw_kb * 2);
+ tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
+ tt_int_op(rs->ipv6_orport,==, 4711);
+ tt_assert(rs->has_bandwidth);
+ tt_assert(vrs->has_measured_bw);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb * 2);
+ tt_int_op(vrs->measured_bw_kb,==, max_unmeasured_bw_kb * 2);
} else if (tor_memeq(rs->identity_digest,
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33",
@@ -2081,10 +2597,10 @@ test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
* cutoff; this one should be clipped later on in the consensus, but
* appears unclipped in the vote.
*/
- test_assert(rs->has_bandwidth);
- test_assert(!(vrs->has_measured_bw));
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb * 2);
- test_eq(vrs->measured_bw_kb, 0);
+ tt_assert(rs->has_bandwidth);
+ tt_assert(!(vrs->has_measured_bw));
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb * 2);
+ tt_int_op(vrs->measured_bw_kb,==, 0);
} else if (tor_memeq(rs->identity_digest,
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34"
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34",
@@ -2093,12 +2609,12 @@ test_vrs_for_umbw(vote_routerstatus_t *vrs, int voter, time_t now)
* Check the fourth routerstatus - unmeasured bandwidth below the clip
* cutoff; this one should not be clipped.
*/
- test_assert(rs->has_bandwidth);
- test_assert(!(vrs->has_measured_bw));
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb / 2);
- test_eq(vrs->measured_bw_kb, 0);
+ tt_assert(rs->has_bandwidth);
+ tt_assert(!(vrs->has_measured_bw));
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb / 2);
+ tt_int_op(vrs->measured_bw_kb,==, 0);
} else {
- test_assert(0);
+ tt_assert(0);
}
done:
@@ -2113,11 +2629,11 @@ test_consensus_for_umbw(networkstatus_t *con, time_t now)
{
(void)now;
- test_assert(con);
- test_assert(!con->cert);
- // test_assert(con->consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB);
- test_assert(con->consensus_method >= 16);
- test_eq(4, smartlist_len(con->routerstatus_list));
+ tt_assert(con);
+ tt_assert(!con->cert);
+ // tt_assert(con->consensus_method >= MIN_METHOD_TO_CLIP_UNMEASURED_BW_KB);
+ tt_assert(con->consensus_method >= 16);
+ tt_int_op(4,==, smartlist_len(con->routerstatus_list));
/* There should be four listed routers; all voters saw the same in this */
done:
@@ -2134,61 +2650,61 @@ test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
uint32_t max_unmeasured_bw_kb = (alternate_clip_bw > 0) ?
alternate_clip_bw : DEFAULT_MAX_UNMEASURED_BW_KB;
- test_assert(rs);
+ tt_assert(rs);
/* There should be four listed routers, as constructed above */
if (tor_memeq(rs->identity_digest,
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
DIGEST_LEN)) {
- test_memeq(rs->identity_digest,
+ tt_mem_op(rs->identity_digest,==,
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3"
"\x3\x3\x3\x3\x3\x3\x3\x3\x3\x3",
DIGEST_LEN);
- test_memeq(rs->descriptor_digest, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
- test_assert(!rs->is_authority);
- test_assert(!rs->is_exit);
- test_assert(!rs->is_fast);
- test_assert(!rs->is_possible_guard);
- test_assert(!rs->is_stable);
+ tt_mem_op(rs->descriptor_digest,==, "NNNNNNNNNNNNNNNNNNNN", DIGEST_LEN);
+ tt_assert(!rs->is_authority);
+ tt_assert(!rs->is_exit);
+ tt_assert(!rs->is_fast);
+ tt_assert(!rs->is_possible_guard);
+ tt_assert(!rs->is_stable);
/* (If it wasn't running it wouldn't be here) */
- test_assert(rs->is_flagged_running);
- test_assert(!rs->is_valid);
- test_assert(!rs->is_named);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(!rs->is_valid);
+ tt_assert(!rs->is_named);
/* This one should have measured bandwidth below the clip cutoff */
- test_assert(rs->has_bandwidth);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb / 2);
- test_assert(!(rs->bw_is_unmeasured));
+ tt_assert(rs->has_bandwidth);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb / 2);
+ tt_assert(!(rs->bw_is_unmeasured));
} else if (tor_memeq(rs->identity_digest,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
DIGEST_LEN)) {
/* This one showed up in 3 digests. Twice with ID 'M', once with 'Z'. */
- test_memeq(rs->identity_digest,
+ tt_mem_op(rs->identity_digest,==,
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5"
"\x5\x5\x5\x5\x5\x5\x5\x5\x5\x5",
DIGEST_LEN);
- test_streq(rs->nickname, "router1");
- test_memeq(rs->descriptor_digest, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
- test_eq(rs->published_on, now-1000);
- test_eq(rs->addr, 0x99009901);
- test_eq(rs->or_port, 443);
- test_eq(rs->dir_port, 0);
+ tt_str_op(rs->nickname,==, "router1");
+ tt_mem_op(rs->descriptor_digest,==, "MMMMMMMMMMMMMMMMMMMM", DIGEST_LEN);
+ tt_int_op(rs->published_on,==, now-1000);
+ tt_int_op(rs->addr,==, 0x99009901);
+ tt_int_op(rs->or_port,==, 443);
+ tt_int_op(rs->dir_port,==, 0);
tor_addr_parse(&addr_ipv6, "[1:2:3::4]");
- test_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
- test_eq(rs->ipv6_orport, 4711);
- test_assert(!rs->is_authority);
- test_assert(rs->is_exit);
- test_assert(rs->is_fast);
- test_assert(rs->is_possible_guard);
- test_assert(rs->is_stable);
- test_assert(rs->is_flagged_running);
- test_assert(rs->is_valid);
- test_assert(!rs->is_named);
+ tt_assert(tor_addr_eq(&rs->ipv6_addr, &addr_ipv6));
+ tt_int_op(rs->ipv6_orport,==, 4711);
+ tt_assert(!rs->is_authority);
+ tt_assert(rs->is_exit);
+ tt_assert(rs->is_fast);
+ tt_assert(rs->is_possible_guard);
+ tt_assert(rs->is_stable);
+ tt_assert(rs->is_flagged_running);
+ tt_assert(rs->is_valid);
+ tt_assert(!rs->is_named);
/* This one should have measured bandwidth above the clip cutoff */
- test_assert(rs->has_bandwidth);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb * 2);
- test_assert(!(rs->bw_is_unmeasured));
+ tt_assert(rs->has_bandwidth);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb * 2);
+ tt_assert(!(rs->bw_is_unmeasured));
} else if (tor_memeq(rs->identity_digest,
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33"
"\x33\x33\x33\x33\x33\x33\x33\x33\x33\x33",
@@ -2197,9 +2713,9 @@ test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
* This one should have unmeasured bandwidth above the clip cutoff,
* and so should be clipped
*/
- test_assert(rs->has_bandwidth);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb);
- test_assert(rs->bw_is_unmeasured);
+ tt_assert(rs->has_bandwidth);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb);
+ tt_assert(rs->bw_is_unmeasured);
} else if (tor_memeq(rs->identity_digest,
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34"
"\x34\x34\x34\x34\x34\x34\x34\x34\x34\x34",
@@ -2208,12 +2724,12 @@ test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
* This one should have unmeasured bandwidth below the clip cutoff,
* and so should not be clipped
*/
- test_assert(rs->has_bandwidth);
- test_eq(rs->bandwidth_kb, max_unmeasured_bw_kb / 2);
- test_assert(rs->bw_is_unmeasured);
+ tt_assert(rs->has_bandwidth);
+ tt_int_op(rs->bandwidth_kb,==, max_unmeasured_bw_kb / 2);
+ tt_assert(rs->bw_is_unmeasured);
} else {
/* Weren't expecting this... */
- test_assert(0);
+ tt_assert(0);
}
done:
@@ -2227,9 +2743,10 @@ test_routerstatus_for_umbw(routerstatus_t *rs, time_t now)
*/
static void
-test_dir_clip_unmeasured_bw_kb(void)
+test_dir_clip_unmeasured_bw_kb(void *arg)
{
/* Run the test with the default clip bandwidth */
+ (void)arg;
alternate_clip_bw = 0;
test_a_networkstatus(gen_routerstatus_for_umbw,
vote_tweaks_for_umbw,
@@ -2244,7 +2761,7 @@ test_dir_clip_unmeasured_bw_kb(void)
*/
static void
-test_dir_clip_unmeasured_bw_kb_alt(void)
+test_dir_clip_unmeasured_bw_kb_alt(void *arg)
{
/*
* Try a different one; this value is chosen so that the below-the-cutoff
@@ -2252,6 +2769,7 @@ test_dir_clip_unmeasured_bw_kb_alt(void)
* DEFAULT_MAX_UNMEASURED_BW_KB and if the consensus incorrectly uses that
* cutoff it will fail the test.
*/
+ (void)arg;
alternate_clip_bw = 3 * DEFAULT_MAX_UNMEASURED_BW_KB;
test_a_networkstatus(gen_routerstatus_for_umbw,
vote_tweaks_for_umbw,
@@ -2302,60 +2820,60 @@ test_dir_http_handling(void *args)
/* Parse http url tests: */
/* Good headers */
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1\r\n"
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1\r\n"
"Host: example.com\r\n"
"User-Agent: Mozilla/5.0 (Windows;"
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
- &url), 0);
- test_streq(url, "/tor/a/b/c.txt");
+ &url),==, 0);
+ tt_str_op(url,==, "/tor/a/b/c.txt");
tor_free(url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.0\r\n", &url), 0);
- test_streq(url, "/tor/a/b/c.txt");
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.0\r\n", &url),==, 0);
+ tt_str_op(url,==, "/tor/a/b/c.txt");
tor_free(url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.600\r\n", &url), 0);
- test_streq(url, "/tor/a/b/c.txt");
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.600\r\n", &url),==, 0);
+ tt_str_op(url,==, "/tor/a/b/c.txt");
tor_free(url);
/* Should prepend '/tor/' to url if required */
- test_eq(parse_http_url("GET /a/b/c.txt HTTP/1.1\r\n"
+ tt_int_op(parse_http_url("GET /a/b/c.txt HTTP/1.1\r\n"
"Host: example.com\r\n"
"User-Agent: Mozilla/5.0 (Windows;"
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
- &url), 0);
- test_streq(url, "/tor/a/b/c.txt");
+ &url),==, 0);
+ tt_str_op(url,==, "/tor/a/b/c.txt");
tor_free(url);
/* Bad headers -- no HTTP/1.x*/
- test_eq(parse_http_url("GET /a/b/c.txt\r\n"
+ tt_int_op(parse_http_url("GET /a/b/c.txt\r\n"
"Host: example.com\r\n"
"User-Agent: Mozilla/5.0 (Windows;"
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
- &url), -1);
+ &url),==, -1);
tt_assert(!url);
/* Bad headers */
- test_eq(parse_http_url("GET /a/b/c.txt\r\n"
+ tt_int_op(parse_http_url("GET /a/b/c.txt\r\n"
"Host: example.com\r\n"
"User-Agent: Mozilla/5.0 (Windows;"
" U; Windows NT 6.1; en-US; rv:1.9.1.5)\r\n",
- &url), -1);
+ &url),==, -1);
tt_assert(!url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt", &url), -1);
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt", &url),==, -1);
tt_assert(!url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1", &url), -1);
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1", &url),==, -1);
tt_assert(!url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1x\r\n", &url), -1);
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.1x\r\n", &url),==, -1);
tt_assert(!url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.", &url), -1);
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.", &url),==, -1);
tt_assert(!url);
- test_eq(parse_http_url("GET /tor/a/b/c.txt HTTP/1.\r", &url), -1);
+ tt_int_op(parse_http_url("GET /tor/a/b/c.txt HTTP/1.\r", &url),==, -1);
tt_assert(!url);
done:
@@ -2363,7 +2881,7 @@ test_dir_http_handling(void *args)
}
#define DIR_LEGACY(name) \
- { #name, legacy_test_helper, TT_FORK, &legacy_setup, test_dir_ ## name }
+ { #name, test_dir_ ## name , TT_FORK, NULL, NULL }
#define DIR(name,flags) \
{ #name, test_dir_##name, (flags), NULL, NULL }
@@ -2371,6 +2889,11 @@ test_dir_http_handling(void *args)
struct testcase_t dir_tests[] = {
DIR_LEGACY(nicknames),
DIR_LEGACY(formats),
+ DIR(routerparse_bad, 0),
+ DIR(extrainfo_parsing, 0),
+ DIR(parse_router_list, TT_FORK),
+ DIR(load_routers, TT_FORK),
+ DIR(load_extrainfo, TT_FORK),
DIR_LEGACY(versions),
DIR_LEGACY(fp_pairs),
DIR(split_fps, 0),
diff --git a/src/test/test_entrynodes.c b/src/test/test_entrynodes.c
index ede93fb43a..bddc0f11e0 100644
--- a/src/test/test_entrynodes.c
+++ b/src/test/test_entrynodes.c
@@ -139,7 +139,7 @@ test_choose_random_entry_no_guards(void *arg)
/* Unintuitively, we actually pick a random node as our entry,
because router_choose_random_node() relaxes its constraints if it
can't find a proper entry guard. */
- test_assert(chosen_entry);
+ tt_assert(chosen_entry);
done:
;
@@ -201,7 +201,7 @@ populate_live_entry_guards_test_helper(int num_needed)
SMARTLIST_FOREACH_BEGIN(our_nodelist, const node_t *, node) {
const node_t *node_tmp;
node_tmp = add_an_entry_guard(node, 0, 1, 0, 0);
- test_assert(node_tmp);
+ tt_assert(node_tmp);
} SMARTLIST_FOREACH_END(node);
/* Make sure the nodes were added as entry guards. */
@@ -325,6 +325,19 @@ state_lines_free(smartlist_t *entry_guard_lines)
smartlist_free(entry_guard_lines);
}
+/* Return a statically allocated string representing yesterday's date
+ * in ISO format. We use it so that state file items are not found to
+ * be outdated. */
+static const char *
+get_yesterday_date_str(void)
+{
+ static char buf[ISO_TIME_LEN+1];
+
+ time_t yesterday = time(NULL) - 24*60*60;
+ format_iso_time(buf, yesterday);
+ return buf;
+}
+
/* Tests entry_guards_parse_state(). It creates a fake Tor state with
a saved entry guard and makes sure that Tor can parse it and
creates the right entry node out of it.
@@ -342,7 +355,7 @@ test_entry_guards_parse_state_simple(void *arg)
const char *nickname = "hagbard";
const char *fpr = "B29D536DD1752D542E1FBB3C9CE4449D51298212";
const char *tor_version = "0.2.5.3-alpha-dev";
- const char *added_at = "2014-05-22 02:40:47";
+ const char *added_at = get_yesterday_date_str();
const char *unlisted_since = "2014-06-08 16:16:50";
(void) arg;
@@ -418,6 +431,7 @@ test_entry_guards_parse_state_simple(void *arg)
done:
state_lines_free(entry_state_lines);
or_state_free(state);
+ tor_free(msg);
}
/** Similar to test_entry_guards_parse_state_simple() but aims to test
@@ -457,7 +471,7 @@ test_entry_guards_parse_state_pathbias(void *arg)
smartlist_add_asprintf(state_line, "EntryGuardAddedBy");
smartlist_add_asprintf(state_line,
"B29D536DD1752D542E1FBB3C9CE4449D51298212 0.2.5.3-alpha-dev "
- "2014-05-22 02:40:47");
+ "%s", get_yesterday_date_str());
smartlist_add(entry_state_lines, state_line);
state_line = smartlist_new();
@@ -502,6 +516,7 @@ test_entry_guards_parse_state_pathbias(void *arg)
done:
or_state_free(state);
state_lines_free(entry_state_lines);
+ tor_free(msg);
}
/* Simple test of entry_guards_set_from_config() by specifying a
@@ -538,6 +553,80 @@ test_entry_guards_set_from_config(void *arg)
routerset_free(options->EntryNodes);
}
+static void
+test_entry_is_time_to_retry(void *arg)
+{
+ entry_guard_t *test_guard;
+ time_t now;
+ int retval;
+ (void)arg;
+
+ now = time(NULL);
+
+ test_guard = tor_malloc_zero(sizeof(entry_guard_t));
+
+ test_guard->last_attempted = now - 10;
+ test_guard->unreachable_since = now - 1;
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->unreachable_since = now - (6*60*60 - 1);
+ test_guard->last_attempted = now - (60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->last_attempted = now - (60*60 - 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,0);
+
+ test_guard->unreachable_since = now - (6*60*60 + 1);
+ test_guard->last_attempted = now - (4*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->unreachable_since = now - (3*24*60*60 - 1);
+ test_guard->last_attempted = now - (4*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->unreachable_since = now - (3*24*60*60 + 1);
+ test_guard->last_attempted = now - (18*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->unreachable_since = now - (7*24*60*60 - 1);
+ test_guard->last_attempted = now - (18*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->last_attempted = now - (18*60*60 - 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,0);
+
+ test_guard->unreachable_since = now - (7*24*60*60 + 1);
+ test_guard->last_attempted = now - (36*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ test_guard->unreachable_since = now - (7*24*60*60 + 1);
+ test_guard->last_attempted = now - (36*60*60 + 1);
+
+ retval = entry_is_time_to_retry(test_guard,now);
+ tt_int_op(retval,==,1);
+
+ done:
+ tor_free(test_guard);
+}
+
/** XXX Do some tests that entry_is_live() */
static void
test_entry_is_live(void *arg)
@@ -561,7 +650,7 @@ test_entry_is_live(void *arg)
SMARTLIST_FOREACH_BEGIN(our_nodelist, const node_t *, node) {
const node_t *node_tmp;
node_tmp = add_an_entry_guard(node, 0, 1, 0, 0);
- test_assert(node_tmp);
+ tt_assert(node_tmp);
tt_int_op(node->is_stable, ==, 0);
tt_int_op(node->is_fast, ==, 0);
@@ -581,22 +670,22 @@ test_entry_is_live(void *arg)
test_node = entry_is_live(test_entry,
ENTRY_NEED_UPTIME | ENTRY_ASSUME_REACHABLE,
&msg);
- test_assert(!test_node);
+ tt_assert(!test_node);
/* Require the node to be fast, but it's not. Should fail. */
test_node = entry_is_live(test_entry,
ENTRY_NEED_CAPACITY | ENTRY_ASSUME_REACHABLE,
&msg);
- test_assert(!test_node);
+ tt_assert(!test_node);
/* Don't impose any restrictions on the node. Should succeed. */
test_node = entry_is_live(test_entry, 0, &msg);
- test_assert(test_node);
+ tt_assert(test_node);
tt_ptr_op(test_node, ==, node_get_by_id(test_entry->identity));
/* Require descriptor for this node. It has one so it should succeed. */
test_node = entry_is_live(test_entry, ENTRY_NEED_DESCRIPTOR, &msg);
- test_assert(test_node);
+ tt_assert(test_node);
tt_ptr_op(test_node, ==, node_get_by_id(test_entry->identity));
done:
@@ -608,6 +697,8 @@ static const struct testcase_setup_t fake_network = {
};
struct testcase_t entrynodes_tests[] = {
+ { "entry_is_time_to_retry", test_entry_is_time_to_retry,
+ TT_FORK, NULL, NULL },
{ "choose_random_entry_no_guards", test_choose_random_entry_no_guards,
TT_FORK, &fake_network, NULL },
{ "choose_random_entry_one_possibleguard",
diff --git a/src/test/test_extorport.c b/src/test/test_extorport.c
index 93c8f77d5b..4049d6d5e0 100644
--- a/src/test/test_extorport.c
+++ b/src/test/test_extorport.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define CONNECTION_PRIVATE
@@ -42,7 +42,7 @@ test_ext_or_id_map(void *arg)
/* Give c2 a new ID. */
connection_or_set_ext_or_identifier(c2);
- test_mem_op(idp, !=, c2->ext_or_conn_id, EXT_OR_CONN_ID_LEN);
+ tt_mem_op(idp, !=, c2->ext_or_conn_id, EXT_OR_CONN_ID_LEN);
idp2 = tor_memdup(c2->ext_or_conn_id, EXT_OR_CONN_ID_LEN);
tt_assert(!tor_digest_is_zero(idp2));
@@ -119,7 +119,7 @@ test_ext_or_write_command(void *arg)
==, 0);
cp = buf_get_contents(TO_CONN(c1)->outbuf, &sz);
tt_int_op(sz, ==, 4);
- test_mem_op(cp, ==, "\x00\x99\x00\x00", 4);
+ tt_mem_op(cp, ==, "\x00\x99\x00\x00", 4);
tor_free(cp);
/* Medium command. */
@@ -127,7 +127,7 @@ test_ext_or_write_command(void *arg)
"Wai\0Hello", 9), ==, 0);
cp = buf_get_contents(TO_CONN(c1)->outbuf, &sz);
tt_int_op(sz, ==, 13);
- test_mem_op(cp, ==, "\x00\x99\x00\x09Wai\x00Hello", 13);
+ tt_mem_op(cp, ==, "\x00\x99\x00\x09Wai\x00Hello", 13);
tor_free(cp);
/* Long command */
@@ -137,8 +137,8 @@ test_ext_or_write_command(void *arg)
buf, 65535), ==, 0);
cp = buf_get_contents(TO_CONN(c1)->outbuf, &sz);
tt_int_op(sz, ==, 65539);
- test_mem_op(cp, ==, "\xf0\x0d\xff\xff", 4);
- test_mem_op(cp+4, ==, buf, 65535);
+ tt_mem_op(cp, ==, "\xf0\x0d\xff\xff", 4);
+ tt_mem_op(cp+4, ==, buf, 65535);
tor_free(cp);
done:
@@ -181,7 +181,7 @@ test_ext_or_init_auth(void *arg)
/* Shouldn't be initialized already, or our tests will be a bit
* meaningless */
ext_or_auth_cookie = tor_malloc_zero(32);
- test_assert(tor_mem_is_zero((char*)ext_or_auth_cookie, 32));
+ tt_assert(tor_mem_is_zero((char*)ext_or_auth_cookie, 32));
/* Now make sure we use a temporary file */
fn = get_fname("ext_cookie_file");
@@ -203,14 +203,14 @@ test_ext_or_init_auth(void *arg)
cp = read_file_to_str(fn, RFTS_BIN, &st);
tt_ptr_op(cp, !=, NULL);
tt_u64_op((uint64_t)st.st_size, ==, 64);
- test_memeq(cp, "! Extended ORPort Auth Cookie !\x0a", 32);
- test_memeq(cp+32, ext_or_auth_cookie, 32);
+ tt_mem_op(cp,==, "! Extended ORPort Auth Cookie !\x0a", 32);
+ tt_mem_op(cp+32,==, ext_or_auth_cookie, 32);
memcpy(cookie0, ext_or_auth_cookie, 32);
- test_assert(!tor_mem_is_zero((char*)ext_or_auth_cookie, 32));
+ tt_assert(!tor_mem_is_zero((char*)ext_or_auth_cookie, 32));
/* Operation should be idempotent. */
tt_int_op(0, ==, init_ext_or_cookie_authentication(1));
- test_memeq(cookie0, ext_or_auth_cookie, 32);
+ tt_mem_op(cookie0,==, ext_or_auth_cookie, 32);
done:
tor_free(cp);
@@ -280,15 +280,15 @@ test_ext_or_cookie_auth(void *arg)
46+32+32);
crypto_hmac_sha256(hmac2, (char*)ext_or_auth_cookie, 32, client_hash_input,
46+32+32);
- test_memeq(hmac1, reply, 32);
- test_memeq(hmac2, client_hash, 32);
+ tt_mem_op(hmac1,==, reply, 32);
+ tt_mem_op(hmac2,==, client_hash, 32);
/* Now do it again and make sure that the results are *different* */
tt_int_op(0, ==,
handle_client_auth_nonce(client_nonce, 32, &client_hash2, &reply2,
&reply_len));
- test_memneq(reply2, reply, reply_len);
- test_memneq(client_hash2, client_hash, 32);
+ tt_mem_op(reply2,!=, reply, reply_len);
+ tt_mem_op(client_hash2,!=, client_hash, 32);
/* But that this one checks out too. */
memcpy(server_hash_input+46+32, reply2+32, 32);
memcpy(client_hash_input+46+32, reply2+32, 32);
@@ -297,8 +297,8 @@ test_ext_or_cookie_auth(void *arg)
46+32+32);
crypto_hmac_sha256(hmac2, (char*)ext_or_auth_cookie, 32, client_hash_input,
46+32+32);
- test_memeq(hmac1, reply2, 32);
- test_memeq(hmac2, client_hash2, 32);
+ tt_mem_op(hmac1,==, reply2, 32);
+ tt_mem_op(hmac2,==, client_hash2, 32);
done:
tor_free(reply);
@@ -339,7 +339,7 @@ test_ext_or_cookie_auth_testvec(void *arg)
&reply_len));
tt_ptr_op(reply, !=, NULL );
tt_uint_op(reply_len, ==, 64);
- test_memeq(reply+32, "te road There is always another ", 32);
+ tt_mem_op(reply+32,==, "te road There is always another ", 32);
/* HMACSHA256("Gliding wrapt in a brown mantle,"
* "ExtORPort authentication server-to-client hash"
* "But when I look ahead up the write road There is always another ");
@@ -406,7 +406,7 @@ handshake_start(or_connection_t *conn, int receiving)
tt_int_op(buf_datalen(TO_CONN(conn)->outbuf), ==, (n)); \
if ((n)) { \
fetch_from_buf(b, (n), TO_CONN(conn)->outbuf); \
- test_memeq(b, (s), (n)); \
+ tt_mem_op(b, ==, (s), (n)); \
} \
} while (0)
diff --git a/src/test/test_hs.c b/src/test/test_hs.c
index 99ef7dd570..c4820014c7 100644
--- a/src/test/test_hs.c
+++ b/src/test/test_hs.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -84,8 +84,8 @@ test_hs_desc_event(void *arg)
STR_HS_ID);
expected_msg = "650 HS_DESC REQUESTED "STR_HS_ADDR" NO_AUTH "\
STR_HSDIR_EXIST_LONGNAME" "STR_HS_ID"\r\n";
- test_assert(received_msg);
- test_streq(received_msg, expected_msg);
+ tt_assert(received_msg);
+ tt_str_op(received_msg,==, expected_msg);
tor_free(received_msg);
/* test received event */
@@ -93,8 +93,8 @@ test_hs_desc_event(void *arg)
control_event_hs_descriptor_received(&rend_query, HSDIR_EXIST_ID);
expected_msg = "650 HS_DESC RECEIVED "STR_HS_ADDR" BASIC_AUTH "\
STR_HSDIR_EXIST_LONGNAME"\r\n";
- test_assert(received_msg);
- test_streq(received_msg, expected_msg);
+ tt_assert(received_msg);
+ tt_str_op(received_msg,==, expected_msg);
tor_free(received_msg);
/* test failed event */
@@ -102,8 +102,8 @@ test_hs_desc_event(void *arg)
control_event_hs_descriptor_failed(&rend_query, HSDIR_NONE_EXIST_ID);
expected_msg = "650 HS_DESC FAILED "STR_HS_ADDR" STEALTH_AUTH "\
STR_HSDIR_NONE_EXIST_LONGNAME"\r\n";
- test_assert(received_msg);
- test_streq(received_msg, expected_msg);
+ tt_assert(received_msg);
+ tt_str_op(received_msg,==, expected_msg);
tor_free(received_msg);
/* test invalid auth type */
@@ -111,8 +111,8 @@ test_hs_desc_event(void *arg)
control_event_hs_descriptor_failed(&rend_query, HSDIR_EXIST_ID);
expected_msg = "650 HS_DESC FAILED "STR_HS_ADDR" UNKNOWN "\
STR_HSDIR_EXIST_LONGNAME"\r\n";
- test_assert(received_msg);
- test_streq(received_msg, expected_msg);
+ tt_assert(received_msg);
+ tt_str_op(received_msg,==, expected_msg);
tor_free(received_msg);
done:
diff --git a/src/test/test_introduce.c b/src/test/test_introduce.c
index 69c1152229..0febd59276 100644
--- a/src/test/test_introduce.c
+++ b/src/test/test_introduce.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -290,48 +290,48 @@ do_parse_test(uint8_t *plaintext, size_t plaintext_len, int phase)
/* Get a key */
k = crypto_pk_new();
- test_assert(k);
+ tt_assert(k);
r = crypto_pk_read_private_key_from_string(k, AUTHORITY_SIGNKEY_1, -1);
- test_assert(!r);
+ tt_assert(!r);
/* Get digest for future comparison */
r = crypto_pk_get_digest(k, digest);
- test_assert(r >= 0);
+ tt_assert(r >= 0);
/* Make a cell out of it */
r = make_intro_from_plaintext(
plaintext, plaintext_len,
k, (void **)(&cell));
- test_assert(r > 0);
- test_assert(cell);
+ tt_assert(r > 0);
+ tt_assert(cell);
cell_len = r;
/* Do early parsing */
parsed_req = rend_service_begin_parse_intro(cell, cell_len, 2, &err_msg);
- test_assert(parsed_req);
- test_assert(!err_msg);
- test_memeq(parsed_req->pk, digest, DIGEST_LEN);
- test_assert(parsed_req->ciphertext);
- test_assert(parsed_req->ciphertext_len > 0);
+ tt_assert(parsed_req);
+ tt_assert(!err_msg);
+ tt_mem_op(parsed_req->pk,==, digest, DIGEST_LEN);
+ tt_assert(parsed_req->ciphertext);
+ tt_assert(parsed_req->ciphertext_len > 0);
if (phase == EARLY_PARSE_ONLY)
goto done;
/* Do decryption */
r = rend_service_decrypt_intro(parsed_req, k, &err_msg);
- test_assert(!r);
- test_assert(!err_msg);
- test_assert(parsed_req->plaintext);
- test_assert(parsed_req->plaintext_len > 0);
+ tt_assert(!r);
+ tt_assert(!err_msg);
+ tt_assert(parsed_req->plaintext);
+ tt_assert(parsed_req->plaintext_len > 0);
if (phase == DECRYPT_ONLY)
goto done;
/* Do late parsing */
r = rend_service_parse_intro_plaintext(parsed_req, &err_msg);
- test_assert(!r);
- test_assert(!err_msg);
- test_assert(parsed_req->parsed);
+ tt_assert(!r);
+ tt_assert(!err_msg);
+ tt_assert(parsed_req->parsed);
done:
tor_free(cell);
@@ -371,14 +371,14 @@ make_intro_from_plaintext(
/* Compute key digest (will be first DIGEST_LEN octets of cell) */
r = crypto_pk_get_digest(key, cell);
- test_assert(r >= 0);
+ tt_assert(r >= 0);
/* Do encryption */
r = crypto_pk_public_hybrid_encrypt(
key, cell + DIGEST_LEN, ciphertext_size,
buf, len,
PK_PKCS1_OAEP_PADDING, 0);
- test_assert(r >= 0);
+ tt_assert(r >= 0);
/* Figure out cell length */
cell_len = DIGEST_LEN + r;
@@ -394,8 +394,9 @@ make_intro_from_plaintext(
*/
static void
-test_introduce_decrypt_v0(void)
+test_introduce_decrypt_v0(void *arg)
{
+ (void)arg;
do_decrypt_test(v0_test_plaintext, sizeof(v0_test_plaintext));
}
@@ -403,8 +404,9 @@ test_introduce_decrypt_v0(void)
*/
static void
-test_introduce_decrypt_v1(void)
+test_introduce_decrypt_v1(void *arg)
{
+ (void)arg;
do_decrypt_test(v1_test_plaintext, sizeof(v1_test_plaintext));
}
@@ -412,8 +414,9 @@ test_introduce_decrypt_v1(void)
*/
static void
-test_introduce_decrypt_v2(void)
+test_introduce_decrypt_v2(void *arg)
{
+ (void)arg;
do_decrypt_test(v2_test_plaintext, sizeof(v2_test_plaintext));
}
@@ -421,8 +424,9 @@ test_introduce_decrypt_v2(void)
*/
static void
-test_introduce_decrypt_v3(void)
+test_introduce_decrypt_v3(void *arg)
{
+ (void)arg;
do_decrypt_test(
v3_no_auth_test_plaintext, sizeof(v3_no_auth_test_plaintext));
do_decrypt_test(
@@ -433,8 +437,9 @@ test_introduce_decrypt_v3(void)
*/
static void
-test_introduce_early_parse_v0(void)
+test_introduce_early_parse_v0(void *arg)
{
+ (void)arg;
do_early_parse_test(v0_test_plaintext, sizeof(v0_test_plaintext));
}
@@ -442,8 +447,9 @@ test_introduce_early_parse_v0(void)
*/
static void
-test_introduce_early_parse_v1(void)
+test_introduce_early_parse_v1(void *arg)
{
+ (void)arg;
do_early_parse_test(v1_test_plaintext, sizeof(v1_test_plaintext));
}
@@ -451,8 +457,9 @@ test_introduce_early_parse_v1(void)
*/
static void
-test_introduce_early_parse_v2(void)
+test_introduce_early_parse_v2(void *arg)
{
+ (void)arg;
do_early_parse_test(v2_test_plaintext, sizeof(v2_test_plaintext));
}
@@ -460,8 +467,9 @@ test_introduce_early_parse_v2(void)
*/
static void
-test_introduce_early_parse_v3(void)
+test_introduce_early_parse_v3(void *arg)
{
+ (void)arg;
do_early_parse_test(
v3_no_auth_test_plaintext, sizeof(v3_no_auth_test_plaintext));
do_early_parse_test(
@@ -472,8 +480,9 @@ test_introduce_early_parse_v3(void)
*/
static void
-test_introduce_late_parse_v0(void)
+test_introduce_late_parse_v0(void *arg)
{
+ (void)arg;
do_late_parse_test(v0_test_plaintext, sizeof(v0_test_plaintext));
}
@@ -481,8 +490,9 @@ test_introduce_late_parse_v0(void)
*/
static void
-test_introduce_late_parse_v1(void)
+test_introduce_late_parse_v1(void *arg)
{
+ (void)arg;
do_late_parse_test(v1_test_plaintext, sizeof(v1_test_plaintext));
}
@@ -490,8 +500,9 @@ test_introduce_late_parse_v1(void)
*/
static void
-test_introduce_late_parse_v2(void)
+test_introduce_late_parse_v2(void *arg)
{
+ (void)arg;
do_late_parse_test(v2_test_plaintext, sizeof(v2_test_plaintext));
}
@@ -499,8 +510,9 @@ test_introduce_late_parse_v2(void)
*/
static void
-test_introduce_late_parse_v3(void)
+test_introduce_late_parse_v3(void *arg)
{
+ (void)arg;
do_late_parse_test(
v3_no_auth_test_plaintext, sizeof(v3_no_auth_test_plaintext));
do_late_parse_test(
@@ -508,7 +520,7 @@ test_introduce_late_parse_v3(void)
}
#define INTRODUCE_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_introduce_ ## name }
+ { #name, test_introduce_ ## name , 0, NULL, NULL }
struct testcase_t introduce_tests[] = {
INTRODUCE_LEGACY(early_parse_v0),
diff --git a/src/test/test_logging.c b/src/test/test_logging.c
index 9f57000bea..9d9cbae6a8 100644
--- a/src/test/test_logging.c
+++ b/src/test/test_logging.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -19,7 +19,7 @@ test_get_sigsafe_err_fds(void *arg)
int n;
log_severity_list_t include_bug, no_bug, no_bug2;
(void) arg;
- init_logging();
+ init_logging(1);
n = tor_log_get_sigsafe_err_fds(&fds);
tt_int_op(n, ==, 1);
@@ -87,7 +87,7 @@ test_sigsafe_err(void *arg)
set_log_severity_config(LOG_WARN, LOG_ERR, &include_bug);
- init_logging();
+ init_logging(1);
mark_logs_temp();
add_file_log(&include_bug, fn, 0);
tor_log_update_sigsafe_err_fds();
diff --git a/src/test/test_microdesc.c b/src/test/test_microdesc.c
index 78f4823b87..aa4bdf2ae8 100644
--- a/src/test/test_microdesc.c
+++ b/src/test/test_microdesc.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010-2013, The Tor Project, Inc. */
+/* Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -7,11 +7,16 @@
#include "config.h"
#include "dirvote.h"
#include "microdesc.h"
+#include "networkstatus.h"
#include "routerlist.h"
#include "routerparse.h"
#include "test.h"
+#include <openssl/rsa.h>
+#include <openssl/bn.h>
+#include <openssl/pem.h>
+
#ifdef _WIN32
/* For mkdir() */
#include <direct.h>
@@ -108,7 +113,7 @@ test_md_cache(void *data)
md2 = smartlist_get(added, 0);
/* And it should have gotten removed from 'wanted' */
tt_int_op(smartlist_len(wanted), ==, 1);
- test_mem_op(smartlist_get(wanted, 0), ==, d3, DIGEST256_LEN);
+ tt_mem_op(smartlist_get(wanted, 0), ==, d3, DIGEST256_LEN);
smartlist_free(added);
added = NULL;
@@ -144,18 +149,18 @@ test_md_cache(void *data)
tt_int_op(md1->bodylen, ==, strlen(test_md1));
tt_int_op(md2->bodylen, ==, strlen(test_md2));
tt_int_op(md3->bodylen, ==, strlen(test_md3_noannotation));
- test_mem_op(md1->body, ==, test_md1, strlen(test_md1));
- test_mem_op(md2->body, ==, test_md2, strlen(test_md2));
- test_mem_op(md3->body, ==, test_md3_noannotation,
+ tt_mem_op(md1->body, ==, test_md1, strlen(test_md1));
+ tt_mem_op(md2->body, ==, test_md2, strlen(test_md2));
+ tt_mem_op(md3->body, ==, test_md3_noannotation,
strlen(test_md3_noannotation));
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs.new",
options->DataDirectory);
s = read_file_to_str(fn, RFTS_BIN, NULL);
tt_assert(s);
- test_mem_op(md1->body, ==, s + md1->off, md1->bodylen);
- test_mem_op(md2->body, ==, s + md2->off, md2->bodylen);
- test_mem_op(md3->body, ==, s + md3->off, md3->bodylen);
+ tt_mem_op(md1->body, ==, s + md1->off, md1->bodylen);
+ tt_mem_op(md2->body, ==, s + md2->off, md2->bodylen);
+ tt_mem_op(md3->body, ==, s + md3->off, md3->bodylen);
tt_ptr_op(md1->family, ==, NULL);
tt_ptr_op(md3->family, !=, NULL);
@@ -180,9 +185,9 @@ test_md_cache(void *data)
tor_asprintf(&fn, "%s"PATH_SEPARATOR"cached-microdescs",
options->DataDirectory);
s = read_file_to_str(fn, RFTS_BIN, NULL);
- test_mem_op(md1->body, ==, s + md1->off, strlen(test_md1));
- test_mem_op(md2->body, ==, s + md2->off, strlen(test_md2));
- test_mem_op(md3->body, ==, s + md3->off, strlen(test_md3_noannotation));
+ tt_mem_op(md1->body, ==, s + md1->off, strlen(test_md1));
+ tt_mem_op(md2->body, ==, s + md2->off, strlen(test_md2));
+ tt_mem_op(md3->body, ==, s + md3->off, strlen(test_md3_noannotation));
/* Okay, now we are going to forget about the cache entirely, and reload it
* from the disk. */
@@ -191,12 +196,12 @@ test_md_cache(void *data)
md1 = microdesc_cache_lookup_by_digest256(mc, d1);
md2 = microdesc_cache_lookup_by_digest256(mc, d2);
md3 = microdesc_cache_lookup_by_digest256(mc, d3);
- test_assert(md1);
- test_assert(md2);
- test_assert(md3);
- test_mem_op(md1->body, ==, s + md1->off, strlen(test_md1));
- test_mem_op(md2->body, ==, s + md2->off, strlen(test_md2));
- test_mem_op(md3->body, ==, s + md3->off, strlen(test_md3_noannotation));
+ tt_assert(md1);
+ tt_assert(md2);
+ tt_assert(md3);
+ tt_mem_op(md1->body, ==, s + md1->off, strlen(test_md1));
+ tt_mem_op(md2->body, ==, s + md2->off, strlen(test_md2));
+ tt_mem_op(md3->body, ==, s + md3->off, strlen(test_md3_noannotation));
tt_int_op(md1->last_listed, ==, time1);
tt_int_op(md2->last_listed, ==, time2);
@@ -367,7 +372,7 @@ test_md_generate(void *arg)
microdesc_t *md = NULL;
(void)arg;
- ri = router_parse_entry_from_string(test_ri, NULL, 0, 0, NULL);
+ ri = router_parse_entry_from_string(test_ri, NULL, 0, 0, NULL, NULL);
tt_assert(ri);
md = dirvote_create_microdescriptor(ri, 8);
tt_str_op(md->body, ==, test_md_8);
@@ -391,10 +396,330 @@ test_md_generate(void *arg)
routerinfo_free(ri);
}
+/* Taken at random from my ~/.tor/cached-microdescs file and then
+ * hand-munged */
+static const char MD_PARSE_TEST_DATA[] =
+ /* Good 0 */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANsKd1GRfOuSR1MkcwKqs6SVy4Gi/JXplt/bHDkIGm6Q96TeJ5uyVgUL\n"
+ "DBr/ij6+JqgVFeriuiMzHKREytzjdaTuKsKBFFpLwb+Ppcjr5nMIH/AR6/aHO8hW\n"
+ "T3B9lx5T6Kl7CqZ4yqXxYRHzn50EPTIZuz0y9se4J4gi9mLmL+pHAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "p accept 20-23,43,53,79-81,88,110,143,194,220,443,464,531,543-544\n"
+ "id rsa1024 GEo59/iR1GWSIWZDzXTd5QxtqnU\n"
+ /* Bad 0: I've messed with the onion-key in the second one. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMr4o/pflVwscx11vC1AKEADlKEqnhpvCIjAEzNEenMhvGQHRlA0EXLC\n"
+ "7G7O5bhnCwEHqK8Pvg8cuX/fD8v08TF1EVPhwPa0UI6ab8KnPP2F!!!!!!b92DG7EQIk3q\n"
+ "d68Uxp7E9/t3v1WWZjzDqvEe0par6ul+DKW6HMlTGebFo5Q4e8R1AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key 761Dmm27via7lXygNHM3l+oJLrYU2Nye0Uz4pkpipyY=\n"
+ "p accept 53\n"
+ "id rsa1024 3Y4fwXhtgkdGDZ5ef5mtb6TJRQQ\n"
+ /* Good 1 */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANsMSjVi3EX8ZHfm/dvPF6KdVR66k1tVul7Jp+dDbDajBYNhgKRzVCxy\n"
+ "Yac1CBuQjOqK89tKap9PQBnhF087eDrfaZDqYTLwB2W2sBJncVej15WEPXPRBifo\n"
+ "iFZ8337kgczkaY+IOfSuhtbOUyDOoDpRJheIKBNq0ZiTqtLbbadVAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key ncfiHJjSgdDEW/gc6q6/7idac7j+x7ejQrRm6i75pGA=\n"
+ "p accept 443,6660-6669,6697,7000-7001\n"
+ "id rsa1024 XXuLzw3mfBELEq3veXoNhdehwD4\n"
+ /* Good 2 */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANQfBlrHrh9F/CAOytrNFgi0ikWMW/HZxuoszF9X+AQ+MudR8bcxxOGl\n"
+ "1RFwb74s8E3uuzrCkNFvSw9Ar1L02F2DOX0gLsxEGuYC4Ave9NUteGqSqDyEJQUJ\n"
+ "KlfxCPn2qC9nvNT7wR/Dg2WRvAEKnJmkpb57N3+WSAOPLjKOFEz3AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key AppBt6CSeb1kKid/36ototmFA24ddfW5JpjWPLuoJgs=\n"
+ "id rsa1024 6y60AEI9a1PUUlRPO0YQT9WzrjI\n"
+ /* Bad 1: Here I've messed with the ntor key */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAPjy2HacU3jDNO5nTOFGSwNa0qKCNn4yhtrDVcAJ5alIQeBWZZGJLZ0q\n"
+ "Cqylw1vYqxu8E09g+QXXFbAgBv1U9TICaATxrIJhIJzc8TJPhqJemp1kq0DvHLDx\n"
+ "mxwlkNnCD/P5NS+JYB3EjOlU9EnSKUWNU61+Co344m2JqhEau40vAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key 4i2Fp9JHTUr1uQs0pxD5j5spl4/RG56S2P0gQxU=\n"
+ "id rsa1024 nMRmNEGysA0NmlALVaUmI7D5jLU\n"
+ /* Good 3: I've added a weird token in this one. This shouldn't prevent
+ * it parsing */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKmosxudyNA/yJNz3S890VqV/ebylzoD11Sc0b/d5tyNNaNZjcYy5vRD\n"
+ "kwyxFRMbP2TLZQ1zRfNwY7IDnYjU2SbW0pxuM6M8WRtsmx/YOE3kHMVAFJNrTUqU\n"
+ "6D1zB3IiRDS5q5+NoRxwqo+hYUck60O3WTwEoqb+l3lvXeu7z9rFAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "flux-capacitor 1.21 GW\n"
+ "ntor-onion-key MWBoEkl+RlBiGX44XKIvTSqbznTNZStOmUYtcYRQQyY=\n"
+ "id rsa1024 R+A5O9qRvRac4FT3C4L2QnFyxsc\n"
+ /* Good 4: Here I've made the 'id rsa' token odd. It should still parse
+ * just fine. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAOh+WMkdNe/Pkjb8UjQyfLOlFgpuVFrxAIGnJsmWWx0yBE97DQxGyh2n\n"
+ "h8G5OJZHRarJQyCIf7vpZQAi0oP0OkGGaCaDQsM+D8TnqhnU++RWGnMqY/cXxPrL\n"
+ "MEq+n6aGiLmzkO7ah8yorZpoREk4GqLUIN89/tHHGOhJL3c4CPGjAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n"
+ "id rsa1234 jlqAKFD2E7uMKv+8TmKSeo7NBho\n"
+ /* Good 5: Extra id type. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAMdgPPc5uaw4y/q+SUTN/I8Y+Gvdx9kKgWV4dmDGJ0mxsVZmo1v6+v3F\n"
+ "12M2f9m99G3WB8F8now29C+9XyEv8MBHj1lHRdUFHSQes3YTFvDNlgj+FjLqO5TJ\n"
+ "adOOmfu4DCUUtUEDyQKbNVL4EkMTXY73omTVsjcH3xxFjTx5wixhAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key AAVnWZcnDbxasdZwKqb4fL6O9sZV+XsRNHTpNd1YMz8=\n"
+ "id rsa1024 72EfBL11QuwX2vU8y+p9ExGfGEg\n"
+ "id expolding hedgehog 0+A5O9qRvRac4FT3C4L2QnFyxsc\n"
+ /* Good 6: I've given this a bogus policy. It should parse. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALNuufwhPMF8BooxYMNvhYJMPqUB8hQDt8wGmPKphJcD1sVD1i4gAZM2\n"
+ "HIo+zUBlljDrRWL5NzVzd1yxUJAiQxvXS5dRRFY3B70M7wTVpXw53xe0/BM5t1AX\n"
+ "n0MFk7Jl6XIKMlzRalZvmMvE/odtyWXkP4Nd1MyZ1QcIwrQ2iwyrAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "p condone 1-10\n"
+ "ntor-onion-key 2/nMJ+L4dd/2GpMyTYjz3zC59MvQy4MIzJZhdzKHekg=\n"
+ "id rsa1024 FHyh10glEMA6MCmBb5R9Y+X/MhQ\n"
+ /* Good 7: I've given this one another sort of odd policy. Should parse. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAKcd3FmQ8iAADghyvX8eca0ePqtJ2w1IDdUdTlf5Y/8+OMdp//sD01yC\n"
+ "YmiX45LK5ge1O3AzcakYCO6fb3pyIqvXdvm24OjyYZELQ40cmKSLjdhcSf4Fr/N9\n"
+ "uR/CkknR9cEePu1wZ5WBIGmGdXI6s7t3LB+e7XFyBYAx6wMGlnX7AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "p accept frogs-mice\n"
+ "ntor-onion-key AMxvhaQ1Qg7jBJFoyHuPRgETvLbFmJ194hExV24FuAI=\n"
+ "family $D8CFEA0D996F5D1473D2063C041B7910DB23981E\n"
+ "id rsa1024 d0VVZC/cHh1P3y4MMbfKlQHFycc\n"
+ /* Good 8: This one has the ntor-onion-key without terminating =. That's
+ * allowed. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAL438YfjrJE2SPqkkXeQwICygu8KNO54Juj6sjqk5hgsiazIWMOBgbaX\n"
+ "LIRqPNGaiSq01xSqwjwCBCfwZYT/nSdDBqj1h9aoR8rnjxZjyQ+m3rWpdDqeCDMx\n"
+ "I3NgZ5w4bNX4poRb42lrV6NmQiFdjzpqszVbv5Lpn2CSKu32CwKVAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key UKL6Dnj2KwYsFlkCvOkXVatxvOPB4MaxqwPQQgZMTwI\n"
+ "id rsa1024 FPIXc6k++JnKCtSKWUxaR6oXEKs\n"
+ /* Good 9: Another totally normal one.*/
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBANNGIKRd8PFNXkJ2JPV1ohDMFNbJwKbwybeieaQFjtU9KWedHCbr+QD4\n"
+ "B6zNY5ysguNjHNnlq2f6D09+uhnfDBON8tAz0mPQH/6JqnOXm+EiUn+8bN0E8Nke\n"
+ "/i3GEgDeaxJJMNQcpsJvmmSmKFOlYy9Fy7ejAjTGqtAnqOte7BnTAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key gUsq3e5iYgsQQvyxINtLzBpHxmIt5rtuFlEbKfI4gFk=\n"
+ "id rsa1024 jv+LdatDzsMfEW6pLBeL/5uzwCc\n"
+ /* Bad 2: RSA key has bad exponent of 3. */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGHAoGBAMMTWtvPxYnUNJ5Y7B+XENcpxzPoGstrdiUszCBS+/42xvluLJ+JDSdR\n"
+ "qJaMD6ax8vKAeLS5C6O17MNdG2VldlPRbtgl41MXsOoUqEJ+nY9e3WG9Snjp47xC\n"
+ "zmWIfeduXSavIsb3a43/MLIz/9qO0TkgAAiuQr79JlwKhLdzCqTLAgED\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key NkRB4wTUFogiVp5jYmjGORe2ffb/y5Kk8Itw8jdzMjA=\n"
+ "p reject 25,119,135-139,445,563,1214,4661-4666,6346-6429,6699,6881-6999\n"
+ "id rsa1024 fKvYjP7TAjCC1FzYee5bYAwYkoDg\n"
+ /* Bad 3: Bogus annotation */
+ "@last-listed with strange aeons\n"
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBALcRBFNCZtpd2TFJysU77/fJMFzKisRQEBOtDGtTZ2Bg4aEGosssa0Id\n"
+ "YtUagRLYle08QVGvGB+EHBI5qf6Ah2yPH7k5QiN2a3Sq+nyh85dXKPazBGBBbM+C\n"
+ "DOfDauV02CAnADNMLJEf1voY3oBVvYyIsmHxn5i1R19ZYIiR8NX5AgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "ntor-onion-key m4xcFXMWMjCvZDXq8FT3XmS0EHYseGOeu+fV+6FYDlk=\n"
+ "p accept 20-23,43,53,79-81,88,110,143,194,220,389,443,464,531,543-544\n"
+ "id rsa1024 SSbfNE9vmaiwRKH+eqNAkiKQhds\n"
+ /* Good 10: Normal, with added ipv6 address and added other address */
+ "onion-key\n"
+ "-----BEGIN RSA PUBLIC KEY-----\n"
+ "MIGJAoGBAM7uUtq5F6h63QNYIvC+4NcWaD0DjtnrOORZMkdpJhinXUOwce3cD5Dj\n"
+ "sgdN1wJpWpTQMXJ2DssfSgmOVXETP7qJuZyRprxalQhaEATMDNJA/66Ml1jSO9mZ\n"
+ "+8Xb7m/4q778lNtkSbsvMaYD2Dq6k2QQ3kMhr9z8oUtX0XA23+pfAgMBAAE=\n"
+ "-----END RSA PUBLIC KEY-----\n"
+ "a [::1:2:3:4]:9090\n"
+ "a 18.0.0.1:9999\n"
+ "ntor-onion-key k2yFqTU2vzMCQDEiE/j9UcEHxKrXMLpB3IL0or09sik=\n"
+ "id rsa1024 2A8wYpHxnkKJ92orocvIQBzeHlE\n"
+ "p6 allow 80\n"
+ ;
+
+/** More tests for parsing different kinds of microdescriptors, and getting
+ * invalid digests trackd from them. */
+static void
+test_md_parse(void *arg)
+{
+ (void) arg;
+ char *mem_op_hex_tmp = NULL;
+ smartlist_t *invalid = smartlist_new();
+
+ smartlist_t *mds = microdescs_parse_from_string(MD_PARSE_TEST_DATA,
+ NULL, 1, SAVED_NOWHERE,
+ invalid);
+ tt_int_op(smartlist_len(mds), ==, 11);
+ tt_int_op(smartlist_len(invalid), ==, 4);
+
+ test_memeq_hex(smartlist_get(invalid,0),
+ "5d76bf1c6614e885614a1e0ad074e1ab"
+ "4ea14655ebeefb1736a71b5ed8a15a51");
+ test_memeq_hex(smartlist_get(invalid,1),
+ "2fde0ee3343669c2444cd9d53cbd39c6"
+ "a7d1fc0513513e840ca7f6e68864b36c");
+ test_memeq_hex(smartlist_get(invalid,2),
+ "20d1576c5ab11bbcff0dedb1db4a3cfc"
+ "c8bc8dd839d8cbfef92d00a1a7d7b294");
+ test_memeq_hex(smartlist_get(invalid,3),
+ "074770f394c73dbde7b44412e9692add"
+ "691a478d4727f9804b77646c95420a96");
+
+ /* Spot-check the valid ones. */
+ const microdesc_t *md = smartlist_get(mds, 5);
+ test_memeq_hex(md->digest,
+ "54bb6d733ddeb375d2456c79ae103961"
+ "da0cae29620375ac4cf13d54da4d92b3");
+ tt_int_op(md->last_listed, ==, 0);
+ tt_int_op(md->saved_location, ==, SAVED_NOWHERE);
+ tt_int_op(md->no_save, ==, 0);
+ tt_uint_op(md->held_in_map, ==, 0);
+ tt_uint_op(md->held_by_nodes, ==, 0);
+ tt_assert(md->onion_curve25519_pkey);
+
+ md = smartlist_get(mds, 6);
+ test_memeq_hex(md->digest,
+ "53f740bd222ab37f19f604b1d3759aa6"
+ "5eff1fbce9ac254bd0fa50d4af9b1bae");
+ tt_assert(! md->exit_policy);
+
+ md = smartlist_get(mds, 8);
+ test_memeq_hex(md->digest,
+ "a0a155562d8093d8fd0feb7b93b7226e"
+ "17f056c2142aab7a4ea8c5867a0376d5");
+ tt_assert(md->onion_curve25519_pkey);
+
+ md = smartlist_get(mds, 10);
+ test_memeq_hex(md->digest,
+ "409ebd87d23925a2732bd467a92813c9"
+ "21ca378fcb9ca193d354c51550b6d5e9");
+ tt_assert(tor_addr_family(&md->ipv6_addr) == AF_INET6);
+ tt_int_op(md->ipv6_orport, ==, 9090);
+
+ done:
+ SMARTLIST_FOREACH(mds, microdesc_t *, md, microdesc_free(md));
+ smartlist_free(mds);
+ SMARTLIST_FOREACH(invalid, char *, cp, tor_free(cp));
+ smartlist_free(invalid);
+ tor_free(mem_op_hex_tmp);
+}
+
+static int mock_rgsbd_called = 0;
+static routerstatus_t *mock_rgsbd_val_a = NULL;
+static routerstatus_t *mock_rgsbd_val_b = NULL;
+static routerstatus_t *
+mock_router_get_status_by_digest(networkstatus_t *c, const char *d)
+{
+ (void) c;
+ ++mock_rgsbd_called;
+
+ if (fast_memeq(d, "\x5d\x76", 2)) {
+ memcpy(mock_rgsbd_val_a->descriptor_digest, d, 32);
+ return mock_rgsbd_val_a;
+ } else if (fast_memeq(d, "\x20\xd1", 2)) {
+ memcpy(mock_rgsbd_val_b->descriptor_digest, d, 32);
+ return mock_rgsbd_val_b;
+ } else {
+ return NULL;
+ }
+}
+
+static networkstatus_t *mock_ns_val = NULL;
+static networkstatus_t *
+mock_ns_get_by_flavor(consensus_flavor_t f)
+{
+ (void)f;
+ return mock_ns_val;
+}
+
+static void
+test_md_reject_cache(void *arg)
+{
+ (void) arg;
+ microdesc_cache_t *mc = NULL ;
+ smartlist_t *added = NULL, *wanted = smartlist_new();
+ or_options_t *options = get_options_mutable();
+ char buf[DIGEST256_LEN];
+
+ tor_free(options->DataDirectory);
+ options->DataDirectory = tor_strdup(get_fname("md_datadir_test_rej"));
+ mock_rgsbd_val_a = tor_malloc_zero(sizeof(routerstatus_t));
+ mock_rgsbd_val_b = tor_malloc_zero(sizeof(routerstatus_t));
+ mock_ns_val = tor_malloc_zero(sizeof(networkstatus_t));
+
+ mock_ns_val->valid_after = time(NULL) - 86400;
+ mock_ns_val->valid_until = time(NULL) + 86400;
+ mock_ns_val->flavor = FLAV_MICRODESC;
+
+#ifdef _WIN32
+ tt_int_op(0, ==, mkdir(options->DataDirectory));
+#else
+ tt_int_op(0, ==, mkdir(options->DataDirectory, 0700));
+#endif
+
+ MOCK(router_get_mutable_consensus_status_by_descriptor_digest,
+ mock_router_get_status_by_digest);
+ MOCK(networkstatus_get_latest_consensus_by_flavor, mock_ns_get_by_flavor);
+
+ mc = get_microdesc_cache();
+#define ADD(hex) \
+ do { \
+ tt_int_op(0,==,base16_decode(buf,sizeof(buf),hex,strlen(hex))); \
+ smartlist_add(wanted, tor_memdup(buf, DIGEST256_LEN)); \
+ } while (0)
+
+ /* invalid,0 */
+ ADD("5d76bf1c6614e885614a1e0ad074e1ab4ea14655ebeefb1736a71b5ed8a15a51");
+ /* invalid,2 */
+ ADD("20d1576c5ab11bbcff0dedb1db4a3cfcc8bc8dd839d8cbfef92d00a1a7d7b294");
+ /* valid, 6 */
+ ADD("53f740bd222ab37f19f604b1d3759aa65eff1fbce9ac254bd0fa50d4af9b1bae");
+ /* valid, 8 */
+ ADD("a0a155562d8093d8fd0feb7b93b7226e17f056c2142aab7a4ea8c5867a0376d5");
+
+ added = microdescs_add_to_cache(mc, MD_PARSE_TEST_DATA, NULL,
+ SAVED_NOWHERE, 0, time(NULL), wanted);
+
+ tt_int_op(smartlist_len(added), ==, 2);
+ tt_int_op(mock_rgsbd_called, ==, 2);
+ tt_int_op(mock_rgsbd_val_a->dl_status.n_download_failures, ==, 255);
+ tt_int_op(mock_rgsbd_val_b->dl_status.n_download_failures, ==, 255);
+
+ done:
+ UNMOCK(networkstatus_get_latest_consensus_by_flavor);
+ UNMOCK(router_get_mutable_consensus_status_by_descriptor_digest);
+ if (options)
+ tor_free(options->DataDirectory);
+ microdesc_free_all();
+ smartlist_free(added);
+ SMARTLIST_FOREACH(wanted, char *, cp, tor_free(cp));
+ smartlist_free(wanted);
+ tor_free(mock_rgsbd_val_a);
+ tor_free(mock_rgsbd_val_b);
+ tor_free(mock_ns_val);
+}
+
struct testcase_t microdesc_tests[] = {
{ "cache", test_md_cache, TT_FORK, NULL, NULL },
{ "broken_cache", test_md_cache_broken, TT_FORK, NULL, NULL },
{ "generate", test_md_generate, 0, NULL, NULL },
+ { "parse", test_md_parse, 0, NULL, NULL },
+ { "reject_cache", test_md_reject_cache, TT_FORK, NULL, NULL },
END_OF_TESTCASES
};
diff --git a/src/test/test_nodelist.c b/src/test/test_nodelist.c
index 600e6a89d4..7c94084a02 100644
--- a/src/test/test_nodelist.c
+++ b/src/test/test_nodelist.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
@@ -23,9 +23,9 @@ test_nodelist_node_get_verbose_nickname_by_id_null_node(void *arg)
(void) arg;
/* make sure node_get_by_id returns NULL */
- test_assert(!node_get_by_id(ID));
+ tt_assert(!node_get_by_id(ID));
node_get_verbose_nickname_by_id(ID, vname);
- test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
+ tt_str_op(vname,==, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
done:
return;
}
@@ -54,7 +54,7 @@ test_nodelist_node_get_verbose_nickname_not_named(void *arg)
"\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA",
DIGEST_LEN);
node_get_verbose_nickname(&mock_node, vname);
- test_streq(vname, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~TestOR");
+ tt_str_op(vname,==, "$AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA~TestOR");
done:
return;
diff --git a/src/test/test_ntor_cl.c b/src/test/test_ntor_cl.c
index f2b7a72ad5..2899ad6710 100644
--- a/src/test/test_ntor_cl.c
+++ b/src/test/test_ntor_cl.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -13,10 +13,6 @@
#include "crypto_curve25519.h"
#include "onion_ntor.h"
-#ifndef CURVE25519_ENABLED
-#error "This isn't going to work without curve25519."
-#endif
-
#define N_ARGS(n) STMT_BEGIN { \
if (argc < (n)) { \
fprintf(stderr, "%s needs %d arguments.\n",argv[1],n); \
diff --git a/src/test/test_options.c b/src/test/test_options.c
index 737f658e2c..57ab38c027 100644
--- a/src/test/test_options.c
+++ b/src/test/test_options.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define CONFIG_PRIVATE
diff --git a/src/test/test_policy.c b/src/test/test_policy.c
index 4cdcd034bb..c043ac6e3a 100644
--- a/src/test/test_policy.c
+++ b/src/test/test_policy.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, The Tor Project, Inc. */
+/* Copyright (c) 2013-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -47,17 +47,20 @@ test_policy_summary_helper(const char *policy_str,
line.value = (char *)policy_str;
line.next = NULL;
- r = policies_parse_exit_policy(&line, &policy, 1, 0, 0, 1);
- test_eq(r, 0);
+ r = policies_parse_exit_policy(&line, &policy,
+ EXIT_POLICY_IPV6_ENABLED |
+ EXIT_POLICY_ADD_DEFAULT ,0);
+ tt_int_op(r,==, 0);
+
summary = policy_summarize(policy, AF_INET);
- test_assert(summary != NULL);
- test_streq(summary, expected_summary);
+ tt_assert(summary != NULL);
+ tt_str_op(summary,==, expected_summary);
short_policy = parse_short_policy(summary);
tt_assert(short_policy);
summary_after = write_short_policy(short_policy);
- test_streq(summary, summary_after);
+ tt_str_op(summary,==, summary_after);
done:
tor_free(summary_after);
@@ -86,104 +89,108 @@ test_policies_general(void *arg)
policy = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*",-1);
- test_assert(p != NULL);
- test_eq(ADDR_POLICY_REJECT, p->policy_type);
+ tt_assert(p != NULL);
+ tt_int_op(ADDR_POLICY_REJECT,==, p->policy_type);
tor_addr_from_ipv4h(&tar, 0xc0a80000u);
- test_eq(0, tor_addr_compare(&p->addr, &tar, CMP_EXACT));
- test_eq(16, p->maskbits);
- test_eq(1, p->prt_min);
- test_eq(65535, p->prt_max);
+ tt_int_op(0,==, tor_addr_compare(&p->addr, &tar, CMP_EXACT));
+ tt_int_op(16,==, p->maskbits);
+ tt_int_op(1,==, p->prt_min);
+ tt_int_op(65535,==, p->prt_max);
smartlist_add(policy, p);
tor_addr_from_ipv4h(&tar, 0x01020304u);
- test_assert(ADDR_POLICY_ACCEPTED ==
+ tt_assert(ADDR_POLICY_ACCEPTED ==
compare_tor_addr_to_addr_policy(&tar, 2, policy));
tor_addr_make_unspec(&tar);
- test_assert(ADDR_POLICY_PROBABLY_ACCEPTED ==
+ tt_assert(ADDR_POLICY_PROBABLY_ACCEPTED ==
compare_tor_addr_to_addr_policy(&tar, 2, policy));
tor_addr_from_ipv4h(&tar, 0xc0a80102);
- test_assert(ADDR_POLICY_REJECTED ==
+ tt_assert(ADDR_POLICY_REJECTED ==
compare_tor_addr_to_addr_policy(&tar, 2, policy));
- test_assert(0 == policies_parse_exit_policy(NULL, &policy2, 1, 1, 0, 1));
- test_assert(policy2);
+ tt_int_op(0, ==, policies_parse_exit_policy(NULL, &policy2,
+ EXIT_POLICY_IPV6_ENABLED |
+ EXIT_POLICY_REJECT_PRIVATE |
+ EXIT_POLICY_ADD_DEFAULT, 0));
+
+ tt_assert(policy2);
policy3 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject *:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy3, p);
p = router_parse_addr_policy_item_from_string("accept *:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy3, p);
policy4 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept *:443",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy4, p);
p = router_parse_addr_policy_item_from_string("accept *:443",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy4, p);
policy5 = smartlist_new();
p = router_parse_addr_policy_item_from_string("reject 0.0.0.0/8:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 169.254.0.0/16:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 127.0.0.0/8:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 192.168.0.0/16:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 10.0.0.0/8:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 172.16.0.0/12:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject 80.190.250.90:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject *:1-65534",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("reject *:65535",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
p = router_parse_addr_policy_item_from_string("accept *:1-65535",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy5, p);
policy6 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 43.3.0.0/9:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy6, p);
policy7 = smartlist_new();
p = router_parse_addr_policy_item_from_string("accept 0.0.0.0/8:*",-1);
- test_assert(p != NULL);
+ tt_assert(p != NULL);
smartlist_add(policy7, p);
- test_assert(!exit_policy_is_general_exit(policy));
- test_assert(exit_policy_is_general_exit(policy2));
- test_assert(!exit_policy_is_general_exit(NULL));
- test_assert(!exit_policy_is_general_exit(policy3));
- test_assert(!exit_policy_is_general_exit(policy4));
- test_assert(!exit_policy_is_general_exit(policy5));
- test_assert(!exit_policy_is_general_exit(policy6));
- test_assert(!exit_policy_is_general_exit(policy7));
+ tt_assert(!exit_policy_is_general_exit(policy));
+ tt_assert(exit_policy_is_general_exit(policy2));
+ tt_assert(!exit_policy_is_general_exit(NULL));
+ tt_assert(!exit_policy_is_general_exit(policy3));
+ tt_assert(!exit_policy_is_general_exit(policy4));
+ tt_assert(!exit_policy_is_general_exit(policy5));
+ tt_assert(!exit_policy_is_general_exit(policy6));
+ tt_assert(!exit_policy_is_general_exit(policy7));
- test_assert(cmp_addr_policies(policy, policy2));
- test_assert(cmp_addr_policies(policy, NULL));
- test_assert(!cmp_addr_policies(policy2, policy2));
- test_assert(!cmp_addr_policies(NULL, NULL));
+ tt_assert(cmp_addr_policies(policy, policy2));
+ tt_assert(cmp_addr_policies(policy, NULL));
+ tt_assert(!cmp_addr_policies(policy2, policy2));
+ tt_assert(!cmp_addr_policies(NULL, NULL));
- test_assert(!policy_is_reject_star(policy2, AF_INET));
- test_assert(policy_is_reject_star(policy, AF_INET));
- test_assert(policy_is_reject_star(NULL, AF_INET));
+ tt_assert(!policy_is_reject_star(policy2, AF_INET));
+ tt_assert(policy_is_reject_star(policy, AF_INET));
+ tt_assert(policy_is_reject_star(NULL, AF_INET));
addr_policy_list_free(policy);
policy = NULL;
@@ -193,11 +200,14 @@ test_policies_general(void *arg)
line.key = (char*)"foo";
line.value = (char*)"accept *:80,reject private:*,reject *:*";
line.next = NULL;
- test_assert(0 == policies_parse_exit_policy(&line, &policy, 1, 0, 0, 1));
- test_assert(policy);
+ tt_int_op(0, ==, policies_parse_exit_policy(&line,&policy,
+ EXIT_POLICY_IPV6_ENABLED |
+ EXIT_POLICY_ADD_DEFAULT,0));
+ tt_assert(policy);
+
//test_streq(policy->string, "accept *:80");
//test_streq(policy->next->string, "reject *:*");
- test_eq(smartlist_len(policy), 4);
+ tt_int_op(smartlist_len(policy),==, 4);
/* test policy summaries */
/* check if we properly ignore private IP addresses */
@@ -359,7 +369,7 @@ test_dump_exit_policy_to_string(void *arg)
ri->exit_policy = NULL; // expecting "reject *:*"
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("reject *:*",ep);
+ tt_str_op("reject *:*",==, ep);
tor_free(ep);
@@ -372,7 +382,7 @@ test_dump_exit_policy_to_string(void *arg)
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("accept *:*",ep);
+ tt_str_op("accept *:*",==, ep);
tor_free(ep);
@@ -382,7 +392,7 @@ test_dump_exit_policy_to_string(void *arg)
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("accept *:*\nreject *:25",ep);
+ tt_str_op("accept *:*\nreject *:25",==, ep);
tor_free(ep);
@@ -393,7 +403,7 @@ test_dump_exit_policy_to_string(void *arg)
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("accept *:*\nreject *:25\nreject 8.8.8.8:*",ep);
+ tt_str_op("accept *:*\nreject *:25\nreject 8.8.8.8:*",==, ep);
tor_free(ep);
policy_entry =
@@ -403,8 +413,8 @@ test_dump_exit_policy_to_string(void *arg)
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("accept *:*\nreject *:25\nreject 8.8.8.8:*\n"
- "reject6 [fc00::]/7:*",ep);
+ tt_str_op("accept *:*\nreject *:25\nreject 8.8.8.8:*\n"
+ "reject6 [fc00::]/7:*",==, ep);
tor_free(ep);
policy_entry =
@@ -414,8 +424,8 @@ test_dump_exit_policy_to_string(void *arg)
ep = router_dump_exit_policy_to_string(ri,1,1);
- test_streq("accept *:*\nreject *:25\nreject 8.8.8.8:*\n"
- "reject6 [fc00::]/7:*\naccept6 [c000::]/3:*",ep);
+ tt_str_op("accept *:*\nreject *:25\nreject 8.8.8.8:*\n"
+ "reject6 [fc00::]/7:*\naccept6 [c000::]/3:*",==, ep);
done:
diff --git a/src/test/test_pt.c b/src/test/test_pt.c
index f71627df1e..1be52ee5bd 100644
--- a/src/test/test_pt.c
+++ b/src/test/test_pt.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -27,75 +27,76 @@ reset_mp(managed_proxy_t *mp)
}
static void
-test_pt_parsing(void)
+test_pt_parsing(void *arg)
{
char line[200];
transport_t *transport = NULL;
tor_addr_t test_addr;
- managed_proxy_t *mp = tor_malloc(sizeof(managed_proxy_t));
+ managed_proxy_t *mp = tor_malloc_zero(sizeof(managed_proxy_t));
+ (void)arg;
mp->conf_state = PT_PROTO_INFANT;
mp->transports = smartlist_new();
/* incomplete cmethod */
strlcpy(line,"CMETHOD trebuchet",sizeof(line));
- test_assert(parse_cmethod_line(line, mp) < 0);
+ tt_assert(parse_cmethod_line(line, mp) < 0);
reset_mp(mp);
/* wrong proxy type */
strlcpy(line,"CMETHOD trebuchet dog 127.0.0.1:1999",sizeof(line));
- test_assert(parse_cmethod_line(line, mp) < 0);
+ tt_assert(parse_cmethod_line(line, mp) < 0);
reset_mp(mp);
/* wrong addrport */
strlcpy(line,"CMETHOD trebuchet socks4 abcd",sizeof(line));
- test_assert(parse_cmethod_line(line, mp) < 0);
+ tt_assert(parse_cmethod_line(line, mp) < 0);
reset_mp(mp);
/* correct line */
strlcpy(line,"CMETHOD trebuchet socks5 127.0.0.1:1999",sizeof(line));
- test_assert(parse_cmethod_line(line, mp) == 0);
- test_assert(smartlist_len(mp->transports) == 1);
+ tt_assert(parse_cmethod_line(line, mp) == 0);
+ tt_assert(smartlist_len(mp->transports) == 1);
transport = smartlist_get(mp->transports, 0);
/* test registered address of transport */
tor_addr_parse(&test_addr, "127.0.0.1");
- test_assert(tor_addr_eq(&test_addr, &transport->addr));
+ tt_assert(tor_addr_eq(&test_addr, &transport->addr));
/* test registered port of transport */
- test_assert(transport->port == 1999);
+ tt_assert(transport->port == 1999);
/* test registered SOCKS version of transport */
- test_assert(transport->socks_version == PROXY_SOCKS5);
+ tt_assert(transport->socks_version == PROXY_SOCKS5);
/* test registered name of transport */
- test_streq(transport->name, "trebuchet");
+ tt_str_op(transport->name,==, "trebuchet");
reset_mp(mp);
/* incomplete smethod */
strlcpy(line,"SMETHOD trebuchet",sizeof(line));
- test_assert(parse_smethod_line(line, mp) < 0);
+ tt_assert(parse_smethod_line(line, mp) < 0);
reset_mp(mp);
/* wrong addr type */
strlcpy(line,"SMETHOD trebuchet abcd",sizeof(line));
- test_assert(parse_smethod_line(line, mp) < 0);
+ tt_assert(parse_smethod_line(line, mp) < 0);
reset_mp(mp);
/* cowwect */
strlcpy(line,"SMETHOD trebuchy 127.0.0.2:2999",sizeof(line));
- test_assert(parse_smethod_line(line, mp) == 0);
- test_assert(smartlist_len(mp->transports) == 1);
+ tt_assert(parse_smethod_line(line, mp) == 0);
+ tt_assert(smartlist_len(mp->transports) == 1);
transport = smartlist_get(mp->transports, 0);
/* test registered address of transport */
tor_addr_parse(&test_addr, "127.0.0.2");
- test_assert(tor_addr_eq(&test_addr, &transport->addr));
+ tt_assert(tor_addr_eq(&test_addr, &transport->addr));
/* test registered port of transport */
- test_assert(transport->port == 2999);
+ tt_assert(transport->port == 2999);
/* test registered name of transport */
- test_streq(transport->name, "trebuchy");
+ tt_str_op(transport->name,==, "trebuchy");
reset_mp(mp);
@@ -103,7 +104,7 @@ test_pt_parsing(void)
strlcpy(line,"SMETHOD trebuchet 127.0.0.1:9999 "
"ARGS:counterweight=3,sling=snappy",
sizeof(line));
- test_assert(parse_smethod_line(line, mp) == 0);
+ tt_assert(parse_smethod_line(line, mp) == 0);
tt_int_op(1, ==, smartlist_len(mp->transports));
{
const transport_t *transport = smartlist_get(mp->transports, 0);
@@ -118,15 +119,15 @@ test_pt_parsing(void)
/* unsupported version */
strlcpy(line,"VERSION 666",sizeof(line));
- test_assert(parse_version(line, mp) < 0);
+ tt_assert(parse_version(line, mp) < 0);
/* incomplete VERSION */
strlcpy(line,"VERSION ",sizeof(line));
- test_assert(parse_version(line, mp) < 0);
+ tt_assert(parse_version(line, mp) < 0);
/* correct VERSION */
strlcpy(line,"VERSION 1",sizeof(line));
- test_assert(parse_version(line, mp) == 0);
+ tt_assert(parse_version(line, mp) == 0);
done:
reset_mp(mp);
@@ -187,46 +188,47 @@ test_pt_get_transport_options(void *arg)
}
static void
-test_pt_protocol(void)
+test_pt_protocol(void *arg)
{
char line[200];
managed_proxy_t *mp = tor_malloc_zero(sizeof(managed_proxy_t));
+ (void)arg;
mp->conf_state = PT_PROTO_LAUNCHED;
mp->transports = smartlist_new();
- mp->argv = tor_malloc_zero(sizeof(char*)*2);
+ mp->argv = tor_calloc(2, sizeof(char *));
mp->argv[0] = tor_strdup("<testcase>");
/* various wrong protocol runs: */
strlcpy(line,"VERSION 1",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
+ tt_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
strlcpy(line,"VERSION 1",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_BROKEN);
+ tt_assert(mp->conf_state == PT_PROTO_BROKEN);
reset_mp(mp);
strlcpy(line,"CMETHOD trebuchet socks5 127.0.0.1:1999",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_BROKEN);
+ tt_assert(mp->conf_state == PT_PROTO_BROKEN);
reset_mp(mp);
/* correct protocol run: */
strlcpy(line,"VERSION 1",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
+ tt_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
strlcpy(line,"CMETHOD trebuchet socks5 127.0.0.1:1999",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
+ tt_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
strlcpy(line,"CMETHODS DONE",sizeof(line));
handle_proxy_line(line, mp);
- test_assert(mp->conf_state == PT_PROTO_CONFIGURED);
+ tt_assert(mp->conf_state == PT_PROTO_CONFIGURED);
done:
reset_mp(mp);
@@ -363,7 +365,7 @@ test_pt_configure_proxy(void *arg)
control_testing_set_global_event_mask(EVENT_TRANSPORT_LAUNCHED);
- mp = tor_malloc(sizeof(managed_proxy_t));
+ mp = tor_malloc_zero(sizeof(managed_proxy_t));
mp->conf_state = PT_PROTO_ACCEPTING_METHODS;
mp->transports = smartlist_new();
mp->transports_to_launch = smartlist_new();
@@ -378,19 +380,19 @@ test_pt_configure_proxy(void *arg)
for (i = 0 ; i < 5 ; i++) {
retval = configure_proxy(mp);
/* retval should be zero because proxy hasn't finished configuring yet */
- test_assert(retval == 0);
+ tt_int_op(retval, ==, 0);
/* check the number of registered transports */
- test_assert(smartlist_len(mp->transports) == i+1);
+ tt_assert(smartlist_len(mp->transports) == i+1);
/* check that the mp is still waiting for transports */
- test_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
+ tt_assert(mp->conf_state == PT_PROTO_ACCEPTING_METHODS);
}
/* this last configure_proxy() should finalize the proxy configuration. */
retval = configure_proxy(mp);
/* retval should be 1 since the proxy finished configuring */
- test_assert(retval == 1);
+ tt_int_op(retval, ==, 1);
/* check the mp state */
- test_assert(mp->conf_state == PT_PROTO_COMPLETED);
+ tt_assert(mp->conf_state == PT_PROTO_COMPLETED);
tt_int_op(controlevent_n, ==, 5);
tt_int_op(controlevent_event, ==, EVENT_TRANSPORT_LAUNCHED);
@@ -416,7 +418,7 @@ test_pt_configure_proxy(void *arg)
/* Get the bindaddr for "mock1" and check it against the bindaddr
that the mocked tor_get_lines_from_handle() generated. */
transport_in_state = get_transport_in_state_by_name("mock1");
- test_assert(transport_in_state);
+ tt_assert(transport_in_state);
smartlist_split_string(transport_info_sl, transport_in_state->value,
NULL, 0, 0);
name_of_transport = smartlist_get(transport_info_sl, 0);
@@ -450,8 +452,86 @@ test_pt_configure_proxy(void *arg)
tor_free(mp);
}
+/* Test the get_pt_proxy_uri() function. */
+static void
+test_get_pt_proxy_uri(void *arg)
+{
+ or_options_t *options = get_options_mutable();
+ char *uri = NULL;
+ int ret;
+ (void) arg;
+
+ /* Test with no proxy. */
+ uri = get_pt_proxy_uri();
+ tt_assert(uri == NULL);
+
+ /* Test with a SOCKS4 proxy. */
+ options->Socks4Proxy = tor_strdup("192.0.2.1:1080");
+ ret = tor_addr_port_lookup(options->Socks4Proxy,
+ &options->Socks4ProxyAddr,
+ &options->Socks4ProxyPort);
+ tt_int_op(ret, ==, 0);
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "socks4a://192.0.2.1:1080");
+ tor_free(uri);
+ tor_free(options->Socks4Proxy);
+
+ /* Test with a SOCKS5 proxy, no username/password. */
+ options->Socks5Proxy = tor_strdup("192.0.2.1:1080");
+ ret = tor_addr_port_lookup(options->Socks5Proxy,
+ &options->Socks5ProxyAddr,
+ &options->Socks5ProxyPort);
+ tt_int_op(ret, ==, 0);
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "socks5://192.0.2.1:1080");
+ tor_free(uri);
+
+ /* Test with a SOCKS5 proxy, with username/password. */
+ options->Socks5ProxyUsername = tor_strdup("hwest");
+ options->Socks5ProxyPassword = tor_strdup("r34n1m470r");
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "socks5://hwest:r34n1m470r@192.0.2.1:1080");
+ tor_free(uri);
+ tor_free(options->Socks5Proxy);
+ tor_free(options->Socks5ProxyUsername);
+ tor_free(options->Socks5ProxyPassword);
+
+ /* Test with a HTTPS proxy, no authenticator. */
+ options->HTTPSProxy = tor_strdup("192.0.2.1:80");
+ ret = tor_addr_port_lookup(options->HTTPSProxy,
+ &options->HTTPSProxyAddr,
+ &options->HTTPSProxyPort);
+ tt_int_op(ret, ==, 0);
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "http://192.0.2.1:80");
+ tor_free(uri);
+
+ /* Test with a HTTPS proxy, with authenticator. */
+ options->HTTPSProxyAuthenticator = tor_strdup("hwest:r34n1m470r");
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "http://hwest:r34n1m470r@192.0.2.1:80");
+ tor_free(uri);
+ tor_free(options->HTTPSProxy);
+ tor_free(options->HTTPSProxyAuthenticator);
+
+ /* Token nod to the fact that IPv6 exists. */
+ options->Socks4Proxy = tor_strdup("[2001:db8::1]:1080");
+ ret = tor_addr_port_lookup(options->Socks4Proxy,
+ &options->Socks4ProxyAddr,
+ &options->Socks4ProxyPort);
+ tt_int_op(ret, ==, 0);
+ uri = get_pt_proxy_uri();
+ tt_str_op(uri, ==, "socks4a://[2001:db8::1]:1080");
+ tor_free(uri);
+ tor_free(options->Socks4Proxy);
+
+ done:
+ if (uri)
+ tor_free(uri);
+}
+
#define PT_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_pt_ ## name }
+ { #name, test_pt_ ## name , 0, NULL, NULL }
struct testcase_t pt_tests[] = {
PT_LEGACY(parsing),
@@ -462,6 +542,8 @@ struct testcase_t pt_tests[] = {
NULL, NULL },
{ "configure_proxy",test_pt_configure_proxy, TT_FORK,
NULL, NULL },
+ { "get_pt_proxy_uri", test_get_pt_proxy_uri, TT_FORK,
+ NULL, NULL },
END_OF_TESTCASES
};
diff --git a/src/test/test_replay.c b/src/test/test_replay.c
index b48f582f5e..bb8017d261 100644
--- a/src/test/test_replay.c
+++ b/src/test/test_replay.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2012-2013, The Tor Project, Inc. */
+/* Copyright (c) 2012-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#define REPLAYCACHE_PRIVATE
@@ -18,12 +18,13 @@ static const char *test_buffer =
" mollit anim id est laborum.";
static void
-test_replaycache_alloc(void)
+test_replaycache_alloc(void *arg)
{
replaycache_t *r = NULL;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
done:
if (r) replaycache_free(r);
@@ -32,21 +33,22 @@ test_replaycache_alloc(void)
}
static void
-test_replaycache_badalloc(void)
+test_replaycache_badalloc(void *arg)
{
replaycache_t *r = NULL;
/* Negative horizon should fail */
+ (void)arg;
r = replaycache_new(-600, 300);
- test_assert(r == NULL);
+ tt_assert(r == NULL);
/* Negative interval should get adjusted to zero */
r = replaycache_new(600, -300);
- test_assert(r != NULL);
- test_eq(r->scrub_interval, 0);
+ tt_assert(r != NULL);
+ tt_int_op(r->scrub_interval,==, 0);
replaycache_free(r);
/* Negative horizon and negative interval should still fail */
r = replaycache_new(-600, -300);
- test_assert(r == NULL);
+ tt_assert(r == NULL);
done:
if (r) replaycache_free(r);
@@ -55,35 +57,37 @@ test_replaycache_badalloc(void)
}
static void
-test_replaycache_free_null(void)
+test_replaycache_free_null(void *arg)
{
+ (void)arg;
replaycache_free(NULL);
/* Assert that we're here without horrible death */
- test_assert(1);
+ tt_assert(1);
done:
return;
}
static void
-test_replaycache_miss(void)
+test_replaycache_miss(void *arg)
{
replaycache_t *r = NULL;
int result;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
/* poke the bad-parameter error case too */
result =
replaycache_add_and_test_internal(1200, NULL, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
done:
if (r) replaycache_free(r);
@@ -92,23 +96,24 @@ test_replaycache_miss(void)
}
static void
-test_replaycache_hit(void)
+test_replaycache_hit(void *arg)
{
replaycache_t *r = NULL;
int result;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
result =
replaycache_add_and_test_internal(1300, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
done:
if (r) replaycache_free(r);
@@ -117,28 +122,29 @@ test_replaycache_hit(void)
}
static void
-test_replaycache_age(void)
+test_replaycache_age(void *arg)
{
replaycache_t *r = NULL;
int result;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
result =
replaycache_add_and_test_internal(1300, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
result =
replaycache_add_and_test_internal(3000, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
done:
if (r) replaycache_free(r);
@@ -147,25 +153,26 @@ test_replaycache_age(void)
}
static void
-test_replaycache_elapsed(void)
+test_replaycache_elapsed(void *arg)
{
replaycache_t *r = NULL;
int result;
time_t elapsed;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
result =
replaycache_add_and_test_internal(1300, r, test_buffer,
strlen(test_buffer), &elapsed);
- test_eq(result, 1);
- test_eq(elapsed, 100);
+ tt_int_op(result,==, 1);
+ tt_int_op(elapsed,==, 100);
done:
if (r) replaycache_free(r);
@@ -174,28 +181,29 @@ test_replaycache_elapsed(void)
}
static void
-test_replaycache_noexpire(void)
+test_replaycache_noexpire(void *arg)
{
replaycache_t *r = NULL;
int result;
+ (void)arg;
r = replaycache_new(0, 0);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
result =
replaycache_add_and_test_internal(1300, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
result =
replaycache_add_and_test_internal(3000, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
done:
if (r) replaycache_free(r);
@@ -204,24 +212,25 @@ test_replaycache_noexpire(void)
}
static void
-test_replaycache_scrub(void)
+test_replaycache_scrub(void *arg)
{
replaycache_t *r = NULL;
int result;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
/* Set up like in test_replaycache_hit() */
result =
replaycache_add_and_test_internal(100, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
result =
replaycache_add_and_test_internal(200, r, test_buffer,
strlen(test_buffer), NULL);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
/*
* Poke a few replaycache_scrub_if_needed_internal() error cases that
@@ -231,12 +240,12 @@ test_replaycache_scrub(void)
/* Null cache */
replaycache_scrub_if_needed_internal(300, NULL);
/* Assert we're still here */
- test_assert(1);
+ tt_assert(1);
/* Make sure we hit the aging-out case too */
replaycache_scrub_if_needed_internal(1500, r);
/* Assert that we aged it */
- test_eq(digestmap_size(r->digests_seen), 0);
+ tt_int_op(digestmap_size(r->digests_seen),==, 0);
done:
if (r) replaycache_free(r);
@@ -245,29 +254,30 @@ test_replaycache_scrub(void)
}
static void
-test_replaycache_future(void)
+test_replaycache_future(void *arg)
{
replaycache_t *r = NULL;
int result;
time_t elapsed = 0;
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
/* Set up like in test_replaycache_hit() */
result =
replaycache_add_and_test_internal(100, r, test_buffer,
strlen(test_buffer), &elapsed);
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
/* elapsed should still be 0, since it wasn't written */
- test_eq(elapsed, 0);
+ tt_int_op(elapsed,==, 0);
result =
replaycache_add_and_test_internal(200, r, test_buffer,
strlen(test_buffer), &elapsed);
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
/* elapsed should be the time since the last hit */
- test_eq(elapsed, 100);
+ tt_int_op(elapsed,==, 100);
/*
* Now let's turn the clock back to get coverage on the cache entry from the
@@ -277,9 +287,9 @@ test_replaycache_future(void)
replaycache_add_and_test_internal(150, r, test_buffer,
strlen(test_buffer), &elapsed);
/* We should still get a hit */
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
/* ...but it shouldn't let us see a negative elapsed time */
- test_eq(elapsed, 0);
+ tt_int_op(elapsed,==, 0);
done:
if (r) replaycache_free(r);
@@ -288,7 +298,7 @@ test_replaycache_future(void)
}
static void
-test_replaycache_realtime(void)
+test_replaycache_realtime(void *arg)
{
replaycache_t *r = NULL;
/*
@@ -299,26 +309,27 @@ test_replaycache_realtime(void)
int result;
/* Test the realtime as well as *_internal() entry points */
+ (void)arg;
r = replaycache_new(600, 300);
- test_assert(r != NULL);
+ tt_assert(r != NULL);
/* This should miss */
result =
replaycache_add_and_test(r, test_buffer, strlen(test_buffer));
- test_eq(result, 0);
+ tt_int_op(result,==, 0);
/* This should hit */
result =
replaycache_add_and_test(r, test_buffer, strlen(test_buffer));
- test_eq(result, 1);
+ tt_int_op(result,==, 1);
/* This should hit and return a small elapsed time */
result =
replaycache_add_test_and_elapsed(r, test_buffer,
strlen(test_buffer), &elapsed);
- test_eq(result, 1);
- test_assert(elapsed >= 0);
- test_assert(elapsed <= 5);
+ tt_int_op(result,==, 1);
+ tt_assert(elapsed >= 0);
+ tt_assert(elapsed <= 5);
/* Scrub it to exercise that entry point too */
replaycache_scrub_if_needed(r);
@@ -329,7 +340,7 @@ test_replaycache_realtime(void)
}
#define REPLAYCACHE_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_replaycache_ ## name }
+ { #name, test_replaycache_ ## name , 0, NULL, NULL }
struct testcase_t replaycache_tests[] = {
REPLAYCACHE_LEGACY(alloc),
diff --git a/src/test/test_routerkeys.c b/src/test/test_routerkeys.c
index 182e0f6f87..652d7d6c52 100644
--- a/src/test/test_routerkeys.c
+++ b/src/test/test_routerkeys.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
diff --git a/src/test/test_routerset.c b/src/test/test_routerset.c
new file mode 100644
index 0000000000..81e4dbb1eb
--- /dev/null
+++ b/src/test/test_routerset.c
@@ -0,0 +1,2122 @@
+#define ROUTERSET_PRIVATE
+
+#include "or.h"
+#include "geoip.h"
+#include "routerset.h"
+#include "routerparse.h"
+#include "policies.h"
+#include "nodelist.h"
+#include "test.h"
+
+#define NS_MODULE routerset
+
+#define NS_SUBMODULE routerset_new
+
+/*
+ * Functional (blackbox) test to determine that each member of the routerset
+ * is non-NULL
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *rs;
+ (void)arg;
+
+ rs = routerset_new();
+
+ tt_ptr_op(rs, !=, NULL);
+ tt_ptr_op(rs->list, !=, NULL);
+ tt_ptr_op(rs->names, !=, NULL);
+ tt_ptr_op(rs->digests, !=, NULL);
+ tt_ptr_op(rs->policies, !=, NULL);
+ tt_ptr_op(rs->country_names, !=, NULL);
+
+ done:
+ routerset_free(rs);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_get_countryname
+
+/*
+ * Functional test to strip the braces from a "{xx}" country code string.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ const char *input;
+ char *name;
+ (void)arg;
+
+ /* strlen(c) < 4 */
+ input = "xxx";
+ name = routerset_get_countryname(input);
+ tt_ptr_op(name, ==, NULL);
+ tor_free(name);
+
+ /* c[0] != '{' */
+ input = "xxx}";
+ name = routerset_get_countryname(input);
+ tt_ptr_op(name, ==, NULL);
+ tor_free(name);
+
+ /* c[3] != '}' */
+ input = "{xxx";
+ name = routerset_get_countryname(input);
+ tt_ptr_op(name, ==, NULL);
+ tor_free(name);
+
+ /* tor_strlower */
+ input = "{XX}";
+ name = routerset_get_countryname(input);
+ tt_str_op(name, ==, "xx");
+ tor_free(name);
+
+ input = "{xx}";
+ name = routerset_get_countryname(input);
+ tt_str_op(name, ==, "xx");
+ done:
+ tor_free(name);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_refresh_counties, geoip_not_loaded)
+
+/*
+ * Structural (whitebox) test for routerset_refresh_counties, when the GeoIP DB
+ * is not loaded.
+ */
+
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+NS_DECL(int, geoip_get_n_countries, (void));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ (void)arg;
+
+ NS_MOCK(geoip_is_loaded);
+ NS_MOCK(geoip_get_n_countries);
+
+ routerset_refresh_countries(set);
+
+ tt_ptr_op(set->countries, ==, NULL);
+ tt_int_op(set->n_countries, ==, 0);
+ tt_int_op(CALLED(geoip_is_loaded), ==, 1);
+ tt_int_op(CALLED(geoip_get_n_countries), ==, 0);
+
+ done:
+ NS_UNMOCK(geoip_is_loaded);
+ NS_UNMOCK(geoip_get_n_countries);
+ routerset_free(set);
+}
+
+static int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ (void)family;
+ CALLED(geoip_is_loaded)++;
+
+ return 0;
+}
+
+static int
+NS(geoip_get_n_countries)(void)
+{
+ CALLED(geoip_get_n_countries)++;
+
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_refresh_counties, no_countries)
+
+/*
+ * Structural test for routerset_refresh_counties, when there are no countries.
+ */
+
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+NS_DECL(int, geoip_get_n_countries, (void));
+NS_DECL(country_t, geoip_get_country, (const char *country));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ (void)arg;
+
+ NS_MOCK(geoip_is_loaded);
+ NS_MOCK(geoip_get_n_countries);
+ NS_MOCK(geoip_get_country);
+
+ routerset_refresh_countries(set);
+
+ tt_ptr_op(set->countries, !=, NULL);
+ tt_int_op(set->n_countries, ==, 1);
+ tt_int_op((unsigned int)(*set->countries), ==, 0);
+ tt_int_op(CALLED(geoip_is_loaded), ==, 1);
+ tt_int_op(CALLED(geoip_get_n_countries), ==, 1);
+ tt_int_op(CALLED(geoip_get_country), ==, 0);
+
+ done:
+ NS_UNMOCK(geoip_is_loaded);
+ NS_UNMOCK(geoip_get_n_countries);
+ NS_UNMOCK(geoip_get_country);
+ routerset_free(set);
+}
+
+static int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ (void)family;
+ CALLED(geoip_is_loaded)++;
+
+ return 1;
+}
+
+static int
+NS(geoip_get_n_countries)(void)
+{
+ CALLED(geoip_get_n_countries)++;
+
+ return 1;
+}
+
+static country_t
+NS(geoip_get_country)(const char *countrycode)
+{
+ (void)countrycode;
+ CALLED(geoip_get_country)++;
+
+ return 1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_refresh_counties, one_valid_country)
+
+/*
+ * Structural test for routerset_refresh_counties, with one valid country.
+ */
+
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+NS_DECL(int, geoip_get_n_countries, (void));
+NS_DECL(country_t, geoip_get_country, (const char *country));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ (void)arg;
+
+ NS_MOCK(geoip_is_loaded);
+ NS_MOCK(geoip_get_n_countries);
+ NS_MOCK(geoip_get_country);
+ smartlist_add(set->country_names, tor_strndup("foo", 3));
+
+ routerset_refresh_countries(set);
+
+ tt_ptr_op(set->countries, !=, NULL);
+ tt_int_op(set->n_countries, ==, 2);
+ tt_int_op(CALLED(geoip_is_loaded), ==, 1);
+ tt_int_op(CALLED(geoip_get_n_countries), ==, 1);
+ tt_int_op(CALLED(geoip_get_country), ==, 1);
+ tt_int_op((unsigned int)(*set->countries), !=, 0);
+
+ done:
+ NS_UNMOCK(geoip_is_loaded);
+ NS_UNMOCK(geoip_get_n_countries);
+ NS_UNMOCK(geoip_get_country);
+ routerset_free(set);
+}
+
+static int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ (void)family;
+ CALLED(geoip_is_loaded)++;
+
+ return 1;
+}
+
+static int
+NS(geoip_get_n_countries)(void)
+{
+ CALLED(geoip_get_n_countries)++;
+
+ return 2;
+}
+
+static country_t
+NS(geoip_get_country)(const char *countrycode)
+{
+ (void)countrycode;
+ CALLED(geoip_get_country)++;
+
+ return 1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_refresh_counties, one_invalid_country)
+
+/*
+ * Structural test for routerset_refresh_counties, with one invalid
+ * country code..
+ */
+
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+NS_DECL(int, geoip_get_n_countries, (void));
+NS_DECL(country_t, geoip_get_country, (const char *country));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ (void)arg;
+
+ NS_MOCK(geoip_is_loaded);
+ NS_MOCK(geoip_get_n_countries);
+ NS_MOCK(geoip_get_country);
+ smartlist_add(set->country_names, tor_strndup("foo", 3));
+
+ routerset_refresh_countries(set);
+
+ tt_ptr_op(set->countries, !=, NULL);
+ tt_int_op(set->n_countries, ==, 2);
+ tt_int_op(CALLED(geoip_is_loaded), ==, 1);
+ tt_int_op(CALLED(geoip_get_n_countries), ==, 1);
+ tt_int_op(CALLED(geoip_get_country), ==, 1);
+ tt_int_op((unsigned int)(*set->countries), ==, 0);
+
+ done:
+ NS_UNMOCK(geoip_is_loaded);
+ NS_UNMOCK(geoip_get_n_countries);
+ NS_UNMOCK(geoip_get_country);
+ routerset_free(set);
+}
+
+static int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ (void)family;
+ CALLED(geoip_is_loaded)++;
+
+ return 1;
+}
+
+static int
+NS(geoip_get_n_countries)(void)
+{
+ CALLED(geoip_get_n_countries)++;
+
+ return 2;
+}
+
+static country_t
+NS(geoip_get_country)(const char *countrycode)
+{
+ (void)countrycode;
+ CALLED(geoip_get_country)++;
+
+ return -1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_parse, malformed)
+
+/*
+ * Functional test, with a malformed string to parse.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ const char *s = "_";
+ int r;
+ (void)arg;
+
+ r = routerset_parse(set, s, "");
+
+ tt_int_op(r, ==, -1);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_parse, valid_hexdigest)
+
+/*
+ * Functional test for routerset_parse, that routerset_parse returns 0
+ * on a valid hexdigest entry.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set;
+ const char *s;
+ int r;
+ (void)arg;
+
+ set = routerset_new();
+ s = "$0000000000000000000000000000000000000000";
+ r = routerset_parse(set, s, "");
+ tt_int_op(r, ==, 0);
+ tt_int_op(digestmap_isempty(set->digests), !=, 1);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_parse, valid_nickname)
+
+/*
+ * Functional test for routerset_parse, when given a valid nickname as input.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set;
+ const char *s;
+ int r;
+ (void)arg;
+
+ set = routerset_new();
+ s = "fred";
+ r = routerset_parse(set, s, "");
+ tt_int_op(r, ==, 0);
+ tt_int_op(strmap_isempty(set->names), !=, 1);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_parse, get_countryname)
+
+/*
+ * Functional test for routerset_parse, when given a valid countryname.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set;
+ const char *s;
+ int r;
+ (void)arg;
+
+ set = routerset_new();
+ s = "{cc}";
+ r = routerset_parse(set, s, "");
+ tt_int_op(r, ==, 0);
+ tt_int_op(smartlist_len(set->country_names), !=, 0);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_parse, policy)
+
+/*
+ * Structural test for routerset_parse, when given a valid policy.
+ */
+
+NS_DECL(addr_policy_t *, router_parse_addr_policy_item_from_string,
+ (const char *s, int assume_action));
+
+addr_policy_t *NS(mock_addr_policy);
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set;
+ const char *s;
+ int r;
+ (void)arg;
+
+ NS_MOCK(router_parse_addr_policy_item_from_string);
+ NS(mock_addr_policy) = tor_malloc_zero(sizeof(addr_policy_t));
+
+ set = routerset_new();
+ s = "*";
+ r = routerset_parse(set, s, "");
+ tt_int_op(r, ==, 0);
+ tt_int_op(smartlist_len(set->policies), !=, 0);
+ tt_int_op(CALLED(router_parse_addr_policy_item_from_string), ==, 1);
+
+ done:
+ routerset_free(set);
+}
+
+addr_policy_t *
+NS(router_parse_addr_policy_item_from_string)(const char *s, int assume_action)
+{
+ (void)s;
+ (void)assume_action;
+ CALLED(router_parse_addr_policy_item_from_string)++;
+
+ return NS(mock_addr_policy);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_union, source_bad)
+
+/*
+ * Structural test for routerset_union, when given a bad source argument.
+ */
+
+NS_DECL(smartlist_t *, smartlist_new, (void));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set, *bad_set;
+ (void)arg;
+
+ set = routerset_new();
+ bad_set = routerset_new();
+ smartlist_free(bad_set->list);
+ bad_set->list = NULL;
+
+ NS_MOCK(smartlist_new);
+
+ routerset_union(set, NULL);
+ tt_int_op(CALLED(smartlist_new), ==, 0);
+
+ routerset_union(set, bad_set);
+ tt_int_op(CALLED(smartlist_new), ==, 0);
+
+ done:
+ NS_UNMOCK(smartlist_new);
+ routerset_free(set);
+
+ /* Just recreate list, so we can simply use routerset_free. */
+ bad_set->list = smartlist_new();
+ routerset_free(bad_set);
+}
+
+static smartlist_t *
+NS(smartlist_new)(void)
+{
+ CALLED(smartlist_new)++;
+
+ return NULL;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_union, one)
+
+/*
+ * Functional test for routerset_union.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *src = routerset_new();
+ routerset_t *tgt;
+ (void)arg;
+
+ tgt = routerset_new();
+ smartlist_add(src->list, tor_strdup("{xx}"));
+ routerset_union(tgt, src);
+
+ tt_int_op(smartlist_len(tgt->list), !=, 0);
+
+ done:
+ routerset_free(src);
+ routerset_free(tgt);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_is_list
+
+/*
+ * Functional tests for routerset_is_list.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set;
+ addr_policy_t *policy;
+ int is_list;
+ (void)arg;
+
+ /* len(set->country_names) == 0, len(set->policies) == 0 */
+ set = routerset_new();
+ is_list = routerset_is_list(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_list, !=, 0);
+
+ /* len(set->country_names) != 0, len(set->policies) == 0 */
+ set = routerset_new();
+ smartlist_add(set->country_names, tor_strndup("foo", 3));
+ is_list = routerset_is_list(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_list, ==, 0);
+
+ /* len(set->country_names) == 0, len(set->policies) != 0 */
+ set = routerset_new();
+ policy = tor_malloc_zero(sizeof(addr_policy_t));
+ smartlist_add(set->policies, (void *)policy);
+ is_list = routerset_is_list(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_list, ==, 0);
+
+ /* len(set->country_names) != 0, len(set->policies) != 0 */
+ set = routerset_new();
+ smartlist_add(set->country_names, tor_strndup("foo", 3));
+ policy = tor_malloc_zero(sizeof(addr_policy_t));
+ smartlist_add(set->policies, (void *)policy);
+ is_list = routerset_is_list(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_list, ==, 0);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_needs_geoip
+
+/*
+ * Functional tests for routerset_needs_geoip.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ const routerset_t *set;
+ int needs_geoip;
+ (void)arg;
+
+ set = NULL;
+ needs_geoip = routerset_needs_geoip(set);
+ tt_int_op(needs_geoip, ==, 0);
+
+ set = routerset_new();
+ needs_geoip = routerset_needs_geoip(set);
+ routerset_free((routerset_t *)set);
+ tt_int_op(needs_geoip, ==, 0);
+ set = NULL;
+
+ set = routerset_new();
+ smartlist_add(set->country_names, tor_strndup("xx", 2));
+ needs_geoip = routerset_needs_geoip(set);
+ routerset_free((routerset_t *)set);
+ set = NULL;
+ tt_int_op(needs_geoip, !=, 0);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_is_empty
+
+/*
+ * Functional tests for routerset_is_empty.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = NULL;
+ int is_empty;
+ (void)arg;
+
+ is_empty = routerset_is_empty(set);
+ tt_int_op(is_empty, !=, 0);
+
+ set = routerset_new();
+ is_empty = routerset_is_empty(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_empty, !=, 0);
+
+ set = routerset_new();
+ smartlist_add(set->list, tor_strdup("{xx}"));
+ is_empty = routerset_is_empty(set);
+ routerset_free(set);
+ set = NULL;
+ tt_int_op(is_empty, ==, 0);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, null_set_or_null_set_list)
+
+/*
+ * Functional test for routerset_contains, when given a NULL set or the
+ * set has a NULL list.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = NULL;
+ int contains;
+ (void)arg;
+
+ contains = routerset_contains(set, NULL, 0, NULL, NULL, 0);
+
+ tt_int_op(contains, ==, 0);
+
+ set = tor_malloc_zero(sizeof(routerset_t));
+ set->list = NULL;
+ contains = routerset_contains(set, NULL, 0, NULL, NULL, 0);
+ tor_free(set);
+ tt_int_op(contains, ==, 0);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_null_nickname)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset but a
+ * NULL nickname.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ char *nickname = NULL;
+ int contains;
+ (void)arg;
+
+ contains = routerset_contains(set, NULL, 0, nickname, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_nickname)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset
+ * and the nickname is in the routerset.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ const char *nickname;
+ int contains;
+ (void)arg;
+
+ nickname = "Foo"; /* This tests the lowercase comparison as well. */
+ strmap_set_lc(set->names, nickname, (void *)1);
+ contains = routerset_contains(set, NULL, 0, nickname, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 4);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_no_nickname)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset
+ * and the nickname is not in the routerset.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains;
+ (void)arg;
+
+ strmap_set_lc(set->names, "bar", (void *)1);
+ contains = routerset_contains(set, NULL, 0, "foo", NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_digest)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset
+ * and the digest is contained in the routerset.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains;
+ uint8_t foo[20] = { 2, 3, 4 };
+ (void)arg;
+
+ digestmap_set(set->digests, (const char*)foo, (void *)1);
+ contains = routerset_contains(set, NULL, 0, NULL, (const char*)foo, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 4);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_no_digest)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset
+ * and the digest is not contained in the routerset.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains;
+ uint8_t bar[20] = { 9, 10, 11, 55 };
+ uint8_t foo[20] = { 1, 2, 3, 4};
+ (void)arg;
+
+ digestmap_set(set->digests, (const char*)bar, (void *)1);
+ contains = routerset_contains(set, NULL, 0, NULL, (const char*)foo, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_null_digest)
+
+/*
+ * Functional test for routerset_contains, when given a valid routerset
+ * and the digest is NULL.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains;
+ uint8_t bar[20] = { 9, 10, 11, 55 };
+ (void)arg;
+
+ digestmap_set(set->digests, (const char*)bar, (void *)1);
+ contains = routerset_contains(set, NULL, 0, NULL, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_addr)
+
+/*
+ * Structural test for routerset_contains, when given a valid routerset
+ * and the address is rejected by policy.
+ */
+
+NS_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
+
+static tor_addr_t MOCK_TOR_ADDR;
+#define MOCK_TOR_ADDR_PTR (&MOCK_TOR_ADDR)
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ tor_addr_t *addr = MOCK_TOR_ADDR_PTR;
+ int contains;
+ (void)arg;
+
+ NS_MOCK(compare_tor_addr_to_addr_policy);
+
+ contains = routerset_contains(set, addr, 0, NULL, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(CALLED(compare_tor_addr_to_addr_policy), ==, 1);
+ tt_int_op(contains, ==, 3);
+
+ done:
+ ;
+}
+
+addr_policy_result_t
+NS(compare_tor_addr_to_addr_policy)(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy)
+{
+ (void)port;
+ (void)policy;
+ CALLED(compare_tor_addr_to_addr_policy)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+ return ADDR_POLICY_REJECTED;
+
+ done:
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_no_addr)
+
+/*
+ * Structural test for routerset_contains, when given a valid routerset
+ * and the address is not rejected by policy.
+ */
+
+NS_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ tor_addr_t *addr = MOCK_TOR_ADDR_PTR;
+ int contains;
+ (void)arg;
+
+ NS_MOCK(compare_tor_addr_to_addr_policy);
+
+ contains = routerset_contains(set, addr, 0, NULL, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(CALLED(compare_tor_addr_to_addr_policy), ==, 1);
+ tt_int_op(contains, ==, 0);
+
+ done:
+ ;
+}
+
+addr_policy_result_t
+NS(compare_tor_addr_to_addr_policy)(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy)
+{
+ (void)port;
+ (void)policy;
+ CALLED(compare_tor_addr_to_addr_policy)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ return ADDR_POLICY_ACCEPTED;
+
+ done:
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, set_and_null_addr)
+
+/*
+ * Structural test for routerset_contains, when given a valid routerset
+ * and the address is NULL.
+ */
+
+NS_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains;
+ (void)arg;
+
+ NS_MOCK(compare_tor_addr_to_addr_policy);
+
+ contains = routerset_contains(set, NULL, 0, NULL, NULL, 0);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+
+ done:
+ ;
+}
+
+addr_policy_result_t
+NS(compare_tor_addr_to_addr_policy)(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy)
+{
+ (void)port;
+ (void)policy;
+ CALLED(compare_tor_addr_to_addr_policy)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ return ADDR_POLICY_ACCEPTED;
+
+ done:
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, countries_no_geoip)
+
+/*
+ * Structural test for routerset_contains, when there is no matching country
+ * for the address.
+ */
+
+NS_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
+NS_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains = 1;
+ (void)arg;
+
+ NS_MOCK(compare_tor_addr_to_addr_policy);
+ NS_MOCK(geoip_get_country_by_addr);
+
+ set->countries = bitarray_init_zero(1);
+ bitarray_set(set->countries, 1);
+ contains = routerset_contains(set, MOCK_TOR_ADDR_PTR, 0, NULL, NULL, -1);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 0);
+ tt_int_op(CALLED(compare_tor_addr_to_addr_policy), ==, 1);
+ tt_int_op(CALLED(geoip_get_country_by_addr), ==, 1);
+
+ done:
+ ;
+}
+
+addr_policy_result_t
+NS(compare_tor_addr_to_addr_policy)(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy)
+{
+ (void)port;
+ (void)policy;
+ CALLED(compare_tor_addr_to_addr_policy)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ done:
+ return ADDR_POLICY_ACCEPTED;
+}
+
+int
+NS(geoip_get_country_by_addr)(const tor_addr_t *addr)
+{
+ CALLED(geoip_get_country_by_addr)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ done:
+ return -1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains, countries_geoip)
+
+/*
+ * Structural test for routerset_contains, when there a matching country
+ * for the address.
+ */
+
+NS_DECL(addr_policy_result_t, compare_tor_addr_to_addr_policy,
+ (const tor_addr_t *addr, uint16_t port, const smartlist_t *policy));
+NS_DECL(int, geoip_get_country_by_addr, (const tor_addr_t *addr));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int contains = 1;
+ (void)arg;
+
+ NS_MOCK(compare_tor_addr_to_addr_policy);
+ NS_MOCK(geoip_get_country_by_addr);
+
+ set->n_countries = 2;
+ set->countries = bitarray_init_zero(1);
+ bitarray_set(set->countries, 1);
+ contains = routerset_contains(set, MOCK_TOR_ADDR_PTR, 0, NULL, NULL, -1);
+ routerset_free(set);
+
+ tt_int_op(contains, ==, 2);
+ tt_int_op(CALLED(compare_tor_addr_to_addr_policy), ==, 1);
+ tt_int_op(CALLED(geoip_get_country_by_addr), ==, 1);
+
+ done:
+ ;
+}
+
+addr_policy_result_t
+NS(compare_tor_addr_to_addr_policy)(const tor_addr_t *addr, uint16_t port,
+ const smartlist_t *policy)
+{
+ (void)port;
+ (void)policy;
+ CALLED(compare_tor_addr_to_addr_policy)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ done:
+ return ADDR_POLICY_ACCEPTED;
+}
+
+int
+NS(geoip_get_country_by_addr)(const tor_addr_t *addr)
+{
+ CALLED(geoip_get_country_by_addr)++;
+ tt_ptr_op(addr, ==, MOCK_TOR_ADDR_PTR);
+
+ done:
+ return 1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_add_unknown_ccs, only_flag_and_no_ccs)
+
+/*
+ * Functional test for routerset_add_unknown_ccs, where only_if_some_cc_set
+ * is set and there are no country names.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ routerset_t **setp = &set;
+ int r;
+ (void)arg;
+
+ r = routerset_add_unknown_ccs(setp, 1);
+
+ tt_int_op(r, ==, 0);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_add_unknown_ccs, creates_set)
+
+/*
+ * Functional test for routerset_add_unknown_ccs, where the set argument
+ * is created if passed in as NULL.
+ */
+
+/* The mock is only used to stop the test from asserting erroneously. */
+NS_DECL(country_t, geoip_get_country, (const char *country));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = NULL;
+ routerset_t **setp = &set;
+ int r;
+ (void)arg;
+
+ NS_MOCK(geoip_get_country);
+
+ r = routerset_add_unknown_ccs(setp, 0);
+
+ tt_ptr_op(*setp, !=, NULL);
+ tt_int_op(r, ==, 0);
+
+ done:
+ if (set != NULL)
+ routerset_free(set);
+}
+
+country_t
+NS(geoip_get_country)(const char *country)
+{
+ (void)country;
+ CALLED(geoip_get_country)++;
+
+ return -1;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_add_unknown_ccs, add_unknown)
+
+/*
+ * Structural test for routerset_add_unknown_ccs, that the "{??}"
+ * country code is added to the list.
+ */
+
+NS_DECL(country_t, geoip_get_country, (const char *country));
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ routerset_t **setp = &set;
+ int r;
+ (void)arg;
+
+ NS_MOCK(geoip_get_country);
+ NS_MOCK(geoip_is_loaded);
+
+ r = routerset_add_unknown_ccs(setp, 0);
+
+ tt_int_op(r, ==, 1);
+ tt_int_op(smartlist_contains_string(set->country_names, "??"), ==, 1);
+ tt_int_op(smartlist_contains_string(set->list, "{??}"), ==, 1);
+
+ done:
+ if (set != NULL)
+ routerset_free(set);
+}
+
+country_t
+NS(geoip_get_country)(const char *country)
+{
+ int arg_is_qq, arg_is_a1;
+
+ CALLED(geoip_get_country)++;
+
+ arg_is_qq = !strcmp(country, "??");
+ arg_is_a1 = !strcmp(country, "A1");
+
+ tt_int_op(arg_is_qq || arg_is_a1, ==, 1);
+
+ if (arg_is_qq)
+ return 1;
+
+ done:
+ return -1;
+}
+
+int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ CALLED(geoip_is_loaded)++;
+
+ tt_int_op(family, ==, AF_INET);
+
+ done:
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_add_unknown_ccs, add_a1)
+
+/*
+ * Structural test for routerset_add_unknown_ccs, that the "{a1}"
+ * country code is added to the list.
+ */
+
+NS_DECL(country_t, geoip_get_country, (const char *country));
+NS_DECL(int, geoip_is_loaded, (sa_family_t family));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ routerset_t **setp = &set;
+ int r;
+ (void)arg;
+
+ NS_MOCK(geoip_get_country);
+ NS_MOCK(geoip_is_loaded);
+
+ r = routerset_add_unknown_ccs(setp, 0);
+
+ tt_int_op(r, ==, 1);
+ tt_int_op(smartlist_contains_string(set->country_names, "a1"), ==, 1);
+ tt_int_op(smartlist_contains_string(set->list, "{a1}"), ==, 1);
+
+ done:
+ if (set != NULL)
+ routerset_free(set);
+}
+
+country_t
+NS(geoip_get_country)(const char *country)
+{
+ int arg_is_qq, arg_is_a1;
+
+ CALLED(geoip_get_country)++;
+
+ arg_is_qq = !strcmp(country, "??");
+ arg_is_a1 = !strcmp(country, "A1");
+
+ tt_int_op(arg_is_qq || arg_is_a1, ==, 1);
+
+ if (arg_is_a1)
+ return 1;
+
+ done:
+ return -1;
+}
+
+int
+NS(geoip_is_loaded)(sa_family_t family)
+{
+ CALLED(geoip_is_loaded)++;
+
+ tt_int_op(family, ==, AF_INET);
+
+ done:
+ return 0;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_contains_extendinfo
+
+/*
+ * Functional test for routerset_contains_extendinfo.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ extend_info_t ei;
+ int r;
+ const char *nickname = "foo";
+ (void)arg;
+
+ memset(&ei, 0, sizeof(ei));
+ strmap_set_lc(set->names, nickname, (void *)1);
+ strncpy(ei.nickname, nickname, sizeof(ei.nickname) - 1);
+ ei.nickname[sizeof(ei.nickname) - 1] = '\0';
+
+ r = routerset_contains_extendinfo(set, &ei);
+
+ tt_int_op(r, ==, 4);
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_contains_router
+
+/*
+ * Functional test for routerset_contains_router.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ routerinfo_t ri;
+ country_t country = 1;
+ int r;
+ const char *nickname = "foo";
+ (void)arg;
+
+ memset(&ri, 0, sizeof(ri));
+ strmap_set_lc(set->names, nickname, (void *)1);
+ ri.nickname = (char *)nickname;
+
+ r = routerset_contains_router(set, &ri, country);
+
+ tt_int_op(r, ==, 4);
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_contains_routerstatus
+
+/*
+ * Functional test for routerset_contains_routerstatus.
+ */
+
+// XXX: This is a bit brief. It only populates and tests the nickname fields
+// ie., enough to make the containment check succeed. Perhaps it should do
+// a bit more or test a bit more.
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ routerstatus_t rs;
+ country_t country = 1;
+ int r;
+ const char *nickname = "foo";
+ (void)arg;
+
+ memset(&rs, 0, sizeof(rs));
+ strmap_set_lc(set->names, nickname, (void *)1);
+ strncpy(rs.nickname, nickname, sizeof(rs.nickname) - 1);
+ rs.nickname[sizeof(rs.nickname) - 1] = '\0';
+
+ r = routerset_contains_routerstatus(set, &rs, country);
+
+ tt_int_op(r, ==, 4);
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains_node, none)
+
+/*
+ * Functional test for routerset_contains_node, when the node has no
+ * routerset or routerinfo.
+ */
+
+node_t NS(mock_node);
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int r;
+ (void)arg;
+
+ NS(mock_node).ri = NULL;
+ NS(mock_node).rs = NULL;
+
+ r = routerset_contains_node(set, &NS(mock_node));
+ tt_int_op(r, ==, 0);
+
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains_node, routerstatus)
+
+/*
+ * Functional test for routerset_contains_node, when the node has a
+ * routerset and no routerinfo.
+ */
+
+node_t NS(mock_node);
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int r;
+ const char *nickname = "foo";
+ routerstatus_t rs;
+ (void)arg;
+
+ strmap_set_lc(set->names, nickname, (void *)1);
+
+ strncpy(rs.nickname, nickname, sizeof(rs.nickname) - 1);
+ rs.nickname[sizeof(rs.nickname) - 1] = '\0';
+ NS(mock_node).ri = NULL;
+ NS(mock_node).rs = &rs;
+
+ r = routerset_contains_node(set, &NS(mock_node));
+
+ tt_int_op(r, ==, 4);
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_contains_node, routerinfo)
+
+/*
+ * Functional test for routerset_contains_node, when the node has no
+ * routerset and a routerinfo.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ int r;
+ const char *nickname = "foo";
+ routerinfo_t ri;
+ node_t mock_node;
+ (void)arg;
+
+ strmap_set_lc(set->names, nickname, (void *)1);
+
+ ri.nickname = (char *)nickname;
+ mock_node.ri = &ri;
+ mock_node.rs = NULL;
+
+ r = routerset_contains_node(set, &mock_node);
+
+ tt_int_op(r, ==, 4);
+ done:
+ routerset_free(set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, no_routerset)
+
+/*
+ * Functional test for routerset_get_all_nodes, when routerset is NULL or
+ * the routerset list is NULL.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ smartlist_t *out = smartlist_new();
+ routerset_t *set = NULL;
+ (void)arg;
+
+ tt_int_op(smartlist_len(out), ==, 0);
+ routerset_get_all_nodes(out, NULL, NULL, 0);
+
+ tt_int_op(smartlist_len(out), ==, 0);
+
+ set = routerset_new();
+ smartlist_free(set->list);
+ routerset_get_all_nodes(out, NULL, NULL, 0);
+ tt_int_op(smartlist_len(out), ==, 0);
+
+ /* Just recreate list, so we can simply use routerset_free. */
+ set->list = smartlist_new();
+
+ done:
+ routerset_free(set);
+ smartlist_free(out);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, list_with_no_nodes)
+
+/*
+ * Structural test for routerset_get_all_nodes, when the routerset list
+ * is empty.
+ */
+
+NS_DECL(const node_t *, node_get_by_nickname,
+ (const char *nickname, int warn_if_unused));
+const char *NS(mock_nickname);
+
+static void
+NS(test_main)(void *arg)
+{
+ smartlist_t *out = smartlist_new();
+ routerset_t *set = routerset_new();
+ int out_len;
+ (void)arg;
+
+ NS_MOCK(node_get_by_nickname);
+
+ NS(mock_nickname) = "foo";
+ smartlist_add(set->list, tor_strdup(NS(mock_nickname)));
+
+ routerset_get_all_nodes(out, set, NULL, 0);
+ out_len = smartlist_len(out);
+
+ smartlist_free(out);
+ routerset_free(set);
+
+ tt_int_op(out_len, ==, 0);
+ tt_int_op(CALLED(node_get_by_nickname), ==, 1);
+
+ done:
+ ;
+}
+
+const node_t *
+NS(node_get_by_nickname)(const char *nickname, int warn_if_unused)
+{
+ CALLED(node_get_by_nickname)++;
+ tt_str_op(nickname, ==, NS(mock_nickname));
+ tt_int_op(warn_if_unused, ==, 1);
+
+ done:
+ return NULL;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, list_flag_not_running)
+
+/*
+ * Structural test for routerset_get_all_nodes, with the running_only flag
+ * is set but the nodes are not running.
+ */
+
+NS_DECL(const node_t *, node_get_by_nickname,
+ (const char *nickname, int warn_if_unused));
+const char *NS(mock_nickname);
+node_t NS(mock_node);
+
+static void
+NS(test_main)(void *arg)
+{
+ smartlist_t *out = smartlist_new();
+ routerset_t *set = routerset_new();
+ int out_len;
+ (void)arg;
+
+ NS_MOCK(node_get_by_nickname);
+
+ NS(mock_node).is_running = 0;
+ NS(mock_nickname) = "foo";
+ smartlist_add(set->list, tor_strdup(NS(mock_nickname)));
+
+ routerset_get_all_nodes(out, set, NULL, 1);
+ out_len = smartlist_len(out);
+
+ smartlist_free(out);
+ routerset_free(set);
+
+ tt_int_op(out_len, ==, 0);
+ tt_int_op(CALLED(node_get_by_nickname), ==, 1);
+
+ done:
+ ;
+}
+
+const node_t *
+NS(node_get_by_nickname)(const char *nickname, int warn_if_unused)
+{
+ CALLED(node_get_by_nickname)++;
+ tt_str_op(nickname, ==, NS(mock_nickname));
+ tt_int_op(warn_if_unused, ==, 1);
+
+ done:
+ return &NS(mock_node);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, list)
+
+/*
+ * Structural test for routerset_get_all_nodes.
+ */
+
+NS_DECL(const node_t *, node_get_by_nickname,
+ (const char *nickname, int warn_if_unused));
+char *NS(mock_nickname);
+node_t NS(mock_node);
+
+static void
+NS(test_main)(void *arg)
+{
+ smartlist_t *out = smartlist_new();
+ routerset_t *set = routerset_new();
+ int out_len;
+ node_t *ent;
+ (void)arg;
+
+ NS_MOCK(node_get_by_nickname);
+
+ NS(mock_nickname) = tor_strdup("foo");
+ smartlist_add(set->list, NS(mock_nickname));
+
+ routerset_get_all_nodes(out, set, NULL, 0);
+ out_len = smartlist_len(out);
+ ent = (node_t *)smartlist_get(out, 0);
+
+ smartlist_free(out);
+ routerset_free(set);
+
+ tt_int_op(out_len, ==, 1);
+ tt_ptr_op(ent, ==, &NS(mock_node));
+ tt_int_op(CALLED(node_get_by_nickname), ==, 1);
+
+ done:
+ ;
+}
+
+const node_t *
+NS(node_get_by_nickname)(const char *nickname, int warn_if_unused)
+{
+ CALLED(node_get_by_nickname)++;
+ tt_str_op(nickname, ==, NS(mock_nickname));
+ tt_int_op(warn_if_unused, ==, 1);
+
+ done:
+ return &NS(mock_node);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, nodelist_with_no_nodes)
+
+/*
+ * Structural test for routerset_get_all_nodes, when the nodelist has no nodes.
+ */
+
+NS_DECL(smartlist_t *, nodelist_get_list, (void));
+
+smartlist_t *NS(mock_smartlist);
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ smartlist_t *out = smartlist_new();
+ int r;
+ (void)arg;
+
+ NS_MOCK(nodelist_get_list);
+
+ smartlist_add(set->country_names, tor_strdup("{xx}"));
+ NS(mock_smartlist) = smartlist_new();
+
+ routerset_get_all_nodes(out, set, NULL, 1);
+ r = smartlist_len(out);
+ routerset_free(set);
+ smartlist_free(out);
+ smartlist_free(NS(mock_smartlist));
+
+ tt_int_op(r, ==, 0);
+ tt_int_op(CALLED(nodelist_get_list), ==, 1);
+
+ done:
+ ;
+}
+
+smartlist_t *
+NS(nodelist_get_list)(void)
+{
+ CALLED(nodelist_get_list)++;
+
+ return NS(mock_smartlist);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_get_all_nodes, nodelist_flag_not_running)
+
+/*
+ * Structural test for routerset_get_all_nodes, with a non-list routerset
+ * the running_only flag is set, but the nodes are not running.
+ */
+
+NS_DECL(smartlist_t *, nodelist_get_list, (void));
+
+smartlist_t *NS(mock_smartlist);
+node_t NS(mock_node);
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ smartlist_t *out = smartlist_new();
+ int r;
+ (void)arg;
+
+ NS_MOCK(nodelist_get_list);
+
+ smartlist_add(set->country_names, tor_strdup("{xx}"));
+ NS(mock_smartlist) = smartlist_new();
+ NS(mock_node).is_running = 0;
+ smartlist_add(NS(mock_smartlist), (void *)&NS(mock_node));
+
+ routerset_get_all_nodes(out, set, NULL, 1);
+ r = smartlist_len(out);
+ routerset_free(set);
+ smartlist_free(out);
+ smartlist_free(NS(mock_smartlist));
+
+ tt_int_op(r, ==, 0);
+ tt_int_op(CALLED(nodelist_get_list), ==, 1);
+
+ done:
+ ;
+}
+
+smartlist_t *
+NS(nodelist_get_list)(void)
+{
+ CALLED(nodelist_get_list)++;
+
+ return NS(mock_smartlist);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_subtract_nodes
+
+/*
+ * Functional test for routerset_subtract_nodes.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = routerset_new();
+ smartlist_t *list = smartlist_new();
+ const char *nickname = "foo";
+ routerinfo_t ri;
+ node_t mock_node;
+ (void)arg;
+
+ strmap_set_lc(set->names, nickname, (void *)1);
+
+ ri.nickname = (char *)nickname;
+ mock_node.rs = NULL;
+ mock_node.ri = &ri;
+ smartlist_add(list, (void *)&mock_node);
+
+ tt_int_op(smartlist_len(list), !=, 0);
+ routerset_subtract_nodes(list, set);
+
+ tt_int_op(smartlist_len(list), ==, 0);
+ done:
+ routerset_free(set);
+ smartlist_free(list);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_subtract_nodes, null_routerset)
+
+/*
+ * Functional test for routerset_subtract_nodes, with a NULL routerset.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = NULL;
+ smartlist_t *list = smartlist_new();
+ const char *nickname = "foo";
+ routerinfo_t ri;
+ node_t mock_node;
+ (void)arg;
+
+ ri.nickname = (char *)nickname;
+ mock_node.ri = &ri;
+ smartlist_add(list, (void *)&mock_node);
+
+ tt_int_op(smartlist_len(list), !=, 0);
+ routerset_subtract_nodes(list, set);
+
+ tt_int_op(smartlist_len(list), !=, 0);
+ done:
+ routerset_free(set);
+ smartlist_free(list);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_to_string
+
+/*
+ * Functional test for routerset_to_string.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *set = NULL;
+ char *s = NULL;
+ (void)arg;
+
+ set = NULL;
+ s = routerset_to_string(set);
+ tt_str_op(s, ==, "");
+ tor_free(s);
+
+ set = routerset_new();
+ s = routerset_to_string(set);
+ tt_str_op(s, ==, "");
+ tor_free(s);
+ routerset_free(set); set = NULL;
+
+ set = routerset_new();
+ smartlist_add(set->list, tor_strndup("a", 1));
+ s = routerset_to_string(set);
+ tt_str_op(s, ==, "a");
+ tor_free(s);
+ routerset_free(set); set = NULL;
+
+ set = routerset_new();
+ smartlist_add(set->list, tor_strndup("a", 1));
+ smartlist_add(set->list, tor_strndup("b", 1));
+ s = routerset_to_string(set);
+ tt_str_op(s, ==, "a,b");
+ tor_free(s);
+ routerset_free(set); set = NULL;
+
+ done:
+ tor_free(s);
+ routerset_free((routerset_t *)set);
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_equal, empty_empty)
+
+/*
+ * Functional test for routerset_equal, with both routersets empty.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *a = routerset_new(), *b = routerset_new();
+ int r;
+ (void)arg;
+
+ r = routerset_equal(a, b);
+ routerset_free(a);
+ routerset_free(b);
+
+ tt_int_op(r, ==, 1);
+
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_equal, empty_not_empty)
+
+/*
+ * Functional test for routerset_equal, with one routersets empty.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *a = routerset_new(), *b = routerset_new();
+ int r;
+ (void)arg;
+
+ smartlist_add(b->list, tor_strdup("{xx}"));
+ r = routerset_equal(a, b);
+ routerset_free(a);
+ routerset_free(b);
+
+ tt_int_op(r, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_equal, differing_lengths)
+
+/*
+ * Functional test for routerset_equal, with the routersets having
+ * differing lengths.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *a = routerset_new(), *b = routerset_new();
+ int r;
+ (void)arg;
+
+ smartlist_add(a->list, tor_strdup("{aa}"));
+ smartlist_add(b->list, tor_strdup("{b1}"));
+ smartlist_add(b->list, tor_strdup("{b2}"));
+ r = routerset_equal(a, b);
+ routerset_free(a);
+ routerset_free(b);
+
+ tt_int_op(r, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_equal, unequal)
+
+/*
+ * Functional test for routerset_equal, with the routersets being
+ * different.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *a = routerset_new(), *b = routerset_new();
+ int r;
+ (void)arg;
+
+ smartlist_add(a->list, tor_strdup("foo"));
+ smartlist_add(b->list, tor_strdup("bar"));
+ r = routerset_equal(a, b);
+ routerset_free(a);
+ routerset_free(b);
+
+ tt_int_op(r, ==, 0);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_equal, equal)
+
+/*
+ * Functional test for routerset_equal, with the routersets being
+ * equal.
+ */
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *a = routerset_new(), *b = routerset_new();
+ int r;
+ (void)arg;
+
+ smartlist_add(a->list, tor_strdup("foo"));
+ smartlist_add(b->list, tor_strdup("foo"));
+ r = routerset_equal(a, b);
+ routerset_free(a);
+ routerset_free(b);
+
+ tt_int_op(r, ==, 1);
+ done:
+ ;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE ASPECT(routerset_free, null_routerset)
+
+/*
+ * Structural test for routerset_free, where the routerset is NULL.
+ */
+
+NS_DECL(void, smartlist_free, (smartlist_t *sl));
+
+static void
+NS(test_main)(void *arg)
+{
+ (void)arg;
+
+ NS_MOCK(smartlist_free);
+
+ routerset_free(NULL);
+
+ tt_int_op(CALLED(smartlist_free), ==, 0);
+
+ done:
+ ;
+}
+
+void
+NS(smartlist_free)(smartlist_t *s)
+{
+ (void)s;
+ CALLED(smartlist_free)++;
+}
+
+#undef NS_SUBMODULE
+#define NS_SUBMODULE routerset_free
+
+/*
+ * Structural test for routerset_free.
+ */
+
+NS_DECL(void, smartlist_free, (smartlist_t *sl));
+NS_DECL(void, strmap_free,(strmap_t *map, void (*free_val)(void*)));
+NS_DECL(void, digestmap_free, (digestmap_t *map, void (*free_val)(void*)));
+
+static void
+NS(test_main)(void *arg)
+{
+ routerset_t *routerset = routerset_new();
+ (void)arg;
+
+ NS_MOCK(smartlist_free);
+ NS_MOCK(strmap_free);
+ NS_MOCK(digestmap_free);
+
+ routerset_free(routerset);
+
+ tt_int_op(CALLED(smartlist_free), !=, 0);
+ tt_int_op(CALLED(strmap_free), !=, 0);
+ tt_int_op(CALLED(digestmap_free), !=, 0);
+
+ done:
+ ;
+}
+
+void
+NS(smartlist_free)(smartlist_t *s)
+{
+ CALLED(smartlist_free)++;
+ smartlist_free__real(s);
+}
+
+void
+NS(strmap_free)(strmap_t *map, void (*free_val)(void*))
+{
+ CALLED(strmap_free)++;
+ strmap_free__real(map, free_val);
+}
+
+void
+NS(digestmap_free)(digestmap_t *map, void (*free_val)(void*))
+{
+ CALLED(digestmap_free)++;
+ digestmap_free__real(map, free_val);
+}
+
+#undef NS_SUBMODULE
+
+struct testcase_t routerset_tests[] = {
+ TEST_CASE(routerset_new),
+ TEST_CASE(routerset_get_countryname),
+ TEST_CASE(routerset_is_list),
+ TEST_CASE(routerset_needs_geoip),
+ TEST_CASE(routerset_is_empty),
+ TEST_CASE_ASPECT(routerset_contains, null_set_or_null_set_list),
+ TEST_CASE_ASPECT(routerset_contains, set_and_nickname),
+ TEST_CASE_ASPECT(routerset_contains, set_and_null_nickname),
+ TEST_CASE_ASPECT(routerset_contains, set_and_no_nickname),
+ TEST_CASE_ASPECT(routerset_contains, set_and_digest),
+ TEST_CASE_ASPECT(routerset_contains, set_and_no_digest),
+ TEST_CASE_ASPECT(routerset_contains, set_and_null_digest),
+ TEST_CASE_ASPECT(routerset_contains, set_and_addr),
+ TEST_CASE_ASPECT(routerset_contains, set_and_no_addr),
+ TEST_CASE_ASPECT(routerset_contains, set_and_null_addr),
+ TEST_CASE_ASPECT(routerset_contains, countries_no_geoip),
+ TEST_CASE_ASPECT(routerset_contains, countries_geoip),
+ TEST_CASE_ASPECT(routerset_add_unknown_ccs, only_flag_and_no_ccs),
+ TEST_CASE_ASPECT(routerset_add_unknown_ccs, creates_set),
+ TEST_CASE_ASPECT(routerset_add_unknown_ccs, add_unknown),
+ TEST_CASE_ASPECT(routerset_add_unknown_ccs, add_a1),
+ TEST_CASE(routerset_contains_extendinfo),
+ TEST_CASE(routerset_contains_router),
+ TEST_CASE(routerset_contains_routerstatus),
+ TEST_CASE_ASPECT(routerset_contains_node, none),
+ TEST_CASE_ASPECT(routerset_contains_node, routerinfo),
+ TEST_CASE_ASPECT(routerset_contains_node, routerstatus),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, no_routerset),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, list_with_no_nodes),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, list_flag_not_running),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, list),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, nodelist_with_no_nodes),
+ TEST_CASE_ASPECT(routerset_get_all_nodes, nodelist_flag_not_running),
+ TEST_CASE_ASPECT(routerset_refresh_counties, geoip_not_loaded),
+ TEST_CASE_ASPECT(routerset_refresh_counties, no_countries),
+ TEST_CASE_ASPECT(routerset_refresh_counties, one_valid_country),
+ TEST_CASE_ASPECT(routerset_refresh_counties, one_invalid_country),
+ TEST_CASE_ASPECT(routerset_union, source_bad),
+ TEST_CASE_ASPECT(routerset_union, one),
+ TEST_CASE_ASPECT(routerset_parse, malformed),
+ TEST_CASE_ASPECT(routerset_parse, valid_hexdigest),
+ TEST_CASE_ASPECT(routerset_parse, valid_nickname),
+ TEST_CASE_ASPECT(routerset_parse, get_countryname),
+ TEST_CASE_ASPECT(routerset_parse, policy),
+ TEST_CASE(routerset_subtract_nodes),
+ TEST_CASE_ASPECT(routerset_subtract_nodes, null_routerset),
+ TEST_CASE(routerset_to_string),
+ TEST_CASE_ASPECT(routerset_equal, empty_empty),
+ TEST_CASE_ASPECT(routerset_equal, empty_not_empty),
+ TEST_CASE_ASPECT(routerset_equal, differing_lengths),
+ TEST_CASE_ASPECT(routerset_equal, unequal),
+ TEST_CASE_ASPECT(routerset_equal, equal),
+ TEST_CASE_ASPECT(routerset_free, null_routerset),
+ TEST_CASE(routerset_free),
+ END_OF_TESTCASES
+};
+
diff --git a/src/test/test_socks.c b/src/test/test_socks.c
index 4ce61e068b..29faa69fb8 100644
--- a/src/test/test_socks.c
+++ b/src/test/test_socks.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "or.h"
@@ -61,10 +61,10 @@ test_socks_4_unsupported_commands(void *ptr)
/* SOCKS 4 Send BIND [02] to IP address 2.2.2.2:4369 */
ADD_DATA(buf, "\x04\x02\x11\x11\x02\x02\x02\x02\x00");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == -1);
- test_eq(4, socks->socks_version);
- test_eq(0, socks->replylen); /* XXX: shouldn't tor reply? */
+ tt_int_op(4,==, socks->socks_version);
+ tt_int_op(0,==, socks->replylen); /* XXX: shouldn't tor reply? */
done:
;
@@ -76,49 +76,49 @@ test_socks_4_supported_commands(void *ptr)
{
SOCKS_TEST_INIT();
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
/* SOCKS 4 Send CONNECT [01] to IP address 2.2.2.2:4370 */
ADD_DATA(buf, "\x04\x01\x11\x12\x02\x02\x02\x03\x00");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(4, socks->socks_version);
- test_eq(0, socks->replylen); /* XXX: shouldn't tor reply? */
- test_eq(SOCKS_COMMAND_CONNECT, socks->command);
- test_streq("2.2.2.3", socks->address);
- test_eq(4370, socks->port);
- test_assert(socks->got_auth == 0);
- test_assert(! socks->username);
-
- test_eq(0, buf_datalen(buf));
+ tt_int_op(4,==, socks->socks_version);
+ tt_int_op(0,==, socks->replylen); /* XXX: shouldn't tor reply? */
+ tt_int_op(SOCKS_COMMAND_CONNECT,==, socks->command);
+ tt_str_op("2.2.2.3",==, socks->address);
+ tt_int_op(4370,==, socks->port);
+ tt_assert(socks->got_auth == 0);
+ tt_assert(! socks->username);
+
+ tt_int_op(0,==, buf_datalen(buf));
socks_request_clear(socks);
/* SOCKS 4 Send CONNECT [01] to IP address 2.2.2.2:4369 with userid*/
ADD_DATA(buf, "\x04\x01\x11\x12\x02\x02\x02\x04me\x00");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(4, socks->socks_version);
- test_eq(0, socks->replylen); /* XXX: shouldn't tor reply? */
- test_eq(SOCKS_COMMAND_CONNECT, socks->command);
- test_streq("2.2.2.4", socks->address);
- test_eq(4370, socks->port);
- test_assert(socks->got_auth == 1);
- test_assert(socks->username);
- test_eq(2, socks->usernamelen);
- test_memeq("me", socks->username, 2);
-
- test_eq(0, buf_datalen(buf));
+ tt_int_op(4,==, socks->socks_version);
+ tt_int_op(0,==, socks->replylen); /* XXX: shouldn't tor reply? */
+ tt_int_op(SOCKS_COMMAND_CONNECT,==, socks->command);
+ tt_str_op("2.2.2.4",==, socks->address);
+ tt_int_op(4370,==, socks->port);
+ tt_assert(socks->got_auth == 1);
+ tt_assert(socks->username);
+ tt_int_op(2,==, socks->usernamelen);
+ tt_mem_op("me",==, socks->username, 2);
+
+ tt_int_op(0,==, buf_datalen(buf));
socks_request_clear(socks);
/* SOCKS 4a Send RESOLVE [F0] request for torproject.org */
ADD_DATA(buf, "\x04\xF0\x01\x01\x00\x00\x00\x02me\x00torproject.org\x00");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(4, socks->socks_version);
- test_eq(0, socks->replylen); /* XXX: shouldn't tor reply? */
- test_streq("torproject.org", socks->address);
+ tt_int_op(4,==, socks->socks_version);
+ tt_int_op(0,==, socks->replylen); /* XXX: shouldn't tor reply? */
+ tt_str_op("torproject.org",==, socks->address);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
done:
;
@@ -133,33 +133,43 @@ test_socks_5_unsupported_commands(void *ptr)
/* SOCKS 5 Send unsupported BIND [02] command */
ADD_DATA(buf, "\x05\x02\x00\x01");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), 0);
- test_eq(0, buf_datalen(buf));
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, 0);
+ tt_int_op(0,==, buf_datalen(buf));
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
ADD_DATA(buf, "\x05\x02\x00\x01\x02\x02\x02\x01\x01\x01");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), -1);
- /* XXX: shouldn't tor reply 'command not supported' [07]? */
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_COMMAND_NOT_SUPPORTED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
buf_clear(buf);
socks_request_clear(socks);
/* SOCKS 5 Send unsupported UDP_ASSOCIATE [03] command */
- ADD_DATA(buf, "\x05\x03\x00\x01\x02");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), 0);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(2, socks->reply[1]);
+ ADD_DATA(buf, "\x05\x02\x00\x01");
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, 0);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
ADD_DATA(buf, "\x05\x03\x00\x01\x02\x02\x02\x01\x01\x01");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), -1);
- /* XXX: shouldn't tor reply 'command not supported' [07]? */
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_COMMAND_NOT_SUPPORTED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
done:
;
@@ -173,64 +183,100 @@ test_socks_5_supported_commands(void *ptr)
/* SOCKS 5 Send CONNECT [01] to IP address 2.2.2.2:4369 */
ADD_DATA(buf, "\x05\x01\x00");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), 0);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, 0);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
ADD_DATA(buf, "\x05\x01\x00\x01\x02\x02\x02\x02\x11\x11");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), 1);
- test_streq("2.2.2.2", socks->address);
- test_eq(4369, socks->port);
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, 1);
+ tt_str_op("2.2.2.2",==, socks->address);
+ tt_int_op(4369,==, socks->port);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
socks_request_clear(socks);
/* SOCKS 5 Send CONNECT [01] to FQDN torproject.org:4369 */
ADD_DATA(buf, "\x05\x01\x00");
ADD_DATA(buf, "\x05\x01\x00\x03\x0Etorproject.org\x11\x11");
- test_eq(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
- get_options()->SafeSocks), 1);
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, 1);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(0, socks->reply[1]);
- test_streq("torproject.org", socks->address);
- test_eq(4369, socks->port);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
+ tt_str_op("torproject.org",==, socks->address);
+ tt_int_op(4369,==, socks->port);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
socks_request_clear(socks);
/* SOCKS 5 Send RESOLVE [F0] request for torproject.org:4369 */
ADD_DATA(buf, "\x05\x01\x00");
ADD_DATA(buf, "\x05\xF0\x00\x03\x0Etorproject.org\x01\x02");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(0, socks->reply[1]);
- test_streq("torproject.org", socks->address);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
+ tt_str_op("torproject.org",==, socks->address);
+
+ tt_int_op(0,==, buf_datalen(buf));
+ socks_request_clear(socks);
+
+ /* SOCKS 5 Should reject RESOLVE [F0] request for IPv4 address
+ * string if SafeSocks is enabled. */
+
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\xF0\x00\x03\x07");
+ ADD_DATA(buf, "8.8.8.8");
+ ADD_DATA(buf, "\x01\x02");
+ tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
+ == -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_NOT_ALLOWED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
+ socks_request_clear(socks);
+
+ /* SOCKS 5 should reject RESOLVE [F0] reject for IPv6 address
+ * string if SafeSocks is enabled. */
+
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\xF0\x00\x03\x27");
+ ADD_DATA(buf, "2001:0db8:85a3:0000:0000:8a2e:0370:7334");
+ ADD_DATA(buf, "\x01\x02");
+ tt_assert(fetch_from_buf_socks(buf,socks,get_options()->TestSocks,1)
+ == -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_NOT_ALLOWED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
- test_eq(0, buf_datalen(buf));
socks_request_clear(socks);
/* SOCKS 5 Send RESOLVE_PTR [F1] for IP address 2.2.2.5 */
ADD_DATA(buf, "\x05\x01\x00");
ADD_DATA(buf, "\x05\xF1\x00\x01\x02\x02\x02\x05\x01\x03");
- test_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ tt_assert(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(0, socks->reply[1]);
- test_streq("2.2.2.5", socks->address);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
+ tt_str_op("2.2.2.5",==, socks->address);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
done:
;
@@ -244,30 +290,30 @@ test_socks_5_no_authenticate(void *ptr)
/*SOCKS 5 No Authentication */
ADD_DATA(buf,"\x05\x01\x00");
- test_assert(!fetch_from_buf_socks(buf, socks,
+ tt_assert(!fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks));
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(SOCKS_NO_AUTH, socks->reply[1]);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(SOCKS_NO_AUTH,==, socks->reply[1]);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
/*SOCKS 5 Send username/password anyway - pretend to be broken */
ADD_DATA(buf,"\x01\x02\x01\x01\x02\x01\x01");
- test_assert(!fetch_from_buf_socks(buf, socks,
+ tt_assert(!fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks));
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(1, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(1,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
- test_eq(2, socks->usernamelen);
- test_eq(2, socks->passwordlen);
+ tt_int_op(2,==, socks->usernamelen);
+ tt_int_op(2,==, socks->passwordlen);
- test_memeq("\x01\x01", socks->username, 2);
- test_memeq("\x01\x01", socks->password, 2);
+ tt_mem_op("\x01\x01",==, socks->username, 2);
+ tt_mem_op("\x01\x01",==, socks->password, 2);
done:
;
@@ -282,31 +328,31 @@ test_socks_5_authenticate(void *ptr)
/* SOCKS 5 Negotiate username/password authentication */
ADD_DATA(buf, "\x05\x01\x02");
- test_assert(!fetch_from_buf_socks(buf, socks,
+ tt_assert(!fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks));
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(SOCKS_USER_PASS, socks->reply[1]);
- test_eq(5, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(SOCKS_USER_PASS,==, socks->reply[1]);
+ tt_int_op(5,==, socks->socks_version);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
/* SOCKS 5 Send username/password */
ADD_DATA(buf, "\x01\x02me\x08mypasswd");
- test_assert(!fetch_from_buf_socks(buf, socks,
+ tt_assert(!fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks));
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(1, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(1,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
- test_eq(2, socks->usernamelen);
- test_eq(8, socks->passwordlen);
+ tt_int_op(2,==, socks->usernamelen);
+ tt_int_op(8,==, socks->passwordlen);
- test_memeq("me", socks->username, 2);
- test_memeq("mypasswd", socks->password, 8);
+ tt_mem_op("me",==, socks->username, 2);
+ tt_mem_op("mypasswd",==, socks->password, 8);
done:
;
@@ -321,34 +367,34 @@ test_socks_5_authenticate_with_data(void *ptr)
/* SOCKS 5 Negotiate username/password authentication */
ADD_DATA(buf, "\x05\x01\x02");
- test_assert(!fetch_from_buf_socks(buf, socks,
+ tt_assert(!fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks));
- test_eq(2, socks->replylen);
- test_eq(5, socks->reply[0]);
- test_eq(SOCKS_USER_PASS, socks->reply[1]);
- test_eq(5, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(5,==, socks->reply[0]);
+ tt_int_op(SOCKS_USER_PASS,==, socks->reply[1]);
+ tt_int_op(5,==, socks->socks_version);
- test_eq(0, buf_datalen(buf));
+ tt_int_op(0,==, buf_datalen(buf));
/* SOCKS 5 Send username/password */
/* SOCKS 5 Send CONNECT [01] to IP address 2.2.2.2:4369 */
ADD_DATA(buf, "\x01\x02me\x03you\x05\x01\x00\x01\x02\x02\x02\x02\x11\x11");
- test_assert(fetch_from_buf_socks(buf, socks,
+ tt_assert(fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks) == 1);
- test_eq(5, socks->socks_version);
- test_eq(2, socks->replylen);
- test_eq(1, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(5,==, socks->socks_version);
+ tt_int_op(2,==, socks->replylen);
+ tt_int_op(1,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
- test_streq("2.2.2.2", socks->address);
- test_eq(4369, socks->port);
+ tt_str_op("2.2.2.2",==, socks->address);
+ tt_int_op(4369,==, socks->port);
- test_eq(2, socks->usernamelen);
- test_eq(3, socks->passwordlen);
- test_memeq("me", socks->username, 2);
- test_memeq("you", socks->password, 3);
+ tt_int_op(2,==, socks->usernamelen);
+ tt_int_op(3,==, socks->passwordlen);
+ tt_mem_op("me",==, socks->username, 2);
+ tt_mem_op("you",==, socks->password, 3);
done:
;
@@ -362,13 +408,85 @@ test_socks_5_auth_before_negotiation(void *ptr)
/* SOCKS 5 Send username/password */
ADD_DATA(buf, "\x01\x02me\x02me");
- test_assert(fetch_from_buf_socks(buf, socks,
+ tt_assert(fetch_from_buf_socks(buf, socks,
get_options()->TestSocks,
get_options()->SafeSocks) == -1);
- test_eq(0, socks->socks_version);
- test_eq(0, socks->replylen);
- test_eq(0, socks->reply[0]);
- test_eq(0, socks->reply[1]);
+ tt_int_op(0,==, socks->socks_version);
+ tt_int_op(0,==, socks->replylen);
+ tt_int_op(0,==, socks->reply[0]);
+ tt_int_op(0,==, socks->reply[1]);
+
+ done:
+ ;
+}
+
+/** Perform malformed SOCKS 5 commands */
+static void
+test_socks_5_malformed_commands(void *ptr)
+{
+ SOCKS_TEST_INIT();
+
+ /* XXX: Stringified address length > MAX_SOCKS_ADDR_LEN will never happen */
+
+ /** SOCKS 5 Send CONNECT [01] to IP address 2.2.2.2:4369, with SafeSocks set
+ */
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\x01\x00\x01\x02\x02\x02\x02\x11\x11");
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks, 1),==,
+ -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_NOT_ALLOWED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
+ buf_clear(buf);
+ socks_request_clear(socks);
+
+ /* SOCKS 5 Send RESOLVE_PTR [F1] for FQDN torproject.org */
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\xF1\x00\x03\x0Etorproject.org\x11\x11");
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
+ buf_clear(buf);
+ socks_request_clear(socks);
+
+ /* XXX: len + 1 > MAX_SOCKS_ADDR_LEN (FQDN request) will never happen */
+
+ /* SOCKS 5 Send CONNECT [01] to FQDN """"".com */
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\x01\x00\x03\x09\"\"\"\"\".com\x11\x11");
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_GENERAL_ERROR,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
+
+ buf_clear(buf);
+ socks_request_clear(socks);
+
+ /* SOCKS 5 Send CONNECT [01] to address type 0x23 */
+ ADD_DATA(buf, "\x05\x01\x00");
+ ADD_DATA(buf, "\x05\x01\x00\x23\x02\x02\x02\x02\x11\x11");
+ tt_int_op(fetch_from_buf_socks(buf, socks, get_options()->TestSocks,
+ get_options()->SafeSocks),==, -1);
+
+ tt_int_op(5,==,socks->socks_version);
+ tt_int_op(10,==,socks->replylen);
+ tt_int_op(5,==,socks->reply[0]);
+ tt_int_op(SOCKS5_ADDRESS_TYPE_NOT_SUPPORTED,==,socks->reply[1]);
+ tt_int_op(1,==,socks->reply[3]);
done:
;
@@ -387,6 +505,7 @@ struct testcase_t socks_tests[] = {
SOCKSENT(5_auth_before_negotiation),
SOCKSENT(5_authenticate),
SOCKSENT(5_authenticate_with_data),
+ SOCKSENT(5_malformed_commands),
END_OF_TESTCASES
};
diff --git a/src/test/test_status.c b/src/test/test_status.c
index 46dd473132..8bc0152ffb 100644
--- a/src/test/test_status.c
+++ b/src/test/test_status.c
@@ -30,27 +30,24 @@
* global circuits.
*/
-struct global_circuitlist_s mock_global_circuitlist =
- TOR_LIST_HEAD_INITIALIZER(global_circuitlist);
+static smartlist_t * mock_global_circuitlist = NULL;
-NS_DECL(struct global_circuitlist_s *, circuit_get_global_list, (void));
+NS_DECL(smartlist_t *, circuit_get_global_list, (void));
static void
NS(test_main)(void *arg)
{
/* Choose origin_circuit_t wlog. */
origin_circuit_t *mock_circuit1, *mock_circuit2;
- circuit_t *circ, *tmp;
int expected_circuits = 2, actual_circuits;
(void)arg;
mock_circuit1 = tor_malloc_zero(sizeof(origin_circuit_t));
mock_circuit2 = tor_malloc_zero(sizeof(origin_circuit_t));
- TOR_LIST_INSERT_HEAD(
- &mock_global_circuitlist, TO_CIRCUIT(mock_circuit1), head);
- TOR_LIST_INSERT_HEAD(
- &mock_global_circuitlist, TO_CIRCUIT(mock_circuit2), head);
+ mock_global_circuitlist = smartlist_new();
+ smartlist_add(mock_global_circuitlist, TO_CIRCUIT(mock_circuit1));
+ smartlist_add(mock_global_circuitlist, TO_CIRCUIT(mock_circuit2));
NS_MOCK(circuit_get_global_list);
@@ -58,17 +55,18 @@ NS(test_main)(void *arg)
tt_assert(expected_circuits == actual_circuits);
- done:
- TOR_LIST_FOREACH_SAFE(
- circ, NS(circuit_get_global_list)(), head, tmp);
- tor_free(circ);
- NS_UNMOCK(circuit_get_global_list);
+ done:
+ tor_free(mock_circuit1);
+ tor_free(mock_circuit2);
+ smartlist_free(mock_global_circuitlist);
+ mock_global_circuitlist = NULL;
+ NS_UNMOCK(circuit_get_global_list);
}
-static struct global_circuitlist_s *
+static smartlist_t *
NS(circuit_get_global_list)(void)
{
- return &mock_global_circuitlist;
+ return mock_global_circuitlist;
}
#undef NS_SUBMODULE
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 3a1ebb89a8..04dfe64f5a 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -1,6 +1,6 @@
/* Copyright (c) 2001-2004, Roger Dingledine.
* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson.
- * Copyright (c) 2007-2013, The Tor Project, Inc. */
+ * Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -22,6 +22,7 @@
#include <tchar.h>
#endif
#include <math.h>
+#include <ctype.h>
/* XXXX this is a minimal wrapper to make the unit tests compile with the
* changed tor_timegm interface. */
@@ -64,8 +65,8 @@ test_util_read_until_eof_impl(const char *fname, size_t file_len,
else
tt_int_op(sz, ==, file_len);
- test_mem_op(test_str, ==, str, sz);
- test_assert(str[sz] == '\0');
+ tt_mem_op(test_str, ==, str, sz);
+ tt_int_op(str[sz], ==, '\0');
done:
unlink(fifo_name);
@@ -87,6 +88,20 @@ test_util_read_file_eof_tiny_limit(void *arg)
}
static void
+test_util_read_file_eof_one_loop_a(void *arg)
+{
+ (void)arg;
+ test_util_read_until_eof_impl("tor_test_fifo_1ka", 1024, 1023);
+}
+
+static void
+test_util_read_file_eof_one_loop_b(void *arg)
+{
+ (void)arg;
+ test_util_read_until_eof_impl("tor_test_fifo_1kb", 1024, 1024);
+}
+
+static void
test_util_read_file_eof_two_loops(void *arg)
{
(void)arg;
@@ -98,6 +113,14 @@ test_util_read_file_eof_two_loops(void *arg)
}
static void
+test_util_read_file_eof_two_loops_b(void *arg)
+{
+ (void)arg;
+
+ test_util_read_until_eof_impl("tor_test_fifo_2kb", 2048, 2048);
+}
+
+static void
test_util_read_file_eof_zero_bytes(void *arg)
{
(void)arg;
@@ -155,7 +178,7 @@ test_util_write_chunks_to_file(void *arg)
str = read_file_to_str(fname, RFTS_BIN, &st);
tt_assert(str != NULL);
tt_u64_op((uint64_t)st.st_size, ==, data_str_len);
- test_mem_op(data_str, ==, str, data_str_len);
+ tt_mem_op(data_str, ==, str, data_str_len);
tor_free(str);
// assert that the tempfile is removed (should not leave artifacts)
@@ -186,14 +209,14 @@ test_util_write_chunks_to_file(void *arg)
str = read_file_to_str(fname, RFTS_BIN, &st);
tt_assert(str != NULL);
tt_u64_op((uint64_t)st.st_size, ==, data_str_len);
- test_mem_op(data_str, ==, str, data_str_len);
+ tt_mem_op(data_str, ==, str, data_str_len);
tor_free(str);
// assert the tempfile still contains the known string
str = read_file_to_str(tempname, RFTS_BIN, &st);
tt_assert(str != NULL);
tt_u64_op((uint64_t)st.st_size, ==, temp_str_len);
- test_mem_op(temp_str, ==, str, temp_str_len);
+ tt_mem_op(temp_str, ==, str, temp_str_len);
done:
unlink(fname);
@@ -206,11 +229,24 @@ test_util_write_chunks_to_file(void *arg)
tor_free(temp_str);
}
+#define _TFE(a, b, f) tt_int_op((a).f, ==, (b).f)
+/** test the minimum set of struct tm fields needed for a unique epoch value
+ * this is also the set we use to test tor_timegm */
+#define TM_EQUAL(a, b) \
+ TT_STMT_BEGIN \
+ _TFE(a, b, tm_year); \
+ _TFE(a, b, tm_mon ); \
+ _TFE(a, b, tm_mday); \
+ _TFE(a, b, tm_hour); \
+ _TFE(a, b, tm_min ); \
+ _TFE(a, b, tm_sec ); \
+ TT_STMT_END
+
static void
-test_util_time(void)
+test_util_time(void *arg)
{
struct timeval start, end;
- struct tm a_time;
+ struct tm a_time, b_time;
char timestr[128];
time_t t_res;
int i;
@@ -218,117 +254,349 @@ test_util_time(void)
/* Test tv_udiff */
+ (void)arg;
start.tv_sec = 5;
start.tv_usec = 5000;
end.tv_sec = 5;
end.tv_usec = 5000;
- test_eq(0L, tv_udiff(&start, &end));
+ tt_int_op(0L,==, tv_udiff(&start, &end));
end.tv_usec = 7000;
- test_eq(2000L, tv_udiff(&start, &end));
+ tt_int_op(2000L,==, tv_udiff(&start, &end));
end.tv_sec = 6;
- test_eq(1002000L, tv_udiff(&start, &end));
+ tt_int_op(1002000L,==, tv_udiff(&start, &end));
end.tv_usec = 0;
- test_eq(995000L, tv_udiff(&start, &end));
+ tt_int_op(995000L,==, tv_udiff(&start, &end));
end.tv_sec = 4;
- test_eq(-1005000L, tv_udiff(&start, &end));
+ tt_int_op(-1005000L,==, tv_udiff(&start, &end));
- /* Test tor_timegm */
+ /* Test tor_timegm & tor_gmtime_r */
/* The test values here are confirmed to be correct on a platform
- * with a working timegm. */
+ * with a working timegm & gmtime_r. */
+
+ /* Start with known-zero a_time and b_time.
+ * This avoids passing uninitialised values to TM_EQUAL in a_time.
+ * Zeroing may not be needed for b_time, as long as tor_gmtime_r
+ * never reads the existing values in the structure.
+ * But we really don't want intermittently failing tests. */
+ memset(&a_time, 0, sizeof(struct tm));
+ memset(&b_time, 0, sizeof(struct tm));
+
a_time.tm_year = 2003-1900;
a_time.tm_mon = 7;
a_time.tm_mday = 30;
a_time.tm_hour = 6;
a_time.tm_min = 14;
a_time.tm_sec = 55;
- test_eq((time_t) 1062224095UL, tor_timegm(&a_time));
+ t_res = 1062224095UL;
+ tt_int_op(t_res, ==, tor_timegm(&a_time));
+ tor_gmtime_r(&t_res, &b_time);
+ TM_EQUAL(a_time, b_time);
+
a_time.tm_year = 2004-1900; /* Try a leap year, after feb. */
- test_eq((time_t) 1093846495UL, tor_timegm(&a_time));
+ t_res = 1093846495UL;
+ tt_int_op(t_res, ==, tor_timegm(&a_time));
+ tor_gmtime_r(&t_res, &b_time);
+ TM_EQUAL(a_time, b_time);
+
a_time.tm_mon = 1; /* Try a leap year, in feb. */
a_time.tm_mday = 10;
- test_eq((time_t) 1076393695UL, tor_timegm(&a_time));
+ t_res = 1076393695UL;
+ tt_int_op(t_res, ==, tor_timegm(&a_time));
+ tor_gmtime_r(&t_res, &b_time);
+ TM_EQUAL(a_time, b_time);
+
a_time.tm_mon = 0;
- a_time.tm_mday = 10;
- test_eq((time_t) 1073715295UL, tor_timegm(&a_time));
+ t_res = 1073715295UL;
+ tt_int_op(t_res, ==, tor_timegm(&a_time));
+ tor_gmtime_r(&t_res, &b_time);
+ TM_EQUAL(a_time, b_time);
+
+ /* Test tor_timegm out of range */
+
+ /* year */
+
+ /* Wrong year < 1970 */
+ a_time.tm_year = 1969-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = -1-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+#if SIZEOF_INT == 4 || SIZEOF_INT == 8
+ a_time.tm_year = -1*(1 << 16);
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* one of the smallest tm_year values my 64 bit system supports:
+ * t_res = -9223372036854775LL without clamping */
+ a_time.tm_year = -292275055-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = INT32_MIN;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+#endif
+
+#if SIZEOF_INT == 8
+ a_time.tm_year = -1*(1 << 48);
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* while unlikely, the system's gmtime(_r) could return
+ * a "correct" retrospective gregorian negative year value,
+ * which I'm pretty sure is:
+ * -1*(2^63)/60/60/24*2000/730485 + 1970 = -292277022657
+ * 730485 is the number of days in two millenia, including leap days */
+ a_time.tm_year = -292277022657-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = INT64_MIN;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+#endif
+
+ /* Wrong year >= INT32_MAX - 1900 */
+#if SIZEOF_INT == 4 || SIZEOF_INT == 8
+ a_time.tm_year = INT32_MAX-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = INT32_MAX;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+#endif
+
+#if SIZEOF_INT == 8
+ /* one of the largest tm_year values my 64 bit system supports */
+ a_time.tm_year = 292278994-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* while unlikely, the system's gmtime(_r) could return
+ * a "correct" proleptic gregorian year value,
+ * which I'm pretty sure is:
+ * (2^63-1)/60/60/24*2000/730485 + 1970 = 292277026596
+ * 730485 is the number of days in two millenia, including leap days */
+ a_time.tm_year = 292277026596-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = INT64_MAX-1900;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = INT64_MAX;
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+#endif
+
+ /* month */
+ a_time.tm_year = 2007-1900; /* restore valid year */
+
a_time.tm_mon = 12; /* Wrong month, it's 0-based */
- a_time.tm_mday = 10;
- test_eq((time_t) -1, tor_timegm(&a_time));
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
a_time.tm_mon = -1; /* Wrong month */
- a_time.tm_mday = 10;
- test_eq((time_t) -1, tor_timegm(&a_time));
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* day */
+ a_time.tm_mon = 6; /* Try July */
+ a_time.tm_mday = 32; /* Wrong day */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_mon = 5; /* Try June */
+ a_time.tm_mday = 31; /* Wrong day */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = 2008-1900; /* Try a leap year */
+ a_time.tm_mon = 1; /* in feb. */
+ a_time.tm_mday = 30; /* Wrong day */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_year = 2011-1900; /* Try a non-leap year */
+ a_time.tm_mon = 1; /* in feb. */
+ a_time.tm_mday = 29; /* Wrong day */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_mday = 0; /* Wrong day, it's 1-based (to be different) */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* hour */
+ a_time.tm_mday = 3; /* restore valid month day */
+
+ a_time.tm_hour = 24; /* Wrong hour, it's 0-based */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_hour = -1; /* Wrong hour */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* minute */
+ a_time.tm_hour = 22; /* restore valid hour */
+
+ a_time.tm_min = 60; /* Wrong minute, it's 0-based */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_min = -1; /* Wrong minute */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* second */
+ a_time.tm_min = 37; /* restore valid minute */
+
+ a_time.tm_sec = 61; /* Wrong second: 0-based with leap seconds */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ a_time.tm_sec = -1; /* Wrong second */
+ tt_int_op((time_t) -1,==, tor_timegm(&a_time));
+
+ /* Test tor_gmtime_r out of range */
+
+ /* time_t < 0 yields a year clamped to 1 or 1970,
+ * depending on whether the implementation of the system gmtime(_r)
+ * sets struct tm (1) or not (1970) */
+ t_res = -1;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (1970-1900) ||
+ b_time.tm_year == (1969-1900));
+
+ if (sizeof(time_t) == 4 || sizeof(time_t) == 8) {
+ t_res = -1*(1 << 30);
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (1970-1900) ||
+ b_time.tm_year == (1935-1900));
+
+ t_res = INT32_MIN;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (1970-1900) ||
+ b_time.tm_year == (1901-1900));
+ }
+
+#if SIZEOF_TIME_T == 8
+ {
+ /* one of the smallest tm_year values my 64 bit system supports:
+ * b_time.tm_year == (-292275055LL-1900LL) without clamping */
+ t_res = -9223372036854775LL;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (1970-1900) ||
+ b_time.tm_year == (1-1900));
+
+ /* while unlikely, the system's gmtime(_r) could return
+ * a "correct" retrospective gregorian negative year value,
+ * which I'm pretty sure is:
+ * -1*(2^63)/60/60/24*2000/730485 + 1970 = -292277022657
+ * 730485 is the number of days in two millenia, including leap days
+ * (int64_t)b_time.tm_year == (-292277022657LL-1900LL) without clamping */
+ t_res = INT64_MIN;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (1970-1900) ||
+ b_time.tm_year == (1-1900));
+ }
+#endif
+
+ /* time_t >= INT_MAX yields a year clamped to 2037 or 9999,
+ * depending on whether the implementation of the system gmtime(_r)
+ * sets struct tm (9999) or not (2037) */
+#if SIZEOF_TIME_T == 4 || SIZEOF_TIME_T == 8
+ {
+ t_res = 3*(1 << 29);
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (2021-1900));
+
+ t_res = INT32_MAX;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (2037-1900) ||
+ b_time.tm_year == (2038-1900));
+ }
+#endif
+
+#if SIZEOF_TIME_T == 8
+ {
+ /* one of the largest tm_year values my 64 bit system supports:
+ * b_time.tm_year == (292278994L-1900L) without clamping */
+ t_res = 9223372036854775LL;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (2037-1900) ||
+ b_time.tm_year == (9999-1900));
+
+ /* while unlikely, the system's gmtime(_r) could return
+ * a "correct" proleptic gregorian year value,
+ * which I'm pretty sure is:
+ * (2^63-1)/60/60/24*2000/730485 + 1970 = 292277026596
+ * 730485 is the number of days in two millenia, including leap days
+ * (int64_t)b_time.tm_year == (292277026596L-1900L) without clamping */
+ t_res = INT64_MAX;
+ tor_gmtime_r(&t_res, &b_time);
+ tt_assert(b_time.tm_year == (2037-1900) ||
+ b_time.tm_year == (9999-1900));
+ }
+#endif
/* Test {format,parse}_rfc1123_time */
format_rfc1123_time(timestr, 0);
- test_streq("Thu, 01 Jan 1970 00:00:00 GMT", timestr);
+ tt_str_op("Thu, 01 Jan 1970 00:00:00 GMT",==, timestr);
format_rfc1123_time(timestr, (time_t)1091580502UL);
- test_streq("Wed, 04 Aug 2004 00:48:22 GMT", timestr);
+ tt_str_op("Wed, 04 Aug 2004 00:48:22 GMT",==, timestr);
t_res = 0;
i = parse_rfc1123_time(timestr, &t_res);
- test_eq(0,i);
- test_eq(t_res, (time_t)1091580502UL);
+ tt_int_op(0,==, i);
+ tt_int_op(t_res,==, (time_t)1091580502UL);
/* The timezone doesn't matter */
t_res = 0;
- test_eq(0, parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res));
- test_eq(t_res, (time_t)1091580502UL);
- test_eq(-1, parse_rfc1123_time("Wed, zz Aug 2004 99-99x99 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 32 Mar 2011 00:00:00 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 2011 24:00:00 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 2011 23:60:00 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:62 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 1969 23:59:59 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Ene 2011 23:59:59 GMT", &t_res));
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:59 GM", &t_res));
-
-#if 0
- /* This fails, I imagine it's important and should be fixed? */
- test_eq(-1, parse_rfc1123_time("Wed, 29 Feb 2011 16:00:00 GMT", &t_res));
- /* Why is this string valid (ie. the test fails because it doesn't
- return -1)? */
- test_eq(-1, parse_rfc1123_time("Wed, 30 Mar 2011 23:59:61 GMT", &t_res));
-#endif
+ tt_int_op(0,==, parse_rfc1123_time("Wed, 04 Aug 2004 00:48:22 ZUL", &t_res));
+ tt_int_op(t_res,==, (time_t)1091580502UL);
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, zz Aug 2004 99-99x99 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 32 Mar 2011 00:00:00 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 2011 24:00:00 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 2011 23:60:00 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 2011 23:59:62 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 1969 23:59:59 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Ene 2011 23:59:59 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 2011 23:59:59 GM", &t_res));
+
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 29 Feb 2011 16:00:00 GMT", &t_res));
+ tt_int_op(-1,==,
+ parse_rfc1123_time("Wed, 30 Mar 2011 23:59:61 GMT", &t_res));
/* Test parse_iso_time */
t_res = 0;
i = parse_iso_time("", &t_res);
- test_eq(-1, i);
+ tt_int_op(-1,==, i);
t_res = 0;
i = parse_iso_time("2004-08-32 00:48:22", &t_res);
- test_eq(-1, i);
+ tt_int_op(-1,==, i);
t_res = 0;
i = parse_iso_time("1969-08-03 00:48:22", &t_res);
- test_eq(-1, i);
+ tt_int_op(-1,==, i);
t_res = 0;
i = parse_iso_time("2004-08-04 00:48:22", &t_res);
- test_eq(0,i);
- test_eq(t_res, (time_t)1091580502UL);
+ tt_int_op(0,==, i);
+ tt_int_op(t_res,==, (time_t)1091580502UL);
t_res = 0;
i = parse_iso_time("2004-8-4 0:48:22", &t_res);
- test_eq(0, i);
- test_eq(t_res, (time_t)1091580502UL);
- test_eq(-1, parse_iso_time("2004-08-zz 99-99x99 GMT", &t_res));
- test_eq(-1, parse_iso_time("2011-03-32 00:00:00 GMT", &t_res));
- test_eq(-1, parse_iso_time("2011-03-30 24:00:00 GMT", &t_res));
- test_eq(-1, parse_iso_time("2011-03-30 23:60:00 GMT", &t_res));
- test_eq(-1, parse_iso_time("2011-03-30 23:59:62 GMT", &t_res));
- test_eq(-1, parse_iso_time("1969-03-30 23:59:59 GMT", &t_res));
- test_eq(-1, parse_iso_time("2011-00-30 23:59:59 GMT", &t_res));
- test_eq(-1, parse_iso_time("2147483647-08-29 14:00:00", &t_res));
- test_eq(-1, parse_iso_time("2011-03-30 23:59", &t_res));
+ tt_int_op(0,==, i);
+ tt_int_op(t_res,==, (time_t)1091580502UL);
+ tt_int_op(-1,==, parse_iso_time("2004-08-zz 99-99x99 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-03-32 00:00:00 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-03-30 24:00:00 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-03-30 23:60:00 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-03-30 23:59:62 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("1969-03-30 23:59:59 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-00-30 23:59:59 GMT", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2147483647-08-29 14:00:00", &t_res));
+ tt_int_op(-1,==, parse_iso_time("2011-03-30 23:59", &t_res));
/* Test tor_gettimeofday */
@@ -348,7 +616,7 @@ test_util_time(void)
tv.tv_sec = (time_t)1326296338;
tv.tv_usec = 3060;
format_iso_time(timestr, (time_t)tv.tv_sec);
- test_streq("2012-01-11 15:38:58", timestr);
+ tt_str_op("2012-01-11 15:38:58",==, timestr);
/* The output of format_local_iso_time will vary by timezone, and setting
our timezone for testing purposes would be a nontrivial flaky pain.
Skip this test for now.
@@ -356,11 +624,11 @@ test_util_time(void)
test_streq("2012-01-11 10:38:58", timestr);
*/
format_iso_time_nospace(timestr, (time_t)tv.tv_sec);
- test_streq("2012-01-11T15:38:58", timestr);
- test_eq(strlen(timestr), ISO_TIME_LEN);
+ tt_str_op("2012-01-11T15:38:58",==, timestr);
+ tt_int_op(strlen(timestr),==, ISO_TIME_LEN);
format_iso_time_nospace_usec(timestr, &tv);
- test_streq("2012-01-11T15:38:58.003060", timestr);
- test_eq(strlen(timestr), ISO_TIME_USEC_LEN);
+ tt_str_op("2012-01-11T15:38:58.003060",==, timestr);
+ tt_int_op(strlen(timestr),==, ISO_TIME_USEC_LEN);
done:
;
@@ -381,55 +649,66 @@ test_util_parse_http_time(void *arg)
/* Test parse_http_time */
- test_eq(-1, parse_http_time("", &a_time));
- test_eq(-1, parse_http_time("Sunday, 32 Aug 2004 00:48:22 GMT", &a_time));
- test_eq(-1, parse_http_time("Sunday, 3 Aug 1869 00:48:22 GMT", &a_time));
- test_eq(-1, parse_http_time("Sunday, 32-Aug-94 00:48:22 GMT", &a_time));
- test_eq(-1, parse_http_time("Sunday, 3-Ago-04 00:48:22", &a_time));
- test_eq(-1, parse_http_time("Sunday, August the third", &a_time));
- test_eq(-1, parse_http_time("Wednesday,,04 Aug 1994 00:48:22 GMT", &a_time));
-
- test_eq(0, parse_http_time("Wednesday, 04 Aug 1994 00:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(-1,==,
+ parse_http_time("", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Sunday, 32 Aug 2004 00:48:22 GMT", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Sunday, 3 Aug 1869 00:48:22 GMT", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Sunday, 32-Aug-94 00:48:22 GMT", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Sunday, 3-Ago-04 00:48:22", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Sunday, August the third", &a_time));
+ tt_int_op(-1,==,
+ parse_http_time("Wednesday,,04 Aug 1994 00:48:22 GMT", &a_time));
+
+ tt_int_op(0,==,
+ parse_http_time("Wednesday, 04 Aug 1994 00:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Wednesday, 4 Aug 1994 0:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==,
+ parse_http_time("Wednesday, 4 Aug 1994 0:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Miercoles, 4 Aug 1994 0:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==,
+ parse_http_time("Miercoles, 4 Aug 1994 0:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==,
+ parse_http_time("Wednesday, 04-Aug-94 00:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Wednesday, 4-Aug-94 0:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Miercoles, 4-Aug-94 0:48:22 GMT", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Wed Aug 04 00:48:22 1994", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Wed Aug 4 0:48:22 1994", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Wed Aug 4 0:48:22 1994", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time));
- test_eq((time_t)775961302UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Mie Aug 4 0:48:22 1994", &a_time));
+ tt_int_op((time_t)775961302UL,==, tor_timegm(&a_time));
T("1994-08-04 00:48:22");
- test_eq(0, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
- test_eq((time_t)1325376000UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Sun, 1 Jan 2012 00:00:00 GMT", &a_time));
+ tt_int_op((time_t)1325376000UL,==, tor_timegm(&a_time));
T("2012-01-01 00:00:00");
- test_eq(0, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
- test_eq((time_t)1356912000UL, tor_timegm(&a_time));
+ tt_int_op(0,==, parse_http_time("Mon, 31 Dec 2012 00:00:00 GMT", &a_time));
+ tt_int_op((time_t)1356912000UL,==, tor_timegm(&a_time));
T("2012-12-31 00:00:00");
- test_eq(-1, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-03-32 00:00:00 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-03-30 24:00:00 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-03-30 23:60:00 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-03-30 23:59:62 GMT", &a_time));
- test_eq(-1, parse_http_time("1969-03-30 23:59:59 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-00-30 23:59:59 GMT", &a_time));
- test_eq(-1, parse_http_time("2011-03-30 23:59", &a_time));
+ tt_int_op(-1,==, parse_http_time("2004-08-zz 99-99x99 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-03-32 00:00:00 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-03-30 24:00:00 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-03-30 23:60:00 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-03-30 23:59:62 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("1969-03-30 23:59:59 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-00-30 23:59:59 GMT", &a_time));
+ tt_int_op(-1,==, parse_http_time("2011-03-30 23:59", &a_time));
#undef T
done:
@@ -437,13 +716,14 @@ test_util_parse_http_time(void *arg)
}
static void
-test_util_config_line(void)
+test_util_config_line(void *arg)
{
char buf[1024];
char *k=NULL, *v=NULL;
const char *str;
/* Test parse_config_line_from_str */
+ (void)arg;
strlcpy(buf, "k v\n" " key value with spaces \n" "keykey val\n"
"k2\n"
"k3 \n" "\n" " \n" "#comment\n"
@@ -463,110 +743,110 @@ test_util_config_line(void)
str = buf;
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k");
- test_streq(v, "v");
+ tt_str_op(k,==, "k");
+ tt_str_op(v,==, "v");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "key value with"));
+ tt_assert(!strcmpstart(str, "key value with"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "key");
- test_streq(v, "value with spaces");
+ tt_str_op(k,==, "key");
+ tt_str_op(v,==, "value with spaces");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "keykey"));
+ tt_assert(!strcmpstart(str, "keykey"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "keykey");
- test_streq(v, "val");
+ tt_str_op(k,==, "keykey");
+ tt_str_op(v,==, "val");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "k2\n"));
+ tt_assert(!strcmpstart(str, "k2\n"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k2");
- test_streq(v, "");
+ tt_str_op(k,==, "k2");
+ tt_str_op(v,==, "");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "k3 \n"));
+ tt_assert(!strcmpstart(str, "k3 \n"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k3");
- test_streq(v, "");
+ tt_str_op(k,==, "k3");
+ tt_str_op(v,==, "");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "#comment"));
+ tt_assert(!strcmpstart(str, "#comment"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k4");
- test_streq(v, "");
+ tt_str_op(k,==, "k4");
+ tt_str_op(v,==, "");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "k5#abc"));
+ tt_assert(!strcmpstart(str, "k5#abc"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k5");
- test_streq(v, "");
+ tt_str_op(k,==, "k5");
+ tt_str_op(v,==, "");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "k6"));
+ tt_assert(!strcmpstart(str, "k6"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k6");
- test_streq(v, "val");
+ tt_str_op(k,==, "k6");
+ tt_str_op(v,==, "val");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "kseven"));
+ tt_assert(!strcmpstart(str, "kseven"));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "kseven");
- test_streq(v, "a quoted \'string");
+ tt_str_op(k,==, "kseven");
+ tt_str_op(v,==, "a quoted \'string");
tor_free(k); tor_free(v);
- test_assert(!strcmpstart(str, "k8 "));
+ tt_assert(!strcmpstart(str, "k8 "));
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k8");
- test_streq(v, "a quoted\n\"str\\ing\t\x01\x01\x01\"");
+ tt_str_op(k,==, "k8");
+ tt_str_op(v,==, "a quoted\n\"str\\ing\t\x01\x01\x01\"");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k9");
- test_streq(v, "a line that spans two lines.");
+ tt_str_op(k,==, "k9");
+ tt_str_op(v,==, "a line that spans two lines.");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k10");
- test_streq(v, "more than one continuation");
+ tt_str_op(k,==, "k10");
+ tt_str_op(v,==, "more than one continuation");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k11");
- test_streq(v, "continuation at the start");
+ tt_str_op(k,==, "k11");
+ tt_str_op(v,==, "continuation at the start");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k12");
- test_streq(v, "line with a embedded");
+ tt_str_op(k,==, "k12");
+ tt_str_op(v,==, "line with a embedded");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k13");
- test_streq(v, "continuation at the very start");
+ tt_str_op(k,==, "k13");
+ tt_str_op(v,==, "continuation at the very start");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k14");
- test_streq(v, "a line that has a comment and" );
+ tt_str_op(k,==, "k14");
+ tt_str_op(v,==, "a line that has a comment and" );
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k15");
- test_streq(v, "this should be the next new line");
+ tt_str_op(k,==, "k15");
+ tt_str_op(v,==, "this should be the next new line");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k16");
- test_streq(v, "a line that has a comment and" );
+ tt_str_op(k,==, "k16");
+ tt_str_op(v,==, "a line that has a comment and" );
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k17");
- test_streq(v, "this should be the next new line");
+ tt_str_op(k,==, "k17");
+ tt_str_op(v,==, "this should be the next new line");
tor_free(k); tor_free(v);
- test_streq(str, "");
+ tt_str_op(str,==, "");
done:
tor_free(k);
@@ -574,7 +854,7 @@ test_util_config_line(void)
}
static void
-test_util_config_line_quotes(void)
+test_util_config_line_quotes(void *arg)
{
char buf1[1024];
char buf2[128];
@@ -584,6 +864,7 @@ test_util_config_line_quotes(void)
const char *str;
/* Test parse_config_line_from_str */
+ (void)arg;
strlcpy(buf1, "kTrailingSpace \"quoted value\" \n"
"kTrailingGarbage \"quoted value\"trailing garbage\n"
, sizeof(buf1));
@@ -596,30 +877,30 @@ test_util_config_line_quotes(void)
str = buf1;
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "kTrailingSpace");
- test_streq(v, "quoted value");
+ tt_str_op(k,==, "kTrailingSpace");
+ tt_str_op(v,==, "quoted value");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
str = buf2;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
str = buf3;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
str = buf4;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
done:
@@ -628,13 +909,14 @@ test_util_config_line_quotes(void)
}
static void
-test_util_config_line_comment_character(void)
+test_util_config_line_comment_character(void *arg)
{
char buf[1024];
char *k=NULL, *v=NULL;
const char *str;
/* Test parse_config_line_from_str */
+ (void)arg;
strlcpy(buf, "k1 \"# in quotes\"\n"
"k2 some value # some comment\n"
"k3 /home/user/myTorNetwork#2\n" /* Testcase for #1323 */
@@ -642,16 +924,16 @@ test_util_config_line_comment_character(void)
str = buf;
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k1");
- test_streq(v, "# in quotes");
+ tt_str_op(k,==, "k1");
+ tt_str_op(v,==, "# in quotes");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "k2");
- test_streq(v, "some value");
+ tt_str_op(k,==, "k2");
+ tt_str_op(v,==, "some value");
tor_free(k); tor_free(v);
- test_streq(str, "k3 /home/user/myTorNetwork#2\n");
+ tt_str_op(str,==, "k3 /home/user/myTorNetwork#2\n");
#if 0
str = parse_config_line_from_str(str, &k, &v);
@@ -668,7 +950,7 @@ test_util_config_line_comment_character(void)
}
static void
-test_util_config_line_escaped_content(void)
+test_util_config_line_escaped_content(void *arg)
{
char buf1[1024];
char buf2[128];
@@ -680,6 +962,7 @@ test_util_config_line_escaped_content(void)
const char *str;
/* Test parse_config_line_from_str */
+ (void)arg;
strlcpy(buf1, "HexadecimalLower \"\\x2a\"\n"
"HexadecimalUpper \"\\x2A\"\n"
"HexadecimalUpperX \"\\X2A\"\n"
@@ -711,91 +994,91 @@ test_util_config_line_escaped_content(void)
str = buf1;
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "HexadecimalLower");
- test_streq(v, "*");
+ tt_str_op(k,==, "HexadecimalLower");
+ tt_str_op(v,==, "*");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "HexadecimalUpper");
- test_streq(v, "*");
+ tt_str_op(k,==, "HexadecimalUpper");
+ tt_str_op(v,==, "*");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "HexadecimalUpperX");
- test_streq(v, "*");
+ tt_str_op(k,==, "HexadecimalUpperX");
+ tt_str_op(v,==, "*");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "Octal");
- test_streq(v, "*");
+ tt_str_op(k,==, "Octal");
+ tt_str_op(v,==, "*");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "Newline");
- test_streq(v, "\n");
+ tt_str_op(k,==, "Newline");
+ tt_str_op(v,==, "\n");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "Tab");
- test_streq(v, "\t");
+ tt_str_op(k,==, "Tab");
+ tt_str_op(v,==, "\t");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "CarriageReturn");
- test_streq(v, "\r");
+ tt_str_op(k,==, "CarriageReturn");
+ tt_str_op(v,==, "\r");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "DoubleQuote");
- test_streq(v, "\"");
+ tt_str_op(k,==, "DoubleQuote");
+ tt_str_op(v,==, "\"");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "SimpleQuote");
- test_streq(v, "'");
+ tt_str_op(k,==, "SimpleQuote");
+ tt_str_op(v,==, "'");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "Backslash");
- test_streq(v, "\\");
+ tt_str_op(k,==, "Backslash");
+ tt_str_op(v,==, "\\");
tor_free(k); tor_free(v);
str = parse_config_line_from_str(str, &k, &v);
- test_streq(k, "Mix");
- test_streq(v, "This is a \"star\":\t'*'\nAnd second line");
+ tt_str_op(k,==, "Mix");
+ tt_str_op(v,==, "This is a \"star\":\t'*'\nAnd second line");
tor_free(k); tor_free(v);
- test_streq(str, "");
+ tt_str_op(str,==, "");
str = buf2;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
str = buf3;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
str = buf4;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
#if 0
str = buf5;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str, ==, NULL);
tor_free(k); tor_free(v);
#endif
str = buf6;
str = parse_config_line_from_str(str, &k, &v);
- test_eq_ptr(str, NULL);
+ tt_ptr_op(str,==, NULL);
tor_free(k); tor_free(v);
done:
@@ -805,46 +1088,47 @@ test_util_config_line_escaped_content(void)
#ifndef _WIN32
static void
-test_util_expand_filename(void)
+test_util_expand_filename(void *arg)
{
char *str;
+ (void)arg;
setenv("HOME", "/home/itv", 1); /* For "internal test value" */
str = expand_filename("");
- test_streq("", str);
+ tt_str_op("",==, str);
tor_free(str);
str = expand_filename("/normal/path");
- test_streq("/normal/path", str);
+ tt_str_op("/normal/path",==, str);
tor_free(str);
str = expand_filename("/normal/trailing/path/");
- test_streq("/normal/trailing/path/", str);
+ tt_str_op("/normal/trailing/path/",==, str);
tor_free(str);
str = expand_filename("~");
- test_streq("/home/itv/", str);
+ tt_str_op("/home/itv/",==, str);
tor_free(str);
str = expand_filename("$HOME/nodice");
- test_streq("$HOME/nodice", str);
+ tt_str_op("$HOME/nodice",==, str);
tor_free(str);
str = expand_filename("~/");
- test_streq("/home/itv/", str);
+ tt_str_op("/home/itv/",==, str);
tor_free(str);
str = expand_filename("~/foobarqux");
- test_streq("/home/itv/foobarqux", str);
+ tt_str_op("/home/itv/foobarqux",==, str);
tor_free(str);
str = expand_filename("~/../../etc/passwd");
- test_streq("/home/itv/../../etc/passwd", str);
+ tt_str_op("/home/itv/../../etc/passwd",==, str);
tor_free(str);
str = expand_filename("~/trailing/");
- test_streq("/home/itv/trailing/", str);
+ tt_str_op("/home/itv/trailing/",==, str);
tor_free(str);
/* Ideally we'd test ~anotheruser, but that's shady to test (we'd
have to somehow inject/fake the get_user_homedir call) */
@@ -853,15 +1137,15 @@ test_util_expand_filename(void)
setenv("HOME", "/home/itv/", 1);
str = expand_filename("~");
- test_streq("/home/itv/", str);
+ tt_str_op("/home/itv/",==, str);
tor_free(str);
str = expand_filename("~/");
- test_streq("/home/itv/", str);
+ tt_str_op("/home/itv/",==, str);
tor_free(str);
str = expand_filename("~/foo");
- test_streq("/home/itv/foo", str);
+ tt_str_op("/home/itv/foo",==, str);
tor_free(str);
/* Try with empty $HOME */
@@ -869,15 +1153,15 @@ test_util_expand_filename(void)
setenv("HOME", "", 1);
str = expand_filename("~");
- test_streq("/", str);
+ tt_str_op("/",==, str);
tor_free(str);
str = expand_filename("~/");
- test_streq("/", str);
+ tt_str_op("/",==, str);
tor_free(str);
str = expand_filename("~/foobar");
- test_streq("/foobar", str);
+ tt_str_op("/foobar",==, str);
tor_free(str);
/* Try with $HOME unset */
@@ -885,15 +1169,15 @@ test_util_expand_filename(void)
unsetenv("HOME");
str = expand_filename("~");
- test_streq("/", str);
+ tt_str_op("/",==, str);
tor_free(str);
str = expand_filename("~/");
- test_streq("/", str);
+ tt_str_op("/",==, str);
tor_free(str);
str = expand_filename("~/foobar");
- test_streq("/foobar", str);
+ tt_str_op("/foobar",==, str);
tor_free(str);
done:
@@ -903,37 +1187,38 @@ test_util_expand_filename(void)
/** Test tor_escape_str_for_pt_args(). */
static void
-test_util_escape_string_socks(void)
+test_util_escape_string_socks(void *arg)
{
char *escaped_string = NULL;
/** Simple backslash escape. */
+ (void)arg;
escaped_string = tor_escape_str_for_pt_args("This is a backslash: \\",";\\");
- test_assert(escaped_string);
- test_streq(escaped_string, "This is a backslash: \\\\");
+ tt_assert(escaped_string);
+ tt_str_op(escaped_string,==, "This is a backslash: \\\\");
tor_free(escaped_string);
/** Simple semicolon escape. */
escaped_string = tor_escape_str_for_pt_args("First rule:Do not use ;",";\\");
- test_assert(escaped_string);
- test_streq(escaped_string, "First rule:Do not use \\;");
+ tt_assert(escaped_string);
+ tt_str_op(escaped_string,==, "First rule:Do not use \\;");
tor_free(escaped_string);
/** Empty string. */
escaped_string = tor_escape_str_for_pt_args("", ";\\");
- test_assert(escaped_string);
- test_streq(escaped_string, "");
+ tt_assert(escaped_string);
+ tt_str_op(escaped_string,==, "");
tor_free(escaped_string);
/** Escape all characters. */
escaped_string = tor_escape_str_for_pt_args(";\\;\\", ";\\");
- test_assert(escaped_string);
- test_streq(escaped_string, "\\;\\\\\\;\\\\");
+ tt_assert(escaped_string);
+ tt_str_op(escaped_string,==, "\\;\\\\\\;\\\\");
tor_free(escaped_string);
escaped_string = tor_escape_str_for_pt_args(";", ";\\");
- test_assert(escaped_string);
- test_streq(escaped_string, "\\;");
+ tt_assert(escaped_string);
+ tt_str_op(escaped_string,==, "\\;");
tor_free(escaped_string);
done:
@@ -944,288 +1229,290 @@ static void
test_util_string_is_key_value(void *ptr)
{
(void)ptr;
- test_assert(string_is_key_value(LOG_WARN, "key=value"));
- test_assert(string_is_key_value(LOG_WARN, "k=v"));
- test_assert(string_is_key_value(LOG_WARN, "key="));
- test_assert(string_is_key_value(LOG_WARN, "x="));
- test_assert(string_is_key_value(LOG_WARN, "xx="));
- test_assert(!string_is_key_value(LOG_WARN, "=value"));
- test_assert(!string_is_key_value(LOG_WARN, "=x"));
- test_assert(!string_is_key_value(LOG_WARN, "="));
+ tt_assert(string_is_key_value(LOG_WARN, "key=value"));
+ tt_assert(string_is_key_value(LOG_WARN, "k=v"));
+ tt_assert(string_is_key_value(LOG_WARN, "key="));
+ tt_assert(string_is_key_value(LOG_WARN, "x="));
+ tt_assert(string_is_key_value(LOG_WARN, "xx="));
+ tt_assert(!string_is_key_value(LOG_WARN, "=value"));
+ tt_assert(!string_is_key_value(LOG_WARN, "=x"));
+ tt_assert(!string_is_key_value(LOG_WARN, "="));
/* ??? */
- /* test_assert(!string_is_key_value(LOG_WARN, "===")); */
+ /* tt_assert(!string_is_key_value(LOG_WARN, "===")); */
done:
;
}
/** Test basic string functionality. */
static void
-test_util_strmisc(void)
+test_util_strmisc(void *arg)
{
char buf[1024];
int i;
char *cp, *cp_tmp = NULL;
/* Test strl operations */
- test_eq(5, strlcpy(buf, "Hello", 0));
- test_eq(5, strlcpy(buf, "Hello", 10));
- test_streq(buf, "Hello");
- test_eq(5, strlcpy(buf, "Hello", 6));
- test_streq(buf, "Hello");
- test_eq(5, strlcpy(buf, "Hello", 5));
- test_streq(buf, "Hell");
+ (void)arg;
+ tt_int_op(5,==, strlcpy(buf, "Hello", 0));
+ tt_int_op(5,==, strlcpy(buf, "Hello", 10));
+ tt_str_op(buf,==, "Hello");
+ tt_int_op(5,==, strlcpy(buf, "Hello", 6));
+ tt_str_op(buf,==, "Hello");
+ tt_int_op(5,==, strlcpy(buf, "Hello", 5));
+ tt_str_op(buf,==, "Hell");
strlcpy(buf, "Hello", sizeof(buf));
- test_eq(10, strlcat(buf, "Hello", 5));
+ tt_int_op(10,==, strlcat(buf, "Hello", 5));
/* Test strstrip() */
strlcpy(buf, "Testing 1 2 3", sizeof(buf));
tor_strstrip(buf, ",!");
- test_streq(buf, "Testing 1 2 3");
+ tt_str_op(buf,==, "Testing 1 2 3");
strlcpy(buf, "!Testing 1 2 3?", sizeof(buf));
tor_strstrip(buf, "!? ");
- test_streq(buf, "Testing123");
+ tt_str_op(buf,==, "Testing123");
strlcpy(buf, "!!!Testing 1 2 3??", sizeof(buf));
tor_strstrip(buf, "!? ");
- test_streq(buf, "Testing123");
+ tt_str_op(buf,==, "Testing123");
/* Test parse_long */
/* Empty/zero input */
- test_eq(0L, tor_parse_long("",10,0,100,&i,NULL));
- test_eq(0, i);
- test_eq(0L, tor_parse_long("0",10,0,100,&i,NULL));
- test_eq(1, i);
+ tt_int_op(0L,==, tor_parse_long("",10,0,100,&i,NULL));
+ tt_int_op(0,==, i);
+ tt_int_op(0L,==, tor_parse_long("0",10,0,100,&i,NULL));
+ tt_int_op(1,==, i);
/* Normal cases */
- test_eq(10L, tor_parse_long("10",10,0,100,&i,NULL));
- test_eq(1, i);
- test_eq(10L, tor_parse_long("10",10,0,10,&i,NULL));
- test_eq(1, i);
- test_eq(10L, tor_parse_long("10",10,10,100,&i,NULL));
- test_eq(1, i);
- test_eq(-50L, tor_parse_long("-50",10,-100,100,&i,NULL));
- test_eq(1, i);
- test_eq(-50L, tor_parse_long("-50",10,-100,0,&i,NULL));
- test_eq(1, i);
- test_eq(-50L, tor_parse_long("-50",10,-50,0,&i,NULL));
- test_eq(1, i);
+ tt_int_op(10L,==, tor_parse_long("10",10,0,100,&i,NULL));
+ tt_int_op(1,==, i);
+ tt_int_op(10L,==, tor_parse_long("10",10,0,10,&i,NULL));
+ tt_int_op(1,==, i);
+ tt_int_op(10L,==, tor_parse_long("10",10,10,100,&i,NULL));
+ tt_int_op(1,==, i);
+ tt_int_op(-50L,==, tor_parse_long("-50",10,-100,100,&i,NULL));
+ tt_int_op(1,==, i);
+ tt_int_op(-50L,==, tor_parse_long("-50",10,-100,0,&i,NULL));
+ tt_int_op(1,==, i);
+ tt_int_op(-50L,==, tor_parse_long("-50",10,-50,0,&i,NULL));
+ tt_int_op(1,==, i);
/* Extra garbage */
- test_eq(0L, tor_parse_long("10m",10,0,100,&i,NULL));
- test_eq(0, i);
- test_eq(0L, tor_parse_long("-50 plus garbage",10,-100,100,&i,NULL));
- test_eq(0, i);
- test_eq(10L, tor_parse_long("10m",10,0,100,&i,&cp));
- test_eq(1, i);
- test_streq(cp, "m");
- test_eq(-50L, tor_parse_long("-50 plus garbage",10,-100,100,&i,&cp));
- test_eq(1, i);
- test_streq(cp, " plus garbage");
+ tt_int_op(0L,==, tor_parse_long("10m",10,0,100,&i,NULL));
+ tt_int_op(0,==, i);
+ tt_int_op(0L,==, tor_parse_long("-50 plus garbage",10,-100,100,&i,NULL));
+ tt_int_op(0,==, i);
+ tt_int_op(10L,==, tor_parse_long("10m",10,0,100,&i,&cp));
+ tt_int_op(1,==, i);
+ tt_str_op(cp,==, "m");
+ tt_int_op(-50L,==, tor_parse_long("-50 plus garbage",10,-100,100,&i,&cp));
+ tt_int_op(1,==, i);
+ tt_str_op(cp,==, " plus garbage");
/* Out of bounds */
- test_eq(0L, tor_parse_long("10",10,50,100,&i,NULL));
- test_eq(0, i);
- test_eq(0L, tor_parse_long("-50",10,0,100,&i,NULL));
- test_eq(0, i);
+ tt_int_op(0L,==, tor_parse_long("10",10,50,100,&i,NULL));
+ tt_int_op(0,==, i);
+ tt_int_op(0L,==, tor_parse_long("-50",10,0,100,&i,NULL));
+ tt_int_op(0,==, i);
/* Base different than 10 */
- test_eq(2L, tor_parse_long("10",2,0,100,NULL,NULL));
- test_eq(0L, tor_parse_long("2",2,0,100,NULL,NULL));
- test_eq(0L, tor_parse_long("10",-2,0,100,NULL,NULL));
- test_eq(68284L, tor_parse_long("10abc",16,0,70000,NULL,NULL));
- test_eq(68284L, tor_parse_long("10ABC",16,0,70000,NULL,NULL));
- test_eq(0, tor_parse_long("10ABC",-1,0,70000,&i,NULL));
- test_eq(i, 0);
+ tt_int_op(2L,==, tor_parse_long("10",2,0,100,NULL,NULL));
+ tt_int_op(0L,==, tor_parse_long("2",2,0,100,NULL,NULL));
+ tt_int_op(0L,==, tor_parse_long("10",-2,0,100,NULL,NULL));
+ tt_int_op(68284L,==, tor_parse_long("10abc",16,0,70000,NULL,NULL));
+ tt_int_op(68284L,==, tor_parse_long("10ABC",16,0,70000,NULL,NULL));
+ tt_int_op(0,==, tor_parse_long("10ABC",-1,0,70000,&i,NULL));
+ tt_int_op(i,==, 0);
/* Test parse_ulong */
- test_eq(0UL, tor_parse_ulong("",10,0,100,NULL,NULL));
- test_eq(0UL, tor_parse_ulong("0",10,0,100,NULL,NULL));
- test_eq(10UL, tor_parse_ulong("10",10,0,100,NULL,NULL));
- test_eq(0UL, tor_parse_ulong("10",10,50,100,NULL,NULL));
- test_eq(10UL, tor_parse_ulong("10",10,0,10,NULL,NULL));
- test_eq(10UL, tor_parse_ulong("10",10,10,100,NULL,NULL));
- test_eq(0UL, tor_parse_ulong("8",8,0,100,NULL,NULL));
- test_eq(50UL, tor_parse_ulong("50",10,50,100,NULL,NULL));
- test_eq(0UL, tor_parse_ulong("-50",10,-100,100,NULL,NULL));
- test_eq(0UL, tor_parse_ulong("50",-1,50,100,&i,NULL));
- test_eq(0, i);
+ tt_int_op(0UL,==, tor_parse_ulong("",10,0,100,NULL,NULL));
+ tt_int_op(0UL,==, tor_parse_ulong("0",10,0,100,NULL,NULL));
+ tt_int_op(10UL,==, tor_parse_ulong("10",10,0,100,NULL,NULL));
+ tt_int_op(0UL,==, tor_parse_ulong("10",10,50,100,NULL,NULL));
+ tt_int_op(10UL,==, tor_parse_ulong("10",10,0,10,NULL,NULL));
+ tt_int_op(10UL,==, tor_parse_ulong("10",10,10,100,NULL,NULL));
+ tt_int_op(0UL,==, tor_parse_ulong("8",8,0,100,NULL,NULL));
+ tt_int_op(50UL,==, tor_parse_ulong("50",10,50,100,NULL,NULL));
+ tt_int_op(0UL,==, tor_parse_ulong("-50",10,-100,100,NULL,NULL));
+ tt_int_op(0UL,==, tor_parse_ulong("50",-1,50,100,&i,NULL));
+ tt_int_op(0,==, i);
/* Test parse_uint64 */
- test_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
- test_eq(1, i);
- test_streq(cp, " x");
- test_assert(U64_LITERAL(12345678901) ==
+ tt_assert(U64_LITERAL(10) == tor_parse_uint64("10 x",10,0,100, &i, &cp));
+ tt_int_op(1,==, i);
+ tt_str_op(cp,==, " x");
+ tt_assert(U64_LITERAL(12345678901) ==
tor_parse_uint64("12345678901",10,0,UINT64_MAX, &i, &cp));
- test_eq(1, i);
- test_streq(cp, "");
- test_assert(U64_LITERAL(0) ==
+ tt_int_op(1,==, i);
+ tt_str_op(cp,==, "");
+ tt_assert(U64_LITERAL(0) ==
tor_parse_uint64("12345678901",10,500,INT32_MAX, &i, &cp));
- test_eq(0, i);
- test_assert(U64_LITERAL(0) ==
+ tt_int_op(0,==, i);
+ tt_assert(U64_LITERAL(0) ==
tor_parse_uint64("123",-1,0,INT32_MAX, &i, &cp));
- test_eq(0, i);
+ tt_int_op(0,==, i);
{
/* Test parse_double */
double d = tor_parse_double("10", 0, UINT64_MAX,&i,NULL);
- test_eq(1, i);
- test_assert(DBL_TO_U64(d) == 10);
+ tt_int_op(1,==, i);
+ tt_assert(DBL_TO_U64(d) == 10);
d = tor_parse_double("0", 0, UINT64_MAX,&i,NULL);
- test_eq(1, i);
- test_assert(DBL_TO_U64(d) == 0);
+ tt_int_op(1,==, i);
+ tt_assert(DBL_TO_U64(d) == 0);
d = tor_parse_double(" ", 0, UINT64_MAX,&i,NULL);
- test_eq(0, i);
+ tt_int_op(0,==, i);
d = tor_parse_double(".0a", 0, UINT64_MAX,&i,NULL);
- test_eq(0, i);
+ tt_int_op(0,==, i);
d = tor_parse_double(".0a", 0, UINT64_MAX,&i,&cp);
- test_eq(1, i);
+ tt_int_op(1,==, i);
d = tor_parse_double("-.0", 0, UINT64_MAX,&i,NULL);
- test_eq(1, i);
- test_assert(DBL_TO_U64(d) == 0);
+ tt_int_op(1,==, i);
+ tt_assert(DBL_TO_U64(d) == 0);
d = tor_parse_double("-10", -100.0, 100.0,&i,NULL);
- test_eq(1, i);
- test_eq(-10.0, d);
+ tt_int_op(1,==, i);
+ tt_int_op(-10.0,==, d);
}
{
/* Test tor_parse_* where we overflow/underflow the underlying type. */
/* This string should overflow 64-bit ints. */
#define TOOBIG "100000000000000000000000000"
- test_eq(0L, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
- test_eq(i, 0);
- test_eq(0L, tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
- test_eq(i, 0);
- test_eq(0UL, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL));
- test_eq(i, 0);
+ tt_int_op(0L,==, tor_parse_long(TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
+ tt_int_op(i,==, 0);
+ tt_int_op(0L,==,
+ tor_parse_long("-"TOOBIG, 10, LONG_MIN, LONG_MAX, &i, NULL));
+ tt_int_op(i,==, 0);
+ tt_int_op(0UL,==, tor_parse_ulong(TOOBIG, 10, 0, ULONG_MAX, &i, NULL));
+ tt_int_op(i,==, 0);
tt_u64_op(U64_LITERAL(0), ==, tor_parse_uint64(TOOBIG, 10,
0, UINT64_MAX, &i, NULL));
- test_eq(i, 0);
+ tt_int_op(i,==, 0);
}
/* Test snprintf */
/* Returning -1 when there's not enough room in the output buffer */
- test_eq(-1, tor_snprintf(buf, 0, "Foo"));
- test_eq(-1, tor_snprintf(buf, 2, "Foo"));
- test_eq(-1, tor_snprintf(buf, 3, "Foo"));
- test_neq(-1, tor_snprintf(buf, 4, "Foo"));
+ tt_int_op(-1,==, tor_snprintf(buf, 0, "Foo"));
+ tt_int_op(-1,==, tor_snprintf(buf, 2, "Foo"));
+ tt_int_op(-1,==, tor_snprintf(buf, 3, "Foo"));
+ tt_int_op(-1,!=, tor_snprintf(buf, 4, "Foo"));
/* Always NUL-terminate the output */
tor_snprintf(buf, 5, "abcdef");
- test_eq(0, buf[4]);
+ tt_int_op(0,==, buf[4]);
tor_snprintf(buf, 10, "abcdef");
- test_eq(0, buf[6]);
+ tt_int_op(0,==, buf[6]);
/* uint64 */
tor_snprintf(buf, sizeof(buf), "x!"U64_FORMAT"!x",
U64_PRINTF_ARG(U64_LITERAL(12345678901)));
- test_streq("x!12345678901!x", buf);
+ tt_str_op("x!12345678901!x",==, buf);
/* Test str{,case}cmpstart */
- test_assert(strcmpstart("abcdef", "abcdef")==0);
- test_assert(strcmpstart("abcdef", "abc")==0);
- test_assert(strcmpstart("abcdef", "abd")<0);
- test_assert(strcmpstart("abcdef", "abb")>0);
- test_assert(strcmpstart("ab", "abb")<0);
- test_assert(strcmpstart("ab", "")==0);
- test_assert(strcmpstart("ab", "ab ")<0);
- test_assert(strcasecmpstart("abcdef", "abCdEF")==0);
- test_assert(strcasecmpstart("abcDeF", "abc")==0);
- test_assert(strcasecmpstart("abcdef", "Abd")<0);
- test_assert(strcasecmpstart("Abcdef", "abb")>0);
- test_assert(strcasecmpstart("ab", "Abb")<0);
- test_assert(strcasecmpstart("ab", "")==0);
- test_assert(strcasecmpstart("ab", "ab ")<0);
+ tt_assert(strcmpstart("abcdef", "abcdef")==0);
+ tt_assert(strcmpstart("abcdef", "abc")==0);
+ tt_assert(strcmpstart("abcdef", "abd")<0);
+ tt_assert(strcmpstart("abcdef", "abb")>0);
+ tt_assert(strcmpstart("ab", "abb")<0);
+ tt_assert(strcmpstart("ab", "")==0);
+ tt_assert(strcmpstart("ab", "ab ")<0);
+ tt_assert(strcasecmpstart("abcdef", "abCdEF")==0);
+ tt_assert(strcasecmpstart("abcDeF", "abc")==0);
+ tt_assert(strcasecmpstart("abcdef", "Abd")<0);
+ tt_assert(strcasecmpstart("Abcdef", "abb")>0);
+ tt_assert(strcasecmpstart("ab", "Abb")<0);
+ tt_assert(strcasecmpstart("ab", "")==0);
+ tt_assert(strcasecmpstart("ab", "ab ")<0);
/* Test str{,case}cmpend */
- test_assert(strcmpend("abcdef", "abcdef")==0);
- test_assert(strcmpend("abcdef", "def")==0);
- test_assert(strcmpend("abcdef", "deg")<0);
- test_assert(strcmpend("abcdef", "dee")>0);
- test_assert(strcmpend("ab", "aab")>0);
- test_assert(strcasecmpend("AbcDEF", "abcdef")==0);
- test_assert(strcasecmpend("abcdef", "dEF")==0);
- test_assert(strcasecmpend("abcdef", "Deg")<0);
- test_assert(strcasecmpend("abcDef", "dee")>0);
- test_assert(strcasecmpend("AB", "abb")<0);
+ tt_assert(strcmpend("abcdef", "abcdef")==0);
+ tt_assert(strcmpend("abcdef", "def")==0);
+ tt_assert(strcmpend("abcdef", "deg")<0);
+ tt_assert(strcmpend("abcdef", "dee")>0);
+ tt_assert(strcmpend("ab", "aab")>0);
+ tt_assert(strcasecmpend("AbcDEF", "abcdef")==0);
+ tt_assert(strcasecmpend("abcdef", "dEF")==0);
+ tt_assert(strcasecmpend("abcdef", "Deg")<0);
+ tt_assert(strcasecmpend("abcDef", "dee")>0);
+ tt_assert(strcasecmpend("AB", "abb")<0);
/* Test digest_is_zero */
memset(buf,0,20);
buf[20] = 'x';
- test_assert(tor_digest_is_zero(buf));
+ tt_assert(tor_digest_is_zero(buf));
buf[19] = 'x';
- test_assert(!tor_digest_is_zero(buf));
+ tt_assert(!tor_digest_is_zero(buf));
/* Test mem_is_zero */
memset(buf,0,128);
buf[128] = 'x';
- test_assert(tor_mem_is_zero(buf, 10));
- test_assert(tor_mem_is_zero(buf, 20));
- test_assert(tor_mem_is_zero(buf, 128));
- test_assert(!tor_mem_is_zero(buf, 129));
+ tt_assert(tor_mem_is_zero(buf, 10));
+ tt_assert(tor_mem_is_zero(buf, 20));
+ tt_assert(tor_mem_is_zero(buf, 128));
+ tt_assert(!tor_mem_is_zero(buf, 129));
buf[60] = (char)255;
- test_assert(!tor_mem_is_zero(buf, 128));
+ tt_assert(!tor_mem_is_zero(buf, 128));
buf[0] = (char)1;
- test_assert(!tor_mem_is_zero(buf, 10));
+ tt_assert(!tor_mem_is_zero(buf, 10));
/* Test 'escaped' */
- test_assert(NULL == escaped(NULL));
- test_streq("\"\"", escaped(""));
- test_streq("\"abcd\"", escaped("abcd"));
- test_streq("\"\\\\ \\n\\r\\t\\\"\\'\"", escaped("\\ \n\r\t\"'"));
- test_streq("\"unnecessary \\'backslashes\\'\"",
+ tt_assert(NULL == escaped(NULL));
+ tt_str_op("\"\"",==, escaped(""));
+ tt_str_op("\"abcd\"",==, escaped("abcd"));
+ tt_str_op("\"\\\\ \\n\\r\\t\\\"\\'\"",==, escaped("\\ \n\r\t\"'"));
+ tt_str_op("\"unnecessary \\'backslashes\\'\"",==,
escaped("unnecessary \'backslashes\'"));
/* Non-printable characters appear as octal */
- test_streq("\"z\\001abc\\277d\"", escaped("z\001abc\277d"));
- test_streq("\"z\\336\\255 ;foo\"", escaped("z\xde\xad\x20;foo"));
+ tt_str_op("\"z\\001abc\\277d\"",==, escaped("z\001abc\277d"));
+ tt_str_op("\"z\\336\\255 ;foo\"",==, escaped("z\xde\xad\x20;foo"));
/* Test strndup and memdup */
{
const char *s = "abcdefghijklmnopqrstuvwxyz";
cp_tmp = tor_strndup(s, 30);
- test_streq(cp_tmp, s); /* same string, */
- test_neq_ptr(cp_tmp, s); /* but different pointers. */
+ tt_str_op(cp_tmp,==, s); /* same string, */
+ tt_ptr_op(cp_tmp,!=,s); /* but different pointers. */
tor_free(cp_tmp);
cp_tmp = tor_strndup(s, 5);
- test_streq(cp_tmp, "abcde");
+ tt_str_op(cp_tmp,==, "abcde");
tor_free(cp_tmp);
s = "a\0b\0c\0d\0e\0";
cp_tmp = tor_memdup(s,10);
- test_memeq(cp_tmp, s, 10); /* same ram, */
- test_neq_ptr(cp_tmp, s); /* but different pointers. */
+ tt_mem_op(cp_tmp,==, s, 10); /* same ram, */
+ tt_ptr_op(cp_tmp,!=,s); /* but different pointers. */
tor_free(cp_tmp);
}
/* Test str-foo functions */
cp_tmp = tor_strdup("abcdef");
- test_assert(tor_strisnonupper(cp_tmp));
+ tt_assert(tor_strisnonupper(cp_tmp));
cp_tmp[3] = 'D';
- test_assert(!tor_strisnonupper(cp_tmp));
+ tt_assert(!tor_strisnonupper(cp_tmp));
tor_strupper(cp_tmp);
- test_streq(cp_tmp, "ABCDEF");
+ tt_str_op(cp_tmp,==, "ABCDEF");
tor_strlower(cp_tmp);
- test_streq(cp_tmp, "abcdef");
- test_assert(tor_strisnonupper(cp_tmp));
- test_assert(tor_strisprint(cp_tmp));
+ tt_str_op(cp_tmp,==, "abcdef");
+ tt_assert(tor_strisnonupper(cp_tmp));
+ tt_assert(tor_strisprint(cp_tmp));
cp_tmp[3] = 3;
- test_assert(!tor_strisprint(cp_tmp));
+ tt_assert(!tor_strisprint(cp_tmp));
tor_free(cp_tmp);
/* Test memmem and memstr */
{
const char *haystack = "abcde";
- test_assert(!tor_memmem(haystack, 5, "ef", 2));
- test_eq_ptr(tor_memmem(haystack, 5, "cd", 2), haystack + 2);
- test_eq_ptr(tor_memmem(haystack, 5, "cde", 3), haystack + 2);
- test_assert(!tor_memmem(haystack, 4, "cde", 3));
+ tt_assert(!tor_memmem(haystack, 5, "ef", 2));
+ tt_ptr_op(tor_memmem(haystack, 5, "cd", 2),==, haystack + 2);
+ tt_ptr_op(tor_memmem(haystack, 5, "cde", 3),==, haystack + 2);
+ tt_assert(!tor_memmem(haystack, 4, "cde", 3));
haystack = "ababcad";
- test_eq_ptr(tor_memmem(haystack, 7, "abc", 3), haystack + 2);
- test_eq_ptr(tor_memmem(haystack, 7, "ad", 2), haystack + 5);
- test_eq_ptr(tor_memmem(haystack, 7, "cad", 3), haystack + 4);
- test_assert(!tor_memmem(haystack, 7, "dadad", 5));
- test_assert(!tor_memmem(haystack, 7, "abcdefghij", 10));
+ tt_ptr_op(tor_memmem(haystack, 7, "abc", 3),==, haystack + 2);
+ tt_ptr_op(tor_memmem(haystack, 7, "ad", 2),==, haystack + 5);
+ tt_ptr_op(tor_memmem(haystack, 7, "cad", 3),==, haystack + 4);
+ tt_assert(!tor_memmem(haystack, 7, "dadad", 5));
+ tt_assert(!tor_memmem(haystack, 7, "abcdefghij", 10));
/* memstr */
- test_eq_ptr(tor_memstr(haystack, 7, "abc"), haystack + 2);
- test_eq_ptr(tor_memstr(haystack, 7, "cad"), haystack + 4);
- test_assert(!tor_memstr(haystack, 6, "cad"));
- test_assert(!tor_memstr(haystack, 7, "cadd"));
- test_assert(!tor_memstr(haystack, 7, "fe"));
- test_assert(!tor_memstr(haystack, 7, "ababcade"));
+ tt_ptr_op(tor_memstr(haystack, 7, "abc"),==, haystack + 2);
+ tt_ptr_op(tor_memstr(haystack, 7, "cad"),==, haystack + 4);
+ tt_assert(!tor_memstr(haystack, 6, "cad"));
+ tt_assert(!tor_memstr(haystack, 7, "cadd"));
+ tt_assert(!tor_memstr(haystack, 7, "fe"));
+ tt_assert(!tor_memstr(haystack, 7, "ababcade"));
}
/* Test hex_str */
@@ -1234,19 +1521,20 @@ test_util_strmisc(void)
size_t i;
for (i = 0; i < sizeof(binary_data); ++i)
binary_data[i] = i;
- test_streq(hex_str(binary_data, 0), "");
- test_streq(hex_str(binary_data, 1), "00");
- test_streq(hex_str(binary_data, 17), "000102030405060708090A0B0C0D0E0F10");
- test_streq(hex_str(binary_data, 32),
+ tt_str_op(hex_str(binary_data, 0),==, "");
+ tt_str_op(hex_str(binary_data, 1),==, "00");
+ tt_str_op(hex_str(binary_data, 17),==,
+ "000102030405060708090A0B0C0D0E0F10");
+ tt_str_op(hex_str(binary_data, 32),==,
"000102030405060708090A0B0C0D0E0F"
"101112131415161718191A1B1C1D1E1F");
- test_streq(hex_str(binary_data, 34),
+ tt_str_op(hex_str(binary_data, 34),==,
"000102030405060708090A0B0C0D0E0F"
"101112131415161718191A1B1C1D1E1F");
/* Repeat these tests for shorter strings after longer strings
have been tried, to make sure we're correctly terminating strings */
- test_streq(hex_str(binary_data, 1), "00");
- test_streq(hex_str(binary_data, 0), "");
+ tt_str_op(hex_str(binary_data, 1),==, "00");
+ tt_str_op(hex_str(binary_data, 0),==, "");
}
/* Test strcmp_opt */
@@ -1275,20 +1563,21 @@ test_util_strmisc(void)
}
static void
-test_util_pow2(void)
+test_util_pow2(void *arg)
{
/* Test tor_log2(). */
- test_eq(tor_log2(64), 6);
- test_eq(tor_log2(65), 6);
- test_eq(tor_log2(63), 5);
- test_eq(tor_log2(0), 0); /* incorrect mathematically, but as specified */
- test_eq(tor_log2(1), 0);
- test_eq(tor_log2(2), 1);
- test_eq(tor_log2(3), 1);
- test_eq(tor_log2(4), 2);
- test_eq(tor_log2(5), 2);
- test_eq(tor_log2(U64_LITERAL(40000000000000000)), 55);
- test_eq(tor_log2(UINT64_MAX), 63);
+ (void)arg;
+ tt_int_op(tor_log2(64),==, 6);
+ tt_int_op(tor_log2(65),==, 6);
+ tt_int_op(tor_log2(63),==, 5);
+ tt_int_op(tor_log2(0),==, 0);/* incorrect mathematically, but as specified */
+ tt_int_op(tor_log2(1),==, 0);
+ tt_int_op(tor_log2(2),==, 1);
+ tt_int_op(tor_log2(3),==, 1);
+ tt_int_op(tor_log2(4),==, 2);
+ tt_int_op(tor_log2(5),==, 2);
+ tt_int_op(tor_log2(U64_LITERAL(40000000000000000)),==, 55);
+ tt_int_op(tor_log2(UINT64_MAX),==, 63);
/* Test round_to_power_of_2 */
tt_u64_op(round_to_power_of_2(120), ==, 128);
@@ -1373,7 +1662,7 @@ thread_test_func_(void* _s)
/** Run unit tests for threading logic. */
static void
-test_util_threads(void)
+test_util_threads(void *arg)
{
char *s1 = NULL, *s2 = NULL;
int done = 0, timedout = 0;
@@ -1383,6 +1672,7 @@ test_util_threads(void)
tv.tv_sec=0;
tv.tv_usec=100*1000;
#endif
+ (void)arg;
thread_test_mutex_ = tor_mutex_new();
thread_test_start1_ = tor_mutex_new();
thread_test_start2_ = tor_mutex_new();
@@ -1420,15 +1710,15 @@ test_util_threads(void)
if (timedout) {
printf("\nTimed out: %d %d", t1_count, t2_count);
- test_assert(strmap_get(thread_test_strmap_, "thread 1"));
- test_assert(strmap_get(thread_test_strmap_, "thread 2"));
- test_assert(!timedout);
+ tt_assert(strmap_get(thread_test_strmap_, "thread 1"));
+ tt_assert(strmap_get(thread_test_strmap_, "thread 2"));
+ tt_assert(!timedout);
}
/* different thread IDs. */
- test_assert(strcmp(strmap_get(thread_test_strmap_, "thread 1"),
+ tt_assert(strcmp(strmap_get(thread_test_strmap_, "thread 1"),
strmap_get(thread_test_strmap_, "thread 2")));
- test_assert(!strcmp(strmap_get(thread_test_strmap_, "thread 1"),
+ tt_assert(!strcmp(strmap_get(thread_test_strmap_, "thread 1"),
strmap_get(thread_test_strmap_, "last to run")) ||
!strcmp(strmap_get(thread_test_strmap_, "thread 2"),
strmap_get(thread_test_strmap_, "last to run")));
@@ -1448,51 +1738,52 @@ test_util_threads(void)
/** Run unit tests for compression functions */
static void
-test_util_gzip(void)
+test_util_gzip(void *arg)
{
char *buf1=NULL, *buf2=NULL, *buf3=NULL, *cp1, *cp2;
const char *ccp2;
size_t len1, len2;
tor_zlib_state_t *state = NULL;
+ (void)arg;
buf1 = tor_strdup("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ");
- test_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD);
+ tt_assert(detect_compression_method(buf1, strlen(buf1)) == UNKNOWN_METHOD);
if (is_gzip_supported()) {
- test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
+ tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
GZIP_METHOD));
- test_assert(buf2);
- test_assert(len1 < strlen(buf1));
- test_assert(detect_compression_method(buf2, len1) == GZIP_METHOD);
+ tt_assert(buf2);
+ tt_assert(len1 < strlen(buf1));
+ tt_assert(detect_compression_method(buf2, len1) == GZIP_METHOD);
- test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
+ tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
GZIP_METHOD, 1, LOG_INFO));
- test_assert(buf3);
- test_eq(strlen(buf1) + 1, len2);
- test_streq(buf1, buf3);
+ tt_assert(buf3);
+ tt_int_op(strlen(buf1) + 1,==, len2);
+ tt_str_op(buf1,==, buf3);
tor_free(buf2);
tor_free(buf3);
}
- test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
+ tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
ZLIB_METHOD));
- test_assert(buf2);
- test_assert(detect_compression_method(buf2, len1) == ZLIB_METHOD);
+ tt_assert(buf2);
+ tt_assert(detect_compression_method(buf2, len1) == ZLIB_METHOD);
- test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
+ tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1,
ZLIB_METHOD, 1, LOG_INFO));
- test_assert(buf3);
- test_eq(strlen(buf1) + 1, len2);
- test_streq(buf1, buf3);
+ tt_assert(buf3);
+ tt_int_op(strlen(buf1) + 1,==, len2);
+ tt_str_op(buf1,==, buf3);
/* Check whether we can uncompress concatenated, compressed strings. */
tor_free(buf3);
- buf2 = tor_realloc(buf2, len1*2);
+ buf2 = tor_reallocarray(buf2, len1, 2);
memcpy(buf2+len1, buf2, len1);
- test_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2,
+ tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf2, len1*2,
ZLIB_METHOD, 1, LOG_INFO));
- test_eq((strlen(buf1)+1)*2, len2);
- test_memeq(buf3,
+ tt_int_op((strlen(buf1)+1)*2,==, len2);
+ tt_mem_op(buf3,==,
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAZAAAAAAAAAAAAAAAAAAAZ\0",
(strlen(buf1)+1)*2);
@@ -1504,7 +1795,7 @@ test_util_gzip(void)
/* Check whether we can uncompress partial strings. */
buf1 =
tor_strdup("String with low redundancy that won't be compressed much.");
- test_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
+ tt_assert(!tor_gzip_compress(&buf2, &len1, buf1, strlen(buf1)+1,
ZLIB_METHOD));
tt_assert(len1>16);
/* when we allow an incomplete string, we should succeed.*/
@@ -1530,22 +1821,22 @@ test_util_gzip(void)
len1 = 1024;
ccp2 = "ABCDEFGHIJABCDEFGHIJ";
len2 = 21;
- test_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 0)
+ tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 0)
== TOR_ZLIB_OK);
- test_eq(0, len2); /* Make sure we compressed it all. */
- test_assert(cp1 > buf1);
+ tt_int_op(0,==, len2); /* Make sure we compressed it all. */
+ tt_assert(cp1 > buf1);
len2 = 0;
cp2 = cp1;
- test_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 1)
+ tt_assert(tor_zlib_process(state, &cp1, &len1, &ccp2, &len2, 1)
== TOR_ZLIB_DONE);
- test_eq(0, len2);
- test_assert(cp1 > cp2); /* Make sure we really added something. */
+ tt_int_op(0,==, len2);
+ tt_assert(cp1 > cp2); /* Make sure we really added something. */
tt_assert(!tor_gzip_uncompress(&buf3, &len2, buf1, 1024-len1,
ZLIB_METHOD, 1, LOG_WARN));
- test_streq(buf3, "ABCDEFGHIJABCDEFGHIJ"); /*Make sure it compressed right.*/
- test_eq(21, len2);
+ tt_str_op(buf3,==,"ABCDEFGHIJABCDEFGHIJ"); /*Make sure it compressed right.*/
+ tt_int_op(21,==, len2);
done:
if (state)
@@ -1557,7 +1848,7 @@ test_util_gzip(void)
/** Run unit tests for mmap() wrapper functionality. */
static void
-test_util_mmap(void)
+test_util_mmap(void *arg)
{
char *fname1 = tor_strdup(get_fname("mapped_1"));
char *fname2 = tor_strdup(get_fname("mapped_2"));
@@ -1566,25 +1857,26 @@ test_util_mmap(void)
char *buf = tor_malloc(17000);
tor_mmap_t *mapping = NULL;
+ (void)arg;
crypto_rand(buf, buflen);
mapping = tor_mmap_file(fname1);
- test_assert(! mapping);
+ tt_assert(! mapping);
write_str_to_file(fname1, "Short file.", 1);
mapping = tor_mmap_file(fname1);
- test_assert(mapping);
- test_eq(mapping->size, strlen("Short file."));
- test_streq(mapping->data, "Short file.");
+ tt_assert(mapping);
+ tt_int_op(mapping->size,==, strlen("Short file."));
+ tt_str_op(mapping->data,==, "Short file.");
#ifdef _WIN32
tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL;
- test_assert(unlink(fname1) == 0);
+ tt_assert(unlink(fname1) == 0);
#else
/* make sure we can unlink. */
- test_assert(unlink(fname1) == 0);
- test_streq(mapping->data, "Short file.");
+ tt_assert(unlink(fname1) == 0);
+ tt_str_op(mapping->data,==, "Short file.");
tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL;
#endif
@@ -1592,29 +1884,29 @@ test_util_mmap(void)
/* Now a zero-length file. */
write_str_to_file(fname1, "", 1);
mapping = tor_mmap_file(fname1);
- test_eq_ptr(mapping, NULL);
- test_eq(ERANGE, errno);
+ tt_ptr_op(mapping,==, NULL);
+ tt_int_op(ERANGE,==, errno);
unlink(fname1);
/* Make sure that we fail to map a no-longer-existent file. */
mapping = tor_mmap_file(fname1);
- test_assert(! mapping);
+ tt_assert(! mapping);
/* Now try a big file that stretches across a few pages and isn't aligned */
write_bytes_to_file(fname2, buf, buflen, 1);
mapping = tor_mmap_file(fname2);
- test_assert(mapping);
- test_eq(mapping->size, buflen);
- test_memeq(mapping->data, buf, buflen);
+ tt_assert(mapping);
+ tt_int_op(mapping->size,==, buflen);
+ tt_mem_op(mapping->data,==, buf, buflen);
tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL;
/* Now try a big aligned file. */
write_bytes_to_file(fname3, buf, 16384, 1);
mapping = tor_mmap_file(fname3);
- test_assert(mapping);
- test_eq(mapping->size, 16384);
- test_memeq(mapping->data, buf, 16384);
+ tt_assert(mapping);
+ tt_int_op(mapping->size,==, 16384);
+ tt_mem_op(mapping->data,==, buf, 16384);
tt_int_op(0, ==, tor_munmap_file(mapping));
mapping = NULL;
@@ -1633,17 +1925,18 @@ test_util_mmap(void)
/** Run unit tests for escaping/unescaping data for use by controllers. */
static void
-test_util_control_formats(void)
+test_util_control_formats(void *arg)
{
char *out = NULL;
const char *inp =
"..This is a test\r\n.of the emergency \n..system.\r\n\rZ.\r\n";
size_t sz;
+ (void)arg;
sz = read_escaped_data(inp, strlen(inp), &out);
- test_streq(out,
+ tt_str_op(out,==,
".This is a test\nof the emergency \n.system.\n\rZ.\n");
- test_eq(sz, strlen(out));
+ tt_int_op(sz,==, strlen(out));
done:
tor_free(out);
@@ -1663,9 +1956,10 @@ test_util_control_formats(void)
} while (0)
static void
-test_util_sscanf(void)
+test_util_sscanf(void *arg)
{
unsigned u1, u2, u3;
+ unsigned long ulng;
char s1[20], s2[10], s3[10], ch;
int r;
long lng1,lng2;
@@ -1673,186 +1967,335 @@ test_util_sscanf(void)
double d1,d2,d3,d4;
/* Simple tests (malformed patterns, literal matching, ...) */
- test_eq(-1, tor_sscanf("123", "%i", &r)); /* %i is not supported */
- test_eq(-1, tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */
- test_eq(-1, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */
- test_eq(-1, tor_sscanf("prettylongstring", "%999999s", s1));
+ (void)arg;
+ tt_int_op(-1,==, tor_sscanf("123", "%i", &r)); /* %i is not supported */
+ tt_int_op(-1,==,
+ tor_sscanf("wrong", "%5c", s1)); /* %c cannot have a number. */
+ tt_int_op(-1,==, tor_sscanf("hello", "%s", s1)); /* %s needs a number. */
+ tt_int_op(-1,==, tor_sscanf("prettylongstring", "%999999s", s1));
#if 0
/* GCC thinks these two are illegal. */
test_eq(-1, tor_sscanf("prettylongstring", "%0s", s1));
test_eq(0, tor_sscanf("prettylongstring", "%10s", NULL));
#endif
/* No '%'-strings: always "success" */
- test_eq(0, tor_sscanf("hello world", "hello world"));
- test_eq(0, tor_sscanf("hello world", "good bye"));
+ tt_int_op(0,==, tor_sscanf("hello world", "hello world"));
+ tt_int_op(0,==, tor_sscanf("hello world", "good bye"));
/* Excess data */
- test_eq(0, tor_sscanf("hello 3", "%u", &u1)); /* have to match the start */
- test_eq(0, tor_sscanf(" 3 hello", "%u", &u1));
- test_eq(0, tor_sscanf(" 3 hello", "%2u", &u1)); /* not even in this case */
- test_eq(1, tor_sscanf("3 hello", "%u", &u1)); /* but trailing is alright */
+ tt_int_op(0,==,
+ tor_sscanf("hello 3", "%u", &u1)); /* have to match the start */
+ tt_int_op(0,==, tor_sscanf(" 3 hello", "%u", &u1));
+ tt_int_op(0,==,
+ tor_sscanf(" 3 hello", "%2u", &u1)); /* not even in this case */
+ tt_int_op(1,==,
+ tor_sscanf("3 hello", "%u", &u1)); /* but trailing is alright */
/* Numbers (ie. %u) */
- test_eq(0, tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */
- test_eq(1, tor_sscanf("12345", "%u", &u1));
- test_eq(12345u, u1);
- test_eq(1, tor_sscanf("12346 ", "%u", &u1));
- test_eq(12346u, u1);
- test_eq(0, tor_sscanf(" 12347", "%u", &u1));
- test_eq(1, tor_sscanf(" 12348", " %u", &u1));
- test_eq(12348u, u1);
- test_eq(1, tor_sscanf("0", "%u", &u1));
- test_eq(0u, u1);
- test_eq(1, tor_sscanf("0000", "%u", &u2));
- test_eq(0u, u2);
- test_eq(0, tor_sscanf("", "%u", &u1)); /* absent number */
- test_eq(0, tor_sscanf("A", "%u", &u1)); /* bogus number */
- test_eq(0, tor_sscanf("-1", "%u", &u1)); /* negative number */
- test_eq(1, tor_sscanf("4294967295", "%u", &u1)); /* UINT32_MAX should work */
- test_eq(4294967295u, u1);
- test_eq(0, tor_sscanf("4294967296", "%u", &u1)); /* But not at 32 bits */
- test_eq(1, tor_sscanf("4294967296", "%9u", &u1)); /* but parsing only 9... */
- test_eq(429496729u, u1);
+ tt_int_op(0,==,
+ tor_sscanf("hello world 3", "hello worlb %u", &u1)); /* d vs b */
+ tt_int_op(1,==, tor_sscanf("12345", "%u", &u1));
+ tt_int_op(12345u,==, u1);
+ tt_int_op(1,==, tor_sscanf("12346 ", "%u", &u1));
+ tt_int_op(12346u,==, u1);
+ tt_int_op(0,==, tor_sscanf(" 12347", "%u", &u1));
+ tt_int_op(1,==, tor_sscanf(" 12348", " %u", &u1));
+ tt_int_op(12348u,==, u1);
+ tt_int_op(1,==, tor_sscanf("0", "%u", &u1));
+ tt_int_op(0u,==, u1);
+ tt_int_op(1,==, tor_sscanf("0000", "%u", &u2));
+ tt_int_op(0u,==, u2);
+ tt_int_op(0,==, tor_sscanf("", "%u", &u1)); /* absent number */
+ tt_int_op(0,==, tor_sscanf("A", "%u", &u1)); /* bogus number */
+ tt_int_op(0,==, tor_sscanf("-1", "%u", &u1)); /* negative number */
/* Numbers with size (eg. %2u) */
- test_eq(0, tor_sscanf("-1", "%2u", &u1));
- test_eq(2, tor_sscanf("123456", "%2u%u", &u1, &u2));
- test_eq(12u, u1);
- test_eq(3456u, u2);
- test_eq(1, tor_sscanf("123456", "%8u", &u1));
- test_eq(123456u, u1);
- test_eq(1, tor_sscanf("123457 ", "%8u", &u1));
- test_eq(123457u, u1);
- test_eq(0, tor_sscanf(" 123456", "%8u", &u1));
- test_eq(3, tor_sscanf("!12:3:456", "!%2u:%2u:%3u", &u1, &u2, &u3));
- test_eq(12u, u1);
- test_eq(3u, u2);
- test_eq(456u, u3);
- test_eq(3, tor_sscanf("67:8:099", "%2u:%2u:%3u", &u1, &u2, &u3)); /* 0s */
- test_eq(67u, u1);
- test_eq(8u, u2);
- test_eq(99u, u3);
+ tt_int_op(0,==, tor_sscanf("-1", "%2u", &u1));
+ tt_int_op(2,==, tor_sscanf("123456", "%2u%u", &u1, &u2));
+ tt_int_op(12u,==, u1);
+ tt_int_op(3456u,==, u2);
+ tt_int_op(1,==, tor_sscanf("123456", "%8u", &u1));
+ tt_int_op(123456u,==, u1);
+ tt_int_op(1,==, tor_sscanf("123457 ", "%8u", &u1));
+ tt_int_op(123457u,==, u1);
+ tt_int_op(0,==, tor_sscanf(" 123456", "%8u", &u1));
+ tt_int_op(3,==, tor_sscanf("!12:3:456", "!%2u:%2u:%3u", &u1, &u2, &u3));
+ tt_int_op(12u,==, u1);
+ tt_int_op(3u,==, u2);
+ tt_int_op(456u,==, u3);
+ tt_int_op(3,==,
+ tor_sscanf("67:8:099", "%2u:%2u:%3u", &u1, &u2, &u3)); /* 0s */
+ tt_int_op(67u,==, u1);
+ tt_int_op(8u,==, u2);
+ tt_int_op(99u,==, u3);
/* %u does not match space.*/
- test_eq(2, tor_sscanf("12:3: 45", "%2u:%2u:%3u", &u1, &u2, &u3));
- test_eq(12u, u1);
- test_eq(3u, u2);
+ tt_int_op(2,==, tor_sscanf("12:3: 45", "%2u:%2u:%3u", &u1, &u2, &u3));
+ tt_int_op(12u,==, u1);
+ tt_int_op(3u,==, u2);
/* %u does not match negative numbers. */
- test_eq(2, tor_sscanf("67:8:-9", "%2u:%2u:%3u", &u1, &u2, &u3));
- test_eq(67u, u1);
- test_eq(8u, u2);
+ tt_int_op(2,==, tor_sscanf("67:8:-9", "%2u:%2u:%3u", &u1, &u2, &u3));
+ tt_int_op(67u,==, u1);
+ tt_int_op(8u,==, u2);
/* Arbitrary amounts of 0-padding are okay */
- test_eq(3, tor_sscanf("12:03:000000000000000099", "%2u:%2u:%u",
+ tt_int_op(3,==, tor_sscanf("12:03:000000000000000099", "%2u:%2u:%u",
&u1, &u2, &u3));
- test_eq(12u, u1);
- test_eq(3u, u2);
- test_eq(99u, u3);
+ tt_int_op(12u,==, u1);
+ tt_int_op(3u,==, u2);
+ tt_int_op(99u,==, u3);
/* Hex (ie. %x) */
- test_eq(3, tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3));
- test_eq(0x1234, u1);
- test_eq(0x2ABCDEF, u2);
- test_eq(0xFF, u3);
+ tt_int_op(3,==, tor_sscanf("1234 02aBcdEf ff", "%x %x %x", &u1, &u2, &u3));
+ tt_int_op(0x1234,==, u1);
+ tt_int_op(0x2ABCDEF,==, u2);
+ tt_int_op(0xFF,==, u3);
/* Width works on %x */
- test_eq(3, tor_sscanf("f00dcafe444", "%4x%4x%u", &u1, &u2, &u3));
- test_eq(0xf00d, u1);
- test_eq(0xcafe, u2);
- test_eq(444, u3);
+ tt_int_op(3,==, tor_sscanf("f00dcafe444", "%4x%4x%u", &u1, &u2, &u3));
+ tt_int_op(0xf00d,==, u1);
+ tt_int_op(0xcafe,==, u2);
+ tt_int_op(444,==, u3);
/* Literal '%' (ie. '%%') */
- test_eq(1, tor_sscanf("99% fresh", "%3u%% fresh", &u1));
- test_eq(99, u1);
- test_eq(0, tor_sscanf("99 fresh", "%% %3u %s", &u1, s1));
- test_eq(1, tor_sscanf("99 fresh", "%3u%% %s", &u1, s1));
- test_eq(2, tor_sscanf("99 fresh", "%3u %5s %%", &u1, s1));
- test_eq(99, u1);
- test_streq(s1, "fresh");
- test_eq(1, tor_sscanf("% boo", "%% %3s", s1));
- test_streq("boo", s1);
+ tt_int_op(1,==, tor_sscanf("99% fresh", "%3u%% fresh", &u1));
+ tt_int_op(99,==, u1);
+ tt_int_op(0,==, tor_sscanf("99 fresh", "%% %3u %s", &u1, s1));
+ tt_int_op(1,==, tor_sscanf("99 fresh", "%3u%% %s", &u1, s1));
+ tt_int_op(2,==, tor_sscanf("99 fresh", "%3u %5s %%", &u1, s1));
+ tt_int_op(99,==, u1);
+ tt_str_op(s1,==, "fresh");
+ tt_int_op(1,==, tor_sscanf("% boo", "%% %3s", s1));
+ tt_str_op("boo",==, s1);
/* Strings (ie. %s) */
- test_eq(2, tor_sscanf("hello", "%3s%7s", s1, s2));
- test_streq(s1, "hel");
- test_streq(s2, "lo");
- test_eq(2, tor_sscanf("WD40", "%2s%u", s3, &u1)); /* %s%u */
- test_streq(s3, "WD");
- test_eq(40, u1);
- test_eq(2, tor_sscanf("WD40", "%3s%u", s3, &u1)); /* %s%u */
- test_streq(s3, "WD4");
- test_eq(0, u1);
- test_eq(2, tor_sscanf("76trombones", "%6u%9s", &u1, s1)); /* %u%s */
- test_eq(76, u1);
- test_streq(s1, "trombones");
- test_eq(1, tor_sscanf("prettylongstring", "%999s", s1));
- test_streq(s1, "prettylongstring");
+ tt_int_op(2,==, tor_sscanf("hello", "%3s%7s", s1, s2));
+ tt_str_op(s1,==, "hel");
+ tt_str_op(s2,==, "lo");
+ tt_int_op(2,==, tor_sscanf("WD40", "%2s%u", s3, &u1)); /* %s%u */
+ tt_str_op(s3,==, "WD");
+ tt_int_op(40,==, u1);
+ tt_int_op(2,==, tor_sscanf("WD40", "%3s%u", s3, &u1)); /* %s%u */
+ tt_str_op(s3,==, "WD4");
+ tt_int_op(0,==, u1);
+ tt_int_op(2,==, tor_sscanf("76trombones", "%6u%9s", &u1, s1)); /* %u%s */
+ tt_int_op(76,==, u1);
+ tt_str_op(s1,==, "trombones");
+ tt_int_op(1,==, tor_sscanf("prettylongstring", "%999s", s1));
+ tt_str_op(s1,==, "prettylongstring");
/* %s doesn't eat spaces */
- test_eq(2, tor_sscanf("hello world", "%9s %9s", s1, s2));
- test_streq(s1, "hello");
- test_streq(s2, "world");
- test_eq(2, tor_sscanf("bye world?", "%9s %9s", s1, s2));
- test_streq(s1, "bye");
- test_streq(s2, "");
- test_eq(3, tor_sscanf("hi", "%9s%9s%3s", s1, s2, s3)); /* %s can be empty. */
- test_streq(s1, "hi");
- test_streq(s2, "");
- test_streq(s3, "");
-
- test_eq(3, tor_sscanf("1.2.3", "%u.%u.%u%c", &u1, &u2, &u3, &ch));
- test_eq(4, tor_sscanf("1.2.3 foobar", "%u.%u.%u%c", &u1, &u2, &u3, &ch));
- test_eq(' ', ch);
+ tt_int_op(2,==, tor_sscanf("hello world", "%9s %9s", s1, s2));
+ tt_str_op(s1,==, "hello");
+ tt_str_op(s2,==, "world");
+ tt_int_op(2,==, tor_sscanf("bye world?", "%9s %9s", s1, s2));
+ tt_str_op(s1,==, "bye");
+ tt_str_op(s2,==, "");
+ tt_int_op(3,==,
+ tor_sscanf("hi", "%9s%9s%3s", s1, s2, s3)); /* %s can be empty. */
+ tt_str_op(s1,==, "hi");
+ tt_str_op(s2,==, "");
+ tt_str_op(s3,==, "");
+
+ tt_int_op(3,==, tor_sscanf("1.2.3", "%u.%u.%u%c", &u1, &u2, &u3, &ch));
+ tt_int_op(4,==,
+ tor_sscanf("1.2.3 foobar", "%u.%u.%u%c", &u1, &u2, &u3, &ch));
+ tt_int_op(' ',==, ch);
r = tor_sscanf("12345 -67890 -1", "%d %ld %d", &int1, &lng1, &int2);
- test_eq(r,3);
- test_eq(int1, 12345);
- test_eq(lng1, -67890);
- test_eq(int2, -1);
+ tt_int_op(r,==, 3);
+ tt_int_op(int1,==, 12345);
+ tt_int_op(lng1,==, -67890);
+ tt_int_op(int2,==, -1);
#if SIZEOF_INT == 4
+ /* %u */
+ /* UINT32_MAX should work */
+ tt_int_op(1,==, tor_sscanf("4294967295", "%u", &u1));
+ tt_int_op(4294967295U,==, u1);
+
+ /* But UINT32_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("4294967296", "%u", &u1));
+ /* but parsing only 9... */
+ tt_int_op(1,==, tor_sscanf("4294967296", "%9u", &u1));
+ tt_int_op(429496729U,==, u1);
+
+ /* %x */
+ /* UINT32_MAX should work */
+ tt_int_op(1,==, tor_sscanf("FFFFFFFF", "%x", &u1));
+ tt_int_op(0xFFFFFFFF,==, u1);
+
+ /* But UINT32_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("100000000", "%x", &u1));
+
+ /* %d */
+ /* INT32_MIN and INT32_MAX should work */
r = tor_sscanf("-2147483648. 2147483647.", "%d. %d.", &int1, &int2);
- test_eq(r,2);
- test_eq(int1, -2147483647-1);
- test_eq(int2, 2147483647);
+ tt_int_op(r,==, 2);
+ tt_int_op(int1,==, -2147483647 - 1);
+ tt_int_op(int2,==, 2147483647);
+
+ /* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */
+ r = tor_sscanf("-2147483649.", "%d.", &int1);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("2147483648.", "%d.", &int1);
+ tt_int_op(r,==, 0);
- r = tor_sscanf("-2147483679.", "%d.", &int1);
- test_eq(r,0);
+ /* and the first failure stops further processing */
+ r = tor_sscanf("-2147483648. 2147483648.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 1);
+
+ r = tor_sscanf("-2147483649. 2147483647.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 0);
- r = tor_sscanf("2147483678.", "%d.", &int1);
- test_eq(r,0);
+ r = tor_sscanf("2147483648. -2147483649.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 0);
#elif SIZEOF_INT == 8
+ /* %u */
+ /* UINT64_MAX should work */
+ tt_int_op(1,==, tor_sscanf("18446744073709551615", "%u", &u1));
+ tt_int_op(18446744073709551615U,==, u1);
+
+ /* But UINT64_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("18446744073709551616", "%u", &u1));
+ /* but parsing only 19... */
+ tt_int_op(1,==, tor_sscanf("18446744073709551616", "%19u", &u1));
+ tt_int_op(1844674407370955161U,==, u1);
+
+ /* %x */
+ /* UINT64_MAX should work */
+ tt_int_op(1,==, tor_sscanf("FFFFFFFFFFFFFFFF", "%x", &u1));
+ tt_int_op(0xFFFFFFFFFFFFFFFF,==, u1);
+
+ /* But UINT64_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("10000000000000000", "%x", &u1));
+
+ /* %d */
+ /* INT64_MIN and INT64_MAX should work */
r = tor_sscanf("-9223372036854775808. 9223372036854775807.",
"%d. %d.", &int1, &int2);
- test_eq(r,2);
- test_eq(int1, -9223372036854775807-1);
- test_eq(int2, 9223372036854775807);
+ tt_int_op(r,==, 2);
+ tt_int_op(int1,==, -9223372036854775807 - 1);
+ tt_int_op(int2,==, 9223372036854775807);
+ /* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */
r = tor_sscanf("-9223372036854775809.", "%d.", &int1);
- test_eq(r,0);
+ tt_int_op(r,==, 0);
r = tor_sscanf("9223372036854775808.", "%d.", &int1);
- test_eq(r,0);
+ tt_int_op(r,==, 0);
+
+ /* and the first failure stops further processing */
+ r = tor_sscanf("-9223372036854775808. 9223372036854775808.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 1);
+
+ r = tor_sscanf("-9223372036854775809. 9223372036854775807.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("9223372036854775808. -9223372036854775809.",
+ "%d. %d.", &int1, &int2);
+ tt_int_op(r,==, 0);
#endif
#if SIZEOF_LONG == 4
+ /* %lu */
+ /* UINT32_MAX should work */
+ tt_int_op(1,==, tor_sscanf("4294967295", "%lu", &ulng));
+ tt_int_op(4294967295UL,==, ulng);
+
+ /* But UINT32_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("4294967296", "%lu", &ulng));
+ /* but parsing only 9... */
+ tt_int_op(1,==, tor_sscanf("4294967296", "%9lu", &ulng));
+ tt_int_op(429496729UL,==, ulng);
+
+ /* %lx */
+ /* UINT32_MAX should work */
+ tt_int_op(1,==, tor_sscanf("FFFFFFFF", "%lx", &ulng));
+ tt_int_op(0xFFFFFFFFUL,==, ulng);
+
+ /* But UINT32_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("100000000", "%lx", &ulng));
+
+ /* %ld */
+ /* INT32_MIN and INT32_MAX should work */
r = tor_sscanf("-2147483648. 2147483647.", "%ld. %ld.", &lng1, &lng2);
- test_eq(r,2);
- test_eq(lng1, -2147483647 - 1);
- test_eq(lng2, 2147483647);
+ tt_int_op(r,==, 2);
+ tt_int_op(lng1,==, -2147483647L - 1L);
+ tt_int_op(lng2,==, 2147483647L);
+
+ /* But INT32_MIN - 1 and INT32_MAX + 1 shouldn't work */
+ r = tor_sscanf("-2147483649.", "%ld.", &lng1);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("2147483648.", "%ld.", &lng1);
+ tt_int_op(r,==, 0);
+
+ /* and the first failure stops further processing */
+ r = tor_sscanf("-2147483648. 2147483648.",
+ "%ld. %ld.", &lng1, &lng2);
+ tt_int_op(r,==, 1);
+
+ r = tor_sscanf("-2147483649. 2147483647.",
+ "%ld. %ld.", &lng1, &lng2);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("2147483648. -2147483649.",
+ "%ld. %ld.", &lng1, &lng2);
+ tt_int_op(r,==, 0);
#elif SIZEOF_LONG == 8
+ /* %lu */
+ /* UINT64_MAX should work */
+ tt_int_op(1,==, tor_sscanf("18446744073709551615", "%lu", &ulng));
+ tt_int_op(18446744073709551615UL,==, ulng);
+
+ /* But UINT64_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("18446744073709551616", "%lu", &ulng));
+ /* but parsing only 19... */
+ tt_int_op(1,==, tor_sscanf("18446744073709551616", "%19lu", &ulng));
+ tt_int_op(1844674407370955161UL,==, ulng);
+
+ /* %lx */
+ /* UINT64_MAX should work */
+ tt_int_op(1,==, tor_sscanf("FFFFFFFFFFFFFFFF", "%lx", &ulng));
+ tt_int_op(0xFFFFFFFFFFFFFFFFUL,==, ulng);
+
+ /* But UINT64_MAX + 1 shouldn't work */
+ tt_int_op(0,==, tor_sscanf("10000000000000000", "%lx", &ulng));
+
+ /* %ld */
+ /* INT64_MIN and INT64_MAX should work */
r = tor_sscanf("-9223372036854775808. 9223372036854775807.",
"%ld. %ld.", &lng1, &lng2);
- test_eq(r,2);
- test_eq(lng1, -9223372036854775807L - 1);
- test_eq(lng2, 9223372036854775807L);
+ tt_int_op(r,==, 2);
+ tt_int_op(lng1,==, -9223372036854775807L - 1L);
+ tt_int_op(lng2,==, 9223372036854775807L);
+
+ /* But INT64_MIN - 1 and INT64_MAX + 1 shouldn't work */
+ r = tor_sscanf("-9223372036854775809.", "%ld.", &lng1);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("9223372036854775808.", "%ld.", &lng1);
+ tt_int_op(r,==, 0);
+ /* and the first failure stops further processing */
r = tor_sscanf("-9223372036854775808. 9223372036854775808.",
"%ld. %ld.", &lng1, &lng2);
- test_eq(r,1);
- r = tor_sscanf("-9223372036854775809. 9223372036854775808.",
+ tt_int_op(r,==, 1);
+
+ r = tor_sscanf("-9223372036854775809. 9223372036854775807.",
+ "%ld. %ld.", &lng1, &lng2);
+ tt_int_op(r,==, 0);
+
+ r = tor_sscanf("9223372036854775808. -9223372036854775809.",
"%ld. %ld.", &lng1, &lng2);
- test_eq(r,0);
+ tt_int_op(r,==, 0);
#endif
r = tor_sscanf("123.456 .000007 -900123123.2000787 00003.2",
"%lf %lf %lf %lf", &d1,&d2,&d3,&d4);
- test_eq(r,4);
+ tt_int_op(r,==, 4);
test_feq(d1, 123.456);
test_feq(d2, .000007);
test_feq(d3, -900123123.2000787);
@@ -1862,34 +2305,466 @@ test_util_sscanf(void)
;
}
+#define tt_char_op(a,op,b) tt_assert_op_type(a,op,b,char,"%c")
+#define tt_ci_char_op(a,op,b) tt_char_op(tolower(a),op,tolower(b))
+
+#ifndef HAVE_STRNLEN
+static size_t
+strnlen(const char *s, size_t len)
+{
+ const char *p = memchr(s, 0, len);
+ if (!p)
+ return len;
+ return p - s;
+}
+#endif
+
static void
-test_util_path_is_relative(void)
+test_util_format_time_interval(void *arg)
+{
+ /* use the same sized buffer and integers as tor uses */
+#define DBUF_SIZE 64
+ char dbuf[DBUF_SIZE];
+#define T_ "%ld"
+ long sec, min, hour, day;
+
+ /* we don't care about the exact spelling of the
+ * second(s), minute(s), hour(s), day(s) labels */
+#define LABEL_SIZE 21
+#define L_ "%20s"
+ char label_s[LABEL_SIZE];
+ char label_m[LABEL_SIZE];
+ char label_h[LABEL_SIZE];
+ char label_d[LABEL_SIZE];
+
+#define TL_ T_ " " L_
+
+ int r;
+
+ (void)arg;
+
+ /* In these tests, we're not picky about
+ * spelling or abbreviations */
+
+ /* seconds: 0, 1, 9, 10, 59 */
+
+ /* ignore exact spelling of "second(s)"*/
+ format_time_interval(dbuf, sizeof(dbuf), 0);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 0);
+
+ format_time_interval(dbuf, sizeof(dbuf), 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 1);
+
+ format_time_interval(dbuf, sizeof(dbuf), 10);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 10);
+
+ format_time_interval(dbuf, sizeof(dbuf), 59);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 59);
+
+ /* negative seconds are reported as their absolute value */
+
+ format_time_interval(dbuf, sizeof(dbuf), -4);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 4);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+
+ format_time_interval(dbuf, sizeof(dbuf), -32);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &sec, label_s);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(sec,==, 32);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+
+ /* minutes: 1:00, 1:01, 1:59, 2:00, 2:01, 59:59 */
+
+ /* ignore trailing "0 second(s)", if present */
+ format_time_interval(dbuf, sizeof(dbuf), 60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &min, label_m);
+ tt_int_op(r,==, 2);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(min,==, 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+
+ /* ignore exact spelling of "minute(s)," and "second(s)" */
+ format_time_interval(dbuf, sizeof(dbuf), 60 + 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 1);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 1);
+ tt_ci_char_op(label_s[0],==, 's');
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+
+ format_time_interval(dbuf, sizeof(dbuf), 60*2 - 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 1);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 59);
+ tt_ci_char_op(label_s[0],==, 's');
+
+ /* ignore trailing "0 second(s)", if present */
+ format_time_interval(dbuf, sizeof(dbuf), 60*2);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &min, label_m);
+ tt_int_op(r,==, 2);
+ tt_int_op(min,==, 2);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* ignore exact spelling of "minute(s)," and "second(s)" */
+ format_time_interval(dbuf, sizeof(dbuf), 60*2 + 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 2);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 1);
+ tt_ci_char_op(label_s[0],==, 's');
+
+ format_time_interval(dbuf, sizeof(dbuf), 60*60 - 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 59);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 59);
+ tt_ci_char_op(label_s[0],==, 's');
+
+ /* negative minutes are reported as their absolute value */
+
+ /* ignore trailing "0 second(s)", if present */
+ format_time_interval(dbuf, sizeof(dbuf), -3*60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &min, label_m);
+ tt_int_op(r,==, 2);
+ tt_int_op(min,==, 3);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* ignore exact spelling of "minute(s)," and "second(s)" */
+ format_time_interval(dbuf, sizeof(dbuf), -96);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 1);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 36);
+ tt_ci_char_op(label_s[0],==, 's');
+
+ format_time_interval(dbuf, sizeof(dbuf), -2815);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &min, label_m, &sec, label_s);
+ tt_int_op(r,==, 4);
+ tt_int_op(min,==, 46);
+ tt_ci_char_op(label_m[0],==, 'm');
+ tt_int_op(sec,==, 55);
+ tt_ci_char_op(label_s[0],==, 's');
+
+ /* hours: 1:00, 1:00:01, 1:01, 23:59, 23:59:59 */
+ /* always ignore trailing seconds, if present */
+
+ /* ignore trailing "0 minute(s)" etc., if present */
+ format_time_interval(dbuf, sizeof(dbuf), 60*60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &hour, label_h);
+ tt_int_op(r,==, 2);
+ tt_int_op(hour,==, 1);
+ tt_ci_char_op(label_h[0],==, 'h');
+
+ format_time_interval(dbuf, sizeof(dbuf), 60*60 + 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &hour, label_h);
+ tt_int_op(r,==, 2);
+ tt_int_op(hour,==, 1);
+ tt_ci_char_op(label_h[0],==, 'h');
+
+ /* ignore exact spelling of "hour(s)," etc. */
+ format_time_interval(dbuf, sizeof(dbuf), 60*60 + 60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 4);
+ tt_int_op(hour,==, 1);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 1);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 4);
+ tt_int_op(hour,==, 23);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 59);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 - 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 4);
+ tt_int_op(hour,==, 23);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 59);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* negative hours are reported as their absolute value */
+
+ /* ignore exact spelling of "hour(s)," etc., if present */
+ format_time_interval(dbuf, sizeof(dbuf), -2*60*60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &hour, label_h);
+ tt_int_op(r,==, 2);
+ tt_int_op(hour,==, 2);
+ tt_ci_char_op(label_h[0],==, 'h');
+
+ format_time_interval(dbuf, sizeof(dbuf), -75804);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 4);
+ tt_int_op(hour,==, 21);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 3);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* days: 1:00, 1:00:00:01, 1:00:01, 1:01 */
+ /* always ignore trailing seconds, if present */
+
+ /* ignore trailing "0 hours(s)" etc., if present */
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &day, label_d);
+ tt_int_op(r,==, 2);
+ tt_int_op(day,==, 1);
+ tt_ci_char_op(label_d[0],==, 'd');
+
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 1);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_, &day, label_d);
+ tt_int_op(r,==, 2);
+ tt_int_op(day,==, 1);
+ tt_ci_char_op(label_d[0],==, 'd');
+
+ /* ignore exact spelling of "days(s)," etc. */
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ if (r == -1) {
+ /* ignore 0 hours(s), if present */
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &day, label_d, &min, label_m);
+ }
+ tt_assert(r == 4 || r == 6);
+ tt_int_op(day,==, 1);
+ tt_ci_char_op(label_d[0],==, 'd');
+ if (r == 6) {
+ tt_int_op(hour,==, 0);
+ tt_ci_char_op(label_h[0],==, 'h');
+ }
+ tt_int_op(min,==, 1);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* ignore trailing "0 minutes(s)" etc., if present */
+ format_time_interval(dbuf, sizeof(dbuf), 24*60*60 + 60*60);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_,
+ &day, label_d, &hour, label_h);
+ tt_int_op(r,==, 4);
+ tt_int_op(day,==, 1);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 1);
+ tt_ci_char_op(label_h[0],==, 'h');
+
+ /* negative days are reported as their absolute value */
+
+ format_time_interval(dbuf, sizeof(dbuf), -21936184);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 253);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 21);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 23);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* periods > 1 year are reported in days (warn?) */
+
+ /* ignore exact spelling of "days(s)," etc., if present */
+ format_time_interval(dbuf, sizeof(dbuf), 758635154);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 8780);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 11);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 59);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+ /* negative periods > 1 year are reported in days (warn?) */
+
+ format_time_interval(dbuf, sizeof(dbuf), -1427014922);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 16516);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 9);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 2);
+ tt_ci_char_op(label_m[0],==, 'm');
+
+#if SIZEOF_LONG == 4 || SIZEOF_LONG == 8
+
+ /* We can try INT32_MIN/MAX */
+ /* Always ignore second(s) */
+
+ /* INT32_MAX */
+ format_time_interval(dbuf, sizeof(dbuf), 2147483647);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 24855);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 3);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 14);
+ tt_ci_char_op(label_m[0],==, 'm');
+ /* and 7 seconds - ignored */
+
+ /* INT32_MIN: check that we get the absolute value of interval,
+ * which doesn't actually fit in int32_t.
+ * We expect INT32_MAX or INT32_MAX + 1 with 64 bit longs */
+ format_time_interval(dbuf, sizeof(dbuf), -2147483647L - 1L);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 24855);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 3);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 14);
+ tt_ci_char_op(label_m[0],==, 'm');
+ /* and 7 or 8 seconds - ignored */
+
+#endif
+
+#if SIZEOF_LONG == 8
+
+ /* We can try INT64_MIN/MAX */
+ /* Always ignore second(s) */
+
+ /* INT64_MAX */
+ format_time_interval(dbuf, sizeof(dbuf), 9223372036854775807L);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 106751991167300L);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 15);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 30);
+ tt_ci_char_op(label_m[0],==, 'm');
+ /* and 7 seconds - ignored */
+
+ /* INT64_MIN: check that we get the absolute value of interval,
+ * which doesn't actually fit in int64_t.
+ * We expect INT64_MAX */
+ format_time_interval(dbuf, sizeof(dbuf),
+ -9223372036854775807L - 1L);
+ tt_int_op(strnlen(dbuf, DBUF_SIZE),<=, DBUF_SIZE - 1);
+ r = tor_sscanf(dbuf, TL_ " " TL_ " " TL_,
+ &day, label_d, &hour, label_h, &min, label_m);
+ tt_int_op(r,==, 6);
+ tt_int_op(day,==, 106751991167300L);
+ tt_ci_char_op(label_d[0],==, 'd');
+ tt_int_op(hour,==, 15);
+ tt_ci_char_op(label_h[0],==, 'h');
+ tt_int_op(min,==, 30);
+ tt_ci_char_op(label_m[0],==, 'm');
+ /* and 7 or 8 seconds - ignored */
+
+#endif
+
+ done:
+ ;
+}
+
+#undef tt_char_op
+#undef tt_ci_char_op
+#undef DBUF_SIZE
+#undef T_
+#undef LABEL_SIZE
+#undef L_
+#undef TL_
+
+static void
+test_util_path_is_relative(void *arg)
{
/* OS-independent tests */
- test_eq(1, path_is_relative(""));
- test_eq(1, path_is_relative("dir"));
- test_eq(1, path_is_relative("dir/"));
- test_eq(1, path_is_relative("./dir"));
- test_eq(1, path_is_relative("../dir"));
+ (void)arg;
+ tt_int_op(1,==, path_is_relative(""));
+ tt_int_op(1,==, path_is_relative("dir"));
+ tt_int_op(1,==, path_is_relative("dir/"));
+ tt_int_op(1,==, path_is_relative("./dir"));
+ tt_int_op(1,==, path_is_relative("../dir"));
- test_eq(0, path_is_relative("/"));
- test_eq(0, path_is_relative("/dir"));
- test_eq(0, path_is_relative("/dir/"));
+ tt_int_op(0,==, path_is_relative("/"));
+ tt_int_op(0,==, path_is_relative("/dir"));
+ tt_int_op(0,==, path_is_relative("/dir/"));
/* Windows */
#ifdef _WIN32
/* I don't have Windows so I can't test this, hence the "#ifdef
0". These are tests that look useful, so please try to get them
running and uncomment if it all works as it should */
- test_eq(1, path_is_relative("dir"));
- test_eq(1, path_is_relative("dir\\"));
- test_eq(1, path_is_relative("dir\\a:"));
- test_eq(1, path_is_relative("dir\\a:\\"));
- test_eq(1, path_is_relative("http:\\dir"));
-
- test_eq(0, path_is_relative("\\dir"));
- test_eq(0, path_is_relative("a:\\dir"));
- test_eq(0, path_is_relative("z:\\dir"));
+ tt_int_op(1,==, path_is_relative("dir"));
+ tt_int_op(1,==, path_is_relative("dir\\"));
+ tt_int_op(1,==, path_is_relative("dir\\a:"));
+ tt_int_op(1,==, path_is_relative("dir\\a:\\"));
+ tt_int_op(1,==, path_is_relative("http:\\dir"));
+
+ tt_int_op(0,==, path_is_relative("\\dir"));
+ tt_int_op(0,==, path_is_relative("a:\\dir"));
+ tt_int_op(0,==, path_is_relative("z:\\dir"));
#endif
done:
@@ -1900,25 +2775,26 @@ test_util_path_is_relative(void)
/** Run unittests for memory pool allocator */
static void
-test_util_mempool(void)
+test_util_mempool(void *arg)
{
mp_pool_t *pool = NULL;
smartlist_t *allocated = NULL;
int i;
+ (void)arg;
pool = mp_pool_new(1, 100);
- test_assert(pool);
- test_assert(pool->new_chunk_capacity >= 100);
- test_assert(pool->item_alloc_size >= sizeof(void*)+1);
+ tt_assert(pool);
+ tt_assert(pool->new_chunk_capacity >= 100);
+ tt_assert(pool->item_alloc_size >= sizeof(void*)+1);
mp_pool_destroy(pool);
pool = NULL;
pool = mp_pool_new(241, 2500);
- test_assert(pool);
- test_assert(pool->new_chunk_capacity >= 10);
- test_assert(pool->item_alloc_size >= sizeof(void*)+241);
- test_eq(pool->item_alloc_size & 0x03, 0);
- test_assert(pool->new_chunk_capacity < 60);
+ tt_assert(pool);
+ tt_assert(pool->new_chunk_capacity >= 10);
+ tt_assert(pool->item_alloc_size >= sizeof(void*)+241);
+ tt_int_op(pool->item_alloc_size & 0x03,==, 0);
+ tt_assert(pool->new_chunk_capacity < 60);
allocated = smartlist_new();
for (i = 0; i < 20000; ++i) {
@@ -1960,39 +2836,40 @@ test_util_mempool(void)
/** Run unittests for memory area allocator */
static void
-test_util_memarea(void)
+test_util_memarea(void *arg)
{
memarea_t *area = memarea_new();
char *p1, *p2, *p3, *p1_orig;
void *malloced_ptr = NULL;
int i;
- test_assert(area);
+ (void)arg;
+ tt_assert(area);
p1_orig = p1 = memarea_alloc(area,64);
p2 = memarea_alloc_zero(area,52);
p3 = memarea_alloc(area,11);
- test_assert(memarea_owns_ptr(area, p1));
- test_assert(memarea_owns_ptr(area, p2));
- test_assert(memarea_owns_ptr(area, p3));
+ tt_assert(memarea_owns_ptr(area, p1));
+ tt_assert(memarea_owns_ptr(area, p2));
+ tt_assert(memarea_owns_ptr(area, p3));
/* Make sure we left enough space. */
- test_assert(p1+64 <= p2);
- test_assert(p2+52 <= p3);
+ tt_assert(p1+64 <= p2);
+ tt_assert(p2+52 <= p3);
/* Make sure we aligned. */
- test_eq(((uintptr_t)p1) % sizeof(void*), 0);
- test_eq(((uintptr_t)p2) % sizeof(void*), 0);
- test_eq(((uintptr_t)p3) % sizeof(void*), 0);
- test_assert(!memarea_owns_ptr(area, p3+8192));
- test_assert(!memarea_owns_ptr(area, p3+30));
- test_assert(tor_mem_is_zero(p2, 52));
+ tt_int_op(((uintptr_t)p1) % sizeof(void*),==, 0);
+ tt_int_op(((uintptr_t)p2) % sizeof(void*),==, 0);
+ tt_int_op(((uintptr_t)p3) % sizeof(void*),==, 0);
+ tt_assert(!memarea_owns_ptr(area, p3+8192));
+ tt_assert(!memarea_owns_ptr(area, p3+30));
+ tt_assert(tor_mem_is_zero(p2, 52));
/* Make sure we don't overalign. */
p1 = memarea_alloc(area, 1);
p2 = memarea_alloc(area, 1);
- test_eq_ptr(p1+sizeof(void*), p2);
+ tt_ptr_op(p1+sizeof(void*),==, p2);
{
malloced_ptr = tor_malloc(64);
- test_assert(!memarea_owns_ptr(area, malloced_ptr));
+ tt_assert(!memarea_owns_ptr(area, malloced_ptr));
tor_free(malloced_ptr);
}
@@ -2001,18 +2878,18 @@ test_util_memarea(void)
malloced_ptr = tor_malloc(64);
crypto_rand((char*)malloced_ptr, 64);
p1 = memarea_memdup(area, malloced_ptr, 64);
- test_assert(p1 != malloced_ptr);
- test_memeq(p1, malloced_ptr, 64);
+ tt_assert(p1 != malloced_ptr);
+ tt_mem_op(p1,==, malloced_ptr, 64);
tor_free(malloced_ptr);
}
/* memarea_strdup. */
p1 = memarea_strdup(area,"");
p2 = memarea_strdup(area, "abcd");
- test_assert(p1);
- test_assert(p2);
- test_streq(p1, "");
- test_streq(p2, "abcd");
+ tt_assert(p1);
+ tt_assert(p2);
+ tt_str_op(p1,==, "");
+ tt_str_op(p2,==, "abcd");
/* memarea_strndup. */
{
@@ -2021,33 +2898,33 @@ test_util_memarea(void)
size_t len = strlen(s);
p1 = memarea_strndup(area, s, 1000);
p2 = memarea_strndup(area, s, 10);
- test_streq(p1, s);
- test_assert(p2 >= p1 + len + 1);
- test_memeq(s, p2, 10);
- test_eq(p2[10], '\0');
+ tt_str_op(p1,==, s);
+ tt_assert(p2 >= p1 + len + 1);
+ tt_mem_op(s,==, p2, 10);
+ tt_int_op(p2[10],==, '\0');
p3 = memarea_strndup(area, s, len);
- test_streq(p3, s);
+ tt_str_op(p3,==, s);
p3 = memarea_strndup(area, s, len-1);
- test_memeq(s, p3, len-1);
- test_eq(p3[len-1], '\0');
+ tt_mem_op(s,==, p3, len-1);
+ tt_int_op(p3[len-1],==, '\0');
}
memarea_clear(area);
p1 = memarea_alloc(area, 1);
- test_eq_ptr(p1, p1_orig);
+ tt_ptr_op(p1,==, p1_orig);
memarea_clear(area);
/* Check for running over an area's size. */
for (i = 0; i < 512; ++i) {
p1 = memarea_alloc(area, crypto_rand_int(5)+1);
- test_assert(memarea_owns_ptr(area, p1));
+ tt_assert(memarea_owns_ptr(area, p1));
}
memarea_assert_ok(area);
/* Make sure we can allocate a too-big object. */
p1 = memarea_alloc_zero(area, 9000);
p2 = memarea_alloc_zero(area, 16);
- test_assert(memarea_owns_ptr(area, p1));
- test_assert(memarea_owns_ptr(area, p2));
+ tt_assert(memarea_owns_ptr(area, p1));
+ tt_assert(memarea_owns_ptr(area, p2));
done:
memarea_drop_all(area);
@@ -2057,31 +2934,32 @@ test_util_memarea(void)
/** Run unit tests for utility functions to get file names relative to
* the data directory. */
static void
-test_util_datadir(void)
+test_util_datadir(void *arg)
{
char buf[1024];
char *f = NULL;
char *temp_dir = NULL;
+ (void)arg;
temp_dir = get_datadir_fname(NULL);
f = get_datadir_fname("state");
tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"state", temp_dir);
- test_streq(f, buf);
+ tt_str_op(f,==, buf);
tor_free(f);
f = get_datadir_fname2("cache", "thingy");
tor_snprintf(buf, sizeof(buf),
"%s"PATH_SEPARATOR"cache"PATH_SEPARATOR"thingy", temp_dir);
- test_streq(f, buf);
+ tt_str_op(f,==, buf);
tor_free(f);
f = get_datadir_fname2_suffix("cache", "thingy", ".foo");
tor_snprintf(buf, sizeof(buf),
"%s"PATH_SEPARATOR"cache"PATH_SEPARATOR"thingy.foo", temp_dir);
- test_streq(f, buf);
+ tt_str_op(f,==, buf);
tor_free(f);
f = get_datadir_fname_suffix("cache", ".foo");
tor_snprintf(buf, sizeof(buf), "%s"PATH_SEPARATOR"cache.foo",
temp_dir);
- test_streq(f, buf);
+ tt_str_op(f,==, buf);
done:
tor_free(f);
@@ -2089,13 +2967,14 @@ test_util_datadir(void)
}
static void
-test_util_strtok(void)
+test_util_strtok(void *arg)
{
char buf[128];
char buf2[128];
int i;
char *cp1, *cp2;
+ (void)arg;
for (i = 0; i < 3; i++) {
const char *pad1="", *pad2="";
switch (i) {
@@ -2112,8 +2991,8 @@ test_util_strtok(void)
}
tor_snprintf(buf, sizeof(buf), "%s", pad1);
tor_snprintf(buf2, sizeof(buf2), "%s", pad2);
- test_assert(NULL == tor_strtok_r_impl(buf, " ", &cp1));
- test_assert(NULL == tor_strtok_r_impl(buf2, ".!..;!", &cp2));
+ tt_assert(NULL == tor_strtok_r_impl(buf, " ", &cp1));
+ tt_assert(NULL == tor_strtok_r_impl(buf2, ".!..;!", &cp2));
tor_snprintf(buf, sizeof(buf),
"%sGraved on the dark in gestures of descent%s", pad1, pad1);
@@ -2121,43 +3000,43 @@ test_util_strtok(void)
"%sthey.seemed;;their!.own;most.perfect;monument%s",pad2,pad2);
/* -- "Year's End", Richard Wilbur */
- test_streq("Graved", tor_strtok_r_impl(buf, " ", &cp1));
- test_streq("they", tor_strtok_r_impl(buf2, ".!..;!", &cp2));
+ tt_str_op("Graved",==, tor_strtok_r_impl(buf, " ", &cp1));
+ tt_str_op("they",==, tor_strtok_r_impl(buf2, ".!..;!", &cp2));
#define S1() tor_strtok_r_impl(NULL, " ", &cp1)
#define S2() tor_strtok_r_impl(NULL, ".!..;!", &cp2)
- test_streq("on", S1());
- test_streq("the", S1());
- test_streq("dark", S1());
- test_streq("seemed", S2());
- test_streq("their", S2());
- test_streq("own", S2());
- test_streq("in", S1());
- test_streq("gestures", S1());
- test_streq("of", S1());
- test_streq("most", S2());
- test_streq("perfect", S2());
- test_streq("descent", S1());
- test_streq("monument", S2());
- test_eq_ptr(NULL, S1());
- test_eq_ptr(NULL, S2());
+ tt_str_op("on",==, S1());
+ tt_str_op("the",==, S1());
+ tt_str_op("dark",==, S1());
+ tt_str_op("seemed",==, S2());
+ tt_str_op("their",==, S2());
+ tt_str_op("own",==, S2());
+ tt_str_op("in",==, S1());
+ tt_str_op("gestures",==, S1());
+ tt_str_op("of",==, S1());
+ tt_str_op("most",==, S2());
+ tt_str_op("perfect",==, S2());
+ tt_str_op("descent",==, S1());
+ tt_str_op("monument",==, S2());
+ tt_ptr_op(NULL,==, S1());
+ tt_ptr_op(NULL,==, S2());
}
buf[0] = 0;
- test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
- test_eq_ptr(NULL, tor_strtok_r_impl(buf, "!", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, "!", &cp1));
strlcpy(buf, "Howdy!", sizeof(buf));
- test_streq("Howdy", tor_strtok_r_impl(buf, "!", &cp1));
- test_eq_ptr(NULL, tor_strtok_r_impl(NULL, "!", &cp1));
+ tt_str_op("Howdy",==, tor_strtok_r_impl(buf, "!", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(NULL, "!", &cp1));
strlcpy(buf, " ", sizeof(buf));
- test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1));
strlcpy(buf, " ", sizeof(buf));
- test_eq_ptr(NULL, tor_strtok_r_impl(buf, " ", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(buf, " ", &cp1));
strlcpy(buf, "something ", sizeof(buf));
- test_streq("something", tor_strtok_r_impl(buf, " ", &cp1));
- test_eq_ptr(NULL, tor_strtok_r_impl(NULL, ";", &cp1));
+ tt_str_op("something",==, tor_strtok_r_impl(buf, " ", &cp1));
+ tt_ptr_op(NULL,==, tor_strtok_r_impl(NULL, ";", &cp1));
done:
;
}
@@ -2177,23 +3056,24 @@ test_util_find_str_at_start_of_line(void *ptr)
(void)ptr;
- test_eq_ptr(long_string, find_str_at_start_of_line(long_string, ""));
- test_eq_ptr(NULL, find_str_at_start_of_line(short_string, "nonsense"));
- test_eq_ptr(NULL, find_str_at_start_of_line(long_string, "nonsense"));
- test_eq_ptr(NULL, find_str_at_start_of_line(long_string, "\n"));
- test_eq_ptr(NULL, find_str_at_start_of_line(long_string, "how "));
- test_eq_ptr(NULL, find_str_at_start_of_line(long_string, "kitty"));
- test_eq_ptr(long_string, find_str_at_start_of_line(long_string, "h"));
- test_eq_ptr(long_string, find_str_at_start_of_line(long_string, "how"));
- test_eq_ptr(line2, find_str_at_start_of_line(long_string, "he"));
- test_eq_ptr(line2, find_str_at_start_of_line(long_string, "hell"));
- test_eq_ptr(line2, find_str_at_start_of_line(long_string, "hello k"));
- test_eq_ptr(line2, find_str_at_start_of_line(long_string, "hello kitty\n"));
- test_eq_ptr(line2, find_str_at_start_of_line(long_string, "hello kitty\nt"));
- test_eq_ptr(line3, find_str_at_start_of_line(long_string, "third"));
- test_eq_ptr(line3, find_str_at_start_of_line(long_string, "third line"));
- test_eq_ptr(NULL, find_str_at_start_of_line(long_string, "third line\n"));
- test_eq_ptr(short_line2, find_str_at_start_of_line(short_string,
+ tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, ""));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(short_string, "nonsense"));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "nonsense"));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "\n"));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "how "));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "kitty"));
+ tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, "h"));
+ tt_ptr_op(long_string,==, find_str_at_start_of_line(long_string, "how"));
+ tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "he"));
+ tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hell"));
+ tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hello k"));
+ tt_ptr_op(line2,==, find_str_at_start_of_line(long_string, "hello kitty\n"));
+ tt_ptr_op(line2,==,
+ find_str_at_start_of_line(long_string, "hello kitty\nt"));
+ tt_ptr_op(line3,==, find_str_at_start_of_line(long_string, "third"));
+ tt_ptr_op(line3,==, find_str_at_start_of_line(long_string, "third line"));
+ tt_ptr_op(NULL,==, find_str_at_start_of_line(long_string, "third line\n"));
+ tt_ptr_op(short_line2,==, find_str_at_start_of_line(short_string,
"second line\n"));
done:
;
@@ -2204,25 +3084,25 @@ test_util_string_is_C_identifier(void *ptr)
{
(void)ptr;
- test_eq(1, string_is_C_identifier("string_is_C_identifier"));
- test_eq(1, string_is_C_identifier("_string_is_C_identifier"));
- test_eq(1, string_is_C_identifier("_"));
- test_eq(1, string_is_C_identifier("i"));
- test_eq(1, string_is_C_identifier("_____"));
- test_eq(1, string_is_C_identifier("__00__"));
- test_eq(1, string_is_C_identifier("__init__"));
- test_eq(1, string_is_C_identifier("_0"));
- test_eq(1, string_is_C_identifier("_0string_is_C_identifier"));
- test_eq(1, string_is_C_identifier("_0"));
-
- test_eq(0, string_is_C_identifier("0_string_is_C_identifier"));
- test_eq(0, string_is_C_identifier("0"));
- test_eq(0, string_is_C_identifier(""));
- test_eq(0, string_is_C_identifier(";"));
- test_eq(0, string_is_C_identifier("i;"));
- test_eq(0, string_is_C_identifier("_;"));
- test_eq(0, string_is_C_identifier("í"));
- test_eq(0, string_is_C_identifier("ñ"));
+ tt_int_op(1,==, string_is_C_identifier("string_is_C_identifier"));
+ tt_int_op(1,==, string_is_C_identifier("_string_is_C_identifier"));
+ tt_int_op(1,==, string_is_C_identifier("_"));
+ tt_int_op(1,==, string_is_C_identifier("i"));
+ tt_int_op(1,==, string_is_C_identifier("_____"));
+ tt_int_op(1,==, string_is_C_identifier("__00__"));
+ tt_int_op(1,==, string_is_C_identifier("__init__"));
+ tt_int_op(1,==, string_is_C_identifier("_0"));
+ tt_int_op(1,==, string_is_C_identifier("_0string_is_C_identifier"));
+ tt_int_op(1,==, string_is_C_identifier("_0"));
+
+ tt_int_op(0,==, string_is_C_identifier("0_string_is_C_identifier"));
+ tt_int_op(0,==, string_is_C_identifier("0"));
+ tt_int_op(0,==, string_is_C_identifier(""));
+ tt_int_op(0,==, string_is_C_identifier(";"));
+ tt_int_op(0,==, string_is_C_identifier("i;"));
+ tt_int_op(0,==, string_is_C_identifier("_;"));
+ tt_int_op(0,==, string_is_C_identifier("í"));
+ tt_int_op(0,==, string_is_C_identifier("ñ"));
done:
;
@@ -2239,48 +3119,48 @@ test_util_asprintf(void *ptr)
/* simple string */
r = tor_asprintf(&cp, "simple string 100%% safe");
- test_assert(cp);
- test_streq("simple string 100% safe", cp);
- test_eq(strlen(cp), r);
+ tt_assert(cp);
+ tt_str_op("simple string 100% safe",==, cp);
+ tt_int_op(strlen(cp),==, r);
tor_free(cp);
/* empty string */
r = tor_asprintf(&cp, "%s", "");
- test_assert(cp);
- test_streq("", cp);
- test_eq(strlen(cp), r);
+ tt_assert(cp);
+ tt_str_op("",==, cp);
+ tt_int_op(strlen(cp),==, r);
tor_free(cp);
/* numbers (%i) */
r = tor_asprintf(&cp, "I like numbers-%2i, %i, etc.", -1, 2);
- test_assert(cp);
- test_streq("I like numbers--1, 2, etc.", cp);
- test_eq(strlen(cp), r);
+ tt_assert(cp);
+ tt_str_op("I like numbers--1, 2, etc.",==, cp);
+ tt_int_op(strlen(cp),==, r);
/* don't free cp; next test uses it. */
/* numbers (%d) */
r = tor_asprintf(&cp2, "First=%d, Second=%d", 101, 202);
- test_assert(cp2);
- test_eq(strlen(cp2), r);
- test_streq("First=101, Second=202", cp2);
- test_assert(cp != cp2);
+ tt_assert(cp2);
+ tt_int_op(strlen(cp2),==, r);
+ tt_str_op("First=101, Second=202",==, cp2);
+ tt_assert(cp != cp2);
tor_free(cp);
tor_free(cp2);
/* Glass-box test: a string exactly 128 characters long. */
r = tor_asprintf(&cp, "Lorem1: %sLorem2: %s", LOREMIPSUM, LOREMIPSUM);
- test_assert(cp);
- test_eq(128, r);
- test_assert(cp[128] == '\0');
- test_streq("Lorem1: "LOREMIPSUM"Lorem2: "LOREMIPSUM, cp);
+ tt_assert(cp);
+ tt_int_op(128,==, r);
+ tt_int_op(cp[128], ==, '\0');
+ tt_str_op("Lorem1: "LOREMIPSUM"Lorem2: "LOREMIPSUM,==, cp);
tor_free(cp);
/* String longer than 128 characters */
r = tor_asprintf(&cp, "1: %s 2: %s 3: %s",
LOREMIPSUM, LOREMIPSUM, LOREMIPSUM);
- test_assert(cp);
- test_eq(strlen(cp), r);
- test_streq("1: "LOREMIPSUM" 2: "LOREMIPSUM" 3: "LOREMIPSUM, cp);
+ tt_assert(cp);
+ tt_int_op(strlen(cp),==, r);
+ tt_str_op("1: "LOREMIPSUM" 2: "LOREMIPSUM" 3: "LOREMIPSUM,==, cp);
done:
tor_free(cp);
@@ -2301,9 +3181,9 @@ test_util_listdir(void *ptr)
dir1 = tor_strdup(get_fname("some-directory"));
dirname = tor_strdup(get_fname(NULL));
- test_eq(0, write_str_to_file(fname1, "X\n", 0));
- test_eq(0, write_str_to_file(fname2, "Y\n", 0));
- test_eq(0, write_str_to_file(fname3, "Z\n", 0));
+ tt_int_op(0,==, write_str_to_file(fname1, "X\n", 0));
+ tt_int_op(0,==, write_str_to_file(fname2, "Y\n", 0));
+ tt_int_op(0,==, write_str_to_file(fname3, "Z\n", 0));
#ifdef _WIN32
r = mkdir(dir1);
#else
@@ -2316,15 +3196,15 @@ test_util_listdir(void *ptr)
}
dir_contents = tor_listdir(dirname);
- test_assert(dir_contents);
+ tt_assert(dir_contents);
/* make sure that each filename is listed. */
- test_assert(smartlist_contains_string_case(dir_contents, "hopscotch"));
- test_assert(smartlist_contains_string_case(dir_contents, "mumblety-peg"));
- test_assert(smartlist_contains_string_case(dir_contents, ".hidden-file"));
- test_assert(smartlist_contains_string_case(dir_contents, "some-directory"));
+ tt_assert(smartlist_contains_string_case(dir_contents, "hopscotch"));
+ tt_assert(smartlist_contains_string_case(dir_contents, "mumblety-peg"));
+ tt_assert(smartlist_contains_string_case(dir_contents, ".hidden-file"));
+ tt_assert(smartlist_contains_string_case(dir_contents, "some-directory"));
- test_assert(!smartlist_contains_string(dir_contents, "."));
- test_assert(!smartlist_contains_string(dir_contents, ".."));
+ tt_assert(!smartlist_contains_string(dir_contents, "."));
+ tt_assert(!smartlist_contains_string(dir_contents, ".."));
done:
tor_free(fname1);
@@ -2404,22 +3284,22 @@ test_util_ftruncate(void *ptr)
/* Make the file be there. */
tt_int_op(strlen(message), ==, write_all(fd, message, strlen(message), 0));
- tt_int_op(tor_fd_getpos(fd), ==, strlen(message));
+ tt_int_op((int)tor_fd_getpos(fd), ==, strlen(message));
tt_int_op(0, ==, fstat(fd, &st));
- tt_int_op(st.st_size, ==, strlen(message));
+ tt_int_op((int)st.st_size, ==, strlen(message));
/* Truncate and see if it got truncated */
tt_int_op(0, ==, tor_ftruncate(fd));
- tt_int_op(tor_fd_getpos(fd), ==, 0);
+ tt_int_op((int)tor_fd_getpos(fd), ==, 0);
tt_int_op(0, ==, fstat(fd, &st));
- tt_int_op(st.st_size, ==, 0);
+ tt_int_op((int)st.st_size, ==, 0);
/* Replace, and see if it got replaced */
tt_int_op(strlen(message2), ==,
write_all(fd, message2, strlen(message2), 0));
- tt_int_op(tor_fd_getpos(fd), ==, strlen(message2));
+ tt_int_op((int)tor_fd_getpos(fd), ==, strlen(message2));
tt_int_op(0, ==, fstat(fd, &st));
- tt_int_op(st.st_size, ==, strlen(message2));
+ tt_int_op((int)st.st_size, ==, strlen(message2));
close(fd);
fd = -1;
@@ -2464,30 +3344,53 @@ test_util_exit_status(void *ptr)
(void)ptr;
clear_hex_errno(hex_errno);
+ tt_str_op("",==, hex_errno);
+
+ clear_hex_errno(hex_errno);
n = format_helper_exit_status(0, 0, hex_errno);
- test_streq("0/0\n", hex_errno);
- test_eq(n, strlen(hex_errno));
+ tt_str_op("0/0\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
+
+#if SIZEOF_INT == 4
clear_hex_errno(hex_errno);
n = format_helper_exit_status(0, 0x7FFFFFFF, hex_errno);
- test_streq("0/7FFFFFFF\n", hex_errno);
- test_eq(n, strlen(hex_errno));
+ tt_str_op("0/7FFFFFFF\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
clear_hex_errno(hex_errno);
n = format_helper_exit_status(0xFF, -0x80000000, hex_errno);
- test_streq("FF/-80000000\n", hex_errno);
- test_eq(n, strlen(hex_errno));
- test_eq(n, HEX_ERRNO_SIZE);
+ tt_str_op("FF/-80000000\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
+ tt_int_op(n,==, HEX_ERRNO_SIZE);
+
+#elif SIZEOF_INT == 8
+
+ clear_hex_errno(hex_errno);
+ n = format_helper_exit_status(0, 0x7FFFFFFFFFFFFFFF, hex_errno);
+ tt_str_op("0/7FFFFFFFFFFFFFFF\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
+
+ clear_hex_errno(hex_errno);
+ n = format_helper_exit_status(0xFF, -0x8000000000000000, hex_errno);
+ tt_str_op("FF/-8000000000000000\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
+ tt_int_op(n,==, HEX_ERRNO_SIZE);
+
+#endif
clear_hex_errno(hex_errno);
n = format_helper_exit_status(0x7F, 0, hex_errno);
- test_streq("7F/0\n", hex_errno);
- test_eq(n, strlen(hex_errno));
+ tt_str_op("7F/0\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
clear_hex_errno(hex_errno);
n = format_helper_exit_status(0x08, -0x242, hex_errno);
- test_streq("8/-242\n", hex_errno);
- test_eq(n, strlen(hex_errno));
+ tt_str_op("8/-242\n",==, hex_errno);
+ tt_int_op(n,==, strlen(hex_errno));
+
+ clear_hex_errno(hex_errno);
+ tt_str_op("",==, hex_errno);
done:
;
@@ -2615,6 +3518,30 @@ test_util_fgets_eagain(void *ptr)
#define EOL "\n"
#endif
+#ifdef _WIN32
+/* I've assumed Windows doesn't have the gap between fork and exec
+ * that causes the race condition on unix-like platforms */
+#define MATCH_PROCESS_STATUS(s1,s2) ((s1) == (s2))
+
+#else
+/* work around a race condition of the timing of SIGCHLD handler updates
+ * to the process_handle's fields, and checks of those fields
+ *
+ * TODO: Once we can signal failure to exec, change PROCESS_STATUS_RUNNING to
+ * PROCESS_STATUS_ERROR (and similarly with *_OR_NOTRUNNING) */
+#define PROCESS_STATUS_RUNNING_OR_NOTRUNNING (PROCESS_STATUS_RUNNING+1)
+#define IS_RUNNING_OR_NOTRUNNING(s) \
+ ((s) == PROCESS_STATUS_RUNNING || (s) == PROCESS_STATUS_NOTRUNNING)
+/* well, this is ugly */
+#define MATCH_PROCESS_STATUS(s1,s2) \
+ ( (s1) == (s2) \
+ ||((s1) == PROCESS_STATUS_RUNNING_OR_NOTRUNNING \
+ && IS_RUNNING_OR_NOTRUNNING(s2)) \
+ ||((s2) == PROCESS_STATUS_RUNNING_OR_NOTRUNNING \
+ && IS_RUNNING_OR_NOTRUNNING(s1)))
+
+#endif // _WIN32
+
/** Helper function for testing tor_spawn_background */
static void
run_util_spawn_background(const char *argv[], const char *expected_out,
@@ -2636,26 +3563,47 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
notify_pending_waitpid_callbacks();
- test_eq(expected_status, status);
+ /* the race condition doesn't affect status,
+ * because status isn't updated by the SIGCHLD handler,
+ * but we still need to handle PROCESS_STATUS_RUNNING_OR_NOTRUNNING */
+ tt_assert(MATCH_PROCESS_STATUS(expected_status, status));
if (status == PROCESS_STATUS_ERROR) {
tt_ptr_op(process_handle, ==, NULL);
return;
}
- test_assert(process_handle != NULL);
- test_eq(expected_status, process_handle->status);
+ tt_assert(process_handle != NULL);
+
+ /* When a spawned process forks, fails, then exits very quickly,
+ * (this typically occurs when exec fails)
+ * there is a race condition between the SIGCHLD handler
+ * updating the process_handle's fields, and this test
+ * checking the process status in those fields.
+ * The SIGCHLD update can occur before or after the code below executes.
+ * This causes intermittent failures in spawn_background_fail(),
+ * typically when the machine is under load.
+ * We use PROCESS_STATUS_RUNNING_OR_NOTRUNNING to avoid this issue. */
+
+ /* the race condition affects the change in
+ * process_handle->status from RUNNING to NOTRUNNING */
+ tt_assert(MATCH_PROCESS_STATUS(expected_status, process_handle->status));
#ifndef _WIN32
notify_pending_waitpid_callbacks();
- tt_ptr_op(process_handle->waitpid_cb, !=, NULL);
+ /* the race condition affects the change in
+ * process_handle->waitpid_cb to NULL,
+ * so we skip the check if expected_status is ambiguous,
+ * that is, PROCESS_STATUS_RUNNING_OR_NOTRUNNING */
+ tt_assert(process_handle->waitpid_cb != NULL
+ || expected_status == PROCESS_STATUS_RUNNING_OR_NOTRUNNING);
#endif
#ifdef _WIN32
- test_assert(process_handle->stdout_pipe != INVALID_HANDLE_VALUE);
- test_assert(process_handle->stderr_pipe != INVALID_HANDLE_VALUE);
+ tt_assert(process_handle->stdout_pipe != INVALID_HANDLE_VALUE);
+ tt_assert(process_handle->stderr_pipe != INVALID_HANDLE_VALUE);
#else
- test_assert(process_handle->stdout_pipe >= 0);
- test_assert(process_handle->stderr_pipe >= 0);
+ tt_assert(process_handle->stdout_pipe >= 0);
+ tt_assert(process_handle->stderr_pipe >= 0);
#endif
/* Check stdout */
@@ -2663,15 +3611,15 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
sizeof(stdout_buf) - 1);
tt_assert(pos >= 0);
stdout_buf[pos] = '\0';
- test_eq(strlen(expected_out), pos);
- test_streq(expected_out, stdout_buf);
+ tt_int_op(strlen(expected_out),==, pos);
+ tt_str_op(expected_out,==, stdout_buf);
notify_pending_waitpid_callbacks();
/* Check it terminated correctly */
retval = tor_get_exit_code(process_handle, 1, &exit_code);
- test_eq(PROCESS_EXIT_EXITED, retval);
- test_eq(expected_exit, exit_code);
+ tt_int_op(PROCESS_EXIT_EXITED,==, retval);
+ tt_int_op(expected_exit,==, exit_code);
// TODO: Make test-child exit with something other than 0
#ifndef _WIN32
@@ -2682,10 +3630,10 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
/* Check stderr */
pos = tor_read_all_from_process_stderr(process_handle, stderr_buf,
sizeof(stderr_buf) - 1);
- test_assert(pos >= 0);
+ tt_assert(pos >= 0);
stderr_buf[pos] = '\0';
- test_streq(expected_err, stderr_buf);
- test_eq(strlen(expected_err), pos);
+ tt_str_op(expected_err,==, stderr_buf);
+ tt_int_op(strlen(expected_err),==, pos);
notify_pending_waitpid_callbacks();
@@ -2720,10 +3668,13 @@ test_util_spawn_background_fail(void *ptr)
const int expected_status = PROCESS_STATUS_ERROR;
#else
/* TODO: Once we can signal failure to exec, set this to be
- * PROCESS_STATUS_ERROR */
- const int expected_status = PROCESS_STATUS_RUNNING;
+ * PROCESS_STATUS_RUNNING_OR_ERROR */
+ const int expected_status = PROCESS_STATUS_RUNNING_OR_NOTRUNNING;
#endif
+ memset(expected_out, 0xf0, sizeof(expected_out));
+ memset(code, 0xf0, sizeof(code));
+
(void)ptr;
tor_snprintf(code, sizeof(code), "%x/%x",
@@ -2771,9 +3722,9 @@ test_util_spawn_background_partial_read_impl(int exit_early)
#else
status = tor_spawn_background(argv[0], argv, NULL, &process_handle);
#endif
- test_eq(expected_status, status);
- test_assert(process_handle);
- test_eq(expected_status, process_handle->status);
+ tt_int_op(expected_status,==, status);
+ tt_assert(process_handle);
+ tt_int_op(expected_status,==, process_handle->status);
/* Check stdout */
for (expected_out_ctr = 0; expected_out[expected_out_ctr] != NULL;) {
@@ -2782,7 +3733,7 @@ test_util_spawn_background_partial_read_impl(int exit_early)
sizeof(stdout_buf) - 1, NULL);
#else
/* Check that we didn't read the end of file last time */
- test_assert(!eof);
+ tt_assert(!eof);
pos = tor_read_all_handle(process_handle->stdout_handle, stdout_buf,
sizeof(stdout_buf) - 1, NULL, &eof);
#endif
@@ -2792,10 +3743,10 @@ test_util_spawn_background_partial_read_impl(int exit_early)
if (0 == pos)
continue;
- test_assert(pos > 0);
+ tt_assert(pos > 0);
stdout_buf[pos] = '\0';
- test_streq(expected_out[expected_out_ctr], stdout_buf);
- test_eq(strlen(expected_out[expected_out_ctr]), pos);
+ tt_str_op(expected_out[expected_out_ctr],==, stdout_buf);
+ tt_int_op(strlen(expected_out[expected_out_ctr]),==, pos);
expected_out_ctr++;
}
@@ -2810,33 +3761,33 @@ test_util_spawn_background_partial_read_impl(int exit_early)
pos = tor_read_all_handle(process_handle->stdout_pipe, stdout_buf,
sizeof(stdout_buf) - 1,
process_handle);
- test_eq(0, pos);
+ tt_int_op(0,==, pos);
#else
if (!eof) {
/* We should have got all the data, but maybe not the EOF flag */
pos = tor_read_all_handle(process_handle->stdout_handle, stdout_buf,
sizeof(stdout_buf) - 1,
process_handle, &eof);
- test_eq(0, pos);
- test_assert(eof);
+ tt_int_op(0,==, pos);
+ tt_assert(eof);
}
/* Otherwise, we got the EOF on the last read */
#endif
/* Check it terminated correctly */
retval = tor_get_exit_code(process_handle, 1, &exit_code);
- test_eq(PROCESS_EXIT_EXITED, retval);
- test_eq(expected_exit, exit_code);
+ tt_int_op(PROCESS_EXIT_EXITED,==, retval);
+ tt_int_op(expected_exit,==, exit_code);
// TODO: Make test-child exit with something other than 0
/* Check stderr */
pos = tor_read_all_from_process_stderr(process_handle, stderr_buf,
sizeof(stderr_buf) - 1);
- test_assert(pos >= 0);
+ tt_assert(pos >= 0);
stderr_buf[pos] = '\0';
- test_streq(expected_err, stderr_buf);
- test_eq(strlen(expected_err), pos);
+ tt_str_op(expected_err,==, stderr_buf);
+ tt_int_op(strlen(expected_err),==, pos);
done:
tor_process_handle_destroy(process_handle, 1);
@@ -2911,6 +3862,13 @@ test_util_spawn_background_waitpid_notify(void *arg)
#undef TEST_CHILD
#undef EOL
+#undef MATCH_PROCESS_STATUS
+
+#ifndef _WIN32
+#undef PROCESS_STATUS_RUNNING_OR_NOTRUNNING
+#undef IS_RUNNING_OR_NOTRUNNING
+#endif
+
/**
* Test for format_hex_number_sigsafe()
*/
@@ -2941,15 +3899,15 @@ test_util_format_hex_number(void *ptr)
for (i = 0; test_data[i].str != NULL; ++i) {
len = format_hex_number_sigsafe(test_data[i].x, buf, sizeof(buf));
- test_neq(len, 0);
- test_eq(len, strlen(buf));
- test_streq(buf, test_data[i].str);
+ tt_int_op(len,!=, 0);
+ tt_int_op(len,==, strlen(buf));
+ tt_str_op(buf,==, test_data[i].str);
}
- test_eq(4, format_hex_number_sigsafe(0xffff, buf, 5));
- test_streq(buf, "FFFF");
- test_eq(0, format_hex_number_sigsafe(0xffff, buf, 4));
- test_eq(0, format_hex_number_sigsafe(0, buf, 1));
+ tt_int_op(4,==, format_hex_number_sigsafe(0xffff, buf, 5));
+ tt_str_op(buf,==, "FFFF");
+ tt_int_op(0,==, format_hex_number_sigsafe(0xffff, buf, 4));
+ tt_int_op(0,==, format_hex_number_sigsafe(0, buf, 1));
done:
return;
@@ -2985,21 +3943,21 @@ test_util_format_dec_number(void *ptr)
for (i = 0; test_data[i].str != NULL; ++i) {
len = format_dec_number_sigsafe(test_data[i].x, buf, sizeof(buf));
- test_neq(len, 0);
- test_eq(len, strlen(buf));
- test_streq(buf, test_data[i].str);
+ tt_int_op(len,!=, 0);
+ tt_int_op(len,==, strlen(buf));
+ tt_str_op(buf,==, test_data[i].str);
len = format_dec_number_sigsafe(test_data[i].x, buf,
(int)(strlen(test_data[i].str) + 1));
- test_eq(len, strlen(buf));
- test_streq(buf, test_data[i].str);
+ tt_int_op(len,==, strlen(buf));
+ tt_str_op(buf,==, test_data[i].str);
}
- test_eq(4, format_dec_number_sigsafe(7331, buf, 5));
- test_streq(buf, "7331");
- test_eq(0, format_dec_number_sigsafe(7331, buf, 4));
- test_eq(1, format_dec_number_sigsafe(0, buf, 2));
- test_eq(0, format_dec_number_sigsafe(0, buf, 1));
+ tt_int_op(4,==, format_dec_number_sigsafe(7331, buf, 5));
+ tt_str_op(buf,==, "7331");
+ tt_int_op(0,==, format_dec_number_sigsafe(7331, buf, 4));
+ tt_int_op(1,==, format_dec_number_sigsafe(0, buf, 2));
+ tt_int_op(0,==, format_dec_number_sigsafe(0, buf, 1));
done:
return;
@@ -3048,7 +4006,7 @@ test_util_join_win_cmdline(void *ptr)
for (i=0; cmdlines[i]!=NULL; i++) {
log_info(LD_GENERAL, "Joining argvs[%d], expecting <%s>", i, cmdlines[i]);
joined_argv = tor_join_win_cmdline(argvs[i]);
- test_streq(cmdlines[i], joined_argv);
+ tt_str_op(cmdlines[i],==, joined_argv);
tor_free(joined_argv);
}
@@ -3103,17 +4061,17 @@ test_util_split_lines(void *ptr)
i, tests[i].orig_length);
SMARTLIST_FOREACH_BEGIN(sl, const char *, line) {
/* Check we have not got too many lines */
- test_assert(j < MAX_SPLIT_LINE_COUNT);
+ tt_int_op(MAX_SPLIT_LINE_COUNT, >, j);
/* Check that there actually should be a line here */
- test_assert(tests[i].split_line[j] != NULL);
+ tt_assert(tests[i].split_line[j] != NULL);
log_info(LD_GENERAL, "Line %d of test %d, should be <%s>",
j, i, tests[i].split_line[j]);
/* Check that the line is as expected */
- test_streq(line, tests[i].split_line[j]);
+ tt_str_op(line,==, tests[i].split_line[j]);
j++;
} SMARTLIST_FOREACH_END(line);
/* Check that we didn't miss some lines */
- test_eq_ptr(NULL, tests[i].split_line[j]);
+ tt_ptr_op(NULL,==, tests[i].split_line[j]);
tor_free(orig_line);
smartlist_free(sl);
sl = NULL;
@@ -3125,7 +4083,7 @@ test_util_split_lines(void *ptr)
}
static void
-test_util_di_ops(void)
+test_util_di_ops(void *arg)
{
#define LT -1
#define GT 1
@@ -3145,10 +4103,11 @@ test_util_di_ops(void)
int i;
+ (void)arg;
for (i = 0; examples[i].a; ++i) {
size_t len = strlen(examples[i].a);
int eq1, eq2, neq1, neq2, cmp1, cmp2;
- test_eq(len, strlen(examples[i].b));
+ tt_int_op(len,==, strlen(examples[i].b));
/* We do all of the operations, with operands in both orders. */
eq1 = tor_memeq(examples[i].a, examples[i].b, len);
eq2 = tor_memeq(examples[i].b, examples[i].a, len);
@@ -3159,18 +4118,37 @@ test_util_di_ops(void)
/* Check for correctness of cmp1 */
if (cmp1 < 0 && examples[i].want_sign != LT)
- test_fail();
+ TT_DIE(("Assertion failed."));
else if (cmp1 > 0 && examples[i].want_sign != GT)
- test_fail();
+ TT_DIE(("Assertion failed."));
else if (cmp1 == 0 && examples[i].want_sign != EQ)
- test_fail();
+ TT_DIE(("Assertion failed."));
/* Check for consistency of everything else with cmp1 */
- test_eq(eq1, eq2);
- test_eq(neq1, neq2);
- test_eq(cmp1, -cmp2);
- test_eq(eq1, cmp1 == 0);
- test_eq(neq1, !eq1);
+ tt_int_op(eq1,==, eq2);
+ tt_int_op(neq1,==, neq2);
+ tt_int_op(cmp1,==, -cmp2);
+ tt_int_op(eq1,==, cmp1 == 0);
+ tt_int_op(neq1,==, !eq1);
+ }
+
+ {
+ uint8_t zz = 0;
+ uint8_t ii = 0;
+ int z;
+
+ /* exhaustively test tor_memeq and tor_memcmp
+ * against each possible single-byte numeric difference
+ * some arithmetic bugs only appear with certain bit patterns */
+ for (z = 0; z < 256; z++) {
+ for (i = 0; i < 256; i++) {
+ ii = (uint8_t)i;
+ zz = (uint8_t)z;
+ tt_int_op(tor_memeq(&zz, &ii, 1),==, zz == ii);
+ tt_int_op(tor_memcmp(&zz, &ii, 1) > 0 ? GT : EQ,==, zz > ii ? GT : EQ);
+ tt_int_op(tor_memcmp(&ii, &zz, 1) < 0 ? LT : EQ,==, ii < zz ? LT : EQ);
+ }
+ }
}
tt_int_op(1, ==, safe_mem_is_zero("", 0));
@@ -3194,12 +4172,12 @@ static void
test_util_n_bits_set(void *ptr)
{
(void)ptr;
- test_eq(0, n_bits_set_u8(0));
- test_eq(1, n_bits_set_u8(1));
- test_eq(3, n_bits_set_u8(7));
- test_eq(1, n_bits_set_u8(8));
- test_eq(2, n_bits_set_u8(129));
- test_eq(8, n_bits_set_u8(255));
+ tt_int_op(0,==, n_bits_set_u8(0));
+ tt_int_op(1,==, n_bits_set_u8(1));
+ tt_int_op(3,==, n_bits_set_u8(7));
+ tt_int_op(1,==, n_bits_set_u8(8));
+ tt_int_op(2,==, n_bits_set_u8(129));
+ tt_int_op(8,==, n_bits_set_u8(255));
done:
;
}
@@ -3220,78 +4198,78 @@ test_util_eat_whitespace(void *ptr)
strlcpy(str, "fuubaar", sizeof(str));
for (i = 0; i < sizeof(ws); ++i) {
str[0] = ws[i];
- test_eq_ptr(str + 1, eat_whitespace(str));
- test_eq_ptr(str + 1, eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + 1, eat_whitespace_no_nl(str));
- test_eq_ptr(str + 1, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_ptr_op(str + 1,==, eat_whitespace(str));
+ tt_ptr_op(str + 1,==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str + 1,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str + 1,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
}
str[0] = '\n';
- test_eq_ptr(str + 1, eat_whitespace(str));
- test_eq_ptr(str + 1, eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str, eat_whitespace_no_nl(str));
- test_eq_ptr(str, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_ptr_op(str + 1,==, eat_whitespace(str));
+ tt_ptr_op(str + 1,==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Empty string */
strlcpy(str, "", sizeof(str));
- test_eq_ptr(str, eat_whitespace(str));
- test_eq_ptr(str, eat_whitespace_eos(str, str));
- test_eq_ptr(str, eat_whitespace_no_nl(str));
- test_eq_ptr(str, eat_whitespace_eos_no_nl(str, str));
+ tt_ptr_op(str,==, eat_whitespace(str));
+ tt_ptr_op(str,==, eat_whitespace_eos(str, str));
+ tt_ptr_op(str,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str));
/* Only ws */
strlcpy(str, " \t\r\n", sizeof(str));
- test_eq_ptr(str + strlen(str), eat_whitespace(str));
- test_eq_ptr(str + strlen(str), eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + strlen(str) - 1,
+ tt_ptr_op(str + strlen(str),==, eat_whitespace(str));
+ tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str + strlen(str) - 1,==,
eat_whitespace_no_nl(str));
- test_eq_ptr(str + strlen(str) - 1,
+ tt_ptr_op(str + strlen(str) - 1,==,
eat_whitespace_eos_no_nl(str, str + strlen(str)));
strlcpy(str, " \t\r ", sizeof(str));
- test_eq_ptr(str + strlen(str), eat_whitespace(str));
- test_eq_ptr(str + strlen(str),
+ tt_ptr_op(str + strlen(str),==, eat_whitespace(str));
+ tt_ptr_op(str + strlen(str),==,
eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + strlen(str), eat_whitespace_no_nl(str));
- test_eq_ptr(str + strlen(str),
+ tt_ptr_op(str + strlen(str),==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str + strlen(str),==,
eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Multiple ws */
strlcpy(str, "fuubaar", sizeof(str));
for (i = 0; i < sizeof(ws); ++i)
str[i] = ws[i];
- test_eq_ptr(str + sizeof(ws), eat_whitespace(str));
- test_eq_ptr(str + sizeof(ws), eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + sizeof(ws), eat_whitespace_no_nl(str));
- test_eq_ptr(str + sizeof(ws),
+ tt_ptr_op(str + sizeof(ws),==, eat_whitespace(str));
+ tt_ptr_op(str + sizeof(ws),==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str + sizeof(ws),==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str + sizeof(ws),==,
eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Eat comment */
strlcpy(str, "# Comment \n No Comment", sizeof(str));
- test_streq("No Comment", eat_whitespace(str));
- test_streq("No Comment", eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str, eat_whitespace_no_nl(str));
- test_eq_ptr(str, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_str_op("No Comment",==, eat_whitespace(str));
+ tt_str_op("No Comment",==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Eat comment & ws mix */
strlcpy(str, " # \t Comment \n\t\nNo Comment", sizeof(str));
- test_streq("No Comment", eat_whitespace(str));
- test_streq("No Comment", eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + 1, eat_whitespace_no_nl(str));
- test_eq_ptr(str + 1, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_str_op("No Comment",==, eat_whitespace(str));
+ tt_str_op("No Comment",==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str + 1,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str + 1,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Eat entire comment */
strlcpy(str, "#Comment", sizeof(str));
- test_eq_ptr(str + strlen(str), eat_whitespace(str));
- test_eq_ptr(str + strlen(str), eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str, eat_whitespace_no_nl(str));
- test_eq_ptr(str, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_ptr_op(str + strlen(str),==, eat_whitespace(str));
+ tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
/* Blank line, then comment */
strlcpy(str, " \t\n # Comment", sizeof(str));
- test_eq_ptr(str + strlen(str), eat_whitespace(str));
- test_eq_ptr(str + strlen(str), eat_whitespace_eos(str, str + strlen(str)));
- test_eq_ptr(str + 2, eat_whitespace_no_nl(str));
- test_eq_ptr(str + 2, eat_whitespace_eos_no_nl(str, str + strlen(str)));
+ tt_ptr_op(str + strlen(str),==, eat_whitespace(str));
+ tt_ptr_op(str + strlen(str),==, eat_whitespace_eos(str, str + strlen(str)));
+ tt_ptr_op(str + 2,==, eat_whitespace_no_nl(str));
+ tt_ptr_op(str + 2,==, eat_whitespace_eos_no_nl(str, str + strlen(str)));
done:
;
@@ -3619,12 +4597,12 @@ test_util_round_to_next_multiple_of(void *arg)
{
(void)arg;
- test_assert(round_uint64_to_next_multiple_of(0,1) == 0);
- test_assert(round_uint64_to_next_multiple_of(0,7) == 0);
+ tt_assert(round_uint64_to_next_multiple_of(0,1) == 0);
+ tt_assert(round_uint64_to_next_multiple_of(0,7) == 0);
- test_assert(round_uint64_to_next_multiple_of(99,1) == 99);
- test_assert(round_uint64_to_next_multiple_of(99,7) == 105);
- test_assert(round_uint64_to_next_multiple_of(99,9) == 99);
+ tt_assert(round_uint64_to_next_multiple_of(99,1) == 99);
+ tt_assert(round_uint64_to_next_multiple_of(99,7) == 105);
+ tt_assert(round_uint64_to_next_multiple_of(99,9) == 99);
done:
;
@@ -3651,7 +4629,7 @@ test_util_strclear(void *arg)
}
#define UTIL_LEGACY(name) \
- { #name, legacy_test_helper, 0, &legacy_setup, test_util_ ## name }
+ { #name, test_util_ ## name , 0, NULL, NULL }
#define UTIL_TEST(name, flags) \
{ #name, test_util_ ## name, flags, NULL, NULL }
@@ -3812,6 +4790,52 @@ test_util_max_mem(void *arg)
;
}
+static void
+test_util_hostname_validation(void *arg)
+{
+ (void)arg;
+
+ // Lets try valid hostnames first.
+ tt_assert(string_is_valid_hostname("torproject.org"));
+ tt_assert(string_is_valid_hostname("ocw.mit.edu"));
+ tt_assert(string_is_valid_hostname("i.4cdn.org"));
+ tt_assert(string_is_valid_hostname("stanford.edu"));
+ tt_assert(string_is_valid_hostname("multiple-words-with-hypens.jp"));
+
+ // Subdomain name cannot start with '-'.
+ tt_assert(!string_is_valid_hostname("-torproject.org"));
+ tt_assert(!string_is_valid_hostname("subdomain.-domain.org"));
+ tt_assert(!string_is_valid_hostname("-subdomain.domain.org"));
+
+ // Hostnames cannot contain non-alphanumeric characters.
+ tt_assert(!string_is_valid_hostname("%%domain.\\org."));
+ tt_assert(!string_is_valid_hostname("***x.net"));
+ tt_assert(!string_is_valid_hostname("___abc.org"));
+ tt_assert(!string_is_valid_hostname("\xff\xffxyz.org"));
+ tt_assert(!string_is_valid_hostname("word1 word2.net"));
+
+ // XXX: do we allow single-label DNS names?
+
+ done:
+ return;
+}
+
+static void
+test_util_ipv4_validation(void *arg)
+{
+ (void)arg;
+
+ tt_assert(string_is_valid_ipv4_address("192.168.0.1"));
+ tt_assert(string_is_valid_ipv4_address("8.8.8.8"));
+
+ tt_assert(!string_is_valid_ipv4_address("abcd"));
+ tt_assert(!string_is_valid_ipv4_address("300.300.300.300"));
+ tt_assert(!string_is_valid_ipv4_address("8.8."));
+
+ done:
+ return;
+}
+
struct testcase_t util_tests[] = {
UTIL_LEGACY(time),
UTIL_TEST(parse_http_time, 0),
@@ -3836,6 +4860,7 @@ struct testcase_t util_tests[] = {
UTIL_LEGACY(mmap),
UTIL_LEGACY(threads),
UTIL_LEGACY(sscanf),
+ UTIL_LEGACY(format_time_interval),
UTIL_LEGACY(path_is_relative),
UTIL_LEGACY(strtok),
UTIL_LEGACY(di_ops),
@@ -3870,7 +4895,10 @@ struct testcase_t util_tests[] = {
UTIL_TEST(make_environment, 0),
UTIL_TEST(set_env_var_in_sl, 0),
UTIL_TEST(read_file_eof_tiny_limit, 0),
+ UTIL_TEST(read_file_eof_one_loop_a, 0),
+ UTIL_TEST(read_file_eof_one_loop_b, 0),
UTIL_TEST(read_file_eof_two_loops, 0),
+ UTIL_TEST(read_file_eof_two_loops_b, 0),
UTIL_TEST(read_file_eof_zero_bytes, 0),
UTIL_TEST(write_chunks_to_file, 0),
UTIL_TEST(mathlog, 0),
@@ -3881,6 +4909,8 @@ struct testcase_t util_tests[] = {
{ "socketpair_ersatz", test_util_socketpair, TT_FORK,
&socketpair_setup, (void*)"1" },
UTIL_TEST(max_mem, 0),
+ UTIL_TEST(hostname_validation, 0),
+ UTIL_TEST(ipv4_validation, 0),
END_OF_TESTCASES
};
diff --git a/src/tools/tor-checkkey.c b/src/tools/tor-checkkey.c
index d50f12ed2a..f6c6508c33 100644
--- a/src/tools/tor-checkkey.c
+++ b/src/tools/tor-checkkey.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008-2013, The Tor Project, Inc. */
+/* Copyright (c) 2008-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -21,7 +21,7 @@ main(int c, char **v)
int wantdigest=0;
int fname_idx;
char *fname=NULL;
- init_logging();
+ init_logging(1);
if (c < 2) {
fprintf(stderr, "Hi. I'm tor-checkkey. Tell me a filename that "
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
index 41eb9dcb76..74485f9803 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h
index 2d924ce750..1bfebd91f9 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h
+++ b/src/tools/tor-fw-helper/tor-fw-helper-natpmp.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-upnp.c b/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
index 692186d372..59bc232dd3 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper-upnp.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-fw-helper/tor-fw-helper-upnp.h b/src/tools/tor-fw-helper/tor-fw-helper-upnp.h
index b6c7ed8643..9a5123e09f 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper-upnp.h
+++ b/src/tools/tor-fw-helper/tor-fw-helper-upnp.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-fw-helper/tor-fw-helper.c b/src/tools/tor-fw-helper/tor-fw-helper.c
index 84cc21e346..9a32b0cbe2 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper.c
+++ b/src/tools/tor-fw-helper/tor-fw-helper.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-fw-helper/tor-fw-helper.h b/src/tools/tor-fw-helper/tor-fw-helper.h
index 0b0d179935..71bc11e168 100644
--- a/src/tools/tor-fw-helper/tor-fw-helper.h
+++ b/src/tools/tor-fw-helper/tor-fw-helper.h
@@ -1,5 +1,5 @@
/* Copyright (c) 2010, Jacob Appelbaum, Steven J. Murdoch.
- * Copyright (c) 2010-2013, The Tor Project, Inc. */
+ * Copyright (c) 2010-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
/**
diff --git a/src/tools/tor-gencert.c b/src/tools/tor-gencert.c
index e799df5cad..f6805c1193 100644
--- a/src/tools/tor-gencert.c
+++ b/src/tools/tor-gencert.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2007-2013, The Tor Project, Inc. */
+/* Copyright (c) 2007-2014, The Tor Project, Inc. */
/* See LICENSE for licensing information */
#include "orconfig.h"
@@ -134,18 +134,30 @@ parse_commandline(int argc, char **argv)
fprintf(stderr, "No argument to -i\n");
return 1;
}
+ if (identity_key_file) {
+ fprintf(stderr, "Duplicate values for -i\n");
+ return -1;
+ }
identity_key_file = tor_strdup(argv[++i]);
} else if (!strcmp(argv[i], "-s")) {
if (i+1>=argc) {
fprintf(stderr, "No argument to -s\n");
return 1;
}
+ if (signing_key_file) {
+ fprintf(stderr, "Duplicate values for -s\n");
+ return -1;
+ }
signing_key_file = tor_strdup(argv[++i]);
} else if (!strcmp(argv[i], "-c")) {
if (i+1>=argc) {
fprintf(stderr, "No argument to -c\n");
return 1;
}
+ if (certificate_file) {
+ fprintf(stderr, "Duplicate values for -c\n");
+ return -1;
+ }
certificate_file = tor_strdup(argv[++i]);
} else if (!strcmp(argv[i], "-m")) {
if (i+1>=argc) {
@@ -513,7 +525,7 @@ int
main(int argc, char **argv)
{
int r = 1;
- init_logging();
+ init_logging(1);
/* Don't bother using acceleration. */
if (crypto_global_init(0, NULL, NULL)) {
diff --git a/src/tools/tor-resolve.c b/src/tools/tor-resolve.c
index 306f6c66ab..6ee155ade5 100644
--- a/src/tools/tor-resolve.c
+++ b/src/tools/tor-resolve.c
@@ -1,5 +1,5 @@
/* Copyright (c) 2004-2006, Roger Dingledine, Nick Mathewson
- * Copyright (c) 2007-2013, The Tor Project, Inc.
+ * Copyright (c) 2007-2014, The Tor Project, Inc.
*/
/* See LICENSE for licensing information */
@@ -8,6 +8,7 @@
#include "../common/util.h"
#include "address.h"
#include "../common/torlog.h"
+#include "sandbox.h"
#include <stdio.h>
#include <stdlib.h>
@@ -343,7 +344,8 @@ main(int argc, char **argv)
char *result_hostname = NULL;
log_severity_list_t *s = tor_malloc_zero(sizeof(log_severity_list_t));
- init_logging();
+ init_logging(1);
+ sandbox_disable_getaddrinfo_cache();
arg = &argv[1];
n_args = argc-1;
diff --git a/src/trunnel/include.am b/src/trunnel/include.am
new file mode 100644
index 0000000000..c7ac1679d0
--- /dev/null
+++ b/src/trunnel/include.am
@@ -0,0 +1,29 @@
+
+noinst_LIBRARIES += \
+ src/trunnel/libor-trunnel.a
+
+if UNITTESTS_ENABLED
+noinst_LIBRARIES += \
+ src/trunnel/libor-trunnel-testing.a
+endif
+
+AM_CPPFLAGS += -I$(srcdir)/src/ext/trunnel -I$(srcdir)/src/trunnel
+
+TRUNNELSOURCES = \
+ src/ext/trunnel/trunnel.c \
+ src/trunnel/pwbox.c
+
+TRUNNELHEADERS = \
+ src/ext/trunnel/trunnel.h \
+ src/ext/trunnel/trunnel-impl.h \
+ src/trunnel/trunnel-local.h \
+ src/trunnel/pwbox.h
+
+src_trunnel_libor_trunnel_a_SOURCES = $(TRUNNELSOURCES)
+src_trunnel_libor_trunnel_a_CPPFLAGS = -DTRUNNEL_LOCAL_H $(AM_CPPFLAGS)
+
+src_trunnel_libor_trunnel_testing_a_SOURCES = $(TRUNNELSOURCES)
+src_trunnel_libor_trunnel_testing_a_CPPFLAGS = -DTOR_UNIT_TESTS -DTRUNNEL_LOCAL_H $(AM_CPPFLAGS)
+src_trunnel_libor_trunnel_testing_a_CFLAGS = $(AM_CFLAGS) $(TEST_CFLAGS)
+
+noinst_HEADERS+= $(TRUNNELHEADERS)
diff --git a/src/trunnel/pwbox.c b/src/trunnel/pwbox.c
new file mode 100644
index 0000000000..bfea3ac671
--- /dev/null
+++ b/src/trunnel/pwbox.c
@@ -0,0 +1,515 @@
+/* pwbox.c -- generated by Trunnel v1.2.
+ * https://gitweb.torproject.org/trunnel.git
+ * You probably shouldn't edit this file.
+ */
+#include <stdlib.h>
+#include "trunnel-impl.h"
+
+#include "pwbox.h"
+
+#define TRUNNEL_SET_ERROR_CODE(obj) \
+ do { \
+ (obj)->trunnel_error_code_ = 1; \
+ } while (0)
+
+#if defined(__COVERITY__) || defined(__clang_analyzer__)
+/* If we're runnning a static analysis tool, we don't want it to complain
+ * that some of our remaining-bytes checks are dead-code. */
+int pwbox_deadcode_dummy__ = 0;
+#define OR_DEADCODE_DUMMY || pwbox_deadcode_dummy__
+#else
+#define OR_DEADCODE_DUMMY
+#endif
+
+#define CHECK_REMAINING(nbytes, label) \
+ do { \
+ if (remaining < (nbytes) OR_DEADCODE_DUMMY) { \
+ goto label; \
+ } \
+ } while (0)
+
+pwbox_encoded_t *
+pwbox_encoded_new(void)
+{
+ pwbox_encoded_t *val = trunnel_calloc(1, sizeof(pwbox_encoded_t));
+ if (NULL == val)
+ return NULL;
+ val->fixedbytes0 = PWBOX0_CONST0;
+ val->fixedbytes1 = PWBOX0_CONST1;
+ return val;
+}
+
+/** Release all storage held inside 'obj', but do not free 'obj'.
+ */
+static void
+pwbox_encoded_clear(pwbox_encoded_t *obj)
+{
+ (void) obj;
+ TRUNNEL_DYNARRAY_WIPE(&obj->skey_header);
+ TRUNNEL_DYNARRAY_CLEAR(&obj->skey_header);
+ TRUNNEL_DYNARRAY_WIPE(&obj->data);
+ TRUNNEL_DYNARRAY_CLEAR(&obj->data);
+}
+
+void
+pwbox_encoded_free(pwbox_encoded_t *obj)
+{
+ if (obj == NULL)
+ return;
+ pwbox_encoded_clear(obj);
+ trunnel_memwipe(obj, sizeof(pwbox_encoded_t));
+ trunnel_free_(obj);
+}
+
+uint32_t
+pwbox_encoded_get_fixedbytes0(pwbox_encoded_t *inp)
+{
+ return inp->fixedbytes0;
+}
+int
+pwbox_encoded_set_fixedbytes0(pwbox_encoded_t *inp, uint32_t val)
+{
+ if (! ((val == PWBOX0_CONST0))) {
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+ }
+ inp->fixedbytes0 = val;
+ return 0;
+}
+uint32_t
+pwbox_encoded_get_fixedbytes1(pwbox_encoded_t *inp)
+{
+ return inp->fixedbytes1;
+}
+int
+pwbox_encoded_set_fixedbytes1(pwbox_encoded_t *inp, uint32_t val)
+{
+ if (! ((val == PWBOX0_CONST1))) {
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+ }
+ inp->fixedbytes1 = val;
+ return 0;
+}
+uint8_t
+pwbox_encoded_get_header_len(pwbox_encoded_t *inp)
+{
+ return inp->header_len;
+}
+int
+pwbox_encoded_set_header_len(pwbox_encoded_t *inp, uint8_t val)
+{
+ inp->header_len = val;
+ return 0;
+}
+size_t
+pwbox_encoded_getlen_skey_header(const pwbox_encoded_t *inp)
+{
+ return TRUNNEL_DYNARRAY_LEN(&inp->skey_header);
+}
+
+uint8_t
+pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx)
+{
+ return TRUNNEL_DYNARRAY_GET(&inp->skey_header, idx);
+}
+
+int
+pwbox_encoded_set_skey_header(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
+{
+ TRUNNEL_DYNARRAY_SET(&inp->skey_header, idx, elt);
+ return 0;
+}
+int
+pwbox_encoded_add_skey_header(pwbox_encoded_t *inp, uint8_t elt)
+{
+#if SIZE_MAX >= UINT8_MAX
+ if (inp->skey_header.n_ == UINT8_MAX)
+ goto trunnel_alloc_failed;
+#endif
+ TRUNNEL_DYNARRAY_ADD(uint8_t, &inp->skey_header, elt, {});
+ return 0;
+ trunnel_alloc_failed:
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+}
+
+uint8_t *
+pwbox_encoded_getarray_skey_header(pwbox_encoded_t *inp)
+{
+ return inp->skey_header.elts_;
+}
+int
+pwbox_encoded_setlen_skey_header(pwbox_encoded_t *inp, size_t newlen)
+{
+ uint8_t *newptr;
+#if UINT8_MAX < SIZE_MAX
+ if (newlen > UINT8_MAX)
+ goto trunnel_alloc_failed;
+#endif
+ newptr = trunnel_dynarray_setlen(&inp->skey_header.allocated_,
+ &inp->skey_header.n_, inp->skey_header.elts_, newlen,
+ sizeof(inp->skey_header.elts_[0]), (trunnel_free_fn_t) NULL,
+ &inp->trunnel_error_code_);
+ if (newptr == NULL)
+ goto trunnel_alloc_failed;
+ inp->skey_header.elts_ = newptr;
+ return 0;
+ trunnel_alloc_failed:
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+}
+size_t
+pwbox_encoded_getlen_iv(const pwbox_encoded_t *inp)
+{
+ (void)inp; return 16;
+}
+
+uint8_t
+pwbox_encoded_get_iv(const pwbox_encoded_t *inp, size_t idx)
+{
+ trunnel_assert(idx < 16);
+ return inp->iv[idx];
+}
+
+int
+pwbox_encoded_set_iv(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
+{
+ trunnel_assert(idx < 16);
+ inp->iv[idx] = elt;
+ return 0;
+}
+
+uint8_t *
+pwbox_encoded_getarray_iv(pwbox_encoded_t *inp)
+{
+ return inp->iv;
+}
+size_t
+pwbox_encoded_getlen_data(const pwbox_encoded_t *inp)
+{
+ return TRUNNEL_DYNARRAY_LEN(&inp->data);
+}
+
+uint8_t
+pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx)
+{
+ return TRUNNEL_DYNARRAY_GET(&inp->data, idx);
+}
+
+int
+pwbox_encoded_set_data(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
+{
+ TRUNNEL_DYNARRAY_SET(&inp->data, idx, elt);
+ return 0;
+}
+int
+pwbox_encoded_add_data(pwbox_encoded_t *inp, uint8_t elt)
+{
+ TRUNNEL_DYNARRAY_ADD(uint8_t, &inp->data, elt, {});
+ return 0;
+ trunnel_alloc_failed:
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+}
+
+uint8_t *
+pwbox_encoded_getarray_data(pwbox_encoded_t *inp)
+{
+ return inp->data.elts_;
+}
+int
+pwbox_encoded_setlen_data(pwbox_encoded_t *inp, size_t newlen)
+{
+ uint8_t *newptr;
+ newptr = trunnel_dynarray_setlen(&inp->data.allocated_,
+ &inp->data.n_, inp->data.elts_, newlen,
+ sizeof(inp->data.elts_[0]), (trunnel_free_fn_t) NULL,
+ &inp->trunnel_error_code_);
+ if (newptr == NULL)
+ goto trunnel_alloc_failed;
+ inp->data.elts_ = newptr;
+ return 0;
+ trunnel_alloc_failed:
+ TRUNNEL_SET_ERROR_CODE(inp);
+ return -1;
+}
+size_t
+pwbox_encoded_getlen_hmac(const pwbox_encoded_t *inp)
+{
+ (void)inp; return 32;
+}
+
+uint8_t
+pwbox_encoded_get_hmac(const pwbox_encoded_t *inp, size_t idx)
+{
+ trunnel_assert(idx < 32);
+ return inp->hmac[idx];
+}
+
+int
+pwbox_encoded_set_hmac(pwbox_encoded_t *inp, size_t idx, uint8_t elt)
+{
+ trunnel_assert(idx < 32);
+ inp->hmac[idx] = elt;
+ return 0;
+}
+
+uint8_t *
+pwbox_encoded_getarray_hmac(pwbox_encoded_t *inp)
+{
+ return inp->hmac;
+}
+const char *
+pwbox_encoded_check(const pwbox_encoded_t *obj)
+{
+ if (obj == NULL)
+ return "Object was NULL";
+ if (obj->trunnel_error_code_)
+ return "A set function failed on this object";
+ if (! (obj->fixedbytes0 == PWBOX0_CONST0))
+ return "Integer out of bounds";
+ if (! (obj->fixedbytes1 == PWBOX0_CONST1))
+ return "Integer out of bounds";
+ if (TRUNNEL_DYNARRAY_LEN(&obj->skey_header) != obj->header_len)
+ return "Length mismatch for skey_header";
+ return NULL;
+}
+
+ssize_t
+pwbox_encoded_encoded_len(const pwbox_encoded_t *obj)
+{
+ ssize_t result = 0;
+
+ if (NULL != pwbox_encoded_check(obj))
+ return -1;
+
+
+ /* Length of u32 fixedbytes0 IN [PWBOX0_CONST0] */
+ result += 4;
+
+ /* Length of u32 fixedbytes1 IN [PWBOX0_CONST1] */
+ result += 4;
+
+ /* Length of u8 header_len */
+ result += 1;
+
+ /* Length of u8 skey_header[header_len] */
+ result += TRUNNEL_DYNARRAY_LEN(&obj->skey_header);
+
+ /* Length of u8 iv[16] */
+ result += 16;
+
+ /* Length of u8 data[] */
+ result += TRUNNEL_DYNARRAY_LEN(&obj->data);
+
+ /* Length of u8 hmac[32] */
+ result += 32;
+ return result;
+}
+int
+pwbox_encoded_clear_errors(pwbox_encoded_t *obj)
+{
+ int r = obj->trunnel_error_code_;
+ obj->trunnel_error_code_ = 0;
+ return r;
+}
+ssize_t
+pwbox_encoded_encode(uint8_t *output, size_t avail, const pwbox_encoded_t *obj)
+{
+ ssize_t result = 0;
+ size_t written = 0;
+ uint8_t *ptr = output;
+ const char *msg;
+#ifdef TRUNNEL_CHECK_ENCODED_LEN
+ const ssize_t encoded_len = pwbox_encoded_encoded_len(obj);
+#endif
+ int enforce_avail = 0;
+ const size_t avail_orig = avail;
+
+ if (NULL != (msg = pwbox_encoded_check(obj)))
+ goto check_failed;
+
+#ifdef TRUNNEL_CHECK_ENCODED_LEN
+ trunnel_assert(encoded_len >= 0);
+#endif
+
+ /* Encode u32 fixedbytes0 IN [PWBOX0_CONST0] */
+ trunnel_assert(written <= avail);
+ if (avail - written < 4)
+ goto truncated;
+ trunnel_set_uint32(ptr, trunnel_htonl(obj->fixedbytes0));
+ written += 4; ptr += 4;
+
+ /* Encode u32 fixedbytes1 IN [PWBOX0_CONST1] */
+ trunnel_assert(written <= avail);
+ if (avail - written < 4)
+ goto truncated;
+ trunnel_set_uint32(ptr, trunnel_htonl(obj->fixedbytes1));
+ written += 4; ptr += 4;
+
+ /* Encode u8 header_len */
+ trunnel_assert(written <= avail);
+ if (avail - written < 1)
+ goto truncated;
+ trunnel_set_uint8(ptr, (obj->header_len));
+ written += 1; ptr += 1;
+
+ /* Encode u8 skey_header[header_len] */
+ {
+ size_t elt_len = TRUNNEL_DYNARRAY_LEN(&obj->skey_header);
+ trunnel_assert(obj->header_len == elt_len);
+ trunnel_assert(written <= avail);
+ if (avail - written < elt_len)
+ goto truncated;
+ memcpy(ptr, obj->skey_header.elts_, elt_len);
+ written += elt_len; ptr += elt_len;
+ }
+
+ /* Encode u8 iv[16] */
+ trunnel_assert(written <= avail);
+ if (avail - written < 16)
+ goto truncated;
+ memcpy(ptr, obj->iv, 16);
+ written += 16; ptr += 16;
+ {
+
+ /* Encode u8 data[] */
+ {
+ size_t elt_len = TRUNNEL_DYNARRAY_LEN(&obj->data);
+ trunnel_assert(written <= avail);
+ if (avail - written < elt_len)
+ goto truncated;
+ memcpy(ptr, obj->data.elts_, elt_len);
+ written += elt_len; ptr += elt_len;
+ }
+ trunnel_assert(written <= avail);
+ if (avail - written < 32)
+ goto truncated;
+ avail = written + 32;
+ enforce_avail = 1;
+ }
+
+ /* Encode u8 hmac[32] */
+ trunnel_assert(written <= avail);
+ if (avail - written < 32) {
+ if (avail_orig - written < 32)
+ goto truncated;
+ else
+ goto check_failed;
+ }
+ memcpy(ptr, obj->hmac, 32);
+ written += 32; ptr += 32;
+
+
+ trunnel_assert(ptr == output + written);
+ if (enforce_avail && avail != written)
+ goto check_failed;
+#ifdef TRUNNEL_CHECK_ENCODED_LEN
+ {
+ trunnel_assert(encoded_len >= 0);
+ trunnel_assert((size_t)encoded_len == written);
+ }
+
+#endif
+
+ return written;
+
+ truncated:
+ result = -2;
+ goto fail;
+ check_failed:
+ (void)msg;
+ result = -1;
+ goto fail;
+ fail:
+ trunnel_assert(result < 0);
+ return result;
+}
+
+/** As pwbox_encoded_parse(), but do not allocate the output object.
+ */
+static ssize_t
+pwbox_encoded_parse_into(pwbox_encoded_t *obj, const uint8_t *input, const size_t len_in)
+{
+ const uint8_t *ptr = input;
+ size_t remaining = len_in;
+ ssize_t result = 0;
+ (void)result;
+
+ /* Parse u32 fixedbytes0 IN [PWBOX0_CONST0] */
+ CHECK_REMAINING(4, truncated);
+ obj->fixedbytes0 = trunnel_ntohl(trunnel_get_uint32(ptr));
+ remaining -= 4; ptr += 4;
+ if (! (obj->fixedbytes0 == PWBOX0_CONST0))
+ goto fail;
+
+ /* Parse u32 fixedbytes1 IN [PWBOX0_CONST1] */
+ CHECK_REMAINING(4, truncated);
+ obj->fixedbytes1 = trunnel_ntohl(trunnel_get_uint32(ptr));
+ remaining -= 4; ptr += 4;
+ if (! (obj->fixedbytes1 == PWBOX0_CONST1))
+ goto fail;
+
+ /* Parse u8 header_len */
+ CHECK_REMAINING(1, truncated);
+ obj->header_len = (trunnel_get_uint8(ptr));
+ remaining -= 1; ptr += 1;
+
+ /* Parse u8 skey_header[header_len] */
+ CHECK_REMAINING(obj->header_len, truncated);
+ TRUNNEL_DYNARRAY_EXPAND(uint8_t, &obj->skey_header, obj->header_len, {});
+ obj->skey_header.n_ = obj->header_len;
+ memcpy(obj->skey_header.elts_, ptr, obj->header_len);
+ ptr += obj->header_len; remaining -= obj->header_len;
+
+ /* Parse u8 iv[16] */
+ CHECK_REMAINING(16, truncated);
+ memcpy(obj->iv, ptr, 16);
+ remaining -= 16; ptr += 16;
+ {
+ size_t remaining_after;
+ CHECK_REMAINING(32, truncated);
+ remaining_after = 32;
+ remaining = remaining - 32;
+
+ /* Parse u8 data[] */
+ TRUNNEL_DYNARRAY_EXPAND(uint8_t, &obj->data, remaining, {});
+ obj->data.n_ = remaining;
+ memcpy(obj->data.elts_, ptr, remaining);
+ ptr += remaining; remaining -= remaining;
+ if (remaining != 0)
+ goto fail;
+ remaining = remaining_after;
+ }
+
+ /* Parse u8 hmac[32] */
+ CHECK_REMAINING(32, truncated);
+ memcpy(obj->hmac, ptr, 32);
+ remaining -= 32; ptr += 32;
+ trunnel_assert(ptr + remaining == input + len_in);
+ return len_in - remaining;
+
+ truncated:
+ return -2;
+ trunnel_alloc_failed:
+ return -1;
+ fail:
+ result = -1;
+ return result;
+}
+
+ssize_t
+pwbox_encoded_parse(pwbox_encoded_t **output, const uint8_t *input, const size_t len_in)
+{
+ ssize_t result;
+ *output = pwbox_encoded_new();
+ if (NULL == *output)
+ return -1;
+ result = pwbox_encoded_parse_into(*output, input, len_in);
+ if (result < 0) {
+ pwbox_encoded_free(*output);
+ *output = NULL;
+ }
+ return result;
+}
diff --git a/src/trunnel/pwbox.h b/src/trunnel/pwbox.h
new file mode 100644
index 0000000000..5b170eb45e
--- /dev/null
+++ b/src/trunnel/pwbox.h
@@ -0,0 +1,173 @@
+/* pwbox.h -- generated by by Trunnel v1.2.
+ * https://gitweb.torproject.org/trunnel.git
+ * You probably shouldn't edit this file.
+ */
+#ifndef TRUNNEL_PWBOX_H
+#define TRUNNEL_PWBOX_H
+
+#include <stdint.h>
+#include "trunnel.h"
+
+#define PWBOX0_CONST0 1414484546
+#define PWBOX0_CONST1 1331179568
+#if !defined(TRUNNEL_OPAQUE) && !defined(TRUNNEL_OPAQUE_PWBOX_ENCODED)
+struct pwbox_encoded_st {
+ uint32_t fixedbytes0;
+ uint32_t fixedbytes1;
+ uint8_t header_len;
+ TRUNNEL_DYNARRAY_HEAD(, uint8_t) skey_header;
+ uint8_t iv[16];
+ TRUNNEL_DYNARRAY_HEAD(, uint8_t) data;
+ uint8_t hmac[32];
+ uint8_t trunnel_error_code_;
+};
+#endif
+typedef struct pwbox_encoded_st pwbox_encoded_t;
+/** Return a newly allocated pwbox_encoded with all elements set to
+ * zero.
+ */
+pwbox_encoded_t *pwbox_encoded_new(void);
+/** Release all storage held by the pwbox_encoded in 'victim'. (Do
+ * nothing if 'victim' is NULL.)
+ */
+void pwbox_encoded_free(pwbox_encoded_t *victim);
+/** Try to parse a pwbox_encoded from the buffer in 'input', using up
+ * to 'len_in' bytes from the input buffer. On success, return the
+ * number of bytes consumed and set *output to the newly allocated
+ * pwbox_encoded_t. On failure, return -2 if the input appears
+ * truncated, and -1 if the input is otherwise invalid.
+ */
+ssize_t pwbox_encoded_parse(pwbox_encoded_t **output, const uint8_t *input, const size_t len_in);
+/** Return the number of bytes we expect to need to encode the
+ * pwbox_encoded in 'obj'. On failure, return a negative value. Note
+ * that this value may be an overestimate, and can even be an
+ * underestimate for certain unencodeable objects.
+ */
+ssize_t pwbox_encoded_encoded_len(const pwbox_encoded_t *obj);
+/** Try to encode the pwbox_encoded from 'input' into the buffer at
+ * 'output', using up to 'avail' bytes of the output buffer. On
+ * success, return the number of bytes used. On failure, return -2 if
+ * the buffer was not long enough, and -1 if the input was invalid.
+ */
+ssize_t pwbox_encoded_encode(uint8_t *output, const size_t avail, const pwbox_encoded_t *input);
+/** Check whether the internal state of the pwbox_encoded in 'obj' is
+ * consistent. Return NULL if it is, and a short message if it is not.
+ */
+const char *pwbox_encoded_check(const pwbox_encoded_t *obj);
+/** Clear any errors that were set on the object 'obj' by its setter
+ * functions. Return true iff errors were cleared.
+ */
+int pwbox_encoded_clear_errors(pwbox_encoded_t *obj);
+/** Return the value of the fixedbytes0 field of the pwbox_encoded_t
+ * in 'inp'
+ */
+uint32_t pwbox_encoded_get_fixedbytes0(pwbox_encoded_t *inp);
+/** Set the value of the fixedbytes0 field of the pwbox_encoded_t in
+ * 'inp' to 'val'. Return 0 on success; return -1 and set the error
+ * code on 'inp' on failure.
+ */
+int pwbox_encoded_set_fixedbytes0(pwbox_encoded_t *inp, uint32_t val);
+/** Return the value of the fixedbytes1 field of the pwbox_encoded_t
+ * in 'inp'
+ */
+uint32_t pwbox_encoded_get_fixedbytes1(pwbox_encoded_t *inp);
+/** Set the value of the fixedbytes1 field of the pwbox_encoded_t in
+ * 'inp' to 'val'. Return 0 on success; return -1 and set the error
+ * code on 'inp' on failure.
+ */
+int pwbox_encoded_set_fixedbytes1(pwbox_encoded_t *inp, uint32_t val);
+/** Return the value of the header_len field of the pwbox_encoded_t in
+ * 'inp'
+ */
+uint8_t pwbox_encoded_get_header_len(pwbox_encoded_t *inp);
+/** Set the value of the header_len field of the pwbox_encoded_t in
+ * 'inp' to 'val'. Return 0 on success; return -1 and set the error
+ * code on 'inp' on failure.
+ */
+int pwbox_encoded_set_header_len(pwbox_encoded_t *inp, uint8_t val);
+/** Return the length of the dynamic array holding the skey_header
+ * field of the pwbox_encoded_t in 'inp'.
+ */
+size_t pwbox_encoded_getlen_skey_header(const pwbox_encoded_t *inp);
+/** Return the element at position 'idx' of the dynamic array field
+ * skey_header of the pwbox_encoded_t in 'inp'.
+ */
+uint8_t pwbox_encoded_get_skey_header(pwbox_encoded_t *inp, size_t idx);
+/** Change the element at position 'idx' of the dynamic array field
+ * skey_header of the pwbox_encoded_t in 'inp', so that it will hold
+ * the value 'elt'.
+ */
+int pwbox_encoded_set_skey_header(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
+/** Append a new element 'elt' to the dynamic array field skey_header
+ * of the pwbox_encoded_t in 'inp'.
+ */
+int pwbox_encoded_add_skey_header(pwbox_encoded_t *inp, uint8_t elt);
+/** Return a pointer to the variable-length array field skey_header of
+ * 'inp'.
+ */
+uint8_t * pwbox_encoded_getarray_skey_header(pwbox_encoded_t *inp);
+/** Change the length of the variable-length array field skey_header
+ * of 'inp' to 'newlen'.Fill extra elements with 0. Return 0 on
+ * success; return -1 and set the error code on 'inp' on failure.
+ */
+int pwbox_encoded_setlen_skey_header(pwbox_encoded_t *inp, size_t newlen);
+/** Return the (constant) length of the array holding the iv field of
+ * the pwbox_encoded_t in 'inp'.
+ */
+size_t pwbox_encoded_getlen_iv(const pwbox_encoded_t *inp);
+/** Return the element at position 'idx' of the fixed array field iv
+ * of the pwbox_encoded_t in 'inp'.
+ */
+uint8_t pwbox_encoded_get_iv(const pwbox_encoded_t *inp, size_t idx);
+/** Change the element at position 'idx' of the fixed array field iv
+ * of the pwbox_encoded_t in 'inp', so that it will hold the value
+ * 'elt'.
+ */
+int pwbox_encoded_set_iv(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
+/** Return a pointer to the 16-element array field iv of 'inp'.
+ */
+uint8_t * pwbox_encoded_getarray_iv(pwbox_encoded_t *inp);
+/** Return the length of the dynamic array holding the data field of
+ * the pwbox_encoded_t in 'inp'.
+ */
+size_t pwbox_encoded_getlen_data(const pwbox_encoded_t *inp);
+/** Return the element at position 'idx' of the dynamic array field
+ * data of the pwbox_encoded_t in 'inp'.
+ */
+uint8_t pwbox_encoded_get_data(pwbox_encoded_t *inp, size_t idx);
+/** Change the element at position 'idx' of the dynamic array field
+ * data of the pwbox_encoded_t in 'inp', so that it will hold the
+ * value 'elt'.
+ */
+int pwbox_encoded_set_data(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
+/** Append a new element 'elt' to the dynamic array field data of the
+ * pwbox_encoded_t in 'inp'.
+ */
+int pwbox_encoded_add_data(pwbox_encoded_t *inp, uint8_t elt);
+/** Return a pointer to the variable-length array field data of 'inp'.
+ */
+uint8_t * pwbox_encoded_getarray_data(pwbox_encoded_t *inp);
+/** Change the length of the variable-length array field data of 'inp'
+ * to 'newlen'.Fill extra elements with 0. Return 0 on success; return
+ * -1 and set the error code on 'inp' on failure.
+ */
+int pwbox_encoded_setlen_data(pwbox_encoded_t *inp, size_t newlen);
+/** Return the (constant) length of the array holding the hmac field
+ * of the pwbox_encoded_t in 'inp'.
+ */
+size_t pwbox_encoded_getlen_hmac(const pwbox_encoded_t *inp);
+/** Return the element at position 'idx' of the fixed array field hmac
+ * of the pwbox_encoded_t in 'inp'.
+ */
+uint8_t pwbox_encoded_get_hmac(const pwbox_encoded_t *inp, size_t idx);
+/** Change the element at position 'idx' of the fixed array field hmac
+ * of the pwbox_encoded_t in 'inp', so that it will hold the value
+ * 'elt'.
+ */
+int pwbox_encoded_set_hmac(pwbox_encoded_t *inp, size_t idx, uint8_t elt);
+/** Return a pointer to the 32-element array field hmac of 'inp'.
+ */
+uint8_t * pwbox_encoded_getarray_hmac(pwbox_encoded_t *inp);
+
+
+#endif
diff --git a/src/trunnel/pwbox.trunnel b/src/trunnel/pwbox.trunnel
new file mode 100644
index 0000000000..10db74b4e5
--- /dev/null
+++ b/src/trunnel/pwbox.trunnel
@@ -0,0 +1,14 @@
+
+const PWBOX0_CONST0 = 0x544f5242; // TORB
+const PWBOX0_CONST1 = 0x4f583030; // OX00
+
+struct pwbox_encoded {
+ u32 fixedbytes0 IN [PWBOX0_CONST0];
+ u32 fixedbytes1 IN [PWBOX0_CONST1];
+ u8 header_len;
+ u8 skey_header[header_len];
+ u8 iv[16];
+ u8 data[..-32];
+ u8 hmac[32];
+};
+
diff --git a/src/trunnel/trunnel-local.h b/src/trunnel/trunnel-local.h
new file mode 100644
index 0000000000..b7c2ab98ef
--- /dev/null
+++ b/src/trunnel/trunnel-local.h
@@ -0,0 +1,18 @@
+
+#ifndef TRUNNEL_LOCAL_H_INCLUDED
+#define TRUNNEL_LOCAL_H_INCLUDED
+
+#include "util.h"
+#include "compat.h"
+#include "crypto.h"
+
+#define trunnel_malloc tor_malloc
+#define trunnel_calloc tor_calloc
+#define trunnel_strdup tor_strdup
+#define trunnel_free_ tor_free_
+#define trunnel_realloc tor_realloc
+#define trunnel_reallocarray tor_reallocarray
+#define trunnel_assert tor_assert
+#define trunnel_memwipe(mem, len) memwipe((mem), 0, (len))
+
+#endif
diff --git a/src/win32/orconfig.h b/src/win32/orconfig.h
index 030341af34..cee81b31eb 100644
--- a/src/win32/orconfig.h
+++ b/src/win32/orconfig.h
@@ -232,7 +232,7 @@
#define USING_TWOS_COMPLEMENT
/* Version number of package */
-#define VERSION "0.2.6.0-alpha-dev"
+#define VERSION "0.2.6.1-alpha-dev"
@@ -244,7 +244,14 @@
#define SHARE_DATADIR ""
#define HAVE_EVENT2_DNS_H
#define HAVE_EVENT_BASE_LOOPEXIT
-#define CURVE25519_ENABLED
#define USE_CURVE25519_DONNA
#define ENUM_VALS_ARE_SIGNED 1
+
+#ifndef STDOUT_FILENO
+#define STDOUT_FILENO 1
+#endif
+
+#ifndef STDERR_FILENO
+#define STDERR_FILENO 2
+#endif