Merge default with readd-ident.id

JNI-76
Hussein Kasem 4 years ago
commit 452d998bf7

@ -15,7 +15,7 @@ buildscript {
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.4'
//classpath 'com.android.tools.build:gradle:2.2.0'
}
}
@ -31,7 +31,7 @@ apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion '26.0.2'
buildToolsVersion '27.0.3'
defaultConfig {
minSdkVersion 18

@ -9,7 +9,7 @@
# TODO: get params from the outside for multiarch build
NDK_ABI ?= arm
NDK_TOOLCHAIN_VERSION ?= 4.9
NDK_TOOLCHAIN_VERSION ?= clang
APP_ABI ?= armeabi-v7a
APP_PLATFORM ?= android-18
PEP_PACKAGE_NAME ?= com.pep.k9
@ -44,8 +44,9 @@ else
NDK_PROCESSOR=x86
endif
NDK_SYSROOT=$(ANDROID_NDK_HOME)/platforms/$(APP_PLATFORM)/arch-$(NDK_ABI)
NDK_SYSROOT=$(ANDROID_NDK_HOME)/sysroot
NDK_UNAME := $(shell uname -s | tr '[A-Z]' '[a-z]')
ifeq ($(NDK_ABI),x86)
HOST = i686-linux-android
NDK_TOOLCHAIN = $(NDK_ABI)-$(NDK_TOOLCHAIN_VERSION)
@ -53,27 +54,28 @@ else
HOST = $(NDK_ABI)-linux-androideabi
NDK_TOOLCHAIN = $(HOST)-$(NDK_TOOLCHAIN_VERSION)
endif
NDK_TOOLCHAIN_BASE=$(ANDROID_NDK_HOME)/toolchains/$(NDK_TOOLCHAIN)/prebuilt/$(NDK_UNAME)-$(NDK_PROCESSOR)
# include Android's build flags
TARGET_ARCH_ABI = $(APP_ABI)
include $(ANDROID_NDK_HOME)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk
#include $(ANDROID_NDK)/build/core/toolchains/$(NDK_TOOLCHAIN)/setup.mk
#include $(ANDROID_NDK_HOME)/toolchains/$(NDK_TOOLCHAIN)/setup.mk
ANDROID_NDK_HOME=$(EXTERNAL_ROOT)/ndk-18-arm
LD := $(ANDROID_NDK_HOME)/bin/$(HOST)-ld
AR := $(ANDROID_NDK_HOME)/bin/$(HOST)-ar
AS :cd= $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CC := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang
CXX := $(ANDROID_NDK_HOME)/bin/$(HOST)-clang++
RANLIB := $(ANDROID_NDK_HOME)/bin/$(HOST)-ranlib
CC := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-gcc --sysroot=$(NDK_SYSROOT)
LD := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ld
AR := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ar
RANLIB := $(NDK_TOOLCHAIN_BASE)/bin/$(HOST)-ranlib
CFLAGS = -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS)
LDFLAGS = -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie
CFLAGS += -DANDROID -I$(LOCAL)/include $(TARGET_CFLAGS) -fPIE -fPIC -D_FILE_OFFSET_BITS=64 -DLARGEFILE_SOURCE=1
LDFLAGS += -llog -L$(LOCAL)/lib $(TARGET_LDFLAGS) -pie
# change 'release' to 'debug' for unoptimized debug builds
ifeq ($(APP_ABI),armeabi-v7a)
CFLAGS += $(TARGET_arm_release_CFLAGS)
CFLAGS += $(TARGET_arm_debug_CFLAGS)
endif
ifeq ($(APP_ABI),armeabi)
CFLAGS += $(TARGET_thumb_release_CFLAGS)
CFLAGS += $(TARGET_thumb_debug_CFLAGS)
endif
#------------------------------------------------------------------------------#
@ -187,6 +189,7 @@ libassuan/Makefile: libassuan/configure
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
./configure \
--enable-maintainer-mode \
--disable-largefile \
--host=$(HOST) \
--with-gpg-error-prefix=$(LOCAL) \
--prefix=$(LOCAL)
@ -205,7 +208,7 @@ libassuan-install: $(LOCAL)/lib/libassuan.so
#------------------------------------------------------------------------------#
# libksba
EXTERNAL_GIT_REPOS += libksba|git://git.gnupg.org/libksba.git?libksba-1.3.3
EXTERNAL_GIT_REPOS += libksba|git://git.gnupg.org/libksba.git?libksba-1.3.4
libksba/configure: libksba.src.stamp libksba/configure.ac
cd libksba && ./autogen.sh
@ -231,6 +234,35 @@ libksba-build: libksba/src/.libs/libksba.so
libksba-install: $(LOCAL)/lib/libksba.so
#------------------------------------------------------------------------------#
# npth
EXTERNAL_GIT_REPOS += npth|git://git.gnupg.org/npth.git?npth-1.2
npth/configure: npth.src.stamp npth/configure.ac
cd npth && ./autogen.sh
npth/Makefile: $(LOCAL)/lib/libgpg-error.so npth/configure
cd npth && \
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
./configure $(CONFIGURE_ARGS) \
--enable-maintainer-mode \
--host=$(HOST) \
--with-gpg-error-prefix=$(LOCAL) \
--prefix=$(LOCAL)
npth/src/.libs/libnpth.so: npth/Makefile
$(MAKE) -C npth
$(LOCAL)/lib/libnpth.so: npth/src/.libs/libnpth.so
$(MAKE) -C npth prefix=$(LOCAL) install
ls -l $(LOCAL)/lib/libnpth.so
npth-build: npth/src/.libs/libnpth.so
npth-install: $(LOCAL)/lib/libnpth.so
#------------------------------------------------------------------------------#
# curl
@ -350,7 +382,7 @@ gnupg/Makefile: gnupg/configure
--disable-gpgsm \
--prefix=$(prefix)
gnupg/g10/gpg2: $(LOCAL)/lib/libgpg-error.so $(LOCAL)/lib/libgcrypt.so $(LOCAL)/lib/libksba.so $(LOCAL)/lib/libassuan.so $(LOCAL)/lib/libcurl.so $(LOCAL)/lib/libiconv.so gnupg/Makefile
gnupg/g10/gpg2: $(LOCAL)/lib/libgpg-error.so $(LOCAL)/lib/libgcrypt.so $(LOCAL)/lib/libksba.so $(LOCAL)/lib/libnpth.so $(LOCAL)/lib/libassuan.so $(LOCAL)/lib/libcurl.so $(LOCAL)/lib/libiconv.so gnupg/Makefile
$(MAKE) -C gnupg
$(LOCAL)/bin/gpg2: gnupg/g10/gpg2 gnupg/configure
@ -369,8 +401,14 @@ gnupg-install: $(LOCAL)/bin/gpg2
EXTERNAL_GIT_REPOS += gpgme|git://git.gnupg.org/gpgme.git?gpgme-1.8.0
gpgme/configure: gpgme.src.stamp gpgme/configure.ac
cd gpgme && ./autogen.sh
gpgme/configure: gpgme.src.stamp gpgme/configure.ac
cd gpgme && ./autogen.sh
ifneq ("x$(findstring '64',$(HOST))x","xx")
gpgme_32b_force_no_largefile =
else
gpgme_32b_force_no_largefile = --disable-largefile
endif
gpgme/Makefile: gpgme/configure
-patch -N -p1 --reject-file=- gpgme/m4/libtool.m4 libtool-Add-Android-Linux-support.patch
@ -378,6 +416,7 @@ gpgme/Makefile: gpgme/configure
CC="$(CC)" AR="$(AR)" RANLIB=$(RANLIB) CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
./configure \
--host=$(HOST) \
$(gpgme_32b_force_no_largefile) \
--enable-maintainer-mode \
--with-gpg-error-prefix=$(LOCAL) \
--with-libassuan-prefix=$(LOCAL) \
@ -411,7 +450,7 @@ libetpan/build-android/libetpan-android-1.zip: libiconv-install libetpan.src.sta
libetpan-build: libetpan/build-android/libetpan-android-1.zip
libetpan-cleanzip:
libetpan-cleanzip:
rm -f libetpan/build-android/libetpan-android-1.zip
#------------------------------------------------------------------------------#
@ -438,7 +477,7 @@ EXTERNAL_SRCS_CLEAN += uuid-clean
uuid/Makefile: uuid.src.stamp
sed -i 's,AC_CHECK_VA_COPY(),,' uuid/uuid.ac
cd uuid && autoconf
cd uuid && autoconf
-patch -N -p1 --reject-file=- uuid/libtool.m4 libtool-Add-Android-Linux-support-iconv.patch
cp config.sub uuid
cp config.guess uuid
@ -490,7 +529,7 @@ assets: clean-assets
#------------------------------------------------------------------------------#
# Clone update and archive external projects GIT repos
# Local clone is in external/$project.git while
# Local clone is in external/$project.git while
# selected commit is archived in external/$project
define per_repo_targets
@ -510,7 +549,7 @@ $(1).src.stamp: $(1).git.stamp
$(1)-src: $(1).src.stamp
$(1)-clean:
$(1)-clean:
rm -rf $(1)
rm -f $(1).src.stamp
@ -546,6 +585,9 @@ clean-install:
clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-cleanzip
clean-all: clean
rm -rf *.git
rm -rf *.stamp
#------------------------------------------------------------------------------#
.PHONY = clean clean-install clean-assets libetpan-cleanzip\
@ -553,6 +595,7 @@ clean: $(EXTERNAL_SRCS_CLEAN) clean-assets clean-install libetpan-cleanzip
libgcrypt-build libgcrypt-install \
libassuan-build libassuan-install \
libksba-build libksba-install \
libnpth-build libnpth-install \
libiconv-build libiconv-install \
uuid-build uuid-install \
gnupg-build gnupg-install\

