My favorites | Sign in
Project Logo
                
Search
for
Updated Oct 10, 2008 by alangley
libobstcp  
The core library

The core library is called libobstcp and it's built as a shared library. Everything else depends on this and so you should install it first.

You can get the source code from the git repo or download the tarball.

A simple make, make install should do it. You'll need development headers for libevent to build some of the code (but not the core).

% make
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c libobstcp.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c salsa20-merged.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c sha256.c
libobstcp.c:32: warning: ‘print_bytes’ defined but not used
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c base64.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c curve25519-donna-x86-64.c -Wall
cpp curve25519-donna-x86-64.s > curve25519-donna-x86-64.s.pp
as -o curve25519-donna-x86-64.s.o curve25519-donna-x86-64.s.pp
ar -rc libobstcp.a libobstcp.o salsa20-merged.o sha256.o curve25519-donna-x86-64.o curve25519-donna-x86-64.s.o base64.o
gcc -o libobstcp.so.1 -shared -Wl,-soname -Wl,libobstcp.so.1 -ldl libobstcp.o salsa20-merged.o sha256.o base64.o curve25519-donna-x86-64.o curve25519-donna-x86-64.s.o
gcc -ggdb -fPIC -Wall -fvisibility=hidden -o obstcp-serv obstcp-serv.c libobstcp.a
gcc -ggdb -fPIC -Wall -fvisibility=hidden -o obstcp-cli obstcp-cli.c libobstcp.a
gcc -ggdb -fPIC -Wall -fvisibility=hidden -o obstcp-redir obstcp-redir.c libobstcp.a -levent
gcc -ggdb -fPIC -Wall -fvisibility=hidden -o obstcp-keygen obstcp-keygen.c libobstcp.a
% sudo make install
[sudo] password for agl: 
cp libobstcp.h /usr/include
cp libobstcp.so.1 /usr/lib
ln -sf /usr/lib/libobstcp.so.1 /usr/lib/libobstcp.so
ldconfig

TODO

In no order:

Tools

The library includes several tools:

obstcp-serv: An obstcp server. Just run it and it'll print a random port number and advert for the new server. Connect using obstcp-cli and you can exchange lines via stdin and stdout.

obstcp-cli: An obstcp client. Give it an IP address and an advert string on the command line.

obstcp-keygen: generates a private key (which is written to stdout) and an advert (written to stderr). Give it a port number on the command line.

obstcp-redir: A proxy for a TCP server. You can hide webservers (for example) behind this to make them support obstcp. It accepted obfuscated connections on a given port and forwards the connection to an IP:port pair.


Comment by matt.martini, Oct 08, 2008

I was unsuccessful at compiling on a Mac. See the error output below:

macintosh 19 $ uname -a
Darwin varena 9.5.0 Darwin Kernel Version 9.5.0: Wed Sep  3 11:29:43 PDT 2008; root:xnu-1228.7.58~1/RELEASE_I386 i386
macintosh 20 $ macosver 
10.5.5
macintosh 21 $  make
cat build-note
***** NOTE *****

Due to the way that the build process works, some compiler errors
are expected as we try to build different platform specific code
to find one that works.

Just because you see errors, it doesn't mean that the build failed.
Additionally, libevent development headers are needed to build
some of the optional utilities, but the core works fine without.

sleep 7
touch .warning
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c libobstcp.c
libobstcp.c: In function 'advert_create':
libobstcp.c:94: error: 'ENOKEY' undeclared (first use in this function)
libobstcp.c:94: error: (Each undeclared identifier is reported only once
libobstcp.c:94: error: for each function it appears in.)
libobstcp.c: At top level:
libobstcp.c:414: error: conflicting types for 'encrypt'
/usr/include/unistd.h:429: error: previous declaration of 'encrypt' was here
libobstcp.c: In function 'obstcp_server_read':
libobstcp.c:656: error: 'ENOKEY' undeclared (first use in this function)
make: *** [libobstcp.o] Error 1
macintosh 22 $
Comment by alangley, Oct 08, 2008

@matt.martini: thanks for the report. That's very helpful - I OS X doesn't define ENOKEY, but does define a standard function already called encrypt. I'll fix both in the next couple of days.

Comment by alangley, Oct 08, 2008

@matt.martini: those two issues should be fixed in the git tree with commits afb885fa3a6072ce6d624af38b4b4a85d0ca09f2 and 1b50458286542e3489d64f6fb57144c51596d1bf. Thanks!

Comment by matt.martini, Oct 08, 2008

Ok, that helped but now I get:

 $ make
cat build-note
***** NOTE *****

Due to the way that the build process works, some compiler errors
are expected as we try to build different platform specific code
to find one that works.

