aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/main/jni
diff options
context:
space:
mode:
authorpedroGitt <pedro.contreiras@amdocs.com>2016-11-23 01:20:47 +0100
committerpedroGitt <pedro.contreiras@amdocs.com>2016-11-23 01:20:47 +0100
commite63be9777453d6bc18fe70c68839bb91406ffcd0 (patch)
treec2f850e833a695c09f7cc8d0c19c7d75e4131aff /java/android/OlmLibSdk/olm-sdk/src/main/jni
parent7a6897642baa8fc5d9d9f14c80fc4f201cfe2173 (diff)
Update with master branch => OLM V2.0.0
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/Android.mk4
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp23
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h2
3 files changed, 24 insertions, 5 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/Android.mk b/java/android/OlmLibSdk/olm-sdk/src/main/jni/Android.mk
index 2d94676..2a7d216 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/Android.mk
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/Android.mk
@@ -2,8 +2,8 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := olm
-MAJOR := 1
-MINOR := 3
+MAJOR := 2
+MINOR := 0
PATCH := 0
OLM_VERSION := $(MAJOR).$(MINOR).$(PATCH)
SRC_ROOT_DIR := ../../../../../../..
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
index a78c2cf..e450a4c 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
@@ -180,13 +180,16 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn
}
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jboolean aIsUtf8ConversionRequired)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jobject aDecryptIndex, jboolean aIsUtf8ConversionRequired)
{
jstring decryptedMsgRetValue = 0;
OlmInboundGroupSession *sessionPtr = NULL;
const char *encryptedMsgPtr = NULL;
uint8_t *plainTextMsgPtr = NULL;
uint8_t *tempEncryptedPtr = NULL;
+ uint32_t messageIndex = 0;
+ jclass indexObjJClass = 0;
+ jfieldID indexMsgFieldId;
LOGD("## decryptMessageJni(): inbound group session IN");
@@ -198,10 +201,22 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
{
LOGE(" ## decryptMessageJni(): failure - invalid encrypted message");
}
+ else if(0 == aDecryptIndex)
+ {
+ LOGE(" ## decryptMessageJni(): failure - invalid index object");
+ }
else if(0 == (encryptedMsgPtr = env->GetStringUTFChars(aEncryptedMsg, 0)))
{
LOGE(" ## decryptMessageJni(): failure - encrypted message JNI allocation OOM");
}
+ else if(0 == (indexObjJClass = env->GetObjectClass(aDecryptIndex)))
+ {
+ LOGE("## decryptMessageJni(): failure - unable to get index class");
+ }
+ else if(0 == (indexMsgFieldId = env->GetFieldID(indexObjJClass,"mIndex","J")))
+ {
+ LOGE("## decryptMessageJni(): failure - unable to get index type field");
+ }
else
{
// get encrypted message length
@@ -238,13 +253,17 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
tempEncryptedPtr,
encryptedMsgLength,
plainTextMsgPtr,
- maxPlainTextLength);
+ maxPlainTextLength,
+ &messageIndex);
if(plaintextLength == olm_error())
{
LOGE(" ## decryptMessageJni(): failure - olm_group_decrypt Msg=%s",(const char *)olm_inbound_group_session_last_error(sessionPtr));
}
else
{
+ // update index
+ env->SetLongField(aDecryptIndex, indexMsgFieldId, (jlong)messageIndex);
+
// UTF-8 conversion workaround for issue on Android versions older than Marshmallow (23)
if(aIsUtf8ConversionRequired)
{
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
index ec402fd..7d6fb5e 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
@@ -33,7 +33,7 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *
JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jstring aSessionKey);
JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEnv *env, jobject thiz);
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jboolean aIsUtf8ConversionRequired);
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jobject aDecryptIndex, jboolean aIsUtf8ConversionRequired);
// serialization
JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);