├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── README-PLUGINS.markdown ├── README-WINDOWS.markdown ├── README.markdown ├── TECHNOTES ├── THANKS ├── autogen.sh ├── config.guess-bitrig.diff ├── configure.ac ├── dist-build ├── Makefile.am ├── android.sh ├── iphone.sh ├── msys.sh └── osx.sh ├── m4 ├── ax_check_compile_flag.m4 ├── ax_check_gnu_make.m4 ├── ax_check_link_flag.m4 └── ax_pthread.m4 ├── man ├── Makefile.am ├── dnscrypt-proxy.8 ├── dnscrypt-proxy.8.markdown ├── hostip.8 └── hostip.8.markdown ├── org.dnscrypt.osx.DNSCryptProxy.plist ├── packages ├── OpenBSD │ └── net │ │ └── dnscrypt-proxy │ │ ├── Makefile │ │ ├── distinfo │ │ └── pkg │ │ ├── DESCR-main │ │ ├── DESCR-plugins │ │ ├── MESSAGE-main │ │ ├── PFRAG.shared │ │ ├── PFRAG.shared-plugins │ │ ├── PLIST-main │ │ ├── PLIST-plugins │ │ └── dnscrypt_proxy.rc ├── fpm │ └── fpm.sh ├── gentoo │ └── net-dns │ │ └── dnscrypt-proxy │ │ ├── Manifest │ │ ├── dnscrypt-proxy-0.9.3.ebuild │ │ ├── dnscrypt-proxy-0.9.4.ebuild │ │ ├── dnscrypt-proxy-1.0.ebuild │ │ └── files │ │ ├── dnscrypt-proxy.confd │ │ └── dnscrypt-proxy.initd ├── homebrew │ └── dnscrypt-proxy.rb └── pkgsrc │ └── net │ └── dnscrypt-proxy │ ├── DESCR │ ├── MESSAGE │ ├── Makefile │ ├── PLIST │ ├── distinfo │ └── files │ └── dnscrypt_proxy.sh ├── src ├── Makefile.am ├── ext │ ├── Makefile.am │ └── queue.h ├── hostip │ ├── Makefile.am │ ├── app.c │ ├── app.h │ ├── options.c │ └── options.h ├── include │ ├── Makefile.am │ └── dnscrypt │ │ ├── plugin.h │ │ ├── private.h │ │ └── version.h.in ├── libevent │ ├── ChangeLog │ ├── Doxyfile │ ├── LICENSE │ ├── Makefile.am │ ├── Makefile.nmake │ ├── README │ ├── WIN32-Code │ │ ├── event2 │ │ │ └── event-config.h │ │ └── tree.h │ ├── arc4random.c │ ├── autogen.sh │ ├── buffer.c │ ├── buffer_iocp.c │ ├── bufferevent-internal.h │ ├── bufferevent.c │ ├── bufferevent_async.c │ ├── bufferevent_filter.c │ ├── bufferevent_openssl.c │ ├── bufferevent_pair.c │ ├── bufferevent_ratelim.c │ ├── bufferevent_sock.c │ ├── changelist-internal.h │ ├── compat │ │ └── sys │ │ │ └── queue.h │ ├── configure.in │ ├── defer-internal.h │ ├── devpoll.c │ ├── epoll.c │ ├── epoll_sub.c │ ├── evbuffer-internal.h │ ├── evdns.c │ ├── evdns.h │ ├── event-internal.h │ ├── event.c │ ├── event.h │ ├── event_iocp.c │ ├── event_rpcgen.py │ ├── event_tagging.c │ ├── evhttp.h │ ├── evmap-internal.h │ ├── evmap.c │ ├── evport.c │ ├── evrpc-internal.h │ ├── evrpc.c │ ├── evrpc.h │ ├── evsignal-internal.h │ ├── evthread-internal.h │ ├── evthread.c │ ├── evthread_pthread.c │ ├── evthread_win32.c │ ├── evutil.c │ ├── evutil.h │ ├── evutil_rand.c │ ├── ht-internal.h │ ├── http-internal.h │ ├── http.c │ ├── include │ │ ├── Makefile.am │ │ └── event2 │ │ │ ├── buffer.h │ │ │ ├── buffer_compat.h │ │ │ ├── bufferevent.h │ │ │ ├── bufferevent_compat.h │ │ │ ├── bufferevent_ssl.h │ │ │ ├── bufferevent_struct.h │ │ │ ├── dns.h │ │ │ ├── dns_compat.h │ │ │ ├── dns_struct.h │ │ │ ├── event.h │ │ │ ├── event_compat.h │ │ │ ├── event_struct.h │ │ │ ├── http.h │ │ │ ├── http_compat.h │ │ │ ├── http_struct.h │ │ │ ├── keyvalq_struct.h │ │ │ ├── listener.h │ │ │ ├── rpc.h │ │ │ ├── rpc_compat.h │ │ │ ├── rpc_struct.h │ │ │ ├── tag.h │ │ │ ├── tag_compat.h │ │ │ ├── thread.h │ │ │ └── util.h │ ├── iocp-internal.h │ ├── ipv6-internal.h │ ├── kqueue.c │ ├── libevent.pc.in │ ├── libevent_openssl.pc.in │ ├── libevent_pthreads.pc.in │ ├── listener.c │ ├── log-internal.h │ ├── log.c │ ├── m4 │ │ ├── acx_pthread.m4 │ │ ├── ltsugar.m4 │ │ └── lt~obsolete.m4 │ ├── make-event-config.sed │ ├── minheap-internal.h │ ├── mm-internal.h │ ├── poll.c │ ├── ratelim-internal.h │ ├── sample │ │ ├── Makefile.am │ │ ├── dns-example.c │ │ ├── event-test.c │ │ ├── hello-world.c │ │ ├── http-server.c │ │ ├── le-proxy.c │ │ ├── signal-test.c │ │ └── time-test.c │ ├── select.c │ ├── signal.c │ ├── strlcpy-internal.h │ ├── strlcpy.c │ ├── test │ │ ├── Makefile.am │ │ ├── Makefile.nmake │ │ ├── bench.c │ │ ├── bench_cascade.c │ │ ├── bench_http.c │ │ ├── bench_httpclient.c │ │ ├── regress.c │ │ ├── regress.gen.c │ │ ├── regress.gen.h │ │ ├── regress.h │ │ ├── regress.rpc │ │ ├── regress_buffer.c │ │ ├── regress_bufferevent.c │ │ ├── regress_dns.c │ │ ├── regress_et.c │ │ ├── regress_http.c │ │ ├── regress_iocp.c │ │ ├── regress_listener.c │ │ ├── regress_main.c │ │ ├── regress_minheap.c │ │ ├── regress_rpc.c │ │ ├── regress_ssl.c │ │ ├── regress_testutils.c │ │ ├── regress_testutils.h │ │ ├── regress_thread.c │ │ ├── regress_util.c │ │ ├── regress_zlib.c │ │ ├── rpcgen_wrapper.sh │ │ ├── test-changelist.c │ │ ├── test-eof.c │ │ ├── test-init.c │ │ ├── test-ratelim.c │ │ ├── test-time.c │ │ ├── test-weof.c │ │ ├── test.sh │ │ ├── tinytest.c │ │ ├── tinytest.h │ │ ├── tinytest_local.h │ │ └── tinytest_macros.h │ ├── util-internal.h │ ├── whatsnew-2.0.txt │ └── win32select.c ├── libnacl │ ├── MACROS │ ├── Makefile.in │ ├── OPERATIONS │ ├── PROTOTYPES.c │ ├── PROTOTYPES.cpp │ ├── commandline │ │ ├── nacl-sha256.c │ │ └── nacl-sha512.c │ ├── cpucycles │ │ ├── alpha.c │ │ ├── alpha.h │ │ ├── amd64cpuinfo.c │ │ ├── amd64cpuinfo.h │ │ ├── amd64cpuspeed.c │ │ ├── amd64cpuspeed.h │ │ ├── amd64tscfreq.c │ │ ├── amd64tscfreq.h │ │ ├── celllinux.c │ │ ├── celllinux.h │ │ ├── cortex.c │ │ ├── cortex.h │ │ ├── dev4ns.c │ │ ├── dev4ns.h │ │ ├── do │ │ ├── gettimeofday.c │ │ ├── gettimeofday.h │ │ ├── hppapstat.c │ │ ├── hppapstat.h │ │ ├── ia64cpuinfo.c │ │ ├── ia64cpuinfo.h │ │ ├── mips.c │ │ ├── mips.h │ │ ├── monotonic.c │ │ ├── monotonic.h │ │ ├── monotoniccpuinfo.c │ │ ├── monotoniccpuinfo.h │ │ ├── osfreq.c │ │ ├── powerpccpuinfo.c │ │ ├── powerpccpuinfo.h │ │ ├── powerpcmacos.c │ │ ├── powerpcmacos.h │ │ ├── sgi.c │ │ ├── sgi.h │ │ ├── sparc32cpuinfo.c │ │ ├── sparc32cpuinfo.h │ │ ├── sparccpuinfo.c │ │ ├── sparccpuinfo.h │ │ ├── test.c │ │ ├── x86cpuinfo.c │ │ ├── x86cpuinfo.h │ │ ├── x86cpuspeed.c │ │ ├── x86cpuspeed.h │ │ ├── x86estimate.c │ │ ├── x86estimate.h │ │ ├── x86tscfreq.c │ │ └── x86tscfreq.h │ ├── cpuid │ │ ├── cbytes.c │ │ ├── cpuid.c │ │ ├── do │ │ ├── unknown.c │ │ └── x86.c │ ├── crypto_auth │ │ ├── hmacsha256 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── hmac.c │ │ │ │ └── verify.c │ │ │ └── used │ │ ├── hmacsha512256 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── hmac.c │ │ │ │ └── verify.c │ │ │ ├── selected │ │ │ └── used │ │ ├── measure.c │ │ ├── try.c │ │ ├── wrapper-auth.cpp │ │ └── wrapper-verify.cpp │ ├── crypto_box │ │ ├── curve25519xsalsa20poly1305 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── after.c │ │ │ │ ├── api.h │ │ │ │ ├── before.c │ │ │ │ ├── box.c │ │ │ │ └── keypair.c │ │ │ ├── selected │ │ │ └── used │ │ ├── measure.c │ │ ├── try.c │ │ ├── wrapper-box.cpp │ │ ├── wrapper-keypair.cpp │ │ └── wrapper-open.cpp │ ├── crypto_core │ │ ├── hsalsa20 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── core.c │ │ │ │ └── implementors │ │ │ ├── ref2 │ │ │ │ ├── api.h │ │ │ │ ├── core.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── measure.c │ │ ├── salsa20 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── core.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── salsa2012 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── core.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── salsa208 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── core.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── try.c │ │ └── wrapper-empty.cpp │ ├── crypto_hash │ │ ├── measure.c │ │ ├── sha256 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── hash.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── sha512 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── hash.c │ │ │ │ └── implementors │ │ │ ├── selected │ │ │ └── used │ │ ├── try.c │ │ └── wrapper-hash.cpp │ ├── crypto_hashblocks │ │ ├── measure.c │ │ ├── sha256 │ │ │ ├── checksum │ │ │ ├── inplace │ │ │ │ ├── api.h │ │ │ │ ├── blocks.c │ │ │ │ └── implementors │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── blocks.c │ │ │ │ └── implementors │ │ │ └── used │ │ ├── sha512 │ │ │ ├── checksum │ │ │ ├── inplace │ │ │ │ ├── api.h │ │ │ │ ├── blocks.c │ │ │ │ └── implementors │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── blocks.c │ │ │ │ └── implementors │ │ │ ├── selected │ │ │ └── used │ │ ├── try.c │ │ └── wrapper-empty.cpp │ ├── crypto_onetimeauth │ │ ├── measure.c │ │ ├── poly1305 │ │ │ ├── 53 │ │ │ │ ├── api.h │ │ │ │ ├── auth.c │ │ │ │ └── verify.c │ │ │ ├── amd64 │ │ │ │ ├── api.h │ │ │ │ ├── auth.s │ │ │ │ ├── constants.s │ │ │ │ └── verify.c │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── auth.c │ │ │ │ └── verify.c │ │ │ ├── selected │ │ │ ├── used │ │ │ └── x86 │ │ │ │ ├── api.h │ │ │ │ ├── auth.s │ │ │ │ ├── constants.s │ │ │ │ └── verify.c │ │ ├── try.c │ │ ├── wrapper-auth.cpp │ │ └── wrapper-verify.cpp │ ├── crypto_scalarmult │ │ ├── curve25519 │ │ │ ├── checksum │ │ │ ├── donna_c64 │ │ │ │ ├── api.h │ │ │ │ ├── base.c │ │ │ │ ├── implementors │ │ │ │ └── smult.c │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── base.c │ │ │ │ ├── implementors │ │ │ │ └── smult.c │ │ │ └── used │ │ ├── measure.c │ │ ├── try.c │ │ ├── wrapper-base.cpp │ │ └── wrapper-mult.cpp │ ├── crypto_secretbox │ │ ├── measure.c │ │ ├── try.c │ │ ├── wrapper-box.cpp │ │ ├── wrapper-open.cpp │ │ └── xsalsa20poly1305 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ ├── api.h │ │ │ └── box.c │ │ │ ├── selected │ │ │ └── used │ ├── crypto_sign │ │ ├── ed25519 │ │ │ ├── description │ │ │ ├── designers │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── ed25519.c │ │ │ │ ├── fe25519.c │ │ │ │ ├── fe25519.h │ │ │ │ ├── ge25519.c │ │ │ │ ├── ge25519.h │ │ │ │ ├── ge25519_base.data │ │ │ │ ├── implementors │ │ │ │ ├── sc25519.c │ │ │ │ └── sc25519.h │ │ │ ├── selected │ │ │ └── used │ │ ├── edwards25519sha512batch │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── fe25519.c │ │ │ │ ├── fe25519.h │ │ │ │ ├── ge25519.c │ │ │ │ ├── ge25519.h │ │ │ │ ├── sc25519.c │ │ │ │ ├── sc25519.h │ │ │ │ └── sign.c │ │ │ ├── selected │ │ │ └── used │ │ ├── measure.c │ │ ├── try.c │ │ ├── wrapper-keypair.cpp │ │ ├── wrapper-sign-open.cpp │ │ └── wrapper-sign.cpp │ ├── crypto_stream │ │ ├── aes128ctr │ │ │ ├── checksum │ │ │ ├── portable │ │ │ │ ├── afternm.c │ │ │ │ ├── api.h │ │ │ │ ├── beforenm.c │ │ │ │ ├── common.c │ │ │ │ ├── common.h │ │ │ │ ├── consts.c │ │ │ │ ├── consts.h │ │ │ │ ├── int128.c │ │ │ │ ├── int128.h │ │ │ │ ├── stream.c │ │ │ │ ├── types.h │ │ │ │ └── xor_afternm.c │ │ │ └── used │ │ ├── measure.c │ │ ├── salsa20 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── implementors │ │ │ │ ├── stream.c │ │ │ │ └── xor.c │ │ │ └── used │ │ ├── salsa2012 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── implementors │ │ │ │ ├── stream.c │ │ │ │ └── xor.c │ │ │ └── used │ │ ├── salsa208 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ ├── implementors │ │ │ │ ├── stream.c │ │ │ │ └── xor.c │ │ │ └── used │ │ ├── try.c │ │ ├── wrapper-stream.cpp │ │ ├── wrapper-xor.cpp │ │ └── xsalsa20 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ ├── api.h │ │ │ ├── implementors │ │ │ ├── stream.c │ │ │ └── xor.c │ │ │ ├── selected │ │ │ └── used │ ├── crypto_verify │ │ ├── 16 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ └── verify.c │ │ │ └── used │ │ ├── 32 │ │ │ ├── checksum │ │ │ ├── ref │ │ │ │ ├── api.h │ │ │ │ └── verify.c │ │ │ └── used │ │ ├── measure.c │ │ ├── try.c │ │ └── wrapper-empty.cpp │ ├── dist-dirs │ ├── dist-files │ ├── do │ ├── inttypes │ │ ├── crypto_int16.c │ │ ├── crypto_int32.c │ │ ├── crypto_int64.c │ │ ├── crypto_int8.c │ │ ├── crypto_uint16.c │ │ ├── crypto_uint32.c │ │ ├── crypto_uint64.c │ │ ├── crypto_uint8.c │ │ ├── do │ │ ├── signed.h │ │ └── unsigned.h │ ├── measure-anything.c │ ├── okcompilers │ │ ├── abiname.c │ │ ├── abinames │ │ ├── archivers │ │ ├── c.in │ │ ├── do.in │ │ ├── lib.c │ │ ├── lib.cpp │ │ ├── main.c │ │ ├── main.cpp │ │ ├── test-okar │ │ ├── test-okc │ │ ├── test-okc2 │ │ ├── test-okclink │ │ ├── test.c │ │ ├── test10.c │ │ ├── test5.c │ │ ├── test5.cpp │ │ ├── test6.c │ │ └── test9.c │ ├── randombytes │ │ ├── devurandom.c │ │ ├── devurandom.h │ │ ├── do │ │ └── test.c │ ├── tests │ │ ├── Makefile.in │ │ ├── auth.c │ │ ├── auth.out │ │ ├── auth2.c │ │ ├── auth2.out │ │ ├── auth3.c │ │ ├── auth3.out │ │ ├── auth4.cpp │ │ ├── auth4.out │ │ ├── auth5.c │ │ ├── auth5.out │ │ ├── auth6.cpp │ │ ├── auth6.out │ │ ├── box.c │ │ ├── box.out │ │ ├── box2.c │ │ ├── box2.out │ │ ├── box3.cpp │ │ ├── box3.out │ │ ├── box4.cpp │ │ ├── box4.out │ │ ├── box5.cpp │ │ ├── box5.out │ │ ├── box6.cpp │ │ ├── box6.out │ │ ├── box7.c │ │ ├── box7.out │ │ ├── box8.c │ │ ├── box8.out │ │ ├── core1.c │ │ ├── core1.out │ │ ├── core2.c │ │ ├── core2.out │ │ ├── core3.c │ │ ├── core3.out │ │ ├── core4.c │ │ ├── core4.out │ │ ├── core5.c │ │ ├── core5.out │ │ ├── core6.c │ │ ├── core6.out │ │ ├── hash.c │ │ ├── hash.out │ │ ├── hash2.cpp │ │ ├── hash2.out │ │ ├── hash3.c │ │ ├── hash3.out │ │ ├── hash4.cpp │ │ ├── hash4.out │ │ ├── onetimeauth.c │ │ ├── onetimeauth.out │ │ ├── onetimeauth2.c │ │ ├── onetimeauth2.out │ │ ├── onetimeauth5.cpp │ │ ├── onetimeauth5.out │ │ ├── onetimeauth6.cpp │ │ ├── onetimeauth6.out │ │ ├── onetimeauth7.c │ │ ├── onetimeauth7.out │ │ ├── onetimeauth8.cpp │ │ ├── onetimeauth8.out │ │ ├── scalarmult.c │ │ ├── scalarmult.out │ │ ├── scalarmult2.c │ │ ├── scalarmult2.out │ │ ├── scalarmult3.cpp │ │ ├── scalarmult3.out │ │ ├── scalarmult4.cpp │ │ ├── scalarmult4.out │ │ ├── scalarmult5.c │ │ ├── scalarmult5.out │ │ ├── scalarmult6.c │ │ ├── scalarmult6.out │ │ ├── scalarmult7.cpp │ │ ├── scalarmult7.out │ │ ├── secretbox.c │ │ ├── secretbox.out │ │ ├── secretbox2.c │ │ ├── secretbox2.out │ │ ├── secretbox3.cpp │ │ ├── secretbox3.out │ │ ├── secretbox4.cpp │ │ ├── secretbox4.out │ │ ├── secretbox5.cpp │ │ ├── secretbox5.out │ │ ├── secretbox6.cpp │ │ ├── secretbox6.out │ │ ├── secretbox7.c │ │ ├── secretbox7.out │ │ ├── secretbox8.c │ │ ├── secretbox8.out │ │ ├── stream.c │ │ ├── stream.out │ │ ├── stream2.c │ │ ├── stream2.out │ │ ├── stream3.c │ │ ├── stream3.out │ │ ├── stream4.c │ │ ├── stream4.out │ │ ├── stream5.cpp │ │ ├── stream5.out │ │ ├── stream6.cpp │ │ ├── stream6.out │ │ ├── stream7.cpp │ │ ├── stream7.out │ │ ├── stream8.cpp │ │ └── stream8.out │ ├── try-anything.c │ ├── version │ └── windows │ │ └── include │ │ └── windows-quirks.h ├── plugins │ ├── Makefile.am │ ├── WARNING │ ├── example-ldns-aaaa-blocking │ │ ├── Makefile.am │ │ └── example-ldns-aaaa-blocking.c │ ├── example-ldns-blocking │ │ ├── Makefile.am │ │ └── example-ldns-blocking.c │ ├── example-ldns-forward-after-nxdomain │ │ ├── Makefile.am │ │ └── example-ldns-forward-after-nxdomain.c │ ├── example-ldns-opendns-deviceid │ │ ├── Makefile.am │ │ └── example-ldns-opendns-deviceid.c │ ├── example-logging │ │ ├── Makefile.am │ │ └── example-logging.c │ └── example │ │ ├── Makefile.am │ │ └── example.c └── proxy │ ├── Makefile.am │ ├── app.c │ ├── app.h │ ├── cert.c │ ├── cert.h │ ├── cert_p.h │ ├── dnscrypt.c │ ├── dnscrypt.h │ ├── dnscrypt_client.c │ ├── dnscrypt_client.h │ ├── dnscrypt_proxy.h │ ├── edns.c │ ├── edns.h │ ├── getpwnam.h │ ├── logger.c │ ├── logger.h │ ├── options.c │ ├── options.h │ ├── pathnames.h │ ├── pid_file.c │ ├── pid_file.h │ ├── plugin_options.c │ ├── plugin_options.h │ ├── plugin_support.c │ ├── plugin_support.h │ ├── plugin_support_p.h │ ├── probes_dnscrypt_proxy.d │ ├── probes_no_dtrace.h │ ├── safe_rw.c │ ├── safe_rw.h │ ├── salsa20_random.c │ ├── salsa20_random.h │ ├── sandboxes.c │ ├── sandboxes.h │ ├── stack_trace.c │ ├── stack_trace.h │ ├── tcp_request.c │ ├── tcp_request.h │ ├── tcp_request_p.h │ ├── udp_request.c │ ├── udp_request.h │ ├── udp_request_p.h │ ├── utils.c │ ├── utils.h │ ├── windows_service.c │ └── windows_service.h └── test ├── Gemfile ├── Gemfile.lock ├── Makefile.in ├── Rakefile ├── dist-dirs ├── dist-files └── features ├── step_definitions ├── dnscrypt-proxy.rb └── opendnscache.rb ├── support └── env.rb ├── test-dnscrypt-proxy ├── forced_tcp.feature ├── help.feature ├── small_udp_query.feature └── tcp_fallback.feature └── test-hostip ├── help.feature ├── resolve-specific.feature └── resolve.feature /AUTHORS: -------------------------------------------------------------------------------- 1 | NaCl 2 | ---- 3 | see http://nacl.cr.yp.to/ for more info about this library and the 4 | list of contributors. 5 | 6 | libevent 7 | -------- 8 | see https://http://libevent.org/ for more info about this library 9 | and the src/libevent/README file for the list of contributors. 10 | 11 | dnscrypt 12 | -------- 13 | Frank Denis 14 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | ACLOCAL_AMFLAGS = -I m4 2 | 3 | AUTOMAKE_OPTIONS = gnu 4 | 5 | EXTRA_DIST = \ 6 | README.markdown \ 7 | README-PLUGINS.markdown \ 8 | README-WINDOWS.markdown \ 9 | TECHNOTES \ 10 | THANKS \ 11 | autogen.sh \ 12 | org.dnscrypt.osx.DNSCryptProxy.plist 13 | 14 | SUBDIRS = \ 15 | dist-build \ 16 | man 17 | 18 | if PLUGINS 19 | SUBDIRS += \ 20 | libltdl 21 | endif 22 | 23 | SUBDIRS += \ 24 | src \ 25 | test 26 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | See README.markdown 2 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Stuart Henderson - OpenBSD port 2 | D. J. Bernstein - for his feedback 3 | Lance Fredrickson - for his feedback on DD-WRT/mips 4 | Sebastian Sjoholm - reported and fixed a compilation issue on Debian PPC. 5 | David Lebel - Gentoo package 6 | Black Roland - OpenWRT packages 7 | RotBlitz - Reported that Windows binary packages should work on old CPUs. 8 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 4 | exec autoreconf -ivf 5 | fi 6 | 7 | if glibtoolize --version > /dev/null 2>&1; then 8 | LIBTOOLIZE='glibtoolize' 9 | else 10 | LIBTOOLIZE='libtoolize' 11 | fi 12 | 13 | src/libevent/autogen.sh & 14 | cpid=$! 15 | 16 | $LIBTOOLIZE --ltdl && \ 17 | aclocal && \ 18 | autoheader && \ 19 | automake --add-missing --force-missing --include-deps && \ 20 | autoconf 21 | 22 | wait $cpid 23 | -------------------------------------------------------------------------------- /config.guess-bitrig.diff: -------------------------------------------------------------------------------- 1 | --- config.guess~ Mon Jul 16 07:03:25 2012 2 | +++ config.guess Mon Jul 16 07:03:25 2012 3 | @@ -204,6 +204,10 @@ 4 | UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` 5 | echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} 6 | exit ;; 7 | + *:Bitrig:*:*) 8 | + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` 9 | + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} 10 | + exit ;; 11 | *:ekkoBSD:*:*) 12 | echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} 13 | exit ;; 14 | -------------------------------------------------------------------------------- /dist-build/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = \ 2 | android.sh \ 3 | iphone.sh \ 4 | msys.sh \ 5 | osx.sh 6 | -------------------------------------------------------------------------------- /dist-build/android.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | export CFLAGS="-Os -mthumb" 4 | export DROID_HOST=darwin-x86 5 | export LDFLAGS="-mthumb" 6 | export NDK_PLATFORM=8 7 | export NDK_ROOT=/usr/local/Cellar/android-ndk/r8b 8 | export TARGET_TOOLCHAIN_VERSION=4.4.3 9 | export TARGET=arm-linux-androideabi 10 | export NDK_TARGET="arm-linux-androideabi-${TARGET_TOOLCHAIN_VERSION}" 11 | export AR=droid-ar 12 | export AS=droid-as 13 | export CC=droid-gcc 14 | export LD=droid-ld 15 | export NM=droid-nm 16 | export OBJCOPY=droid-objcopy 17 | export RANLIB=droid-ranlib 18 | export STRIP=droid-strip 19 | 20 | ./configure --host=arm-linux-androideabi && make -j3 21 | -------------------------------------------------------------------------------- /dist-build/iphone.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | export XCODEDIR="/Applications/Xcode.app/Contents/Developer" 4 | export BASEDIR="${XCODEDIR}/Platforms/iPhoneOS.platform/Developer" 5 | export PATH="${BASEDIR}/usr/bin:$BASEDIR/usr/sbin:$PATH" 6 | export SDK="${BASEDIR}/SDKs/iPhoneOS6.0.sdk" 7 | export CFLAGS="-Oz -mthumb -arch armv7 -isysroot ${SDK}" 8 | export LDFLAGS="-mthumb -arch armv7 -isysroot ${SDK}" 9 | 10 | ./configure --host=arm-apple-darwin10 && make -j3 11 | 12 | echo 'Now, using codesign(1) to sign dnscrypt-proxy' 13 | -------------------------------------------------------------------------------- /dist-build/msys.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | export CFLAGS="-Os -march=pentium2 -mtune=nocona" 4 | 5 | ./configure --disable-ssp --enable-plugins --with-included-ltdl && \ 6 | make -j3 install-strip 7 | 8 | upx --best --ultra-brute /usr/local/sbin/dnscrypt-proxy.exe & 9 | upx --best --ultra-brute /usr/local/bin/hostip.exe 10 | 11 | wait 12 | -------------------------------------------------------------------------------- /dist-build/osx.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | export CFLAGS="-mmacosx-version-min=10.6" 4 | export LDFLAGS="-mmacosx-version-min=10.6" 5 | 6 | ./configure --with-included-ltdl \ 7 | --enable-plugins \ 8 | --enable-plugins-root && \ 9 | make -j3 10 | -------------------------------------------------------------------------------- /man/Makefile.am: -------------------------------------------------------------------------------- 1 | man_MANS = \ 2 | dnscrypt-proxy.8 \ 3 | hostip.8 4 | 5 | EXTRA_DIST= \ 6 | dnscrypt-proxy.8 \ 7 | dnscrypt-proxy.8.markdown \ 8 | hostip.8 \ 9 | hostip.8.markdown 10 | 11 | dnscrypt-proxy.8: dnscrypt-proxy.8.markdown 12 | @RONN@ dnscrypt-proxy.8.markdown 13 | 14 | hostip.8: hostip.8.markdown 15 | @RONN@ hostip.8.markdown 16 | -------------------------------------------------------------------------------- /man/hostip.8.markdown: -------------------------------------------------------------------------------- 1 | hostip(8) -- Resolve a host name to an IP address 2 | ================================================= 3 | 4 | ## SYNOPSIS 5 | 6 | `hostip` [] host_name 7 | 8 | ## DESCRIPTION 9 | 10 | **hostip** sends a DNS query to a resolver, and prints the IP 11 | addresses for the given host name. 12 | 13 | It can be useful in order to retrieve IP addresses before 14 | dnscrypt-proxy(8) is started. 15 | 16 | ## OPTIONS 17 | 18 | * `-6`, `--ipv6`: ask for AAAA records. 19 | 20 | * `-h`, `--help`: show usage. 21 | 22 | * `-r`, `--resolver-address=[:port]`: the resolver IP address 23 | (default: 208.67.220.220, OpenDNS). 24 | 25 | * `-V`, `--version`: show version number. 26 | 27 | ## SIMPLE USAGE EXAMPLE 28 | 29 | $ hostip www.example.com 30 | 31 | ## ADVANCED USAGE EXAMPLE 32 | 33 | $ hostip -6 -r 213.154.224.3 www.google.com 34 | 35 | ## EXIT STATUS 36 | 37 | The `hostip` utility exits 0 on success, and > 0 if an error occurs. 38 | 39 | ## SEE ALSO 40 | 41 | dnscrypt-proxy(8) 42 | 43 | ## COPYRIGHT 44 | 45 | hostip is Copyright (C) 2012 OpenDNS, Inc. 46 | `http://www.opendns.com/` 47 | 48 | -------------------------------------------------------------------------------- /org.dnscrypt.osx.DNSCryptProxy.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Label 6 | org.dnscrypt.osx.DNSCryptProxy 7 | KeepAlive 8 | 9 | RunAtLoad 10 | 11 | ProgramArguments 12 | 13 | /usr/local/sbin/dnscrypt-proxy 14 | --user=nobody 15 | 16 | StandardErrorPath 17 | /dev/null 18 | StandardOutPath 19 | /dev/null 20 | UserName 21 | root 22 | 23 | 24 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/distinfo: -------------------------------------------------------------------------------- 1 | SHA256 (dnscrypt-proxy-1.1.0.tar.gz) = c8EEL2umje3YmrUYwxn15Gs1NqPEnml++bpQRgGybHE= 2 | SIZE (dnscrypt-proxy-1.1.0.tar.gz) = 1720324 3 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/DESCR-main: -------------------------------------------------------------------------------- 1 | DNSCrypt is a slight variation on DNSCurve. 2 | 3 | DNSCurve improves confidentiality and integrity of DNS requests using 4 | high-speed high-security elliptic-curve cryptography. Best of all, 5 | DNSCurve has a very low overhead and adds virtually no latency to 6 | queries. 7 | 8 | DNSCurve aims at securing the entiere chain down to authoritative 9 | servers. But it only works with authoritative servers that explicitly 10 | support the protocol. 11 | 12 | The DNSCrypt protocol is very similar to DNSCurve, but focuses on 13 | securing communications between a client and its first-level resolver. 14 | While not providing end-to-end security, it protects the local 15 | network, which is often the weakest point of the chain, against 16 | man-in-the-middle attacks. It also provides some confidentiality to 17 | DNS queries. 18 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/DESCR-plugins: -------------------------------------------------------------------------------- 1 | A collection of plugins for dnscrypt-proxy. 2 | 3 | - example-ldns-blocking: This plugin returns a REFUSED response if the 4 | query name is in a list of blacklisted names, or if at least one of 5 | the returned IP addresses happens to be in a list of blacklisted IPs. 6 | 7 | - example-ldns-logging: This plugin logs the client queries to the 8 | standard output (default) or to a file. 9 | 10 | - example-ldns-opendns-deviceid: This plugin is only useful when using 11 | OpenDNS with specific routers and enterprise products. 12 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/MESSAGE-main: -------------------------------------------------------------------------------- 1 | In order to perform queries over DNSCrypt, using OpenDNS as a 2 | resolver, the easiest way is change your /etc/resolv.conf file to: 3 | 4 | nameserver 127.0.0.1 5 | lookup file bind 6 | options edns0 7 | 8 | But DNSCrypt does _not_ cache queries. So the recommended way to use 9 | it is as a forwarder for a DNS cache like Unbound. 10 | Both can safely run on the same host. 11 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/PFRAG.shared: -------------------------------------------------------------------------------- 1 | @comment $OpenBSD$ 2 | lib/dnscrypt-proxy/libdcplugin_example.so 3 | lib/dnscrypt-proxy/libdcplugin_example_ldns_blocking.so 4 | lib/dnscrypt-proxy/libdcplugin_example_ldns_opendns_deviceid.so 5 | lib/dnscrypt-proxy/libdcplugin_example_logging.so 6 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/PFRAG.shared-plugins: -------------------------------------------------------------------------------- 1 | @comment $OpenBSD$ 2 | lib/dnscrypt-proxy/libdcplugin_example.so 3 | lib/dnscrypt-proxy/libdcplugin_example_ldns_blocking.so 4 | lib/dnscrypt-proxy/libdcplugin_example_ldns_opendns_deviceid.so 5 | lib/dnscrypt-proxy/libdcplugin_example_ldns_opendns_parental_control.so 6 | lib/dnscrypt-proxy/libdcplugin_example_ldns_opendns_set_client_ip.so 7 | lib/dnscrypt-proxy/libdcplugin_example_logging.so 8 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/PLIST-main: -------------------------------------------------------------------------------- 1 | @comment $OpenBSD$ 2 | @newgroup _dnscrypt-proxy:688 3 | @newuser _dnscrypt-proxy:688:_dnscrypt-proxy:daemon:dnscrypt-proxy user:/var/empty:/sbin/nologin 4 | @bin bin/hostip 5 | include/dnscrypt/ 6 | include/dnscrypt/plugin.h 7 | include/dnscrypt/private.h 8 | include/dnscrypt/version.h 9 | @man man/man8/dnscrypt-proxy.8 10 | @man man/man8/hostip.8 11 | @bin sbin/dnscrypt-proxy 12 | share/doc/dnscrypt-proxy/ 13 | share/doc/dnscrypt-proxy/README-PLUGINS.markdown 14 | share/doc/dnscrypt-proxy/README.markdown 15 | share/doc/dnscrypt-proxy/TECHNOTES 16 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/PLIST-plugins: -------------------------------------------------------------------------------- 1 | @comment $OpenBSD$ 2 | %%SHARED%% 3 | -------------------------------------------------------------------------------- /packages/OpenBSD/net/dnscrypt-proxy/pkg/dnscrypt_proxy.rc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # $OpenBSD$ 4 | 5 | daemon="${TRUEPREFIX}/sbin/dnscrypt-proxy" 6 | 7 | # Use OpenDNS resolvers 8 | daemon_flags="-d --user=_dnscrypt-proxy" 9 | 10 | . /etc/rc.d/rc.subr 11 | 12 | rc_reload=NO 13 | 14 | rc_cmd $1 15 | -------------------------------------------------------------------------------- /packages/gentoo/net-dns/dnscrypt-proxy/dnscrypt-proxy-0.9.3.ebuild: -------------------------------------------------------------------------------- 1 | EAPI="3" 2 | 3 | inherit eutils flag-o-matic 4 | 5 | DESCRIPTION="A tool for securing communications between a client and a DNS resolver" 6 | HOMEPAGE="http://www.opendns.com/technology/dnscrypt/" 7 | SRC_URI="https://github.com/downloads/opendns/dnscrypt-proxy/${P}.tar.gz" 8 | 9 | LICENSE="BSD" 10 | SLOT="0" 11 | KEYWORDS="amd64 i386" 12 | 13 | pkg_setup() { 14 | enewgroup dnscrypt 15 | enewuser dnscrypt -1 -1 /var/empty dnscrypt 16 | } 17 | 18 | src_configure() { 19 | append-ldflags -Wl,-z,noexecstack || die 20 | econf || die 21 | } 22 | 23 | src_install() { 24 | emake DESTDIR="${D}" install || die "emake install failed" 25 | 26 | newinitd "${FILESDIR}/dnscrypt-proxy.initd" dnscrypt-proxy || die "newinitd failed" 27 | newconfd "${FILESDIR}/dnscrypt-proxy.confd" dnscrypt-proxy || die "newconfd failed" 28 | 29 | dodoc {AUTHORS,COPYING,INSTALL,NEWS,README,README.markdown,TECHNOTES,THANKS} || die "dodoc failed" 30 | } 31 | -------------------------------------------------------------------------------- /packages/gentoo/net-dns/dnscrypt-proxy/dnscrypt-proxy-0.9.4.ebuild: -------------------------------------------------------------------------------- 1 | EAPI="3" 2 | 3 | inherit eutils flag-o-matic 4 | 5 | DESCRIPTION="A tool for securing communications between a client and a DNS resolver" 6 | HOMEPAGE="http://www.opendns.com/technology/dnscrypt/" 7 | SRC_URI="https://github.com/downloads/opendns/dnscrypt-proxy/${P}.tar.gz" 8 | 9 | LICENSE="BSD" 10 | SLOT="0" 11 | KEYWORDS="amd64 i386" 12 | 13 | pkg_setup() { 14 | enewgroup dnscrypt 15 | enewuser dnscrypt -1 -1 /var/empty dnscrypt 16 | } 17 | 18 | src_configure() { 19 | append-ldflags -Wl,-z,noexecstack || die 20 | econf --enable-nonblocking-random || die 21 | } 22 | 23 | src_install() { 24 | emake DESTDIR="${D}" install || die "emake install failed" 25 | 26 | newinitd "${FILESDIR}/dnscrypt-proxy.initd" dnscrypt-proxy || die "newinitd failed" 27 | newconfd "${FILESDIR}/dnscrypt-proxy.confd" dnscrypt-proxy || die "newconfd failed" 28 | 29 | dodoc {AUTHORS,COPYING,INSTALL,NEWS,README,README.markdown,TECHNOTES,THANKS} || die "dodoc failed" 30 | } 31 | -------------------------------------------------------------------------------- /packages/gentoo/net-dns/dnscrypt-proxy/dnscrypt-proxy-1.0.ebuild: -------------------------------------------------------------------------------- 1 | EAPI="3" 2 | 3 | inherit eutils flag-o-matic 4 | 5 | DESCRIPTION="A tool for securing communications between a client and a DNS resolver" 6 | HOMEPAGE="http://www.opendns.com/technology/dnscrypt/" 7 | SRC_URI="https://github.com/downloads/opendns/dnscrypt-proxy/${P}.tar.gz" 8 | 9 | LICENSE="BSD" 10 | SLOT="0" 11 | KEYWORDS="amd64 i386" 12 | 13 | pkg_setup() { 14 | enewgroup dnscrypt 15 | enewuser dnscrypt -1 -1 /var/empty dnscrypt 16 | } 17 | 18 | src_configure() { 19 | append-ldflags -Wl,-z,noexecstack || die 20 | econf --enable-nonblocking-random || die 21 | } 22 | 23 | src_install() { 24 | emake DESTDIR="${D}" install || die "emake install failed" 25 | 26 | newinitd "${FILESDIR}/dnscrypt-proxy.initd" dnscrypt-proxy || die "newinitd failed" 27 | newconfd "${FILESDIR}/dnscrypt-proxy.confd" dnscrypt-proxy || die "newconfd failed" 28 | 29 | dodoc {AUTHORS,COPYING,INSTALL,NEWS,README,README.markdown,TECHNOTES,THANKS} || die "dodoc failed" 30 | } 31 | -------------------------------------------------------------------------------- /packages/gentoo/net-dns/dnscrypt-proxy/files/dnscrypt-proxy.confd: -------------------------------------------------------------------------------- 1 | DNSCRYPT_LOCALIP=127.0.0.1 2 | DNSCRYPT_LOCALPORT=52 3 | -------------------------------------------------------------------------------- /packages/homebrew/dnscrypt-proxy.rb: -------------------------------------------------------------------------------- 1 | require 'formula' 2 | 3 | class DnscryptProxy < Formula 4 | homepage 'http://dnscrypt.org' 5 | url 'https://github.com/downloads/opendns/dnscrypt-proxy/dnscrypt-proxy-1.1.0.tar.gz' 6 | head 'https://github.com/opendns/dnscrypt-proxy.git', :branch => 'master' 7 | sha256 '73c1042f6ba68dedd89ab518c319f5e46b3536a3c49e697ef9ba504601b26c71' 8 | 9 | if build.head? 10 | depends_on :automake 11 | depends_on :libtool 12 | end 13 | 14 | option "plugins", "Support plugins and install example plugins." 15 | 16 | def install 17 | system "autoreconf", "-if" if build.head? 18 | 19 | configure_args = [ "--prefix=#{prefix}", "--disable-dependency-tracking" ] 20 | if build.include? "plugins" 21 | configure_args << "--enable-plugins" 22 | configure_args << "--enable-plugins-root" 23 | configure_args << "--enable-relaxed-plugins-permissions" 24 | end 25 | system "./configure", *configure_args 26 | system "make install" 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/DESCR: -------------------------------------------------------------------------------- 1 | DNSCrypt is a slight variation on DNSCurve. 2 | 3 | DNSCurve improves confidentiality and integrity of DNS requests using 4 | high-speed high-security elliptic-curve cryptography. Best of all, 5 | DNSCurve has a very low overhead and adds virtually no latency to 6 | queries. 7 | 8 | DNSCurve aims at securing the entiere chain down to authoritative 9 | servers. But it only works with authoritative servers that explicitly 10 | support the protocol. 11 | 12 | The DNSCrypt protocol is very similar to DNSCurve, but focuses on 13 | securing communications between a client and its first-level resolver. 14 | While not providing end-to-end security, it protects the local 15 | network, which is often the weakest point of the chain, against 16 | man-in-the-middle attacks. It also provides some confidentiality to 17 | DNS queries. 18 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/MESSAGE: -------------------------------------------------------------------------------- 1 | In order to perform queries over DNSCrypt, using OpenDNS as a 2 | resolver, the easiest way is change your /etc/resolv.conf file to: 3 | 4 | nameserver 127.0.0.1 5 | lookup file bind 6 | options edns0 7 | 8 | But DNSCrypt does _not_ cache queries. So the recommended way to use 9 | it is as a forwarder for a DNS cache like Unbound. 10 | Both can safely run on the same host. 11 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/Makefile: -------------------------------------------------------------------------------- 1 | 2 | DISTNAME= dnscrypt-proxy-1.1.0 3 | CATEGORIES= net 4 | MASTER_SITES= http://cloud.github.com/downloads/opendns/dnscrypt-proxy/ 5 | 6 | MAINTAINER= dnscrypt@pureftpd.org 7 | HOMEPAGE= http://dnscrypt.org 8 | COMMENT= secure communications between a client and a DNS resolver 9 | LICENSE= modified-bsd 10 | 11 | PKG_DESTDIR_SUPPORT= user-destdir 12 | 13 | GNU_CONFIGURE= yes 14 | CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR} 15 | CONFIGURE_ARGS+= --localstatedir=${VARBASE} 16 | 17 | BUILD_DEFS+= VARBASE 18 | 19 | .include "../../mk/bsd.prefs.mk" 20 | 21 | RCD_SCRIPTS= dnscrypt_proxy 22 | INSTALLATION_DIRS= share/doc/dnscrypt-proxy 23 | 24 | post-install: 25 | cd ${WRKSRC} && \ 26 | ${INSTALL_DATA} README.markdown \ 27 | ${DESTDIR}${PREFIX}/share/doc/dnscrypt-proxy 28 | 29 | .include "../../mk/bsd.pkg.mk" 30 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/PLIST: -------------------------------------------------------------------------------- 1 | @comment $NetBSD$ 2 | bin/hostip 3 | sbin/dnscrypt-proxy 4 | man/man8/dnscrypt-proxy.8 5 | man/man8/hostip.8 6 | share/doc/dnscrypt-proxy/README.markdown 7 | share/examples/rc.d/dnscrypt_proxy 8 | 9 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/distinfo: -------------------------------------------------------------------------------- 1 | $NetBSD$ 2 | 3 | SHA1 (dnscrypt-proxy-1.1.0.tar.gz) = dca837481dbd6903f7a4eb212cc6189e41299e78 4 | RMD160 (dnscrypt-proxy-1.1.0.tar.gz) = 274f09132d46ffc1f2ebff1cff6aa99e2c587143 5 | Size (dnscrypt-proxy-1.0.tar.gz) = 1720324 bytes 6 | -------------------------------------------------------------------------------- /packages/pkgsrc/net/dnscrypt-proxy/files/dnscrypt_proxy.sh: -------------------------------------------------------------------------------- 1 | #!@RCD_SCRIPTS_SHELL@ 2 | # 3 | # PROVIDE: dnscrypt_proxy 4 | # REQUIRE: DAEMON 5 | 6 | . /etc/rc.subr 7 | 8 | name="dnscrypt_proxy" 9 | help_name="dnscrypt-proxy" 10 | rcvar=$name 11 | command="@PREFIX@/sbin/${help_name}" 12 | pidfile="@VARBASE@/run/${help_name}.pid" 13 | command_args="--daemonize --pidfile={$pidfile}" 14 | 15 | load_rc_config $name 16 | run_rc_command "$1" 17 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | SUBDIRS = \ 3 | ext \ 4 | libevent \ 5 | libnacl \ 6 | proxy \ 7 | hostip 8 | 9 | if PLUGINS 10 | SUBDIRS += \ 11 | include \ 12 | plugins 13 | endif 14 | -------------------------------------------------------------------------------- /src/ext/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_HEADERS = \ 3 | queue.h 4 | -------------------------------------------------------------------------------- /src/hostip/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | bin_PROGRAMS = \ 3 | hostip 4 | 5 | hostip_SOURCES = \ 6 | app.c \ 7 | app.h \ 8 | options.c \ 9 | options.h 10 | 11 | AM_CFLAGS = @CWFLAGS@ 12 | 13 | AM_CPPFLAGS = \ 14 | -I../libevent/include 15 | 16 | hostip_LDADD = \ 17 | ../libevent/libevent_extra.la \ 18 | ../libevent/libevent_core.la 19 | -------------------------------------------------------------------------------- /src/hostip/app.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __APP_H__ 3 | #define __APP_H__ 1 4 | 5 | #include 6 | 7 | typedef struct AppContext_ { 8 | struct event_base *event_loop; 9 | const char *host_name; 10 | const char *resolver_ip; 11 | _Bool want_ipv6; 12 | } AppContext; 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/hostip/options.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __OPTIONS_H__ 3 | #define __OPTIONS_H__ 1 4 | 5 | #include "options.h" 6 | 7 | int options_parse(AppContext * const app_context, int argc, char *argv[]); 8 | 9 | #endif 10 | 11 | -------------------------------------------------------------------------------- /src/include/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | DNSCRYPT_EXPORT = \ 3 | dnscrypt/plugin.h \ 4 | dnscrypt/private.h \ 5 | dnscrypt/version.h 6 | 7 | EXTRA_SRC = $(DNSCRYPT_EXPORT) \ 8 | dnscrypt/version.h.in 9 | 10 | nobase_include_HEADERS = $(DNSCRYPT_EXPORT) 11 | -------------------------------------------------------------------------------- /src/include/dnscrypt/private.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DNSCRYPT_PRIVATE_H__ 3 | #define __DNSCRYPT_PRIVATE_H__ 1 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | #ifdef __cplusplus 13 | extern "C" { 14 | #endif 15 | 16 | struct DCPlugin_ { 17 | void *user_data; 18 | }; 19 | 20 | struct DCPluginDNSPacket_ { 21 | struct sockaddr_storage *client_sockaddr; 22 | uint8_t *dns_packet; 23 | size_t *dns_packet_len_p; 24 | size_t client_sockaddr_len_s; 25 | size_t dns_packet_max_len; 26 | }; 27 | 28 | #define DCPLUGIN_MAIN_PRIVATE(ID) \ 29 | int dcplugin_interface_version_major = DCP_INTERFACE_VERSION_MAJOR; \ 30 | int dcplugin_interface_version_minor = DCP_INTERFACE_VERSION_MINOR 31 | 32 | #ifdef __cplusplus 33 | } 34 | #endif 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /src/include/dnscrypt/version.h.in: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __DNSCRYPT_VERSION_H__ 3 | #define __DNSCRYPT_VERSION_H__ 1 4 | 5 | #define DNSCRYPT_VERSION_STRING "@VERSION@" 6 | 7 | #define DCP_INTERFACE_VERSION_MAJOR 1 8 | #define DCP_INTERFACE_VERSION_MINOR 1 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libevent/autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | if [ -x "`which autoreconf 2>/dev/null`" ] ; then 3 | exec autoreconf -ivf 4 | fi 5 | 6 | $LIBTOOLIZE && \ 7 | aclocal -I m4 && \ 8 | autoheader && \ 9 | automake --add-missing --force-missing --include-deps && \ 10 | autoconf -I m4 11 | -------------------------------------------------------------------------------- /src/libevent/libevent.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent 9 | Description: libevent is an asynchronous notification event loop library 10 | Version: @VERSION@ 11 | Requires: 12 | Conflicts: 13 | Libs: -L${libdir} -levent 14 | Libs.private: @LIBS@ 15 | Cflags: -I${includedir} 16 | 17 | -------------------------------------------------------------------------------- /src/libevent/libevent_openssl.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent_openssl 9 | Description: libevent_openssl adds openssl-based TLS support to libevent 10 | Version: @VERSION@ 11 | Requires: libevent 12 | Conflicts: 13 | Libs: -L${libdir} -levent_openssl 14 | Libs.private: @LIBS@ -lssl -lcrypto 15 | Cflags: -I${includedir} 16 | 17 | -------------------------------------------------------------------------------- /src/libevent/libevent_pthreads.pc.in: -------------------------------------------------------------------------------- 1 | #libevent pkg-config source file 2 | 3 | prefix=@prefix@ 4 | exec_prefix=@exec_prefix@ 5 | libdir=@libdir@ 6 | includedir=@includedir@ 7 | 8 | Name: libevent_pthreads 9 | Description: libevent_pthreads adds pthreads-based threading support to libevent 10 | Version: @VERSION@ 11 | Requires: libevent 12 | Conflicts: 13 | Libs: -L${libdir} -levent_pthreads 14 | Libs.private: @LIBS@ @PTHREAD_LIBS@ 15 | Cflags: -I${includedir} @PTHREAD_CFLAGS@ 16 | 17 | -------------------------------------------------------------------------------- /src/libevent/make-event-config.sed: -------------------------------------------------------------------------------- 1 | # Sed script to postprocess config.h into event-config.h. 2 | 3 | 1i\ 4 | /* event2/event-config.h\ 5 | *\ 6 | * This file was generated by autoconf when libevent was built, and post-\ 7 | * processed by Libevent so that its macros would have a uniform prefix.\ 8 | *\ 9 | * DO NOT EDIT THIS FILE.\ 10 | *\ 11 | * Do not rely on macros in this file existing in later versions.\ 12 | */\ 13 | \ 14 | #ifndef _EVENT2_EVENT_CONFIG_H_\ 15 | #define _EVENT2_EVENT_CONFIG_H_\ 16 | 17 | $a\ 18 | \ 19 | #endif /* event2/event-config.h */ 20 | 21 | s/#define /#define _EVENT_/ 22 | s/#undef /#undef _EVENT_/ 23 | s/#ifndef /#ifndef _EVENT_/ 24 | -------------------------------------------------------------------------------- /src/libevent/sample/Makefile.am: -------------------------------------------------------------------------------- 1 | # sample/Makefile.am for libevent 2 | # Copyright 2000-2007 Niels Provos 3 | # Copyright 2007-2012 Niels Provos and Nick Mathewson 4 | # 5 | # See LICENSE for copying information. 6 | 7 | AUTOMAKE_OPTIONS = foreign no-dependencies 8 | 9 | LDADD = $(LIBEVENT_GC_SECTIONS) ../libevent.la 10 | AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/compat -I$(top_srcdir)/include -I../include 11 | 12 | noinst_PROGRAMS = event-test time-test signal-test dns-example hello-world http-server 13 | 14 | event_test_SOURCES = event-test.c 15 | time_test_SOURCES = time-test.c 16 | signal_test_SOURCES = signal-test.c 17 | dns_example_SOURCES = dns-example.c 18 | hello_world_SOURCES = hello-world.c 19 | http_server_SOURCES = http-server.c 20 | 21 | if OPENSSL 22 | noinst_PROGRAMS += le-proxy 23 | le_proxy_SOURCES = le-proxy.c 24 | le_proxy_LDADD = $(LDADD) ../libevent_openssl.la -lssl -lcrypto ${OPENSSL_LIBADD} 25 | endif 26 | 27 | verify: 28 | 29 | DISTCLEANFILES = *~ 30 | -------------------------------------------------------------------------------- /src/libevent/strlcpy-internal.h: -------------------------------------------------------------------------------- 1 | #ifndef _STRLCPY_INTERNAL_H_ 2 | #define _STRLCPY_INTERNAL_H_ 3 | 4 | #ifdef __cplusplus 5 | extern "C" { 6 | #endif 7 | 8 | #include "event2/event-config.h" 9 | 10 | #ifndef _EVENT_HAVE_STRLCPY 11 | #include 12 | size_t _event_strlcpy(char *dst, const char *src, size_t siz); 13 | #define strlcpy _event_strlcpy 14 | #endif 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #endif 21 | 22 | -------------------------------------------------------------------------------- /src/libevent/test/regress.rpc: -------------------------------------------------------------------------------- 1 | /* tests data packing and unpacking */ 2 | 3 | struct msg { 4 | string /* sender */ from_name = 1; /* be verbose */ 5 | string to_name = 2; 6 | optional struct[kill] attack = 3; 7 | array struct[run] run = 4; 8 | } 9 | 10 | struct kill { 11 | string weapon = 0x10121; 12 | string action = 2; 13 | array int how_often = 3; 14 | } 15 | 16 | struct run { 17 | string how = 1; 18 | optional bytes some_bytes = 2; 19 | 20 | bytes fixed_bytes[24] = 3; 21 | array string notes = 4; 22 | 23 | optional int64 large_number = 5; 24 | array int other_numbers = 6; 25 | } 26 | -------------------------------------------------------------------------------- /src/libevent/test/tinytest_local.h: -------------------------------------------------------------------------------- 1 | 2 | #ifdef WIN32 3 | #include 4 | #endif 5 | 6 | #include "event2/util.h" 7 | #include "util-internal.h" 8 | 9 | #ifdef snprintf 10 | #undef snprintf 11 | #endif 12 | #define snprintf evutil_snprintf 13 | -------------------------------------------------------------------------------- /src/libnacl/Makefile.in: -------------------------------------------------------------------------------- 1 | 2 | all: .done 3 | 4 | .done: 5 | ./do 6 | touch .done 7 | 8 | test: 9 | cd tests && $(MAKE) $(AM_MAKEFLAGS) test 10 | 11 | clean: 12 | cd tests && $(MAKE) $(AM_MAKEFLAGS) clean 13 | -$(RM) .done 14 | -$(RM) -r okcompilers/bin 15 | -$(RM) -r okcompilers/oldbin 16 | -$(RM) -r build/* 17 | 18 | distclean: clean 19 | cd tests && $(MAKE) $(AM_MAKEFLAGS) distclean 20 | -$(RM) okcompilers/c 21 | -$(RM) okcompilers/do 22 | 23 | install: 24 | install-data: 25 | install-exec: 26 | uninstall: 27 | install-dvi: 28 | install-html: 29 | install-info: 30 | install-ps: 31 | install-pdf: 32 | installdirs: 33 | check: 34 | installcheck: 35 | mostlyclean: clean 36 | maintainer-clean: distclean 37 | 38 | distdir: 39 | while read dir ; do @MKDIR_P@ "$(distdir)/$$dir" ; done < dist-dirs 40 | while read file ; do @INSTALL@ "$$file" "$(distdir)/$$file" ; done < dist-files 41 | 42 | EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags 43 | .PHONY: $(EMPTY_AUTOMAKE_TARGETS) 44 | $(EMPTY_AUTOMAKE_TARGETS): 45 | -------------------------------------------------------------------------------- /src/libnacl/OPERATIONS: -------------------------------------------------------------------------------- 1 | crypto_verify 2 | crypto_core 3 | crypto_hashblocks 4 | crypto_hash 5 | crypto_stream 6 | crypto_onetimeauth 7 | crypto_auth 8 | crypto_secretbox 9 | crypto_scalarmult 10 | crypto_box 11 | crypto_sign 12 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/alpha.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles alpha.h version 20060318 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_alpha_h 8 | #define CPUCYCLES_alpha_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_alpha(void); 15 | extern long long cpucycles_alpha_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "alpha" 23 | #define cpucycles cpucycles_alpha 24 | #define cpucycles_persecond cpucycles_alpha_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64cpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osfreq.c" 4 | 5 | long long cpucycles_amd64cpuinfo(void) 6 | { 7 | unsigned long long result; 8 | asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" 9 | : "=a" (result) :: "%rdx"); 10 | return result; 11 | } 12 | 13 | long long cpucycles_amd64cpuinfo_persecond(void) 14 | { 15 | return osfreq(); 16 | } 17 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles amd64cpuinfo.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_amd64cpuinfo_h 8 | #define CPUCYCLES_amd64cpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_amd64cpuinfo(void); 15 | extern long long cpucycles_amd64cpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "amd64cpuinfo" 23 | #define cpucycles cpucycles_amd64cpuinfo 24 | #define cpucycles_persecond cpucycles_amd64cpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64cpuspeed.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | long long cpucycles_amd64cpuspeed(void) 7 | { 8 | unsigned long long result; 9 | asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" 10 | : "=a" (result) :: "%rdx"); 11 | return result; 12 | } 13 | 14 | long long cpucycles_amd64cpuspeed_persecond(void) 15 | { 16 | int oid[2]; 17 | int val; 18 | size_t size; 19 | oid[0] = CTL_HW; 20 | oid[1] = HW_CPUSPEED; 21 | size = sizeof val; 22 | if (sysctl(oid,2,&val,&size,0,0) == -1) return 0; 23 | if (size != sizeof val) return 0; 24 | return val * 1000000LL; 25 | } 26 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64cpuspeed.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles amd64cpuspeed.h version 20090716 3 | Matthew Dempsky 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_amd64cpuspeed_h 8 | #define CPUCYCLES_amd64cpuspeed_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_amd64cpuspeed(void); 15 | extern long long cpucycles_amd64cpuspeed_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "amd64cpuspeed" 23 | #define cpucycles cpucycles_amd64cpuspeed 24 | #define cpucycles_persecond cpucycles_amd64cpuspeed_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64tscfreq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | long long cpucycles_amd64tscfreq(void) 5 | { 6 | unsigned long long result; 7 | asm volatile(".byte 15;.byte 49;shlq $32,%%rdx;orq %%rdx,%%rax" 8 | : "=a" (result) :: "%rdx"); 9 | return result; 10 | } 11 | 12 | long long cpucycles_amd64tscfreq_persecond(void) 13 | { 14 | long result = 0; 15 | size_t resultlen = sizeof(long); 16 | sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0); 17 | return result; 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/amd64tscfreq.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles amd64tscfreq.h version 20060318 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_amd64tscfreq_h 8 | #define CPUCYCLES_amd64tscfreq_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_amd64tscfreq(void); 15 | extern long long cpucycles_amd64tscfreq_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "amd64tscfreq" 23 | #define cpucycles cpucycles_amd64tscfreq 24 | #define cpucycles_persecond cpucycles_amd64tscfreq_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/celllinux.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles celllinux.h version 20081201 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_celllinux_h 8 | #define CPUCYCLES_celllinux_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_celllinux(void); 15 | extern long long cpucycles_celllinux_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "celllinux" 23 | #define cpucycles cpucycles_celllinux 24 | #define cpucycles_persecond cpucycles_celllinux_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/cortex.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles cortex.h version 20100912 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_cortex_h 8 | #define CPUCYCLES_cortex_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_cortex(void); 15 | extern long long cpucycles_cortex_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "cortex" 23 | #define cpucycles cpucycles_cortex 24 | #define cpucycles_persecond cpucycles_cortex_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/dev4ns.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles dev4ns.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_dev4ns_h 8 | #define CPUCYCLES_dev4ns_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_dev4ns(void); 15 | extern long long cpucycles_dev4ns_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "dev4ns" 23 | #define cpucycles cpucycles_dev4ns 24 | #define cpucycles_persecond cpucycles_dev4ns_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/gettimeofday.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include "osfreq.c" 7 | 8 | static double cpufrequency = 0; 9 | 10 | static void init(void) 11 | { 12 | cpufrequency = osfreq(); 13 | } 14 | 15 | long long cpucycles_gettimeofday(void) 16 | { 17 | double result; 18 | struct timeval t; 19 | if (!cpufrequency) init(); 20 | gettimeofday(&t,(struct timezone *) 0); 21 | result = t.tv_usec; 22 | result *= 0.000001; 23 | result += (double) t.tv_sec; 24 | result *= cpufrequency; 25 | return result; 26 | } 27 | 28 | long long cpucycles_gettimeofday_persecond(void) 29 | { 30 | if (!cpufrequency) init(); 31 | return cpufrequency; 32 | } 33 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/gettimeofday.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles gettimeofday.h version 20060318 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_gettimeofday_h 8 | #define CPUCYCLES_gettimeofday_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_gettimeofday(void); 15 | extern long long cpucycles_gettimeofday_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "gettimeofday" 23 | #define cpucycles cpucycles_gettimeofday 24 | #define cpucycles_persecond cpucycles_gettimeofday_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/hppapstat.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | long long cpucycles_hppapstat(void) 9 | { 10 | register long long result; 11 | _MFCTL(16,result); 12 | return result; 13 | } 14 | 15 | long long cpucycles_hppapstat_persecond(void) 16 | { 17 | struct pst_processor pst; 18 | union pstun pu; 19 | double result; 20 | 21 | pu.pst_processor = &pst; 22 | if (pstat(PSTAT_PROCESSOR,pu,sizeof(pst),1,0) < 0) return 0; 23 | result = pst.psp_iticksperclktick; 24 | result *= (double) sysconf(_SC_CLK_TCK); 25 | return result; 26 | } 27 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/hppapstat.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles hppapstat.h version 20060319 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_hppapstat_h 8 | #define CPUCYCLES_hppapstat_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_hppapstat(void); 15 | extern long long cpucycles_hppapstat_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "hppapstat" 23 | #define cpucycles cpucycles_hppapstat 24 | #define cpucycles_persecond cpucycles_hppapstat_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/ia64cpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osfreq.c" 4 | 5 | long long cpucycles_ia64cpuinfo(void) 6 | { 7 | long long result; 8 | asm volatile("mov %0=ar.itc" : "=r"(result)); 9 | return result; 10 | } 11 | 12 | long long cpucycles_ia64cpuinfo_persecond(void) 13 | { 14 | return osfreq(); 15 | } 16 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/ia64cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles ia64cpuinfo.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_ia64cpuinfo_h 8 | #define CPUCYCLES_ia64cpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_ia64cpuinfo(void); 15 | extern long long cpucycles_ia64cpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "ia64cpuinfo" 23 | #define cpucycles cpucycles_ia64cpuinfo 24 | #define cpucycles_persecond cpucycles_ia64cpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/mips.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles mips.h version 20100802 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_mips_h 8 | #define CPUCYCLES_mips_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_mips(void); 15 | extern long long cpucycles_mips_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "mips" 23 | #define cpucycles cpucycles_mips 24 | #define cpucycles_persecond cpucycles_mips_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/monotonic.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static double cpufrequency = 0; 10 | 11 | static void init(void) 12 | { 13 | long result = 0; size_t resultlen = sizeof(long); 14 | sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0); 15 | cpufrequency = result; 16 | } 17 | 18 | long long cpucycles_monotonic(void) 19 | { 20 | double result; 21 | struct timespec t; 22 | if (!cpufrequency) init(); 23 | clock_gettime(CLOCK_MONOTONIC,&t); 24 | result = t.tv_nsec; 25 | result *= 0.000000001; 26 | result += (double) t.tv_sec; 27 | result *= cpufrequency; 28 | return result; 29 | } 30 | 31 | long long cpucycles_monotonic_persecond(void) 32 | { 33 | if (!cpufrequency) init(); 34 | return cpufrequency; 35 | } 36 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/monotonic.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles monotonic.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_monotonic_h 8 | #define CPUCYCLES_monotonic_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_monotonic(void); 15 | extern long long cpucycles_monotonic_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "monotonic" 23 | #define cpucycles cpucycles_monotonic 24 | #define cpucycles_persecond cpucycles_monotonic_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/monotoniccpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "osfreq.c" 9 | 10 | static double cpufrequency = 0; 11 | 12 | static void init(void) 13 | { 14 | cpufrequency = osfreq(); 15 | } 16 | 17 | long long cpucycles_monotoniccpuinfo(void) 18 | { 19 | double result; 20 | struct timespec t; 21 | if (!cpufrequency) init(); 22 | clock_gettime(CLOCK_MONOTONIC,&t); 23 | result = t.tv_nsec; 24 | result *= 0.000000001; 25 | result += (double) t.tv_sec; 26 | result *= cpufrequency; 27 | return result; 28 | } 29 | 30 | long long cpucycles_monotoniccpuinfo_persecond(void) 31 | { 32 | if (!cpufrequency) init(); 33 | return cpufrequency; 34 | } 35 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/monotoniccpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles monotoniccpuinfo.h version 20100804 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_monotoniccpuinfo_h 8 | #define CPUCYCLES_monotoniccpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_monotoniccpuinfo(void); 15 | extern long long cpucycles_monotoniccpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "monotoniccpuinfo" 23 | #define cpucycles cpucycles_monotoniccpuinfo 24 | #define cpucycles_persecond cpucycles_monotoniccpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/powerpccpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles powerpccpuinfo.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_powerpccpuinfo_h 8 | #define CPUCYCLES_powerpccpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_powerpccpuinfo(void); 15 | extern long long cpucycles_powerpccpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "powerpccpuinfo" 23 | #define cpucycles cpucycles_powerpccpuinfo 24 | #define cpucycles_persecond cpucycles_powerpccpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/powerpcmacos.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles powerpcmacos.h version 20060319 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_powerpcmacos_h 8 | #define CPUCYCLES_powerpcmacos_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_powerpcmacos(void); 15 | extern long long cpucycles_powerpcmacos_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "powerpcmacos" 23 | #define cpucycles cpucycles_powerpcmacos 24 | #define cpucycles_persecond cpucycles_powerpcmacos_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sgi.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | static double cpufrequency = 0; 10 | 11 | static void init(void) 12 | { 13 | FILE *f; 14 | 15 | f = popen("hinv -c processor | awk '{if ($3==\"MHZ\") print $2*1000000}'","r"); 16 | if (!f) return; 17 | if (fscanf(f,"%lf",&cpufrequency) < 1) cpufrequency = 0; 18 | pclose(f); 19 | if (!cpufrequency) return; 20 | } 21 | 22 | long long cpucycles_sgi(void) 23 | { 24 | double result; 25 | struct timespec t; 26 | if (!cpufrequency) init(); 27 | clock_gettime(CLOCK_SGI_CYCLE,&t); 28 | result = t.tv_nsec; 29 | result *= 0.000000001; 30 | result += (double) t.tv_sec; 31 | result *= cpufrequency; 32 | return result; 33 | } 34 | 35 | long long cpucycles_sgi_persecond(void) 36 | { 37 | if (!cpufrequency) init(); 38 | return cpufrequency; 39 | } 40 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sgi.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles sgi.h version 20070916 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_sgi_h 8 | #define CPUCYCLES_sgi_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_sgi(void); 15 | extern long long cpucycles_sgi_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "sgi" 23 | #define cpucycles cpucycles_sgi 24 | #define cpucycles_persecond cpucycles_sgi_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sparc32cpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osfreq.c" 4 | 5 | long long cpucycles_sparc32cpuinfo(void) 6 | { 7 | long long result; 8 | asm volatile(".word 2202075136; .word 2570088480; srl %%g1,0,%L0; mov %%o4,%H0" 9 | : "=r" (result) : : "g1","o4"); 10 | return result; 11 | } 12 | 13 | long long cpucycles_sparc32cpuinfo_persecond(void) 14 | { 15 | return osfreq(); 16 | } 17 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sparc32cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles sparc32cpuinfo.h version 20100804 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_sparc32cpuinfo_h 8 | #define CPUCYCLES_sparc32cpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_sparc32cpuinfo(void); 15 | extern long long cpucycles_sparc32cpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "sparc32cpuinfo" 23 | #define cpucycles cpucycles_sparc32cpuinfo 24 | #define cpucycles_persecond cpucycles_sparc32cpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sparccpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osfreq.c" 4 | 5 | long long cpucycles_sparccpuinfo(void) 6 | { 7 | long long result; 8 | asm volatile("rd %%tick,%0" : "=r" (result)); 9 | return result; 10 | } 11 | 12 | long long cpucycles_sparccpuinfo_persecond(void) 13 | { 14 | return osfreq(); 15 | } 16 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/sparccpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles sparccpuinfo.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_sparccpuinfo_h 8 | #define CPUCYCLES_sparccpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_sparccpuinfo(void); 15 | extern long long cpucycles_sparccpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "sparccpuinfo" 23 | #define cpucycles cpucycles_sparccpuinfo 24 | #define cpucycles_persecond cpucycles_sparccpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/test.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include "cpucycles-impl.h" 6 | 7 | static long long tod(void) 8 | { 9 | struct timeval t; 10 | gettimeofday(&t,(struct timezone *) 0); 11 | return t.tv_sec * (long long) 1000000 + t.tv_usec; 12 | } 13 | 14 | long long todstart; 15 | long long todend; 16 | long long cpustart; 17 | long long cpuend; 18 | 19 | long long cyclespersecond; 20 | long long cyclespertod; 21 | 22 | long long t[1001]; 23 | 24 | int main() 25 | { 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86cpuinfo.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "osfreq.c" 4 | 5 | long long cpucycles_x86cpuinfo(void) 6 | { 7 | long long result; 8 | asm volatile(".byte 15;.byte 49" : "=A" (result)); 9 | return result; 10 | } 11 | 12 | long long cpucycles_x86cpuinfo_persecond(void) 13 | { 14 | return osfreq(); 15 | } 16 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86cpuinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles x86cpuinfo.h version 20100803 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_x86cpuinfo_h 8 | #define CPUCYCLES_x86cpuinfo_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_x86cpuinfo(void); 15 | extern long long cpucycles_x86cpuinfo_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "x86cpuinfo" 23 | #define cpucycles cpucycles_x86cpuinfo 24 | #define cpucycles_persecond cpucycles_x86cpuinfo_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86cpuspeed.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | long long cpucycles_x86cpuspeed(void) 7 | { 8 | long long result; 9 | asm volatile(".byte 15;.byte 49" : "=A" (result)); 10 | return result; 11 | } 12 | 13 | long long cpucycles_x86cpuspeed_persecond(void) 14 | { 15 | int oid[2]; 16 | int val; 17 | size_t size; 18 | oid[0] = CTL_HW; 19 | oid[1] = HW_CPUSPEED; 20 | size = sizeof val; 21 | if (sysctl(oid,2,&val,&size,0,0) == -1) return 0; 22 | if (size != sizeof val) return 0; 23 | return val * 1000000LL; 24 | } 25 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86cpuspeed.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles x86cpuspeed.h version 20090716 3 | Matthew Dempsky 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_x86cpuspeed_h 8 | #define CPUCYCLES_x86cpuspeed_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_x86cpuspeed(void); 15 | extern long long cpucycles_x86cpuspeed_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "x86cpuspeed" 23 | #define cpucycles cpucycles_x86cpuspeed 24 | #define cpucycles_persecond cpucycles_x86cpuspeed_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86estimate.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles x86estimate.h version 20070121 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_x86estimate_h 8 | #define CPUCYCLES_x86estimate_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_x86estimate(void); 15 | extern long long cpucycles_x86estimate_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "x86estimate" 23 | #define cpucycles cpucycles_x86estimate 24 | #define cpucycles_persecond cpucycles_x86estimate_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86tscfreq.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | long long cpucycles_x86tscfreq(void) 6 | { 7 | long long result; 8 | asm volatile(".byte 15;.byte 49" : "=A" (result)); 9 | return result; 10 | } 11 | 12 | long long cpucycles_x86tscfreq_persecond(void) 13 | { 14 | long result = 0; 15 | size_t resultlen = sizeof(long); 16 | sysctlbyname("machdep.tsc_freq",&result,&resultlen,0,0); 17 | return result; 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/cpucycles/x86tscfreq.h: -------------------------------------------------------------------------------- 1 | /* 2 | cpucycles x86tscfreq.h version 20060318 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef CPUCYCLES_x86tscfreq_h 8 | #define CPUCYCLES_x86tscfreq_h 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern long long cpucycles_x86tscfreq(void); 15 | extern long long cpucycles_x86tscfreq_persecond(void); 16 | 17 | #ifdef __cplusplus 18 | } 19 | #endif 20 | 21 | #ifndef cpucycles_implementation 22 | #define cpucycles_implementation "x86tscfreq" 23 | #define cpucycles cpucycles_x86tscfreq 24 | #define cpucycles_persecond cpucycles_x86tscfreq_persecond 25 | #endif 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /src/libnacl/cpuid/cbytes.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() 4 | { 5 | char ch; 6 | int loop = 0; 7 | while (scanf("%c",&ch) == 1) { 8 | printf("0x%02x,",255 & (int) ch); 9 | if (++loop == 16) { 10 | loop = 0; 11 | printf("\n"); 12 | } 13 | } 14 | printf("0x00\n"); 15 | return 0; 16 | } 17 | -------------------------------------------------------------------------------- /src/libnacl/cpuid/cpuid.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void nope() 7 | { 8 | exit(1); 9 | } 10 | 11 | int main() 12 | { 13 | unsigned long x[4]; 14 | unsigned long y[4]; 15 | int i; 16 | int j; 17 | char c; 18 | 19 | signal(SIGILL,nope); 20 | 21 | x[0] = 0; 22 | x[1] = 0; 23 | x[2] = 0; 24 | x[3] = 0; 25 | 26 | asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); 27 | if (!x[0]) return 0; 28 | asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); 29 | 30 | for (i = 1;i < 4;++i) 31 | for (j = 0;j < 4;++j) { 32 | c = x[i] >> (8 * j); 33 | if (c < 32) c = 32; 34 | if (c > 126) c = 126; 35 | putchar(c); 36 | } 37 | 38 | printf("-%08x-%08x\n",y[0],y[3]); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/libnacl/cpuid/do: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | mkdir include 4 | 5 | ( 6 | echo x86 7 | echo unknown 8 | ) | ( 9 | while read n 10 | do 11 | okabi | ( 12 | while read abi 13 | do 14 | okc-$abi | ( 15 | while read c 16 | do 17 | echo "=== `date` === Trying $n.c with $c..." >&2 18 | rm -f cpuid.c 19 | cp $n.c cpuid.c || continue 20 | $c -o cpuid cpuid.c || continue 21 | $c -o cbytes cbytes.c || continue 22 | ./cpuid > cpuid.out || continue 23 | echo 'static const char cpuid[] = {' > cpuid.h || continue 24 | ./cbytes < cpuid.out >> cpuid.h || continue 25 | echo '} ;' >> cpuid.h || continue 26 | cp cpuid.h include/cpuid.h || continue 27 | cat cpuid.out 28 | exit 0 29 | done 30 | exit 111 31 | ) && exit 0 32 | done 33 | exit 111 34 | ) && exit 0 35 | done 36 | exit 111 37 | ) 38 | -------------------------------------------------------------------------------- /src/libnacl/cpuid/unknown.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | main() 4 | { 5 | printf("unknown CPU ID\n"); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /src/libnacl/cpuid/x86.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | void nope() 7 | { 8 | exit(1); 9 | } 10 | 11 | int main() 12 | { 13 | unsigned long x[4]; 14 | unsigned long y[4]; 15 | int i; 16 | int j; 17 | char c; 18 | 19 | signal(SIGILL,nope); 20 | 21 | x[0] = 0; 22 | x[1] = 0; 23 | x[2] = 0; 24 | x[3] = 0; 25 | 26 | asm volatile(".byte 15;.byte 162" : "=a"(x[0]),"=b"(x[1]),"=c"(x[3]),"=d"(x[2]) : "0"(0) ); 27 | if (!x[0]) return 0; 28 | asm volatile(".byte 15;.byte 162" : "=a"(y[0]),"=b"(y[1]),"=c"(y[2]),"=d"(y[3]) : "0"(1) ); 29 | 30 | for (i = 1;i < 4;++i) 31 | for (j = 0;j < 4;++j) { 32 | c = x[i] >> (8 * j); 33 | if (c < 32) c = 32; 34 | if (c > 126) c = 126; 35 | putchar(c); 36 | } 37 | 38 | printf("-%08x-%08x\n",(unsigned int) y[0],(unsigned int) y[3]); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha256/checksum: -------------------------------------------------------------------------------- 1 | 3bd7abd4f4dce04396f2ac7cb1cff70607f692411c49a1563b037d31e1662632 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha256/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha256/ref/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_32.h" 2 | #include "crypto_auth.h" 3 | 4 | int crypto_auth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[32]; 7 | crypto_auth(correct,in,inlen,k); 8 | return crypto_verify_32(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha256/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_auth/hmacsha256/used -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha512256/checksum: -------------------------------------------------------------------------------- 1 | 2f5e8a6a0cac012d8d001351d7d583e69f91390df46305c3608e0c2893491886 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha512256/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha512256/ref/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_32.h" 2 | #include "crypto_auth.h" 3 | 4 | int crypto_auth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[32]; 7 | crypto_auth(correct,in,inlen,k); 8 | return crypto_verify_32(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha512256/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_auth/hmacsha512256/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/hmacsha512256/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_auth/hmacsha512256/used -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/wrapper-auth.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_auth.h" 4 | 5 | string crypto_auth(const string &m,const string &k) 6 | { 7 | if (k.size() != crypto_auth_KEYBYTES) throw "incorrect key length"; 8 | unsigned char a[crypto_auth_BYTES]; 9 | crypto_auth(a,(const unsigned char *) m.c_str(),m.size(),(const unsigned char *) k.c_str()); 10 | return string((char *) a,crypto_auth_BYTES); 11 | } 12 | -------------------------------------------------------------------------------- /src/libnacl/crypto_auth/wrapper-verify.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_auth.h" 4 | 5 | void crypto_auth_verify(const string &a,const string &m,const string &k) 6 | { 7 | if (k.size() != crypto_auth_KEYBYTES) throw "incorrect key length"; 8 | if (a.size() != crypto_auth_BYTES) throw "incorrect authenticator length"; 9 | if (crypto_auth_verify( 10 | (const unsigned char *) a.c_str(), 11 | (const unsigned char *) m.c_str(),m.size(), 12 | (const unsigned char *) k.c_str()) == 0) return; 13 | throw "invalid authenticator"; 14 | } 15 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/checksum: -------------------------------------------------------------------------------- 1 | 5fac7400caabc14a99c5c0bc13fb1df5e468e870382a3a1c 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/ref/after.c: -------------------------------------------------------------------------------- 1 | #include "crypto_secretbox_xsalsa20poly1305.h" 2 | #include "crypto_box.h" 3 | 4 | int crypto_box_afternm( 5 | unsigned char *c, 6 | const unsigned char *m,unsigned long long mlen, 7 | const unsigned char *n, 8 | const unsigned char *k 9 | ) 10 | { 11 | return crypto_secretbox_xsalsa20poly1305(c,m,mlen,n,k); 12 | } 13 | 14 | int crypto_box_open_afternm( 15 | unsigned char *m, 16 | const unsigned char *c,unsigned long long clen, 17 | const unsigned char *n, 18 | const unsigned char *k 19 | ) 20 | { 21 | return crypto_secretbox_xsalsa20poly1305_open(m,c,clen,n,k); 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_PUBLICKEYBYTES 32 2 | #define CRYPTO_SECRETKEYBYTES 32 3 | #define CRYPTO_BEFORENMBYTES 32 4 | #define CRYPTO_NONCEBYTES 24 5 | #define CRYPTO_ZEROBYTES 32 6 | #define CRYPTO_BOXZEROBYTES 16 7 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/ref/before.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core_hsalsa20.h" 2 | #include "crypto_scalarmult_curve25519.h" 3 | #include "crypto_box.h" 4 | 5 | static const unsigned char sigma[16] = "expand 32-byte k"; 6 | static const unsigned char n[16] = {0}; 7 | 8 | int crypto_box_beforenm( 9 | unsigned char *k, 10 | const unsigned char *pk, 11 | const unsigned char *sk 12 | ) 13 | { 14 | unsigned char s[32]; 15 | crypto_scalarmult_curve25519(s,sk,pk); 16 | return crypto_core_hsalsa20(k,n,s,sigma); 17 | } 18 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/ref/box.c: -------------------------------------------------------------------------------- 1 | #include "crypto_box.h" 2 | 3 | int crypto_box( 4 | unsigned char *c, 5 | const unsigned char *m,unsigned long long mlen, 6 | const unsigned char *n, 7 | const unsigned char *pk, 8 | const unsigned char *sk 9 | ) 10 | { 11 | unsigned char k[crypto_box_BEFORENMBYTES]; 12 | crypto_box_beforenm(k,pk,sk); 13 | return crypto_box_afternm(c,m,mlen,n,k); 14 | } 15 | 16 | int crypto_box_open( 17 | unsigned char *m, 18 | const unsigned char *c,unsigned long long clen, 19 | const unsigned char *n, 20 | const unsigned char *pk, 21 | const unsigned char *sk 22 | ) 23 | { 24 | unsigned char k[crypto_box_BEFORENMBYTES]; 25 | crypto_box_beforenm(k,pk,sk); 26 | return crypto_box_open_afternm(m,c,clen,n,k); 27 | } 28 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/ref/keypair.c: -------------------------------------------------------------------------------- 1 | #include "crypto_scalarmult_curve25519.h" 2 | #include "crypto_box.h" 3 | #include "randombytes.h" 4 | 5 | int crypto_box_keypair( 6 | unsigned char *pk, 7 | unsigned char *sk 8 | ) 9 | { 10 | randombytes(sk,32); 11 | return crypto_scalarmult_curve25519_base(pk,sk); 12 | } 13 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_box/curve25519xsalsa20poly1305/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_box/curve25519xsalsa20poly1305/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_box/curve25519xsalsa20poly1305/used -------------------------------------------------------------------------------- /src/libnacl/crypto_box/wrapper-box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_box.h" 4 | 5 | string crypto_box(const string &m,const string &n,const string &pk,const string &sk) 6 | { 7 | if (pk.size() != crypto_box_PUBLICKEYBYTES) throw "incorrect public-key length"; 8 | if (sk.size() != crypto_box_SECRETKEYBYTES) throw "incorrect secret-key length"; 9 | if (n.size() != crypto_box_NONCEBYTES) throw "incorrect nonce length"; 10 | size_t mlen = m.size() + crypto_box_ZEROBYTES; 11 | unsigned char mpad[mlen]; 12 | for (int i = 0;i < crypto_box_ZEROBYTES;++i) mpad[i] = 0; 13 | for (int i = crypto_box_ZEROBYTES;i < mlen;++i) mpad[i] = m[i - crypto_box_ZEROBYTES]; 14 | unsigned char cpad[mlen]; 15 | crypto_box(cpad,mpad,mlen, 16 | (const unsigned char *) n.c_str(), 17 | (const unsigned char *) pk.c_str(), 18 | (const unsigned char *) sk.c_str() 19 | ); 20 | return string( 21 | (char *) cpad + crypto_box_BOXZEROBYTES, 22 | mlen - crypto_box_BOXZEROBYTES 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/libnacl/crypto_box/wrapper-keypair.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_box.h" 4 | 5 | string crypto_box_keypair(string *sk_string) 6 | { 7 | unsigned char pk[crypto_box_PUBLICKEYBYTES]; 8 | unsigned char sk[crypto_box_SECRETKEYBYTES]; 9 | crypto_box_keypair(pk,sk); 10 | *sk_string = string((char *) sk,sizeof sk); 11 | return string((char *) pk,sizeof pk); 12 | } 13 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/checksum: -------------------------------------------------------------------------------- 1 | 28ebe700b5878570702a68740aa131e6fa907e58a3f6915cd183c6db3f7afd7a 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_OUTPUTBYTES 32 2 | #define CRYPTO_INPUTBYTES 16 3 | #define CRYPTO_KEYBYTES 32 4 | #define CRYPTO_CONSTBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/ref2/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_OUTPUTBYTES 32 2 | #define CRYPTO_INPUTBYTES 16 3 | #define CRYPTO_KEYBYTES 32 4 | #define CRYPTO_CONSTBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/ref2/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/hsalsa20/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_core/hsalsa20/used -------------------------------------------------------------------------------- /src/libnacl/crypto_core/measure.c: -------------------------------------------------------------------------------- 1 | #include "crypto_core.h" 2 | 3 | const char *primitiveimplementation = crypto_core_IMPLEMENTATION; 4 | const char *implementationversion = crypto_core_VERSION; 5 | const char *sizenames[] = { "outputbytes", "inputbytes", "keybytes", "constbytes", 0 }; 6 | const long long sizes[] = { crypto_core_OUTPUTBYTES, crypto_core_INPUTBYTES, crypto_core_KEYBYTES, crypto_core_CONSTBYTES }; 7 | 8 | void preallocate(void) 9 | { 10 | } 11 | 12 | void allocate(void) 13 | { 14 | } 15 | 16 | void measure(void) 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa20/checksum: -------------------------------------------------------------------------------- 1 | 9d1ee8d84b974e648507ffd93829376c5b4420751710e44f6593abd8769378011d85ecda51ceb8f43661d3c65ef5b57c4f5bf8df76c8202784c8df8def61e6a6 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa20/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_OUTPUTBYTES 64 2 | #define CRYPTO_INPUTBYTES 16 3 | #define CRYPTO_KEYBYTES 32 4 | #define CRYPTO_CONSTBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa20/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa20/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_core/salsa20/used -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa2012/checksum: -------------------------------------------------------------------------------- 1 | f36d643f798efc0fca888d3ac4bdcc54c98a968c2da16bd5b8bfe9fe9025a6ca3a207e9362dc7cf17ddfc7477ee754d3f521b1df91640093754f7275b1a54293 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa2012/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_OUTPUTBYTES 64 2 | #define CRYPTO_INPUTBYTES 16 3 | #define CRYPTO_KEYBYTES 32 4 | #define CRYPTO_CONSTBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa2012/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa2012/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_core/salsa2012/used -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa208/checksum: -------------------------------------------------------------------------------- 1 | 1e13ea9e74cb36989f7cbf4abc80b29154e1a8b150bd5244951318abea002a93ae9fe2abbcf7217526ac2a85b66c256ba9374b1257eda0c01816da328edfa11a 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa208/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_OUTPUTBYTES 64 2 | #define CRYPTO_INPUTBYTES 16 3 | #define CRYPTO_KEYBYTES 32 4 | #define CRYPTO_CONSTBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa208/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_core/salsa208/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_core/salsa208/used -------------------------------------------------------------------------------- /src/libnacl/crypto_core/wrapper-empty.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_core/wrapper-empty.cpp -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha256/checksum: -------------------------------------------------------------------------------- 1 | 86df8bd202b2a2b5fdc04a7f50a591e43a345849c12fef08d487109648a08e05 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha256/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha256/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein (wrapper around crypto_hashblocks/sha256) 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha256/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hash/sha256/used -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha512/checksum: -------------------------------------------------------------------------------- 1 | 9a2a989e136a02c3362c98e6e1e0b52fab980a1dafbebe4dd5e44d15d061742e35fb686befd4e33c608d251c96e26c020f90d92bb7ec8a657f79bb8e0b00a473 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha512/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 64 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha512/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein (wrapper around crypto_hashblocks/sha512) 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha512/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hash/sha512/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/sha512/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hash/sha512/used -------------------------------------------------------------------------------- /src/libnacl/crypto_hash/wrapper-hash.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_hash.h" 4 | 5 | string crypto_hash(const string &m) 6 | { 7 | unsigned char h[crypto_hash_BYTES]; 8 | crypto_hash(h,(const unsigned char *) m.c_str(),m.size()); 9 | return string((char *) h,sizeof h); 10 | } 11 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/measure.c: -------------------------------------------------------------------------------- 1 | #include "crypto_hashblocks.h" 2 | 3 | const char *primitiveimplementation = crypto_hashblocks_IMPLEMENTATION; 4 | const char *implementationversion = crypto_hashblocks_VERSION; 5 | const char *sizenames[] = { "statebytes", 0 }; 6 | const long long sizes[] = { crypto_hashblocks_STATEBYTES }; 7 | 8 | void preallocate(void) 9 | { 10 | } 11 | 12 | void allocate(void) 13 | { 14 | } 15 | 16 | void measure(void) 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/checksum: -------------------------------------------------------------------------------- 1 | 69a9dc2464f9593161e462d3dbb634b84f1d68d67d26df29aaa805f9dcd8f656 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/inplace/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_STATEBYTES 32 2 | #define CRYPTO_BLOCKBYTES 64 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/inplace/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_STATEBYTES 32 2 | #define CRYPTO_BLOCKBYTES 64 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha256/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hashblocks/sha256/used -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/checksum: -------------------------------------------------------------------------------- 1 | f005c91634ae549f0dd4529ddbaf07038cb75a59b818cd1d4eb4e2b4019ab6733556131f320c4a145c735a22594581d454cccb15c18bf198ffcb2da29fe39456 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/inplace/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_STATEBYTES 64 2 | #define CRYPTO_BLOCKBYTES 128 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/inplace/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_STATEBYTES 64 2 | #define CRYPTO_BLOCKBYTES 128 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hashblocks/sha512/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/sha512/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hashblocks/sha512/used -------------------------------------------------------------------------------- /src/libnacl/crypto_hashblocks/wrapper-empty.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_hashblocks/wrapper-empty.cpp -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/53/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 16 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/53/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_16.h" 2 | #include "crypto_onetimeauth.h" 3 | 4 | int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[16]; 7 | crypto_onetimeauth(correct,in,inlen,k); 8 | return crypto_verify_16(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/amd64/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 16 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/amd64/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_16.h" 2 | #include "crypto_onetimeauth.h" 3 | 4 | int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[16]; 7 | crypto_onetimeauth(correct,in,inlen,k); 8 | return crypto_verify_16(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/checksum: -------------------------------------------------------------------------------- 1 | e836d5ca58cf673fca2b4910f23f3990 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 16 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/ref/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_16.h" 2 | #include "crypto_onetimeauth.h" 3 | 4 | int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[16]; 7 | crypto_onetimeauth(correct,in,inlen,k); 8 | return crypto_verify_16(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_onetimeauth/poly1305/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_onetimeauth/poly1305/used -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/x86/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 16 2 | #define CRYPTO_KEYBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/poly1305/x86/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify_16.h" 2 | #include "crypto_onetimeauth.h" 3 | 4 | int crypto_onetimeauth_verify(const unsigned char *h,const unsigned char *in,unsigned long long inlen,const unsigned char *k) 5 | { 6 | unsigned char correct[16]; 7 | crypto_onetimeauth(correct,in,inlen,k); 8 | return crypto_verify_16(h,correct); 9 | } 10 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/wrapper-auth.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_onetimeauth.h" 4 | 5 | string crypto_onetimeauth(const string &m,const string &k) 6 | { 7 | if (k.size() != crypto_onetimeauth_KEYBYTES) throw "incorrect key length"; 8 | unsigned char a[crypto_onetimeauth_BYTES]; 9 | crypto_onetimeauth(a,(const unsigned char *) m.c_str(),m.size(),(const unsigned char *) k.c_str()); 10 | return string((char *) a,crypto_onetimeauth_BYTES); 11 | } 12 | -------------------------------------------------------------------------------- /src/libnacl/crypto_onetimeauth/wrapper-verify.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_onetimeauth.h" 4 | 5 | void crypto_onetimeauth_verify(const string &a,const string &m,const string &k) 6 | { 7 | if (k.size() != crypto_onetimeauth_KEYBYTES) throw "incorrect key length"; 8 | if (a.size() != crypto_onetimeauth_BYTES) throw "incorrect authenticator length"; 9 | if (crypto_onetimeauth_verify( 10 | (const unsigned char *) a.c_str(), 11 | (const unsigned char *) m.c_str(),m.size(), 12 | (const unsigned char *) k.c_str()) == 0) return; 13 | throw "invalid authenticator"; 14 | } 15 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/checksum: -------------------------------------------------------------------------------- 1 | dacdae4a0f12353dfc66757f2fd1fff538fe6616115dace9afb8016a55be2a52 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/donna_c64/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | #define CRYPTO_SCALARBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/donna_c64/base.c: -------------------------------------------------------------------------------- 1 | #include "crypto_scalarmult.h" 2 | 3 | static const unsigned char basepoint[32] = {9}; 4 | 5 | int crypto_scalarmult_base(unsigned char *q,const unsigned char *n) 6 | { 7 | return crypto_scalarmult(q, n, basepoint); 8 | } 9 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/donna_c64/implementors: -------------------------------------------------------------------------------- 1 | Adam Langley (Google) 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | #define CRYPTO_SCALARBYTES 32 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/ref/base.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20081011 3 | Matthew Dempsky 4 | Public domain. 5 | Derived from public domain code by D. J. Bernstein. 6 | */ 7 | 8 | #include "crypto_scalarmult.h" 9 | 10 | const unsigned char base[32] = {9}; 11 | 12 | int crypto_scalarmult_base(unsigned char *q, 13 | const unsigned char *n) 14 | { 15 | return crypto_scalarmult(q,n,base); 16 | } 17 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/ref/implementors: -------------------------------------------------------------------------------- 1 | Matthew Dempsky (Mochi Media) 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/curve25519/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_scalarmult/curve25519/used -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/wrapper-base.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_scalarmult.h" 4 | 5 | string crypto_scalarmult_base(const string &n) 6 | { 7 | unsigned char q[crypto_scalarmult_BYTES]; 8 | if (n.size() != crypto_scalarmult_SCALARBYTES) throw "incorrect scalar length"; 9 | crypto_scalarmult_base(q,(const unsigned char *) n.c_str()); 10 | return string((char *) q,sizeof q); 11 | } 12 | -------------------------------------------------------------------------------- /src/libnacl/crypto_scalarmult/wrapper-mult.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_scalarmult.h" 4 | 5 | string crypto_scalarmult(const string &n,const string &p) 6 | { 7 | unsigned char q[crypto_scalarmult_BYTES]; 8 | if (n.size() != crypto_scalarmult_SCALARBYTES) throw "incorrect scalar length"; 9 | if (p.size() != crypto_scalarmult_BYTES) throw "incorrect element length"; 10 | crypto_scalarmult(q,(const unsigned char *) n.c_str(),(const unsigned char *) p.c_str()); 11 | return string((char *) q,sizeof q); 12 | } 13 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/wrapper-box.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_secretbox.h" 4 | 5 | string crypto_secretbox(const string &m,const string &n,const string &k) 6 | { 7 | if (k.size() != crypto_secretbox_KEYBYTES) throw "incorrect key length"; 8 | if (n.size() != crypto_secretbox_NONCEBYTES) throw "incorrect nonce length"; 9 | size_t mlen = m.size() + crypto_secretbox_ZEROBYTES; 10 | unsigned char mpad[mlen]; 11 | for (int i = 0;i < crypto_secretbox_ZEROBYTES;++i) mpad[i] = 0; 12 | for (int i = crypto_secretbox_ZEROBYTES;i < mlen;++i) mpad[i] = m[i - crypto_secretbox_ZEROBYTES]; 13 | unsigned char cpad[mlen]; 14 | crypto_secretbox(cpad,mpad,mlen,(const unsigned char *) n.c_str(),(const unsigned char *) k.c_str()); 15 | return string( 16 | (char *) cpad + crypto_secretbox_BOXZEROBYTES, 17 | mlen - crypto_secretbox_BOXZEROBYTES 18 | ); 19 | } 20 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/wrapper-open.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_secretbox.h" 4 | 5 | string crypto_secretbox_open(const string &c,const string &n,const string &k) 6 | { 7 | if (k.size() != crypto_secretbox_KEYBYTES) throw "incorrect key length"; 8 | if (n.size() != crypto_secretbox_NONCEBYTES) throw "incorrect nonce length"; 9 | size_t clen = c.size() + crypto_secretbox_BOXZEROBYTES; 10 | unsigned char cpad[clen]; 11 | for (int i = 0;i < crypto_secretbox_BOXZEROBYTES;++i) cpad[i] = 0; 12 | for (int i = crypto_secretbox_BOXZEROBYTES;i < clen;++i) cpad[i] = c[i - crypto_secretbox_BOXZEROBYTES]; 13 | unsigned char mpad[clen]; 14 | if (crypto_secretbox_open(mpad,cpad,clen,(const unsigned char *) n.c_str(),(const unsigned char *) k.c_str()) != 0) 15 | throw "ciphertext fails verification"; 16 | if (clen < crypto_secretbox_ZEROBYTES) 17 | throw "ciphertext too short"; // should have been caught by _open 18 | return string( 19 | (char *) mpad + crypto_secretbox_ZEROBYTES, 20 | clen - crypto_secretbox_ZEROBYTES 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/xsalsa20poly1305/checksum: -------------------------------------------------------------------------------- 1 | df372f95dd87381b7c9ceb6f340ccaa03d19bed5d9e4ab004d99d847675a9658 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/xsalsa20poly1305/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 32 2 | #define CRYPTO_NONCEBYTES 24 3 | #define CRYPTO_ZEROBYTES 32 4 | #define CRYPTO_BOXZEROBYTES 16 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/xsalsa20poly1305/ref/box.c: -------------------------------------------------------------------------------- 1 | #include "crypto_onetimeauth_poly1305.h" 2 | #include "crypto_stream_xsalsa20.h" 3 | #include "crypto_secretbox.h" 4 | 5 | int crypto_secretbox( 6 | unsigned char *c, 7 | const unsigned char *m,unsigned long long mlen, 8 | const unsigned char *n, 9 | const unsigned char *k 10 | ) 11 | { 12 | int i; 13 | if (mlen < 32) return -1; 14 | crypto_stream_xsalsa20_xor(c,m,mlen,n,k); 15 | crypto_onetimeauth_poly1305(c + 16,c + 32,mlen - 32,c); 16 | for (i = 0;i < 16;++i) c[i] = 0; 17 | return 0; 18 | } 19 | 20 | int crypto_secretbox_open( 21 | unsigned char *m, 22 | const unsigned char *c,unsigned long long clen, 23 | const unsigned char *n, 24 | const unsigned char *k 25 | ) 26 | { 27 | int i; 28 | unsigned char subkey[32]; 29 | if (clen < 32) return -1; 30 | crypto_stream_xsalsa20(subkey,32,n,k); 31 | if (crypto_onetimeauth_poly1305_verify(c + 16,c + 32,clen - 32,subkey) != 0) return -1; 32 | crypto_stream_xsalsa20_xor(m,c,clen,n,k); 33 | for (i = 0;i < 32;++i) m[i] = 0; 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/xsalsa20poly1305/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_secretbox/xsalsa20poly1305/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_secretbox/xsalsa20poly1305/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_secretbox/xsalsa20poly1305/used -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/description: -------------------------------------------------------------------------------- 1 | EdDSA signatures using Curve25519 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/designers: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | Niels Duif 3 | Tanja Lange 4 | Peter Schwabe 5 | Bo-Yin Yang 6 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_SECRETKEYBYTES 64 2 | #define CRYPTO_PUBLICKEYBYTES 32 3 | #define CRYPTO_BYTES 64 4 | 5 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | Niels Duif 3 | Tanja Lange 4 | lead: Peter Schwabe 5 | Bo-Yin Yang 6 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_sign/ed25519/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/ed25519/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_sign/ed25519/used -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/edwards25519sha512batch/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_SECRETKEYBYTES 64 2 | #define CRYPTO_PUBLICKEYBYTES 32 3 | #define CRYPTO_BYTES 64 4 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/edwards25519sha512batch/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_sign/edwards25519sha512batch/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/edwards25519sha512batch/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_sign/edwards25519sha512batch/used -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/wrapper-keypair.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_sign.h" 4 | 5 | string crypto_sign_keypair(string *sk_string) 6 | { 7 | unsigned char pk[crypto_sign_PUBLICKEYBYTES]; 8 | unsigned char sk[crypto_sign_SECRETKEYBYTES]; 9 | crypto_sign_keypair(pk,sk); 10 | *sk_string = string((char *) sk,sizeof sk); 11 | return string((char *) pk,sizeof pk); 12 | } 13 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/wrapper-sign-open.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_sign.h" 4 | 5 | string crypto_sign_open(const string &sm_string, const string &pk_string) 6 | { 7 | if (pk_string.size() != crypto_sign_PUBLICKEYBYTES) throw "incorrect public-key length"; 8 | size_t smlen = sm_string.size(); 9 | unsigned char m[smlen]; 10 | unsigned long long mlen; 11 | for (int i = 0;i < smlen;++i) m[i] = sm_string[i]; 12 | if (crypto_sign_open( 13 | m, 14 | &mlen, 15 | m, 16 | smlen, 17 | (const unsigned char *) pk_string.c_str() 18 | ) != 0) 19 | throw "ciphertext fails verification"; 20 | return string( 21 | (char *) m, 22 | mlen 23 | ); 24 | } 25 | -------------------------------------------------------------------------------- /src/libnacl/crypto_sign/wrapper-sign.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_sign.h" 4 | 5 | string crypto_sign(const string &m_string, const string &sk_string) 6 | { 7 | if (sk_string.size() != crypto_sign_SECRETKEYBYTES) throw "incorrect secret-key length"; 8 | size_t mlen = m_string.size(); 9 | unsigned char sm[mlen+crypto_sign_BYTES]; 10 | unsigned long long smlen; 11 | crypto_sign( 12 | sm, 13 | &smlen, 14 | (const unsigned char *) m_string.data(), 15 | mlen, 16 | (const unsigned char *) sk_string.data() 17 | ); 18 | return string( 19 | (char *) sm, 20 | smlen 21 | ); 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/checksum: -------------------------------------------------------------------------------- 1 | 6e9966897837aae181e93261ae88fdf0 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/portable/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 16 2 | #define CRYPTO_NONCEBYTES 16 3 | #define CRYPTO_BEFORENMBYTES 1408 4 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/portable/consts.h: -------------------------------------------------------------------------------- 1 | #ifndef CONSTS_H 2 | #define CONSTS_H 3 | 4 | #include "int128.h" 5 | 6 | #define ROTB crypto_stream_aes128ctr_portable_ROTB 7 | #define M0 crypto_stream_aes128ctr_portable_M0 8 | #define EXPB0 crypto_stream_aes128ctr_portable_EXPB0 9 | #define SWAP32 crypto_stream_aes128ctr_portable_SWAP32 10 | #define M0SWAP crypto_stream_aes128ctr_portable_M0SWAP 11 | #define SR crypto_stream_aes128ctr_portable_SR 12 | #define SRM0 crypto_stream_aes128ctr_portable_SRM0 13 | #define BS0 crypto_stream_aes128ctr_portable_BS0 14 | #define BS1 crypto_stream_aes128ctr_portable_BS1 15 | #define BS2 crypto_stream_aes128ctr_portable_BS2 16 | 17 | extern const unsigned char ROTB[16]; 18 | extern const unsigned char M0[16]; 19 | extern const unsigned char EXPB0[16]; 20 | extern const unsigned char SWAP32[16]; 21 | extern const unsigned char M0SWAP[16]; 22 | extern const unsigned char SR[16]; 23 | extern const unsigned char SRM0[16]; 24 | extern const int128 BS0; 25 | extern const int128 BS1; 26 | extern const int128 BS2; 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/portable/stream.c: -------------------------------------------------------------------------------- 1 | #include "crypto_stream.h" 2 | 3 | int crypto_stream( 4 | unsigned char *out, 5 | unsigned long long outlen, 6 | const unsigned char *n, 7 | const unsigned char *k 8 | ) 9 | { 10 | unsigned char d[crypto_stream_BEFORENMBYTES]; 11 | crypto_stream_beforenm(d, k); 12 | crypto_stream_afternm(out, outlen, n, d); 13 | return 0; 14 | } 15 | 16 | int crypto_stream_xor( 17 | unsigned char *out, 18 | const unsigned char *in, 19 | unsigned long long inlen, 20 | const unsigned char *n, 21 | const unsigned char *k 22 | ) 23 | { 24 | unsigned char d[crypto_stream_BEFORENMBYTES]; 25 | crypto_stream_beforenm(d, k); 26 | crypto_stream_xor_afternm(out, in, inlen, n, d); 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/portable/types.h: -------------------------------------------------------------------------------- 1 | #ifndef TYPES_H 2 | #define TYPES_H 3 | 4 | #include "crypto_uint32.h" 5 | typedef crypto_uint32 uint32; 6 | 7 | #include "crypto_uint64.h" 8 | typedef crypto_uint64 uint64; 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/aes128ctr/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/aes128ctr/used -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/checksum: -------------------------------------------------------------------------------- 1 | 44a3966eabcd3a2b13faca2150e38f2b7e6bac187d626618f50a9f875158ae78 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 32 2 | #define CRYPTO_NONCEBYTES 8 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/ref/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa20.h" 8 | #include "crypto_stream.h" 9 | 10 | typedef unsigned int uint32; 11 | 12 | static const unsigned char sigma[16] = "expand 32-byte k"; 13 | 14 | int crypto_stream( 15 | unsigned char *c,unsigned long long clen, 16 | const unsigned char *n, 17 | const unsigned char *k 18 | ) 19 | { 20 | unsigned char in[16]; 21 | unsigned char block[64]; 22 | int i; 23 | unsigned int u; 24 | 25 | if (!clen) return 0; 26 | 27 | for (i = 0;i < 8;++i) in[i] = n[i]; 28 | for (i = 8;i < 16;++i) in[i] = 0; 29 | 30 | while (clen >= 64) { 31 | crypto_core_salsa20(c,in,k,sigma); 32 | 33 | u = 1; 34 | for (i = 8;i < 16;++i) { 35 | u += (unsigned int) in[i]; 36 | in[i] = u; 37 | u >>= 8; 38 | } 39 | 40 | clen -= 64; 41 | c += 64; 42 | } 43 | 44 | if (clen) { 45 | crypto_core_salsa20(block,in,k,sigma); 46 | for (i = 0;i < clen;++i) c[i] = block[i]; 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/ref/xor.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa20.h" 8 | #include "crypto_stream.h" 9 | 10 | typedef unsigned int uint32; 11 | 12 | static const unsigned char sigma[16] = "expand 32-byte k"; 13 | 14 | int crypto_stream_xor( 15 | unsigned char *c, 16 | const unsigned char *m,unsigned long long mlen, 17 | const unsigned char *n, 18 | const unsigned char *k 19 | ) 20 | { 21 | unsigned char in[16]; 22 | unsigned char block[64]; 23 | int i; 24 | unsigned int u; 25 | 26 | if (!mlen) return 0; 27 | 28 | for (i = 0;i < 8;++i) in[i] = n[i]; 29 | for (i = 8;i < 16;++i) in[i] = 0; 30 | 31 | while (mlen >= 64) { 32 | crypto_core_salsa20(block,in,k,sigma); 33 | for (i = 0;i < 64;++i) c[i] = m[i] ^ block[i]; 34 | 35 | u = 1; 36 | for (i = 8;i < 16;++i) { 37 | u += (unsigned int) in[i]; 38 | in[i] = u; 39 | u >>= 8; 40 | } 41 | 42 | mlen -= 64; 43 | c += 64; 44 | m += 64; 45 | } 46 | 47 | if (mlen) { 48 | crypto_core_salsa20(block,in,k,sigma); 49 | for (i = 0;i < mlen;++i) c[i] = m[i] ^ block[i]; 50 | } 51 | return 0; 52 | } 53 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa20/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/salsa20/used -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa2012/checksum: -------------------------------------------------------------------------------- 1 | ecc758f200061c3cc770b25797da73583548d4f90f69a967fbbe1a6d94d1705c 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa2012/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 32 2 | #define CRYPTO_NONCEBYTES 8 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa2012/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa2012/ref/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa2012.h" 8 | #include "crypto_stream.h" 9 | 10 | typedef unsigned int uint32; 11 | 12 | static const unsigned char sigma[16] = "expand 32-byte k"; 13 | 14 | int crypto_stream( 15 | unsigned char *c,unsigned long long clen, 16 | const unsigned char *n, 17 | const unsigned char *k 18 | ) 19 | { 20 | unsigned char in[16]; 21 | unsigned char block[64]; 22 | int i; 23 | unsigned int u; 24 | 25 | if (!clen) return 0; 26 | 27 | for (i = 0;i < 8;++i) in[i] = n[i]; 28 | for (i = 8;i < 16;++i) in[i] = 0; 29 | 30 | while (clen >= 64) { 31 | crypto_core_salsa2012(c,in,k,sigma); 32 | 33 | u = 1; 34 | for (i = 8;i < 16;++i) { 35 | u += (unsigned int) in[i]; 36 | in[i] = u; 37 | u >>= 8; 38 | } 39 | 40 | clen -= 64; 41 | c += 64; 42 | } 43 | 44 | if (clen) { 45 | crypto_core_salsa2012(block,in,k,sigma); 46 | for (i = 0;i < clen;++i) c[i] = block[i]; 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa2012/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/salsa2012/used -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa208/checksum: -------------------------------------------------------------------------------- 1 | 05f32b0647417aaa446b0b3127318133cf9af32b771869eab267000bf02710cd 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa208/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 32 2 | #define CRYPTO_NONCEBYTES 8 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa208/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa208/ref/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_salsa208.h" 8 | #include "crypto_stream.h" 9 | 10 | typedef unsigned int uint32; 11 | 12 | static const unsigned char sigma[16] = "expand 32-byte k"; 13 | 14 | int crypto_stream( 15 | unsigned char *c,unsigned long long clen, 16 | const unsigned char *n, 17 | const unsigned char *k 18 | ) 19 | { 20 | unsigned char in[16]; 21 | unsigned char block[64]; 22 | int i; 23 | unsigned int u; 24 | 25 | if (!clen) return 0; 26 | 27 | for (i = 0;i < 8;++i) in[i] = n[i]; 28 | for (i = 8;i < 16;++i) in[i] = 0; 29 | 30 | while (clen >= 64) { 31 | crypto_core_salsa208(c,in,k,sigma); 32 | 33 | u = 1; 34 | for (i = 8;i < 16;++i) { 35 | u += (unsigned int) in[i]; 36 | in[i] = u; 37 | u >>= 8; 38 | } 39 | 40 | clen -= 64; 41 | c += 64; 42 | } 43 | 44 | if (clen) { 45 | crypto_core_salsa208(block,in,k,sigma); 46 | for (i = 0;i < clen;++i) c[i] = block[i]; 47 | } 48 | return 0; 49 | } 50 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/salsa208/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/salsa208/used -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/wrapper-stream.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_stream.h" 4 | 5 | string crypto_stream(size_t clen,const string &n,const string &k) 6 | { 7 | if (n.size() != crypto_stream_NONCEBYTES) throw "incorrect nonce length"; 8 | if (k.size() != crypto_stream_KEYBYTES) throw "incorrect key length"; 9 | unsigned char c[clen]; 10 | crypto_stream(c,clen,(const unsigned char *) n.c_str(),(const unsigned char *) k.c_str()); 11 | return string((char *) c,clen); 12 | } 13 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/wrapper-xor.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include "crypto_stream.h" 4 | 5 | string crypto_stream_xor(const string &m,const string &n,const string &k) 6 | { 7 | if (n.size() != crypto_stream_NONCEBYTES) throw "incorrect nonce length"; 8 | if (k.size() != crypto_stream_KEYBYTES) throw "incorrect key length"; 9 | size_t mlen = m.size(); 10 | unsigned char c[mlen]; 11 | crypto_stream_xor(c, 12 | (const unsigned char *) m.c_str(),mlen, 13 | (const unsigned char *) n.c_str(), 14 | (const unsigned char *) k.c_str() 15 | ); 16 | return string((char *) c,mlen); 17 | } 18 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/checksum: -------------------------------------------------------------------------------- 1 | 201bc58a96adcb6ed339ca33c188af8ca04a4ce68be1e0953309ee09a0cf8e7a 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_KEYBYTES 32 2 | #define CRYPTO_NONCEBYTES 24 3 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/ref/implementors: -------------------------------------------------------------------------------- 1 | Daniel J. Bernstein 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/ref/stream.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080914 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_hsalsa20.h" 8 | #include "crypto_stream_salsa20.h" 9 | #include "crypto_stream.h" 10 | 11 | static const unsigned char sigma[16] = "expand 32-byte k"; 12 | 13 | int crypto_stream( 14 | unsigned char *c,unsigned long long clen, 15 | const unsigned char *n, 16 | const unsigned char *k 17 | ) 18 | { 19 | unsigned char subkey[32]; 20 | crypto_core_hsalsa20(subkey,n,k,sigma); 21 | return crypto_stream_salsa20(c,clen,n + 16,subkey); 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/ref/xor.c: -------------------------------------------------------------------------------- 1 | /* 2 | version 20080913 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #include "crypto_core_hsalsa20.h" 8 | #include "crypto_stream_salsa20.h" 9 | #include "crypto_stream.h" 10 | 11 | static const unsigned char sigma[16] = "expand 32-byte k"; 12 | 13 | int crypto_stream_xor( 14 | unsigned char *c, 15 | const unsigned char *m,unsigned long long mlen, 16 | const unsigned char *n, 17 | const unsigned char *k 18 | ) 19 | { 20 | unsigned char subkey[32]; 21 | crypto_core_hsalsa20(subkey,n,k,sigma); 22 | return crypto_stream_salsa20_xor(c,m,mlen,n + 16,subkey); 23 | } 24 | -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/selected: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/xsalsa20/selected -------------------------------------------------------------------------------- /src/libnacl/crypto_stream/xsalsa20/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_stream/xsalsa20/used -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/16/checksum: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/16/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 16 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/16/ref/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify.h" 2 | 3 | int crypto_verify(const unsigned char *x,const unsigned char *y) 4 | { 5 | unsigned int differentbits = 0; 6 | #define F(i) differentbits |= x[i] ^ y[i]; 7 | F(0) 8 | F(1) 9 | F(2) 10 | F(3) 11 | F(4) 12 | F(5) 13 | F(6) 14 | F(7) 15 | F(8) 16 | F(9) 17 | F(10) 18 | F(11) 19 | F(12) 20 | F(13) 21 | F(14) 22 | F(15) 23 | return (1 & ((differentbits - 1) >> 8)) - 1; 24 | } 25 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/16/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_verify/16/used -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/32/checksum: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/32/ref/api.h: -------------------------------------------------------------------------------- 1 | #define CRYPTO_BYTES 32 2 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/32/ref/verify.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify.h" 2 | 3 | int crypto_verify(const unsigned char *x,const unsigned char *y) 4 | { 5 | unsigned int differentbits = 0; 6 | #define F(i) differentbits |= x[i] ^ y[i]; 7 | F(0) 8 | F(1) 9 | F(2) 10 | F(3) 11 | F(4) 12 | F(5) 13 | F(6) 14 | F(7) 15 | F(8) 16 | F(9) 17 | F(10) 18 | F(11) 19 | F(12) 20 | F(13) 21 | F(14) 22 | F(15) 23 | F(16) 24 | F(17) 25 | F(18) 26 | F(19) 27 | F(20) 28 | F(21) 29 | F(22) 30 | F(23) 31 | F(24) 32 | F(25) 33 | F(26) 34 | F(27) 35 | F(28) 36 | F(29) 37 | F(30) 38 | F(31) 39 | return (1 & ((differentbits - 1) >> 8)) - 1; 40 | } 41 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/32/used: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_verify/32/used -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/measure.c: -------------------------------------------------------------------------------- 1 | #include "crypto_verify.h" 2 | 3 | const char *primitiveimplementation = crypto_verify_IMPLEMENTATION; 4 | const char *implementationversion = crypto_verify_VERSION; 5 | const char *sizenames[] = { "inputbytes", 0 }; 6 | const long long sizes[] = { crypto_verify_BYTES }; 7 | 8 | void preallocate(void) 9 | { 10 | } 11 | 12 | void allocate(void) 13 | { 14 | } 15 | 16 | void measure(void) 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/crypto_verify/wrapper-empty.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/crypto_verify/wrapper-empty.cpp -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_int16.c: -------------------------------------------------------------------------------- 1 | #include "crypto_int16.h" 2 | #include "signed.h" 3 | DOIT(16,crypto_int16) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_int32.c: -------------------------------------------------------------------------------- 1 | #include "crypto_int32.h" 2 | #include "signed.h" 3 | DOIT(32,crypto_int32) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_int64.c: -------------------------------------------------------------------------------- 1 | #include "crypto_int64.h" 2 | #include "signed.h" 3 | DOIT(64,crypto_int64) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_int8.c: -------------------------------------------------------------------------------- 1 | #include "crypto_int8.h" 2 | #include "signed.h" 3 | DOIT(8,crypto_int8) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_uint16.c: -------------------------------------------------------------------------------- 1 | #include "crypto_uint16.h" 2 | #include "unsigned.h" 3 | DOIT(16,crypto_uint16) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_uint32.c: -------------------------------------------------------------------------------- 1 | #include "crypto_uint32.h" 2 | #include "unsigned.h" 3 | DOIT(32,crypto_uint32) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_uint64.c: -------------------------------------------------------------------------------- 1 | #include "crypto_uint64.h" 2 | #include "unsigned.h" 3 | DOIT(64,crypto_uint64) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/crypto_uint8.c: -------------------------------------------------------------------------------- 1 | #include "crypto_uint8.h" 2 | #include "unsigned.h" 3 | DOIT(8,crypto_uint8) 4 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/signed.h: -------------------------------------------------------------------------------- 1 | #define DOIT(bits,target) \ 2 | int main() \ 3 | { \ 4 | target x; \ 5 | int i; \ 6 | \ 7 | x = 1; \ 8 | for (i = 0;i < bits;++i) { \ 9 | if (x == 0) return 100; \ 10 | x += x; \ 11 | } \ 12 | if (x != 0) return 100; \ 13 | x -= 1; \ 14 | if (x > 0) return 100; \ 15 | \ 16 | return 0; \ 17 | } 18 | -------------------------------------------------------------------------------- /src/libnacl/inttypes/unsigned.h: -------------------------------------------------------------------------------- 1 | #define DOIT(bits,target) \ 2 | int main() \ 3 | { \ 4 | target x; \ 5 | int i; \ 6 | \ 7 | x = 1; \ 8 | for (i = 0;i < bits;++i) { \ 9 | if (x == 0) return 100; \ 10 | x += x; \ 11 | } \ 12 | if (x != 0) return 100; \ 13 | x -= 1; \ 14 | if (x < 0) return 100; \ 15 | \ 16 | return 0; \ 17 | } 18 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/abinames: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/okcompilers/abinames -------------------------------------------------------------------------------- /src/libnacl/okcompilers/archivers: -------------------------------------------------------------------------------- 1 | ar 2 | ar -X64 3 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/c.in: -------------------------------------------------------------------------------- 1 | @CC@ @CPPFLAGS@ @CFLAGS@ 2 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/do.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | mkdir -p bin 4 | 5 | echo '#!/bin/sh' > bin/okabi 6 | echo 'echo local' >> bin/okabi 7 | 8 | exec < c 9 | echo '#!/bin/sh' > bin/okc-local 10 | while read compiler; do 11 | $compiler lib.c main.c -o test-c || continue 12 | echo "echo $compiler" >> bin/okc-local 13 | done 14 | 15 | echo '#!/bin/sh' > bin/okcpp-local 16 | 17 | echo '#!/bin/sh' > bin/oklibs-local 18 | echo 'echo " @LDFLAGS@ @LIBS@"' >> bin/oklibs-local 19 | 20 | echo '#!/bin/sh' > bin/okar-local 21 | echo 'exec @AR@ "$@"' >> bin/okar-local 22 | 23 | echo '#!/bin/sh' > bin/okranlib-local 24 | echo 'exec @RANLIB@ "$@"' >> bin/okranlib-local 25 | 26 | chmod +x bin/ok* 27 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/lib.c: -------------------------------------------------------------------------------- 1 | int not3(int n) 2 | { 3 | return n != 3; 4 | } 5 | 6 | int bytes(int n) 7 | { 8 | return (n + 7) / 8; 9 | } 10 | 11 | long long shr32(long long n) 12 | { 13 | return n >> 32; 14 | } 15 | 16 | double double5(void) 17 | { 18 | return 5.0; 19 | } 20 | 21 | int intbytes(void) 22 | { 23 | return sizeof(int); 24 | } 25 | 26 | int longbytes(void) 27 | { 28 | return sizeof(long); 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/lib.cpp: -------------------------------------------------------------------------------- 1 | int not3(int n) 2 | { 3 | return n != 3; 4 | } 5 | 6 | int bytes(int n) 7 | { 8 | return (n + 7) / 8; 9 | } 10 | 11 | long long shr32(long long n) 12 | { 13 | return n >> 32; 14 | } 15 | 16 | double double5(void) 17 | { 18 | return 5.0; 19 | } 20 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/main.c: -------------------------------------------------------------------------------- 1 | extern int not3(int); 2 | extern int bytes(int); 3 | extern long long shr32(long long); 4 | extern double double5(void); 5 | extern int longbytes(void); 6 | extern int intbytes(void); 7 | 8 | int main(int argc,char **argv) 9 | { 10 | if (intbytes() != sizeof(int)) return 100; 11 | if (longbytes() != sizeof(long)) return 100; 12 | 13 | if (not3(3)) return 100; 14 | 15 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 16 | if (!not3(shr32(1))) return 100; 17 | 18 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 19 | if (bytes(not3(1)) != 1) return 100; 20 | 21 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 22 | if (double5() < 0) return 100; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/main.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | extern int not3(int); 3 | extern int bytes(int); 4 | extern long long shr32(long long); 5 | extern double double5(void); 6 | } 7 | 8 | int main(int argc,char **argv) 9 | { 10 | if (not3(3)) return 100; 11 | 12 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 13 | if (!not3(shr32(1))) return 100; 14 | 15 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 16 | if (bytes(not3(1)) != 1) return 100; 17 | 18 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 19 | if (double5() < 0) return 100; 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test-okar: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PATH="/Users/j/pear/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/openssh/bin:/opt/openssh/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" 3 | export PATH 4 | ar "$@" 5 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test-okc: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PATH="/Users/j/pear/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/openssh/bin:/opt/openssh/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" 3 | export PATH 4 | gcc -O2 -fomit-frame-pointer "$@" 5 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test-okc2: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PATH="/Users/j/pear/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/openssh/bin:/opt/openssh/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" 3 | export PATH 4 | g++ -O2 -fomit-frame-pointer "$@" 5 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test-okclink: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | PATH="/Users/j/pear/bin:/usr/local/bin:/usr/local/sbin:/opt/local/bin:/opt/local/sbin:/opt/openssh/bin:/opt/openssh/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin" 3 | export PATH 4 | gcc -O2 -fomit-frame-pointer "$@" -lrt -lm 5 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test.c: -------------------------------------------------------------------------------- 1 | int not3(int n) 2 | { 3 | return n != 3; 4 | } 5 | 6 | int bytes(int n) 7 | { 8 | return (n + 7) / 8; 9 | } 10 | 11 | long long shr32(long long n) 12 | { 13 | return n >> 32; 14 | } 15 | 16 | double double5(void) 17 | { 18 | return 5.0; 19 | } 20 | 21 | int intbytes(void) 22 | { 23 | return sizeof(int); 24 | } 25 | 26 | int longbytes(void) 27 | { 28 | return sizeof(long); 29 | } 30 | extern int not3(int); 31 | extern int bytes(int); 32 | extern long long shr32(long long); 33 | extern double double5(void); 34 | extern int longbytes(void); 35 | extern int intbytes(void); 36 | 37 | int main(int argc,char **argv) 38 | { 39 | if (intbytes() != sizeof(int)) return 100; 40 | if (longbytes() != sizeof(long)) return 100; 41 | 42 | if (not3(3)) return 100; 43 | 44 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 45 | if (!not3(shr32(1))) return 100; 46 | 47 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 48 | if (bytes(not3(1)) != 1) return 100; 49 | 50 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 51 | if (double5() < 0) return 100; 52 | 53 | return 0; 54 | } 55 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test10.c: -------------------------------------------------------------------------------- 1 | int not3(int n) 2 | { 3 | return n != 3; 4 | } 5 | 6 | int bytes(int n) 7 | { 8 | return (n + 7) / 8; 9 | } 10 | 11 | long long shr32(long long n) 12 | { 13 | return n >> 32; 14 | } 15 | 16 | double double5(void) 17 | { 18 | return 5.0; 19 | } 20 | 21 | int intbytes(void) 22 | { 23 | return sizeof(int); 24 | } 25 | 26 | int longbytes(void) 27 | { 28 | return sizeof(long); 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test5.c: -------------------------------------------------------------------------------- 1 | extern int not3(int); 2 | extern int bytes(int); 3 | extern long long shr32(long long); 4 | extern double double5(void); 5 | extern int longbytes(void); 6 | extern int intbytes(void); 7 | 8 | int main(int argc,char **argv) 9 | { 10 | if (intbytes() != sizeof(int)) return 100; 11 | if (longbytes() != sizeof(long)) return 100; 12 | 13 | if (not3(3)) return 100; 14 | 15 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 16 | if (!not3(shr32(1))) return 100; 17 | 18 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 19 | if (bytes(not3(1)) != 1) return 100; 20 | 21 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 22 | if (double5() < 0) return 100; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test5.cpp: -------------------------------------------------------------------------------- 1 | extern "C" { 2 | extern int not3(int); 3 | extern int bytes(int); 4 | extern long long shr32(long long); 5 | extern double double5(void); 6 | } 7 | 8 | int main(int argc,char **argv) 9 | { 10 | if (not3(3)) return 100; 11 | 12 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 13 | if (!not3(shr32(1))) return 100; 14 | 15 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 16 | if (bytes(not3(1)) != 1) return 100; 17 | 18 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 19 | if (double5() < 0) return 100; 20 | 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test6.c: -------------------------------------------------------------------------------- 1 | int not3(int n) 2 | { 3 | return n != 3; 4 | } 5 | 6 | int bytes(int n) 7 | { 8 | return (n + 7) / 8; 9 | } 10 | 11 | long long shr32(long long n) 12 | { 13 | return n >> 32; 14 | } 15 | 16 | double double5(void) 17 | { 18 | return 5.0; 19 | } 20 | 21 | int intbytes(void) 22 | { 23 | return sizeof(int); 24 | } 25 | 26 | int longbytes(void) 27 | { 28 | return sizeof(long); 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/okcompilers/test9.c: -------------------------------------------------------------------------------- 1 | extern int not3(int); 2 | extern int bytes(int); 3 | extern long long shr32(long long); 4 | extern double double5(void); 5 | extern int longbytes(void); 6 | extern int intbytes(void); 7 | 8 | int main(int argc,char **argv) 9 | { 10 | if (intbytes() != sizeof(int)) return 100; 11 | if (longbytes() != sizeof(long)) return 100; 12 | 13 | if (not3(3)) return 100; 14 | 15 | /* on ppc32, gcc -mpowerpc64 produces SIGILL for >>32 */ 16 | if (!not3(shr32(1))) return 100; 17 | 18 | /* on pentium 1, gcc -march=pentium2 produces SIGILL for (...+7)/8 */ 19 | if (bytes(not3(1)) != 1) return 100; 20 | 21 | /* on pentium 1, gcc -march=prescott produces SIGILL for double comparison */ 22 | if (double5() < 0) return 100; 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /src/libnacl/randombytes/devurandom.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #ifdef _WIN32 6 | # include 7 | #endif 8 | 9 | /* it's really stupid that there isn't a syscall for this */ 10 | /* -> Y U NO USE OPENBSD? */ 11 | 12 | static int fd = -1; 13 | 14 | void randombytes(unsigned char *x,unsigned long long xlen) 15 | { 16 | int i; 17 | 18 | if (fd == -1) { 19 | for (;;) { 20 | fd = open("/dev/urandom",O_RDONLY); 21 | if (fd != -1) break; 22 | #ifdef _WIN32 23 | Sleep(1000); 24 | #else 25 | sleep(1); 26 | #endif 27 | } 28 | } 29 | 30 | while (xlen > 0) { 31 | if (xlen < 1048576) i = xlen; else i = 1048576; 32 | 33 | i = read(fd,x,i); 34 | if (i < 1) { 35 | #ifdef _WIN32 36 | Sleep(1000); 37 | #else 38 | sleep(1); 39 | #endif 40 | continue; 41 | } 42 | 43 | x += i; 44 | xlen -= i; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/libnacl/randombytes/devurandom.h: -------------------------------------------------------------------------------- 1 | /* 2 | randombytes/devurandom.h version 20080713 3 | D. J. Bernstein 4 | Public domain. 5 | */ 6 | 7 | #ifndef randombytes_devurandom_H 8 | #define randombytes_devurandom_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | extern void randombytes(unsigned char *,unsigned long long); 15 | 16 | #ifdef __cplusplus 17 | } 18 | #endif 19 | 20 | #ifndef randombytes_implementation 21 | #define randombytes_implementation "devurandom" 22 | #endif 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/libnacl/randombytes/test.c: -------------------------------------------------------------------------------- 1 | #include "randombytes-impl.h" 2 | 3 | unsigned char x[65536]; 4 | unsigned long long freq[256]; 5 | 6 | int main() 7 | { 8 | unsigned long long i; 9 | 10 | randombytes(x,sizeof x); 11 | for (i = 0;i < 256;++i) freq[i] = 0; 12 | for (i = 0;i < sizeof x;++i) ++freq[255 & (int) x[i]]; 13 | for (i = 0;i < 256;++i) if (!freq[i]) return 111; 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_auth_hmacsha512256.h" 3 | 4 | /* "Test Case 2" from RFC 4231 */ 5 | unsigned char key[32] = "Jefe"; 6 | unsigned char c[28] = "what do ya want for nothing?"; 7 | 8 | unsigned char a[32]; 9 | 10 | main() 11 | { 12 | int i; 13 | crypto_auth_hmacsha512256(a,c,sizeof c,key); 14 | for (i = 0;i < 32;++i) { 15 | printf(",0x%02x",(unsigned int) a[i]); 16 | if (i % 8 == 7) printf("\n"); 17 | } 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth.out: -------------------------------------------------------------------------------- 1 | ,0x16,0x4b,0x7a,0x7b,0xfc,0xf8,0x19,0xe2 2 | ,0xe3,0x95,0xfb,0xe7,0x3b,0x56,0xe0,0xa3 3 | ,0x87,0xbd,0x64,0x22,0x2e,0x83,0x1f,0xd6 4 | ,0x10,0x27,0x0c,0xd7,0xea,0x25,0x05,0x54 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth2.c: -------------------------------------------------------------------------------- 1 | /* "Test Case AUTH256-4" from RFC 4868 */ 2 | 3 | #include 4 | #include "crypto_auth_hmacsha256.h" 5 | 6 | unsigned char key[32] = { 7 | 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 8 | ,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10 9 | ,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18 10 | ,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20 11 | } ; 12 | 13 | unsigned char c[50] = { 14 | 0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 15 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 16 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 17 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 18 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 19 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 20 | ,0xcd,0xcd 21 | } ; 22 | 23 | unsigned char a[32]; 24 | 25 | main() 26 | { 27 | int i; 28 | crypto_auth_hmacsha256(a,c,sizeof c,key); 29 | for (i = 0;i < 32;++i) { 30 | printf(",0x%02x",(unsigned int) a[i]); 31 | if (i % 8 == 7) printf("\n"); 32 | } 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth2.out: -------------------------------------------------------------------------------- 1 | ,0x37,0x2e,0xfc,0xf9,0xb4,0x0b,0x35,0xc2 2 | ,0x11,0x5b,0x13,0x46,0x90,0x3d,0x2e,0xf4 3 | ,0x2f,0xce,0xd4,0x6f,0x08,0x46,0xe7,0x25 4 | ,0x7b,0xb1,0x56,0xd3,0xd7,0xb3,0x0d,0x3f 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth3.c: -------------------------------------------------------------------------------- 1 | /* "Test Case AUTH256-4" from RFC 4868 */ 2 | 3 | #include 4 | #include "crypto_auth_hmacsha256.h" 5 | 6 | unsigned char key[32] = { 7 | 0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08 8 | ,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,0x10 9 | ,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18 10 | ,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f,0x20 11 | } ; 12 | 13 | unsigned char c[50] = { 14 | 0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 15 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 16 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 17 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 18 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 19 | ,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd,0xcd 20 | ,0xcd,0xcd 21 | } ; 22 | 23 | unsigned char a[32] = { 24 | 0x37,0x2e,0xfc,0xf9,0xb4,0x0b,0x35,0xc2 25 | ,0x11,0x5b,0x13,0x46,0x90,0x3d,0x2e,0xf4 26 | ,0x2f,0xce,0xd4,0x6f,0x08,0x46,0xe7,0x25 27 | ,0x7b,0xb1,0x56,0xd3,0xd7,0xb3,0x0d,0x3f 28 | } ; 29 | 30 | main() 31 | { 32 | printf("%d\n",crypto_auth_hmacsha256_verify(a,c,sizeof c,key)); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth3.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth4.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "crypto_auth_hmacsha512256.h" 4 | #include "randombytes.h" 5 | #include "windows/windows-quirks.h" 6 | 7 | unsigned char key[32]; 8 | unsigned char c[10000]; 9 | unsigned char a[32]; 10 | 11 | main() 12 | { 13 | int clen; 14 | int i; 15 | for (clen = 0;clen < 10000;++clen) { 16 | randombytes(key,sizeof key); 17 | randombytes(c,clen); 18 | crypto_auth_hmacsha512256(a,c,clen,key); 19 | if (crypto_auth_hmacsha512256_verify(a,c,clen,key) != 0) { 20 | printf("fail %d\n",clen); 21 | return 100; 22 | } 23 | if (clen > 0) { 24 | c[random() % clen] += 1 + (random() % 255); 25 | if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) { 26 | printf("forgery %d\n",clen); 27 | return 100; 28 | } 29 | a[random() % sizeof a] += 1 + (random() % 255); 30 | if (crypto_auth_hmacsha512256_verify(a,c,clen,key) == 0) { 31 | printf("forgery %d\n",clen); 32 | return 100; 33 | } 34 | } 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/libnacl/tests/auth5.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/auth5.out -------------------------------------------------------------------------------- /src/libnacl/tests/auth6.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/auth6.out -------------------------------------------------------------------------------- /src/libnacl/tests/box.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 4 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 5 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 6 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 7 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 8 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 9 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 10 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 11 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 12 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 13 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 14 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 15 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 16 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 17 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 18 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 19 | ,0xe3,0x55,0xa5 20 | -------------------------------------------------------------------------------- /src/libnacl/tests/box2.out: -------------------------------------------------------------------------------- 1 | ,0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5 2 | ,0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b 3 | ,0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4 4 | ,0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc 5 | ,0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a 6 | ,0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29 7 | ,0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4 8 | ,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31 9 | ,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d 10 | ,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57 11 | ,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a 12 | ,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde 13 | ,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd 14 | ,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52 15 | ,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40 16 | ,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64 17 | ,0x5e,0x07,0x05 18 | -------------------------------------------------------------------------------- /src/libnacl/tests/box3.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 4 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 5 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 6 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 7 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 8 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 9 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 10 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 11 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 12 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 13 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 14 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 15 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 16 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 17 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 18 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 19 | ,0xe3,0x55,0xa5 20 | -------------------------------------------------------------------------------- /src/libnacl/tests/box4.out: -------------------------------------------------------------------------------- 1 | ,0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5 2 | ,0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b 3 | ,0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4 4 | ,0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc 5 | ,0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a 6 | ,0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29 7 | ,0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4 8 | ,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31 9 | ,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d 10 | ,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57 11 | ,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a 12 | ,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde 13 | ,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd 14 | ,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52 15 | ,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40 16 | ,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64 17 | ,0x5e,0x07,0x05 18 | -------------------------------------------------------------------------------- /src/libnacl/tests/box5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_box.h" 5 | #include "randombytes.h" 6 | 7 | main() 8 | { 9 | int mlen; 10 | for (mlen = 0;mlen < 1000;++mlen) { 11 | string alicesk; 12 | string alicepk = crypto_box_keypair(&alicesk); 13 | string bobsk; 14 | string bobpk = crypto_box_keypair(&bobsk); 15 | unsigned char nbytes[crypto_box_NONCEBYTES]; 16 | randombytes(nbytes,crypto_box_NONCEBYTES); 17 | string n((char *) nbytes,crypto_box_NONCEBYTES); 18 | unsigned char mbytes[mlen]; 19 | randombytes(mbytes,mlen); 20 | string m((char *) mbytes,mlen); 21 | string c = crypto_box(m,n,bobpk,alicesk); 22 | try { 23 | string m2 = crypto_box_open(c,n,alicepk,bobsk); 24 | if (m != m2) printf("bad decryption\n"); 25 | } catch(const char *s) { 26 | printf("%s\n",s); 27 | } 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libnacl/tests/box5.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/box5.out -------------------------------------------------------------------------------- /src/libnacl/tests/box6.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/box6.out -------------------------------------------------------------------------------- /src/libnacl/tests/box7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_box.h" 3 | #include "randombytes.h" 4 | 5 | unsigned char alicesk[crypto_box_SECRETKEYBYTES]; 6 | unsigned char alicepk[crypto_box_PUBLICKEYBYTES]; 7 | unsigned char bobsk[crypto_box_SECRETKEYBYTES]; 8 | unsigned char bobpk[crypto_box_PUBLICKEYBYTES]; 9 | unsigned char n[crypto_box_NONCEBYTES]; 10 | unsigned char m[10000]; 11 | unsigned char c[10000]; 12 | unsigned char m2[10000]; 13 | 14 | main() 15 | { 16 | int mlen; 17 | int i; 18 | 19 | for (mlen = 0;mlen < 1000 && mlen + crypto_box_ZEROBYTES < sizeof m;++mlen) { 20 | crypto_box_keypair(alicepk,alicesk); 21 | crypto_box_keypair(bobpk,bobsk); 22 | randombytes(n,crypto_box_NONCEBYTES); 23 | randombytes(m + crypto_box_ZEROBYTES,mlen); 24 | crypto_box(c,m,mlen + crypto_box_ZEROBYTES,n,bobpk,alicesk); 25 | if (crypto_box_open(m2,c,mlen + crypto_box_ZEROBYTES,n,alicepk,bobsk) == 0) { 26 | for (i = 0;i < mlen + crypto_box_ZEROBYTES;++i) 27 | if (m2[i] != m[i]) { 28 | printf("bad decryption\n"); 29 | break; 30 | } 31 | } else { 32 | printf("ciphertext fails verification\n"); 33 | } 34 | } 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /src/libnacl/tests/box7.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/box7.out -------------------------------------------------------------------------------- /src/libnacl/tests/box8.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/box8.out -------------------------------------------------------------------------------- /src/libnacl/tests/core1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_core_hsalsa20.h" 3 | 4 | unsigned char shared[32] = { 5 | 0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1 6 | ,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25 7 | ,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33 8 | ,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42 9 | } ; 10 | 11 | unsigned char zero[32] = { 0 }; 12 | 13 | unsigned char c[16] = { 14 | 0x65,0x78,0x70,0x61,0x6e,0x64,0x20,0x33 15 | ,0x32,0x2d,0x62,0x79,0x74,0x65,0x20,0x6b 16 | } ; 17 | 18 | unsigned char firstkey[32]; 19 | 20 | main() 21 | { 22 | int i; 23 | crypto_core_hsalsa20(firstkey,zero,shared,c); 24 | for (i = 0;i < 32;++i) { 25 | if (i > 0) printf(","); else printf(" "); 26 | printf("0x%02x",(unsigned int) firstkey[i]); 27 | if (i % 8 == 7) printf("\n"); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libnacl/tests/core1.out: -------------------------------------------------------------------------------- 1 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 2 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 3 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 4 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/core2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_core_hsalsa20.h" 3 | 4 | unsigned char firstkey[32] = { 5 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 6 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 7 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 8 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 9 | } ; 10 | 11 | unsigned char nonceprefix[16] = { 12 | 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73 13 | ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6 14 | } ; 15 | 16 | unsigned char c[16] = { 17 | 0x65,0x78,0x70,0x61,0x6e,0x64,0x20,0x33 18 | ,0x32,0x2d,0x62,0x79,0x74,0x65,0x20,0x6b 19 | } ; 20 | 21 | unsigned char secondkey[32]; 22 | 23 | main() 24 | { 25 | int i; 26 | crypto_core_hsalsa20(secondkey,nonceprefix,firstkey,c); 27 | for (i = 0;i < 32;++i) { 28 | if (i > 0) printf(","); else printf(" "); 29 | printf("0x%02x",(unsigned int) secondkey[i]); 30 | if (i % 8 == 7) printf("\n"); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libnacl/tests/core2.out: -------------------------------------------------------------------------------- 1 | 0xdc,0x90,0x8d,0xda,0x0b,0x93,0x44,0xa9 2 | ,0x53,0x62,0x9b,0x73,0x38,0x20,0x77,0x88 3 | ,0x80,0xf3,0xce,0xb4,0x21,0xbb,0x61,0xb9 4 | ,0x1c,0xbd,0x4c,0x3e,0x66,0x25,0x6c,0xe4 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/core3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_core_salsa20.h" 3 | #include "crypto_hash_sha256.h" 4 | 5 | unsigned char secondkey[32] = { 6 | 0xdc,0x90,0x8d,0xda,0x0b,0x93,0x44,0xa9 7 | ,0x53,0x62,0x9b,0x73,0x38,0x20,0x77,0x88 8 | ,0x80,0xf3,0xce,0xb4,0x21,0xbb,0x61,0xb9 9 | ,0x1c,0xbd,0x4c,0x3e,0x66,0x25,0x6c,0xe4 10 | } ; 11 | 12 | unsigned char noncesuffix[8] = { 13 | 0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 14 | } ; 15 | 16 | unsigned char c[16] = { 17 | 0x65,0x78,0x70,0x61,0x6e,0x64,0x20,0x33 18 | ,0x32,0x2d,0x62,0x79,0x74,0x65,0x20,0x6b 19 | } ; 20 | 21 | unsigned char in[16] = { 0 } ; 22 | 23 | unsigned char output[64 * 256 * 256]; 24 | 25 | unsigned char h[32]; 26 | 27 | main() 28 | { 29 | int i; 30 | long long pos = 0; 31 | for (i = 0;i < 8;++i) in[i] = noncesuffix[i]; 32 | do { 33 | do { 34 | crypto_core_salsa20(output + pos,in,secondkey,c); 35 | pos += 64; 36 | } while (++in[8]); 37 | } while (++in[9]); 38 | crypto_hash_sha256(h,output,sizeof output); 39 | for (i = 0;i < 32;++i) printf("%02x",h[i]); printf("\n"); 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /src/libnacl/tests/core3.out: -------------------------------------------------------------------------------- 1 | 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/core4.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_core_salsa20.h" 3 | 4 | unsigned char k[32] = { 5 | 1, 2, 3, 4, 5, 6, 7, 8 6 | , 9, 10, 11, 12, 13, 14, 15, 16 7 | ,201,202,203,204,205,206,207,208 8 | ,209,210,211,212,213,214,215,216 9 | } ; 10 | 11 | unsigned char in[16] = { 12 | 101,102,103,104,105,106,107,108 13 | ,109,110,111,112,113,114,115,116 14 | } ; 15 | 16 | unsigned char c[16] = { 17 | 101,120,112, 97,110,100, 32, 51 18 | , 50, 45, 98,121,116,101, 32,107 19 | } ; 20 | 21 | unsigned char out[64]; 22 | 23 | main() 24 | { 25 | int i; 26 | crypto_core_salsa20(out,in,k,c); 27 | for (i = 0;i < 64;++i) { 28 | if (i > 0) printf(","); else printf(" "); 29 | printf("%3d",(unsigned int) out[i]); 30 | if (i % 8 == 7) printf("\n"); 31 | } 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /src/libnacl/tests/core4.out: -------------------------------------------------------------------------------- 1 | 69, 37, 68, 39, 41, 15,107,193 2 | ,255,139,122, 6,170,233,217, 98 3 | , 89,144,182,106, 21, 51,200, 65 4 | ,239, 49,222, 34,215,114, 40,126 5 | ,104,197, 7,225,197,153, 31, 2 6 | ,102, 78, 76,176, 84,245,246,184 7 | ,177,160,133,130, 6, 72,149,119 8 | ,192,195,132,236,234,103,246, 74 9 | -------------------------------------------------------------------------------- /src/libnacl/tests/core5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_core_hsalsa20.h" 3 | 4 | unsigned char k[32] = { 5 | 0xee,0x30,0x4f,0xca,0x27,0x00,0x8d,0x8c 6 | ,0x12,0x6f,0x90,0x02,0x79,0x01,0xd8,0x0f 7 | ,0x7f,0x1d,0x8b,0x8d,0xc9,0x36,0xcf,0x3b 8 | ,0x9f,0x81,0x96,0x92,0x82,0x7e,0x57,0x77 9 | } ; 10 | 11 | unsigned char in[16] = { 12 | 0x81,0x91,0x8e,0xf2,0xa5,0xe0,0xda,0x9b 13 | ,0x3e,0x90,0x60,0x52,0x1e,0x4b,0xb3,0x52 14 | } ; 15 | 16 | unsigned char c[16] = { 17 | 101,120,112, 97,110,100, 32, 51 18 | , 50, 45, 98,121,116,101, 32,107 19 | } ; 20 | 21 | unsigned char out[32]; 22 | 23 | main() 24 | { 25 | int i; 26 | crypto_core_hsalsa20(out,in,k,c); 27 | for (i = 0;i < 32;++i) { 28 | printf(",0x%02x",(unsigned int) out[i]); 29 | if (i % 8 == 7) printf("\n"); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/libnacl/tests/core5.out: -------------------------------------------------------------------------------- 1 | ,0xbc,0x1b,0x30,0xfc,0x07,0x2c,0xc1,0x40 2 | ,0x75,0xe4,0xba,0xa7,0x31,0xb5,0xa8,0x45 3 | ,0xea,0x9b,0x11,0xe9,0xa5,0x19,0x1f,0x94 4 | ,0xe1,0x8c,0xba,0x8f,0xd8,0x21,0xa7,0xcd 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/core6.out: -------------------------------------------------------------------------------- 1 | ,0xbc,0x1b,0x30,0xfc,0x07,0x2c,0xc1,0x40 2 | ,0x75,0xe4,0xba,0xa7,0x31,0xb5,0xa8,0x45 3 | ,0xea,0x9b,0x11,0xe9,0xa5,0x19,0x1f,0x94 4 | ,0xe1,0x8c,0xba,0x8f,0xd8,0x21,0xa7,0xcd 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_hash.h" 3 | 4 | unsigned char x[8] = "testing\n"; 5 | unsigned char h[crypto_hash_BYTES]; 6 | 7 | int main() 8 | { 9 | int i; 10 | crypto_hash(h,x,sizeof x); 11 | for (i = 0;i < crypto_hash_BYTES;++i) printf("%02x",(unsigned int) h[i]); 12 | printf("\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash.out: -------------------------------------------------------------------------------- 1 | 24f950aac7b9ea9b3cb728228a0c82b67c39e96b4b344798870d5daee93e3ae5931baae8c7cacfea4b629452c38026a81d138bc7aad1af3ef7bfd5ec646d6c28 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash2.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using std::string; 4 | using std::cout; 5 | using std::hex; 6 | #include "crypto_hash.h" 7 | 8 | int main() 9 | { 10 | string x = "testing\n"; 11 | string h = crypto_hash(x); 12 | for (int i = 0;i < h.size();++i) { 13 | cout << hex << (15 & (int) (h[i] >> 4)); 14 | cout << hex << (15 & (int) h[i]); 15 | } 16 | cout << "\n"; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash2.out: -------------------------------------------------------------------------------- 1 | 24f950aac7b9ea9b3cb728228a0c82b67c39e96b4b344798870d5daee93e3ae5931baae8c7cacfea4b629452c38026a81d138bc7aad1af3ef7bfd5ec646d6c28 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_hash_sha512.h" 3 | 4 | unsigned char x[8] = "testing\n"; 5 | unsigned char h[crypto_hash_sha512_BYTES]; 6 | 7 | int main() 8 | { 9 | int i; 10 | crypto_hash_sha512(h,x,sizeof x); 11 | for (i = 0;i < crypto_hash_sha512_BYTES;++i) printf("%02x",(unsigned int) h[i]); 12 | printf("\n"); 13 | return 0; 14 | } 15 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash3.out: -------------------------------------------------------------------------------- 1 | 24f950aac7b9ea9b3cb728228a0c82b67c39e96b4b344798870d5daee93e3ae5931baae8c7cacfea4b629452c38026a81d138bc7aad1af3ef7bfd5ec646d6c28 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | using std::string; 4 | using std::cout; 5 | using std::hex; 6 | #include "crypto_hash_sha512.h" 7 | 8 | int main() 9 | { 10 | string x = "testing\n"; 11 | string h = crypto_hash_sha512(x); 12 | for (int i = 0;i < h.size();++i) { 13 | cout << hex << (15 & (int) (h[i] >> 4)); 14 | cout << hex << (15 & (int) h[i]); 15 | } 16 | cout << "\n"; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /src/libnacl/tests/hash4.out: -------------------------------------------------------------------------------- 1 | 24f950aac7b9ea9b3cb728228a0c82b67c39e96b4b344798870d5daee93e3ae5931baae8c7cacfea4b629452c38026a81d138bc7aad1af3ef7bfd5ec646d6c28 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth2.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth5.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth6.out: -------------------------------------------------------------------------------- 1 | 0 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "crypto_onetimeauth_poly1305.h" 4 | #include "randombytes.h" 5 | #include "windows/windows-quirks.h" 6 | 7 | unsigned char key[32]; 8 | unsigned char c[10000]; 9 | unsigned char a[16]; 10 | 11 | main() 12 | { 13 | int clen; 14 | int i; 15 | for (clen = 0;clen < 10000;++clen) { 16 | randombytes(key,sizeof key); 17 | randombytes(c,clen); 18 | crypto_onetimeauth_poly1305(a,c,clen,key); 19 | if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) != 0) { 20 | printf("fail %d\n",clen); 21 | return 100; 22 | } 23 | if (clen > 0) { 24 | c[random() % clen] += 1 + (random() % 255); 25 | if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) { 26 | printf("forgery %d\n",clen); 27 | return 100; 28 | } 29 | a[random() % sizeof a] += 1 + (random() % 255); 30 | if (crypto_onetimeauth_poly1305_verify(a,c,clen,key) == 0) { 31 | printf("forgery %d\n",clen); 32 | return 100; 33 | } 34 | } 35 | } 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth7.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/onetimeauth7.out -------------------------------------------------------------------------------- /src/libnacl/tests/onetimeauth8.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/onetimeauth8.out -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_scalarmult_curve25519.h" 3 | 4 | unsigned char alicesk[32] = { 5 | 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d 6 | ,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 7 | ,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a 8 | ,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a 9 | } ; 10 | 11 | unsigned char alicepk[32]; 12 | 13 | main() 14 | { 15 | int i; 16 | crypto_scalarmult_curve25519_base(alicepk,alicesk); 17 | for (i = 0;i < 32;++i) { 18 | if (i > 0) printf(","); else printf(" "); 19 | printf("0x%02x",(unsigned int) alicepk[i]); 20 | if (i % 8 == 7) printf("\n"); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult.out: -------------------------------------------------------------------------------- 1 | 0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54 2 | ,0x74,0x8b,0x7d,0xdc,0xb4,0x3e,0xf7,0x5a 3 | ,0x0d,0xbf,0x3a,0x0d,0x26,0x38,0x1a,0xf4 4 | ,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_scalarmult_curve25519.h" 3 | 4 | unsigned char bobsk[32] = { 5 | 0x5d,0xab,0x08,0x7e,0x62,0x4a,0x8a,0x4b 6 | ,0x79,0xe1,0x7f,0x8b,0x83,0x80,0x0e,0xe6 7 | ,0x6f,0x3b,0xb1,0x29,0x26,0x18,0xb6,0xfd 8 | ,0x1c,0x2f,0x8b,0x27,0xff,0x88,0xe0,0xeb 9 | } ; 10 | 11 | unsigned char bobpk[32]; 12 | 13 | main() 14 | { 15 | int i; 16 | crypto_scalarmult_curve25519_base(bobpk,bobsk); 17 | for (i = 0;i < 32;++i) { 18 | if (i > 0) printf(","); else printf(" "); 19 | printf("0x%02x",(unsigned int) bobpk[i]); 20 | if (i % 8 == 7) printf("\n"); 21 | } 22 | return 0; 23 | } 24 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult2.out: -------------------------------------------------------------------------------- 1 | 0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4 2 | ,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37 3 | ,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d 4 | ,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult3.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using std::string; 5 | using std::cout; 6 | using std::setfill; 7 | using std::setw; 8 | using std::hex; 9 | #include "crypto_scalarmult_curve25519.h" 10 | 11 | char alicesk_bytes[32] = { 12 | 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d 13 | ,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 14 | ,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a 15 | ,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a 16 | } ; 17 | 18 | main() 19 | { 20 | int i; 21 | cout << setfill('0'); 22 | string alicesk(alicesk_bytes,sizeof alicesk_bytes); 23 | string alicepk = crypto_scalarmult_curve25519_base(alicesk); 24 | for (i = 0;i < alicepk.size();++i) { 25 | unsigned char c = alicepk[i]; 26 | if (i > 0) cout << ","; else cout << " "; 27 | cout << "0x" << hex << setw(2) << (unsigned int) c; 28 | if (i % 8 == 7) cout << "\n"; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult3.out: -------------------------------------------------------------------------------- 1 | 0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54 2 | ,0x74,0x8b,0x7d,0xdc,0xb4,0x3e,0xf7,0x5a 3 | ,0x0d,0xbf,0x3a,0x0d,0x26,0x38,0x1a,0xf4 4 | ,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult4.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | using std::string; 5 | using std::cout; 6 | using std::setfill; 7 | using std::setw; 8 | using std::hex; 9 | #include "crypto_scalarmult_curve25519.h" 10 | 11 | char bobsk_bytes[32] = { 12 | 0x5d,0xab,0x08,0x7e,0x62,0x4a,0x8a,0x4b 13 | ,0x79,0xe1,0x7f,0x8b,0x83,0x80,0x0e,0xe6 14 | ,0x6f,0x3b,0xb1,0x29,0x26,0x18,0xb6,0xfd 15 | ,0x1c,0x2f,0x8b,0x27,0xff,0x88,0xe0,0xeb 16 | } ; 17 | 18 | main() 19 | { 20 | int i; 21 | cout << setfill('0'); 22 | string bobsk(bobsk_bytes,sizeof bobsk_bytes); 23 | string bobpk = crypto_scalarmult_curve25519_base(bobsk); 24 | for (i = 0;i < bobpk.size();++i) { 25 | unsigned char c = bobpk[i]; 26 | if (i > 0) cout << ","; else cout << " "; 27 | cout << "0x" << hex << setw(2) << (unsigned int) c; 28 | if (i % 8 == 7) cout << "\n"; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult4.out: -------------------------------------------------------------------------------- 1 | 0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4 2 | ,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37 3 | ,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d 4 | ,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult5.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_scalarmult_curve25519.h" 3 | 4 | unsigned char alicesk[32] = { 5 | 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d 6 | ,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 7 | ,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a 8 | ,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a 9 | } ; 10 | 11 | unsigned char bobpk[32] = { 12 | 0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4 13 | ,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37 14 | ,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d 15 | ,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f 16 | } ; 17 | 18 | unsigned char k[32]; 19 | 20 | main() 21 | { 22 | int i; 23 | crypto_scalarmult_curve25519(k,alicesk,bobpk); 24 | for (i = 0;i < 32;++i) { 25 | if (i > 0) printf(","); else printf(" "); 26 | printf("0x%02x",(unsigned int) k[i]); 27 | if (i % 8 == 7) printf("\n"); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult5.out: -------------------------------------------------------------------------------- 1 | 0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1 2 | ,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25 3 | ,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33 4 | ,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult6.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_scalarmult_curve25519.h" 3 | 4 | unsigned char bobsk[32] = { 5 | 0x5d,0xab,0x08,0x7e,0x62,0x4a,0x8a,0x4b 6 | ,0x79,0xe1,0x7f,0x8b,0x83,0x80,0x0e,0xe6 7 | ,0x6f,0x3b,0xb1,0x29,0x26,0x18,0xb6,0xfd 8 | ,0x1c,0x2f,0x8b,0x27,0xff,0x88,0xe0,0xeb 9 | } ; 10 | 11 | unsigned char alicepk[32] = { 12 | 0x85,0x20,0xf0,0x09,0x89,0x30,0xa7,0x54 13 | ,0x74,0x8b,0x7d,0xdc,0xb4,0x3e,0xf7,0x5a 14 | ,0x0d,0xbf,0x3a,0x0d,0x26,0x38,0x1a,0xf4 15 | ,0xeb,0xa4,0xa9,0x8e,0xaa,0x9b,0x4e,0x6a 16 | } ; 17 | 18 | unsigned char k[32]; 19 | 20 | main() 21 | { 22 | int i; 23 | crypto_scalarmult_curve25519(k,bobsk,alicepk); 24 | for (i = 0;i < 32;++i) { 25 | if (i > 0) printf(","); else printf(" "); 26 | printf("0x%02x",(unsigned int) k[i]); 27 | if (i % 8 == 7) printf("\n"); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult6.out: -------------------------------------------------------------------------------- 1 | 0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1 2 | ,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25 3 | ,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33 4 | ,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_scalarmult_curve25519.h" 5 | 6 | char alicesk_bytes[32] = { 7 | 0x77,0x07,0x6d,0x0a,0x73,0x18,0xa5,0x7d 8 | ,0x3c,0x16,0xc1,0x72,0x51,0xb2,0x66,0x45 9 | ,0xdf,0x4c,0x2f,0x87,0xeb,0xc0,0x99,0x2a 10 | ,0xb1,0x77,0xfb,0xa5,0x1d,0xb9,0x2c,0x2a 11 | } ; 12 | 13 | char bobpk_bytes[32] = { 14 | 0xde,0x9e,0xdb,0x7d,0x7b,0x7d,0xc1,0xb4 15 | ,0xd3,0x5b,0x61,0xc2,0xec,0xe4,0x35,0x37 16 | ,0x3f,0x83,0x43,0xc8,0x5b,0x78,0x67,0x4d 17 | ,0xad,0xfc,0x7e,0x14,0x6f,0x88,0x2b,0x4f 18 | } ; 19 | 20 | main() 21 | { 22 | int i; 23 | string alicesk(alicesk_bytes,sizeof alicesk_bytes); 24 | string bobpk(bobpk_bytes,sizeof bobpk_bytes); 25 | string k = crypto_scalarmult_curve25519(alicesk,bobpk); 26 | for (i = 0;i < k.size();++i) { 27 | if (i > 0) printf(","); else printf(" "); 28 | printf("0x%02x",(unsigned int) (unsigned char) k[i]); 29 | if (i % 8 == 7) printf("\n"); 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/libnacl/tests/scalarmult7.out: -------------------------------------------------------------------------------- 1 | 0x4a,0x5d,0x9d,0x5b,0xa4,0xce,0x2d,0xe1 2 | ,0x72,0x8e,0x3b,0xf4,0x80,0x35,0x0f,0x25 3 | ,0xe0,0x7e,0x21,0xc9,0x47,0xd1,0x9e,0x33 4 | ,0x76,0xf0,0x9b,0x3c,0x1e,0x16,0x17,0x42 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 4 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 5 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 6 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 7 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 8 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 9 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 10 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 11 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 12 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 13 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 14 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 15 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 16 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 17 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 18 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 19 | ,0xe3,0x55,0xa5 20 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox2.out: -------------------------------------------------------------------------------- 1 | ,0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5 2 | ,0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b 3 | ,0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4 4 | ,0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc 5 | ,0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a 6 | ,0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29 7 | ,0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4 8 | ,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31 9 | ,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d 10 | ,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57 11 | ,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a 12 | ,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde 13 | ,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd 14 | ,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52 15 | ,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40 16 | ,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64 17 | ,0x5e,0x07,0x05 18 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox3.out: -------------------------------------------------------------------------------- 1 | ,0xf3,0xff,0xc7,0x70,0x3f,0x94,0x00,0xe5 2 | ,0x2a,0x7d,0xfb,0x4b,0x3d,0x33,0x05,0xd9 3 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 4 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 5 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 6 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 7 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 8 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 9 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 10 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 11 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 12 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 13 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 14 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 15 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 16 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 17 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 18 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 19 | ,0xe3,0x55,0xa5 20 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox4.out: -------------------------------------------------------------------------------- 1 | ,0xbe,0x07,0x5f,0xc5,0x3c,0x81,0xf2,0xd5 2 | ,0xcf,0x14,0x13,0x16,0xeb,0xeb,0x0c,0x7b 3 | ,0x52,0x28,0xc5,0x2a,0x4c,0x62,0xcb,0xd4 4 | ,0x4b,0x66,0x84,0x9b,0x64,0x24,0x4f,0xfc 5 | ,0xe5,0xec,0xba,0xaf,0x33,0xbd,0x75,0x1a 6 | ,0x1a,0xc7,0x28,0xd4,0x5e,0x6c,0x61,0x29 7 | ,0x6c,0xdc,0x3c,0x01,0x23,0x35,0x61,0xf4 8 | ,0x1d,0xb6,0x6c,0xce,0x31,0x4a,0xdb,0x31 9 | ,0x0e,0x3b,0xe8,0x25,0x0c,0x46,0xf0,0x6d 10 | ,0xce,0xea,0x3a,0x7f,0xa1,0x34,0x80,0x57 11 | ,0xe2,0xf6,0x55,0x6a,0xd6,0xb1,0x31,0x8a 12 | ,0x02,0x4a,0x83,0x8f,0x21,0xaf,0x1f,0xde 13 | ,0x04,0x89,0x77,0xeb,0x48,0xf5,0x9f,0xfd 14 | ,0x49,0x24,0xca,0x1c,0x60,0x90,0x2e,0x52 15 | ,0xf0,0xa0,0x89,0xbc,0x76,0x89,0x70,0x40 16 | ,0xe0,0x82,0xf9,0x37,0x76,0x38,0x48,0x64 17 | ,0x5e,0x07,0x05 18 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_secretbox.h" 5 | #include "randombytes.h" 6 | 7 | main() 8 | { 9 | int mlen; 10 | for (mlen = 0;mlen < 1000;++mlen) { 11 | unsigned char kbytes[crypto_secretbox_KEYBYTES]; 12 | randombytes(kbytes,crypto_secretbox_KEYBYTES); 13 | string k((char *) kbytes,crypto_secretbox_KEYBYTES); 14 | unsigned char nbytes[crypto_secretbox_NONCEBYTES]; 15 | randombytes(nbytes,crypto_secretbox_NONCEBYTES); 16 | string n((char *) nbytes,crypto_secretbox_NONCEBYTES); 17 | unsigned char mbytes[mlen]; 18 | randombytes(mbytes,mlen); 19 | string m((char *) mbytes,mlen); 20 | string c = crypto_secretbox(m,n,k); 21 | try { 22 | string m2 = crypto_secretbox_open(c,n,k); 23 | if (m != m2) printf("bad decryption\n"); 24 | } catch(const char *s) { 25 | printf("%s\n",s); 26 | } 27 | } 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox5.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/secretbox5.out -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox6.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/secretbox6.out -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox7.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_secretbox.h" 3 | #include "randombytes.h" 4 | 5 | unsigned char k[crypto_secretbox_KEYBYTES]; 6 | unsigned char n[crypto_secretbox_NONCEBYTES]; 7 | unsigned char m[10000]; 8 | unsigned char c[10000]; 9 | unsigned char m2[10000]; 10 | 11 | main() 12 | { 13 | int mlen; 14 | int i; 15 | 16 | for (mlen = 0;mlen < 1000 && mlen + crypto_secretbox_ZEROBYTES < sizeof m;++mlen) { 17 | randombytes(k,crypto_secretbox_KEYBYTES); 18 | randombytes(n,crypto_secretbox_NONCEBYTES); 19 | randombytes(m + crypto_secretbox_ZEROBYTES,mlen); 20 | crypto_secretbox(c,m,mlen + crypto_secretbox_ZEROBYTES,n,k); 21 | if (crypto_secretbox_open(m2,c,mlen + crypto_secretbox_ZEROBYTES,n,k) == 0) { 22 | for (i = 0;i < mlen + crypto_secretbox_ZEROBYTES;++i) 23 | if (m2[i] != m[i]) { 24 | printf("bad decryption\n"); 25 | break; 26 | } 27 | } else { 28 | printf("ciphertext fails verification\n"); 29 | } 30 | } 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox7.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/secretbox7.out -------------------------------------------------------------------------------- /src/libnacl/tests/secretbox8.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/opendns/dnscrypt-proxy/314374d1c7b1c821274da4e47ba1223af007966e/src/libnacl/tests/secretbox8.out -------------------------------------------------------------------------------- /src/libnacl/tests/stream.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_stream_xsalsa20.h" 3 | #include "crypto_hash_sha256.h" 4 | 5 | unsigned char firstkey[32] = { 6 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 7 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 8 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 9 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 10 | } ; 11 | 12 | unsigned char nonce[24] = { 13 | 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73 14 | ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6 15 | ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 16 | } ; 17 | 18 | unsigned char output[4194304]; 19 | 20 | unsigned char h[32]; 21 | 22 | main() 23 | { 24 | int i; 25 | crypto_stream_xsalsa20(output,4194304,nonce,firstkey); 26 | crypto_hash_sha256(h,output,sizeof output); 27 | for (i = 0;i < 32;++i) printf("%02x",h[i]); printf("\n"); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream.out: -------------------------------------------------------------------------------- 1 | 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_stream_salsa20.h" 3 | #include "crypto_hash_sha256.h" 4 | 5 | unsigned char secondkey[32] = { 6 | 0xdc,0x90,0x8d,0xda,0x0b,0x93,0x44,0xa9 7 | ,0x53,0x62,0x9b,0x73,0x38,0x20,0x77,0x88 8 | ,0x80,0xf3,0xce,0xb4,0x21,0xbb,0x61,0xb9 9 | ,0x1c,0xbd,0x4c,0x3e,0x66,0x25,0x6c,0xe4 10 | } ; 11 | 12 | unsigned char noncesuffix[8] = { 13 | 0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 14 | } ; 15 | 16 | unsigned char output[4194304]; 17 | 18 | unsigned char h[32]; 19 | 20 | main() 21 | { 22 | int i; 23 | crypto_stream_salsa20(output,4194304,noncesuffix,secondkey); 24 | crypto_hash_sha256(h,output,sizeof output); 25 | for (i = 0;i < 32;++i) printf("%02x",h[i]); printf("\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream2.out: -------------------------------------------------------------------------------- 1 | 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream3.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "crypto_stream_xsalsa20.h" 3 | 4 | unsigned char firstkey[32] = { 5 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 6 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 7 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 8 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 9 | } ; 10 | 11 | unsigned char nonce[24] = { 12 | 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73 13 | ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6 14 | ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 15 | } ; 16 | 17 | unsigned char rs[32]; 18 | 19 | main() 20 | { 21 | int i; 22 | crypto_stream_xsalsa20(rs,32,nonce,firstkey); 23 | for (i = 0;i < 32;++i) { 24 | printf(",0x%02x",(unsigned int) rs[i]); 25 | if (i % 8 == 7) printf("\n"); 26 | } 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream3.out: -------------------------------------------------------------------------------- 1 | ,0xee,0xa6,0xa7,0x25,0x1c,0x1e,0x72,0x91 2 | ,0x6d,0x11,0xc2,0xcb,0x21,0x4d,0x3c,0x25 3 | ,0x25,0x39,0x12,0x1d,0x8e,0x23,0x4e,0x65 4 | ,0x2d,0x65,0x1f,0xa4,0xc8,0xcf,0xf8,0x80 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream4.out: -------------------------------------------------------------------------------- 1 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 2 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 3 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 4 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 5 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 6 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 7 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 8 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 9 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 10 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 11 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 12 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 13 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 14 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 15 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 16 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 17 | ,0xe3,0x55,0xa5 18 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream5.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_stream_xsalsa20.h" 5 | #include "crypto_hash_sha256.h" 6 | 7 | char firstkey_bytes[32] = { 8 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 9 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 10 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 11 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 12 | } ; 13 | 14 | char nonce_bytes[24] = { 15 | 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73 16 | ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6 17 | ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 18 | } ; 19 | 20 | main() 21 | { 22 | int i; 23 | string firstkey(firstkey_bytes,sizeof firstkey_bytes); 24 | string nonce(nonce_bytes,sizeof nonce_bytes); 25 | string output = crypto_stream_xsalsa20(4194304,nonce,firstkey); 26 | string h = crypto_hash_sha256(output); 27 | for (i = 0;i < 32;++i) printf("%02x",(unsigned int) (unsigned char) h[i]); printf("\n"); 28 | return 0; 29 | } 30 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream5.out: -------------------------------------------------------------------------------- 1 | 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream6.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_stream_salsa20.h" 5 | #include "crypto_hash_sha256.h" 6 | 7 | char secondkey_bytes[32] = { 8 | 0xdc,0x90,0x8d,0xda,0x0b,0x93,0x44,0xa9 9 | ,0x53,0x62,0x9b,0x73,0x38,0x20,0x77,0x88 10 | ,0x80,0xf3,0xce,0xb4,0x21,0xbb,0x61,0xb9 11 | ,0x1c,0xbd,0x4c,0x3e,0x66,0x25,0x6c,0xe4 12 | } ; 13 | 14 | char noncesuffix_bytes[8] = { 15 | 0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 16 | } ; 17 | 18 | main() 19 | { 20 | int i; 21 | string secondkey(secondkey_bytes,sizeof secondkey_bytes); 22 | string noncesuffix(noncesuffix_bytes,sizeof noncesuffix_bytes); 23 | string output = crypto_stream_salsa20(4194304,noncesuffix,secondkey); 24 | string h = crypto_hash_sha256(output); 25 | for (i = 0;i < 32;++i) printf("%02x",(unsigned int) (unsigned char) h[i]); printf("\n"); 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream6.out: -------------------------------------------------------------------------------- 1 | 662b9d0e3463029156069b12f918691a98f7dfb2ca0393c96bbfc6b1fbd630a2 2 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream7.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using std::string; 3 | #include 4 | #include "crypto_stream_xsalsa20.h" 5 | 6 | char firstkey_bytes[32] = { 7 | 0x1b,0x27,0x55,0x64,0x73,0xe9,0x85,0xd4 8 | ,0x62,0xcd,0x51,0x19,0x7a,0x9a,0x46,0xc7 9 | ,0x60,0x09,0x54,0x9e,0xac,0x64,0x74,0xf2 10 | ,0x06,0xc4,0xee,0x08,0x44,0xf6,0x83,0x89 11 | } ; 12 | 13 | char nonce_bytes[24] = { 14 | 0x69,0x69,0x6e,0xe9,0x55,0xb6,0x2b,0x73 15 | ,0xcd,0x62,0xbd,0xa8,0x75,0xfc,0x73,0xd6 16 | ,0x82,0x19,0xe0,0x03,0x6b,0x7a,0x0b,0x37 17 | } ; 18 | 19 | main() 20 | { 21 | int i; 22 | string firstkey(firstkey_bytes,sizeof firstkey_bytes); 23 | string nonce(nonce_bytes,sizeof nonce_bytes); 24 | string rs = crypto_stream_xsalsa20(32,nonce,firstkey); 25 | for (i = 0;i < rs.size();++i) { 26 | printf(",0x%02x",(unsigned int) (unsigned char) rs[i]); 27 | if (i % 8 == 7) printf("\n"); 28 | } 29 | return 0; 30 | } 31 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream7.out: -------------------------------------------------------------------------------- 1 | ,0xee,0xa6,0xa7,0x25,0x1c,0x1e,0x72,0x91 2 | ,0x6d,0x11,0xc2,0xcb,0x21,0x4d,0x3c,0x25 3 | ,0x25,0x39,0x12,0x1d,0x8e,0x23,0x4e,0x65 4 | ,0x2d,0x65,0x1f,0xa4,0xc8,0xcf,0xf8,0x80 5 | -------------------------------------------------------------------------------- /src/libnacl/tests/stream8.out: -------------------------------------------------------------------------------- 1 | ,0x8e,0x99,0x3b,0x9f,0x48,0x68,0x12,0x73 2 | ,0xc2,0x96,0x50,0xba,0x32,0xfc,0x76,0xce 3 | ,0x48,0x33,0x2e,0xa7,0x16,0x4d,0x96,0xa4 4 | ,0x47,0x6f,0xb8,0xc5,0x31,0xa1,0x18,0x6a 5 | ,0xc0,0xdf,0xc1,0x7c,0x98,0xdc,0xe8,0x7b 6 | ,0x4d,0xa7,0xf0,0x11,0xec,0x48,0xc9,0x72 7 | ,0x71,0xd2,0xc2,0x0f,0x9b,0x92,0x8f,0xe2 8 | ,0x27,0x0d,0x6f,0xb8,0x63,0xd5,0x17,0x38 9 | ,0xb4,0x8e,0xee,0xe3,0x14,0xa7,0xcc,0x8a 10 | ,0xb9,0x32,0x16,0x45,0x48,0xe5,0x26,0xae 11 | ,0x90,0x22,0x43,0x68,0x51,0x7a,0xcf,0xea 12 | ,0xbd,0x6b,0xb3,0x73,0x2b,0xc0,0xe9,0xda 13 | ,0x99,0x83,0x2b,0x61,0xca,0x01,0xb6,0xde 14 | ,0x56,0x24,0x4a,0x9e,0x88,0xd5,0xf9,0xb3 15 | ,0x79,0x73,0xf6,0x22,0xa4,0x3d,0x14,0xa6 16 | ,0x59,0x9b,0x1f,0x65,0x4c,0xb4,0x5a,0x74 17 | ,0xe3,0x55,0xa5 18 | -------------------------------------------------------------------------------- /src/libnacl/version: -------------------------------------------------------------------------------- 1 | 20110221 2 | -------------------------------------------------------------------------------- /src/libnacl/windows/include/windows-quirks.h: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | #ifdef _WIN32 5 | 6 | static void 7 | srandom(unsigned seed) 8 | { 9 | srand(seed); 10 | } 11 | 12 | static long 13 | random(void) 14 | { 15 | return (long) rand(); 16 | } 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/plugins/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = \ 3 | WARNING 4 | 5 | SUBDIRS = \ 6 | example \ 7 | example-logging 8 | 9 | if USE_LDNS 10 | SUBDIRS += \ 11 | example-ldns-aaaa-blocking \ 12 | example-ldns-blocking \ 13 | example-ldns-forward-after-nxdomain \ 14 | example-ldns-opendns-deviceid 15 | endif 16 | -------------------------------------------------------------------------------- /src/plugins/WARNING: -------------------------------------------------------------------------------- 1 | 2 | These plugins are just *examples*. 3 | 4 | They haven't been designed to be fast/reliable/secure. None of that, actually. 5 | 6 | Use them at your own risks. Or as a base for writing fantastic plugins. 7 | -------------------------------------------------------------------------------- /src/plugins/example-ldns-aaaa-blocking/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example_ldns_aaaa_blocking.la 4 | 5 | libdcplugin_example_ldns_aaaa_blocking_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_ldns_aaaa_blocking_la_SOURCES = \ 8 | example-ldns-aaaa-blocking.c 9 | 10 | libdcplugin_example_ldns_aaaa_blocking_la_LIBADD = @LDNS_LIBS@ 11 | 12 | libdcplugin_example_ldns_aaaa_blocking_la_LDFLAGS = \ 13 | $(AM_LDFLAGS) \ 14 | -avoid-version \ 15 | -export-dynamic \ 16 | -module \ 17 | -no-undefined 18 | 19 | libdcplugin_example_ldns_aaaa_blocking_la_CPPFLAGS = \ 20 | $(LTDLINCL) \ 21 | -I../../include 22 | -------------------------------------------------------------------------------- /src/plugins/example-ldns-blocking/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example_ldns_blocking.la 4 | 5 | libdcplugin_example_ldns_blocking_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_ldns_blocking_la_SOURCES = \ 8 | example-ldns-blocking.c 9 | 10 | libdcplugin_example_ldns_blocking_la_LIBADD = @LDNS_LIBS@ 11 | 12 | libdcplugin_example_ldns_blocking_la_LDFLAGS = \ 13 | $(AM_LDFLAGS) \ 14 | -avoid-version \ 15 | -export-dynamic \ 16 | -module \ 17 | -no-undefined 18 | 19 | libdcplugin_example_ldns_blocking_la_CPPFLAGS = \ 20 | $(LTDLINCL) \ 21 | -I../../include 22 | -------------------------------------------------------------------------------- /src/plugins/example-ldns-forward-after-nxdomain/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example_ldns_forward_after_nxdomain.la 4 | 5 | libdcplugin_example_ldns_forward_after_nxdomain_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_ldns_forward_after_nxdomain_la_SOURCES = \ 8 | example-ldns-forward-after-nxdomain.c 9 | 10 | libdcplugin_example_ldns_forward_after_nxdomain_la_LIBADD = @LDNS_LIBS@ 11 | 12 | libdcplugin_example_ldns_forward_after_nxdomain_la_LDFLAGS = \ 13 | $(AM_LDFLAGS) \ 14 | -avoid-version \ 15 | -export-dynamic \ 16 | -module \ 17 | -no-undefined 18 | 19 | libdcplugin_example_ldns_forward_after_nxdomain_la_CPPFLAGS = \ 20 | $(LTDLINCL) \ 21 | -I../../include 22 | -------------------------------------------------------------------------------- /src/plugins/example-ldns-opendns-deviceid/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example_ldns_opendns_deviceid.la 4 | 5 | libdcplugin_example_ldns_opendns_deviceid_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_ldns_opendns_deviceid_la_SOURCES = \ 8 | example-ldns-opendns-deviceid.c 9 | 10 | libdcplugin_example_ldns_opendns_deviceid_la_LIBADD = @LDNS_LIBS@ 11 | 12 | libdcplugin_example_ldns_opendns_deviceid_la_LDFLAGS = \ 13 | $(AM_LDFLAGS) \ 14 | -avoid-version \ 15 | -export-dynamic \ 16 | -module \ 17 | -no-undefined 18 | 19 | libdcplugin_example_ldns_opendns_deviceid_la_CPPFLAGS = \ 20 | $(LTDLINCL) \ 21 | -I../../include 22 | -------------------------------------------------------------------------------- /src/plugins/example-logging/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example_logging.la 4 | 5 | libdcplugin_example_logging_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_logging_la_SOURCES = \ 8 | example-logging.c 9 | 10 | libdcplugin_example_logging_la_LDFLAGS = \ 11 | $(AM_LDFLAGS) \ 12 | -avoid-version \ 13 | -export-dynamic \ 14 | -module \ 15 | -no-undefined 16 | 17 | libdcplugin_example_logging_la_CPPFLAGS = \ 18 | $(LTDLINCL) \ 19 | -I../../include 20 | -------------------------------------------------------------------------------- /src/plugins/example/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | pkglib_LTLIBRARIES = \ 3 | libdcplugin_example.la 4 | 5 | libdcplugin_example_la_LIBTOOLFLAGS = --tag=disable-static 6 | 7 | libdcplugin_example_la_SOURCES = \ 8 | example.c 9 | 10 | libdcplugin_example_la_LDFLAGS = \ 11 | $(AM_LDFLAGS) \ 12 | -avoid-version \ 13 | -export-dynamic \ 14 | -module \ 15 | -no-undefined 16 | 17 | libdcplugin_example_la_CPPFLAGS = \ 18 | $(LTDLINCL) \ 19 | -I../../include 20 | -------------------------------------------------------------------------------- /src/plugins/example/example.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | DCPLUGIN_MAIN(__FILE__); 5 | 6 | const char * 7 | dcplugin_description(DCPlugin * const dcplugin) 8 | { 9 | return "A sample (useless) plugin for dnscrypt-proxy"; 10 | } 11 | 12 | const char * 13 | dcplugin_long_description(DCPlugin * const dcplugin) 14 | { 15 | return 16 | "This is a sample plugin, that actually doesn't do anything.\n" 17 | "Really. That's the beauty of it."; 18 | } 19 | 20 | int 21 | dcplugin_init(DCPlugin * const dcplugin, int argc, char *argv[]) 22 | { 23 | return 0; 24 | } 25 | 26 | int 27 | dcplugin_destroy(DCPlugin * const dcplugin) 28 | { 29 | return 0; 30 | } 31 | 32 | DCPluginSyncFilterResult 33 | dcplugin_sync_pre_filter(DCPlugin *dcplugin, DCPluginDNSPacket *dcp_packet) 34 | { 35 | return DCP_SYNC_FILTER_RESULT_OK; 36 | } 37 | 38 | DCPluginSyncFilterResult 39 | dcplugin_sync_post_filter(DCPlugin *dcplugin, DCPluginDNSPacket *dcp_packet) 40 | { 41 | return DCP_SYNC_FILTER_RESULT_OK; 42 | } 43 | -------------------------------------------------------------------------------- /src/proxy/app.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __APP_H__ 3 | #define __APP_H__ 1 4 | 5 | #include 6 | #ifdef PLUGINS 7 | # include "plugin_support.h" 8 | #endif 9 | 10 | #ifdef NDEBUG 11 | # error Assertions should be turned on. Always. 12 | #endif 13 | 14 | typedef struct AppContext_ { 15 | struct ProxyContext_ *proxy_context; 16 | #ifdef PLUGINS 17 | DCPluginSupportContext *dcps_context; 18 | #endif 19 | } AppContext; 20 | 21 | int dnscrypt_proxy_main(int argc, char *argv[]); 22 | int dnscrypt_proxy_loop_break(void); 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /src/proxy/cert.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CERT_H__ 3 | #define __CERT_H__ 1 4 | 5 | #include 6 | #include 7 | 8 | #define CERT_QUERY_RETRY_MIN_DELAY 1 9 | #define CERT_QUERY_RETRY_MAX_DELAY (5 * 60) 10 | #define CERT_QUERY_RETRY_STEPS 100 11 | #define CERT_QUERY_RETRY_DELAY_AFTER_SUCCESS_MIN_DELAY (60 * 60) 12 | #define CERT_QUERY_RETRY_DELAY_AFTER_SUCCESS_JITTER 100 13 | 14 | typedef struct CertUpdater_ { 15 | struct evdns_base *evdns_base; 16 | struct event *cert_timer; 17 | unsigned int query_retry_step; 18 | } CertUpdater; 19 | 20 | struct ProxyContext_; 21 | int cert_updater_init(struct ProxyContext_ * const proxy_context); 22 | int cert_updater_start(struct ProxyContext_ * const proxy_context); 23 | void cert_updater_stop(struct ProxyContext_ * const proxy_context); 24 | void cert_updater_free(struct ProxyContext_ * const proxy_context); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/proxy/cert_p.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __CERT_P_H__ 3 | #define __CERT_P_H__ 1 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "crypto_box.h" 10 | 11 | #define CERT_MAGIC_CERT "DNSC" 12 | 13 | typedef struct Bincert_ { 14 | uint8_t magic_cert[4]; 15 | uint8_t version_major[2]; 16 | uint8_t version_minor[2]; 17 | 18 | uint8_t server_publickey[crypto_box_PUBLICKEYBYTES]; 19 | uint8_t magic_query[8]; 20 | uint8_t serial[4]; 21 | uint8_t ts_begin[4]; 22 | uint8_t ts_end[4]; 23 | uint8_t end[]; 24 | } Bincert; 25 | 26 | typedef struct SignedBincert_ { 27 | uint8_t magic_cert[4]; 28 | uint8_t version_major[2]; 29 | uint8_t version_minor[2]; 30 | 31 | uint8_t signed_data[]; 32 | } SignedBincert; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/proxy/edns.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __EDNS_H__ 3 | #define __EDNS_H__ 1 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include "dnscrypt_proxy.h" 11 | 12 | int edns_add_section(ProxyContext * const proxy_context, 13 | uint8_t * const dns_packet, 14 | size_t * const dns_packet_len_p, 15 | size_t dns_packet_max_size, 16 | size_t * const request_edns_payload_size); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/proxy/getpwnam.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __GETPWNAM_H__ 3 | #define __GETPWNAM_H__ 1 4 | 5 | #include 6 | #include 7 | 8 | #ifdef HAVE_PWD_H 9 | # include 10 | # ifdef HAVE_UUID_UUID_H 11 | # include 12 | # endif 13 | 14 | #elif defined(HAVE_GETPWNAM) 15 | 16 | # include 17 | # ifdef HAVE_UUID_UUID_H 18 | # include 19 | # endif 20 | 21 | struct passwd { 22 | char *pw_name; 23 | char *pw_passwd; 24 | uid_t pw_uid; 25 | gid_t pw_gid; 26 | time_t pw_change; 27 | char *pw_class; 28 | char *pw_gecos; 29 | char *pw_dir; 30 | char *pw_shell; 31 | time_t pw_expire; 32 | }; 33 | struct passwd *getpwnam(const char *); 34 | 35 | #endif 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /src/proxy/options.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __OPTIONS_H__ 3 | #define __OPTIONS_H__ 1 4 | 5 | int options_parse(AppContext * const app_context, 6 | ProxyContext * const proxy_context, int argc, char *argv[]); 7 | 8 | void options_free(ProxyContext * const proxy_context); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/proxy/pathnames.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PATHNAMES_H__ 3 | #define __PATHNAMES_H__ 1 4 | 5 | #ifdef HAVE_PATHS_H 6 | # include 7 | #endif 8 | 9 | #ifndef _PATH_DEVNULL 10 | # define _PATH_DEVNULL "/dev/null" 11 | #endif 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/proxy/pid_file.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PID_FILE_H__ 3 | #define __PID_FILE_H__ 1 4 | 5 | int pid_file_create(const char * const pid_file, const _Bool will_chroot); 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/proxy/plugin_options.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "plugin_options.h" 10 | #include "plugin_support.h" 11 | 12 | int 13 | plugin_options_parse_str(DCPluginSupportContext * const dcps_context, 14 | char * const str) 15 | { 16 | DCPluginSupport *dcps = NULL; 17 | char *arg; 18 | char *plugin_file; 19 | char *tmp; 20 | 21 | assert(dcps_context != NULL); 22 | assert(str != NULL); 23 | if (*(plugin_file = str) == 0) { 24 | return -1; 25 | } 26 | arg = str; 27 | while (arg != NULL) { 28 | if ((tmp = strchr(arg, ',')) != NULL) { 29 | *tmp++ = 0; 30 | } 31 | if (dcps == NULL && (dcps = plugin_support_new(plugin_file)) == NULL) { 32 | return -1; 33 | } 34 | if (plugin_support_add_option(dcps, arg) != 0) { 35 | return -1; 36 | } 37 | arg = tmp; 38 | } 39 | return plugin_support_context_insert(dcps_context, dcps); 40 | } 41 | -------------------------------------------------------------------------------- /src/proxy/plugin_options.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PLUGIN_OPTIONS_H__ 3 | #define __PLUGIN_OPTIONS_H__ 1 4 | 5 | #include "plugin_support.h" 6 | 7 | int plugin_options_parse_str(DCPluginSupportContext *dpcs_context, 8 | char * const str); 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /src/proxy/plugin_support_p.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __PLUGIN_SUPPORT_P_H__ 3 | #define __PLUGIN_SUPPORT_P_H__ 1 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include "queue.h" 10 | 11 | typedef int (*DCPluginInit)(DCPlugin * const dcplugin, int argc, char *argv[]); 12 | typedef int (*DCPluginDestroy)(DCPlugin * const dcplugin); 13 | typedef const char *(*DCPluginDescription)(DCPlugin * const dcplugin); 14 | 15 | typedef DCPluginSyncFilterResult (*DCPluginSyncFilter) 16 | (DCPlugin * const dcplugin, DCPluginDNSPacket *dcp_packet); 17 | 18 | struct DCPluginSupport_ { 19 | SLIST_ENTRY(DCPluginSupport_) next; 20 | DCPluginSyncFilter sync_post_filter; 21 | DCPluginSyncFilter sync_pre_filter; 22 | lt_dlhandle handle; 23 | DCPlugin *plugin; 24 | char *plugin_file; 25 | char **argv; 26 | int argc; 27 | }; 28 | 29 | struct DCPluginSupportContext_ { 30 | SLIST_HEAD(DCPluginSupportList_, DCPluginSupport_) dcps_list; 31 | _Bool lt_enabled; 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /src/proxy/safe_rw.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SAFE_RW_H__ 3 | #define __SAFE_RW_H__ 1 4 | 5 | #include 6 | 7 | ssize_t safe_write(const int fd, const void * const buf_, size_t count, 8 | const int timeout); 9 | 10 | ssize_t safe_read(const int fd, void * const buf_, size_t count); 11 | 12 | ssize_t safe_read_partial(const int fd, void * const buf_, 13 | const size_t max_count); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/proxy/salsa20_random.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SALSA20_RANDOM_H__ 3 | #define __SALSA20_RANDOM_H__ 1 4 | 5 | #include 6 | #include 7 | 8 | uint32_t salsa20_random(void); 9 | void salsa20_random_stir(void); 10 | uint32_t salsa20_random_uniform(const uint32_t upper_bound); 11 | void salsa20_random_buf(void * const buf, const size_t size); 12 | int salsa20_random_close(void); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /src/proxy/sandboxes.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | 6 | #ifdef HAVE_SANDBOX_H 7 | # pragma GCC diagnostic ignored "-Wdeprecated-declarations" 8 | # include 9 | #endif 10 | 11 | #include "sandboxes.h" 12 | 13 | int 14 | sandboxes_app(void) 15 | { 16 | return 0; 17 | } 18 | 19 | int 20 | sandboxes_pidproc(void) 21 | { 22 | #ifdef HAVE_SANDBOX_INIT 23 | char *errmsg; 24 | 25 | if (sandbox_init != NULL && 26 | sandbox_init(kSBXProfileNoNetwork, SANDBOX_NAMED, &errmsg) != 0) { 27 | return -1; 28 | } 29 | #endif 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /src/proxy/sandboxes.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __SANDBOXES_H__ 3 | #define __SANDBOXES_H__ 1 4 | 5 | int sandboxes_app(void); 6 | int sandboxes_pidproc(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/proxy/stack_trace.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __STACK_TRACE_H__ 3 | #define __STACK_TRACE_H__ 1 4 | 5 | void stack_trace(void); 6 | int stack_trace_on_crash(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /src/proxy/tcp_request.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCP_REQUEST_H__ 3 | #define __TCP_REQUEST_H__ 1 4 | 5 | #include "dnscrypt_proxy.h" 6 | 7 | #define DNS_MAX_PACKET_SIZE_TCP (65535U + 2U) 8 | 9 | #ifndef TCP_REQUEST_BACKLOG 10 | # define TCP_REQUEST_BACKLOG 128 11 | #endif 12 | 13 | int tcp_listener_bind(ProxyContext * const proxy_context); 14 | int tcp_listener_start(ProxyContext * const proxy_context); 15 | void tcp_listener_stop(ProxyContext * const proxy_context); 16 | int tcp_listener_kill_oldest_request(ProxyContext * const proxy_context); 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /src/proxy/tcp_request_p.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __TCP_REQUEST_H_P__ 3 | #define __TCP_REQUEST_H_P__ 1 4 | 5 | #include 6 | 7 | #include 8 | 9 | #include 10 | 11 | #include "dnscrypt.h" 12 | #include "queue.h" 13 | 14 | typedef struct TCPRequestStatus_ { 15 | _Bool has_dns_query_len : 1; 16 | _Bool has_dns_reply_len : 1; 17 | _Bool is_in_queue : 1; 18 | _Bool is_dying : 1; 19 | } TCPRequestStatus; 20 | 21 | typedef struct TCPRequest_ { 22 | uint8_t client_nonce[crypto_box_HALF_NONCEBYTES]; 23 | TAILQ_ENTRY(TCPRequest_) queue; 24 | #ifdef PLUGINS 25 | struct sockaddr_storage client_sockaddr; 26 | #endif 27 | struct bufferevent *client_proxy_bev; 28 | struct bufferevent *proxy_resolver_bev; 29 | struct evbuffer *proxy_resolver_query_evbuf; 30 | ProxyContext *proxy_context; 31 | struct event *timeout_timer; 32 | #ifdef PLUGINS 33 | ev_socklen_t client_sockaddr_len; 34 | #endif 35 | TCPRequestStatus status; 36 | size_t dns_query_len; 37 | size_t dns_reply_len; 38 | } TCPRequest; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /src/proxy/udp_request.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __UDP_REQUEST_H__ 3 | #define __UDP_REQUEST_H__ 1 4 | 5 | #include "dnscrypt_proxy.h" 6 | 7 | #ifndef UDP_BUFFER_SIZE 8 | # define UDP_BUFFER_SIZE 2097152 9 | #endif 10 | #ifndef UDP_DELAY_BETWEEN_RETRIES 11 | # define UDP_DELAY_BETWEEN_RETRIES 1 12 | #endif 13 | 14 | int udp_listener_bind(ProxyContext * const proxy_context); 15 | int udp_listener_start(ProxyContext * const proxy_context); 16 | void udp_listener_stop(ProxyContext * const proxy_context); 17 | int udp_listener_kill_oldest_request(ProxyContext * const proxy_context); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/proxy/utils.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __UTILS_H__ 3 | #define __UTILS_H__ 1 4 | 5 | #include 6 | #include 7 | 8 | #define COMPILER_ASSERT(X) (void) sizeof(char[(X) ? 1 : -1]) 9 | 10 | void dnscrypt_memzero(void * const pnt, const size_t size); 11 | uint64_t dnscrypt_hrtime(void); 12 | int closedesc_all(const int closestdin); 13 | int do_daemonize(void); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /src/proxy/windows_service.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef __WINDOWS_SERVICE_H__ 3 | #define __WINDOWS_SERVICE_H__ 1 4 | 5 | typedef enum WinOption_ { 6 | WIN_OPTION_INSTALL = 256, 7 | WIN_OPTION_REINSTALL, 8 | WIN_OPTION_UNINSTALL 9 | } WinOption; 10 | 11 | int windows_service_option(const int opt_flag, 12 | const int argc, const char *argv[]); 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /test/Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | gem 'aruba' 3 | gem 'cucumber' 4 | gem 'net-dns' 5 | -------------------------------------------------------------------------------- /test/Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: http://rubygems.org/ 3 | specs: 4 | aruba (0.4.11) 5 | childprocess (>= 0.2.3) 6 | cucumber (>= 1.1.1) 7 | ffi (>= 1.0.11) 8 | rspec (>= 2.7.0) 9 | builder (3.0.0) 10 | childprocess (0.3.3) 11 | ffi (~> 1.0.6) 12 | cucumber (1.2.1) 13 | builder (>= 2.1.2) 14 | diff-lcs (>= 1.1.3) 15 | gherkin (~> 2.11.0) 16 | json (>= 1.4.6) 17 | diff-lcs (1.1.3) 18 | ffi (1.0.11) 19 | gherkin (2.11.1) 20 | json (>= 1.4.6) 21 | json (1.7.3) 22 | net-dns (0.7.1) 23 | rspec (2.11.0) 24 | rspec-core (~> 2.11.0) 25 | rspec-expectations (~> 2.11.0) 26 | rspec-mocks (~> 2.11.0) 27 | rspec-core (2.11.0) 28 | rspec-expectations (2.11.1) 29 | diff-lcs (~> 1.1.3) 30 | rspec-mocks (2.11.1) 31 | 32 | PLATFORMS 33 | ruby 34 | 35 | DEPENDENCIES 36 | aruba 37 | cucumber 38 | net-dns 39 | -------------------------------------------------------------------------------- /test/Makefile.in: -------------------------------------------------------------------------------- 1 | 2 | all: 3 | 4 | test: 5 | rake cucumber 6 | 7 | clean: 8 | distclean: 9 | install: 10 | install-data: 11 | install-exec: 12 | uninstall: 13 | install-dvi: 14 | install-html: 15 | install-info: 16 | install-ps: 17 | install-pdf: 18 | installdirs: 19 | check: 20 | installcheck: 21 | mostlyclean: clean 22 | maintainer-clean: distclean 23 | 24 | distdir: 25 | while read dir ; do @MKDIR_P@ "$(distdir)/$$dir" ; done < dist-dirs 26 | while read file ; do @INSTALL@ "$$file" "$(distdir)/$$file" ; done < dist-files 27 | 28 | EMPTY_AUTOMAKE_TARGETS = dvi pdf ps info html tags ctags 29 | .PHONY: $(EMPTY_AUTOMAKE_TARGETS) 30 | $(EMPTY_AUTOMAKE_TARGETS): 31 | -------------------------------------------------------------------------------- /test/Rakefile: -------------------------------------------------------------------------------- 1 | require 'cucumber' 2 | require 'cucumber/rake/task' 3 | require 'rake/clean' 4 | 5 | Cucumber::Rake::Task.new 6 | 7 | task :default => [:cucumber] 8 | -------------------------------------------------------------------------------- /test/dist-dirs: -------------------------------------------------------------------------------- 1 | . 2 | ./features 3 | ./features/step_definitions 4 | ./features/support 5 | ./features/test-dnscrypt-proxy 6 | ./features/test-hostip 7 | -------------------------------------------------------------------------------- /test/dist-files: -------------------------------------------------------------------------------- 1 | ./dist-dirs 2 | ./dist-files 3 | ./features/step_definitions/dnscrypt-proxy.rb 4 | ./features/step_definitions/opendnscache.rb 5 | ./features/support/env.rb 6 | ./features/test-dnscrypt-proxy/forced_tcp.feature 7 | ./features/test-dnscrypt-proxy/help.feature 8 | ./features/test-dnscrypt-proxy/small_udp_query.feature 9 | ./features/test-dnscrypt-proxy/tcp_fallback.feature 10 | ./features/test-hostip/help.feature 11 | ./features/test-hostip/resolve-specific.feature 12 | ./features/test-hostip/resolve.feature 13 | ./Gemfile 14 | ./Gemfile.lock 15 | ./Makefile.in 16 | ./Rakefile 17 | -------------------------------------------------------------------------------- /test/features/step_definitions/dnscrypt-proxy.rb: -------------------------------------------------------------------------------- 1 | 2 | require 'net/dns/resolver' 3 | 4 | PROXY_IP = '127.0.0.1' 5 | PROXY_PORT = 5300 6 | 7 | Before do 8 | @resolver = Net::DNS::Resolver.new(nameserver: PROXY_IP, port: PROXY_PORT) 9 | end 10 | 11 | After do 12 | Process.kill("KILL", @pipe.pid) if @pipe 13 | @pipe = nil 14 | end 15 | 16 | Around do |scenario, block| 17 | Timeout.timeout(3.0) do 18 | block.call 19 | end 20 | end 21 | 22 | Given /^a running dnscrypt proxy with options "([^"]*)"$/ do |options| 23 | @pipe = IO.popen("dnscrypt-proxy " + 24 | "--local-address=#{PROXY_IP}:#{PROXY_PORT} $#{options}", "r") 25 | sleep(1.5) 26 | end 27 | 28 | When /^a client asks dnscrypt\-proxy for "([^"]*)"$/ do |name| 29 | @answer_section = @resolver.query(name, Net::DNS::A).answer 30 | end 31 | 32 | Then /^dnscrypt\-proxy returns "([^"]*)"$/ do |ip_for_name| 33 | @answer_section.collect { |a| a.address.to_s }.should include(ip_for_name) 34 | end 35 | 36 | Then /^dnscrypt\-proxy returns a NXDOMAIN answer$/ do 37 | @answer_section.should be_empty 38 | end 39 | -------------------------------------------------------------------------------- /test/features/step_definitions/opendnscache.rb: -------------------------------------------------------------------------------- 1 | 2 | require 'net/dns/resolver' 3 | 4 | Given /^a working opendnscache on (\d+\.\d+\.\d+\.\d+)$/ do |resolver| 5 | resolver = Net::DNS::Resolver.new(nameserver: resolver) 6 | 7 | answer_section = resolver.query('resolver1.opendns.com', Net::DNS::A).answer 8 | answer_section.first.address.to_s.should eq('208.67.222.222') 9 | 10 | answer_section = resolver.query('resolver2.opendns.com', Net::DNS::A).answer 11 | answer_section.first.address.to_s.should eq('208.67.220.220') 12 | 13 | answer_section = resolver.query('debug.opendns.com', Net::DNS::TXT).answer 14 | answer_section.should_not be_empty 15 | end 16 | 17 | -------------------------------------------------------------------------------- /test/features/support/env.rb: -------------------------------------------------------------------------------- 1 | require 'aruba/cucumber' 2 | require 'net/dns' 3 | ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../../src/dnscrypt-proxy')}#{File::PATH_SEPARATOR}#{ENV['PATH']}" 4 | -------------------------------------------------------------------------------- /test/features/test-dnscrypt-proxy/forced_tcp.feature: -------------------------------------------------------------------------------- 1 | Feature: check that --tcp-only works as advertised. 2 | 3 | A query sent using UDP should, when the proxy is running with 4 | --tcp-only, return a truncated reply so that the client retries using 5 | TCP. 6 | 7 | Scenario: query an existing name over UDP, and even though this name 8 | would fit in a 512-bytes UDP packet, expect a forced fallback to TCP. 9 | 10 | Given a working opendnscache on 208.67.220.220 11 | And a running dnscrypt proxy with options "--edns-payload-size=4096 --tcp-only" 12 | When a client asks dnscrypt-proxy for "resolver1.opendns.com" 13 | Then dnscrypt-proxy returns "208.67.222.222" 14 | -------------------------------------------------------------------------------- /test/features/test-dnscrypt-proxy/help.feature: -------------------------------------------------------------------------------- 1 | Feature: Show help and version for dnscrypt-proxy 2 | 3 | Display the help when the -h switch is given. 4 | 5 | Scenario: start with the -h switch. 6 | 7 | When I run `dnscrypt-proxy -h` 8 | Then the output should contain: 9 | """ 10 | Options: 11 | """ 12 | And the exit status should be 0 13 | 14 | Scenario: start with the --help switch 15 | 16 | When I run `dnscrypt-proxy --help` 17 | Then the output should contain: 18 | """ 19 | Options: 20 | """ 21 | And the exit status should be 0 22 | 23 | Scenario: start with a nonexistent switch 24 | 25 | When I run `dnscrypt-proxy -%` 26 | Then the output should contain: 27 | """ 28 | Options: 29 | """ 30 | And the exit status should be 1 31 | 32 | Scenario: start the -V switch 33 | 34 | When I run `dnscrypt-proxy -V` 35 | Then the output should contain: 36 | """ 37 | dnscrypt-proxy 38 | """ 39 | And the output should not contain: 40 | """ 41 | Options 42 | """ 43 | And the exit status should be 0 44 | -------------------------------------------------------------------------------- /test/features/test-dnscrypt-proxy/small_udp_query.feature: -------------------------------------------------------------------------------- 1 | Feature: Small UDP query 2 | 3 | A query that fits in a small UDP packet. 4 | 5 | Scenario: query an existing name. 6 | 7 | Given a working opendnscache on 208.67.220.220 8 | And a running dnscrypt proxy with options "--edns-payload-size=0" 9 | When a client asks dnscrypt-proxy for "resolver1.opendns.com" 10 | Then dnscrypt-proxy returns "208.67.222.222" 11 | 12 | Scenario: query a nonexistent name. 13 | 14 | Given a working opendnscache on 208.67.220.220 15 | And a running dnscrypt proxy with options "--edns-payload-size=0" 16 | When a client asks dnscrypt-proxy for "nonexistent.opendns.com" 17 | Then dnscrypt-proxy returns a NXDOMAIN answer 18 | -------------------------------------------------------------------------------- /test/features/test-dnscrypt-proxy/tcp_fallback.feature: -------------------------------------------------------------------------------- 1 | Feature: fallback to TCP 2 | 3 | A query that doesn't fit in a small UDP packet should make the proxy 4 | send a truncated reply, then the stud resolver should retry with TCP 5 | and the proxy should handle TCP just fine. 6 | 7 | Scenario: query an existing name over UDP, expect fallback to TCP. 8 | 9 | Given a working opendnscache on 208.67.220.220 10 | And a running dnscrypt proxy with options "--edns-payload-size=0" 11 | When a client asks dnscrypt-proxy for "test-tcp.stdc.org" 12 | Then dnscrypt-proxy returns "127.0.0.1" 13 | -------------------------------------------------------------------------------- /test/features/test-hostip/help.feature: -------------------------------------------------------------------------------- 1 | Feature: Show help and version for the hostip utility 2 | 3 | Display the help when the -h switch is given. 4 | 5 | Scenario: start with the -h switch. 6 | 7 | When I run `hostip -h` 8 | Then the output should contain: 9 | """ 10 | Usage: 11 | """ 12 | And the exit status should be 0 13 | 14 | Scenario: start with the --help switch 15 | 16 | When I run `hostip --help` 17 | Then the output should contain: 18 | """ 19 | Usage: 20 | """ 21 | And the exit status should be 0 22 | 23 | Scenario: start with a nonexistent switch 24 | 25 | When I run `hostip -%` 26 | Then the output should contain: 27 | """ 28 | Usage: 29 | """ 30 | And the exit status should be 1 31 | 32 | Scenario: start the -V switch 33 | 34 | When I run `hostip -V` 35 | Then the output should contain: 36 | """ 37 | hostip 38 | """ 39 | And the output should not contain: 40 | """ 41 | Usage 42 | """ 43 | And the exit status should be 0 44 | -------------------------------------------------------------------------------- /test/features/test-hostip/resolve.feature: -------------------------------------------------------------------------------- 1 | Feature: See if hostip can resolve names 2 | 3 | Resolve names with the hostip utility. 4 | 5 | Scenario: resolve resolver1.opendns.com 6 | 7 | When I run `hostip resolver1.opendns.com` 8 | Then the output should contain exactly: 9 | """ 10 | 208.67.222.222 11 | 12 | """ 13 | And the exit status should be 0 14 | 15 | Scenario: resolve IPv6 address for www.opendns.com 16 | 17 | When I run `hostip -6 www.opendns.com` 18 | Then the output should contain exactly: 19 | """ 20 | 2620:0:cc1:115::210 21 | 22 | """ 23 | And the exit status should be 0 24 | 25 | Scenario: resolve a nonexistent name 26 | 27 | When I run `hostip nonexistent.local` 28 | Then the output should contain exactly: 29 | """ 30 | [name does not exist] 31 | 32 | """ 33 | And the exit status should be 1 34 | 35 | Scenario: resolve a nonexistent IPv6 name 36 | 37 | When I run `hostip -6 nonexistent.local` 38 | Then the output should contain exactly: 39 | """ 40 | [name does not exist] 41 | 42 | """ 43 | And the exit status should be 1 44 | --------------------------------------------------------------------------------