Just because you see errors, it doesn't mean that the build failed.
Additionally, libevent development headers are needed to build
some of the optional utilities, but the core works fine without.

sleep 7
touch .warning
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c libobstcp.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c salsa208.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c sha256.c
gcc -ggdb -fPIC -Wall -fvisibility=hidden -c base32.c
/bin/bash -c 'cd curve25519 && exec /bin/bash buildone.sh'
/usr/local/tmp/libobstcp-0.3.2/curve25519
Trying donna
/usr/local/tmp/libobstcp-0.3.2/curve25519/donna
x.s:2025:Unknown pseudo-op: .extern
x.s:2025:Rest of line ignored. 1st junk character valued 102 (f).
x.s:2047:bad register name `%rbx'
x.s:2048:bad register name `%r12'
x.s:2049:bad register name `%r13'
x.s:2050:bad register name `%r14'
[snip of lots of the same type of error]
Trying athlon
/usr/local/tmp/libobstcp-0.3.2/curve25519/athlon
const.s:2:Expected comma after segment-name
const.s:2:Rest of line ignored. 1st junk character valued 46 (.).
Trying donna_c64
/usr/local/tmp/libobstcp-0.3.2/curve25519/donna_c64
ls: *.s: No such file or directory
smult.c:32: error: unable to emulate 'TI'
smult.c: In function 'fdifference_backwards':
smult.c:44: warning: left shift count >= width of type
smult.c: In function 'fscalar_product':
smult.c:85: warning: integer constant is too large for 'long' type
smult.c:87: warning: right shift count >= width of type
smult.c:88: warning: integer constant is too large for 'long' type
smult.c:90: warning: right shift count >= width of type
smult.c:91: warning: integer constant is too large for 'long' type
smult.c:93: warning: right shift count >= width of type
smult.c:94: warning: integer constant is too large for 'long' type
smult.c:96: warning: right shift count >= width of type
smult.c:97: warning: integer constant is too large for 'long' type
smult.c:99: warning: right shift count >= width of type
smult.c: In function 'fmul':
smult.c:141: warning: right shift count >= width of type
smult.c:142: warning: integer constant is too large for 'long' type
smult.c:143: warning: right shift count >= width of type
smult.c:144: warning: integer constant is too large for 'long' type
smult.c:145: warning: right shift count >= width of type
smult.c:146: warning: integer constant is too large for 'long' type
smult.c:147: warning: right shift count >= width of type
smult.c:148: warning: integer constant is too large for 'long' type
smult.c:149: warning: right shift count >= width of type
smult.c:150: warning: integer constant is too large for 'long' type
smult.c:151: warning: right shift count >= width of type
smult.c:152: warning: integer constant is too large for 'long' type
smult.c: In function 'fsquare':
smult.c:186: warning: right shift count >= width of type
smult.c:187: warning: integer constant is too large for 'long' type
smult.c:188: warning: right shift count >= width of type
smult.c:189: warning: integer constant is too large for 'long' type
smult.c:190: warning: right shift count >= width of type
smult.c:191: warning: integer constant is too large for 'long' type
smult.c:192: warning: right shift count >= width of type
smult.c:193: warning: integer constant is too large for 'long' type
smult.c:194: warning: right shift count >= width of type
smult.c:195: warning: integer constant is too large for 'long' type
smult.c:196: warning: right shift count >= width of type
smult.c:197: warning: integer constant is too large for 'long' type
smult.c: In function 'fexpand':
smult.c:209: warning: integer constant is too large for 'long' type
smult.c:210: warning: integer constant is too large for 'long' type
smult.c:211: warning: integer constant is too large for 'long' type
smult.c:212: warning: integer constant is too large for 'long' type
smult.c:213: warning: integer constant is too large for 'long' type
Sorry, all curve25519 implementations failed to build
make: *** [curve25519.a] Error 1
Comment by alangley, Oct 08, 2008

@matt.martini: looks like all the curve25519 implementations are failing to build. They should cover x86-64, x86 and any 64-bit capable GCC. Have you a CPU outside that set?

Comment by tim.e.mcguire, Oct 08, 2008

Trying to get this working, I compiled and got the following: sleep 7 touch .warning gcc -ggdb -fPIC -Wall -fvisibility=hidden -c libobstcp.c gcc -ggdb -fPIC -Wall -fvisibility=hidden -c salsa208.c gcc -ggdb -fPIC -Wall -fvisibility=hidden -c sha256.c gcc -ggdb -fPIC -Wall -fvisibility=hidden -c base32.c /bin/bash -c 'cd curve25519 && exec /bin/bash buildone.sh' Trying donna x.s: Assembler messages: x.s:41: Error: bad register name `%rbx' x.s:42: Error: bad register name `%r12' x.s:43: Error: bad register name `%r13' x.s:44: Error: bad register name `%r14' x.s:45: Error: bad register name `%r15' x.s:46: Error: bad register name `%rdi' x.s:50: Error: bad register name `%rsi' x.s:51: Error: bad register name `%rcx)' -- followed by a couple hundred lines of "bad register name"

