[PATCH] Add xorpipe utility

jody at jodybruchon.com jody at jodybruchon.com
Thu Sep 13 02:42:31 UTC 2012


I wrote a pipeline utility that performs an XOR of the data streamed through it
using a 32-bit key specified on the command line, intended mainly to serve as a
sort of poor man's encryption. It also includes an option that generates a
random key to stdout. Being new to BusyBox development, I hope that I have done
all of this correctly (libbb usage, etc.) My test build of BusyBox with xorpipe
works as expected, and on x86-64, BusyBox 1.20.2 (built with "make defconfig" in
both cases) increased in size by 176 bytes. If there is anything I could have
done better in the code, please let me know! I would like to make more valuable
contributions to BusyBox in the future where I can.

My rationale behind writing this simple utility is as follows: Moving data
through a fully encrypted tunnel like SSH is too slow for me, so I use
netcat/socat for moving large chunks of data between systems. I don't want the
data to be easily identified and reproduced if it is somehow intercepted, though
it's also not a major problem if someone goes through the trouble of decrypting
it; thus, simple XOR encryption is good enough for my purposes and is also
extremely fast. I'm sure someone else will find it useful, and given its
minuscule size, it is of negligible cost to include.

Encrypting (with specified or generated key):
cat datafile | xorpipe c40da326 > datafile.new
xorpipe -g > datafile.key; cat datafile | xorpipe $(cat datafile.key) >
datafile.new

Decrypting (with a previously generated key:
cat datafile.new | xorpipe $(cat datafile.key) > datafile

Using xorpipe to obfuscate a generated compressed tar (my real-world purpose):
(on remote host)
socat -u tcp-listen:9999 - | xorpipe a8cf5d36 | lzop -dc | tar -x
(on local machine)
tar -c * | lzop | xorpipe a8cf5d36 | socat -u - tcp-connect:1.2.3.4:9999

Cheers,
Jody Lee Bruchon
-------------- next part --------------
A non-text attachment was scrubbed...
Name: xorpipe-bb1202.patch
Type: application/octet-stream
Size: 4322 bytes
Desc: not available
URL: <http://lists.busybox.net/pipermail/busybox/attachments/20120912/f8f31adb/attachment.obj>


More information about the busybox mailing list