spiped 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/ext/spiped/extconf.rb +3 -0
  3. data/ext/spiped/spiped-source/BUILDING +46 -0
  4. data/ext/spiped/spiped-source/CHANGELOG +44 -0
  5. data/ext/spiped/spiped-source/COPYRIGHT +33 -0
  6. data/ext/spiped/spiped-source/Makefile +47 -0
  7. data/ext/spiped/spiped-source/Makefile.POSIX +27 -0
  8. data/ext/spiped/spiped-source/Makefile.inc +20 -0
  9. data/ext/spiped/spiped-source/Makefile.prog +23 -0
  10. data/ext/spiped/spiped-source/POSIX/README +10 -0
  11. data/ext/spiped/spiped-source/POSIX/posix-cflags.sh +10 -0
  12. data/ext/spiped/spiped-source/POSIX/posix-clock_realtime.c +3 -0
  13. data/ext/spiped/spiped-source/POSIX/posix-l.c +1 -0
  14. data/ext/spiped/spiped-source/POSIX/posix-l.sh +14 -0
  15. data/ext/spiped/spiped-source/POSIX/posix-msg_nosignal.c +3 -0
  16. data/ext/spiped/spiped-source/README +198 -0
  17. data/ext/spiped/spiped-source/STYLE +151 -0
  18. data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.c +464 -0
  19. data/ext/spiped/spiped-source/lib/dnsthread/dnsthread.h +45 -0
  20. data/ext/spiped/spiped-source/libcperciva/alg/sha256.c +442 -0
  21. data/ext/spiped/spiped-source/libcperciva/alg/sha256.h +95 -0
  22. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-AESNI.c +13 -0
  23. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport-X86-CPUID.c +8 -0
  24. data/ext/spiped/spiped-source/libcperciva/cpusupport/Build/cpusupport.sh +37 -0
  25. data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport.h +63 -0
  26. data/ext/spiped/spiped-source/libcperciva/cpusupport/cpusupport_x86_aesni.c +30 -0
  27. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.c +166 -0
  28. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes.h +31 -0
  29. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.c +229 -0
  30. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aes_aesni.h +31 -0
  31. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.c +124 -0
  32. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_aesctr.h +41 -0
  33. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.c +293 -0
  34. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh.h +43 -0
  35. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.c +46 -0
  36. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_dh_group14.h +9 -0
  37. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.c +215 -0
  38. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_entropy.h +14 -0
  39. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.c +21 -0
  40. data/ext/spiped/spiped-source/libcperciva/crypto/crypto_verify_bytes.h +14 -0
  41. data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.c +276 -0
  42. data/ext/spiped/spiped-source/libcperciva/datastruct/elasticarray.h +167 -0
  43. data/ext/spiped/spiped-source/libcperciva/datastruct/mpool.h +85 -0
  44. data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.c +334 -0
  45. data/ext/spiped/spiped-source/libcperciva/datastruct/ptrheap.h +89 -0
  46. data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.c +241 -0
  47. data/ext/spiped/spiped-source/libcperciva/datastruct/timerqueue.h +60 -0
  48. data/ext/spiped/spiped-source/libcperciva/events/events.c +203 -0
  49. data/ext/spiped/spiped-source/libcperciva/events/events.h +106 -0
  50. data/ext/spiped/spiped-source/libcperciva/events/events_immediate.c +149 -0
  51. data/ext/spiped/spiped-source/libcperciva/events/events_internal.h +95 -0
  52. data/ext/spiped/spiped-source/libcperciva/events/events_network.c +347 -0
  53. data/ext/spiped/spiped-source/libcperciva/events/events_network_selectstats.c +106 -0
  54. data/ext/spiped/spiped-source/libcperciva/events/events_timer.c +273 -0
  55. data/ext/spiped/spiped-source/libcperciva/network/network.h +95 -0
  56. data/ext/spiped/spiped-source/libcperciva/network/network_accept.c +103 -0
  57. data/ext/spiped/spiped-source/libcperciva/network/network_connect.c +258 -0
  58. data/ext/spiped/spiped-source/libcperciva/network/network_read.c +155 -0
  59. data/ext/spiped/spiped-source/libcperciva/network/network_write.c +188 -0
  60. data/ext/spiped/spiped-source/libcperciva/util/asprintf.c +49 -0
  61. data/ext/spiped/spiped-source/libcperciva/util/asprintf.h +16 -0
  62. data/ext/spiped/spiped-source/libcperciva/util/daemonize.c +134 -0
  63. data/ext/spiped/spiped-source/libcperciva/util/daemonize.h +10 -0
  64. data/ext/spiped/spiped-source/libcperciva/util/entropy.c +76 -0
  65. data/ext/spiped/spiped-source/libcperciva/util/entropy.h +13 -0
  66. data/ext/spiped/spiped-source/libcperciva/util/imalloc.h +33 -0
  67. data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.c +19 -0
  68. data/ext/spiped/spiped-source/libcperciva/util/insecure_memzero.h +33 -0
  69. data/ext/spiped/spiped-source/libcperciva/util/monoclock.c +52 -0
  70. data/ext/spiped/spiped-source/libcperciva/util/monoclock.h +14 -0
  71. data/ext/spiped/spiped-source/libcperciva/util/noeintr.c +54 -0
  72. data/ext/spiped/spiped-source/libcperciva/util/noeintr.h +14 -0
  73. data/ext/spiped/spiped-source/libcperciva/util/sock.c +472 -0
  74. data/ext/spiped/spiped-source/libcperciva/util/sock.h +56 -0
  75. data/ext/spiped/spiped-source/libcperciva/util/sock_internal.h +14 -0
  76. data/ext/spiped/spiped-source/libcperciva/util/sock_util.c +271 -0
  77. data/ext/spiped/spiped-source/libcperciva/util/sock_util.h +51 -0
  78. data/ext/spiped/spiped-source/libcperciva/util/sysendian.h +146 -0
  79. data/ext/spiped/spiped-source/libcperciva/util/warnp.c +76 -0
  80. data/ext/spiped/spiped-source/libcperciva/util/warnp.h +59 -0
  81. data/ext/spiped/spiped-source/proto/proto_conn.c +362 -0
  82. data/ext/spiped/spiped-source/proto/proto_conn.h +25 -0
  83. data/ext/spiped/spiped-source/proto/proto_crypt.c +396 -0
  84. data/ext/spiped/spiped-source/proto/proto_crypt.h +102 -0
  85. data/ext/spiped/spiped-source/proto/proto_handshake.c +330 -0
  86. data/ext/spiped/spiped-source/proto/proto_handshake.h +30 -0
  87. data/ext/spiped/spiped-source/proto/proto_pipe.c +202 -0
  88. data/ext/spiped/spiped-source/proto/proto_pipe.h +23 -0
  89. data/ext/spiped/spiped-source/spipe/Makefile +90 -0
  90. data/ext/spiped/spiped-source/spipe/README +24 -0
  91. data/ext/spiped/spiped-source/spipe/main.c +178 -0
  92. data/ext/spiped/spiped-source/spipe/pushbits.c +101 -0
  93. data/ext/spiped/spiped-source/spipe/pushbits.h +10 -0
  94. data/ext/spiped/spiped-source/spipe/spipe.1 +60 -0
  95. data/ext/spiped/spiped-source/spiped/Makefile +98 -0
  96. data/ext/spiped/spiped-source/spiped/README +62 -0
  97. data/ext/spiped/spiped-source/spiped/dispatch.c +214 -0
  98. data/ext/spiped/spiped-source/spiped/dispatch.h +27 -0
  99. data/ext/spiped/spiped-source/spiped/main.c +267 -0
  100. data/ext/spiped/spiped-source/spiped/spiped.1 +112 -0
  101. data/lib/spiped.rb +3 -0
  102. metadata +143 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 27b671f86f19d8400b9f28f1e43394f0290e74f6