Then I started the server: obstcp-serv and got a port (60829)and a server advert 108...2p5

Then I opened another terminal window and started the client with obstcp-cli 127.0.0.1 advert#

and keep getting:

Usage: ./obstcp-cli <destination ip> <server advert>

any advice?

Thanks

Comment by arthur.casals, Oct 09, 2008

Got the same error as matt. Had to strip out the -fvisibility=hidden option, since it is not recognized by the compiler (using gcc 3.4.4 on a cygwin shell). Using the last commited version. Here's the stack:

$ make
gcc -ggdb -fPIC -Wall  -c libobstcp.c
libobstcp.c:1: warning: -fPIC ignored for target (all code is position independent)
libobstcp.c: In function `advert_create':
libobstcp.c:94: error: `ENOKEY' undeclared (first use in this function)
libobstcp.c:94: error: (Each undeclared identifier is reported only once
libobstcp.c:94: error: for each function it appears in.)
libobstcp.c: In function `obstcp_server_read':
libobstcp.c:656: error: `ENOKEY' undeclared (first use in this function)
make: *** [libobstcp.o] Error 1
Comment by arthur.casals, Oct 09, 2008

Sorry, my mistake - using the last tarball. Got the code from the tree; this error is gone, but got a new one. Here's the complete stack:

$ make
gcc -ggdb -fPIC -Wall  -c libobstcp.c
libobstcp.c:1: warning: -fPIC ignored for target (all code is position independent)
gcc -ggdb -fPIC -Wall  -c salsa208.c
salsa208.c:1: warning: -fPIC ignored for target (all code is position independent)
gcc -ggdb -fPIC -Wall  -c sha256.c
sha256.c:1: warning: -fPIC ignored for target (all code is position independent)
sha256.c: In function `ror':
sha256.c:13: warning: asm operand 1 probably doesn't match constraints
sha256.c:13: error: impossible constraint in `asm'
make: *** [sha256.o] Error 1

Any ideas?

Thanks

Comment by tim.e.mcguire, Oct 09, 2008

UPdate. tried a few more times and got further. Started server with root@adtim-laptop:~/Downloads/libobstcp-0.3.2# ./obstcp-serv port: 42072 advert: 108g3k66dk0rw6wk4jqbqt3g7b8umc7hpn5xnzxqbv6fuujv5psjdcx0209k5

started client with

./obstcp-cli 127.0.0.1 108g3k66dk0rw6wk4jqbqt3g7b8umc7hpn5xnzxqbv6fuujv5psjdcx0209k5

got "remote closed"

and server session said: accepted connection obstcp_rbuf_read_fd: Resource temporarily unavailable

Comment by tim.e.mcguire, Oct 09, 2008

note that it was after a restart of the OS (Ubuntu 8.04) that the client started working. That is the only thing I can think of that changed.

Comment by alangley, Oct 09, 2008

@ tim.e.mcguire: The warnings about the registers are expected on any non 64-bit Intel CPU. The build tries several implementations (for different CPUs) and selects the best that works. Possibly I should just hide the output in the future.

When you get "Usage: ./obstcp-cli <destination ip> <server advert>" that should mean that either the wrong number of arguments were given or the IP address didn't parse. The arguments are broken up by the shell, so it's possible that something odd is happening there. Often one can quote arguments with 'xyz' to stop a shell from breaking in the wrong place.

What platform (OS, CPU, GCC version) are you using?

The "Resource temporarily unavailable" is very odd. That's known as EAGAIN, which should only happen on non-blocking sockets and only obstcp-redir sets any sockets to be non-blocking.

I might know more when I know the platform.

Thanks for testing!

Comment by tim.e.mcguire, Oct 09, 2008

OS = Ubuntu Hardy. 8.0.4 NOT the 64bit edition. CPU = Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz

version: 6.15.10 size: 2001MHz capacity: 2001MHz width: 64 bits
gcc-4.2

Is it possible that the 32bit version of ubuntu running on a 64bit hardware is the issue?

Comment by alangley, Oct 09, 2008

@tim.e.mcguire: Well, it's a real OS, so I'm at a loss I'm afraid. Can you run the programs under strace and send me the output? (strace -o /tmp/output ./obstcp-...). Thanks.

(You might wish to switch to email since the output is probably quite large. I also pay more attention to email! agl at imperialviolet dot org)

Cheers

AGL


Sign in to add a comment
Hosted by Google Code