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
2e77e395
Commit
2e77e395
authored
Dec 21, 2016
by
ylecollen
Browse files
move getOlmLibVersionJni
parent
ffb40326
Changes
5
Hide whitespace changes
Inline
Side-by-side
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
View file @
2e77e395
...
...
@@ -113,7 +113,7 @@ JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thi
// create account
accountRetCode
=
olm_create_account
(
accountPtr
,
(
void
*
)
randomBuffPtr
,
randomSize
);
if
(
accountRetCode
==
olm_error
())
{
LOGE
(
"## initNewAccount(): failure - account creation failed Msg=%s"
,
(
const
char
*
)
olm_account_last_error
(
accountPtr
));
LOGE
(
"## initNewAccount(): failure - account creation failed Msg=%s"
,
olm_account_last_error
(
accountPtr
));
}
LOGD
(
"## initNewAccount(): success - OLM account created"
);
...
...
@@ -147,16 +147,16 @@ JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject
size_t
keysResult
;
jbyteArray
byteArrayRetValue
=
NULL
;
LOGD
(
"## identityKeys(): accountPtr =%p"
,
accountPtr
);
if
(
NULL
==
(
accountPtr
=
(
OlmAccount
*
)
getAccountInstanceId
(
env
,
thiz
)))
{
LOGE
(
"## identityKeys(): failure - invalid Account ptr=NULL"
);
}
else
{
// identity keys allocation
{
LOGD
(
"## identityKeys(): accountPtr =%p"
,
accountPtr
);
// identity keys allocation
identityKeysLength
=
olm_account_identity_keys_length
(
accountPtr
);
if
(
NULL
==
(
identityKeysBytesPtr
=
(
uint8_t
*
)
malloc
(
identityKeysLength
*
sizeof
(
uint8_t
)
)))
if
(
NULL
==
(
identityKeysBytesPtr
=
(
uint8_t
*
)
malloc
(
identityKeysLength
)))
{
LOGE
(
"## identityKeys(): failure - identity keys array OOM"
);
}
...
...
@@ -459,20 +459,7 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
}
JNIEXPORT
jstring
OLM_MANAGER_FUNC_DEF
(
getOlmLibVersionJni
)(
JNIEnv
*
env
,
jobject
thiz
)
{
uint8_t
majorVer
=
0
,
minorVer
=
0
,
patchVer
=
0
;
jstring
returnValueStr
=
0
;
char
buff
[
150
];
olm_get_library_version
(
&
majorVer
,
&
minorVer
,
&
patchVer
);
LOGD
(
"## getOlmLibVersionJni(): Major=%d Minor=%d Patch=%d"
,
majorVer
,
minorVer
,
patchVer
);
snprintf
(
buff
,
sizeof
(
buff
),
"%d.%d.%d"
,
majorVer
,
minorVer
,
patchVer
);
returnValueStr
=
env
->
NewStringUTF
((
const
char
*
)
buff
);
return
returnValueStr
;
}
/**
* Serialize and encrypt account instance into a base64 string.<br>
...
...
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h
View file @
2e77e395
...
...
@@ -27,8 +27,6 @@
extern
"C"
{
#endif
JNIEXPORT
jstring
OLM_MANAGER_FUNC_DEF
(
getOlmLibVersionJni
)(
JNIEnv
*
env
,
jobject
thiz
);
// account creation/destruction
JNIEXPORT
void
OLM_ACCOUNT_FUNC_DEF
(
releaseAccountJni
)(
JNIEnv
*
env
,
jobject
thiz
);
JNIEXPORT
jlong
OLM_ACCOUNT_FUNC_DEF
(
initNewAccountJni
)(
JNIEnv
*
env
,
jobject
thiz
);
...
...
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_jni_helper.cpp
View file @
2e77e395
...
...
@@ -32,7 +32,6 @@ using namespace AndroidOlmSdk;
bool
setRandomInBuffer
(
JNIEnv
*
env
,
uint8_t
**
aBuffer2Ptr
,
size_t
aRandomSize
)
{
bool
retCode
=
false
;
struct
timeval
timeValue
;
int
bufferLen
=
aRandomSize
*
sizeof
(
uint8_t
);
if
(
NULL
==
aBuffer2Ptr
)
...
...
@@ -98,7 +97,7 @@ bool setRandomInBuffer(JNIEnv *env, uint8_t **aBuffer2Ptr, size_t aRandomSize)
if
(
!
secureRandomSucceeds
)
{
LOGE
(
"## setRandomInBuffer(): SecureRandom failed, use a fallback"
);
struct
timeval
timeValue
;
gettimeofday
(
&
timeValue
,
NULL
);
srand
(
timeValue
.
tv_usec
);
// init seed
...
...
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp
View file @
2e77e395
...
...
@@ -36,6 +36,20 @@ OlmUtility* initializeUtilityMemory()
return
utilityPtr
;
}
JNIEXPORT
jstring
OLM_UTILITY_FUNC_DEF
(
getOlmLibVersionJni
)(
JNIEnv
*
env
,
jobject
thiz
)
{
uint8_t
majorVer
=
0
,
minorVer
=
0
,
patchVer
=
0
;
jstring
returnValueStr
=
0
;
char
buff
[
150
];
olm_get_library_version
(
&
majorVer
,
&
minorVer
,
&
patchVer
);
LOGD
(
"## getOlmLibVersionJni(): Major=%d Minor=%d Patch=%d"
,
majorVer
,
minorVer
,
patchVer
);
snprintf
(
buff
,
sizeof
(
buff
),
"%d.%d.%d"
,
majorVer
,
minorVer
,
patchVer
);
returnValueStr
=
env
->
NewStringUTF
((
const
char
*
)
buff
);
return
returnValueStr
;
}
JNIEXPORT
jlong
OLM_UTILITY_FUNC_DEF
(
initUtilityJni
)(
JNIEnv
*
env
,
jobject
thiz
)
{
...
...
java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
View file @
2e77e395
...
...
@@ -26,8 +26,10 @@
#ifdef __cplusplus
extern
"C"
{
#endif
JNIEXPORT
jlong
OLM_UTILITY_FUNC_DEF
(
initUtilityJni
)(
JNIEnv
*
env
,
jobject
thiz
);
JNIEXPORT
jstring
OLM_UTILITY_FUNC_DEF
(
getOlmLibVersionJni
)(
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
);
...
...
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