Commit f2ca1ce3 authored by pedroGitt's avatar pedroGitt
Browse files

- Add OlmSession unit test

- Simplify JNI function signatures definition (Account & Session)
parent 67f79394
...@@ -30,9 +30,6 @@ public class OlmAccountTest { ...@@ -30,9 +30,6 @@ public class OlmAccountTest {
private static OlmManager mOlmManager; private static OlmManager mOlmManager;
private boolean mIsAccountCreated; private boolean mIsAccountCreated;
public static final String TEST_STRING = "This is a string";
public static final long TEST_LONG = 12345678L;
@BeforeClass @BeforeClass
public static void setUpClass(){ public static void setUpClass(){
// load native lib // load native lib
...@@ -61,26 +58,35 @@ public class OlmAccountTest { ...@@ -61,26 +58,35 @@ public class OlmAccountTest {
} }
@Test @Test
public void test1CreateAccount() { public void test01CreateReleaseAccount() {
mOlmAccount = new OlmAccount();
assertNotNull(mOlmAccount);
mOlmAccount.releaseAccount();
assertTrue(0 == mOlmAccount.getOlmAccountId());
}
@Test
public void test02CreateAccount() {
mOlmAccount = new OlmAccount(); mOlmAccount = new OlmAccount();
assertNotNull(mOlmAccount); assertNotNull(mOlmAccount);
} }
@Test @Test
public void test2InitNewAccount() { public void test03InitNewAccount() {
assertTrue(mOlmAccount.initNewAccount()); assertTrue(mOlmAccount.initNewAccount());
mIsAccountCreated = true; mIsAccountCreated = true;
} }
@Test @Test
public void test3GetOlmAccountId() { public void test04GetOlmAccountId() {
long olmNativeInstance = mOlmAccount.getOlmAccountId(); long olmNativeInstance = mOlmAccount.getOlmAccountId();
Log.d(LOG_TAG,"## testGetOlmAccountId olmNativeInstance="+olmNativeInstance); Log.d(LOG_TAG,"## testGetOlmAccountId olmNativeInstance="+olmNativeInstance);
assertTrue(0!=olmNativeInstance); assertTrue(0!=olmNativeInstance);
} }
@Test @Test
public void test4IdentityKeys() { public void test05IdentityKeys() {
JSONObject identityKeysJson = mOlmAccount.identityKeys(); JSONObject identityKeysJson = mOlmAccount.identityKeys();
assertNotNull(identityKeysJson); assertNotNull(identityKeysJson);
Log.d(LOG_TAG,"## testIdentityKeys Keys="+identityKeysJson); Log.d(LOG_TAG,"## testIdentityKeys Keys="+identityKeysJson);
...@@ -108,7 +114,7 @@ public class OlmAccountTest { ...@@ -108,7 +114,7 @@ public class OlmAccountTest {
//** ************** One time keys TESTS ************** //** ************** One time keys TESTS **************
//**************************************************** //****************************************************
@Test @Test
public void test5MaxOneTimeKeys() { public void test06MaxOneTimeKeys() {
long maxOneTimeKeys = mOlmAccount.maxOneTimeKeys(); long maxOneTimeKeys = mOlmAccount.maxOneTimeKeys();
Log.d(LOG_TAG,"## testMaxOneTimeKeys(): maxOneTimeKeys="+maxOneTimeKeys); Log.d(LOG_TAG,"## testMaxOneTimeKeys(): maxOneTimeKeys="+maxOneTimeKeys);
...@@ -116,13 +122,13 @@ public class OlmAccountTest { ...@@ -116,13 +122,13 @@ public class OlmAccountTest {
} }
@Test @Test
public void test6GenerateOneTimeKeys() { public void test07GenerateOneTimeKeys() {
int retValue = mOlmAccount.generateOneTimeKeys(GENERATION_ONE_TIME_KEYS_NUMBER); int retValue = mOlmAccount.generateOneTimeKeys(GENERATION_ONE_TIME_KEYS_NUMBER);
assertTrue(0==retValue); assertTrue(0==retValue);
} }
@Test @Test
public void test7OneTimeKeysJsonFormat() { public void test08OneTimeKeysJsonFormat() {
int oneTimeKeysCount = 0; int oneTimeKeysCount = 0;
JSONObject generatedKeysJsonObj; JSONObject generatedKeysJsonObj;
JSONObject oneTimeKeysJson = mOlmAccount.oneTimeKeys(); JSONObject oneTimeKeysJson = mOlmAccount.oneTimeKeys();
...@@ -145,27 +151,31 @@ public class OlmAccountTest { ...@@ -145,27 +151,31 @@ public class OlmAccountTest {
} }
} }
// TODO testRemoveOneTimeKeysForSession when session is available @Test
/*@Test public void test10RemoveOneTimeKeysForSession() {
public void testRemoveOneTimeKeysForSession() { OlmSession olmSession = new OlmSession();
Log.d(LOG_TAG,"## testRemoveOneTimeKeysForSession"); olmSession.initNewSession();
OLMSession olmSession = new OLMSession(); long sessionId = olmSession.getOlmSessionId();
assertTrue(0 != sessionId);
JSONArray keysJsonArray = mOlmAccount.removeOneTimeKeysForSession(olmSession);
int sessionRetCode = mOlmAccount.removeOneTimeKeysForSession(sessionId);
assertNotNull(keysJsonArray); // no one time key has been use in the session, so removeOneTimeKeysForSession() returns an error
// TODO add extra test to test the JSON content format.. assertTrue(0 != sessionRetCode);
}*/
olmSession.releaseSession();
sessionId = olmSession.getOlmSessionId();
assertTrue("sessionRetCode="+sessionRetCode,0 == sessionId);
}
@Test @Test
public void test8MarkOneTimeKeysAsPublished() { public void test11MarkOneTimeKeysAsPublished() {
int retCode = mOlmAccount.markOneTimeKeysAsPublished(); int retCode = mOlmAccount.markOneTimeKeysAsPublished();
// if OK => retCode=0 // if OK => retCode=0
assertTrue(0 == retCode); assertTrue(0 == retCode);
} }
@Test @Test
public void test9SignMessage() { public void test12SignMessage() {
String clearMsg = "String to be signed by olm"; String clearMsg = "String to be signed by olm";
String signedMsg = mOlmAccount.signMessage(clearMsg); String signedMsg = mOlmAccount.signMessage(clearMsg);
assertNotNull(signedMsg); assertNotNull(signedMsg);
...@@ -193,10 +203,8 @@ public class OlmAccountTest { ...@@ -193,10 +203,8 @@ public class OlmAccountTest {
int generateRetCode = account.generateOneTimeKeys(50); int generateRetCode = account.generateOneTimeKeys(50);
Log.d(LOG_TAG, "## testJni(): generateRetCode="+generateRetCode); Log.d(LOG_TAG, "## testJni(): generateRetCode="+generateRetCode);
JSONObject onteTimeKeysKeysJson = account.oneTimeKeys(); JSONObject oneTimeKeysKeysJson = account.oneTimeKeys();
Log.d(LOG_TAG, "## testJni(): onteTimeKeysKeysJson="+onteTimeKeysKeysJson.toString()); Log.d(LOG_TAG, "## testJni(): oneTimeKeysKeysJson="+oneTimeKeysKeysJson.toString());
// TODO removeOneTimeKeysForSession(session);
int asPublishedRetCode = account.markOneTimeKeysAsPublished(); int asPublishedRetCode = account.markOneTimeKeysAsPublished();
Log.d(LOG_TAG, "## testJni(): asPublishedRetCode="+asPublishedRetCode); Log.d(LOG_TAG, "## testJni(): asPublishedRetCode="+asPublishedRetCode);
......
package org.matrix.olm;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.MethodSorters;
import java.util.Iterator;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@RunWith(AndroidJUnit4.class)
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class OlmSessionTest {
private static final String LOG_TAG = "OlmSessionTest";
private static OlmManager mOlmManager;
@BeforeClass
public static void setUpClass(){
// load native lib
mOlmManager = new OlmManager();
String version = mOlmManager.getOlmLibVersion();
assertNotNull(version);
Log.d(LOG_TAG, "## setUpClass(): lib version="+version);
}
@Test
public void test01AliceToBob() {
String bobIdentityKey = null;
String bobOneTimeKey=null;
// creates alice & bob accounts
OlmAccount aliceAccount = new OlmAccount();
aliceAccount.initNewAccount();
OlmAccount bobAccount = new OlmAccount();
bobAccount.initNewAccount();
// test accounts creation
assertTrue(0!=bobAccount.getOlmAccountId());
assertTrue(0!=aliceAccount.getOlmAccountId());
// get bob identity key
JSONObject bobIdentityKeysJson = bobAccount.identityKeys();
assertNotNull(bobIdentityKeysJson);
try {
bobIdentityKey = bobIdentityKeysJson.getString(OlmAccount.JSON_KEY_IDENTITY_KEY);
assertTrue(null!=bobIdentityKey);
} catch (JSONException e) {
assertTrue("Exception MSg="+e.getMessage(), false);
}
// get bob one time keys
assertTrue(0==bobAccount.generateOneTimeKeys(5));
JSONObject bobOneTimeKeysJsonObj = bobAccount.oneTimeKeys();
assertNotNull(bobOneTimeKeysJsonObj);
try {
JSONObject generatedKeys = bobOneTimeKeysJsonObj.getJSONObject(OlmAccount.JSON_KEY_ONE_TIME_KEY);
assertNotNull(OlmAccount.JSON_KEY_ONE_TIME_KEY +" object is missing", generatedKeys);
// test the count of the generated one time keys:
Iterator<String> generatedKeysIt = generatedKeys.keys();
if(generatedKeysIt.hasNext()) {
bobOneTimeKey = generatedKeys.getString(generatedKeysIt.next());
}
assertNotNull(bobOneTimeKey);
} catch (JSONException e) {
assertTrue("Exception MSg="+e.getMessage(), false);
}
// CREATE ALICE SESSION
OlmSession aliceSession = new OlmSession();
aliceSession.initNewSession();
assertTrue(0!=aliceSession.getOlmSessionId());
// CREATE ALICE OUTBOUND SESSION and encrypt message to bob
assertNotNull(aliceSession.initOutboundSessionWithAccount(aliceAccount, bobIdentityKey, bobOneTimeKey));
String clearMsg = "Heloo bob , this is alice!";
OlmMessage encryptedMsgToBob = aliceSession.encryptMessage(clearMsg);
assertNotNull(encryptedMsgToBob);
Log.d(LOG_TAG,"## test01AliceToBob(): encryptedMsg="+encryptedMsgToBob.mCipherText);
// CREATE BOB INBOUND SESSION and decrypt message from alice
OlmSession bobSession = new OlmSession();
bobSession.initNewSession();
assertTrue(0!=bobSession.getOlmSessionId());
assertNotNull(bobSession.initInboundSessionWithAccount(bobAccount, encryptedMsgToBob.mCipherText));
String decryptedMsg = bobSession.decryptMessage(encryptedMsgToBob);
assertNotNull(decryptedMsg);
// MESSAGE COMPARISON: decrypted vs encrypted
assertTrue(clearMsg.equals(decryptedMsg));
// clean objects..
assertTrue(0==bobAccount.removeOneTimeKeysForSession(bobSession.getOlmSessionId()));
bobAccount.releaseAccount();
aliceAccount.releaseAccount();
bobSession.releaseSession();
aliceSession.releaseSession();
}
}
...@@ -29,16 +29,12 @@ public class OlmAccount { ...@@ -29,16 +29,12 @@ public class OlmAccount {
public static final String JSON_KEY_IDENTITY_KEY = "curve25519"; public static final String JSON_KEY_IDENTITY_KEY = "curve25519";
public static final String JSON_KEY_FINGER_PRINT_KEY = "ed25519"; public static final String JSON_KEY_FINGER_PRINT_KEY = "ed25519";
/** instance unique identifier, used in JNI to match the corresponding native class **/
private int mJavaInstanceId;
/** account raw pointer value (OlmAccount*) returned by JNI. /** account raw pointer value (OlmAccount*) returned by JNI.
* this value identifies uniquely the native account instance. * this value identifies uniquely the native account instance.
*/ */
private long mNativeOlmAccountId; private long mNativeOlmAccountId;
public OlmAccount() { public OlmAccount() {
mJavaInstanceId = hashCode();
//initNewAccount(); //initNewAccount();
} }
...@@ -101,8 +97,13 @@ public class OlmAccount { ...@@ -101,8 +97,13 @@ public class OlmAccount {
/** /**
* Return the identity keys (identity & fingerprint keys) in a JSON array.<br> * Return the identity keys (identity & fingerprint keys) in a JSON array.<br>
* Public API for {@link #identityKeysJni()}. * Public API for {@link #identityKeysJni()}.<br>
* @return identity keys in JSON array format if operation succeed, null otherwise * Ex:<tt>
* {
* "curve25519":"Vam++zZPMqDQM6ANKpO/uAl5ViJSHxV9hd+b0/fwRAg",
* "ed25519":"+v8SOlOASFTMrX3MCKBM4iVnYoZ+JIjpNt1fi8Z9O2I"
* }</tt>
* @return identity keys in JSON array if operation succeed, null otherwise
*/ */
public JSONObject identityKeys() { public JSONObject identityKeys() {
JSONObject identityKeysJsonObj = null; JSONObject identityKeysJsonObj = null;
...@@ -150,6 +151,14 @@ public class OlmAccount { ...@@ -150,6 +151,14 @@ public class OlmAccount {
/** /**
* Return the "one time keys" in a JSON array.<br> * Return the "one time keys" in a JSON array.<br>
* The number of "one time keys", is specified by {@link #generateOneTimeKeys(int)}<br> * The number of "one time keys", is specified by {@link #generateOneTimeKeys(int)}<br>
* Ex:<tt>
* { "curve25519":
* {
* "AAAABQ":"qefVZd8qvjOpsFzoKSAdfUnJVkIreyxWFlipCHjSQQg",
* "AAAABA":"/X8szMU+p+lsTnr56wKjaLgjTMQQkCk8EIWEAilZtQ8",
* "AAAAAw":"qxNxxFHzevFntaaPdT0fhhO7tc7pco4+xB/5VRG81hA",
* }
* }</tt><br>
* Public API for {@link #oneTimeKeysJni()}.<br> * Public API for {@link #oneTimeKeysJni()}.<br>
* Note: these keys are to be published on the server. * Note: these keys are to be published on the server.
* @return one time keys in JSON array format if operation succeed, null otherwise * @return one time keys in JSON array format if operation succeed, null otherwise
...@@ -192,9 +201,4 @@ public class OlmAccount { ...@@ -192,9 +201,4 @@ public class OlmAccount {
* @return the signed message if operation succeed, null otherwise * @return the signed message if operation succeed, null otherwise
*/ */
public native String signMessage(String aMessage); public native String signMessage(String aMessage);
@Override
public String toString() {
return super.toString();
}
} }
...@@ -19,11 +19,9 @@ package org.matrix.olm; ...@@ -19,11 +19,9 @@ package org.matrix.olm;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;
public class OlmSession { public class OlmSession {
private static final String LOG_TAG = "OlmSession"; private static final String LOG_TAG = "OlmSession";
/** session raw pointer value (OlmSession*) returned by JNI. /** session raw pointer value (OlmSession*) returned by JNI.
* this value uniquely identifies the native session instance. * this value uniquely identifies the native session instance.
**/ **/
...@@ -44,6 +42,14 @@ public class OlmSession { ...@@ -44,6 +42,14 @@ public class OlmSession {
return mNativeOlmSessionId; return mNativeOlmSessionId;
} }
/**
* Getter on the session ID.
* @return native session ID
*/
public OlmAccount getOlmAccountId(){
return mOlmAccount;
}
/** /**
* Destroy the corresponding OLM session native object.<br> * Destroy the corresponding OLM session native object.<br>
* This method must ALWAYS be called when this JAVA instance * This method must ALWAYS be called when this JAVA instance
...@@ -105,8 +111,9 @@ public class OlmSession { ...@@ -105,8 +111,9 @@ public class OlmSession {
// set the account of this session // set the account of this session
mOlmAccount = aAccount; mOlmAccount = aAccount;
int retCode = initOutboundSessionJni(mOlmAccount.getOlmAccountId(), aTheirIdentityKey, aTheirOneTimeKey); if(0 == initOutboundSessionJni(mOlmAccount.getOlmAccountId(), aTheirIdentityKey, aTheirOneTimeKey)) {
retObj = this; retObj = this;
}
} }
return retObj; return retObj;
...@@ -121,7 +128,7 @@ public class OlmSession { ...@@ -121,7 +128,7 @@ public class OlmSession {
* Public API for {@link #initInboundSessionJni(long, String)}. * Public API for {@link #initInboundSessionJni(long, String)}.
* This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY). * This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY).
* @param aAccount the account to associate with this session * @param aAccount the account to associate with this session
* @param aOneTimeKeyMsg PRE KEY message TODO TBC * @param aOneTimeKeyMsg PRE KEY message
* @return this if operation succeed, null otherwise * @return this if operation succeed, null otherwise
*/ */
public OlmSession initInboundSessionWithAccount(OlmAccount aAccount, String aOneTimeKeyMsg) { public OlmSession initInboundSessionWithAccount(OlmAccount aAccount, String aOneTimeKeyMsg) {
...@@ -227,6 +234,7 @@ public class OlmSession { ...@@ -227,6 +234,7 @@ public class OlmSession {
/** /**
* Encrypt a message using the session.<br> * Encrypt a message using the session.<br>
* The encrypted message is returned in a OlmMessage object.
* Public API for {@link #encryptMessageJni(String, OlmMessage)}. * Public API for {@link #encryptMessageJni(String, OlmMessage)}.
* @param aClearMsg message to encrypted * @param aClearMsg message to encrypted
* @return the encrypted message if operation succeed, null otherwise * @return the encrypted message if operation succeed, null otherwise
...@@ -243,11 +251,12 @@ public class OlmSession { ...@@ -243,11 +251,12 @@ public class OlmSession {
private native int encryptMessageJni(String aClearMsg, OlmMessage aEncryptedMsg); private native int encryptMessageJni(String aClearMsg, OlmMessage aEncryptedMsg);
/**
@Override * Decrypt a message using the session.<br>
public String toString() { * The encrypted message is given as a OlmMessage object.
return super.toString(); * @param aEncryptedMsg message to decrypt
} * @return the decrypted message if operation succeed, null otherwise
*/
public native String decryptMessage(OlmMessage aEncryptedMsg);
} }
...@@ -44,7 +44,7 @@ OlmAccount* initializeAccountMemory() ...@@ -44,7 +44,7 @@ OlmAccount* initializeAccountMemory()
* This method MUST be called when java counter part account instance is done. * This method MUST be called when java counter part account instance is done.
* *
*/ */
JNIEXPORT void JNICALL Java_org_matrix_olm_OlmAccount_releaseAccountJni(JNIEnv *env, jobject thiz) JNIEXPORT void OLM_ACCOUNT_FUNC_DEF(releaseAccountJni)(JNIEnv *env, jobject thiz)
{ {
OlmAccount* accountPtr = NULL; OlmAccount* accountPtr = NULL;
...@@ -55,8 +55,11 @@ JNIEXPORT void JNICALL Java_org_matrix_olm_OlmAccount_releaseAccountJni(JNIEnv * ...@@ -55,8 +55,11 @@ JNIEXPORT void JNICALL Java_org_matrix_olm_OlmAccount_releaseAccountJni(JNIEnv *
LOGE("## releaseAccountJni(): failure - invalid Account ptr=NULL"); LOGE("## releaseAccountJni(): failure - invalid Account ptr=NULL");
} }
else else
{ // even if free(NULL) does not crash, a test is performed for debug purpose {
olm_clear_account(accountPtr);
LOGD("## releaseAccountJni(): IN"); LOGD("## releaseAccountJni(): IN");
// even if free(NULL) does not crash, logs are performed for debug purpose
free(accountPtr); free(accountPtr);
LOGD("## releaseAccountJni(): OUT"); LOGD("## releaseAccountJni(): OUT");
} }
...@@ -68,7 +71,7 @@ JNIEXPORT void JNICALL Java_org_matrix_olm_OlmAccount_releaseAccountJni(JNIEnv * ...@@ -68,7 +71,7 @@ JNIEXPORT void JNICALL Java_org_matrix_olm_OlmAccount_releaseAccountJni(JNIEnv *
* to make the cast (OlmAccount* => jlong) platform independant. * to make the cast (OlmAccount* => jlong) platform independant.
* @return the initialized OlmAccount* instance if init succeed, NULL otherwise * @return the initialized OlmAccount* instance if init succeed, NULL otherwise
**/ **/
JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_initNewAccountJni(JNIEnv *env, jobject thiz) JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(initNewAccountJni)(JNIEnv *env, jobject thiz)
{ {
OlmAccount *accountPtr = NULL; OlmAccount *accountPtr = NULL;
uint8_t *randomBuffPtr = NULL; uint8_t *randomBuffPtr = NULL;
...@@ -120,7 +123,7 @@ JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_initNewAccountJni(JNIEnv ...@@ -120,7 +123,7 @@ JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_initNewAccountJni(JNIEnv
* The keys are returned in the byte array. * The keys are returned in the byte array.
* @return a valid byte array if operation succeed, null otherwise * @return a valid byte array if operation succeed, null otherwise
**/ **/
JNIEXPORT jbyteArray JNICALL Java_org_matrix_olm_OlmAccount_identityKeysJni(JNIEnv *env, jobject thiz) JNIEXPORT jbyteArray OLM_ACCOUNT_FUNC_DEF(identityKeysJni)(JNIEnv *env, jobject thiz)
{ {
OlmAccount* accountPtr = NULL; OlmAccount* accountPtr = NULL;
size_t identityKeysLength; size_t identityKeysLength;
...@@ -175,7 +178,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_matrix_olm_OlmAccount_identityKeysJni(JNIE ...@@ -175,7 +178,7 @@ JNIEXPORT jbyteArray JNICALL Java_org_matrix_olm_OlmAccount_identityKeysJni(JNIE
* Get the maximum number of "one time keys" the account can store. * Get the maximum number of "one time keys" the account can store.
* *
**/ **/
JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_maxOneTimeKeys(JNIEnv *env, jobject thiz) JNIEXPORT jlong OLM_ACCOUNT_FUNC_DEF(maxOneTimeKeys)(JNIEnv *env, jobject thiz)
{ {
OlmAccount* accountPtr = NULL; OlmAccount* accountPtr = NULL;
size_t maxKeys = -1; size_t maxKeys = -1;
...@@ -198,7 +201,7 @@ JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_maxOneTimeKeys(JNIEnv *en ...@@ -198,7 +201,7 @@ JNIEXPORT jlong JNICALL Java_org_matrix_olm_OlmAccount_maxOneTimeKeys(JNIEnv *en
* @param aNumberOfKeys number of keys to generate * @param aNumberOfKeys number of keys to generate
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise * @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
**/ **/
JNIEXPORT jint JNICALL Java_org_matrix_olm_OlmAccount_generateOneTimeKeys(JNIEnv *env, jobject thiz, jint aNumberOfKeys) JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(generateOneTimeKeys)(JNIEnv *env, jobject thiz, jint aNumberOfKeys)
{ {
OlmAccount *accountPtr = NULL; OlmAccount *accountPtr = NULL;
uint8_t *randomBufferPtr = NULL; uint8_t *randomBufferPtr = NULL;
...@@ -206,7 +209,6 @@ JNIEXPORT jint JNICALL Java_org_matrix_olm_OlmAccount_generateOneTimeKeys(JNIEnv ...@@ -206,7 +209,6 @@ JNIEXPORT jint JNICALL Java_org_matrix_olm_OlmAccount_generateOneTimeKeys(JNIEnv
size_t randomLength; size_t randomLength;
size_t result; size_t result;
LOGD("## generateOneTimeKeys(): accountPtr =%p aNumberOfKeys=%d",accountPtr, aNumberOfKeys);
if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz))) if(NULL == (accountPtr = (OlmAccount*)getAccountInstanceId(env,thiz)))
{ {
...@@ -222,7 +224,10 @@ JNIEXPORT jint JNICALL Java_org_matrix_olm_OlmAccount_generateOneTimeKeys(JNIEnv ...@@ -222,7 +224,10 @@ JNIEXPORT jint JNICALL Java_org_matrix_olm_OlmAccount_generateOneTimeKeys(JNIEnv
LOGE("## generateOneTimeKeys(): failure - random buffer init"); LOGE("## generateOneTimeKeys(): failure - random buffer init");
} }
else else
{ // retrieve key pairs in keysBytesPtr {
LOGD("## generateOneTimeKeys(): accountPtr =%p aNumberOfKeys=%d",accountPtr, aNumberOfKeys);
// retrieve key pairs in keysBytesPtr
result = olm_account_generate_one_time_keys(accountPtr, aNumberOfKeys, (void*)randomBufferPtr, randomLength); result = olm_account_generate_one_time_keys(accountPtr, aNumberOfKeys, (void*)randomBufferPtr, randomLength);
if(result == olm_error()) { if(result == olm_error()) {
const char *errorMsgPtr