Commit 02677432 authored by gregor herrmann's avatar gregor herrmann

Imported Upstream version 0.7.0

parent 7d1fbdde
......@@ -5,7 +5,30 @@ iodine - http://code.kryo.se/iodine
CHANGES:
2010-02-13: 0.6.0-rc1 "Hotspotify"
2014-06-16: 0.7.0 "Kryoptonite"
- Partial IPv6 support (#107)
Client can connect to iodined through an relaying IPv6
nameserver. Server only supports IPv4 for now.
Traffic inside tunnel is IPv4.
- Add socket activation for systemd, by Michael Scherer.
- Add automated lookup of external ip (via -n auto).
- Bugfix for OS X (Can't assign requested address)
- Fix DNS tunneling bug caused by uninitialized variable, #94
- Handle spaces when entering password interactively, fixes #93.
Patch by Hagar.
- Add -R option to set OpenBSD routing domain for the DNS socket.
Patch by laurent at gouloum fr, fixes #95.
- Add android patches and makefile, from Marcel Bokhorst, fixes #105.
- Added missing break in iodine.c, by Pavel Pergamenshchik, #108.
- A number of minor patches from Frank Denis, Gregor Herrmann and
Barak A. Pearlmutter.
- Testcase compilation fixes for OS X and FreeBSD
- Do not let sockets be inherited by sub-processes, fixes #99.
- Add unspecified RR type (called PRIVATE; id 65399, in private use
range). For servers with RFC3597 support. Fixes #97.
- Fix authentication bypass vulnerability; found by Oscar Reparaz.
2010-02-06: 0.6.0-rc1 "Hotspotify"
- Fixed tunnel not working on Windows.
- Any device name is now supported on Windows, fixes #47.
- Multiple installed TAP32 interfaces are now supported, fixes #46.
......@@ -30,6 +53,7 @@ CHANGES:
- Merged low-latency patch from Anne Bezemer, fixes #76.
- Resolve client nameserver argument if given as hostname, fixes #82.
- Open log before chroot, fixes #86: logging on FreeBSD.
- Merged big bugfix patch from Anne Bezemer, #88.
2009-06-01: 0.5.2 "WifiFree"
- Fixed client segfault on OS X, #57
......
prefix=/usr/local
prefix?=/usr/local
sbindir=$(prefix)/sbin
datadir=$(prefix)/share
mandir=$(datadir)/man
......@@ -16,24 +16,9 @@ RM_FLAGS=-f
TARGETOS = `uname`
all:
all:
@(cd src; $(MAKE) TARGETOS=$(TARGETOS) all)
cross-mingw:
@(cd src; $(MAKE) TARGETOS=windows32 CC=i686-mingw32-gcc all)
cross-mingw-dist: cross-mingw
@rm -rf iodine-latest-win32*
@mkdir -p iodine-latest-win32/bin
@for i in `ls bin`; do cp bin/$$i iodine-latest-win32/bin/$$i.exe; done
@cp /usr/i686-mingw32/usr/bin/zlib1.dll iodine-latest-win32/bin
@cp README* CH* TO* iodine-latest-win32
@echo "Create date: " > iodine-latest-win32/VERSION
@date >> iodine-latest-win32/VERSION
@echo "SVN version: " >> iodine-latest-win32/VERSION
@svnversion >> iodine-latest-win32/VERSION
@zip -r iodine-latest-win32.zip iodine-latest-win32
install: all
$(MKDIR) $(MKDIR_FLAGS) $(DESTDIR)$(sbindir)
$(INSTALL) $(INSTALL_FLAGS) bin/iodine $(DESTDIR)$(sbindir)/iodine
......@@ -48,7 +33,7 @@ uninstall:
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodine
$(RM) $(RM_FLAGS) $(DESTDIR)$(sbindir)/iodined
$(RM) $(RM_FLAGS) $(DESTDIR)$(mandir)/man8/iodine.8
test: all
@echo "!! The check library is required for compiling and running the tests"
@echo "!! Get it at http://check.sf.net"
......@@ -58,5 +43,62 @@ clean:
@echo "Cleaning..."
@(cd src; $(MAKE) clean)
@(cd tests; $(MAKE) clean)
@rm -rf bin iodine-latest-win32*
@rm -rf bin iodine-latest*
#Helper target for windows/android zipfiles
iodine-latest:
@rm -rf iodine-latest*
@mkdir -p iodine-latest
@echo "Create date: " > iodine-latest/VERSION.txt
@date >> iodine-latest/VERSION.txt
@echo "Git version: " >> iodine-latest/VERSION.txt
@git rev-parse HEAD >> iodine-latest/VERSION.txt
@for i in README CHANGELOG TODO; do cp $$i iodine-latest/$$i.txt; done
@unix2dos iodine-latest/*
cross-android:
@(cd src; $(MAKE) base64u.c base64u.h)
@(cd src; ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk)
iodine-latest-android.zip: iodine-latest
@mv iodine-latest iodine-latest-android
@mkdir -p iodine-latest-android/armeabi iodine-latest-android/x86
@$(MAKE) cross-android TARGET_ARCH_ABI=armeabi
@cp src/libs/armeabi/* iodine-latest-android/armeabi
@$(MAKE) cross-android TARGET_ARCH_ABI=x86
@cp src/libs/x86/* iodine-latest-android/x86
@cp README-android.txt iodine-latest-android
@zip -r iodine-latest-android.zip iodine-latest-android
cross-mingw32:
@(cd src; $(MAKE) TARGETOS=windows32 CC=i686-w64-mingw32-gcc all)
cross-mingw64:
@(cd src; $(MAKE) TARGETOS=windows32 CC=x86_64-w64-mingw32-gcc all)
iodine-latest-windows.zip: iodine-latest
@mv iodine-latest iodine-latest-windows
@mkdir -p iodine-latest-windows/64bit iodine-latest-windows/32bit
@(cd src; $(MAKE) TARGETOS=windows32 CC=i686-w64-mingw32-gcc clean all)
@i686-w64-mingw32-strip bin/iodine*
@for i in `ls bin`; do cp bin/$$i iodine-latest-windows/32bit/$$i.exe; done
@cp /usr/i686-w64-mingw32/bin/zlib1.dll iodine-latest-windows/32bit
@(cd src; $(MAKE) TARGETOS=windows32 CC=x86_64-w64-mingw32-gcc clean all)
@x86_64-w64-mingw32-strip bin/iodine*
@for i in `ls bin`; do cp bin/$$i iodine-latest-windows/64bit/$$i.exe; done
@cp /usr/x86_64-w64-mingw32/bin/zlib1.dll iodine-latest-windows/64bit
@cp README-win32.txt iodine-latest-windows
@zip -r iodine-latest-windows.zip iodine-latest-windows
cross-mingw:
@(cd src; $(MAKE) TARGETOS=windows32 CC=i686-mingw32-gcc all)
iodine-latest-win32.zip: cross-mingw iodine-latest
@mv iodine-latest iodine-latest-win32
@mkdir -p iodine-latest-win32/bin
@i686-mingw32-strip bin/iodine*
@for i in `ls bin`; do cp bin/$$i iodine-latest-win32/bin/$$i.exe; done
@cp /usr/i686-mingw32/usr/bin/zlib1.dll iodine-latest-win32/bin
@cp README-win32.txt iodine-latest-win32
@zip -r iodine-latest-win32.zip iodine-latest-win32
......@@ -8,6 +8,17 @@ server. This can be usable in different situations where internet access is
firewalled, but DNS queries are allowed.
COMPILING:
Iodine has no configure script. There are two optional features for Linux
(SELinux and systemd support) that will be enabled automatically if the
relevant header files are found in /usr/include. (See script at ./src/osflags)
Run 'make' to compile the server and client binaries.
Run 'make install' to copy binaries and manpage to the destination directory.
Run 'make test' to compile and run the unit tests. (Requires the check library)
QUICKSTART:
Try it out within your own LAN! Follow these simple steps:
......@@ -103,6 +114,16 @@ end of the tunnel. In this case, ping 192.168.99.1 from the iodine client, and
MISC. INFO:
IPv6:
At the moment the iodined server only supports IPv4. The data inside the tunnel
is IPv4 only.
The client can use IPv4 or IPv6 nameservers to connect to iodined. The relay
nameservers will translate between protocols automatically if needed. Use
options -4 or -6 to force the client to use a specific IP version for its DNS
queries. The client has to force IPv4 if it has dual-stack connectivity and
the hostname handling the tunnel domain has both A and AAAA records.
Routing:
It is possible to route all traffic through the DNS tunnel. To do this, first
add a host route to the nameserver used by iodine over the wired/wireless
......@@ -156,12 +177,13 @@ packet, and one query can be max 256 chars. Each domain name part can be max
63 chars. So your domain name and subdomain should be as short as possible to
allow maximum upstream throughput.
Several DNS request types are supported, with the NULL type expected to provide
the largest downstream bandwidth. Other available types are TXT, SRV, MX,
CNAME and A (returning CNAME), in decreasing bandwidth order. Normally the
Several DNS request types are supported, with the NULL and PRIVATE types
expected to provide the largest downstream bandwidth. The PRIVATE type uses
value 65399 in the private-use range. Other available types are TXT, SRV, MX,
CNAME and A (returning CNAME), in decreasing bandwidth order. Normally the
"best" request type is autodetected and used. However, DNS relays may impose
limits on for example NULL and TXT, making SRV or MX actually the best choice.
This is not autodetected, but can be forced using the -T option. It is
This is not autodetected, but can be forced using the -T option. It is
advisable to try various alternatives especially when the autodetected request
type provides a downstream fragment size of less than 200 bytes.
......@@ -169,14 +191,14 @@ Note that SRV, MX and A (returning CNAME) queries may/will cause additional
lookups by "smart" caching nameservers to get an actual IP address, which may
either slow down or fail completely.
DNS responses for non-NULL queries can be encoded with the same set of codecs
as upstream data. This is normally also autodetected, but no fully exhaustive
tests are done, so some problems may not be noticed when selecting more
advanced codecs. In that case, you'll see failures/corruption in the fragment
size autoprobe. In particular, several DNS relays have been found that change
replies returning hostnames (SRV, MX, CNAME, A) to lowercase only when that
hostname exceeds ca. 180 characters. In these and similar cases, use the -O
option to try other downstream codecs; Base32 should always work.
DNS responses for non-NULL/PRIVATE queries can be encoded with the same set of
codecs as upstream data. This is normally also autodetected, but no fully
exhaustive tests are done, so some problems may not be noticed when selecting
more advanced codecs. In that case, you'll see failures/corruption in the
fragment size autoprobe. In particular, several DNS relays have been found that
change replies returning hostnames (SRV, MX, CNAME, A) to lowercase only when
that hostname exceeds ca. 180 characters. In these and similar cases, use the
-O option to try other downstream codecs; Base32 should always work.
Normal operation now is for the server to _not_ answer a DNS request until
the next DNS request has come in, a.k.a. being "lazy". This way, the server
......@@ -337,8 +359,8 @@ THANKS:
AUTHORS & LICENSE:
Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
Also major contributions by Anne Bezemer.
Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>, 2006-2009 Bjorn
Andersson <flex@kryo.se>. Also major contributions by Anne Bezemer.
Permission to use, copy, modify, and distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
......
iodine - http://code.kryo.se/iodine
***********************************
Extra README file for Android
== Running iodine on Android:
1. Get root access on your android device
2. Find/build a compatible tun.ko for your specific Android kernel
3. Copy tun.ko and the iodine binary to your device:
(Almost all devices need the armeabi binary. Only Intel powered
ones need the x86 build.)
adb push tun.ko /data/local/tmp
adb push iodine /data/local/tmp
adb shell
su
cd /data/local/tmp
chmod 777 iodine
4. Run iodine (see the man page for parameters)
./iodine ...
For more information: http://blog.bokhorst.biz/5123
== Building iodine for Android:
1. Download and install the Android SDK and NDK
2. Download and unpack the iodine sources
3. Build:
cd src
make base64u.h base64u.c
ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
or run "make cross-android" in the iodine root directory.
To build for other archs, specify TARGET_ARCH_ABI:
"make cross-android TARGET_ARCH_ABI=x86"
......@@ -8,6 +8,9 @@ Extra README file for Win32 related stuff
== Running iodine on Windows:
0. After iodine 0.6, you need Windows XP or newer to run.
1. Install the TAP32 driver
http://openvpn.net/index.php/open-source/downloads.html
Choose OpenVPN 2.0.9 Windows Installer, when installing you can
......
[Unit]
Description=Iodine Server
After=local-fs.target network.target
[Service]
EnvironmentFile=-/etc/sysconfig/iodine-server
ExecStart=/usr/local/bin/iodined -i 30 -f $OPTIONS
StandardOutput=syslog
[Install]
WantedBy=multi-user.target
[Unit]
Description=Iodine socket
[Socket]
ListenDatagram=53
[Install]
WantedBy=sockets.target
......@@ -122,7 +122,8 @@ Server sends:
s or S: Downstream encoding Base64, for TXT/CNAME/A/MX
u or U: Downstream encoding Base64u, for TXT/CNAME/A/MX
v or V: Downstream encoding Base128, for TXT/CNAME/A/MX
r or R: Downstream encoding Raw, for TXT/NULL (default for NULL)
r or R: Downstream encoding Raw, for PRIVATE/TXT/NULL (default for
PRIVATE and NULL)
If codec unsupported for request type, server will use Base32; note
that server will answer any mix of request types that a client sends.
Server may disregard this option; client must always use the downstream
......@@ -188,8 +189,8 @@ encoded with the chosen upstream codec.
Downstream data starts with 2 byte header. Then payload data, which may be
compressed.
In NULL responses, downstream data is always raw. In all other response types,
downstream data is encoded (see Options above).
In NULL and PRIVATE responses, downstream data is always raw. In all other
response types, downstream data is encoded (see Options above).
Encoding type is indicated by 1 prefix char:
TXT:
End result is always DNS-chopped (series of len-prefixed strings
......
.\" groff -man -Tascii iodine.8
.TH IODINE 8 "DEC 2009" "User Manuals"
.TH IODINE 8 "JUN 2014" "User Manuals"
.SH NAME
iodine, iodined \- tunnel IPv4 over DNS
.SH SYNOPSIS
......@@ -7,7 +7,7 @@ iodine, iodined \- tunnel IPv4 over DNS
.B iodine [-h]
.B iodine [-f] [-r] [-u
.B iodine [-4] [-6] [-f] [-r] [-u
.I user
.B ] [-P
.I password
......@@ -17,6 +17,8 @@ iodine, iodined \- tunnel IPv4 over DNS
.I chrootdir
.B ] [-d
.I device
.B ] [-R
.I rdomain
.B ] [-m
.I fragsize
.B ] [-M
......@@ -56,7 +58,11 @@ iodine, iodined \- tunnel IPv4 over DNS
.B ] [-p
.I port
.B ] [-n
(
.B auto
|
.I external_ip
)
.B ] [-b
.I dnsport
.B ] [-P
......@@ -65,6 +71,8 @@ iodine, iodined \- tunnel IPv4 over DNS
.I context
.B ] [-F
.I pidfile
.B ] [-i
.I max_idle_time
.B ]
.I tunnel_ip
.B [
......@@ -124,11 +132,20 @@ Apply SELinux 'context' after initialization.
Create 'pidfile' and write process id in it.
.SS Client Options:
.TP
.B -4
Force IPv4 DNS queries
.TP
.B -6
Force IPv6 DNS queries
.TP
.B -r
Skip raw UDP mode. If not used, iodine will try getting the public IP address
of the iodined host and test if it is reachable directly. If it is, traffic
will be sent to the server instead of the DNS relay.
.TP
.B -R rdomain
Use OpenBSD routing domain 'rdomain' for the DNS connection.
.TP
.B -m fragsize
Force maximum downstream fragment size. Not setting this will cause the
client to automatically probe the maximum accepted downstream fragment size.
......@@ -139,7 +156,7 @@ Usable range ca. 100 to 255.
Use this option to scale back upstream bandwidth in favor of downstream
bandwidth.
Also useful for DNS servers that perform unreliably when using full-length
hostnames, noticable when fragment size autoprobe returns very
hostnames, noticeable when fragment size autoprobe returns very
different results each time.
.TP
.B -T dnstype
......@@ -152,6 +169,7 @@ more bandwidth.
In that case, use this option to override the autodetection.
In (expected) decreasing bandwidth order, the supported DNS request types are:
.IR NULL ,
.IR PRIVATE ,
.IR TXT ,
.IR SRV ,
.IR MX ,
......@@ -166,7 +184,10 @@ and
.I A
may/will cause additional lookups by "smart" caching
nameservers to get an actual IP address, which may either slow down or fail
completely.
completely. The
.IR PRIVATE
type uses value 65399 (in the 'private use' range) and requires servers
implementing RFC 3597.
.TP
.B -O downenc
Force downstream encoding type for all query type responses except NULL.
......@@ -218,7 +239,7 @@ connection after 60 seconds of inactivity.
.TP
.B -c
Disable checking the client IP address on all incoming requests.
By default, requests originating from non-matching IP adresses will be
By default, requests originating from non-matching IP addresses will be
rejected, however this will cause problems when requests are routed
via a cluster of DNS servers.
.TP
......@@ -232,10 +253,10 @@ Increase debug level. Level 1 prints info about each RX/TX packet.
Implies the
.B -f
option.
On level 2 (-DD) or higher, DNS queries will be printed literally.
On level 2 (\-DD) or higher, DNS queries will be printed literally.
When using Base128 upstream encoding, this is best viewed as
ISO Latin-1 text instead of (illegal) UTF-8.
This is easily done with : "LC_ALL=C luit iodined -DD ..."
This is easily done with : "LC_ALL=C luit iodined \-DD ..."
(see luit(1)).
.TP
.B -m mtu
......@@ -250,26 +271,36 @@ By default, incoming requests are accepted from all interfaces.
.TP
.B -p port
Make the server listen on 'port' instead of 53 for traffic.
If 'listen_ip' does not include localhost, this 'port' can be the same
as 'dnsport'.
.B Note:
You must make sure the dns requests are forwarded to this port yourself.
.TP
.B -n external_ip
.B -n auto|external_ip
The IP address to return in NS responses. Default is to return the address used
as destination in the query.
If external_ip is 'auto', iodined will use externalip.net web service to
retrieve the external IP of the host and use that for NS responses.
.TP
.B -b dnsport
If this port is specified, all incoming requests not inside the tunnel domain
will be forwarded to this port on localhost, to be handled by a real dns.
If 'listen_ip' does not include localhost, this 'dnsport' can be the
same as 'port'.
.B Note:
The forwarding is not fully transparent, and not advised for use
in production environments.
.TP
.B -i max_idle_time
Make the server stop itself after max_idle_time seconds if no traffic have been received.
This should be combined with systemd or upstart on demand activation for being effective.
.SS Client Arguments:
.TP
.B nameserver
The nameserver to use to relay the dns traffic. This can be any relaying
nameserver or the server running iodined if reachable. This field can be
given as an IP address, or as a hostname. This argument is optional, and
if not specified a nameserver will be read from the
given as an IPv4/IPv6 address or as a hostname. This argument is optional,
and if not specified a nameserver will be read from the
.I /etc/resolv.conf
file.
.TP
......@@ -285,7 +316,7 @@ must be the same on both the client and the server.
.B tunnel_ip[/netmask]
This is the server's ip address on the tun interface. The client will be
given the next ip number in the range. It is recommended to use the
10.0.0.0 or 172.16.0.0 ranges. The default netmask is /27, can be overriden
10.0.0.0 or 172.16.0.0 ranges. The default netmask is /27, can be overridden
by specifying it here. Using a smaller network will limit the number of
concurrent users.
.TP
......@@ -327,7 +358,6 @@ is set, iodined will use the value it is set to as password instead of asking
for one. The
.B -P
option still has precedence.
.El
.SH SEE ALSO
The README file in the source distribution contains some more elaborate
information.
......
#
# iodine for Android
#
# by Marcel Bokhorst
# http://blog.bokhorst.biz/5123/computers-en-internet/iodine-for-android/
#
# cd iodine-0.6.0-rc1/src
# make base64u.h base64u.c
# .../ndk-build NDK_PROJECT_PATH=. APP_BUILD_SCRIPT=Android.mk
#
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := iodine
LOCAL_SRC_FILES := tun.c dns.c read.c encoding.c login.c base32.c base64.c base64u.c base128.c md5.c common.c iodine.c client.c util.c
LOCAL_CFLAGS := -c -DANDROID -DLINUX -DIFCONFIGPATH=\"/system/bin/\" -Wall
LOCAL_LDLIBS := -lz
include $(BUILD_EXECUTABLE)
......@@ -9,7 +9,7 @@ ARCH = `uname -m`
LIBPATH = -L.
LDFLAGS += -lz `sh osflags $(TARGETOS) link` $(LIBPATH)
CFLAGS += -c -g -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags`
CFLAGS += -std=c99 -c -g -Wall -D$(OS) -pedantic `sh osflags $(TARGETOS) cflags`
all: stateos $(CLIENT) $(SERVER)
......@@ -26,7 +26,7 @@ $(SERVER): $(COMMONOBJS) $(SERVEROBJS)
@mkdir -p ../bin
@$(CC) $(COMMONOBJS) $(SERVEROBJS) -o $(SERVER) $(LDFLAGS)
.c.o:
.c.o:
@echo CC $<
@$(CC) $(CFLAGS) $< -o $@
......@@ -43,4 +43,5 @@ base64u.h: base64.h
clean:
@echo "Cleaning src/"
@rm -f $(CLIENT){,.exe} $(SERVER){,.exe} *~ *.o *.core base64u.*
@rm -rf obj libs #android stuff
#ifndef __FIX_ANDROID_H__
#define __FIX_ANDROID_H__
typedef struct {
unsigned id :16;
unsigned rd :1;
unsigned tc :1;
unsigned aa :1;
unsigned opcode :4;
unsigned qr :1;
unsigned rcode :4;
unsigned cd: 1;
unsigned ad: 1;
unsigned unused :1;
unsigned ra :1;
unsigned qdcount :16;
unsigned ancount :16;
unsigned nscount :16;
unsigned arcount :16;
} HEADER;
#define NOERROR 0
#define FORMERR 1
#define SERVFAIL 2
#define NXDOMAIN 3
#define NOTIMP 4
#define REFUSED 5
#define C_IN 1
#define T_A 1
#define T_CNAME 5
#define T_NULL 10
#define T_MX 15
#define T_TXT 16
#define T_SRV 33
#endif
......@@ -42,7 +42,7 @@
* accent chars since they might readily be entered in normal use,
* don't use 254-255 because of possible function overloading in DNS systems.
*/
static const unsigned char cb128[] =
static const unsigned char cb128[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
"\274\275\276\277"
"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317"
......@@ -75,19 +75,19 @@ struct encoder
return &base128_encoder;
}
static int
static int
base128_handles_dots()
{
return 0;
}
static int
static int
base128_blksize_raw()
{
return BLKSIZE_RAW;
}
static int
static int
base128_blksize_enc()
{
return BLKSIZE_ENC;
......@@ -109,7 +109,7 @@ base128_reverse_init()
}
}
static int
static int
base128_encode(char *buf, size_t *buflen, const void *data, size_t size)
/*
* Fills *buf with max. *buflen characters, encoding size bytes of *data.
......@@ -231,7 +231,7 @@ base128_decode(void *buf, size_t *buflen, const char *str, size_t slen)
if (iout >= *buflen || iin + 1 >= slen ||
str[iin] == '\0' || str[iin + 1] == '\0')
break;
ubuf[iout] = ((REV128(ustr[iin]) & 0x7f) << 1) |
ubuf[iout] = ((REV128(ustr[iin]) & 0x7f) << 1) |
((REV128(ustr[iin + 1]) & 0x40) >> 6);
iin++; /* 0 used up, iin=1 */
iout++;
......
/*
* Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
* Mostly rewritten 2009 J.A.Bezemer@opensourcepartners.nl
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -25,9 +26,9 @@
#define BLKSIZE_RAW 5
#define BLKSIZE_ENC 8
static const char cb32[] =
static const char cb32[] =
"abcdefghijklmnopqrstuvwxyz012345";
static const char cb32_ucase[] =
static const char cb32_ucase[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZ012345";
static unsigned char rev32[256];
static int reverse_init = 0;
......@@ -55,19 +56,19 @@ struct encoder
return &base32_encoder;
}
static int
static int
base32_handles_dots()
{
return 0;
}
static int
static int
base32_blksize_raw()
{
return BLKSIZE_RAW;
}
static int
static int
base32_blksize_enc()
{
return BLKSIZE_ENC;
......@@ -104,7 +105,7 @@ b32_8to5(int in)
return rev32[in];
}
static int
static int
base32_encode(char *buf, size_t *buflen, const void *data, size_t size)
/*
* Fills *buf with max. *buflen characters, encoding size bytes of *data.
......@@ -222,7 +223,7 @@ base32_decode(void *buf, size_t *buflen, const char *str, size_t slen)
if (iout >= *buflen || iin + 1 >= slen ||
str[iin] == '\0' || str[iin + 1] == '\0')
break;
ubuf[iout] = ((REV32(str[iin]) & 0x1f) << 3) |
ubuf[iout] = ((REV32(str[iin]) & 0x1f) << 3) |
((REV32(str[iin + 1]) & 0x1c) >> 2);
iin++; /* 0 used up, iin=1 */
iout++;
......@@ -231,8 +232,8 @@ base32_decode(void *buf, size_t *buflen, const char *str, size_t slen)
str[iin] == '\0' || str[iin + 1] == '\0' ||
str[iin + 2] == '\0')
break;
ubuf[iout] = ((REV32(str[iin]) & 0x03) << 6) |
((REV32(str[iin + 1]) & 0x1f) << 1) |
ubuf[iout] = ((REV32(str[iin]) & 0x03) << 6) |
((REV32(str[iin + 1]) & 0x1f) << 1) |
((REV32(str[iin + 2]) & 0x10) >> 4);
iin += 2; /* 1,2 used up, iin=3 */
iout++;
......
/*
* Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
......
/*
* Copyright (c) 2006-2009 Bjorn Andersson <flex@kryo.se>, Erik Ekman <yarrick@kryo.se>
* Copyright (c) 2006-2014 Erik Ekman <yarrick@kryo.se>,
* 2006-2009 Bjorn Andersson <flex@kryo.se>
* Mostly rewritten 2009 J.A.Bezemer@opensourcepartners.nl
*
* Permission to use, copy, modify, and distribute this software for any
......@@ -27,7 +28,7 @@
/* Note: the "unofficial" char is last here, which means that the \377 pattern
in DOWNCODECCHECK1 ('Y' request) will properly test it. */
static const char cb64[] =
static const char cb64[] =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-0123456789+";
static unsigned char rev64[256];
static int reverse_init = 0;
......@@ -55,19 +56,19 @@ struct encoder
return &base64_encoder;
}
static int
static int
base64_handles_dots()
{
return 0;
}
static int
static int
base64_blksize_raw()
{
return BLKSIZE_RAW;
}
static int
static int
base64_blksize_enc()
{
return BLKSIZE_ENC;
......@@ -89,7 +90,7 @@ base64_reverse_init()
}
}
static int
static int
base64_encode(char *buf, size_t *buflen, const void *data, size_t size)
/*
* Fills *buf with max. *buflen characters, encoding size bytes of *data.
......@@ -177,7 +178,7 @@ base64_decode(void *buf, size_t *buflen, const char *str, size_t slen)
if (iout >= *buflen || iin + 1 >= slen ||
str[