Alexandre Savard | 1b09e31 | 2012-08-07 20:33:29 -0400 | [diff] [blame] | 1 | OpenSSL on the Android platform. |
| 2 | --- |
| 3 | |
| 4 | The code in this directory is based on $OPENSSL_VERSION in the file |
| 5 | openssl.version. See patches/README for more information on how the |
| 6 | code differs from $OPENSSL_VERSION. |
| 7 | |
| 8 | Porting New Versions of OpenSSL. |
| 9 | -- |
| 10 | |
| 11 | The following steps are recommended for porting new OpenSSL versions. |
| 12 | |
| 13 | 1) Retrieve the appropriate version of the OpenSSL source from |
| 14 | www.openssl.org/source (in openssl-*.tar.gz file). Check the PGP |
| 15 | signature (found in matching openssl-*.tar.gz.asc file) with: |
| 16 | |
| 17 | gpg openssl-*.tar.gz.asc |
| 18 | |
| 19 | If the public key is not found, import the the one with the |
| 20 | matching RSA key ID from http://www.openssl.org/about/, using: |
| 21 | |
| 22 | gpg --import # paste PGP public key block on stdin |
| 23 | |
| 24 | 2) Update the variables in openssl.config and openssl.version as appropriate. |
| 25 | At the very least you will need to update the openssl.version. |
| 26 | Similarly update ThirdPartyProject.prop. |
| 27 | |
| 28 | 3) Run: |
| 29 | |
| 30 | ./import_openssl.sh import openssl-*.tar.gz |
| 31 | |
| 32 | 4) If there are any errors, then modify openssl.config, openssl.version |
| 33 | and patches in patches/ as appropriate. You might want to use: |
| 34 | |
| 35 | ./import_openssl.sh regenerate patches/*.patch |
| 36 | |
| 37 | Repeat step 3. |
| 38 | |
| 39 | 5) Cleanup before building with: |
| 40 | |
| 41 | m -j16 clean-libcrypto clean-libssl clean-openssl clean-ssltest |
| 42 | |
| 43 | 6) Build openssl from the external/openssl directory with: |
| 44 | |
| 45 | mm -j16 snod && adb remount && adb sync system |
| 46 | |
| 47 | If there are build errors, then patches/*.mk, openssl.config, or |
| 48 | android-config.mk may need updating. |
| 49 | |
| 50 | 7) Run tests to make sure things are working: |
| 51 | |
| 52 | # Run local openssl tests |
| 53 | (cd android.testssl/ && ./testssl.sh) |
| 54 | # Build and sync libcore tests |
| 55 | (croot && cd libcore && mm -j16 snod && adb remount && adb sync) |
| 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) |
| 60 | # try an https website |
| 61 | adb shell am start https://online.citibank.com # confirm result in browser |
| 62 | |
| 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 | |
| 69 | # You can also run openssl s_server as a test server on the device: |
| 70 | adb push ./android.testssl/CAss.cnf /sdcard/CAss.cnf |
| 71 | adb shell openssl req -config /sdcard/CAss.cnf -x509 -nodes -days 365 -subj '/C=US/ST=California/L=Mountain View/CN=localhost' -newkey rsa:1024 -keyout /sdcard/server.pem -out /sdcard/server.pem |
| 72 | adb shell openssl s_server -cert /sdcard/server.pem -www -verify 1 |
| 73 | adb shell am start https://localhost:4433 # confirm result in browser |
| 74 | |
| 75 | 8) Do a full build before checking in: |
| 76 | |
| 77 | m -j16 |
| 78 | |
| 79 | Optionally, check whether build flags (located in android-config.mk |
| 80 | need to be updated. Doing this step will help ensure that the |
| 81 | compiled library is appropriately optimized for speed and size. To |
| 82 | update build flags: |
| 83 | |
| 84 | a) source openssl.config |
| 85 | b) tar -zxf openssl-*.tar.gz |
| 86 | c) cd openssl-*/ |
| 87 | d) ./Configure $CONFIGURE_ARGS |
| 88 | e) examine Makefile and compare with ../android-config.mk |
| 89 | f) modify ../openssl.config as appropriate and go to step 3) above. |
| 90 | |
| 91 | Alternatively, ."/import_openssl.sh import" now prints the |
| 92 | post-Configure Makefile for review before deleting in on import. |