summaryrefslogtreecommitdiff
path: root/app/jni
diff options
context:
space:
mode:
Diffstat (limited to 'app/jni')
-rw-r--r--app/jni/Android.mk48
-rw-r--r--app/jni/Application.mk7
-rw-r--r--app/jni/buildall.mk69
-rw-r--r--app/jni/dummy.cpp8
-rw-r--r--app/jni/jbcrypto.cpp19
-rw-r--r--app/jni/jniglue.c3
-rw-r--r--app/jni/prebuilt.mk27
7 files changed, 72 insertions, 109 deletions
diff --git a/app/jni/Android.mk b/app/jni/Android.mk
index 3514b920..a3280bd6 100644
--- a/app/jni/Android.mk
+++ b/app/jni/Android.mk
@@ -1,12 +1,45 @@
# Path of the sources
JNI_DIR := $(call my-dir)
+#optional arguments
+#WITH_POLAR=1
+#WITH_OPENVPN3=1
+# Build openvpn with polar (OpenVPN3 core is always build with polar)
+USE_BREAKPAD=0
+WITH_BREAKPAD=0
+
include lzo/Android.mk
+include snappy/Android.mk
include openssl/Android.mk
+ifneq ($(USE_BREAKPAD),0)
+ ifneq ($(TARGET_ARCH),mips)
+ WITH_BREAKPAD=1
+# include google-breakpad/android/google_breakpad/Android.mk
+ else
+ WITH_BREAKPAD=0
+ endif
+else
+WITH_BREAKPAD=0
+endif
+
+ifeq ($(WITH_POLAR),1)
+ USE_POLAR=1
+endif
+ifeq ($(WITH_OPENVPN3),1)
+ USE_POLAR=1
+endif
+
+ifeq ($(USE_POLAR),1)
+ include polarssl/Android.mk
+endif
+
include openvpn/Android.mk
+ifeq ($(WITH_OPENVPN3),1)
+ include ovpn3/Android.mk
+endif
LOCAL_PATH := $(JNI_DIR)
@@ -23,7 +56,18 @@ include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -lz -lc
LOCAL_SHARED_LIBRARIES := libssl libcrypto openvpn
-LOCAL_SRC_FILES:= minivpn.c
-LOCAL_MODULE = minivpn
+LOCAL_SRC_FILES:= minivpn.c dummy.cpp
+LOCAL_MODULE = nopievpn
+include $(BUILD_EXECUTABLE)
+
+
+include $(CLEAR_VARS)
+LOCAL_LDLIBS := -lz -lc
+LOCAL_CFLAGS= -fPIE -pie
+LOCAL_CFLAGS = -fPIE
+LOCAL_LDFLAGS = -fPIE -pie
+LOCAL_SHARED_LIBRARIES := libssl libcrypto openvpn
+LOCAL_SRC_FILES:= minivpn.c dummy.cpp
+LOCAL_MODULE = pievpn
include $(BUILD_EXECUTABLE)
diff --git a/app/jni/Application.mk b/app/jni/Application.mk
index 0795b5b8..913e0a98 100644
--- a/app/jni/Application.mk
+++ b/app/jni/Application.mk
@@ -1,8 +1,11 @@
APP_ABI := all
-NDK_TOOLCHAIN_VERSION=4.8
APP_PLATFORM := android-14
-APP_STL:=stlport_static
+
+APP_STL:=stlport_shared
+#APP_STL:=gnustl_shared
#APP_OPTIM := release
#LOCAL_ARM_MODE := arm
+
+#NDK_TOOLCHAIN_VERSION=clang
diff --git a/app/jni/buildall.mk b/app/jni/buildall.mk
deleted file mode 100644
index e1d6fdbc..00000000
--- a/app/jni/buildall.mk
+++ /dev/null
@@ -1,69 +0,0 @@
-# Build curl
-include $(CURRENT_DIR)/curl/Android.mk
-
-
-include $(CLEAR_VARS)
-
-
-# SIGC++ Library built as static library
-LOCAL_MODULE := sigc
-LOCAL_PATH = $(CURRENT_DIR)
-LOCAL_CPP_EXTENSION := .cc
-
-
-
-LOCAL_SRC_FILES := sigc++/signal.cc sigc++/signal_base.cc sigc++/trackable.cc
-LOCAL_SRC_FILES += sigc++/functors/slot_base.cc sigc++/adaptors/lambda/lambda.cc
-LOCAL_SRC_FILES += sigc++/connection.cc sigc++/functors/slot.cc
-
-
-LOCAL_C_INCLUDES := sigc++
-
-include $(BUILD_STATIC_LIBRARY)
-
-# Torrent library
-
-include $(CLEAR_VARS)
-
-
-LOCAL_PATH := $(CURRENT_DIR)/libtorrent/src
-LOCAL_C_INCLUDES := $(CURRENT_DIR)/libtorrent $(CURRENT_DIR) $(CURRENT_DIR)/libtorrent/src $(CURRENT_DIR)/libtorrent/src/torrent
-LOCAL_CPP_EXTENSION := .cc
-LOCAL_MODULE = rtorrent
-
-LOCAL_SRC_FILES = globals.cc resource_manager.cc manager.cc
-
-#torrent subdirs
-LOCAL_SRC_FILES+= torrent/data/block.cc torrent/data/block_list.cc torrent/data/chunk_utils.cc torrent/data/file.cc torrent/data/file_list.cc torrent/data/file_list_iterator.cc torrent/data/file_manager.cc torrent/data/file_utils.cc torrent/data/transfer_list.cc torrent/peer/client_info.cc torrent/peer/client_list.cc torrent/peer/connection_list.cc torrent/peer/peer.cc torrent/peer/peer_info.cc torrent/peer/peer_list.cc
-
-
-
-#data
-LOCAL_SRC_FILES+= data/chunk.cc data/chunk_list.cc data/chunk_part.cc data/hash_chunk.cc data/hash_queue.cc data/hash_queue_node.cc data/hash_torrent.cc data/memory_chunk.cc data/socket_file.cc
-
-# dht
-LOCAL_SRC_FILES+= dht/dht_bucket.cc dht/dht_node.cc dht/dht_router.cc dht/dht_server.cc dht/dht_tracker.cc dht/dht_transaction.cc
-
-#download
-LOCAL_SRC_FILES+= download/available_list.cc download/choke_manager.cc download/chunk_selector.cc download/chunk_statistics.cc download/delegator.cc download/download_constructor.cc download/download_main.cc download/download_manager.cc download/download_wrapper.cc
-
-# net
-LOCAL_SRC_FILES+=net/address_list.cc net/listen.cc net/socket_base.cc net/socket_datagram.cc net/socket_fd.cc net/socket_set.cc net/socket_stream.cc net/throttle_internal.cc net/throttle_list.cc
-
-#protocol
-LOCAL_SRC_FILES+=protocol/extensions.cc protocol/handshake.cc protocol/handshake_encryption.cc protocol/handshake_manager.cc protocol/initial_seed.cc protocol/peer_connection_base.cc protocol/peer_connection_leech.cc protocol/peer_connection_metadata.cc protocol/peer_factory.cc protocol/request_list.cc
-
-# torrent
-LOCAL_SRC_FILES+= torrent/bitfield.cc torrent/chunk_manager.cc torrent/connection_manager.cc torrent/dht_manager.cc torrent/download.cc torrent/error.cc torrent/exceptions.cc torrent/hash_string.cc torrent/http.cc torrent/object.cc torrent/object_static_map.cc torrent/object_stream.cc torrent/path.cc torrent/poll_epoll.cc torrent/poll_kqueue.cc torrent/poll_select.cc torrent/rate.cc torrent/resume.cc torrent/thread_base.cc torrent/throttle.cc torrent/torrent.cc torrent/tracker.cc torrent/tracker_list.cc
-
-
-#tracker
-LOCAL_SRC_FILES+= tracker/tracker_dht.cc tracker/tracker_http.cc tracker/tracker_manager.cc tracker/tracker_udp.cc
-
-#utils
-LOCAL_SRC_FILES+= utils/diffie_hellman.cc utils/sha_fast.cc
-
-
-LOCAL_STATIC_LIBRARIES := sigc
-
-include $(BUILD_STATIC_LIBRARY)
diff --git a/app/jni/dummy.cpp b/app/jni/dummy.cpp
new file mode 100644
index 00000000..58466656
--- /dev/null
+++ b/app/jni/dummy.cpp
@@ -0,0 +1,8 @@
+/*#include <string>
+#include <iostream>
+
+void dummy()
+{
+ std::cout << "I am a dummy function to help compile on Android NDK r9" << std::endl;
+}
+*/
diff --git a/app/jni/jbcrypto.cpp b/app/jni/jbcrypto.cpp
index 1c3e3ca9..2fd1262a 100644
--- a/app/jni/jbcrypto.cpp
+++ b/app/jni/jbcrypto.cpp
@@ -17,7 +17,7 @@
extern "C" {
-jbyteArray Java_se_leap_openvpn_OpenVpnManagementThread_rsasign(JNIEnv* env, jclass, jbyteArray from, jint pkeyRef);
+jbyteArray Java_de_blinkt_openvpn_core_NativeUtils_rsasign(JNIEnv* env, jclass, jbyteArray from, jint pkeyRef);
}
int jniThrowException(JNIEnv* env, const char* className, const char* msg) {
@@ -40,8 +40,8 @@ int jniThrowException(JNIEnv* env, const char* className, const char* msg) {
return 0;
}
-
-jbyteArray Java_se_leap_openvpn_OpenVpnManagementThread_rsasign(JNIEnv* env, jclass, jbyteArray from, jint pkeyRef) {
+static char opensslerr[1024];
+jbyteArray Java_de_blinkt_openvpn_core_NativeUtils_rsasign (JNIEnv* env, jclass, jbyteArray from, jint pkeyRef) {
// EVP_MD_CTX* ctx = reinterpret_cast<EVP_MD_CTX*>(ctxRef);
EVP_PKEY* pkey = reinterpret_cast<EVP_PKEY*>(pkeyRef);
@@ -58,7 +58,7 @@ jbyteArray Java_se_leap_openvpn_OpenVpnManagementThread_rsasign(JNIEnv* env, jcl
if(data==NULL )
jniThrowException(env, "java/lang/NullPointerException", "data is null");
- unsigned int siglen;
+ int siglen;
unsigned char* sigret = (unsigned char*)malloc(RSA_size(pkey->pkey.rsa));
@@ -66,11 +66,16 @@ jbyteArray Java_se_leap_openvpn_OpenVpnManagementThread_rsasign(JNIEnv* env, jcl
// unsigned char *sigret, unsigned int *siglen, RSA *rsa);
// adapted from s3_clnt.c
- if (RSA_sign(NID_md5_sha1, (unsigned char*) data, datalen,
- sigret, &siglen, pkey->pkey.rsa) <= 0 )
+ /* if (RSA_sign(NID_md5_sha1, (unsigned char*) data, datalen,
+ sigret, &siglen, pkey->pkey.rsa) <= 0 ) */
+
+ siglen = RSA_private_encrypt(datalen,(unsigned char*) data,sigret,pkey->pkey.rsa,RSA_PKCS1_PADDING);
+
+ if (siglen < 0)
{
- jniThrowException(env, "java/security/InvalidKeyException", "rsa_sign went wrong, see logcat");
+ ERR_error_string_n(ERR_get_error(), opensslerr ,1024);
+ jniThrowException(env, "java/security/InvalidKeyException", opensslerr);
ERR_print_errors_fp(stderr);
return NULL;
diff --git a/app/jni/jniglue.c b/app/jni/jniglue.c
index 143cd10b..36ad8fe7 100644
--- a/app/jni/jniglue.c
+++ b/app/jni/jniglue.c
@@ -16,7 +16,6 @@ void android_openvpn_log(int level,const char* prefix,const char* prefix_sep,con
__android_log_print(ANDROID_LOG_DEBUG,"openvpn","%s%s%s",prefix,prefix_sep,m1);
}
-void Java_se_leap_openvpn_OpenVpnManagementThread_jniclose(JNIEnv *env,jclass jo, jint fd) {
+void Java_de_blinkt_openvpn_core_NativeUtils_jniclose(JNIEnv *env,jclass jo, jint fd) {
int ret = close(fd);
}
-
diff --git a/app/jni/prebuilt.mk b/app/jni/prebuilt.mk
deleted file mode 100644
index 51bf1003..00000000
--- a/app/jni/prebuilt.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-# Build curl
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := curl
-LOCAL_SRC_FILES := prebuilt/libcurl.a
-LOCAL_PATH = $(CURRENT_DIR)
-
-include $(PREBUILT_STATIC_LIBRARY)
-
-# SIGC
-
-include $(CLEAR_VARS)
-LOCAL_MODULE := sigc
-LOCAL_SRC_FILES := prebuilt/libsigc.a
-LOCAL_PATH = $(CURRENT_DIR)
-
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-# Torrent library
-LOCAL_MODULE := rtorrent
-LOCAL_SRC_FILES := prebuilt/librtorrent.a
-LOCAL_PATH = $(CURRENT_DIR)
-
-LOCAL_STATIC_LIBRARIES := sigc
-
-include $(PREBUILT_STATIC_LIBRARY)