commit e9dea379c8253dc861df9606541c656c31ed0aea Author: JohnE Date: Wed Jan 18 18:01:28 2017 -0800 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c5227e8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +.gradle +.idea +**/*.iml +local.properties +build +*~ +.externalNativeBuild +libwebp +.DS_Store + diff --git a/app/build.gradle b/app/build.gradle new file mode 100644 index 0000000..34b28db --- /dev/null +++ b/app/build.gradle @@ -0,0 +1,122 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 25 + buildToolsVersion '25.0.2' + + defaultConfig { + applicationId 'xyz.nc.android.wc' + minSdkVersion 21 + targetSdkVersion 25 + versionCode 1 + versionName '1.0' + testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner' + + // ndk default settings for this build + ndk { + abiFilters 'x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'arm64-v8a' + } + // set these default settings + externalNativeBuild { + arguments '-DANDROID_TOOLCHAIN=clang' + //arguments '-DANDROID_TOOLCHAIN=clang', '-DANDROID_STL=gnustl_static', '-DANDROID_PLATFORM=android-21' + //arguments '-DANDROID_TOOLCHAIN=gcc', '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-22' + } + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } + + // this block links Gradle to the CMake (or ndk-build) + externalNativeBuild { + // cmake build configuration + cmake { + // relative path to CMake build script + path 'src/main/cpp/CMakeLists.txt' + + // Passes optional arguments to CMake. + //arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=clang" + + // Sets optional flags for the C compiler. + //cFlags "-D_EXAMPLE_C_FLAG1", "-D_EXAMPLE_C_FLAG2" + + // Sets a flag to enable format macro constants for the C++ compiler. + //cppFlags "-D__STDC_FORMAT_MACROS" + } + } + + sourceSets { + main { + // let gradle pack the shared library into apk + //jniLibs.srcDirs = ['../wolfssl/dist'] + //jniLibs.srcDirs = ['../dist/gperf/lib'] + } + } + + productFlavors { + demo { + // different build settings + externalNativeBuild { + // ... + // targets "native-lib-demo" + } + } + paid { + externalNativeBuild { + // .. + // targets "native-lib-paid" + } + } + + + // in the future, ndk.abiFilter might also work + // arm7 { + // ndk { + // abiFilter 'armeabi-v7a' + // } + // } + // arm8 { + // ndk { + // abiFilters 'arm64-v8a' + // } + // } + // arm { + // ndk { + // abiFilter 'armeabi' + // } + // } + // x86 { + // ndk { + // abiFilter 'x86' + // } + // } + // x86_64 { + // ndk { + // abiFilter 'x86_64' + // } + // } + // mips { + // ndk { + // abiFilters 'mips', 'mips64' + // } + // } + // all { + // ndk { + // abiFilters 'mips', 'mips64', 'x86', 'x86_64' + // } + // } + + } // productFlavors + +} // android + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:25.1.0' + testCompile 'junit:junit:4.12' +} + diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro new file mode 100644 index 0000000..b7420a7 --- /dev/null +++ b/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/gfan/dev/sdk_current/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/app/src/main/cpp/CMakeLists.txt b/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..70e5799 --- /dev/null +++ b/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,49 @@ + +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.4.1) + +# configure import libs +# set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../distribution) + +add_library(lib_gmath STATIC IMPORTED) +set_target_properties(lib_gmath PROPERTIES IMPORTED_LOCATION + ${distribution_DIR}/gmath/lib/${ANDROID_ABI}/libgmath.a) + +# shared lib will also be tucked into APK and sent to target +# refer to app/build.gradle, jniLibs section for that purpose. +# ${ANDROID_ABI} is handy for our purpose here. Probably this ${ANDROID_ABI} is +# the most valuable thing of this sample, the rest are pretty much normal cmake +add_library(lib_gperf SHARED IMPORTED) +set_target_properties(lib_gperf PROPERTIES IMPORTED_LOCATION + ${distribution_DIR}/gperf/lib/${ANDROID_ABI}/libgperf.so) + +# build application's shared lib +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") + +add_library(hello-libs SHARED + hello-libs.cpp) + +target_include_directories(hello-libs PRIVATE + ${distribution_DIR}/gmath/include + ${distribution_DIR}/gperf/include) + +target_link_libraries(hello-libs + android + lib_gmath + lib_gperf + log) diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_AES.c b/app/src/main/cpp/com_wolfssl_wolfcrypt_AES.c new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_AES.h b/app/src/main/cpp/com_wolfssl_wolfcrypt_AES.h new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_KeyGen.c b/app/src/main/cpp/com_wolfssl_wolfcrypt_KeyGen.c new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_NTRU.c b/app/src/main/cpp/com_wolfssl_wolfcrypt_NTRU.c new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.c b/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.c new file mode 100644 index 0000000..e028a3a --- /dev/null +++ b/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.c @@ -0,0 +1,250 @@ +/* com_wolfssl_wolfcrypt_RSA.c + * + * Copyright (C) 2006-2016 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include +#include +#include "com_wolfssl_wolfcrypt_RSA.h" +#include + +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doSign + (JNIEnv* jenv, jobject jcl, jobject in, jlong inSz, jobject out, + jintArray outSz, jobject keyDer, jlong keySz) +{ + int ret; + RNG rng; + RsaKey myKey; + unsigned int idx; + unsigned int tmpOut; + + /* check in and key sz */ + if ((inSz < 0) || (keySz < 0)) { + return -1; + } + + /* get pointers to our buffers */ + unsigned char* inBuf = (*jenv)->GetDirectBufferAddress(jenv, in); + if (inBuf == NULL) { + printf("problem getting in buffer address\n"); + return -1; + } + + unsigned char* outBuf = (*jenv)->GetDirectBufferAddress(jenv, out); + if (outBuf == NULL) { + printf("problem getting out buffer address\n"); + return -1; + } + + unsigned char* keyBuf = (*jenv)->GetDirectBufferAddress(jenv, keyDer); + if (keyBuf == NULL) { + printf("problem getting key buffer address\n"); + return -1; + } + + /* get output buffer size */ + (*jenv)->GetIntArrayRegion(jenv, outSz, 0, 1, (jint*)&tmpOut); + + wc_InitRng(&rng); + wc_InitRsaKey(&myKey, NULL); + + idx = 0; + + ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz); + if (ret == 0) { + ret = wc_RsaSSL_Sign(inBuf, (unsigned int)inSz, outBuf, tmpOut, + &myKey, &rng); + if (ret > 0) { + /* save and convert to 0 for success */ + (*jenv)->SetIntArrayRegion(jenv, outSz, 0, 1, (jint*)&tmpOut); + ret = 0; + } + } else { + printf("wc_RsaPrivateKeyDecode failed, ret = %d\n", ret); + } + + wc_FreeRsaKey(&myKey); + + return ret; +} + +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doVerify + (JNIEnv* jenv, jobject jcl, jobject sig, jlong sigSz, jobject out, + jlong outSz, jobject keyDer, jlong keySz) +{ + int ret; + RsaKey myKey; + unsigned int idx; + + /* check in and key sz */ + if ((sigSz < 0) || (keySz < 0) || (outSz < 0)) { + return -1; + } + + /* get pointers to our buffers */ + unsigned char* sigBuf = (*jenv)->GetDirectBufferAddress(jenv, sig); + if (sigBuf == NULL) { + printf("problem getting sig buffer address\n"); + return -1; + } + + unsigned char* outBuf = (*jenv)->GetDirectBufferAddress(jenv, out); + if (outBuf == NULL) { + printf("problem getting out buffer address\n"); + return -1; + } + + unsigned char* keyBuf = (*jenv)->GetDirectBufferAddress(jenv, keyDer); + if (keyBuf == NULL) { + printf("problem getting key buffer address\n"); + return -1; + } + + wc_InitRsaKey(&myKey, NULL); + idx = 0; + + ret = wc_RsaPublicKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz); + if (ret == 0) { + ret = wc_RsaSSL_Verify(sigBuf, (unsigned int)sigSz, outBuf, + (unsigned int)outSz, &myKey); + if (ret < 0) { + printf("wc_RsaSSL_Verify failed, ret = %d\n", ret); + return ret; + } + } else { + printf("wc_RsaPublicKeyDecode failed, ret = %d\n", ret); + } + + wc_FreeRsaKey(&myKey); + + return ret; +} + +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doEnc + (JNIEnv* jenv, jobject jcl, jobject in, jlong inSz, jobject out, + jintArray outSz, jobject keyDer, jlong keySz) +{ + int ret; + RsaKey myKey; + RNG rng; + unsigned int idx; + unsigned int tmpOut; + + /* check in and key sz */ + if ((inSz < 0) || (keySz < 0)) { + return -1; + } + + /* get pointers to our buffers */ + unsigned char* inBuf = (*jenv)->GetDirectBufferAddress(jenv, in); + if (inBuf == NULL) { + printf("problem getting in buffer address\n"); + return -1; + } + + unsigned char* outBuf = (*jenv)->GetDirectBufferAddress(jenv, out); + if (outBuf == NULL) { + printf("problem getting out buffer address\n"); + return -1; + } + + unsigned char* keyBuf = (*jenv)->GetDirectBufferAddress(jenv, keyDer); + if (keyBuf == NULL) { + printf("problem getting key buffer address\n"); + return -1; + } + + /* get output buffer size */ + (*jenv)->GetIntArrayRegion(jenv, outSz, 0, 1, (jint*)&tmpOut); + + wc_InitRng(&rng); + wc_InitRsaKey(&myKey, NULL); + + idx = 0; + + ret = wc_RsaPublicKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz); + if (ret == 0) { + ret = wc_RsaPublicEncrypt(inBuf, (unsigned int)inSz, outBuf, tmpOut, + &myKey, &rng); + if (ret > 0) { + /* save and convert to 0 for success */ + (*jenv)->SetIntArrayRegion(jenv, outSz, 0, 1, (jint*)&ret); + ret = 0; + } + } else { + printf("wc_RsaPublicKeyDecode failed, ret = %d\n", ret); + } + + wc_FreeRsaKey(&myKey); + + return ret; +} + +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doDec + (JNIEnv* jenv, jobject jcl, jobject in, jlong inSz, jobject out, + jlong outSz, jobject keyDer, jlong keySz) +{ + int ret; + RsaKey myKey; + unsigned int idx; + + /* check in and key sz */ + if ((inSz < 0) || (keySz < 0) || (outSz < 0)) { + return -1; + } + + /* get pointers to our buffers */ + unsigned char* inBuf = (*jenv)->GetDirectBufferAddress(jenv, in); + if (inBuf == NULL) { + printf("problem getting in buffer address\n"); + return -1; + } + + unsigned char* outBuf = (*jenv)->GetDirectBufferAddress(jenv, out); + if (outBuf == NULL) { + printf("problem getting out buffer address\n"); + return -1; + } + + unsigned char* keyBuf = (*jenv)->GetDirectBufferAddress(jenv, keyDer); + if (keyBuf == NULL) { + printf("problem getting key buffer address\n"); + return -1; + } + + wc_InitRsaKey(&myKey, NULL); + idx = 0; + + ret = wc_RsaPrivateKeyDecode(keyBuf, &idx, &myKey, (unsigned int)keySz); + if (ret == 0) { + ret = wc_RsaPrivateDecrypt(inBuf, (unsigned int)inSz, outBuf, + (unsigned int)outSz, &myKey); + if (ret < 0) { + printf("wc_RsaPrivateDecrypt failed, ret = %d\n", ret); + return ret; + } + } else { + printf("wc_RsaPrivateKeyDecode failed, ret = %d\n", ret); + } + + wc_FreeRsaKey(&myKey); + + return ret; +} + diff --git a/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.h b/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.h new file mode 100644 index 0000000..837f006 --- /dev/null +++ b/app/src/main/cpp/com_wolfssl_wolfcrypt_RSA.h @@ -0,0 +1,45 @@ +/* DO NOT EDIT THIS FILE - it is machine generated */ +#include +/* Header for class com_wolfssl_wolfcrypt_RSA */ + +#ifndef _Included_com_wolfssl_wolfcrypt_RSA +#define _Included_com_wolfssl_wolfcrypt_RSA +#ifdef __cplusplus +extern "C" { +#endif +/* + * Class: com_wolfssl_wolfcrypt_RSA + * Method: doSign + * Signature: (Ljava/nio/ByteBuffer;JLjava/nio/ByteBuffer;[ILjava/nio/ByteBuffer;J)I + */ +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doSign + (JNIEnv *, jobject, jobject, jlong, jobject, jintArray, jobject, jlong); + +/* + * Class: com_wolfssl_wolfcrypt_RSA + * Method: doVerify + * Signature: (Ljava/nio/ByteBuffer;JLjava/nio/ByteBuffer;JLjava/nio/ByteBuffer;J)I + */ +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doVerify + (JNIEnv *, jobject, jobject, jlong, jobject, jlong, jobject, jlong); + +/* + * Class: com_wolfssl_wolfcrypt_RSA + * Method: doEnc + * Signature: (Ljava/nio/ByteBuffer;JLjava/nio/ByteBuffer;[ILjava/nio/ByteBuffer;J)I + */ +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doEnc + (JNIEnv *, jobject, jobject, jlong, jobject, jintArray, jobject, jlong); + +/* + * Class: com_wolfssl_wolfcrypt_RSA + * Method: doDec + * Signature: (Ljava/nio/ByteBuffer;JLjava/nio/ByteBuffer;JLjava/nio/ByteBuffer;J)I + */ +JNIEXPORT jint JNICALL Java_com_wolfssl_wolfcrypt_RSA_doDec + (JNIEnv *, jobject, jobject, jlong, jobject, jlong, jobject, jlong); + +#ifdef __cplusplus +} +#endif +#endif diff --git a/app/src/main/java/com/wolfssl/wolfcrypt/AES.java b/app/src/main/java/com/wolfssl/wolfcrypt/AES.java new file mode 100644 index 0000000..e69de29 diff --git a/app/src/main/java/com/wolfssl/wolfcrypt/RSA.java b/app/src/main/java/com/wolfssl/wolfcrypt/RSA.java new file mode 100644 index 0000000..3d84742 --- /dev/null +++ b/app/src/main/java/com/wolfssl/wolfcrypt/RSA.java @@ -0,0 +1,50 @@ +/* RSA.java + * + * Copyright (C) 2006-2016 wolfSSL Inc. + * + * This file is part of wolfSSL. + * + * wolfSSL is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * wolfSSL is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + */ + +package com.wolfssl.wolfcrypt; + +import java.nio.ByteBuffer; + +/** + * Wrapper for the native WolfCrypt RSA implementation, used for examples. + * This class contains a subset of the WolfCrypt RSA implementation and was + * written to be used with this package's example RSA public key callbacks. + * Usage can be found in examples/Client.java and examples/Server.java. + * + * @author wolfSSL + * @version 1.0, August 2013 + */ +public class RSA { + + public native int doSign(ByteBuffer in, long inSz, ByteBuffer out, + int[] outSz, ByteBuffer key, long keySz); + + public native int doVerify(ByteBuffer sig, long sigSz, ByteBuffer out, + long outSz, ByteBuffer keyDer, long keySz); + + public native int doEnc(ByteBuffer in, long inSz, ByteBuffer out, + int[] outSz, ByteBuffer keyDer, long keySz); + + public native int doDec(ByteBuffer in, long inSz, ByteBuffer out, + long outSz, ByteBuffer keyDer, long keySz); + +} + diff --git a/build.gradle b/build.gradle new file mode 100644 index 0000000..84526bd --- /dev/null +++ b/build.gradle @@ -0,0 +1,24 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:2.2.3' + //classpath "com.android.tools.build:gradle-experimental:0.7.0-alpha4" + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/build.properties b/build.properties new file mode 100644 index 0000000..e69de29 diff --git a/docs/nc-wc-ndk b/docs/nc-wc-ndk new file mode 100644 index 0000000..a845051 --- /dev/null +++ b/docs/nc-wc-ndk @@ -0,0 +1,12 @@ +[[[ Normalized Crypto WolfCrypt NDK ]]] + +[[ Features ]] +-uses gradle to build native files +-uses NEW CMake (CMake Android plugin) +-AEAD crypto support +-NO LEGACY. removes legacy crypto support +-WolfSSL crypto engine + -FIPS-140 ver available +-Quantum-Computing safe crypto + -super-fast NTRU algorithm + diff --git a/docs/nc-wc-ndk_dev b/docs/nc-wc-ndk_dev new file mode 100644 index 0000000..78434b1 --- /dev/null +++ b/docs/nc-wc-ndk_dev @@ -0,0 +1,17 @@ +[[[ NC WC Dev Notes ]]] + + +[[ Links ]] +# gradle plugin versions +@ https://jcenter.bintray.com/com/android/tools/build/gradle/ + +# gradle ndk support +@ http://tools.android.com/tech-docs/new-build-system/gradle-experimental/migrate-to-stable + + +[ CMake ] +@ https://developer.android.com/ndk/guides/cmake.html + +# cmake building examples +@ https://github.com/googlesamples/android-ndk/tree/master-cmake + diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 0000000..e69de29 diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..9d495b3 --- /dev/null +++ b/settings.gradle @@ -0,0 +1 @@ +include ':app' \ No newline at end of file diff --git a/wolfcrypt/build.gradle b/wolfcrypt/build.gradle new file mode 100644 index 0000000..32eea06 --- /dev/null +++ b/wolfcrypt/build.gradle @@ -0,0 +1,40 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.3" + + defaultConfig { + minSdkVersion 13 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + + externalNativeBuild { + cmake { + arguments '-DANDROID_PLATFORM=android-9', + '-DANDROID_TOOLCHAIN=clang' + // explicitly build libs + targets 'gmath', 'gperf' + } + + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path 'src/main/cpp/CMakeLists.txt' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:23.4.0' +} diff --git a/wolfcrypt/dist/wolfcrypt.so b/wolfcrypt/dist/wolfcrypt.so new file mode 100644 index 0000000..e69de29 diff --git a/wolfcrypt/proguard-rules.pro b/wolfcrypt/proguard-rules.pro new file mode 100644 index 0000000..b7420a7 --- /dev/null +++ b/wolfcrypt/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/gfan/dev/sdk_current/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/wolfcrypt/src/main/AndroidManifest.xml b/wolfcrypt/src/main/AndroidManifest.xml new file mode 100644 index 0000000..de1e181 --- /dev/null +++ b/wolfcrypt/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/wolfcrypt/src/main/cpp/CMakeLists.txt b/wolfcrypt/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..7d6028f --- /dev/null +++ b/wolfcrypt/src/main/cpp/CMakeLists.txt @@ -0,0 +1,32 @@ + +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Generate one static lib and one shared lib, copy them into +# ${project_dir}/distribution for other indepdendent applications +# to use. +cmake_minimum_required(VERSION 3.4.1) + +set(CMAKE_VERBOSE_MAKEFILE on) + +set(lib_src_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +set(lib_build_DIR $ENV{HOME}/tmp) +file(MAKE_DIRECTORY ${lib_build_DIR}) + +add_subdirectory(${lib_src_DIR}/gmath ${lib_build_DIR}/gmath) +add_subdirectory(${lib_src_DIR}/gperf ${lib_build_DIR}/gperf) + diff --git a/wolfcrypt/src/main/cpp/gmath/CMakeLists.txt b/wolfcrypt/src/main/cpp/gmath/CMakeLists.txt new file mode 100644 index 0000000..3de63af --- /dev/null +++ b/wolfcrypt/src/main/cpp/gmath/CMakeLists.txt @@ -0,0 +1,43 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Build a static lib and copy it into distribution place for independent app to use +# we could not delete the bin directory is because android studio would error out +# when it checks target's existance. Only distribution place is used as import to app + +cmake_minimum_required(VERSION 3.4.1) + +set(CMAKE_VERBOSE_MAKEFILE on) + +add_library(gmath STATIC src/gmath.c) + +# copy out the lib binary... need to leave the static lib around to pass gradle check +set(distribution_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../distribution) +set_target_properties(gmath + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY + "${distribution_DIR}/gmath/lib/${ANDROID_ABI}") + +# copy out lib header file... +add_custom_command(TARGET gmath POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + copy "${CMAKE_CURRENT_SOURCE_DIR}/src/gmath.h" + "${distribution_DIR}/gmath/include/gmath.h" +# **** the following 2 lines are for potential future debug purpose **** +# COMMAND "${CMAKE_COMMAND}" -E +# remove_directory "${CMAKE_CURRENT_BINARY_DIR}" + COMMENT "Copying gmath to output directory") + diff --git a/wolfcrypt/src/main/cpp/gmath/src/gmath.c b/wolfcrypt/src/main/cpp/gmath/src/gmath.c new file mode 100644 index 0000000..f691d8c --- /dev/null +++ b/wolfcrypt/src/main/cpp/gmath/src/gmath.c @@ -0,0 +1,46 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include "gmath.h" + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define GMATH_EXPORT __attribute__((visibility("default"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define GMATH_EXPORT __attribute__((visibility("default"))) +#else +#define GMATH_EXPORT +#endif + +#define LOGE(...) \ + ((void)__android_log_print(ANDROID_LOG_ERROR, "gmath::", __VA_ARGS__)) + +/* + * return 2 ^ n with multiplication implementation + */ +GMATH_EXPORT unsigned gpower(unsigned n) { + if (n == 0) + return 1; + if (n > 31) { + LOGE("error from power(%d): integer overflow", n); + return 0; + } + unsigned val = gpower(n>>1) * gpower (n>>1); + if (n & 1) + val *= 2; + return val; +} + diff --git a/wolfcrypt/src/main/cpp/gmath/src/gmath.h b/wolfcrypt/src/main/cpp/gmath/src/gmath.h new file mode 100644 index 0000000..60ea677 --- /dev/null +++ b/wolfcrypt/src/main/cpp/gmath/src/gmath.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __POWER_HPP__ +#define __POWER_HPP__ +/* + * return pow(2, n) + */ +#ifdef __cplusplus +extern "C" +#endif // __cplusplus + unsigned gpower(unsigned n); + +#endif //__POWER_HPP__ diff --git a/wolfcrypt/src/main/cpp/gperf/CMakeLists.txt b/wolfcrypt/src/main/cpp/gperf/CMakeLists.txt new file mode 100644 index 0000000..427e99b --- /dev/null +++ b/wolfcrypt/src/main/cpp/gperf/CMakeLists.txt @@ -0,0 +1,38 @@ +# +# Copyright (C) 2016 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Build one shared lib. When we build, we set the bin to $user/tmp, and +# remove it after build complete, so only the distribution place could be +# used for application linking. + +cmake_minimum_required(VERSION 3.4.1) + +set(CMAKE_VERBOSE_MAKEFILE on) + +add_library(gperf SHARED src/gperf.c) + +# copy out the lib binary and remove generated files +set(distribution_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../../distribution) +set_target_properties(gperf + PROPERTIES + LIBRARY_OUTPUT_DIRECTORY + "${distribution_DIR}/gperf/lib/${ANDROID_ABI}") +add_custom_command(TARGET gperf POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E + copy "${CMAKE_CURRENT_SOURCE_DIR}/src/gperf.h" + "${distribution_DIR}/gperf/include/gperf.h" + COMMENT "Copying gperf to output directory") + diff --git a/wolfcrypt/src/main/cpp/gperf/src/gperf.c b/wolfcrypt/src/main/cpp/gperf/src/gperf.c new file mode 100644 index 0000000..1b733ad --- /dev/null +++ b/wolfcrypt/src/main/cpp/gperf/src/gperf.c @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#include +#include "gperf.h" + +#if defined(__GNUC__) && __GNUC__ >= 4 +#define GPERF_EXPORT __attribute__((visibility("default"))) +#elif defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590) +#define GPERF_EXPORT __attribute__((visibility("default"))) +#else +#define GPERF_EXPORT +#endif + +/* + * return current ticks + */ +GPERF_EXPORT uint64_t GetTicks(void) { + struct timeval Time; + uint64_t cur_tick = (uint64_t) 1000000; + + gettimeofday( &Time, NULL ); + cur_tick *= Time.tv_sec; + + return (cur_tick + Time.tv_usec); +} + diff --git a/wolfcrypt/src/main/cpp/gperf/src/gperf.h b/wolfcrypt/src/main/cpp/gperf/src/gperf.h new file mode 100644 index 0000000..c7933c7 --- /dev/null +++ b/wolfcrypt/src/main/cpp/gperf/src/gperf.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +#ifndef __GPERF_HPP__ +#define __GPERF_HPP__ + +#include + +/* + * return current system ticks + */ +#ifdef __cplusplus +extern "C" +#endif // __cplusplus +uint64_t GetTicks(void); + +#endif //__GPERF_HPP__ diff --git a/wolfcrypt/src/main/res/values/strings.xml b/wolfcrypt/src/main/res/values/strings.xml new file mode 100644 index 0000000..a763d34 --- /dev/null +++ b/wolfcrypt/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + BuildLibs + diff --git a/wolfssl/build.gradle b/wolfssl/build.gradle new file mode 100644 index 0000000..32eea06 --- /dev/null +++ b/wolfssl/build.gradle @@ -0,0 +1,40 @@ +apply plugin: 'com.android.library' + +android { + compileSdkVersion 23 + buildToolsVersion "23.0.3" + + defaultConfig { + minSdkVersion 13 + targetSdkVersion 23 + versionCode 1 + versionName "1.0" + + externalNativeBuild { + cmake { + arguments '-DANDROID_PLATFORM=android-9', + '-DANDROID_TOOLCHAIN=clang' + // explicitly build libs + targets 'gmath', 'gperf' + } + + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path 'src/main/cpp/CMakeLists.txt' + } + } +} + +dependencies { + compile fileTree(dir: 'libs', include: ['*.jar']) + compile 'com.android.support:appcompat-v7:23.4.0' +} diff --git a/wolfssl/dist/android-19/arm64-v8a/libjnitest.so b/wolfssl/dist/android-19/arm64-v8a/libjnitest.so new file mode 100755 index 0000000..555a44a Binary files /dev/null and b/wolfssl/dist/android-19/arm64-v8a/libjnitest.so differ diff --git a/wolfssl/dist/android-19/arm64-v8a/libwolfssl.so b/wolfssl/dist/android-19/arm64-v8a/libwolfssl.so new file mode 100755 index 0000000..ccab2bd Binary files /dev/null and b/wolfssl/dist/android-19/arm64-v8a/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/arm64-v8a/libwolfssljni.so b/wolfssl/dist/android-19/arm64-v8a/libwolfssljni.so new file mode 100755 index 0000000..9be8e13 Binary files /dev/null and b/wolfssl/dist/android-19/arm64-v8a/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/armeabi-v7a/libjnitest.so b/wolfssl/dist/android-19/armeabi-v7a/libjnitest.so new file mode 100755 index 0000000..d0218d7 Binary files /dev/null and b/wolfssl/dist/android-19/armeabi-v7a/libjnitest.so differ diff --git a/wolfssl/dist/android-19/armeabi-v7a/libwolfssl.so b/wolfssl/dist/android-19/armeabi-v7a/libwolfssl.so new file mode 100755 index 0000000..4ef496a Binary files /dev/null and b/wolfssl/dist/android-19/armeabi-v7a/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/armeabi-v7a/libwolfssljni.so b/wolfssl/dist/android-19/armeabi-v7a/libwolfssljni.so new file mode 100755 index 0000000..ec8c167 Binary files /dev/null and b/wolfssl/dist/android-19/armeabi-v7a/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/armeabi/libjnitest.so b/wolfssl/dist/android-19/armeabi/libjnitest.so new file mode 100755 index 0000000..03dad2c Binary files /dev/null and b/wolfssl/dist/android-19/armeabi/libjnitest.so differ diff --git a/wolfssl/dist/android-19/armeabi/libwolfssl.so b/wolfssl/dist/android-19/armeabi/libwolfssl.so new file mode 100755 index 0000000..24f519a Binary files /dev/null and b/wolfssl/dist/android-19/armeabi/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/armeabi/libwolfssljni.so b/wolfssl/dist/android-19/armeabi/libwolfssljni.so new file mode 100755 index 0000000..9885db0 Binary files /dev/null and b/wolfssl/dist/android-19/armeabi/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/kitkat_4.4 b/wolfssl/dist/android-19/kitkat_4.4 new file mode 100644 index 0000000..e69de29 diff --git a/wolfssl/dist/android-19/mips/libjnitest.so b/wolfssl/dist/android-19/mips/libjnitest.so new file mode 100755 index 0000000..dc045c3 Binary files /dev/null and b/wolfssl/dist/android-19/mips/libjnitest.so differ diff --git a/wolfssl/dist/android-19/mips/libwolfssl.so b/wolfssl/dist/android-19/mips/libwolfssl.so new file mode 100755 index 0000000..adeecb9 Binary files /dev/null and b/wolfssl/dist/android-19/mips/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/mips/libwolfssljni.so b/wolfssl/dist/android-19/mips/libwolfssljni.so new file mode 100755 index 0000000..53c3f62 Binary files /dev/null and b/wolfssl/dist/android-19/mips/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/mips64/libjnitest.so b/wolfssl/dist/android-19/mips64/libjnitest.so new file mode 100755 index 0000000..ef7adaf Binary files /dev/null and b/wolfssl/dist/android-19/mips64/libjnitest.so differ diff --git a/wolfssl/dist/android-19/mips64/libwolfssl.so b/wolfssl/dist/android-19/mips64/libwolfssl.so new file mode 100755 index 0000000..a124370 Binary files /dev/null and b/wolfssl/dist/android-19/mips64/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/mips64/libwolfssljni.so b/wolfssl/dist/android-19/mips64/libwolfssljni.so new file mode 100755 index 0000000..80c7711 Binary files /dev/null and b/wolfssl/dist/android-19/mips64/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/x86/libjnitest.so b/wolfssl/dist/android-19/x86/libjnitest.so new file mode 100755 index 0000000..87c1eb4 Binary files /dev/null and b/wolfssl/dist/android-19/x86/libjnitest.so differ diff --git a/wolfssl/dist/android-19/x86/libwolfssl.so b/wolfssl/dist/android-19/x86/libwolfssl.so new file mode 100755 index 0000000..37588cf Binary files /dev/null and b/wolfssl/dist/android-19/x86/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/x86/libwolfssljni.so b/wolfssl/dist/android-19/x86/libwolfssljni.so new file mode 100755 index 0000000..0444cdc Binary files /dev/null and b/wolfssl/dist/android-19/x86/libwolfssljni.so differ diff --git a/wolfssl/dist/android-19/x86_64/libjnitest.so b/wolfssl/dist/android-19/x86_64/libjnitest.so new file mode 100755 index 0000000..ca77727 Binary files /dev/null and b/wolfssl/dist/android-19/x86_64/libjnitest.so differ diff --git a/wolfssl/dist/android-19/x86_64/libwolfssl.so b/wolfssl/dist/android-19/x86_64/libwolfssl.so new file mode 100755 index 0000000..1a23d59 Binary files /dev/null and b/wolfssl/dist/android-19/x86_64/libwolfssl.so differ diff --git a/wolfssl/dist/android-19/x86_64/libwolfssljni.so b/wolfssl/dist/android-19/x86_64/libwolfssljni.so new file mode 100755 index 0000000..9bb9154 Binary files /dev/null and b/wolfssl/dist/android-19/x86_64/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/arm64-v8a/libjnitest.so b/wolfssl/dist/android-21/arm64-v8a/libjnitest.so new file mode 100755 index 0000000..555a44a Binary files /dev/null and b/wolfssl/dist/android-21/arm64-v8a/libjnitest.so differ diff --git a/wolfssl/dist/android-21/arm64-v8a/libwolfssl.so b/wolfssl/dist/android-21/arm64-v8a/libwolfssl.so new file mode 100755 index 0000000..ccab2bd Binary files /dev/null and b/wolfssl/dist/android-21/arm64-v8a/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/arm64-v8a/libwolfssljni.so b/wolfssl/dist/android-21/arm64-v8a/libwolfssljni.so new file mode 100755 index 0000000..9be8e13 Binary files /dev/null and b/wolfssl/dist/android-21/arm64-v8a/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/armeabi-v7a/libjnitest.so b/wolfssl/dist/android-21/armeabi-v7a/libjnitest.so new file mode 100755 index 0000000..5e70e4b Binary files /dev/null and b/wolfssl/dist/android-21/armeabi-v7a/libjnitest.so differ diff --git a/wolfssl/dist/android-21/armeabi-v7a/libwolfssl.so b/wolfssl/dist/android-21/armeabi-v7a/libwolfssl.so new file mode 100755 index 0000000..49c478d Binary files /dev/null and b/wolfssl/dist/android-21/armeabi-v7a/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/armeabi-v7a/libwolfssljni.so b/wolfssl/dist/android-21/armeabi-v7a/libwolfssljni.so new file mode 100755 index 0000000..86b8bf9 Binary files /dev/null and b/wolfssl/dist/android-21/armeabi-v7a/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/armeabi/libjnitest.so b/wolfssl/dist/android-21/armeabi/libjnitest.so new file mode 100755 index 0000000..45a4609 Binary files /dev/null and b/wolfssl/dist/android-21/armeabi/libjnitest.so differ diff --git a/wolfssl/dist/android-21/armeabi/libwolfssl.so b/wolfssl/dist/android-21/armeabi/libwolfssl.so new file mode 100755 index 0000000..146e0d3 Binary files /dev/null and b/wolfssl/dist/android-21/armeabi/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/armeabi/libwolfssljni.so b/wolfssl/dist/android-21/armeabi/libwolfssljni.so new file mode 100755 index 0000000..6ca8c9a Binary files /dev/null and b/wolfssl/dist/android-21/armeabi/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/lollipop_5.0 b/wolfssl/dist/android-21/lollipop_5.0 new file mode 100644 index 0000000..e69de29 diff --git a/wolfssl/dist/android-21/mips/libjnitest.so b/wolfssl/dist/android-21/mips/libjnitest.so new file mode 100755 index 0000000..14cae44 Binary files /dev/null and b/wolfssl/dist/android-21/mips/libjnitest.so differ diff --git a/wolfssl/dist/android-21/mips/libwolfssl.so b/wolfssl/dist/android-21/mips/libwolfssl.so new file mode 100755 index 0000000..9de61c7 Binary files /dev/null and b/wolfssl/dist/android-21/mips/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/mips/libwolfssljni.so b/wolfssl/dist/android-21/mips/libwolfssljni.so new file mode 100755 index 0000000..456f2c3 Binary files /dev/null and b/wolfssl/dist/android-21/mips/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/mips64/libjnitest.so b/wolfssl/dist/android-21/mips64/libjnitest.so new file mode 100755 index 0000000..ef7adaf Binary files /dev/null and b/wolfssl/dist/android-21/mips64/libjnitest.so differ diff --git a/wolfssl/dist/android-21/mips64/libwolfssl.so b/wolfssl/dist/android-21/mips64/libwolfssl.so new file mode 100755 index 0000000..a124370 Binary files /dev/null and b/wolfssl/dist/android-21/mips64/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/mips64/libwolfssljni.so b/wolfssl/dist/android-21/mips64/libwolfssljni.so new file mode 100755 index 0000000..80c7711 Binary files /dev/null and b/wolfssl/dist/android-21/mips64/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/x86/libjnitest.so b/wolfssl/dist/android-21/x86/libjnitest.so new file mode 100755 index 0000000..403f1c5 Binary files /dev/null and b/wolfssl/dist/android-21/x86/libjnitest.so differ diff --git a/wolfssl/dist/android-21/x86/libwolfssl.so b/wolfssl/dist/android-21/x86/libwolfssl.so new file mode 100755 index 0000000..463eb8a Binary files /dev/null and b/wolfssl/dist/android-21/x86/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/x86/libwolfssljni.so b/wolfssl/dist/android-21/x86/libwolfssljni.so new file mode 100755 index 0000000..99fd24e Binary files /dev/null and b/wolfssl/dist/android-21/x86/libwolfssljni.so differ diff --git a/wolfssl/dist/android-21/x86_64/libjnitest.so b/wolfssl/dist/android-21/x86_64/libjnitest.so new file mode 100755 index 0000000..ca77727 Binary files /dev/null and b/wolfssl/dist/android-21/x86_64/libjnitest.so differ diff --git a/wolfssl/dist/android-21/x86_64/libwolfssl.so b/wolfssl/dist/android-21/x86_64/libwolfssl.so new file mode 100755 index 0000000..1a23d59 Binary files /dev/null and b/wolfssl/dist/android-21/x86_64/libwolfssl.so differ diff --git a/wolfssl/dist/android-21/x86_64/libwolfssljni.so b/wolfssl/dist/android-21/x86_64/libwolfssljni.so new file mode 100755 index 0000000..9bb9154 Binary files /dev/null and b/wolfssl/dist/android-21/x86_64/libwolfssljni.so differ diff --git a/wolfssl/dist/include/include.h b/wolfssl/dist/include/include.h new file mode 100644 index 0000000..e69de29 diff --git a/wolfssl/dist/include/ssl.h b/wolfssl/dist/include/ssl.h new file mode 100644 index 0000000..e69de29 diff --git a/wolfssl/get_wolfssl_src.sh b/wolfssl/get_wolfssl_src.sh new file mode 100644 index 0000000..6197fc0 --- /dev/null +++ b/wolfssl/get_wolfssl_src.sh @@ -0,0 +1,4 @@ +#!/bin/sh +git clone https://github.com/wolfSSL/wolfssl.git +git checkout v3.10.0-stable +git checkout -b building diff --git a/wolfssl/proguard-rules.pro b/wolfssl/proguard-rules.pro new file mode 100644 index 0000000..b7420a7 --- /dev/null +++ b/wolfssl/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/gfan/dev/sdk_current/tools/proguard/proguard-android.txt +# You can edit the include path and order by changing the proguardFiles +# directive in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# Add any project specific keep options here: + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} diff --git a/wolfssl/src/main/AndroidManifest.xml b/wolfssl/src/main/AndroidManifest.xml new file mode 100644 index 0000000..de1e181 --- /dev/null +++ b/wolfssl/src/main/AndroidManifest.xml @@ -0,0 +1,9 @@ + + + + + + + diff --git a/wolfssl/src/main/cpp/Android.mk b/wolfssl/src/main/cpp/Android.mk new file mode 100644 index 0000000..5d962da --- /dev/null +++ b/wolfssl/src/main/cpp/Android.mk @@ -0,0 +1,100 @@ +TOP_PATH := $(call my-dir)/.. + +WOLFSSL_DIR := wolfssl + +# Build wolfSSL shared library +include $(CLEAR_VARS) +LOCAL_PATH := $(TOP_PATH)/$(WOLFSSL_DIR) +LOCAL_MODULE := libwolfssl +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH) +LOCAL_C_INCLUDES := $(LOCAL_PATH) +LOCAL_CFLAGS := -DOPENSSL_EXTRA -DWOLFSSL_DTLS -D_POSIX_THREADS -DNDEBUG \ + -DPERSIST_SESSION_CACHE -DPERSIST_CERT_CACHE -DATOMIC_USER \ + -DHAVE_PK_CALLBACKS -DNO_DSA -DHAVE_ECC -DTFM_ECC256 \ + -DECC_SHAMIR -DNO_MD4 -DNO_HC128 -DNO_RABBIT \ + -DHAVE_OCSP -DHAVE_CRL -DWOLFSSL_JNI -DHAVE_DH \ + -Wall +LOCAL_SRC_FILES := src/crl.c \ + src/internal.c \ + src/io.c \ + src/keys.c \ + src/ocsp.c \ + src/sniffer.c \ + src/ssl.c \ + src/tls.c \ + wolfcrypt/src/aes.c \ + wolfcrypt/src/arc4.c \ + wolfcrypt/src/asm.c \ + wolfcrypt/src/asn.c \ + wolfcrypt/src/blake2b.c \ + wolfcrypt/src/camellia.c \ + wolfcrypt/src/chacha.c \ + wolfcrypt/src/chacha20_poly1305.c \ + wolfcrypt/src/coding.c \ + wolfcrypt/src/compress.c \ + wolfcrypt/src/curve25519.c \ + wolfcrypt/src/des3.c \ + wolfcrypt/src/dh.c \ + wolfcrypt/src/dsa.c \ + wolfcrypt/src/ecc.c \ + wolfcrypt/src/ecc_fp.c \ + wolfcrypt/src/ed25519.c \ + wolfcrypt/src/error.c \ + wolfcrypt/src/fe_low_mem.c \ + wolfcrypt/src/fe_operations.c \ + wolfcrypt/src/ge_low_mem.c \ + wolfcrypt/src/ge_operations.c \ + wolfcrypt/src/hash.c \ + wolfcrypt/src/hc128.c \ + wolfcrypt/src/hmac.c \ + wolfcrypt/src/idea.c \ + wolfcrypt/src/integer.c \ + wolfcrypt/src/logging.c \ + wolfcrypt/src/md2.c \ + wolfcrypt/src/md4.c \ + wolfcrypt/src/md5.c \ + wolfcrypt/src/memory.c \ + wolfcrypt/src/misc.c \ + wolfcrypt/src/pkcs7.c \ + wolfcrypt/src/pkcs12.c \ + wolfcrypt/src/poly1305.c \ + wolfcrypt/src/pwdbased.c \ + wolfcrypt/src/rabbit.c \ + wolfcrypt/src/random.c \ + wolfcrypt/src/ripemd.c \ + wolfcrypt/src/rsa.c \ + wolfcrypt/src/sha.c \ + wolfcrypt/src/sha256.c \ + wolfcrypt/src/sha512.c \ + wolfcrypt/src/srp.c \ + wolfcrypt/src/tfm.c \ + wolfcrypt/src/wc_encrypt.c \ + wolfcrypt/src/wc_port.c +include $(BUILD_SHARED_LIBRARY) + + +## Build wolfSSL JNI library +include $(CLEAR_VARS) +LOCAL_PATH := $(TOP_PATH)/wolfssljni +LOCAL_MODULE := libwolfssljni +LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/native +LOCAL_C_INCLUDES := $(LOCAL_PATH)/native +LOCAL_SRC_FILES := native/com_wolfssl_WolfSSL.c \ + native/com_wolfssl_WolfSSLContext.c \ + native/com_wolfssl_WolfSSLSession.c \ + native/com_wolfssl_wolfcrypt_ECC.c \ + native/com_wolfssl_wolfcrypt_RSA.c +LOCAL_CFLAGS := -Wall -Os -DWOLFSSL_DTLS -DHAVE_ECC +LOCAL_SHARED_LIBRARIES := libwolfssl +include $(BUILD_SHARED_LIBRARY) + + +include $(CLEAR_VARS) +LOCAL_PATH := $(TOP_PATH)/jni +LOCAL_MODULE := libjnitest +LOCAL_C_INCLUDES := $(LOCAL_PATH) +LOCAL_SRC_FILES := jnitest.c +LOCAL_CFLAGS := -Wall +LOCAL_SHARED_LIBRARIES := libwolfssl +include $(BUILD_SHARED_LIBRARY) + diff --git a/wolfssl/src/main/cpp/Application.mk b/wolfssl/src/main/cpp/Application.mk new file mode 100644 index 0000000..6beb2de --- /dev/null +++ b/wolfssl/src/main/cpp/Application.mk @@ -0,0 +1,5 @@ +# +APP_ABI := all +#APP_ABI := armeabi armeabi-v7a x86 x86_64 +#APP_ABI := mips mips64 arm64-v8a +#APP_ABI := arm64-v8a \ No newline at end of file diff --git a/wolfssl/src/main/cpp/CMakeLists.txt b/wolfssl/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..7d6028f --- /dev/null +++ b/wolfssl/src/main/cpp/CMakeLists.txt @@ -0,0 +1,32 @@ + +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Generate one static lib and one shared lib, copy them into +# ${project_dir}/distribution for other indepdendent applications +# to use. +cmake_minimum_required(VERSION 3.4.1) + +set(CMAKE_VERBOSE_MAKEFILE on) + +set(lib_src_DIR ${CMAKE_CURRENT_SOURCE_DIR}) + +set(lib_build_DIR $ENV{HOME}/tmp) +file(MAKE_DIRECTORY ${lib_build_DIR}) + +add_subdirectory(${lib_src_DIR}/gmath ${lib_build_DIR}/gmath) +add_subdirectory(${lib_src_DIR}/gperf ${lib_build_DIR}/gperf) + diff --git a/wolfssl/src/main/res/values/strings.xml b/wolfssl/src/main/res/values/strings.xml new file mode 100644 index 0000000..a763d34 --- /dev/null +++ b/wolfssl/src/main/res/values/strings.xml @@ -0,0 +1,3 @@ + + BuildLibs +