Finally: Tor on Android W/O Rooting!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 The latest beta of Firefox 4 on Android (and Maemo) is quite nice. You can get it here: http://www.mozilla.com/en-US/mobile/ However, it is lacking the ability to even manually set proxy settings through any sort of usable interface. Android also lacks the ability to set system wide proxy settings, which has been a real problem with getting Orbot (aka Tor on Android) working for normal users. I have taken the first step towards porting TorButton to Firefox on Android, and created a very simple add-on which exposes the proxy settings. This means you can use Orbot on Android 2.x devices and route your web traffic through it without needing to root your device! Also, since I know understand how Firefox mobile add-ons are built, I can now start engaging with Mike around a full port of TorButton. For now though, if you are eager to play, you can find proxymob here: https://guardianproject.info/downloads/proxymob-addon-0.0.5.xpi https://guardianproject.info/downloads/proxymob-addon-0.0.5.xpi.asc Source is here: https://github.com/guardianproject/ProxyMob +nathan -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkzWTSwACgkQhemw+yiNNc6nlgCdGFQQqjCPZFymGHgST/nLADYG 7yoAn0kpGKrLZeenCvu+GTE5tz31EqiV =sRnw -END PGP SIGNATURE- *** To unsubscribe, send an e-mail to majord...@torproject.org with unsubscribe or-talkin the body. http://archives.seul.org/or/talk/
Re: Tor for Android
On 10/12/2009 03:40 AM, M wrote: What about Tor for Nokias or PDAs? No one that we know of has worked on Tor for symbian. If people have done this, let us know. -- Andrew Lewman The Tor Project pgp 0x31B0974B Website: https://torproject.org/ Blog: https://blog.torproject.org/ Identi.ca: torproject *** To unsubscribe, send an e-mail to majord...@torproject.org with unsubscribe or-talkin the body. http://archives.seul.org/or/talk/
Tor for Android
http://www.cl.cam.ac.uk/research/dtg/android/tor/ TorProxy and Shadow Summer placement project, written by Connell Gauld. TorProxy is an Android application that makes it possible to use Internet sites and services anonymously from a mobile device. This is possible thanks to the Tor network and OnionCoffee. TorProxy can be used by many different Android applications to obtain an anonymous Internet application. For example, if you want to browse website anonymously you will need to install a web browser which uses TorProxy such as Shadow (see below). Shadow is an Android application allows you to browse the Web anonymously from your mobile phone. The Shadow browser requires TorProxy (see above) do do this. In addition to using the Tor network to anonymously retrieve information from the Web, Shadow also helps you manage any cookies sent to Shadow by Websites to protect your browsing history. The source code of TorProxy and Shadow are available under the GPL v2 license. Please email us for further details. We hope to provide public access to our SVN repository shortly. How to use TorProxy and Shadow 1. Install TorProxy and Shadow by downloading them from the Android Marketplace. 2. Start the TorProxy application. 3. Select a profile for TorProxy: * off — do not connect to the tor network. * on-demand — only connect to the tor network if a program (e.g. Shadow) needs it. This profile is probably the best choice if you only want to make occassional use of an anonymous Internet connection. * always on — maintain an anonymous connection whenever the phone is actively in use. 4. Once a connection to the Tor network is requested, a notification of the state of the connection appears in the notification bar. A countdown will appear with an estimate of the time remaining before an anonymous connection becomes available. This will take approximately one minute in the first instance, and around 35 seconds when reconnecting after the phone has woken up from a sleep state. 5. To browse the Web, start the Shadow web browser. Shadow works in a very similar way to the normal Android Web browser. The Menu button reveals the usual browser options. Typing in a URL will initiate an anonymous connection over the Internet via Tor. Frequently asked questions Why is the Google Website frequently displayed in a foreign language? Google determines the language you want from the internet address of your device. When browsing anonymously, the Tor network may provide an internet address from another country. You can click on the Google.com in English link to see the website in English. Source Download The TorProxy and Shadow source code is available through anonymous access to our SVN repository: svn co http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor We developed and compile this code using Eclipse with Subclipse and the Android developer SDK. Each of the four modules in the above repository should be checked out as separate eclipse projects (each has its own .project file). Compiling TorProxyLib 1. Checkout URL: http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor/TorProxyLib 2. Build in Eclipse as normal 3. Right click on export-torproxylib.jardesc and choose Create Jar Compiling TorProxy 1. Checkout URL: http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor/TorProxy Compiling Shadow 1. Checkout URL: http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor/Shadow Compiling TorProxyExamples 1. Checkout URL: http://www.cl.cam.ac.uk/research/dtg/code/svn/android-tor/TorProxyExamples Documentation for Application Developers Overview In order to anonymize your application's Internet communication: 1. Import TorProxyLib.jar into your project 2. Connect to the TorProxy control service 3. Register for the TorProxy status change broadcast 4. When the Tor connection is available, create your socket and tunnel it through SocksProxy 1. TorProxyLib This library contains everything you need to allow your application to anonymize its sockets. Add TorProxyLib.jar to your build path. 2. Connect to the TorProxy control service The TorProxy service exports an interface which you can use to check the availability of the anonymous connection and register your desire to use it. Example: // Keep track of the control service private ITorProxyControl mControlService = null; private final IntentFilter torStatusFilter = new IntentFilter( TorProxyLib.STATUS_CHANGE_INTENT); // Service connection to TorProxy service private ServiceConnection mSvcConn = new ServiceConnection() { @Override public void onServiceConnected(ComponentName name, IBinder service) { mControlService = ITorProxyControl.Stub.asInterface(service); // Connected to Control Service // Perhaps check Tor status here } @Override public void
Re: Tor for Android
It also seems like TorProxy should have a new identity button. Shadow suggests that users should restart TorProxy if connections fail and that seems costly. Perhaps it's not too costly on the network or cpu? The Shadow Browser/TorProxy setup seems like a pretty great start for anonymity on Android. It's great stuff! Exciting! Best, Jacob signature.asc Description: OpenPGP digital signature
Tor on Android
Just for lark, more than anything else, I built Tor on Android and have it running on a (release) HTC Dream: $ ./tor -f torrc Dec 28 12:40:33.468 [notice] Tor v0.2.0.32 (r17346). This is experimental software. Do not rely on it for strong anonymity. (Running on Linux armv6l) Dec 28 12:40:33.478 [notice] Initialized libevent version 1.4.9-stable using method epoll. Good. Dec 28 12:40:33.480 [notice] Opening Socks listener on 127.0.0.1:9050 The native web browser doesn't have support for SOCKS proxies, only HTTP proxies, so one would have to add a HTTP-SOCKS proxy in the mix to get it working. However, I did test it with Firefox routing SOCKS requests over a USB link to Tor running on the phone. The 3G latencies and limited CPU power make for a pretty slow result, but it does work. It's back to work tomorrow, so this is probably as far as I'll take it. If anyone wants the binaries or build instructions (I didn't do anything shockingly odd), let me know. Cheers AGL -- Adam Langley a...@imperialviolet.org http://www.imperialviolet.org
Re: Tor on Android
Hi Adam, I just bought an OpenMoko, and have been meaning to try Android on it. I would like to get Tor running on Android. I also have an HTC Dream that I've been meaning to convert to linux for awhile now. If you have some instructions on how to do this, I would very much appreciate it. Have you tried using iptables and Tor's TransPort/DNSPort to re-route your traffic through Tor since the web browser doesn't support SOCKS? Best regards, Kyle On Sun, Dec 28, 2008 at 12:53 PM, Adam Langley a...@imperialviolet.orgwrote: Just for lark, more than anything else, I built Tor on Android and have it running on a (release) HTC Dream: $ ./tor -f torrc Dec 28 12:40:33.468 [notice] Tor v0.2.0.32 (r17346). This is experimental software. Do not rely on it for strong anonymity. (Running on Linux armv6l) Dec 28 12:40:33.478 [notice] Initialized libevent version 1.4.9-stable using method epoll. Good. Dec 28 12:40:33.480 [notice] Opening Socks listener on 127.0.0.1:9050 The native web browser doesn't have support for SOCKS proxies, only HTTP proxies, so one would have to add a HTTP-SOCKS proxy in the mix to get it working. However, I did test it with Firefox routing SOCKS requests over a USB link to Tor running on the phone. The 3G latencies and limited CPU power make for a pretty slow result, but it does work. It's back to work tomorrow, so this is probably as far as I'll take it. If anyone wants the binaries or build instructions (I didn't do anything shockingly odd), let me know. Cheers AGL -- Adam Langley a...@imperialviolet.org http://www.imperialviolet.org
Re: Tor on Android
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Adam, I would like the binaries and build instructions. I have a G1 development phone (T-Mobile). Thanks. Alex Donnini Adam Langley wrote: Just for lark, more than anything else, I built Tor on Android and have it running on a (release) HTC Dream: $ ./tor -f torrc Dec 28 12:40:33.468 [notice] Tor v0.2.0.32 (r17346). This is experimental software. Do not rely on it for strong anonymity. (Running on Linux armv6l) Dec 28 12:40:33.478 [notice] Initialized libevent version 1.4.9-stable using method epoll. Good. Dec 28 12:40:33.480 [notice] Opening Socks listener on 127.0.0.1:9050 The native web browser doesn't have support for SOCKS proxies, only HTTP proxies, so one would have to add a HTTP-SOCKS proxy in the mix to get it working. However, I did test it with Firefox routing SOCKS requests over a USB link to Tor running on the phone. The 3G latencies and limited CPU power make for a pretty slow result, but it does work. It's back to work tomorrow, so this is probably as far as I'll take it. If anyone wants the binaries or build instructions (I didn't do anything shockingly odd), let me know. Cheers AGL -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAklX8TEACgkQ3ju7mowpX9WohgCggvSDRkYN9PHpWKKMD03S/fOQ 6sMAoIyxVC9a19qh8D99pkH9hfAxll+U =4qgL -END PGP SIGNATURE-
Re: Tor on Android
On Sun, Dec 28, 2008 at 1:29 PM, Kyle Williams kyle.kwilli...@gmail.com wrote: Have you tried using iptables and Tor's TransPort/DNSPort to re-route your traffic through Tor since the web browser doesn't support SOCKS? If you have a dev phone, that might be possible. However, the release phones don't provide you with root (or any other way to setup iptables) AGL -- Adam Langley a...@imperialviolet.org http://www.imperialviolet.org
Re: Tor on Android
Looks like I should do a quick write up: One caveat, I'm running Android 1.1 PLAT-RC16, which is an unreleased testing version. However, I don't believe that anything pertinent has changed. 1) Setup your phone for debugging. Home - Settings - Applications - Development. Check both USB debugging and Stay Awake. 2) Setup udev See http://code.google.com/android/intro/develop-and-debug.html and search the page for udev. This is to make sure that the USB device inodes get the correct permissions. 3) Download the SDK http://code.google.com/android/intro/installing.html Put the tools/ directory from the SDK in your $PATH. You'll need the adb utility from there. 4) Plug your phone into a USB port on your computer `adb devices` should list a single device. 5) Grab a full source release and build it Follow http://source.android.com/download. It's a lot of downloading, disk space and build time. If you aren't running an Intel x86 or x86-64 build platform you might have some issues. If you are running x86-64 you'll still have some issues. Many of them are covered on the above page but one which I had was that my distro (Ubuntu 8.10) doesn't seem to have 32-bit libreadline libraries. I built a 32-bit libreadline from source (this is from memory only): % export CC=gcc -m32 % ./configure % make % sudo cp libreadline.so.5.2 libhistory.so.5.2 /usr/lib32 % sudo chmod a+rx /usr/lib32/libreadline.so.5.2 /usr/lib32/libhistory.so.5.2 % ldconfig (might setup the symlinks /usr/lib/libreadline.so for you, otherwise, do it manually) Hopefully you can do a successful `make` run with the android source. 6) Setup agcc Once you have a source build, you should have an ARM cross-compiler in mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin. The agcc[1] script will give all the correct arguments to it to build binaries with bionic etc. Put both agcc and /arm-eabi-4.3.1 in your $PATH. [1] http://plausible.org/andy/agcc 7) Build a test binary % cat test.c EOF #include stdio.h int main() { printf(hello android\n); return 0; } EOF % agcc test.c % file ./a.out That should get you an ARM binary 8) Try running it % adb push a.out /sqlite_stmt_journals % adb shell $ cd /sqlite_stmt_journals $ ./a.out /sqlite_stmt_journals is just a tmpfs filesystem that's easy to get to. 9) Build libevent Download libevent % export CC=agcc % ./configure --host=arm-eabi I had to manually disable select support in config.h and remove select.c (and everything else to do with select) from the Makefile because bionic seems to be missing fd_mask structures. I also didn't bother building anything in /test. Hopefully you end up with libevent.a (probably in .libs). Copy it to mydroid/out/target/product/generic/obj/lib. 10) Setup include paths I added these lines to the list of include paths in agcc: -I$DROID/external/libevent-1.4.9-stable, -I$DROID/external/openssl/include, -I$DROID/external/zlib, The first is where I happened to build libevent. Your location may vary. The other two are path of the standard source distribution. 11) Build tor I used 0.2.0.32 Firstly, Android doesn't include deprecated OpenSSL functions, so add a wrapper to src/common/crypto.c: +++ tor-0.2.0.32-agl/src/common/crypto.c 2008-12-28 12:24:25.0 -0800 @@ -387,6 +387,37 @@ tor_free(env); } +RSA *RSA_generate_key(int bits, unsigned long e_value, + void (*callback)(int,int,void *), void *cb_arg) +{ +BN_GENCB cb; +int i; +RSA *rsa = RSA_new(); +BIGNUM *e = BN_new(); + +if(!rsa || !e) goto err; + +/* The problem is when building with 8, 16, or 32 BN_ULONG, + * unsigned long can be larger */ +for (i=0; i(int)sizeof(unsigned long)*8; i++) +{ +if (e_value (1ULi)) +if (BN_set_bit(e,i) == 0) +goto err; +} + +BN_GENCB_set_old(cb, callback, cb_arg); + +if(RSA_generate_key_ex(rsa, bits, e, cb)) { +BN_free(e); +return rsa; +} +err: +if(e) BN_free(e); +if(rsa) RSA_free(rsa); +return 0; +} + Then, the only other issues I had were with some odd namespace collision with log.h. I'll include the diffs, although I didn't bother pinning down the problem, I just worked around where it popped up: --- tor-0.2.0.32/src/common/log.h 2008-02-26 11:56:29.0 -0800 +++ tor-0.2.0.32-agl/src/common/log.h 2008-12-28 12:02:17.0 -0800 @@ -11,7 +11,7 @@ * \brief Headers for log.c **/ -#ifndef __LOG_H +#ifndef __TOR_LOG_H #define LOG_H_ID $Id: log.h 13412 2008-02-07 05:31:47Z nickm $ #include compat.h @@ -180,6 +180,6 @@ #endif /* !GNUC */ -# define __LOG_H +# define __TOR_LOG_H #endif --- tor-0.2.0.32/src/or/buffers.c 2008-11-20 14:14:26.0 -0800 +++ tor-0.2.0.32-agl/src/or/buffers.c 2008-12-28 12:03:08.0 -0800 @@ -14,6 +14,7 @@ * memory,
Re: Tor on Android
Thank you very much. :)I'll post some results when I have them. - Kyle On Sun, Dec 28, 2008 at 3:55 PM, Adam Langley a...@imperialviolet.orgwrote: Looks like I should do a quick write up: One caveat, I'm running Android 1.1 PLAT-RC16, which is an unreleased testing version. However, I don't believe that anything pertinent has changed. 1) Setup your phone for debugging. Home - Settings - Applications - Development. Check both USB debugging and Stay Awake. 2) Setup udev See http://code.google.com/android/intro/develop-and-debug.html and search the page for udev. This is to make sure that the USB device inodes get the correct permissions. 3) Download the SDK http://code.google.com/android/intro/installing.html Put the tools/ directory from the SDK in your $PATH. You'll need the adb utility from there. 4) Plug your phone into a USB port on your computer `adb devices` should list a single device. 5) Grab a full source release and build it Follow http://source.android.com/download. It's a lot of downloading, disk space and build time. If you aren't running an Intel x86 or x86-64 build platform you might have some issues. If you are running x86-64 you'll still have some issues. Many of them are covered on the above page but one which I had was that my distro (Ubuntu 8.10) doesn't seem to have 32-bit libreadline libraries. I built a 32-bit libreadline from source (this is from memory only): % export CC=gcc -m32 % ./configure % make % sudo cp libreadline.so.5.2 libhistory.so.5.2 /usr/lib32 % sudo chmod a+rx /usr/lib32/libreadline.so.5.2 /usr/lib32/libhistory.so.5.2 % ldconfig (might setup the symlinks /usr/lib/libreadline.so for you, otherwise, do it manually) Hopefully you can do a successful `make` run with the android source. 6) Setup agcc Once you have a source build, you should have an ARM cross-compiler in mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin. The agcc[1] script will give all the correct arguments to it to build binaries with bionic etc. Put both agcc and /arm-eabi-4.3.1 in your $PATH. [1] http://plausible.org/andy/agcc 7) Build a test binary % cat test.c EOF #include stdio.h int main() { printf(hello android\n); return 0; } EOF % agcc test.c % file ./a.out That should get you an ARM binary 8) Try running it % adb push a.out /sqlite_stmt_journals % adb shell $ cd /sqlite_stmt_journals $ ./a.out /sqlite_stmt_journals is just a tmpfs filesystem that's easy to get to. 9) Build libevent Download libevent % export CC=agcc % ./configure --host=arm-eabi I had to manually disable select support in config.h and remove select.c (and everything else to do with select) from the Makefile because bionic seems to be missing fd_mask structures. I also didn't bother building anything in /test. Hopefully you end up with libevent.a (probably in .libs). Copy it to mydroid/out/target/product/generic/obj/lib. 10) Setup include paths I added these lines to the list of include paths in agcc: -I$DROID/external/libevent-1.4.9-stable, -I$DROID/external/openssl/include, -I$DROID/external/zlib, The first is where I happened to build libevent. Your location may vary. The other two are path of the standard source distribution. 11) Build tor I used 0.2.0.32 Firstly, Android doesn't include deprecated OpenSSL functions, so add a wrapper to src/common/crypto.c: +++ tor-0.2.0.32-agl/src/common/crypto.c 2008-12-28 12:24:25.0 -0800 @@ -387,6 +387,37 @@ tor_free(env); } +RSA *RSA_generate_key(int bits, unsigned long e_value, + void (*callback)(int,int,void *), void *cb_arg) +{ +BN_GENCB cb; +int i; +RSA *rsa = RSA_new(); +BIGNUM *e = BN_new(); + +if(!rsa || !e) goto err; + +/* The problem is when building with 8, 16, or 32 BN_ULONG, + * unsigned long can be larger */ +for (i=0; i(int)sizeof(unsigned long)*8; i++) +{ +if (e_value (1ULi)) +if (BN_set_bit(e,i) == 0) +goto err; +} + +BN_GENCB_set_old(cb, callback, cb_arg); + +if(RSA_generate_key_ex(rsa, bits, e, cb)) { +BN_free(e); +return rsa; +} +err: +if(e) BN_free(e); +if(rsa) RSA_free(rsa); +return 0; +} + Then, the only other issues I had were with some odd namespace collision with log.h. I'll include the diffs, although I didn't bother pinning down the problem, I just worked around where it popped up: --- tor-0.2.0.32/src/common/log.h 2008-02-26 11:56:29.0 -0800 +++ tor-0.2.0.32-agl/src/common/log.h 2008-12-28 12:02:17.0 -0800 @@ -11,7 +11,7 @@ * \brief Headers for log.c **/ -#ifndef __LOG_H +#ifndef __TOR_LOG_H #define LOG_H_ID $Id: log.h 13412 2008-02-07 05:31:47Z nickm $ #include compat.h
Re: Tor on Android
Nice stuff! A few comments. On Sun, Dec 28, 2008 at 03:55:21PM -0800, Adam Langley wrote: [...] 9) Build libevent Download libevent % export CC=agcc % ./configure --host=arm-eabi I had to manually disable select support in config.h and remove select.c (and everything else to do with select) from the Makefile because bionic seems to be missing fd_mask structures. I also didn't bother building anything in /test. Hopefully you end up with libevent.a (probably in .libs). Copy it to mydroid/out/target/product/generic/obj/lib. Hm. Libevent should be made to detect this. Ordinarily, fd_mask is defined in sys/select.h or something it includes. Can you grep around a little in the Android headers to make sure it's not defined anywhere? If it isn't, we can probably define it to long without hurting anything, so long as we define NFDBITS to match. 11) Build tor I used 0.2.0.32 Firstly, Android doesn't include deprecated OpenSSL functions, so add a wrapper to src/common/crypto.c: I've changed trunk to use RSA_generate_key_ex when we have it, and to only use RSA_generate_key on OpenSSL 0.9.7, which doesn't have RSA_generate_key_ex(). This way, we won't need to copy code from OpenSSL and make our license even more complicated. ;) (A reminder to folks: when you paste code that you didn't write, please mention the fact? Thanks!) [...] -#ifndef __LOG_H +#ifndef __TOR_LOG_H I noticed in trunk that the header files didn't use a consistent macro naming scheme, so I've switched them all to use the _TOR_FILENAME_H convention, which seemed least likely to collide with anything. --- tor-0.2.0.32/src/or/buffers.c 2008-11-20 14:14:26.0 -0800 +++ tor-0.2.0.32-agl/src/or/buffers.c 2008-12-28 12:03:08.0 -0800 @@ -14,6 +14,7 @@ * memory, file descriptors, or TLS connections. **/ #define BUFFERS_PRIVATE +#include src/common/log.h #include or.h Hm. Usually if system headers are getting searched before our headers, that's a sign that the C compiler is acting weird. Can you investigate this one a little more? As you can tell, I'd like 0.2.1.x to build out-of-the-box for Android, especially given how little code changing seems to be required. Yrs, -- Nick Mathewson
Re: Tor on Android
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Great. Thanks. Adam Langley wrote: Looks like I should do a quick write up: One caveat, I'm running Android 1.1 PLAT-RC16, which is an unreleased testing version. However, I don't believe that anything pertinent has changed. 1) Setup your phone for debugging. Home - Settings - Applications - Development. Check both USB debugging and Stay Awake. 2) Setup udev See http://code.google.com/android/intro/develop-and-debug.html and search the page for udev. This is to make sure that the USB device inodes get the correct permissions. 3) Download the SDK http://code.google.com/android/intro/installing.html Put the tools/ directory from the SDK in your $PATH. You'll need the adb utility from there. 4) Plug your phone into a USB port on your computer `adb devices` should list a single device. 5) Grab a full source release and build it Follow http://source.android.com/download. It's a lot of downloading, disk space and build time. If you aren't running an Intel x86 or x86-64 build platform you might have some issues. If you are running x86-64 you'll still have some issues. Many of them are covered on the above page but one which I had was that my distro (Ubuntu 8.10) doesn't seem to have 32-bit libreadline libraries. I built a 32-bit libreadline from source (this is from memory only): % export CC=gcc -m32 % ./configure % make % sudo cp libreadline.so.5.2 libhistory.so.5.2 /usr/lib32 % sudo chmod a+rx /usr/lib32/libreadline.so.5.2 /usr/lib32/libhistory.so.5.2 % ldconfig (might setup the symlinks /usr/lib/libreadline.so for you, otherwise, do it manually) Hopefully you can do a successful `make` run with the android source. 6) Setup agcc Once you have a source build, you should have an ARM cross-compiler in mydroid/prebuilt/linux-x86/toolchain/arm-eabi-4.3.1/bin. The agcc[1] script will give all the correct arguments to it to build binaries with bionic etc. Put both agcc and /arm-eabi-4.3.1 in your $PATH. [1] http://plausible.org/andy/agcc 7) Build a test binary % cat test.c EOF #include stdio.h int main() { printf(hello android\n); return 0; } EOF % agcc test.c % file ./a.out That should get you an ARM binary 8) Try running it % adb push a.out /sqlite_stmt_journals % adb shell $ cd /sqlite_stmt_journals $ ./a.out /sqlite_stmt_journals is just a tmpfs filesystem that's easy to get to. 9) Build libevent Download libevent % export CC=agcc % ./configure --host=arm-eabi I had to manually disable select support in config.h and remove select.c (and everything else to do with select) from the Makefile because bionic seems to be missing fd_mask structures. I also didn't bother building anything in /test. Hopefully you end up with libevent.a (probably in .libs). Copy it to mydroid/out/target/product/generic/obj/lib. 10) Setup include paths I added these lines to the list of include paths in agcc: -I$DROID/external/libevent-1.4.9-stable, -I$DROID/external/openssl/include, -I$DROID/external/zlib, The first is where I happened to build libevent. Your location may vary. The other two are path of the standard source distribution. 11) Build tor I used 0.2.0.32 Firstly, Android doesn't include deprecated OpenSSL functions, so add a wrapper to src/common/crypto.c: +++ tor-0.2.0.32-agl/src/common/crypto.c 2008-12-28 12:24:25.0 -0800 @@ -387,6 +387,37 @@ tor_free(env); } +RSA *RSA_generate_key(int bits, unsigned long e_value, + void (*callback)(int,int,void *), void *cb_arg) +{ +BN_GENCB cb; +int i; +RSA *rsa = RSA_new(); +BIGNUM *e = BN_new(); + +if(!rsa || !e) goto err; + +/* The problem is when building with 8, 16, or 32 BN_ULONG, + * unsigned long can be larger */ +for (i=0; i(int)sizeof(unsigned long)*8; i++) +{ +if (e_value (1ULi)) +if (BN_set_bit(e,i) == 0) +goto err; +} + +BN_GENCB_set_old(cb, callback, cb_arg); + +if(RSA_generate_key_ex(rsa, bits, e, cb)) { +BN_free(e); +return rsa; +} +err: +if(e) BN_free(e); +if(rsa) RSA_free(rsa); +return 0; +} + Then, the only other issues I had were with some odd namespace collision with log.h. I'll include the diffs, although I didn't bother pinning down the problem, I just worked around where it popped up: --- tor-0.2.0.32/src/common/log.h 2008-02-26 11:56:29.0 -0800 +++ tor-0.2.0.32-agl/src/common/log.h 2008-12-28 12:02:17.0 -0800 @@ -11,7 +11,7 @@ * \brief Headers for log.c **/ -#ifndef __LOG_H +#ifndef __TOR_LOG_H #define LOG_H_ID $Id: log.h 13412 2008-02-07 05:31:47Z nickm $ #include compat.h @@ -180,6
Re: Tor on Android
On Sun, Dec 28, 2008 at 6:30 PM, Nick Mathewson ni...@freehaven.net wrote: Hm. Libevent should be made to detect this. Ordinarily, fd_mask is defined in sys/select.h or something it includes. Can you grep around a little in the Android headers to make sure it's not defined anywhere? If it isn't, we can probably define it to long without hurting anything, so long as we define NFDBITS to match. It's not defined. This is probably a mistake on bionic's part since, from reading around, fd_mask is POSIX. Rather than change libevent, probably bionic should be changed. I'll look at doing that tomorrow. Also, android has a config include file which is included in all compiles. This might well be a mistake as it defines HAVE_SYS_SOCKET_H and that's pretty rude. This way, we won't need to copy code from OpenSSL and make our license even more complicated. ;) (A reminder to folks: when you paste code that you didn't write, please mention the fact? Thanks!) Sorry! That is, indeed, OpenSSL code. I noticed in trunk that the header files didn't use a consistent macro naming scheme, so I've switched them all to use the _TOR_FILENAME_H convention, which seemed least likely to collide with anything. Great! Hm. Usually if system headers are getting searched before our headers, that's a sign that the C compiler is acting weird. Can you investigate this one a little more? As you can tell, I'd like 0.2.1.x to build out-of-the-box for Android, especially given how little code changing seems to be required. With custom libc etc, this C compiler is certainly acting a little weird! With a little investigate, the issue is in the agcc script. I had it add the libevent directory as an include path, but it put's -I options last on the resulting command line. Thus libevent's log.h was getting picked up. I've attached a version which collects -I arguments and puts them first on the gcc command line and this allows tip-of-SVN to build with these modifications: --- or.h(revision 17805) +++ or.h(working copy) @@ -2872,7 +2872,7 @@ int config_get_lines(const char *string, config_line_t **result); void config_free_lines(config_line_t *front); -int options_trial_assign(config_line_t *list, int use_defaults, +setopt_err_t options_trial_assign(config_line_t *list, int use_defaults, int clear_first, char **msg); int resolve_my_address(int warn_severity, or_options_t *options, uint32_t *addr, char **hostname_out); This looks like the compiler is just being more picky (maybe because it's GCC 4.3?) Enums aren't technically ints. Index: eventdns.c === --- eventdns.c (revision 17805) +++ eventdns.c (working copy) @@ -102,7 +102,7 @@ #endif #ifdef HAVE_NETINET_IN6_H -#include netinet6/in6.h +#include netinet/in6.h #endif #ifdef WIN32 The configure script checks for netinet/in6.h, but eventdns.c uses netinet6/in6.h. The former exists in bionic, but not the latter. AGL -- Adam Langley a...@imperialviolet.org http://www.imperialviolet.org agcc Description: Binary data
Re: Tor on Android
On Sun, Dec 28, 2008 at 7:24 PM, Adam Langley a...@imperialviolet.org wrote: from reading around, fd_mask is POSIX. Rather than change libevent, probably bionic should be changed. Nick, does this work for you? http://review.source.android.com/6445 AGL -- Adam Langley a...@imperialviolet.org http://www.imperialviolet.org
Re: Tor on Android
On Sun, Dec 28, 2008 at 07:24:17PM -0800, Adam Langley wrote: On Sun, Dec 28, 2008 at 6:30 PM, Nick Mathewson ni...@freehaven.net wrote: Hm. Libevent should be made to detect this. Ordinarily, fd_mask is defined in sys/select.h or something it includes. Can you grep around a little in the Android headers to make sure it's not defined anywhere? If it isn't, we can probably define it to long without hurting anything, so long as we define NFDBITS to match. It's not defined. This is probably a mistake on bionic's part since, from reading around, fd_mask is POSIX. Rather than change libevent, probably bionic should be changed. I'll look at doing that tomorrow. If so, bionic should be changed. But sometimes writing portable software means building on platforms that do silly things. If the broken bionics are widespread, libevent could cope pretty easily, since it only uses fd_mask for sizeof(fd_mask) which it uses to calculate how many bytes to allocate for an fd_set. If the code instead just always allocated a multiple of sizeof(long) bits per fd_set, it would be more concise anyway, and not significantly less correct. Also, android has a config include file which is included in all compiles. This might well be a mistake as it defines HAVE_SYS_SOCKET_H and that's pretty rude. Yeah. If you want to do something like this, the usual trick is to post-process the config.h so that all the macros now start with a common prefix that won't conflict with the regular autoconf macros. For an example, recent libevent versions should do it right; old ones had the same problem as Android. [...] With a little investigate, the issue is in the agcc script. I had it add the libevent directory as an include path, but it put's -I options last on the resulting command line. Thus libevent's log.h was getting picked up. I've attached a version which collects -I arguments and puts them first on the gcc command line It would be neat if you sent the agcc patch upstream. :) [...] and this allows tip-of-SVN to build with these modifications: Interesting! Both were clearly errors in the source. Both patches are now applied. If you're feeling brave, try configuring Tor with the --enable-gcc-warnings option: it will warn about other compilation issues that we might want to care about. -- Nick
Re: Tor on Android
On Sun, Dec 28, 2008 at 08:01:26PM -0800, Adam Langley wrote: On Sun, Dec 28, 2008 at 7:24 PM, Adam Langley a...@imperialviolet.org wrote: from reading around, fd_mask is POSIX. Rather than change libevent, probably bionic should be changed. Nick, does this work for you? http://review.source.android.com/6445 Looks fine by me. -- Nick