diff options
author | ylecollen <ylecollen@amdocs.com> | 2017-01-03 16:12:20 +0100 |
---|---|---|
committer | ylecollen <ylecollen@amdocs.com> | 2017-01-03 16:12:20 +0100 |
commit | 9552e14fdadd9fadbe88970cfb8df7b697c0deb4 (patch) | |
tree | fd955c9b67c06eae88a4e3e8d796e7b2017858da /java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp | |
parent | 765647cda501b53bac990332444aadc4404fe314 (diff) |
-> the byte[] to String conversions are done on Java level (when it is possible)
-> remove javaCStringToUtf8
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp')
-rw-r--r-- | java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
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 584e83e..f4a0c80 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 @@ -166,9 +166,10 @@ 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, jbyteArray aMessageToHashBuffer) +JNIEXPORT jbyteArray OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jbyteArray aMessageToHashBuffer) { - jstring sha256RetValue = 0; + jbyteArray sha256Ret = 0; + OlmUtility* utilityPtr = NULL; jbyte* messagePtr = NULL; @@ -212,9 +213,10 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jby { // update length (static_cast<char*>(hashValuePtr))[result] = static_cast<char>('\0'); - LOGD("## sha256Jni(): success - result=%lu hashValue=%s",static_cast<long unsigned int>(result), (char*)hashValuePtr); - sha256RetValue = env->NewStringUTF((const char*)hashValuePtr); + + sha256Ret = env->NewByteArray(result); + env->SetByteArrayRegion(sha256Ret, 0 , result, (jbyte*)hashValuePtr); } free(hashValuePtr); @@ -226,5 +228,5 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jby env->ReleaseByteArrayElements(aMessageToHashBuffer, messagePtr, JNI_ABORT); } - return sha256RetValue; + return sha256Ret; }
\ No newline at end of file |