@ -0,0 +1,21 @@
#!/bin/bash
usage="Usage: $(basename "$0") [-h][--force] -- Script to generate android standalone toolchain to build pEp for Android.
where:
-h Show this help text
--force Force generating the toolchain"
if [ "$1" == "-h" ]; then
echo "$usage"
exit 0
fi
if [ -z "$ANDROID_NDK" ]; then
echo "Please define \$ANDROID_NDK"
exit 1
fi
$ANDROID_NDK/build/tools/make_standalone_toolchain.py $1 --arch arm --api 18 --install-dir=ndk-18-arm
exit 0

@ -1,13 +1,13 @@
--- a/libgcrypt/Makefile.am 2015-09-08 08:29:55.000000000 +0200
+++ b/libgcrypt/Makefile.am 2016-08-23 17:16:50.712565999 +0200
@@ -24,8 +24,8 @@
# (A suitable gitlog-to-changelog script can be found in GnuPG master.)
GITLOG_TO_CHANGELOG=gitlog-to-changelog
--- Makefile.am 2018-09-14 09:13:36.224317923 +0200
+++ Makefile.am.orig 2018-09-14 08:57:37.545217924 +0200
@@ -31,8 +31,8 @@
endif
-DIST_SUBDIRS = m4 compat mpi cipher random src doc tests
-SUBDIRS = compat mpi cipher random src doc tests
+DIST_SUBDIRS = m4 compat mpi cipher random src
+SUBDIRS = compat mpi cipher random src
-DIST_SUBDIRS = m4 compat mpi cipher random src
-SUBDIRS = compat mpi cipher random src
+DIST_SUBDIRS = m4 compat mpi cipher random src doc tests
+SUBDIRS = compat mpi cipher random src $(doc) tests
EXTRA_DIST = autogen.sh autogen.rc README.GIT LICENSES \
ChangeLog-2011 build-aux/ChangeLog-2011 doc/ChangeLog-2011 \