4
+ data.tar.gz: 81725ffc4e73f64e08b250c35b304c181430fc22
5
+ SHA512:
6
+ metadata.gz: 966032c8cbcfdaa3c67950c1c7fd53eeb30a54c627c1f177e57f526e2ec1a157bdbcf4708a2c29187e76ff586633614c841b416fc6f02e5dfb331b307905eb57
7
+ data.tar.gz: 236fdf9e640e837bb7e99a7b3b7c4c4dcdb9538140d3338a14220e4a0a5505d8f99085645750538c3393a23305b7183012ef70741ab75ac9946b6b362ebe4b91
@@ -0,0 +1,3 @@
1
+ system "cp -R spiped-source/* ./"
2
+
3
+
@@ -0,0 +1,46 @@
1
+ To build and install spiped, run:
2
+ # make BINDIR=/path/to/target/directory install
3
+
4
+ To install man pages, add MAN1DIR=/path/to/man.1/directory to the command
5
+ line (e.g., MAN1DIR=/usr/local/man/man1 on FreeBSD).
6
+
7
+ Spiped should build and run on any IEEE Std 1003.1 (POSIX) compliant
8
+ system which
9
+ 1. Includes the Software Development Utilities option,
10
+ 2. Has OpenSSL available via -lcrypto and #include <openssl/foo>, and
11
+ 3. Provides /dev/urandom.
12
+
13
+ On some platforms (Solaris, maybe others), additional compiler and/or linker
14
+ options are required to find OpenSSL or system libraries; these can be
15
+ provided by adding e.g., CFLAGS="-I/path/to/openssl/headers" (compiler option)
16
+ or LDADD_EXTRA="-L/usr/sfw/lib -lsocket -lnsl" (linker option) to the make
17
+ command line.
18
+
19
+ On OS X, the version of OpenSSL included with the operating system is outdated
20
+ (0.9.8) and deprecated, and it is recommended that spiped be built with an
21
+ updated version of OpenSSL. After installing a newer version of OpenSSL, use
22
+ CFLAGS="-I /path/to/openssl/headers" and LDADD_EXTRA="-L /path/to/openssl/lib"
23
+ to build spiped with your newer OpenSSL. Note that spiped will still build if
24
+ you set these options wrong: If you see
25
+ warning: 'AES_set_encrypt_key' is deprecated
26
+ during the build then spiped is still using the outdated version of OpenSSL
27
+ from OS X.
28
+
29
+ On some platforms (OpenBSD prior to 5.4, and possibly others) you will need to
30
+ add #include <sys/types.h> at the start of
31
+ lib/dnsthread/dnsthread.c
32
+ libcperciva/util/sock_util.c
33
+ proto/proto_conn.c
34
+ spipe/main.c
35
+ spipe/pushbits.c
36
+ due to a POSIX-compliance bug on those platforms.
37
+
38
+ On some platforms (mostly Linuxes) it is possible to install OpenSSL libaries
39
+ wihout the associated header files; the header files are usually in packages
40
+ named "openssl-devel", "libssl-dev", or similar.
41
+
42
+ If your OS provides random bytes via some mechanism other than /dev/urandom,
43
+ please make local changes to lib/util/entropy.c and notify the author.
44
+
45
+ If spiped fails to build or run for other reasons, please notify the
46
+ author.
@@ -0,0 +1,44 @@
1
+ spiped-1.4.1
2
+ * Fix build on OS X, and improve strict POSIX compliance.
3
+ * Improved zeroing of sensitive cryptographic data.
4
+ spiped-1.4.0
5
+ * Add automatic detection of compiler support (at compile-time) and CPU
6
+ support (at run-time) for x86 "AES New Instructions"; and when available,
7
+ use these to improve cryptographic performance.
8
+ * Add support for -g option, which makes {spiped, spipe} require perfect
9
+ forward secrecy by dropping connections if the peer endpoint is detected to
10
+ be running using the -f option.
11
+ spiped-1.3.1
12
+ * Fix build by adding missing <stdint.h> #include.
13
+ * Minor code cleanups.
14
+ spiped-1.3.0
15
+ * Bug fix: spiped now correctly closes connections which have been reset;
16
+ in earlier versions spiped could erronously hold "dead" connections open
17
+ as long as they remained idle.
18
+ * Man pages added.
19
+ * Protocol-layer keep-alives are now enabled by default.
20
+ * New option -j (spipe/spiped): Disable protocol-layer keep-alives.
21
+ * In spiped the target address is now re-resolved every 60 seconds by default.
22
+ * New option -R (spiped): Do not re-resolve target address.
23
+ * New option -r <rtime> (spiped): Re-resolve target address every <rtime>
24
+ seconds.
25
+ spiped-1.2.2
26
+ * Build fixes for some strictly POSIX-conforming platforms.
27
+ * Detect and work around compilers which are POSIX-noncompliant in their
28
+ handling of -rt and -lxnet options.
29
+ * Minor documentation and typo fixes.
30
+ spiped-1.2.1
31
+ * Fix build by adding missing <stdint.h> #include.
32
+ spiped-1.2.0
33
+ * New utility "spipe": A client for the spiped protocol, handling a single
34
+ connection with standard input/output as one end.
35
+ * Code rearrangement with no functional consequences.
36
+ * Minor bug and documentation fixes.
37
+ spiped-1.1.0
38
+ * New option -D: Wait until DNS lookups succeed.
39
+ * New option -F: Don't daemonize.
40
+ * Use SO_REUSEADDR to avoid 'socket address already in use' error (most
41
+ importantly, if spiped is killed and restarted).
42
+ * Minor bug and style fixes.
43
+ spiped-1.0.0
44
+ * Initial release
@@ -0,0 +1,33 @@
1
+ The included code and documentation ("spiped") is distributed under the
2
+ following terms:
3
+
4
+ Copyright 2005-2014 Colin Percival. All rights reserved.
5
+ Copyright 2014 Sean Kelly. All rights reserved.
6
+
7
+ Redistribution and use in source and binary forms, with or without
8
+ modification, are permitted provided that the following conditions
9
+ are met:
10
+ 1. Redistributions of source code must retain the above copyright
11
+ notice, this list of conditions and the following disclaimer.
12
+ 2. Redistributions in binary form must reproduce the above copyright
13
+ notice, this list of conditions and the following disclaimer in the
14
+ documentation and/or other materials provided with the distribution.
15
+
16
+ THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26
+ SUCH DAMAGE.
27
+
28
+ In addition to the above, some files are:
29
+
30
+ Copyright 2012 Andreas Olsson
31
+
32
+ and distributed under the same terms. Such files contain individual
33
+ copyright statements and licenses.
@@ -0,0 +1,47 @@
1
+ PKG= spiped
2
+ PROGS= spiped spipe
3
+ PUBLISH= ${PROGS} BUILDING CHANGELOG COPYRIGHT README STYLE POSIX lib libcperciva proto
4
+
5
+ .for D in ${PROGS}
6
+ ${PKG}-${VERSION}/${D}/Makefile:
7
+ echo '.POSIX:' > $@
8
+ ( cd ${D} && echo -n 'PROG=' && make -V PROG ) >> $@
9
+ ( cd ${D} && echo -n 'MAN1=' && make -V MAN1 ) >> $@
10
+ ( cd ${D} && echo -n 'SRCS=' && make -V SRCS | sed -e 's|cpusupport-config.h||' ) >> $@
11
+ ( cd ${D} && echo -n 'IDIRS=' && make -V IDIRS ) >> $@
12
+ ( cd ${D} && echo -n 'LDADD_REQ=' && make -V LDADD_REQ ) >> $@
13
+ cat Makefile.prog >> $@
14
+ ( cd ${D} && make -V SRCS | \
15
+ sed -e 's| cpusupport-config.h||' | \
16
+ tr ' ' '\n' | \
17
+ sed -E 's/.c$$/.o/' | \
18
+ while read F; do \
19
+ S=`make source-$${F}`; \
20
+ CF=`make -V cflags-$${F}`; \
21
+ echo "$${F}: $${S}"; \
22
+ echo " \$${CC} \$${CFLAGS} \$${CFLAGS_POSIX} -D_POSIX_C_SOURCE=200809L -DCPUSUPPORT_CONFIG_FILE=\\\"cpusupport-config.h\\\" $${CF} -I .. \$${IDIRS} -c $${S} -o $${F}"; \
23
+ done ) >> $@
24
+ .endfor
25
+
26
+ publish: clean
27
+ if [ -z "${VERSION}" ]; then \
28
+ echo "VERSION must be specified!"; \
29
+ exit 1; \
30
+ fi
31
+ if find . | grep \~; then \
32
+ echo "Delete temporary files before publishing!"; \
33
+ exit 1; \
34
+ fi
35
+ rm -f ${PKG}-${VERSION}.tgz
36
+ mkdir ${PKG}-${VERSION}
37
+ tar -cf- --exclude 'Makefile.*' --exclude Makefile --exclude .svn ${PUBLISH} | \
38
+ tar -xf- -C ${PKG}-${VERSION}
39
+ cp Makefile.POSIX ${PKG}-${VERSION}/Makefile
40
+ .for D in ${PROGS}
41
+ make ${PKG}-${VERSION}/${D}/Makefile
42
+ .endfor
43
+ tar -cvzf ${PKG}-${VERSION}.tgz ${PKG}-${VERSION}
44
+ rm -r ${PKG}-${VERSION}
45
+
46
+ SUBDIR= ${PROGS}
47
+ .include <bsd.subdir.mk>
@@ -0,0 +1,27 @@
1
+ .POSIX:
2
+
3
+ PROGS= spiped spipe
4
+ BINDIR_DEFAULT= /usr/local/bin
5
+ CFLAGS_DEFAULT= -O2
6
+
7
+ all:
8
+ export CFLAGS="$${CFLAGS:-${CFLAGS_DEFAULT}}"; \
9
+ export LDADD_POSIX=`export CC="${CC}"; cd POSIX && command -p sh posix-l.sh`; \
10
+ export CFLAGS_POSIX=`export CC="${CC}"; cd POSIX && command -p sh posix-cflags.sh`; \
11
+ ( export CC="${CC}"; cd libcperciva/cpusupport/Build && command -p sh cpusupport.sh ) > cpusupport-config.h; \
12
+ . ./cpusupport-config.h; \
13
+ for D in ${PROGS}; do \
14
+ ( cd $${D} && ${MAKE} all ) || exit 2; \
15
+ done
16
+
17
+ install: all
18
+ export BINDIR=$${BINDIR:-${BINDIR_DEFAULT}}; \
19
+ for D in ${PROGS}; do \
20
+ ( cd $${D} && ${MAKE} install ) || exit 2; \
21
+ done
22
+
23
+ clean:
24
+ rm -f cpusupport-config.h
25
+ for D in ${PROGS}; do \
26
+ ( cd $${D} && ${MAKE} clean ) || exit 2; \
27
+ done
@@ -0,0 +1,20 @@
1
+ # Used by Makefile code which generates POSIX Makefiles
2
+ .for X in ${SRCS}
3
+ source-${X:.c=.o}: ${X}
4
+ @echo $>
5
+ .endfor
6
+
7
+ # Defaults for all kivaloo code
8
+ NO_MAN ?= yes
9
+ WARNS ?= 6
10
+
11
+ # Make logic (bits which are separated out in individual Makefiles).
12
+ CFLAGS += ${IDIRS}
13
+ LDADD += ${LDADD_REQ}
14
+
15
+ # CPU features compiler support detection
16
+ SRCS += cpusupport-config.h
17
+ cpusupport-config.h:
18
+ ( export CFLAGS="${CFLAGS}"; cd ../libcperciva/cpusupport/Build && command -p sh cpusupport.sh ) > cpusupport-config.h
19
+ CLEANFILES+= cpusupport-config.h
20
+ CFLAGS += -I . -D CPUSUPPORT_CONFIG_FILE=\"cpusupport-config.h\"
@@ -0,0 +1,23 @@
1
+
2
+ all: ${PROG}
3
+
4
+ install:${PROG}
5
+ mkdir -p ${BINDIR}
6
+ cp ${PROG} ${BINDIR}/_inst.${PROG}.$$$$_ && \
7
+ strip ${BINDIR}/_inst.${PROG}.$$$$_ && \
8
+ chmod 0555 ${BINDIR}/_inst.${PROG}.$$$$_ && \
9
+ mv -f ${BINDIR}/_inst.${PROG}.$$$$_ ${BINDIR}/${PROG}
10
+ if ! [ -z "${MAN1DIR}" ]; then \
11
+ for MPAGE in ${MAN1}; do \
12
+ cp $$MPAGE ${MAN1DIR}/_inst.$$MPAGE.$$$$_ && \
13
+ chmod 0444 ${MAN1DIR}/_inst.$$MPAGE.$$$$_ && \
14
+ mv -f ${MAN1DIR}/_inst.$$MPAGE.$$$$_ ${MAN1DIR}/$$MPAGE; \
15
+ done; \
16
+ fi
17
+
18
+ clean:
19
+ rm -f ${PROG} ${SRCS:.c=.o}
20
+
21
+ ${PROG}:${SRCS:.c=.o}
22
+ ${CC} -o ${PROG} ${SRCS:.c=.o} ${LDADD_EXTRA} ${LDADD_REQ} ${LDADD_POSIX}
23
+
@@ -0,0 +1,10 @@
1
+ POSIX compatibility code
2
+ ------------------------
3
+
4
+ This code exists to work around some common POSIX compatibility issues.
5
+
6
+ POSIX specifies that if the first line of a Makefile is ".POSIX:" then the
7
+ Makefile should be processed according to POSIX rules, including with CC=c99.
8
+ Further, c99 is required to understand the -lrt and -lxnet options (and ignore
9
+ them if the routines they specify linkage for are already in the standard C
10
+ library). Unfortunately some systems fail or one or both of these accounts.
@@ -0,0 +1,10 @@
1
+ # Should be sourced by `command -p sh posix-cflags.sh` from within a Makefile
2
+ if ! ${CC} -D_POSIX_C_SOURCE=200809L posix-msg_nosignal.c 2>/dev/null; then
3
+ printf %s "-DPOSIXFAIL_MSG_NOSIGNAL "
4
+ echo "WARNING: POSIX violation: <sys/socket.h> not defining MSG_NOSIGNAL" >/dev/stderr
5
+ fi
6
+ if ! ${CC} -D_POSIX_C_SOURCE=200809L posix-clock_realtime.c 2>/dev/null; then
7
+ printf %s "-DPOSIXFAIL_CLOCK_REALTIME"
8
+ echo "WARNING: POSIX violation: <time.h> not defining CLOCK_REALTIME" >/dev/stderr
9
+ fi
10
+ rm -f a.out
@@ -0,0 +1,3 @@
1
+ #include <time.h>
2
+
3
+ int main() {return CLOCK_REALTIME;}
@@ -0,0 +1 @@
1
+ int main() {return 0;}
@@ -0,0 +1,14 @@
1
+ # Should be sourced by `command -p sh posix-l.sh` from within a Makefile.
2
+ FIRST=YES
3
+ for LIB in rt xnet; do
4
+ if ${CC} -l${LIB} posix-l.c 2>/dev/null; then
5
+ if [ ${FIRST} = "NO" ]; then
6
+ printf " ";
7
+ fi
8
+ printf "%s" "-l${LIB}";
9
+ FIRST=NO;
10
+ else
11
+ echo "WARNING: POSIX violation: make's CC doesn't understand -l${LIB}" >/dev/stderr
12
+ fi
13
+ rm -f a.out
14
+ done
@@ -0,0 +1,3 @@
1
+ #include <sys/socket.h>
2
+
3
+ int main() {return MSG_NOSIGNAL;}
@@ -0,0 +1,198 @@
1
+ spiped design
2
+ =============
3
+
4
+ Introduction
5
+ ------------
6
+
7
+ spiped (pronounced "ess-pipe-dee") is a utility for creating symmetrically
8
+ encrypted and authenticated pipes between socket addresses, so that one may
9
+ connect to one address (e.g., a UNIX socket on localhost) and transparently
10
+ have a connection established to another address (e.g., a UNIX socket on a
11
+ different system). This is similar to 'ssh -L' functionality, but does not
12
+ use SSH and requires a pre-shared symmetric key.
13
+
14
+ spipe (pronounced "ess-pipe") is a utility which acts as an spiped protocol
15
+ client (i.e., connects to an spiped daemon), taking input from the standard
16
+ input and writing data read back to the standard output.
17
+
18
+ Note that spiped:
19
+ 1. Requires a strong key file: The file specified via the -k option should
20
+ have at least 256 bits of entropy. ('dd if=/dev/urandom bs=32 count=1' is
21
+ your friend.)
22
+ 2. Requires strong entropy from /dev/urandom. (Make sure your kernel's
23
+ random number generator is seeded at boot time!)
24
+ 3. Does not provide any protection against information leakage via packet
25
+ timing: Running telnet over spiped will protect a password from being directly
26
+ read from the network, but will not obscure the typing rhythm.
27
+ 4. Can significantly increase bandwidth usage for interactive sessions: It
28
+ sends data in packets of 1024 bytes, and pads smaller messages up to this
29
+ length, so a 1 byte write could be expanded to 1024 bytes if it cannot be
30
+ coalesced with adjacent bytes.
31
+ 5. Uses a symmetric key -- so anyone who can connect to an spiped "server" is
32
+ also able to impersonate it.
33
+
34
+ Example usage
35
+ -------------
36
+
37
+ To set up an encrypted and authenticated pipe for sending email between two
38
+ systems (in the author's case, from many systems around the internet to his
39
+ central SMTP server, which then relays email to the rest of the world), one
40
+ might run
41
+
42
+ # dd if=/dev/urandom bs=32 count=1 of=keyfile
43
+ # spiped -d -s '[0.0.0.0]:8025' -t '[127.0.0.1]:25' -k keyfile
44
+
45
+ on a server and after copying keyfile to the local system, run
46
+
47
+ # spiped -e -s '[127.0.0.1]:25' -t $SERVERNAME:8025 -k keyfile
48
+
49
+ at which point mail delivered via localhost:25 on the local system will be
50
+ securely transmitted to port 25 on the server.
51
+
52
+ You can also use spiped to protect SSH servers from attackers: Since data is
53
+ authenticated before being forwarded to the target, this can allow you to SSH
54
+ to a host while protecting you in the event that someone finds an exploitable
55
+ bug in the SSH daemon -- this serves the same purpose as port knocking or a
56
+ firewall which restricts source IP addresses which can connect to SSH. On the
57
+ SSH server, run
58
+
59
+ # dd if=/dev/urandom bs=32 count=1 of=/etc/ssh/spiped.key
60
+ # spiped -d -s '[0.0.0.0]:8022' -t '[127.0.0.1]:22' -k /etc/ssh/spiped.key
61
+
62
+ then copy the server's /etc/ssh/spiped.key to ~/.ssh/spiped_HOSTNAME_key on
63
+ your local system and add the lines
64
+
65
+ Host HOSTNAME
66
+ ProxyCommand spipe -t %h:8022 -k ~/.ssh/spiped_%h_key
67
+
68
+ to the ~/.ssh/config file. This will cause "ssh HOSTNAME" to automatically
69
+ connect using the spipe client via the spiped daemon; you can then firewall
70
+ off all incoming traffic on port tcp/22.
71
+
72
+ For a detailed list of the command-line options to spiped and spipe, see the
73
+ README files in the respective subdirectories.
74
+
75
+ Security requirements
76
+ ---------------------
77
+
78
+ The user is responsible for ensuring that:
79
+ 1. The key file contains 256 or more bits of entropy.
80
+ 2. The same key file is not used for more than 2^64 connections.
81
+ 3. Any individual connection does not transmit more than 2^64 bytes.
82
+
83
+ Encrypted protocol
84
+ ------------------
85
+
86
+ The client and server share a key file with 256 or more bits of entropy. On
87
+ launch, they read the key file and compute
88
+ K = SHA256(key file).
89
+
90
+ When a connection is established:
91
+ C1. The client generates a 256-bit random value nonce_C and sends it.
92
+ S1. The server generates a 256-bit random value nonce_S and sends it.
93
+
94
+ C2. The client receives a 256-bit value nonce_S.
95
+ S2. The server receives a 256-bit value nonce_C.
96
+
97
+ C3/S3. Both parties now compute the 512-bit value
98
+ dk_1 = PBKDF2-SHA256(K, nonce_C || nonce_S, 1)
99
+ and parse it as a pair of 256-bit values
100
+ dhmac_C || dhmac_S = dk_1.
101
+
102
+ C4. The client picks* a value x_C and computes** y_C = 2^x_C mod p, where p is
103
+ the Diffie-Hellman "group #14" modulus, and h_C = HMAC-SHA256(dhmac_C, y_C).
104
+ The client sends y_C || h_C to the server.
105
+ S4. The server receives a 2304-bit value which it parses as y_C || h_C, where
106
+ y_C is 2048 bits and h_C is 256 bits; and drops the connection if h_C is not
107
+ equal to HMAC-SHA256(dhmac_C, y_C) or y_C >= p.
108
+
109
+ S5. The server picks* a value x_S and computes** y_S = 2^x_S mod p and
110
+ h_S = HMAC-SHA256(dhmac_S, y_S). The server sends y_S || h_S to the client.
111
+ C5. The client receives a 2304-bit value which it parses as y_S || h_S, where
112
+ y_S is 2048 bits and h_S is 256 bits; and drops the connection if h_S is not
113
+ equal to HMAC-SHA256(dhmac_S, y_S) or y_S >= p.
114
+
115
+ C6. The client computes** y_SC = y_S^x_C mod p.
116
+ S6. The server computes** y_SC = y_C^x_S mod p.
117
+ (Note that these two compute values are identical.)
118
+
119
+ C7/S7. Both parties now compute the 1024-bit value
120
+ dk_2 = PBKDF2-SHA256(K, nonce_C || nonce_S || y_SC, 1)
121
+ and parse it as a 4-tuple of 256-bit values
122
+ E_C || H_C || E_S || H_S.
123
+
124
+ Thereafter, the client and server exchange 1060-byte packets P generated from
125
+ plaintext messages M of 1--1024 bytes
126
+ msg_padded = M || ( 0x00 x (1024 - length(M))) || bigendian32(length(M))
127
+ msg_encrypted = AES256-CTR(E, msg_padded, packet#)
128
+ P = msg_encrypted || HMAC-SHA256(H, msg_encrypted || bigendian64(packet#))
129
+ where E and H are E_C and H_C or E_S and H_S depending on whether the packet
130
+ is being sent by the client or the server, and AES256-CTR is computed with
131
+ nonce equal to the packet #, which starts at zero and increments for each
132
+ packet sent in the same direction.
133
+
134
+ * The values x_C, x_S picked must either be 0 (if forward perfect secrecy
135
+ is not desired) or have 256 bits of entropy (if forward perfect secrecy is
136
+ desired).
137
+
138
+ ** The values y_C, y_S, and y_SC are 2048 bits and big-endian.
139
+
140
+ Security proof
141
+ --------------
142
+ 1. Under the random oracle model, K has at least 255 bits of entropy (it's a
143
+ 256-bit hash computed from a value with at least 256 bits of entropy).
144
+
145
+ 2. Provided that at least one party is following the protocol and the key
146
+ file has been used for fewer than 2^64 connections, the probability of the
147
+ tuple (K, nonce_C, nonce_S) being non-unique is less than 2^(-192).
148
+
149
+ 3. Under the random oracle model, the probability of an attacker without
150
+ access to K guessing either of dhmac_C and dhmac_S is less than
151
+ P(attacker guesses K) +
152
+ P(the tuple has been input to the oracle before) +
153
+ P(the attacker directly guesses),
154
+ which is less than
155
+ 2^(-255) + 2^(-192) + 2^(-255) = 2^(-192) + 2^(-254).
156
+
157
+ 4. Consequently, in order for an attacker to convince a protocol-obeying
158
+ party that a tuple (y, h) is legitimate, the attacker must do at least 2^190
159
+ expected work (which we consider to be computationally infeasible and do not
160
+ consider any further).
161
+
162
+ 5. If one of the parties opts to not have perfect forward secrecy, then the
163
+ value y_SC will be equal to 1 and dk_2 will have the same security properties
164
+ as dk_1, i.e., it will be computationally infeasible for an attacker without
165
+ access to K to compute dk_2.
166
+
167
+ 6. If both parties opt for perfect forward secrecy, an attacker who can
168
+ compute y_SC has solved a Diffie-Hellman problem over the 2048-bit group #14,
169
+ which is (under the CDH assumption) computationally infeasible.
170
+
171
+ 7. Consequently, if both parties opt for perfect forward secrecy, an attacker
172
+ who obtains access to K after the handshake has completed will continue to be
173
+ unable to compute dk_2 from information exchanged during the handshake.
174
+
175
+ 8. Under the random oracle model, the packets P are indistinguishable from
176
+ random 1060-byte packets; thus no information about the keys used or the
177
+ plaintext being transmitted is revealed by post-key-exchange communications.
178
+
179
+ 9. Because the values (msg_encrypted || bigendian(packet#)) are distinct for
180
+ each packet, under the random oracle model it is infeasible for an attacker
181
+ without access to the value H to generate a packet which will be accepted as
182
+ valid.
183
+
184
+ Code layout
185
+ -----------
186
+
187
+ spiped/* -- Code specific to the spiped utility.
188
+ main.c -- Command-line parsing, initialization, and event loop.
189
+ dispatch.c -- Accepts connections and hands them off to protocol code.
190
+ spipe/* -- Code specific to the spipe utility.
191
+ main.c -- Command-line parsing, initialization, and event loop.
192
+ pushbits.c -- Copies data between standard input/output and a socket.
193
+ proto/* -- Implements the spiped protocol.
194
+ _conn.c -- Manages the lifecycle of a connection.
195
+ _handshake.c -- Performs the handshaking portion of the protocol.
196
+ _pipe.c -- Performs the data-shuttling portion of the protocol.
197
+ _crypt.c -- Does the cryptographic bits needed by _handshake and _pipe.
198
+ lib/* -- Library code (mostly originating from tarsnap and kivaloo).