aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/main/jni
diff options
context:
space:
mode:
authorylecollen <ylecollen@amdocs.com>2017-01-03 14:14:56 +0100
committerylecollen <ylecollen@amdocs.com>2017-01-03 14:14:56 +0100
commit765647cda501b53bac990332444aadc4404fe314 (patch)
treed395c297cad84907bda9e5e63c291702f2911a8f /java/android/OlmLibSdk/olm-sdk/src/main/jni
parentde962ef8d7f0dd447274dc88d9630caa6614379b (diff)
There is more GetStringUTFChars call.
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp36
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h4
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp62
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h8
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp34
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h4
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp132
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h16
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp40
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h4
10 files changed, 170 insertions, 170 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 a44d9db..87ed86a 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
@@ -468,22 +468,22 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
/**
* Serialize and encrypt account instance into a base64 string.<br>
-* @param aKey key used to encrypt the serialized account data
+* @param aKeyBuffer key used to encrypt the serialized account data
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmAccount* accountPtr = NULL;
LOGD("## serializeDataWithKeyJni(): IN");
- if (!aKey)
+ if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -503,14 +503,14 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, NULL)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_account_length(accountPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -552,27 +552,27 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmAccount* accountPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
- if (!aKey)
+ if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
@@ -580,18 +580,18 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
{
LOGE(" ## initWithSerializedDataJni(): failure - account failure OOM");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -616,12 +616,12 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
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 7e09403..88ef215 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 jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aMessage);
// serialization
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring 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);
#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 8a56a12..9eba3af 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,11 +86,11 @@ 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, jstring aSessionKey)
+JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmInboundGroupSession *sessionPtr = NULL;
- const uint8_t *sessionKeyPtr = NULL;
+ jbyte* sessionKeyPtr = NULL;
size_t sessionResult;
LOGD("## initInboundGroupSessionWithSessionKeyJni(): inbound group session IN");
@@ -99,20 +99,20 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
{
LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid inbound group session instance");
}
- else if (!aSessionKey)
+ else if (!aSessionKeyBuffer)
{
LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid aSessionKey");
}
- else if (!(sessionKeyPtr = (const uint8_t *)env->GetStringUTFChars(aSessionKey, 0)))
+ else if (!(sessionKeyPtr = env->GetByteArrayElements(aSessionKeyBuffer, 0)))
{
LOGE(" ## initInboundSessionFromIdKeyJni(): failure - session key JNI allocation OOM");
}
else
{
- size_t sessionKeyLength = (size_t)env->GetStringUTFLength(aSessionKey);
+ size_t sessionKeyLength = (size_t)env->GetArrayLength(aSessionKeyBuffer);
LOGD(" ## initInboundSessionFromIdKeyJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength));
- sessionResult = olm_init_inbound_group_session(sessionPtr, sessionKeyPtr, 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);
@@ -127,7 +127,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
// free local alloc
if (sessionKeyPtr)
{
- env->ReleaseStringUTFChars(aSessionKey, (const char*)sessionKeyPtr);
+ env->ReleaseByteArrayElements(aSessionKeyBuffer, sessionKeyPtr, JNI_ABORT);
}
return retCode;
@@ -183,11 +183,11 @@ 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, jobject aDecryptionResult, jobject aErrorMsg)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aEncryptedMsgBuffer, jobject aDecryptionResult, jobject aErrorMsg)
{
jstring decryptedMsgRetValue = 0;
OlmInboundGroupSession *sessionPtr = NULL;
- const char *encryptedMsgPtr = NULL;
+ jbyte *encryptedMsgPtr = NULL;
jclass indexObjJClass = 0;
jfieldID indexMsgFieldId;
jclass errorMsgJClass = 0;
@@ -200,7 +200,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
{
LOGE(" ## decryptMessageJni(): failure - invalid inbound group session ptr=NULL");
}
- else if (!aEncryptedMsg)
+ else if (!aEncryptedMsgBuffer)
{
LOGE(" ## decryptMessageJni(): failure - invalid encrypted message");
}
@@ -220,7 +220,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
{
LOGE(" ## decryptMessageJni(): failure - unable to get error method ID");
}
- else if (!(encryptedMsgPtr = env->GetStringUTFChars(aEncryptedMsg, 0)))
+ else if (!(encryptedMsgPtr = env->GetByteArrayElements(aEncryptedMsgBuffer, 0)))
{
LOGE(" ## decryptMessageJni(): failure - encrypted message JNI allocation OOM");
}
@@ -235,7 +235,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
else
{
// get encrypted message length
- size_t encryptedMsgLength = (size_t)env->GetStringUTFLength(aEncryptedMsg);
+ size_t encryptedMsgLength = (size_t)env->GetArrayLength(aEncryptedMsgBuffer);
uint8_t *tempEncryptedPtr = static_cast<uint8_t*>(malloc(encryptedMsgLength*sizeof(uint8_t)));
// create a dedicated temp buffer to be used in next Olm API calls
@@ -327,7 +327,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
// free alloc
if (encryptedMsgPtr)
{
- env->ReleaseStringUTFChars(aEncryptedMsg, encryptedMsgPtr);
+ env->ReleaseByteArrayElements(aEncryptedMsgBuffer, encryptedMsgPtr, JNI_ABORT);
}
return decryptedMsgRetValue;
@@ -336,16 +336,16 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
/**
* Serialize and encrypt session instance into a base64 string.<br>
-* @param aKey key used to encrypt the serialized session data
+* @param aKeyBuffer key used to encrypt the serialized session data
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmInboundGroupSession* sessionPtr = NULL;
LOGD("## inbound group session serializeDataWithKeyJni(): IN");
@@ -354,7 +354,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -370,14 +370,14 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_inbound_group_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -421,19 +421,19 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmInboundGroupSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -441,26 +441,26 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -485,12 +485,12 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
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 7060df4..af763f4 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, jstring aSessionKey);
+JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer);
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, jobject aDecryptIndex, jobject aErrorMsg);
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aEncryptedMsg, jobject aDecryptIndex, jobject aErrorMsg);
// serialization
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring 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);
#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 3ee3db7..0ccc6e8 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
@@ -338,13 +338,13 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv
* @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, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmOutboundGroupSession* sessionPtr = NULL;
LOGD("## outbound group session serializeDataWithKeyJni(): IN");
@@ -353,7 +353,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -369,14 +369,14 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_outbound_group_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -418,19 +418,19 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmOutboundGroupSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -438,26 +438,26 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -482,12 +482,12 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
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 f7e8a21..43ec4f7 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 jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env
JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsgBuffer);
// serialization
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+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);
#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 0797ae6..491795f 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
@@ -107,7 +107,7 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thi
* @param aTheirOneTimeKey the one time key of the recipient
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
**/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aTheirOneTimeKey)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aTheirOneTimeKeyBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession* sessionPtr = NULL;
@@ -121,7 +121,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
{
LOGE("## initOutboundSessionJni(): failure - invalid Account ptr=NULL");
}
- else if (!aTheirIdentityKey || !aTheirOneTimeKey)
+ else if (!aTheirIdentityKeyBuffer || !aTheirOneTimeKeyBuffer)
{
LOGE("## initOutboundSessionJni(): failure - invalid keys");
}
@@ -138,22 +138,22 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
}
else
{
- const char* theirIdentityKeyPtr = NULL;
- const char* theirOneTimeKeyPtr = NULL;
+ jbyte* theirIdentityKeyPtr = NULL;
+ jbyte* theirOneTimeKeyPtr = NULL;
// convert identity & one time keys to C strings
- if (!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ if (!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## initOutboundSessionJni(): failure - identityKey JNI allocation OOM");
}
- else if (!(theirOneTimeKeyPtr = env->GetStringUTFChars(aTheirOneTimeKey, 0)))
+ else if (!(theirOneTimeKeyPtr = env->GetByteArrayElements(aTheirOneTimeKeyBuffer, 0)))
{
LOGE("## initOutboundSessionJni(): failure - one time Key JNI allocation OOM");
}
else
{
- size_t theirIdentityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
- size_t theirOneTimeKeyLength = (size_t)env->GetStringUTFLength(aTheirOneTimeKey);
+ size_t theirIdentityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
+ size_t theirOneTimeKeyLength = (size_t)env->GetArrayLength(aTheirOneTimeKeyBuffer);
LOGD("## initOutboundSessionJni(): identityKey=%s oneTimeKey=%s",theirIdentityKeyPtr,theirOneTimeKeyPtr);
size_t sessionResult = olm_create_outbound_session(sessionPtr,
@@ -176,12 +176,12 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
if (theirOneTimeKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirOneTimeKey, theirOneTimeKeyPtr);
+ env->ReleaseByteArrayElements(aTheirOneTimeKeyBuffer, theirOneTimeKeyPtr, JNI_ABORT);
}
if (randomBuffPtr)
@@ -205,7 +205,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
* @param aOneTimeKeyMsg PRE_KEY message
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
@@ -220,13 +220,13 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
{
LOGE("## initInboundSessionJni(): failure - invalid Account ptr=NULL");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## initInboundSessionJni(): failure - invalid message");
}
else
{
- const char *messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0);
+ jbyte* messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0);
if (!messagePtr)
{
@@ -234,7 +234,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
LOGD("## initInboundSessionJni(): messageLength=%lu message=%s", static_cast<long unsigned int>(messageLength), messagePtr);
sessionResult = olm_create_inbound_session(sessionPtr, accountPtr, (void*)messagePtr , messageLength);
@@ -250,7 +250,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
}
// free local alloc
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
}
return retCode;
@@ -264,13 +264,13 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
* @param aOneTimeKeyMsg encrypted message
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
OlmAccount *accountPtr = NULL;
- const char *messagePtr = NULL;
- const char *theirIdentityKeyPtr = NULL;
+ jbyte *messagePtr = NULL;
+ jbyte *theirIdentityKeyPtr = NULL;
size_t sessionResult;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
@@ -281,26 +281,26 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - invalid Account ptr=NULL");
}
- else if (!aTheirIdentityKey)
+ else if (!aTheirIdentityKeyBuffer)
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - invalid theirIdentityKey");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## initInboundSessionJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - message JNI allocation OOM");
}
- else if(!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ else if(!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - theirIdentityKey JNI allocation OOM");
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
- size_t theirIdentityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
+ size_t theirIdentityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
LOGD("## initInboundSessionFromIdKeyJni(): message=%s messageLength=%lu",messagePtr,static_cast<long unsigned int>(messageLength));
@@ -319,12 +319,12 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
// free local alloc
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
return retCode;
@@ -336,27 +336,27 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
* @param aOneTimeKeyMsg PRE KEY message
* @return ERROR_CODE_OK if match, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *messagePtr = NULL;
+ jbyte *messagePtr = NULL;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
{
LOGE("## matchesInboundSessionJni(): failure - invalid Session ptr=NULL");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## matchesInboundSessionJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## matchesInboundSessionJni(): failure - one time key JNI allocation OOM");
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
size_t matchResult = olm_matches_inbound_session(sessionPtr, (void*)messagePtr , messageLength);
//if(matchResult == olm_error()) {
@@ -374,7 +374,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobje
// free local alloc
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
return retCode;
@@ -388,37 +388,37 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobje
* @param aOneTimeKeyMsg PRE KEY message
* @return ERROR_CODE_OK if match, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg)
+JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *messagePtr = NULL;
- const char *theirIdentityKeyPtr = NULL;
+ jbyte *messagePtr = NULL;
+ jbyte *theirIdentityKeyPtr = NULL;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid Session ptr=NULL");
}
- else if (!aTheirIdentityKey)
+ else if (!aTheirIdentityKeyBuffer)
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid theirIdentityKey");
}
- else if (!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ else if (!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - theirIdentityKey JNI allocation OOM");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - one time key JNI allocation OOM");
}
else
{
- size_t identityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t identityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
size_t matchResult = olm_matches_inbound_session_from(sessionPtr, (void const *)theirIdentityKeyPtr, identityKeyLength, (void*)messagePtr , messageLength);
//if(matchResult == olm_error()) {
@@ -437,12 +437,12 @@ JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(J
// free local alloc
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
return retCode;
@@ -455,11 +455,11 @@ JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(J
* @param [out] aEncryptedMsg ciphered message
* @return ERROR_CODE_OK if encrypt operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jstring aClearMsg, jobject aEncryptedMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsgBuffer, jobject aEncryptedMsg)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *clearMsgPtr = NULL;
+ jbyte *clearMsgPtr = NULL;
jclass encryptedMsgJClass = 0;
jfieldID encryptedMsgFieldId;
jfieldID typeMsgFieldId;
@@ -470,7 +470,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
{
LOGE("## encryptMessageJni(): failure - invalid Session ptr=NULL");
}
- else if (!aClearMsg)
+ else if (!aClearMsgBuffer)
{
LOGE("## encryptMessageJni(): failure - invalid clear message");
}
@@ -478,7 +478,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
{
LOGE("## encryptMessageJni(): failure - invalid encrypted message");
}
- else if (!(clearMsgPtr = env->GetStringUTFChars(aClearMsg, 0)))
+ else if (!(clearMsgPtr = env->GetByteArrayElements(aClearMsgBuffer, 0)))
{
LOGE("## encryptMessageJni(): failure - clear message JNI allocation OOM");
}
@@ -514,7 +514,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
else
{
// alloc buffer for encrypted message
- size_t clearMsgLength = (size_t)env->GetStringUTFLength(aClearMsg);
+ size_t clearMsgLength = (size_t)env->GetArrayLength(aClearMsgBuffer);
size_t encryptedMsgLength = olm_encrypt_message_length(sessionPtr, clearMsgLength);
void *encryptedMsgPtr = malloc((encryptedMsgLength+1)*sizeof(uint8_t));
@@ -569,7 +569,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
// free alloc
if (clearMsgPtr)
{
- env->ReleaseStringUTFChars(aClearMsg, clearMsgPtr);
+ env->ReleaseByteArrayElements(aClearMsgBuffer, clearMsgPtr, JNI_ABORT);
}
return retCode;
@@ -760,13 +760,13 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, job
* @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, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmSession* sessionPtr = NULL;
LOGD("## serializeDataWithKeyJni(): IN");
@@ -775,7 +775,7 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -791,14 +791,14 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -840,19 +840,19 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -860,26 +860,26 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ 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);
@@ -905,12 +905,12 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
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 22005d9..b18ac86 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
@@ -33,25 +33,25 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thi
JNIEXPORT jlong OLM_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject thiz);
// outbound session
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aTheirOneTimeKey);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKey, jbyteArray aTheirOneTimeKey);
// inbound sessions: establishment based on PRE KEY message
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aOneTimeKeyMsg);
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKey, jbyteArray aOneTimeKeyMsg);
// match inbound sessions: based on PRE KEY message
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jstring aOneTimeKeyMsg);
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aTheirIdentityKey, jbyteArray aOneTimeKeyMsg);
// encrypt/decrypt
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jstring aClearMsg, jobject aEncryptedMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsg, jobject aEncryptedMsg);
JNIEXPORT jstring OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jobject aEncryptedMsg);
JNIEXPORT jstring OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, jobject thiz);
// serialization
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+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);
#ifdef __cplusplus
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
index 8a7607c..584e83e 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
@@ -85,13 +85,13 @@ JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz
* @param aMessage the message which was signed
* @return 0 if validation succeed, an error message string if operation failed
*/
-JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jstring aSignature, jstring aKey, jstring aMessage)
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jbyteArray aSignatureBuffer, jbyteArray aKeyBuffer, jbyteArray aMessageBuffer)
{
jstring errorMessageRetValue = 0;
OlmUtility* utilityPtr = NULL;
- const char* signaturePtr = NULL;
- const char* keyPtr = NULL;
- const char* messagePtr = NULL;
+ jbyte* signaturePtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* messagePtr = NULL;
LOGD("## verifyEd25519SignatureJni(): IN");
@@ -99,27 +99,27 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, j
{
LOGE(" ## verifyEd25519SignatureJni(): failure - invalid utility ptr=NULL");
}
- else if (!aSignature || !aKey || !aMessage)
+ else if (!aSignatureBuffer || !aKeyBuffer || !aMessageBuffer)
{
LOGE(" ## verifyEd25519SignatureJni(): failure - invalid input parameters ");
}
- else if (!(signaturePtr = env->GetStringUTFChars(aSignature, 0)))
+ else if (!(signaturePtr = env->GetByteArrayElements(aSignatureBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - signature JNI allocation OOM");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - key JNI allocation OOM");
}
- else if (!(messagePtr = env->GetStringUTFChars(aMessage, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aMessageBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - message JNI allocation OOM");
}
else
{
- size_t signatureLength = (size_t)env->GetStringUTFLength(aSignature);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
- size_t messageLength = (size_t)env->GetStringUTFLength(aMessage);
+ size_t signatureLength = (size_t)env->GetArrayLength(aSignatureBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
+ size_t messageLength = (size_t)env->GetArrayLength(aMessageBuffer);
LOGD(" ## verifyEd25519SignatureJni(): signatureLength=%lu keyLength=%lu messageLength=%lu",static_cast<long unsigned int>(signatureLength),static_cast<long unsigned int>(keyLength),static_cast<long unsigned int>(messageLength));
LOGD(" ## verifyEd25519SignatureJni(): key=%s",keyPtr);
@@ -144,17 +144,17 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, j
// free alloc
if (signaturePtr)
{
- env->ReleaseStringUTFChars(aSignature, signaturePtr);
+ env->ReleaseByteArrayElements(aSignatureBuffer, signaturePtr, JNI_ABORT);
}
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (messagePtr)
{
- env->ReleaseStringUTFChars(aMessage, messagePtr);
+ env->ReleaseByteArrayElements(aMessageBuffer, messagePtr, JNI_ABORT);
}
return errorMessageRetValue;
@@ -166,11 +166,11 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, j
* @param aMessage
* @return digest of the message if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jstring aMessageToHash)
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jbyteArray aMessageToHashBuffer)
{
jstring sha256RetValue = 0;
OlmUtility* utilityPtr = NULL;
- const char* messagePtr = NULL;
+ jbyte* messagePtr = NULL;
LOGD("## sha256Jni(): IN");
@@ -178,18 +178,18 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jst
{
LOGE(" ## sha256Jni(): failure - invalid utility ptr=NULL");
}
- else if(!aMessageToHash)
+ else if(!aMessageToHashBuffer)
{
LOGE(" ## sha256Jni(): failure - invalid message parameters ");
}
- else if(!(messagePtr = env->GetStringUTFChars(aMessageToHash, 0)))
+ else if(!(messagePtr = env->GetByteArrayElements(aMessageToHashBuffer, 0)))
{
LOGE(" ## sha256Jni(): failure - message JNI allocation OOM");
}
else
{
// get lengths
- size_t messageLength = (size_t)env->GetStringUTFLength(aMessageToHash);
+ size_t messageLength = (size_t)env->GetArrayLength(aMessageToHashBuffer);
size_t hashLength = olm_sha256_length(utilityPtr);
void* hashValuePtr = malloc((hashLength+1)*sizeof(uint8_t));
@@ -223,7 +223,7 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jst
if (messagePtr)
{
- env->ReleaseStringUTFChars(aMessageToHash, messagePtr);
+ env->ReleaseByteArrayElements(aMessageToHashBuffer, messagePtr, JNI_ABORT);
}
return sha256RetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
index 2a534a3..7c3601d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
@@ -29,8 +29,8 @@ extern "C" {
#endif
JNIEXPORT jlong OLM_UTILITY_FUNC_DEF(initUtilityJni)(JNIEnv *env, jobject thiz);
JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz);
-JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jstring aSignature, jstring aKey, jstring aMessage);
-JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jstring aMessageToHash);
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jbyteArray aSignature, jbyteArray aKey, jbyteArray aMessage);
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jbyteArray aMessageToHash);
#ifdef __cplusplus
}
#endif