Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 1 | OpenSSL on the Android platform. |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 2 | --- |
| 3 | |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 4 | The code in this directory is based on $OPENSSL_VERSION in the file |
| 5 | openssl.config, and some backported OpenSSL code in crypto/0.9.9-dev. |
Brian Carlstrom | f2ee5ff | 2010-03-30 09:41:16 -0700 | [diff] [blame] | 6 | See patches/README for more information on how the code differs from |
| 7 | $OPENSSL_VERSION. |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 8 | |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 9 | Porting New Versions of OpenSSL. |
| 10 | -- |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 11 | |
| 12 | The following steps are recommended for porting new OpenSSL versions. |
| 13 | |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 14 | 1) Retrieve the appropriate version of the OpenSSL source from |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 15 | www.openssl.org/source (in openssl-*.tar.gz file). Check the PGP |
| 16 | signature (found in matching openssl-*.tar.gz.asc file) with: |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 17 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 18 | gpg openssl-*.tar.gz |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 19 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 20 | If the public key is not found, import the the one with the |
| 21 | matching RSA key ID from http://www.openssl.org/about/, using: |
| 22 | |
| 23 | gpg --import # paste PGP public key block on stdin |
| 24 | |
| 25 | 2) Update the variables in openssl.config and openssl.version as appropriate. |
| 26 | At the very least you will need to update the openssl.version. |
| 27 | |
| 28 | 3) Run: |
| 29 | |
| 30 | ./import_openssl.sh import openssl-*.tar.gz |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 31 | |
| 32 | 4) If there are any errors, then modify openssl.config, openssl.version |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 33 | and patches in patches/ as appropriate. You might want to use: |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 34 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 35 | ./import_openssl.sh regenerate patches/*.patch |
| 36 | |
| 37 | Repeat step 3. |
| 38 | |
| 39 | 5) Cleanup before building with: |
| 40 | |
Brian Carlstrom | ad88003 | 2010-05-14 11:42:48 -0700 | [diff] [blame] | 41 | m -j16 clean-libcrypto clean-libssl clean-openssl clean-ssltest |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 42 | |
| 43 | 6) Build openssl from the external/openssl directory with: |
| 44 | |
Brian Carlstrom | ad88003 | 2010-05-14 11:42:48 -0700 | [diff] [blame] | 45 | mm -j16 snod && adb sync system |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 46 | |
| 47 | If there are build errors, then patches/*.mk, openssl.config, or |
| 48 | android-config.mk may need updating. |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 49 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 50 | 7) Run tests to make sure things are working: |
| 51 | |
Brian Carlstrom | 6e42038 | 2010-06-15 20:32:09 -0700 | [diff] [blame] | 52 | # Run local openssl tests |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 53 | (cd android.testssl/ && ./testssl.sh) |
Brian Carlstrom | 6e42038 | 2010-06-15 20:32:09 -0700 | [diff] [blame] | 54 | # Build and sync libcore tests |
| 55 | (croot && cd libcore && mm -j16 snod && adb remount && adb sync) |
Brian Carlstrom | 0494524 | 2010-06-16 11:03:59 -0700 | [diff] [blame^] | 56 | # Run tests from libcore |
| 57 | (croot && vogar --classpath out/target/common/obj/JAVA_LIBRARIES/core-tests-support_intermediates/classes.jar --classpath out/target/common/obj/JAVA_LIBRARIES/core-tests_intermediates/classes.jar javax.net.ssl tests.api.javax.net) |
| 58 | # Run tests from Harmony |
| 59 | (croot && vogar --classpath harmony_tests.jar tests.api.java.math.BigIntegerTest org.apache.harmony.tests.java.math) |
Brian Carlstrom | 6e42038 | 2010-06-15 20:32:09 -0700 | [diff] [blame] | 60 | # try an https website |
Brian Carlstrom | 925e1a4 | 2010-04-26 11:13:10 -0700 | [diff] [blame] | 61 | adb shell am start https://online.citibank.com # confirm result in browser |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 62 | |
Brian Carlstrom | 0494524 | 2010-06-16 11:03:59 -0700 | [diff] [blame^] | 63 | The vogar tool can be found externally at http://code.google.com/p/vogar/ |
| 64 | Within Google it can be run with ~dalvik-prebuild/vogar/bin/vogar |
| 65 | |
| 66 | harmony_tests.jar is built from Subversion http://harmony.apache.org/ |
| 67 | Within Google it can be found at ~dalvik-prebuild/bin/harmony_tests.jar |
| 68 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 69 | 8) Do a full build before checking in: |
| 70 | |
| 71 | m clobber && m -j16 |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 72 | |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 73 | Optionally, check whether build flags (located in android-config.mk |
| 74 | need to be updated. Doing this step will help ensure that the |
| 75 | compiled library is appropriately optimized for speed and size. To |
| 76 | update build flags: |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 77 | |
Nagendra Modadugu | e45f106 | 2009-09-30 11:36:48 -0700 | [diff] [blame] | 78 | a) source openssl.config |
| 79 | b) tar -zxf openssl-*.tar.gz |
| 80 | c) cd openssl-*/ |
| 81 | d) ./Configure $CONFIGURE_ARGS |
| 82 | e) examine Makefile and compare with ../android-config.mk |
| 83 | f) modify ../openssl.config as appropriate and go to step 3) above. |
The Android Open Source Project | 656d9c7 | 2009-03-03 19:30:25 -0800 | [diff] [blame] | 84 | |
Brian Carlstrom | 98d58bb | 2010-03-09 09:56:55 -0800 | [diff] [blame] | 85 | Alternatively, ."/import_openssl.sh import" now prints the |
| 86 | post-Configure Makefile for review before deleting in on import. |