Simplify signMessageJni
This commit is contained in:
parent
60bcf865d0
commit
b893b81c82
1 changed files with 50 additions and 49 deletions
|
@ -413,17 +413,18 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
|
|||
else
|
||||
{
|
||||
int messageLength = env->GetArrayLength(aMessage);
|
||||
unsigned char* messageToSign = new unsigned char[messageLength];
|
||||
env->GetByteArrayRegion(aMessage, 0, messageLength, reinterpret_cast<jbyte*>(messageToSign));
|
||||
jbyte* messageToSign = env->GetByteArrayElements(aMessage, NULL);
|
||||
|
||||
// signature memory allocation
|
||||
signatureLength = olm_account_signature_length(accountPtr);
|
||||
|
||||
if(NULL == (signedMsgPtr = (void*)malloc((signatureLength+1)*sizeof(uint8_t))))
|
||||
{
|
||||
LOGE("## signMessageJni(): failure - signature allocation OOM");
|
||||
}
|
||||
else
|
||||
{ // sign message
|
||||
{
|
||||
// sign message
|
||||
resultSign = olm_account_sign(accountPtr,
|
||||
(void*)messageToSign,
|
||||
(size_t)messageLength,
|
||||
|
@ -446,15 +447,15 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
|
|||
}
|
||||
|
||||
// release messageToSign
|
||||
free(messageToSign);
|
||||
if (messageToSign)
|
||||
{
|
||||
env->ReleaseByteArrayElements(aMessage, messageToSign, JNI_ABORT);
|
||||
}
|
||||
}
|
||||
|
||||
return signedMsgRetValue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Serialize and encrypt account instance into a base64 string.<br>
|
||||
* @param aKey key used to encrypt the serialized account data
|
||||
|
|
Loading…
Reference in a new issue