@ -59,6 +59,7 @@ LOCAL_MODULE := pEpJNI
LOCAL_SHARED_LIBRARIES := libgpgme libassuan libcurl libgcrypt libgpg-error
LOCAL_STATIC_LIBRARIES := pEpEngine libetpan libiconv libuuid
LOCAL_CPP_FEATURES += exceptions
LOCAL_CFLAGS += -DHAVE_PTHREADS
LOCAL_SRC_FILES := \
../../src/org_pEp_jniadapter_AbstractEngine.cc \
../../src/org_pEp_jniadapter_Engine.cc \
@ -68,7 +69,7 @@ LOCAL_SRC_FILES := \
../../src/jniutils.cc
LOCAL_C_INCLUDES += $(GPGBUILD)/include
LOCAL_LDLIBS := -llog
LOCAL_LDLIBS += -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)

@ -1,5 +1,6 @@
APP_STL := stlport_static
APP_STL := c++_static
APP_OPTIM := debug
APP_PLATFORM=android-18
APP_ABI := armeabi-v7a
NDK_TOOLCHAIN_VERSION = 4.9
NDK_TOOLCHAIN_VERSION = clang
APP_UNIFIED_HEADERS=true

@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '25.0.2'
compileSdkVersion 25
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "pep.android.k9.materials"
applicationId "security.pEp"
minSdkVersion 19
targetSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
}

@ -1429,7 +1429,7 @@ public class MainActivity extends AppCompatActivity {
private Engine.decrypt_message_Return decryptMessageOnEngine(Engine engine, Message encriptedMessage) throws pEpException {
long lastTime = System.currentTimeMillis();
logStart("engine.decrypt_message", String.valueOf(lastTime));
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage, 0);
logEnd("engine.decrypt_message", String.valueOf(System.currentTimeMillis() - lastTime));
return decrypt_message_return;
}

