Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
matrix-org
Olm
Commits
b893b81c
Commit
b893b81c
authored
Jan 02, 2017
by
ylecollen
Browse files
Simplify signMessageJni
parent
60bcf865
Changes
1
Show whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
View file @
b893b81c
...
@@ -413,17 +413,18 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
...
@@ -413,17 +413,18 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
else
else
{
{
int
messageLength
=
env
->
GetArrayLength
(
aMessage
);
int
messageLength
=
env
->
GetArrayLength
(
aMessage
);
unsigned
char
*
messageToSign
=
new
unsigned
char
[
messageLength
];
jbyte
*
messageToSign
=
env
->
GetByteArrayElements
(
aMessage
,
NULL
);
env
->
GetByteArrayRegion
(
aMessage
,
0
,
messageLength
,
reinterpret_cast
<
jbyte
*>
(
messageToSign
));
// signature memory allocation
// signature memory allocation
signatureLength
=
olm_account_signature_length
(
accountPtr
);
signatureLength
=
olm_account_signature_length
(
accountPtr
);
if
(
NULL
==
(
signedMsgPtr
=
(
void
*
)
malloc
((
signatureLength
+
1
)
*
sizeof
(
uint8_t
))))
if
(
NULL
==
(
signedMsgPtr
=
(
void
*
)
malloc
((
signatureLength
+
1
)
*
sizeof
(
uint8_t
))))
{
{
LOGE
(
"## signMessageJni(): failure - signature allocation OOM"
);
LOGE
(
"## signMessageJni(): failure - signature allocation OOM"
);
}
}
else
else
{
// sign message
{
// sign message
resultSign
=
olm_account_sign
(
accountPtr
,
resultSign
=
olm_account_sign
(
accountPtr
,
(
void
*
)
messageToSign
,
(
void
*
)
messageToSign
,
(
size_t
)
messageLength
,
(
size_t
)
messageLength
,
...
@@ -446,15 +447,15 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
...
@@ -446,15 +447,15 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
}
}
// release messageToSign
// release messageToSign
free
(
messageToSign
);
if
(
messageToSign
)
{
env
->
ReleaseByteArrayElements
(
aMessage
,
messageToSign
,
JNI_ABORT
);
}
}
}
return
signedMsgRetValue
;
return
signedMsgRetValue
;
}
}
/**
/**
* Serialize and encrypt account instance into a base64 string.<br>
* Serialize and encrypt account instance into a base64 string.<br>
* @param aKey key used to encrypt the serialized account data
* @param aKey key used to encrypt the serialized account data
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment