diff options
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni')
8 files changed, 117 insertions, 118 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp index 06709e7..d57e55b 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp @@ -476,7 +476,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject t * @param[out] aErrorMsg error message set if operation failed * @return a base64 string if operation succeed, null otherwise **/ -JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) +JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) { jbyteArray pickledDataRetValue = 0; jclass errorMsgJClass = 0; @@ -485,44 +485,44 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jbyte* keyPtr = NULL; OlmAccount* accountPtr = NULL; - LOGD("## serializeDataWithKeyJni(): IN"); + LOGD("## serializeJni(): IN"); if (!aKeyBuffer) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid key"); + LOGE(" ## serializeJni(): failure - invalid key"); } else if (!aErrorMsg) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid error object"); + LOGE(" ## serializeJni(): failure - invalid error object"); } else if (!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid account ptr"); + LOGE(" ## serializeJni(): failure - invalid account ptr"); } else if (!(errorMsgJClass = env->GetObjectClass(aErrorMsg))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error class"); + LOGE(" ## serializeJni(): failure - unable to get error class"); } else if (!(errorMsgMethodId = env->GetMethodID(errorMsgJClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID"); + LOGE(" ## serializeJni(): failure - unable to get error method ID"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, NULL))) { - LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## serializeJni(): failure - keyPtr JNI allocation OOM"); } else { size_t pickledLength = olm_pickle_account_length(accountPtr); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); + LOGD(" ## serializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## serializeJni(): key=%s",(char const *)keyPtr); void *pickledPtr = malloc((pickledLength+1)*sizeof(uint8_t)); if (!pickledPtr) { - LOGE(" ## serializeDataWithKeyJni(): failure - pickledPtr buffer OOM"); + LOGE(" ## serializeJni(): failure - pickledPtr buffer OOM"); } else { @@ -534,7 +534,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, if (result == olm_error()) { const char *errorMsgPtr = olm_account_last_error(accountPtr); - LOGE(" ## serializeDataWithKeyJni(): failure - olm_pickle_account() Msg=%s",errorMsgPtr); + LOGE(" ## serializeJni(): failure - olm_pickle_account() Msg=%s",errorMsgPtr); if(0 != (errorJstring = env->NewStringUTF(errorMsgPtr))) { @@ -546,7 +546,7 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, // build success output (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); - LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); + LOGD(" ## serializeJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); pickledDataRetValue = env->NewByteArray(pickledLength+1); env->SetByteArrayRegion(pickledDataRetValue, 0 , pickledLength+1, (jbyte*)pickledPtr); @@ -566,42 +566,42 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, } -JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) +JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) { OlmAccount* accountPtr = NULL; jstring errorMessageRetValue = 0; jbyte* keyPtr = NULL; jbyte* pickledPtr = NULL; - LOGD("## initWithSerializedDataJni(): IN"); + LOGD("## deserializeJni(): IN"); if (!aKeyBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - invalid key"); + LOGE(" ## deserializeJni(): failure - invalid key"); } else if (!aSerializedDataBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - serialized data"); + LOGE(" ## deserializeJni(): failure - serialized data"); } else if (!(accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) { - LOGE(" ## initWithSerializedDataJni(): failure - account failure OOM"); + LOGE(" ## deserializeJni(): failure - account failure OOM"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - keyPtr JNI allocation OOM"); } else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - pickledPtr JNI allocation OOM"); } else { size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); - LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); + LOGD(" ## deserializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## deserializeJni(): key=%s",(char const *)keyPtr); + LOGD(" ## deserializeJni(): pickled=%s",(char const *)pickledPtr); size_t result = olm_unpickle_account(accountPtr, (void const *)keyPtr, @@ -611,12 +611,12 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j if (result == olm_error()) { const char *errorMsgPtr = olm_account_last_error(accountPtr); - LOGE(" ## initWithSerializedDataJni(): failure - olm_unpickle_account() Msg=%s",errorMsgPtr); + LOGE(" ## deserializeJni(): failure - olm_unpickle_account() Msg=%s",errorMsgPtr); errorMessageRetValue = env->NewStringUTF(errorMsgPtr); } else { - LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result)); + LOGD(" ## deserializeJni(): success - result=%lu ", static_cast<long unsigned int>(result)); } } diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h index c866dbc..94a0381 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h @@ -47,8 +47,8 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(markOneTimeKeysAsPublishedJni)(JNIEnv *env, JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aMessage); // serialization -JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg); -JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer); +JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg); +JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer); #ifdef __cplusplus } 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 ca47dbb..d396eb9 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 @@ -86,41 +86,41 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv * * @param aSessionKey session key from an outbound session * @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise */ -JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer) +JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer) { jint retCode = ERROR_CODE_KO; OlmInboundGroupSession *sessionPtr = NULL; jbyte* sessionKeyPtr = NULL; size_t sessionResult; - LOGD("## initInboundGroupSessionWithSessionKeyJni(): inbound group session IN"); + LOGD("## initInboundGroupSessionJni(): inbound group session IN"); if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz))) { - LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid inbound group session instance"); + LOGE(" ## initInboundGroupSessionJni(): failure - invalid inbound group session instance"); } else if (!aSessionKeyBuffer) { - LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid aSessionKey"); + LOGE(" ## initInboundGroupSessionJni(): failure - invalid aSessionKey"); } else if (!(sessionKeyPtr = env->GetByteArrayElements(aSessionKeyBuffer, 0))) { - LOGE(" ## initInboundSessionFromIdKeyJni(): failure - session key JNI allocation OOM"); + LOGE(" ## initInboundGroupSessionJni(): failure - session key JNI allocation OOM"); } else { size_t sessionKeyLength = (size_t)env->GetArrayLength(aSessionKeyBuffer); - LOGD(" ## initInboundSessionFromIdKeyJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength)); + LOGD(" ## initInboundGroupSessionJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength)); sessionResult = olm_init_inbound_group_session(sessionPtr, (const uint8_t*)sessionKeyPtr, sessionKeyLength); if (sessionResult == olm_error()) { const char *errorMsgPtr = olm_inbound_group_session_last_error(sessionPtr); - LOGE(" ## initInboundSessionFromIdKeyJni(): failure - init inbound session creation Msg=%s",errorMsgPtr); + LOGE(" ## initInboundGroupSessionJni(): failure - init inbound session creation Msg=%s",errorMsgPtr); } else { retCode = ERROR_CODE_OK; - LOGD(" ## initInboundSessionFromIdKeyJni(): success - result=%lu", static_cast<long unsigned int>(sessionResult)); + LOGD(" ## initInboundGroupSessionJni(): success - result=%lu", static_cast<long unsigned int>(sessionResult)); } } @@ -337,7 +337,7 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEn * @param[out] aErrorMsg error message set if operation failed * @return a base64 string if operation succeed, null otherwise **/ -JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) +JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) { jbyteArray pickledDataRet = 0; @@ -346,44 +346,44 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni) jbyte* keyPtr = NULL; OlmInboundGroupSession* sessionPtr = NULL; - LOGD("## inbound group session serializeDataWithKeyJni(): IN"); + LOGD("## inbound group session serializeJni(): IN"); if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz))) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr"); + LOGE(" ## serializeJni(): failure - invalid session ptr"); } else if (!aKeyBuffer) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid key"); + LOGE(" ## serializeJni(): failure - invalid key"); } else if (!aErrorMsg) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid error object"); + LOGE(" ## serializeJni(): failure - invalid error object"); } else if (!(errorMsgJClass = env->GetObjectClass(aErrorMsg))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error class"); + LOGE(" ## serializeJni(): failure - unable to get error class"); } else if (!(errorMsgMethodId = env->GetMethodID(errorMsgJClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID"); + LOGE(" ## serializeJni(): failure - unable to get error method ID"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## serializeJni(): failure - keyPtr JNI allocation OOM"); } else { size_t pickledLength = olm_pickle_inbound_group_session_length(sessionPtr); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu", static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); + LOGD(" ## serializeJni(): pickledLength=%lu keyLength=%lu", static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## serializeJni(): key=%s",(char const *)keyPtr); void *pickledPtr = malloc((pickledLength+1)*sizeof(uint8_t)); if (!pickledPtr) { - LOGE(" ## serializeDataWithKeyJni(): failure - pickledPtr buffer OOM"); + LOGE(" ## serializeJni(): failure - pickledPtr buffer OOM"); } else { @@ -395,7 +395,7 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni) if (result == olm_error()) { const char *errorMsgPtr = olm_inbound_group_session_last_error(sessionPtr); - LOGE(" ## serializeDataWithKeyJni(): failure - olm_pickle_outbound_group_session() Msg=%s",errorMsgPtr); + LOGE(" ## serializeJni(): failure - olm_pickle_outbound_group_session() Msg=%s",errorMsgPtr); jstring errorJstring = env->NewStringUTF(errorMsgPtr); @@ -407,7 +407,7 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni) else { (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); - LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); + LOGD(" ## serializeJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); pickledDataRet = env->NewByteArray(pickledLength); env->SetByteArrayRegion(pickledDataRet, 0 , pickledLength, (jbyte*)pickledPtr); @@ -427,42 +427,42 @@ JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni) } -JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) +JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) { OlmInboundGroupSession* sessionPtr = NULL; jstring errorMessageRetValue = 0; jbyte* keyPtr = NULL; jbyte* pickledPtr = NULL; - LOGD("## initWithSerializedDataJni(): IN"); + LOGD("## deserializeJni(): IN"); if (!(sessionPtr = (OlmInboundGroupSession*)getInboundGroupSessionInstanceId(env,thiz))) { - LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM"); + LOGE(" ## deserializeJni(): failure - session failure OOM"); } else if (!aKeyBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - invalid key"); + LOGE(" ## deserializeJni(): failure - invalid key"); } else if (!aSerializedDataBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - serialized data"); + LOGE(" ## deserializeJni(): failure - serialized data"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - keyPtr JNI allocation OOM"); } else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - pickledPtr JNI allocation OOM"); } else { size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); - LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); + LOGD(" ## deserializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## deserializeJni(): key=%s",(char const *)keyPtr); + LOGD(" ## deserializeJni(): pickled=%s",(char const *)pickledPtr); size_t result = olm_unpickle_inbound_group_session(sessionPtr, (void const *)keyPtr, @@ -472,12 +472,12 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)( if (result == olm_error()) { const char *errorMsgPtr = olm_inbound_group_session_last_error(sessionPtr); - LOGE(" ## initWithSerializedDataJni(): failure - olm_unpickle_inbound_group_session() Msg=%s",errorMsgPtr); + LOGE(" ## deserializeJni(): failure - olm_unpickle_inbound_group_session() Msg=%s",errorMsgPtr); errorMessageRetValue = env->NewStringUTF(errorMsgPtr); } else { - LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result)); + LOGD(" ## deserializeJni(): success - result=%lu ", static_cast<long unsigned int>(result)); } } 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 7ed6d8b..0ef55cf 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 @@ -32,13 +32,13 @@ extern "C" { JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env, jobject thiz); JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject thiz); -JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer); +JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer); JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEnv *env, jobject thiz); JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aEncryptedMsg, jobject aDecryptIndex, jobject aErrorMsg); // serialization -JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); -JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); +JNIEXPORT jbyteArray OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); +JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); #ifdef __cplusplus diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp index aa0e5e7..4168742 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp @@ -372,7 +372,7 @@ JNIEXPORT jbyteArray OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIE * @param[out] aErrorMsg error message set if operation failed * @return a base64 string if operation succeed, null otherwise **/ -JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) +JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) { jstring pickledDataRetValue = 0; jclass errorMsgJClass = 0; @@ -381,44 +381,44 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J jbyte* keyPtr = NULL; OlmOutboundGroupSession* sessionPtr = NULL; - LOGD("## outbound group session serializeDataWithKeyJni(): IN"); + LOGD("## outbound group session serializeJni(): IN"); if (!(sessionPtr = (OlmOutboundGroupSession*)getOutboundGroupSessionInstanceId(env,thiz))) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr"); + LOGE(" ## serializeJni(): failure - invalid session ptr"); } else if (!aKeyBuffer) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid key"); + LOGE(" ## serializeJni(): failure - invalid key"); } else if (!aErrorMsg) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid error object"); + LOGE(" ## serializeJni(): failure - invalid error object"); } else if (!(errorMsgJClass = env->GetObjectClass(aErrorMsg))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error class"); + LOGE(" ## serializeJni(): failure - unable to get error class"); } else if (!(errorMsgMethodId = env->GetMethodID(errorMsgJClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID"); + LOGE(" ## serializeJni(): failure - unable to get error method ID"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## serializeJni(): failure - keyPtr JNI allocation OOM"); } else { size_t pickledLength = olm_pickle_outbound_group_session_length(sessionPtr); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); + LOGD(" ## serializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## serializeJni(): key=%s",(char const *)keyPtr); void *pickledPtr = malloc((pickledLength+1)*sizeof(uint8_t)); if(!pickledPtr) { - LOGE(" ## serializeDataWithKeyJni(): failure - pickledPtr buffer OOM"); + LOGE(" ## serializeJni(): failure - pickledPtr buffer OOM"); } else { @@ -430,7 +430,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J if (result == olm_error()) { const char *errorMsgPtr = olm_outbound_group_session_last_error(sessionPtr); - LOGE(" ## serializeDataWithKeyJni(): failure - olm_pickle_outbound_group_session() Msg=%s",errorMsgPtr); + LOGE(" ## serializeJni(): failure - olm_pickle_outbound_group_session() Msg=%s",errorMsgPtr); if (!(errorJstring = env->NewStringUTF(errorMsgPtr))) { @@ -442,7 +442,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J // build success output (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); - LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); + LOGD(" ## serializeJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); } } @@ -459,42 +459,42 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J } -JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) +JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) { OlmOutboundGroupSession* sessionPtr = NULL; jstring errorMessageRetValue = 0; jbyte* keyPtr = NULL; jbyte* pickledPtr = NULL; - LOGD("## initWithSerializedDataJni(): IN"); + LOGD("## deserializeJni(): IN"); if (!(sessionPtr = (OlmOutboundGroupSession*)getOutboundGroupSessionInstanceId(env,thiz))) { - LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM"); + LOGE(" ## deserializeJni(): failure - session failure OOM"); } else if (!aKeyBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - invalid key"); + LOGE(" ## deserializeJni(): failure - invalid key"); } else if (!aSerializedDataBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - serialized data"); + LOGE(" ## deserializeJni(): failure - serialized data"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - keyPtr JNI allocation OOM"); } else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - pickledPtr JNI allocation OOM"); } else { size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); - LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); + LOGD(" ## deserializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## deserializeJni(): key=%s",(char const *)keyPtr); + LOGD(" ## deserializeJni(): pickled=%s",(char const *)pickledPtr); size_t result = olm_unpickle_outbound_group_session(sessionPtr, (void const *)keyPtr, @@ -504,12 +504,12 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni) if (result == olm_error()) { const char *errorMsgPtr = olm_outbound_group_session_last_error(sessionPtr); - LOGE(" ## initWithSerializedDataJni(): failure - olm_unpickle_outbound_group_session() Msg=%s",errorMsgPtr); + LOGE(" ## deserializeJni(): failure - olm_unpickle_outbound_group_session() Msg=%s",errorMsgPtr); errorMessageRetValue = env->NewStringUTF(errorMsgPtr); } else { - LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result)); + LOGD(" ## deserializeJni(): success - result=%lu ", static_cast<long unsigned int>(result)); } } diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h index 37f0ea6..f954bef 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h @@ -40,8 +40,8 @@ JNIEXPORT jbyteArray OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv * JNIEXPORT jbyteArray OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsgBuffer, jobject aErrorMsg); // serialization -JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); -JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); +JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); +JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); #ifdef __cplusplus } diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp index 3731d14..4a1717a 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp @@ -780,7 +780,7 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, * @param[out] aErrorMsg error message set if operation failed * @return a base64 string if operation succeed, null otherwise **/ -JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) +JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg) { jstring pickledDataRetValue = 0; jclass errorMsgJClass = 0; @@ -789,44 +789,44 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job jbyte* keyPtr = NULL; OlmSession* sessionPtr = NULL; - LOGD("## serializeDataWithKeyJni(): IN"); + LOGD("## serializeJni(): IN"); if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz))) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr"); + LOGE(" ## serializeJni(): failure - invalid session ptr"); } else if (!aKeyBuffer) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid key"); + LOGE(" ## serializeJni(): failure - invalid key"); } else if (!aErrorMsg) { - LOGE(" ## serializeDataWithKeyJni(): failure - invalid error object"); + LOGE(" ## serializeJni(): failure - invalid error object"); } else if (!(errorMsgJClass = env->GetObjectClass(aErrorMsg))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error class"); + LOGE(" ## serializeJni(): failure - unable to get error class"); } else if (!(errorMsgMethodId = env->GetMethodID(errorMsgJClass, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;"))) { - LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID"); + LOGE(" ## serializeJni(): failure - unable to get error method ID"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## serializeJni(): failure - keyPtr JNI allocation OOM"); } else { size_t pickledLength = olm_pickle_session_length(sessionPtr); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr); + LOGD(" ## serializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## serializeJni(): key=%s",(char const *)keyPtr); void *pickledPtr = malloc((pickledLength+1)*sizeof(uint8_t)); if (!pickledPtr) { - LOGE(" ## serializeDataWithKeyJni(): failure - pickledPtr buffer OOM"); + LOGE(" ## serializeJni(): failure - pickledPtr buffer OOM"); } else { @@ -838,7 +838,7 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job if (result == olm_error()) { const char *errorMsgPtr = olm_session_last_error(sessionPtr); - LOGE(" ## serializeDataWithKeyJni(): failure - olm_pickle_session() Msg=%s",errorMsgPtr); + LOGE(" ## serializeJni(): failure - olm_pickle_session() Msg=%s",errorMsgPtr); if ((errorJstring = env->NewStringUTF(errorMsgPtr))) { @@ -850,7 +850,7 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job // build success output (static_cast<char*>(pickledPtr))[pickledLength] = static_cast<char>('\0'); pickledDataRetValue = env->NewStringUTF((const char*)pickledPtr); - LOGD(" ## serializeDataWithKeyJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); + LOGD(" ## serializeJni(): success - result=%lu pickled=%s", static_cast<long unsigned int>(result), static_cast<char*>(pickledPtr)); } free(pickledPtr); @@ -867,42 +867,42 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job } -JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) +JNIEXPORT jstring OLM_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer) { OlmSession* sessionPtr = NULL; jstring errorMessageRetValue = 0; jbyte* keyPtr = NULL; jbyte* pickledPtr = NULL; - LOGD("## initWithSerializedDataJni(): IN"); + LOGD("## deserializeJni(): IN"); if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz))) { - LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM"); + LOGE(" ## deserializeJni(): failure - session failure OOM"); } else if (!aKeyBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - invalid key"); + LOGE(" ## deserializeJni(): failure - invalid key"); } else if (!aSerializedDataBuffer) { - LOGE(" ## initWithSerializedDataJni(): failure - serialized data"); + LOGE(" ## deserializeJni(): failure - serialized data"); } else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - keyPtr JNI allocation OOM"); } else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0))) { - LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM"); + LOGE(" ## deserializeJni(): failure - pickledPtr JNI allocation OOM"); } else { size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer); size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer); - LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); - LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr); - LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr); + LOGD(" ## deserializeJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength)); + LOGD(" ## deserializeJni(): key=%s",(char const *)keyPtr); + LOGD(" ## deserializeJni(): pickled=%s",(char const *)pickledPtr); size_t result = olm_unpickle_session(sessionPtr, (void const *)keyPtr, @@ -912,14 +912,13 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j if (result == olm_error()) { const char *errorMsgPtr = olm_session_last_error(sessionPtr); - LOGE(" ## initWithSerializedDataJni(): failure - olm_unpickle_account() Msg=%s",errorMsgPtr); + LOGE(" ## deserializeJni(): failure - olm_unpickle_account() Msg=%s",errorMsgPtr); errorMessageRetValue = env->NewStringUTF(errorMsgPtr); } else { - LOGD(" ## initWithSerializedDataJni(): success - result=%lu ", static_cast<long unsigned int>(result)); + LOGD(" ## initJni(): success - result=%lu ", static_cast<long unsigned int>(result)); } - } // free alloc diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h index 9ce12d4..95b421b 100644 --- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h +++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h @@ -50,8 +50,8 @@ JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobjec JNIEXPORT jbyteArray OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, jobject thiz); // serialization -JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); -JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); +JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg); +JNIEXPORT jstring OLM_SESSION_FUNC_DEF(deserializeJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey); #ifdef __cplusplus } |