@ -37,7 +37,7 @@ public class PEpUnitaryStuff {
msg.setCc(cc);
Message encriptedMessage = engine.encrypt_message(msg, null, Message.EncFormat.PEP);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage, 0);
if (!decrypt_message_return.dst.getLongmsg().equals(message)) {
throw new RuntimeException("FAILED");

@ -177,7 +177,7 @@ public class UnitActivity extends AppCompatActivity {
private Engine.decrypt_message_Return decryptMessageOnEngine(Engine engine, Message encriptedMessage) throws pEpException {
long lastTime = System.currentTimeMillis();
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage);
Engine.decrypt_message_Return decrypt_message_return = engine.decrypt_message(encriptedMessage, 0);
long time = System.currentTimeMillis() - lastTime;
Log.d("time", " " + time);
return decrypt_message_return;

@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.android.tools.build:gradle:3.1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
@ -15,5 +16,6 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}

@ -24,7 +24,10 @@ JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_trustwords(
size_t wsize;
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
::update_identity(session, _ident);
if (_ident->me)
::myself(session, _ident);
else
::update_identity(session, _ident);
}
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -56,8 +59,13 @@ JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_myself(
PEP_SESSION session = (PEP_SESSION) callLongMethod(env, obj, "getHandle");
pEp_identity *_ident = to_identity(env, ident);
::myself(session, _ident);
PEP_STATUS status = ::myself(session, _ident);
if (status != PEP_STATUS_OK) {
LOGD("Failed Myself: 0x%04x\\n", status);
throw_pEp_Exception(env, status);
return NULL;
}
return from_identity(env, _ident);
}
@ -86,7 +94,13 @@ JNIEXPORT jobject JNICALL Java_org_pEp_jniadapter_Engine_setOwnKey(
pEp_identity *_ident = to_identity(env, ident);
char *_fpr = to_string(env, fpr);
::set_own_key(session, _ident, _fpr);
PEP_STATUS status = ::set_own_key(session, _ident, _fpr);
if (status != PEP_STATUS_OK) {
LOGD("Failed setOwnKey: 0x%04x\\n", status);
throw_pEp_Exception(env, status);
return NULL;
}
return from_identity(env, _ident);
}
@ -101,7 +115,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_keyMistrusted(
pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
::update_identity(session, _ident);
if (_ident->me)
::myself(session, _ident);
else
::update_identity(session, _ident);
}
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -122,7 +139,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_keyResetTrust(
pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
::update_identity(session, _ident);
if (_ident->me)
::myself(session, _ident);
else
::update_identity(session, _ident);
}
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
@ -143,7 +163,10 @@ JNIEXPORT void JNICALL Java_org_pEp_jniadapter_Engine_trustPersonalKey(
pEp_identity *_ident = to_identity(env, ident);
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {
::update_identity(session, _ident);
if (_ident->me)
::myself(session, _ident);
else
::update_identity(session, _ident);
}
if (_ident->fpr == NULL || _ident->fpr[0] == 0) {

@ -460,6 +460,9 @@ namespace pEp {
_setStringField(env, classname, obj, "lang", ident->lang);
jfieldID me_id = getFieldID(env, classname, "me", "Z");
env->SetBooleanField(obj, me_id, (jboolean) ident->me);
jfieldID flags_id = getFieldID(env, classname, "flags", "I");
env->SetIntField(obj, flags_id, (jint) (int) ident->flags);
}
@ -489,6 +492,9 @@ namespace pEp {
_setStringField(env, classname, obj, "lang", ident->lang, identityClass);
jfieldID me_id = getFieldID(env, classname, "me", "Z", identityClass);
env->SetBooleanField(obj, me_id, (jboolean) ident->me);
jfieldID flags_id = getFieldID(env, classname, "flags", "I", identityClass);
env->SetIntField(obj, flags_id, (jint) (int) ident->flags);
}
@ -531,6 +537,9 @@ namespace pEp {
}
free(lang);
jfieldID me_id = getFieldID(env, classname, "me", "Z");
ident->me = (bool) env->GetBooleanField(obj, me_id);
jfieldID flags_id = getFieldID(env, classname, "flags", "I");
ident->flags = (identity_flags_t) (int) env->GetIntField(obj, flags_id);

@ -9,9 +9,16 @@ public class Identity implements Serializable{
public String username;
public CommType comm_type;
public String lang;
public boolean me;
public int flags;
public Identity() {
this.me = false;
comm_type = CommType.PEP_ct_unknown;
}
public Identity(boolean me) {
this.me = me;
comm_type = CommType.PEP_ct_unknown;
}
@ -22,6 +29,7 @@ public class Identity implements Serializable{
username = AbstractEngine.toUTF16(i.username);
comm_type = CommType.Management.tag.get(i.comm_type);
lang = AbstractEngine.toUTF16(i.lang);
me = i.me;
flags = i.flags;
}

@ -7,9 +7,15 @@ public class _Identity {
public byte[] username;
public int comm_type;
public byte[] lang;
public boolean me;
public int flags;
public _Identity() {
this.me = false;
}
public _Identity(boolean me) {
this.me = me;
}
public _Identity(Identity i) {
@ -19,6 +25,7 @@ public class _Identity {
username = AbstractEngine.toUTF8(i.username);
comm_type = i.comm_type.value;
lang = AbstractEngine.toUTF8(i.lang);
me = i.me;
flags = i.flags;
}
}

Loading…
Cancel
Save