Merge pull request #316 from cconlon/androidUpdate
Update Android Studio example projectspull/318/head
commit
60ed3b93fd
|
@ -11,10 +11,11 @@ contains a Makefile as well as a simple tutorial on the given topic.
|
|||
## Current Examples
|
||||
|
||||
|
||||
#### android (Android NDK Examples)
|
||||
#### android (Android Studio and NDK Examples)
|
||||
|
||||
This directory contains examples that demonstrate using wolfSSL and wolfSSLJNI
|
||||
on the Android platform, using the Android NDK toolchain.
|
||||
This directory contains examples that demonstrate using wolfSSL,
|
||||
wolfSSL JNI/JSSE, and wolfCrypt JNI/JCE on the Android platform. Examples
|
||||
use either Android Studio with Gradle or the Android NDK standalone toolchain.
|
||||
|
||||
Please see the [android/README.md](android/README.md) for further usage and
|
||||
details.
|
||||
|
|
|
@ -1,28 +1,99 @@
|
|||
# wolfSSL / wolfSSL JNI Android Examples
|
||||
# wolfSSL JNI/JSSE and wolfCrypt JNI/JCE Android Examples
|
||||
|
||||
This directory contains:
|
||||
This directory contains two Android Studio projects that demonstrate how
|
||||
wolfCrypt JNI/JCE and wolfSSL JNI/JSSE can be integrated into an
|
||||
Android Studio project using the Gradle build system to compile both
|
||||
shared libraries and the application.
|
||||
|
||||
**wolfssljni-ndk-sample** - Example project that demonstrates how to integrate
|
||||
wolfSSL and wolfSSL JNI into an Android NDK application's Android.mk build
|
||||
file.
|
||||
[wolfcryptjni-ndk-gradle](./wolfcryptjni-ndk-gradle)
|
||||
|
||||
**wolfssljni-ndk-gradle** - Example project that demonstrates how to integrate
|
||||
wolfSSL and wolfSSL JNI into an Android Studio NDK application using the
|
||||
Gradle build system to compile both shared libraries and the application.
|
||||
[wolfssljni-ndk-gradle](./wolfssljni-ndk-gradle)
|
||||
|
||||
This directory also contains one older example of how wolfSSL JNI/JSSE
|
||||
could be integrated into an older standalone NDK toolchain project's Android.mk
|
||||
build file. The above Android Studio projects are the recommended approach
|
||||
unless using an older standalone NDK toolchain setup.
|
||||
|
||||
[wolfssljni-ndk-sample](./wolfssljni-ndk-sample)
|
||||
|
||||
wolfSSL also maintains an Android Studio example project that is shipped
|
||||
as part of the wolfSSL JNI/JSSE bundle. This example project is set up to
|
||||
run the wolfSSL JNI/JSSE tests on an emulator as well, and is located here:
|
||||
|
||||
[wolfSSL JNI/JSSE IDE/Android Example](https://github.com/wolfSSL/wolfssljni/tree/master/IDE/Android)
|
||||
|
||||
## wolfSSL Android Studio NDK Gradle Examples
|
||||
|
||||
### Prerequisites for successful installation
|
||||
|
||||
In order to build the wolfSSL JNI/JSSE or wolfCrypt JNI/JCE Android Studio
|
||||
sample applications you need to Install **Android Studio**,
|
||||
along with **Android NDK** support.
|
||||
|
||||
### Compiling and Running wolfssljni-ndk-gradle or wolfcryptjni-ndk-gradle
|
||||
|
||||
After a development environment has been set up, follow these instructions
|
||||
to compile and install either the wolfSSL JNI/JSSE + wolfSSL bundle, or the
|
||||
wolfCrypt JNI/JCE + wolfSSL bundle on the Emulator:
|
||||
|
||||
1) Change directories into the android/wolfssljni-ndk-gradle directory
|
||||
|
||||
2) Checkout wolfssl and wolfssljni git submodules
|
||||
|
||||
3) Create stub options.h (since we're using the GitHub repo for wolfSSL)
|
||||
|
||||
4) Open "wolfssljni-ndk-gradle" project in Android Studio and build project
|
||||
|
||||
```
|
||||
$ cd android/wolfssljni-ndk-gradle
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ cp ./wolfssl/wolfssl/options.h.in ./wolfssl/wolfssl/options.h
|
||||
```
|
||||
|
||||
wolfSSL stable releases, available from the wolfSSL download page, contain
|
||||
<wolfssl/options.h>, but the GitHub development branch for wolfSSL does not.
|
||||
This is why options.h.in needs to be copied to options.h above.
|
||||
|
||||
If you would like to update the git submodules for wolfssl and wolfssljni to
|
||||
the most current development HEAD, use the following submodule update command
|
||||
in place of the one above:
|
||||
|
||||
```
|
||||
$ git submodule update --remote
|
||||
```
|
||||
|
||||
Or, to use a specific tag or commit, use `git checkout`:
|
||||
|
||||
```
|
||||
$ cd android/wolfssljni-ndk-gradle/wolfssl
|
||||
$ git checkout vX.X.X-stable
|
||||
```
|
||||
|
||||
To install and run the application in an Android emulator, set one up
|
||||
in Android Studio, then click the Debug application button on the Android
|
||||
Studio toolbar. This will allow you to choose what Android virtual machine
|
||||
you would like to use.
|
||||
|
||||
Logcat output from the emulator can be viewed by opening a new terminal window
|
||||
while the emulator is running and issuing:
|
||||
|
||||
```
|
||||
$ adb logcat
|
||||
```
|
||||
|
||||
## wolfSSL NDK Standalone Toolchain Example
|
||||
|
||||
### Prerequisites for successful installation
|
||||
|
||||
Prerequisites
|
||||
In order to build the wolfSSL JNI sample application,
|
||||
you need to:
|
||||
In order to build the wolfSSL JNI sample application, you need to:
|
||||
|
||||
* Install the `Android SDK` [link](http://developer.android.com/sdk/index.html)
|
||||
* Install the `Android NDK` [link](https://developer.android.com/tools/sdk/ndk/index.html)
|
||||
|
||||
Note that these instructions do not use the Android Studio IDE and environment.
|
||||
This package has been developed and tested using the Android NDK and SDK
|
||||
command line tools.
|
||||
command line tools only.
|
||||
|
||||
After installing the Android SDK, run the `SDK Tools` app packaged with it and
|
||||
install Android 4.4:
|
||||
|
@ -126,60 +197,6 @@ After compilation:
|
|||
on the phone, as described above for the emulator - using
|
||||
"adb debug install".
|
||||
|
||||
## wolfSSL Android Studio NDK Gradle Example
|
||||
|
||||
### Prerequisites for successful installation
|
||||
|
||||
Prerequisites
|
||||
In order to build the wolfSSL JNI Android Studio sample application,
|
||||
you need to:
|
||||
* Install Android Studio, along with Android NDK support
|
||||
|
||||
### Compiling and Running the wolfssljni-ndk-gradle or wolfcryptjni-ndk-gradle
|
||||
|
||||
After the development environment has been set up, follow these instructions
|
||||
to compile and install either the wolfSSL JNI + wolfSSL bundle, or the
|
||||
wolfCrypt JNI + wolfSSL bundle on the Emulator:
|
||||
|
||||
1) Change directories into the android/wolfssljni-ndk-sample directory
|
||||
|
||||
2) Checkout wolfssl and wolfssljni git submodules
|
||||
|
||||
3) Create stub options.h (since we're using the GitHub repo for wolfSSL)
|
||||
|
||||
4) Open "wolfssljni-ndk-gradle" project in Android Studio and build project
|
||||
|
||||
```
|
||||
$ cd android/wolfssljni-ndk-gradle
|
||||
$ git submodule init
|
||||
$ git submodule update
|
||||
$ cp ./wolfssl/wolfssl/options.h.in ./wolfssl/wolfssl/options.h
|
||||
```
|
||||
|
||||
wolfSSL stable releases, available from the wolfSSL download page, contain
|
||||
<wolfssl/options.h>, but the GitHub development branch for wolfSSL does not.
|
||||
This is why options.h.in needs to be copied to options.h above.
|
||||
|
||||
If you would like to update the git submodules for wolfssl and wolfssljni to
|
||||
the most current development HEAD, use the following submodule update command
|
||||
in place of the one above:
|
||||
|
||||
```
|
||||
$ git submodule update --remote
|
||||
```
|
||||
|
||||
To install and run the application in an Android emulator, set one up
|
||||
in Android Studio, then click the Debug application button on the Android
|
||||
Studio toolbar. This will allow you to choose what Android virtual machine
|
||||
you would like to use.
|
||||
|
||||
Logcat output from the emulator can be viewed by opening a new terminal window
|
||||
while the emulator is running and issuing:
|
||||
|
||||
```
|
||||
$ adb logcat
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Please contact wolfSSL at support@wolfssl.com with any questions, bug fixes,
|
||||
|
|
|
@ -4,14 +4,20 @@
|
|||
# Sets the minimum version of CMake required to build the native library.
|
||||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project("wolfcryptjni-ndk-gradle")
|
||||
|
||||
# Add preprocessor defines to CFLAGS
|
||||
add_definitions(-DNO_DSA -DNO_PSK -DNO_MD4 -DNO_HC128 -DNO_RABBIT
|
||||
-DWOLFSSL_SHA512 -DWOLFSSL_SHA384 -DHAVE_AESGCM -DHAVE_HASHDRBG
|
||||
-DHAVE_ECC -DWOLFSSL_KEY_GEN -DNO_PWDBASED -DUSE_FAST_MATH
|
||||
-DTFM_ECC256 -DHAVE_DH -DUSE_FAST_MATH -DTFM_TIMING_RESISTANT
|
||||
-DECC_TIMING_RESISTANT -DWC_RSA_BLINDING -DTFM_NO_ASM
|
||||
)
|
||||
# Add preprocessor defines to CFLAGS. These mirror the CFLAGS set in
|
||||
# wolfssl/options.h if using './configure --enable-keygen'
|
||||
add_definitions(-DUSE_FAST_MATH -DTFM_TIMING_RESISTANT -DECC_TIMING_RESISTANT
|
||||
-DWC_RSA_BLINDING -DWOLFSSL_SHA224 -DWOLFSSL_SHA384
|
||||
-DWOLFSSL_SHA512 -DHAVE_HKDF -DNO_DSA -DHAVE_ECC -DTFM_ECC256
|
||||
-DECC_SHAMIR -DWC_RSA_PSS -DWOLFSSL_BASE64_ENCODE -DWOLFSSL_SHA3
|
||||
-DHAVE_POLY1305 -DHAVE_CHACHA -DHAVE_HASHDRBG
|
||||
-DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES -DHAVE_FFDHE_2048
|
||||
-DWOLFSSL_TLS13 -DHAVE_EXTENDED_MASTER -DNO_RC4 -DNO_MD4
|
||||
-DHAVE_ENCRYPT_THEN_MAC -DNO_PSK -DHAVE_DH_DEFAULT_PARAMS
|
||||
-DWOLFSSL_KEY_GEN -DNO_DES3 -DGCM_TABLE_4BIT -DHAVE_AESGCM
|
||||
-DTFM_NO_ASM)
|
||||
|
||||
# set wolfSSL JNI location as environment variable, change if needed
|
||||
set(wolfcryptjni_DIR ${CMAKE_SOURCE_DIR}/../wolfcrypt-jni)
|
||||
|
@ -52,6 +58,7 @@ add_library(wolfssl SHARED
|
|||
${wolfssl_DIR}/wolfcrypt/src/hash.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/hmac.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/integer.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/kdf.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/logging.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/md2.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/md4.c
|
||||
|
@ -99,6 +106,7 @@ add_library(wolfcryptjni SHARED
|
|||
${wolfcryptjni_DIR}/jni/jni_ecc.c
|
||||
${wolfcryptjni_DIR}/jni/jni_ed25519.c
|
||||
${wolfcryptjni_DIR}/jni/jni_error.c
|
||||
${wolfcryptjni_DIR}/jni/jni_feature_detect.c
|
||||
${wolfcryptjni_DIR}/jni/jni_fips.c
|
||||
${wolfcryptjni_DIR}/jni/jni_hmac.c
|
||||
${wolfcryptjni_DIR}/jni/jni_logging.c
|
||||
|
@ -107,6 +115,7 @@ add_library(wolfcryptjni SHARED
|
|||
${wolfcryptjni_DIR}/jni/jni_rng.c
|
||||
${wolfcryptjni_DIR}/jni/jni_rsa.c
|
||||
${wolfcryptjni_DIR}/jni/jni_sha.c
|
||||
${wolfcryptjni_DIR}/jni/jni_wolfobject.c
|
||||
)
|
||||
|
||||
# Include libraries needed for wolfSSL and wolfCrypt JNI libs
|
||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Wed Jul 03 11:55:41 PDT 2019
|
||||
#Mon May 23 14:17:29 MDT 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 38c4857d6e4c958f42be93d3568901eaa0c092f5
|
||||
Subproject commit 81e1942e00601da6860100e950cc34c80bbe4156
|
|
@ -1 +1 @@
|
|||
Subproject commit 21f2beca9f320199fcea4a96df3e19967804144b
|
||||
Subproject commit e722c15be860794179082a05d09e6a90dc77ccf0
|
|
@ -4,13 +4,31 @@
|
|||
# Sets the minimum version of CMake required to build the native library.
|
||||
|
||||
cmake_minimum_required(VERSION 3.4.1)
|
||||
project("wolfssljni-ndk-gradle")
|
||||
|
||||
# Add preprocessor defines to CFLAGS
|
||||
add_definitions(-DWOLFSSL_JNI -DWOLFSSL_DTLS -DOPENSSL_EXTRA -DHAVE_CRL -DHAVE_CRL_MONITOR
|
||||
-DHAVE_OCSP -DPERSIST_SESSION_CACHE -DPERSIST_CERT_CACHE -DATOMIC_USER
|
||||
-DHAVE_ECC -DTFM_ECC256 -DHAVE_PK_CALLBACKS -DHAVE_DH -DUSE_FAST_MATH
|
||||
-DTFM_TIMING_RESISTANT -DECC_TIMING_RESISTANT -DWC_RSA_BLINDING -DTFM_NO_ASM
|
||||
)
|
||||
# Add preprocessor defines to CFLAGS, these match those placed into
|
||||
# wolfssl/options.h by configure if using: "./configure --enable-jni".
|
||||
# This list may be configurable depending on use case.
|
||||
add_definitions(-DUSE_FAST_MATH -DTFM_TIMING_RESISTANT -DECC_TIMING_RESISTANT
|
||||
-DWC_RSA_BLINDING -DWOLFSSL_SHA224 -DWOLFSSL_SHA384
|
||||
-DWOLFSSL_SHA512 -DHAVE_HKDF -DNO_DSA -DHAVE_ECC -DTFM_ECC256
|
||||
-DECC_SHAMIR -DWC_RSA_PSS -DWOLFSSL_BASE64_ENCODE
|
||||
-DWOLFSSL_SHA3 -DHAVE_POLY1305 -DHAVE_CHACHA -DHAVE_HASHDRBG
|
||||
-DHAVE_TLS_EXTENSIONS -DHAVE_SUPPORTED_CURVES -DHAVE_FFDHE_2048
|
||||
-DWOLFSSL_TLS13 -DHAVE_EXTENDED_MASTER -DWOLFSSL_JNI
|
||||
-DHAVE_EX_DATA -DWOLFSSL_DTLS -DOPENSSL_EXTRA -DOPENSSL_ALL
|
||||
-DHAVE_CRL -DHAVE_OCSP -DHAVE_CRL_MONITOR
|
||||
-DPERSIST_SESSION_CACHE -DPERSIST_CERT_CACHE -DATOMIC_USER
|
||||
-DHAVE_PK_CALLBACKS -DWOLFSSL_CERT_EXT -DWOLFSSL_CERT_GEN
|
||||
-DHAVE_SNI -DHAVE_ALPN -DNO_RC4 -DHAVE_ENCRYPT_THEN_MAC
|
||||
-DNO_MD4 -DWOLFSSL_ENCRYPTED_KEYS -DHAVE_DH_DEFAULT_PARAMS
|
||||
-DNO_ERROR_QUEUE -DWOLFSSL_EITHER_SIDE -DWC_RSA_NO_PADDING
|
||||
-DWC_RSA_PSS -DWOLFSSL_PSS_LONG_SALT -DWOLFSSL_TICKET_HAVE_ID
|
||||
-DWOLFSSL_ERROR_CODE_OPENSSL -DWOLFSSL_ALWAYS_VERIFY_CB
|
||||
-DWOLFSSL_VERIFY_CB_ALL_CERTS -DWOLFSSL_EXTRA_ALERTS
|
||||
-DHAVE_EXT_CACHE -DWOLFSSL_FORCE_CACHE_ON_TICKET
|
||||
-DWOLFSSL_AKID_NAME -DHAVE_CTS -DNO_DES3 -DGCM_TABLE_4BIT
|
||||
-DHAVE_AESGCM -DSIZEOF_LONG=4 -DSIZEOF_LONG_LONG=8 -DTFM_NO_ASM)
|
||||
|
||||
# set wolfSSL JNI location as environment variable, change if needed
|
||||
set(wolfssljni_DIR ${CMAKE_SOURCE_DIR}/../wolfssljni)
|
||||
|
@ -51,6 +69,7 @@ add_library(wolfssl SHARED
|
|||
${wolfssl_DIR}/wolfcrypt/src/hash.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/hmac.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/integer.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/kdf.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/logging.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/md2.c
|
||||
${wolfssl_DIR}/wolfcrypt/src/md4.c
|
||||
|
|
|
@ -31,6 +31,7 @@ android {
|
|||
// wolfSSL JNI Java source files are added here
|
||||
main.java.srcDirs += '../wolfssljni/src/java'
|
||||
}
|
||||
namespace 'com.wolfssl.wolfssljni_ndk_gradle'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="com.wolfssl.wolfssljni_ndk_gradle">
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
|
|
|
@ -6,7 +6,7 @@ buildscript {
|
|||
google()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.4.1'
|
||||
classpath 'com.android.tools.build:gradle:7.2.0'
|
||||
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#Wed Jul 03 11:59:03 PDT 2019
|
||||
#Mon May 23 13:47:02 MDT 2022
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 21f2beca9f320199fcea4a96df3e19967804144b
|
||||
Subproject commit e722c15be860794179082a05d09e6a90dc77ccf0
|
|
@ -1 +1 @@
|
|||
Subproject commit ec3efaad3e0aba288f8f419b00c1ec0ca6085378
|
||||
Subproject commit 59afb975daa2d86bb64b82de3d211ec9edd53949
|
Loading…
Reference in New Issue