aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorylecollen <ylecollen@amdocs.com>2017-01-03 14:14:56 +0100
committerylecollen <ylecollen@amdocs.com>2017-01-03 14:14:56 +0100
commit765647cda501b53bac990332444aadc4404fe314 (patch)
treed395c297cad84907bda9e5e63c291702f2911a8f
parentde962ef8d7f0dd447274dc88d9630caa6614379b (diff)
There is more GetStringUTFChars call.
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java30
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java44
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java28
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java94
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java32
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp36
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h4
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp62
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h8
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp34
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h4
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp132
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h16
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.cpp40
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h4
15 files changed, 322 insertions, 246 deletions
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
index 2d91634..5c1ad3c 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmAccount.java
@@ -117,12 +117,17 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
aErrorMsg.append("Invalid input parameters in serializeDataWithKey()");
} else {
aErrorMsg.setLength(0);
- pickleRetValue = serializeDataWithKeyJni(aKey, aErrorMsg);
+ try {
+ pickleRetValue = serializeDataWithKeyJni(aKey.getBytes("UTF-8"), aErrorMsg);
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## serializeDataWithKey() failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
+ }
}
return pickleRetValue;
}
- private native String serializeDataWithKeyJni(String aKey, StringBuffer aErrorMsg);
+ private native String serializeDataWithKeyJni(byte[] aKey, StringBuffer aErrorMsg);
/**
@@ -138,23 +143,28 @@ public class OlmAccount extends CommonSerializeUtils implements Serializable {
boolean retCode = false;
String jniError;
- if(null == aErrorMsg) {
+ if (null == aErrorMsg) {
Log.e(LOG_TAG, "## initWithSerializedData(): invalid input error parameter");
} else {
aErrorMsg.setLength(0);
- if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
- Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
- } else if (null == (jniError = initWithSerializedDataJni(aSerializedData, aKey))) {
- retCode = true;
- } else {
- aErrorMsg.append(jniError);
+ try {
+ if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
+ } else if (null == (jniError = initWithSerializedDataJni(aSerializedData.getBytes("UTF-8"), aKey.getBytes("UTF-8")))) {
+ retCode = true;
+ } else {
+ aErrorMsg.append(jniError);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initWithSerializedData() failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
}
}
return retCode;
}
- private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+ private native String initWithSerializedDataJni(byte[] aSerializedDataBuffer, byte[] aKeyBuffer);
/**
* Getter on the account ID.
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
index 61d0ec6..7ec5b2f 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmInboundGroupSession.java
@@ -127,12 +127,16 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
if(TextUtils.isEmpty(aSessionKey)){
Log.e(LOG_TAG, "## initInboundGroupSessionWithSessionKey(): invalid session key");
} else {
- retCode = initInboundGroupSessionWithSessionKeyJni(aSessionKey);
+ try {
+ retCode = initInboundGroupSessionWithSessionKeyJni(aSessionKey.getBytes("UTF-8"));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initInboundGroupSessionWithSessionKey() failed " + e.getMessage());
+ }
}
return retCode;
}
- private native int initInboundGroupSessionWithSessionKeyJni(String aSessionKey);
+ private native int initInboundGroupSessionWithSessionKeyJni(byte[] aSessionKeyBuffer);
/**
@@ -156,7 +160,11 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
DecryptMessageResult result = new DecryptMessageResult();
StringBuffer errorMsg = new StringBuffer();
- result.mDecryptedMessage = decryptMessageJni(aEncryptedMsg, result, errorMsg);
+ try {
+ result.mDecryptedMessage = decryptMessageJni(aEncryptedMsg.getBytes("UTF-8"), result, errorMsg);
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## decryptMessage() failed " + e.getMessage());
+ }
// check if there is an error while decrypting
if (0 != errorMsg.length()) {
@@ -166,7 +174,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
return result;
}
- private native String decryptMessageJni(String aEncryptedMsg, DecryptMessageResult aDecryptMessageResult, StringBuffer aErrorMsg);
+ private native String decryptMessageJni(byte[] aEncryptedMsg, DecryptMessageResult aDecryptMessageResult, StringBuffer aErrorMsg);
/**
* Kick off the serialization mechanism.
@@ -217,7 +225,11 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
aErrorMsg.append("Invalid input parameters in serializeDataWithKey()");
} else {
aErrorMsg.setLength(0);
- pickleRetValue = serializeDataWithKeyJni(aKey, aErrorMsg);
+ try {
+ pickleRetValue = serializeDataWithKeyJni(aKey.getBytes("UTF-8"), aErrorMsg);
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## serializeDataWithKey() failed " + e.getMessage());
+ }
}
return pickleRetValue;
@@ -228,7 +240,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
* @param aErrorMsg error message description
* @return pickled base64 string if operation succeed, null otherwise
*/
- private native String serializeDataWithKeyJni(String aKey, StringBuffer aErrorMsg);
+ private native String serializeDataWithKeyJni(byte[] aKey, StringBuffer aErrorMsg);
/**
@@ -248,13 +260,17 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
Log.e(LOG_TAG, "## initWithSerializedData(): invalid input error parameter");
} else {
aErrorMsg.setLength(0);
-
- if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
- Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
- } else if (null == (jniError = initWithSerializedDataJni(aSerializedData, aKey))) {
- retCode = true;
- } else {
- aErrorMsg.append(jniError);
+ try {
+ if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
+ } else if (null == (jniError = initWithSerializedDataJni(aSerializedData.getBytes("UTF-8"), aKey.getBytes("UTF-8")))) {
+ retCode = true;
+ } else {
+ aErrorMsg.append(jniError);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initWithSerializedData() failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
}
}
@@ -266,7 +282,7 @@ public class OlmInboundGroupSession extends CommonSerializeUtils implements Seri
* @param aKey key used to encrypted in {@link #serializeDataWithKey(String, StringBuffer)}
* @return null if operation succeed, an error message if operation failed
*/
- private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+ private native String initWithSerializedDataJni(byte[] aSerializedData, byte[] aKey);
/**
* Return true the object resources have been released.<br>
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
index 7278d0f..bfb2cd1 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmOutboundGroupSession.java
@@ -109,12 +109,17 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
aErrorMsg.append("Invalid input parameters in serializeDataWithKey()");
} else {
aErrorMsg.setLength(0);
- pickleRetValue = serializeDataWithKeyJni(aKey, aErrorMsg);
+ try {
+ pickleRetValue = serializeDataWithKeyJni(aKey.getBytes("UTF-8"), aErrorMsg);
+ } catch (Exception e) {
+ Log.e(LOG_TAG,"## serializeDataWithKey(): failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
+ }
}
return pickleRetValue;
}
- private native String serializeDataWithKeyJni(String aKey, StringBuffer aErrorMsg);
+ private native String serializeDataWithKeyJni(byte[] aKey, StringBuffer aErrorMsg);
/**
@@ -135,18 +140,23 @@ public class OlmOutboundGroupSession extends CommonSerializeUtils implements Ser
} else {
aErrorMsg.setLength(0);
- if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
- Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
- } else if (null == (jniError = initWithSerializedDataJni(aSerializedData, aKey))) {
- retCode = true;
- } else {
- aErrorMsg.append(jniError);
+ try {
+ if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
+ } else if (null == (jniError = initWithSerializedDataJni(aSerializedData.getBytes("UTF-8"), aKey.getBytes("UTF-8")))) {
+ retCode = true;
+ } else {
+ aErrorMsg.append(jniError);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
}
}
return retCode;
}
- private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+ private native String initWithSerializedDataJni(byte[] aSerializedData, byte[] aKey);
/**
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
index faf092e..7b9b736 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmSession.java
@@ -97,12 +97,17 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
aErrorMsg.append("Invalid input parameters in serializeDataWithKey()");
} else {
aErrorMsg.setLength(0);
- pickleRetValue = serializeDataWithKeyJni(aKey, aErrorMsg);
+ try {
+ pickleRetValue = serializeDataWithKeyJni(aKey.getBytes("UTF-8"), aErrorMsg);
+ } catch (Exception e) {
+ Log.e(LOG_TAG,"## serializeDataWithKey(): failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
+ }
}
return pickleRetValue;
}
- private native String serializeDataWithKeyJni(String aKey, StringBuffer aErrorMsg);
+ private native String serializeDataWithKeyJni(byte[] aKey, StringBuffer aErrorMsg);
/**
@@ -123,18 +128,23 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
} else {
aErrorMsg.setLength(0);
- if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
- Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
- } else if (null == (jniError = initWithSerializedDataJni(aSerializedData, aKey))) {
- retCode = true;
- } else {
- aErrorMsg.append(jniError);
+ try {
+ if (TextUtils.isEmpty(aSerializedData) || TextUtils.isEmpty(aKey)) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): invalid input parameters");
+ } else if (null == (jniError = initWithSerializedDataJni(aSerializedData.getBytes("UTF-8"), aKey.getBytes("UTF-8")))) {
+ retCode = true;
+ } else {
+ aErrorMsg.append(jniError);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initWithSerializedData(): failed " + e.getMessage());
+ aErrorMsg.append(e.getMessage());
}
}
return retCode;
}
- private native String initWithSerializedDataJni(String aSerializedData, String aKey);
+ private native String initWithSerializedDataJni(byte[] aSerializedData, byte[] aKey);
/**
* Getter on the session ID.
@@ -215,43 +225,50 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
if((null==aAccount) || TextUtils.isEmpty(aTheirIdentityKey) || TextUtils.isEmpty(aTheirOneTimeKey)){
Log.e(LOG_TAG, "## initOutboundSession(): invalid input parameters");
} else {
- retCode = initOutboundSessionJni(aAccount.getOlmAccountId(), aTheirIdentityKey, aTheirOneTimeKey);
+ try {
+ retCode = initOutboundSessionJni(aAccount.getOlmAccountId(), aTheirIdentityKey.getBytes("UTF-8"), aTheirOneTimeKey.getBytes("UTF-8"));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initOutboundSessionWithAccount(): " + e.getMessage());
+ }
}
return retCode;
}
- private native int initOutboundSessionJni(long aOlmAccountId, String aTheirIdentityKey, String aTheirOneTimeKey);
-
+ private native int initOutboundSessionJni(long aOlmAccountId, byte[] aTheirIdentityKey, byte[] aTheirOneTimeKey);
/**
* Create a new in-bound session for sending/receiving messages from an
* incoming PRE_KEY message ({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}).<br>
- * Public API for {@link #initInboundSessionJni(long, String)}.
+ * Public API for {@link #initInboundSessionJni(long, byte[])}.
* 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 aPreKeyMsg PRE KEY message
* @return 0 if operation succeed, -1 otherwise
*/
public int initInboundSessionWithAccount(OlmAccount aAccount, String aPreKeyMsg) {
- int retCode=-1;
+ int retCode = -1;
- if((null==aAccount) || TextUtils.isEmpty(aPreKeyMsg)){
+ if ((null == aAccount) || TextUtils.isEmpty(aPreKeyMsg)){
Log.e(LOG_TAG, "## initInboundSessionWithAccount(): invalid input parameters");
} else {
- retCode = initInboundSessionJni(aAccount.getOlmAccountId(), aPreKeyMsg);
+ try {
+ retCode = initInboundSessionJni(aAccount.getOlmAccountId(), aPreKeyMsg.getBytes("UTF-8"));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initInboundSessionWithAccount(): " + e.getMessage());
+ }
}
return retCode;
}
- private native int initInboundSessionJni(long aOlmAccountId, String aOneTimeKeyMsg);
+ private native int initInboundSessionJni(long aOlmAccountId, byte[] aOneTimeKeyMsg);
/**
* Create a new in-bound session for sending/receiving messages from an
* incoming PRE_KEY({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}) message based on the sender identity key.<br>
- * Public API for {@link #initInboundSessionFromIdKeyJni(long, String, String)}.
+ * Public API for {@link #initInboundSessionFromIdKeyJni(long, byte[], byte[])}.
* This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY).
* This method must only be called the first time a pre-key message is received from an inbound session.
* @param aAccount the account to associate with this session
@@ -265,13 +282,17 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
if((null==aAccount) || TextUtils.isEmpty(aPreKeyMsg)){
Log.e(LOG_TAG, "## initInboundSessionWithAccount(): invalid input parameters");
} else {
- retCode = initInboundSessionFromIdKeyJni(aAccount.getOlmAccountId(), aTheirIdentityKey, aPreKeyMsg);
+ try {
+ retCode = initInboundSessionFromIdKeyJni(aAccount.getOlmAccountId(), aTheirIdentityKey.getBytes("UTF-8"), aPreKeyMsg.getBytes("UTF-8"));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## initInboundSessionWithAccountFrom(): " + e.getMessage());
+ }
}
return retCode;
}
- private native int initInboundSessionFromIdKeyJni(long aOlmAccountId, String aTheirIdentityKey, String aOneTimeKeyMsg);
+ private native int initInboundSessionFromIdKeyJni(long aOlmAccountId, byte[] aTheirIdentityKey, byte[] aOneTimeKeyMsg);
/**
* Get the session identifier.<br> Will be the same for both ends of the
@@ -289,26 +310,29 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
/**
* Checks if the PRE_KEY({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}) message is for this in-bound session.<br>
* This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY).
- * Public API for {@link #matchesInboundSessionJni(String)}.
+ * Public API for {@link #matchesInboundSessionJni(byte[])}.
* @param aOneTimeKeyMsg PRE KEY message
* @return this if operation succeed, null otherwise
*/
public boolean matchesInboundSession(String aOneTimeKeyMsg) {
boolean retCode = false;
- if(0 == matchesInboundSessionJni(aOneTimeKeyMsg)){
- retCode = true;
+ try {
+ retCode = (0 == matchesInboundSessionJni(aOneTimeKeyMsg.getBytes("UTF-8")));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## matchesInboundSession(): failed " + e.getMessage());
}
+
return retCode;
}
- private native int matchesInboundSessionJni(String aOneTimeKeyMsg);
+ private native int matchesInboundSessionJni(byte[] aOneTimeKeyMsg);
/**
* Checks if the PRE_KEY({@link OlmMessage#MESSAGE_TYPE_PRE_KEY}) message is for this in-bound session based on the sender identity key.<br>
* This API may be used to process a "m.room.encrypted" event when type = 1 (PRE_KEY).
- * Public API for {@link #matchesInboundSessionJni(String)}.
+ * Public API for {@link #matchesInboundSessionJni(byte[])}.
* @param aTheirIdentityKey the sender identity key
* @param aOneTimeKeyMsg PRE KEY message
* @return this if operation succeed, null otherwise
@@ -316,33 +340,41 @@ public class OlmSession extends CommonSerializeUtils implements Serializable {
public boolean matchesInboundSessionFrom(String aTheirIdentityKey, String aOneTimeKeyMsg) {
boolean retCode = false;
- if(0 == matchesInboundSessionFromIdKeyJni(aTheirIdentityKey, aOneTimeKeyMsg)){
- retCode = true;
+ try {
+ retCode = (0 == matchesInboundSessionFromIdKeyJni(aTheirIdentityKey.getBytes("UTF-8"), aOneTimeKeyMsg.getBytes("UTF-8")));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## matchesInboundSessionFrom(): failed " + e.getMessage());
}
+
return retCode;
}
- private native int matchesInboundSessionFromIdKeyJni(String aTheirIdentityKey, String aOneTimeKeyMsg);
+ private native int matchesInboundSessionFromIdKeyJni(byte[] aTheirIdentityKey, byte[] aOneTimeKeyMsg);
/**
* 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(byte[], OlmMessage)}.
* @param aClearMsg message to encrypted
* @return the encrypted message if operation succeed, null otherwise
*/
public OlmMessage encryptMessage(String aClearMsg) {
OlmMessage encryptedMsgRetValue = new OlmMessage();
- if (0 != encryptMessageJni(aClearMsg, encryptedMsgRetValue)){
+ try {
+ if (0 != encryptMessageJni(aClearMsg.getBytes("UTF-8"), encryptedMsgRetValue)) {
+ encryptedMsgRetValue = null;
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## encryptMessage(): failed " + e.getMessage());
encryptedMsgRetValue = null;
}
return encryptedMsgRetValue;
}
- private native int encryptMessageJni(String aClearMsg, OlmMessage aEncryptedMsg);
+ private native int encryptMessageJni(byte[] aClearMsg, OlmMessage aEncryptedMsg);
/**
* Decrypt a message using the session.<br>
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
index 8db9dca..3d9d99d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java
@@ -82,13 +82,17 @@ public class OlmUtility {
} else {
aError.setLength(0);
- if (TextUtils.isEmpty(aSignature) || TextUtils.isEmpty(aFingerprintKey) || TextUtils.isEmpty(aMessage)) {
- Log.e(LOG_TAG, "## verifyEd25519Signature(): invalid input parameters");
- aError.append("JAVA sanity check failure - invalid input parameters");
- } else if (null == (jniError = verifyEd25519SignatureJni(aSignature, aFingerprintKey, aMessage))) {
- retCode = true;
- } else {
- aError.append(jniError);
+ try {
+ if (TextUtils.isEmpty(aSignature) || TextUtils.isEmpty(aFingerprintKey) || TextUtils.isEmpty(aMessage)) {
+ Log.e(LOG_TAG, "## verifyEd25519Signature(): invalid input parameters");
+ aError.append("JAVA sanity check failure - invalid input parameters");
+ } else if (null == (jniError = verifyEd25519SignatureJni(aSignature.getBytes("UTF-8"), aFingerprintKey.getBytes("UTF-8"), aMessage.getBytes("UTF-8")))) {
+ retCode = true;
+ } else {
+ aError.append(jniError);
+ }
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## verifyEd25519Signature(): failed " + e.getMessage());
}
}
@@ -103,7 +107,7 @@ public class OlmUtility {
* @param aMessage the signed message
* @return null if validation succeed, the error message string if operation failed
*/
- private native String verifyEd25519SignatureJni(String aSignature, String aFingerprintKey, String aMessage);
+ private native String verifyEd25519SignatureJni(byte[] aSignature, byte[] aFingerprintKey, byte[] aMessage);
/**
@@ -115,14 +119,18 @@ public class OlmUtility {
public String sha256(String aMessageToHash) {
String hashRetValue = null;
- if(null != aMessageToHash){
- hashRetValue = sha256Jni(aMessageToHash);
+ if (null != aMessageToHash) {
+ try {
+ hashRetValue = sha256Jni(aMessageToHash.getBytes("UTF-8"));
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "## sha256(): failed " + e.getMessage());
+ }
}
return hashRetValue;
-
}
- private native String sha256Jni(String aMessage);
+
+ private native String sha256Jni(byte[] aMessage);
/**
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
index a44d9db..87ed86a 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.cpp
@@ -468,22 +468,22 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz
/**
* Serialize and encrypt account instance into a base64 string.<br>
-* @param aKey key used to encrypt the serialized account data
+* @param aKeyBuffer key used to encrypt the serialized account data
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmAccount* accountPtr = NULL;
LOGD("## serializeDataWithKeyJni(): IN");
- if (!aKey)
+ if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -503,14 +503,14 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, NULL)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_account_length(accountPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
@@ -552,27 +552,27 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmAccount* accountPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
- if (!aKey)
+ if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
@@ -580,18 +580,18 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
{
LOGE(" ## initWithSerializedDataJni(): failure - account failure OOM");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
@@ -616,12 +616,12 @@ JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h
index 7e09403..88ef215 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_account.h
@@ -47,8 +47,8 @@ JNIEXPORT jint OLM_ACCOUNT_FUNC_DEF(markOneTimeKeysAsPublishedJni)(JNIEnv *env,
JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(signMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aMessage);
// serialization
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg);
+JNIEXPORT jstring OLM_ACCOUNT_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer);
#ifdef __cplusplus
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
index 8a56a12..9eba3af 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.cpp
@@ -86,11 +86,11 @@ JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *
* @param aSessionKey session key from an outbound session
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jstring aSessionKey)
+JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmInboundGroupSession *sessionPtr = NULL;
- const uint8_t *sessionKeyPtr = NULL;
+ jbyte* sessionKeyPtr = NULL;
size_t sessionResult;
LOGD("## initInboundGroupSessionWithSessionKeyJni(): inbound group session IN");
@@ -99,20 +99,20 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
{
LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid inbound group session instance");
}
- else if (!aSessionKey)
+ else if (!aSessionKeyBuffer)
{
LOGE(" ## initInboundGroupSessionWithSessionKeyJni(): failure - invalid aSessionKey");
}
- else if (!(sessionKeyPtr = (const uint8_t *)env->GetStringUTFChars(aSessionKey, 0)))
+ else if (!(sessionKeyPtr = env->GetByteArrayElements(aSessionKeyBuffer, 0)))
{
LOGE(" ## initInboundSessionFromIdKeyJni(): failure - session key JNI allocation OOM");
}
else
{
- size_t sessionKeyLength = (size_t)env->GetStringUTFLength(aSessionKey);
+ size_t sessionKeyLength = (size_t)env->GetArrayLength(aSessionKeyBuffer);
LOGD(" ## initInboundSessionFromIdKeyJni(): sessionKeyLength=%lu",static_cast<long unsigned int>(sessionKeyLength));
- sessionResult = olm_init_inbound_group_session(sessionPtr, sessionKeyPtr, sessionKeyLength);
+ sessionResult = olm_init_inbound_group_session(sessionPtr, (const uint8_t*)sessionKeyPtr, sessionKeyLength);
if (sessionResult == olm_error()) {
const char *errorMsgPtr = olm_inbound_group_session_last_error(sessionPtr);
LOGE(" ## initInboundSessionFromIdKeyJni(): failure - init inbound session creation Msg=%s",errorMsgPtr);
@@ -127,7 +127,7 @@ JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSes
// free local alloc
if (sessionKeyPtr)
{
- env->ReleaseStringUTFChars(aSessionKey, (const char*)sessionKeyPtr);
+ env->ReleaseByteArrayElements(aSessionKeyBuffer, sessionKeyPtr, JNI_ABORT);
}
return retCode;
@@ -183,11 +183,11 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEn
}
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jobject aDecryptionResult, jobject aErrorMsg)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aEncryptedMsgBuffer, jobject aDecryptionResult, jobject aErrorMsg)
{
jstring decryptedMsgRetValue = 0;
OlmInboundGroupSession *sessionPtr = NULL;
- const char *encryptedMsgPtr = NULL;
+ jbyte *encryptedMsgPtr = NULL;
jclass indexObjJClass = 0;
jfieldID indexMsgFieldId;
jclass errorMsgJClass = 0;
@@ -200,7 +200,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
{
LOGE(" ## decryptMessageJni(): failure - invalid inbound group session ptr=NULL");
}
- else if (!aEncryptedMsg)
+ else if (!aEncryptedMsgBuffer)
{
LOGE(" ## decryptMessageJni(): failure - invalid encrypted message");
}
@@ -220,7 +220,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
{
LOGE(" ## decryptMessageJni(): failure - unable to get error method ID");
}
- else if (!(encryptedMsgPtr = env->GetStringUTFChars(aEncryptedMsg, 0)))
+ else if (!(encryptedMsgPtr = env->GetByteArrayElements(aEncryptedMsgBuffer, 0)))
{
LOGE(" ## decryptMessageJni(): failure - encrypted message JNI allocation OOM");
}
@@ -235,7 +235,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
else
{
// get encrypted message length
- size_t encryptedMsgLength = (size_t)env->GetStringUTFLength(aEncryptedMsg);
+ size_t encryptedMsgLength = (size_t)env->GetArrayLength(aEncryptedMsgBuffer);
uint8_t *tempEncryptedPtr = static_cast<uint8_t*>(malloc(encryptedMsgLength*sizeof(uint8_t)));
// create a dedicated temp buffer to be used in next Olm API calls
@@ -327,7 +327,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
// free alloc
if (encryptedMsgPtr)
{
- env->ReleaseStringUTFChars(aEncryptedMsg, encryptedMsgPtr);
+ env->ReleaseByteArrayElements(aEncryptedMsgBuffer, encryptedMsgPtr, JNI_ABORT);
}
return decryptedMsgRetValue;
@@ -336,16 +336,16 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *
/**
* Serialize and encrypt session instance into a base64 string.<br>
-* @param aKey key used to encrypt the serialized session data
+* @param aKeyBuffer key used to encrypt the serialized session data
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmInboundGroupSession* sessionPtr = NULL;
LOGD("## inbound group session serializeDataWithKeyJni(): IN");
@@ -354,7 +354,7 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -370,14 +370,14 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_inbound_group_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu", static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
@@ -421,19 +421,19 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JN
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmInboundGroupSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -441,26 +441,26 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
@@ -485,12 +485,12 @@ JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
index 7060df4..af763f4 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_inbound_group_session.h
@@ -32,13 +32,13 @@ extern "C" {
JNIEXPORT void OLM_INBOUND_GROUP_SESSION_FUNC_DEF(releaseSessionJni)(JNIEnv *env, jobject thiz);
JNIEXPORT jlong OLM_INBOUND_GROUP_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject thiz);
-JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jstring aSessionKey);
+JNIEXPORT jint OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initInboundGroupSessionWithSessionKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aSessionKeyBuffer);
JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(sessionIdentifierJni)(JNIEnv *env, jobject thiz);
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jstring aEncryptedMsg, jobject aDecryptIndex, jobject aErrorMsg);
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aEncryptedMsg, jobject aDecryptIndex, jobject aErrorMsg);
// serialization
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg);
+JNIEXPORT jstring OLM_INBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey);
#ifdef __cplusplus
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp
index 3ee3db7..0ccc6e8 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.cpp
@@ -338,13 +338,13 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmOutboundGroupSession* sessionPtr = NULL;
LOGD("## outbound group session serializeDataWithKeyJni(): IN");
@@ -353,7 +353,7 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -369,14 +369,14 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_outbound_group_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
@@ -418,19 +418,19 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(J
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmOutboundGroupSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -438,26 +438,26 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
@@ -482,12 +482,12 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h
index f7e8a21..43ec4f7 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_outbound_group_session.h
@@ -40,8 +40,8 @@ JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(sessionKeyJni)(JNIEnv *env
JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsgBuffer);
// serialization
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg);
+JNIEXPORT jstring OLM_OUTBOUND_GROUP_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey);
#ifdef __cplusplus
}
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
index 0797ae6..491795f 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.cpp
@@ -107,7 +107,7 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thi
* @param aTheirOneTimeKey the one time key of the recipient
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
**/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aTheirOneTimeKey)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aTheirOneTimeKeyBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession* sessionPtr = NULL;
@@ -121,7 +121,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
{
LOGE("## initOutboundSessionJni(): failure - invalid Account ptr=NULL");
}
- else if (!aTheirIdentityKey || !aTheirOneTimeKey)
+ else if (!aTheirIdentityKeyBuffer || !aTheirOneTimeKeyBuffer)
{
LOGE("## initOutboundSessionJni(): failure - invalid keys");
}
@@ -138,22 +138,22 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
}
else
{
- const char* theirIdentityKeyPtr = NULL;
- const char* theirOneTimeKeyPtr = NULL;
+ jbyte* theirIdentityKeyPtr = NULL;
+ jbyte* theirOneTimeKeyPtr = NULL;
// convert identity & one time keys to C strings
- if (!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ if (!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## initOutboundSessionJni(): failure - identityKey JNI allocation OOM");
}
- else if (!(theirOneTimeKeyPtr = env->GetStringUTFChars(aTheirOneTimeKey, 0)))
+ else if (!(theirOneTimeKeyPtr = env->GetByteArrayElements(aTheirOneTimeKeyBuffer, 0)))
{
LOGE("## initOutboundSessionJni(): failure - one time Key JNI allocation OOM");
}
else
{
- size_t theirIdentityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
- size_t theirOneTimeKeyLength = (size_t)env->GetStringUTFLength(aTheirOneTimeKey);
+ size_t theirIdentityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
+ size_t theirOneTimeKeyLength = (size_t)env->GetArrayLength(aTheirOneTimeKeyBuffer);
LOGD("## initOutboundSessionJni(): identityKey=%s oneTimeKey=%s",theirIdentityKeyPtr,theirOneTimeKeyPtr);
size_t sessionResult = olm_create_outbound_session(sessionPtr,
@@ -176,12 +176,12 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
if (theirOneTimeKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirOneTimeKey, theirOneTimeKeyPtr);
+ env->ReleaseByteArrayElements(aTheirOneTimeKeyBuffer, theirOneTimeKeyPtr, JNI_ABORT);
}
if (randomBuffPtr)
@@ -205,7 +205,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject
* @param aOneTimeKeyMsg PRE_KEY message
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
@@ -220,13 +220,13 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
{
LOGE("## initInboundSessionJni(): failure - invalid Account ptr=NULL");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## initInboundSessionJni(): failure - invalid message");
}
else
{
- const char *messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0);
+ jbyte* messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0);
if (!messagePtr)
{
@@ -234,7 +234,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
LOGD("## initInboundSessionJni(): messageLength=%lu message=%s", static_cast<long unsigned int>(messageLength), messagePtr);
sessionResult = olm_create_inbound_session(sessionPtr, accountPtr, (void*)messagePtr , messageLength);
@@ -250,7 +250,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
}
// free local alloc
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
}
return retCode;
@@ -264,13 +264,13 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject
* @param aOneTimeKeyMsg encrypted message
* @return ERROR_CODE_OK if operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
OlmAccount *accountPtr = NULL;
- const char *messagePtr = NULL;
- const char *theirIdentityKeyPtr = NULL;
+ jbyte *messagePtr = NULL;
+ jbyte *theirIdentityKeyPtr = NULL;
size_t sessionResult;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
@@ -281,26 +281,26 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - invalid Account ptr=NULL");
}
- else if (!aTheirIdentityKey)
+ else if (!aTheirIdentityKeyBuffer)
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - invalid theirIdentityKey");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## initInboundSessionJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - message JNI allocation OOM");
}
- else if(!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ else if(!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## initInboundSessionFromIdKeyJni(): failure - theirIdentityKey JNI allocation OOM");
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
- size_t theirIdentityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
+ size_t theirIdentityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
LOGD("## initInboundSessionFromIdKeyJni(): message=%s messageLength=%lu",messagePtr,static_cast<long unsigned int>(messageLength));
@@ -319,12 +319,12 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
// free local alloc
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
return retCode;
@@ -336,27 +336,27 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env,
* @param aOneTimeKeyMsg PRE KEY message
* @return ERROR_CODE_OK if match, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jstring aOneTimeKeyMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *messagePtr = NULL;
+ jbyte *messagePtr = NULL;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
{
LOGE("## matchesInboundSessionJni(): failure - invalid Session ptr=NULL");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## matchesInboundSessionJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## matchesInboundSessionJni(): failure - one time key JNI allocation OOM");
}
else
{
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
size_t matchResult = olm_matches_inbound_session(sessionPtr, (void*)messagePtr , messageLength);
//if(matchResult == olm_error()) {
@@ -374,7 +374,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobje
// free local alloc
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
return retCode;
@@ -388,37 +388,37 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobje
* @param aOneTimeKeyMsg PRE KEY message
* @return ERROR_CODE_OK if match, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg)
+JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aTheirIdentityKeyBuffer, jbyteArray aOneTimeKeyMsgBuffer)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *messagePtr = NULL;
- const char *theirIdentityKeyPtr = NULL;
+ jbyte *messagePtr = NULL;
+ jbyte *theirIdentityKeyPtr = NULL;
if (!(sessionPtr = (OlmSession*)getSessionInstanceId(env,thiz)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid Session ptr=NULL");
}
- else if (!aTheirIdentityKey)
+ else if (!aTheirIdentityKeyBuffer)
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid theirIdentityKey");
}
- else if (!(theirIdentityKeyPtr = env->GetStringUTFChars(aTheirIdentityKey, 0)))
+ else if (!(theirIdentityKeyPtr = env->GetByteArrayElements(aTheirIdentityKeyBuffer, 0)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - theirIdentityKey JNI allocation OOM");
}
- else if (!aOneTimeKeyMsg)
+ else if (!aOneTimeKeyMsgBuffer)
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - invalid one time key message");
}
- else if (!(messagePtr = env->GetStringUTFChars(aOneTimeKeyMsg, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aOneTimeKeyMsgBuffer, 0)))
{
LOGE("## matchesInboundSessionFromIdKeyJni(): failure - one time key JNI allocation OOM");
}
else
{
- size_t identityKeyLength = (size_t)env->GetStringUTFLength(aTheirIdentityKey);
- size_t messageLength = (size_t)env->GetStringUTFLength(aOneTimeKeyMsg);
+ size_t identityKeyLength = (size_t)env->GetArrayLength(aTheirIdentityKeyBuffer);
+ size_t messageLength = (size_t)env->GetArrayLength(aOneTimeKeyMsgBuffer);
size_t matchResult = olm_matches_inbound_session_from(sessionPtr, (void const *)theirIdentityKeyPtr, identityKeyLength, (void*)messagePtr , messageLength);
//if(matchResult == olm_error()) {
@@ -437,12 +437,12 @@ JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(J
// free local alloc
if (theirIdentityKeyPtr)
{
- env->ReleaseStringUTFChars(aTheirIdentityKey, theirIdentityKeyPtr);
+ env->ReleaseByteArrayElements(aTheirIdentityKeyBuffer, theirIdentityKeyPtr, JNI_ABORT);
}
if (messagePtr)
{
- env->ReleaseStringUTFChars(aOneTimeKeyMsg, messagePtr);
+ env->ReleaseByteArrayElements(aOneTimeKeyMsgBuffer, messagePtr, JNI_ABORT);
}
return retCode;
@@ -455,11 +455,11 @@ JNIEXPORT jint JNICALL OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(J
* @param [out] aEncryptedMsg ciphered message
* @return ERROR_CODE_OK if encrypt operation succeed, ERROR_CODE_KO otherwise
*/
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jstring aClearMsg, jobject aEncryptedMsg)
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsgBuffer, jobject aEncryptedMsg)
{
jint retCode = ERROR_CODE_KO;
OlmSession *sessionPtr = NULL;
- const char *clearMsgPtr = NULL;
+ jbyte *clearMsgPtr = NULL;
jclass encryptedMsgJClass = 0;
jfieldID encryptedMsgFieldId;
jfieldID typeMsgFieldId;
@@ -470,7 +470,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
{
LOGE("## encryptMessageJni(): failure - invalid Session ptr=NULL");
}
- else if (!aClearMsg)
+ else if (!aClearMsgBuffer)
{
LOGE("## encryptMessageJni(): failure - invalid clear message");
}
@@ -478,7 +478,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
{
LOGE("## encryptMessageJni(): failure - invalid encrypted message");
}
- else if (!(clearMsgPtr = env->GetStringUTFChars(aClearMsg, 0)))
+ else if (!(clearMsgPtr = env->GetByteArrayElements(aClearMsgBuffer, 0)))
{
LOGE("## encryptMessageJni(): failure - clear message JNI allocation OOM");
}
@@ -514,7 +514,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
else
{
// alloc buffer for encrypted message
- size_t clearMsgLength = (size_t)env->GetStringUTFLength(aClearMsg);
+ size_t clearMsgLength = (size_t)env->GetArrayLength(aClearMsgBuffer);
size_t encryptedMsgLength = olm_encrypt_message_length(sessionPtr, clearMsgLength);
void *encryptedMsgPtr = malloc((encryptedMsgLength+1)*sizeof(uint8_t));
@@ -569,7 +569,7 @@ JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz
// free alloc
if (clearMsgPtr)
{
- env->ReleaseStringUTFChars(aClearMsg, clearMsgPtr);
+ env->ReleaseByteArrayElements(aClearMsgBuffer, clearMsgPtr, JNI_ABORT);
}
return retCode;
@@ -760,13 +760,13 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, job
* @param[out] aErrorMsg error message set if operation failed
* @return a base64 string if operation succeed, null otherwise
**/
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg)
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKeyBuffer, jobject aErrorMsg)
{
jstring pickledDataRetValue = 0;
jclass errorMsgJClass = 0;
jmethodID errorMsgMethodId = 0;
jstring errorJstring = 0;
- const char *keyPtr = NULL;
+ jbyte* keyPtr = NULL;
OlmSession* sessionPtr = NULL;
LOGD("## serializeDataWithKeyJni(): IN");
@@ -775,7 +775,7 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid session ptr");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## serializeDataWithKeyJni(): failure - invalid key");
}
@@ -791,14 +791,14 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
{
LOGE(" ## serializeDataWithKeyJni(): failure - unable to get error method ID");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## serializeDataWithKeyJni(): failure - keyPtr JNI allocation OOM");
}
else
{
size_t pickledLength = olm_pickle_session_length(sessionPtr);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## serializeDataWithKeyJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## serializeDataWithKeyJni(): key=%s",(char const *)keyPtr);
@@ -840,19 +840,19 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, job
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
return pickledDataRetValue;
}
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey)
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedDataBuffer, jbyteArray aKeyBuffer)
{
OlmSession* sessionPtr = NULL;
jstring errorMessageRetValue = 0;
- const char *keyPtr = NULL;
- const char *pickledPtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* pickledPtr = NULL;
LOGD("## initWithSerializedDataJni(): IN");
@@ -860,26 +860,26 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
{
LOGE(" ## initWithSerializedDataJni(): failure - session failure OOM");
}
- else if (!aKey)
+ else if (!aKeyBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - invalid key");
}
- else if (!aSerializedData)
+ else if (!aSerializedDataBuffer)
{
LOGE(" ## initWithSerializedDataJni(): failure - serialized data");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - keyPtr JNI allocation OOM");
}
- else if (!(pickledPtr = env->GetStringUTFChars(aSerializedData, 0)))
+ else if (!(pickledPtr = env->GetByteArrayElements(aSerializedDataBuffer, 0)))
{
LOGE(" ## initWithSerializedDataJni(): failure - pickledPtr JNI allocation OOM");
}
else
{
- size_t pickledLength = (size_t)env->GetStringUTFLength(aSerializedData);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
+ size_t pickledLength = (size_t)env->GetArrayLength(aSerializedDataBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
LOGD(" ## initWithSerializedDataJni(): pickledLength=%lu keyLength=%lu",static_cast<long unsigned int>(pickledLength), static_cast<long unsigned int>(keyLength));
LOGD(" ## initWithSerializedDataJni(): key=%s",(char const *)keyPtr);
LOGD(" ## initWithSerializedDataJni(): pickled=%s",(char const *)pickledPtr);
@@ -905,12 +905,12 @@ JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, j
// free alloc
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (pickledPtr)
{
- env->ReleaseStringUTFChars(aSerializedData, pickledPtr);
+ env->ReleaseByteArrayElements(aSerializedDataBuffer, pickledPtr, JNI_ABORT);
}
return errorMessageRetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h
index 22005d9..b18ac86 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_session.h
@@ -33,25 +33,25 @@ JNIEXPORT jlong OLM_SESSION_FUNC_DEF(initNewSessionJni)(JNIEnv *env, jobject thi
JNIEXPORT jlong OLM_SESSION_FUNC_DEF(createNewSessionJni)(JNIEnv *env, jobject thiz);
// outbound session
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aTheirOneTimeKey);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initOutboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKey, jbyteArray aTheirOneTimeKey);
// inbound sessions: establishment based on PRE KEY message
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aOneTimeKeyMsg);
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(initInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jlong aOlmAccountId, jbyteArray aTheirIdentityKey, jbyteArray aOneTimeKeyMsg);
// match inbound sessions: based on PRE KEY message
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jstring aOneTimeKeyMsg);
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jstring aTheirIdentityKey, jstring aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionJni)(JNIEnv *env, jobject thiz, jbyteArray aOneTimeKeyMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(matchesInboundSessionFromIdKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aTheirIdentityKey, jbyteArray aOneTimeKeyMsg);
// encrypt/decrypt
-JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jstring aClearMsg, jobject aEncryptedMsg);
+JNIEXPORT jint OLM_SESSION_FUNC_DEF(encryptMessageJni)(JNIEnv *env, jobject thiz, jbyteArray aClearMsg, jobject aEncryptedMsg);
JNIEXPORT jstring OLM_SESSION_FUNC_DEF(decryptMessageJni)(JNIEnv *env, jobject thiz, jobject aEncryptedMsg);
JNIEXPORT jstring OLM_SESSION_FUNC_DEF(getSessionIdentifierJni)(JNIEnv *env, jobject thiz);
// serialization
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jstring aKey, jobject aErrorMsg);
-JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jstring aSerializedData, jstring aKey);
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(serializeDataWithKeyJni)(JNIEnv *env, jobject thiz, jbyteArray aKey, jobject aErrorMsg);
+JNIEXPORT jstring OLM_SESSION_FUNC_DEF(initWithSerializedDataJni)(JNIEnv *env, jobject thiz, jbyteArray aSerializedData, jbyteArray aKey);
#ifdef __cplusplus
}
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 8a7607c..584e83e 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
@@ -85,13 +85,13 @@ JNIEXPORT void OLM_UTILITY_FUNC_DEF(releaseUtilityJni)(JNIEnv *env, jobject thiz
* @param aMessage the message which was signed
* @return 0 if validation succeed, an error message string if operation failed
*/
-JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jstring aSignature, jstring aKey, jstring aMessage)
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jbyteArray aSignatureBuffer, jbyteArray aKeyBuffer, jbyteArray aMessageBuffer)
{
jstring errorMessageRetValue = 0;
OlmUtility* utilityPtr = NULL;
- const char* signaturePtr = NULL;
- const char* keyPtr = NULL;
- const char* messagePtr = NULL;
+ jbyte* signaturePtr = NULL;
+ jbyte* keyPtr = NULL;
+ jbyte* messagePtr = NULL;
LOGD("## verifyEd25519SignatureJni(): IN");
@@ -99,27 +99,27 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, j
{
LOGE(" ## verifyEd25519SignatureJni(): failure - invalid utility ptr=NULL");
}
- else if (!aSignature || !aKey || !aMessage)
+ else if (!aSignatureBuffer || !aKeyBuffer || !aMessageBuffer)
{
LOGE(" ## verifyEd25519SignatureJni(): failure - invalid input parameters ");
}
- else if (!(signaturePtr = env->GetStringUTFChars(aSignature, 0)))
+ else if (!(signaturePtr = env->GetByteArrayElements(aSignatureBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - signature JNI allocation OOM");
}
- else if (!(keyPtr = env->GetStringUTFChars(aKey, 0)))
+ else if (!(keyPtr = env->GetByteArrayElements(aKeyBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - key JNI allocation OOM");
}
- else if (!(messagePtr = env->GetStringUTFChars(aMessage, 0)))
+ else if (!(messagePtr = env->GetByteArrayElements(aMessageBuffer, 0)))
{
LOGE(" ## verifyEd25519SignatureJni(): failure - message JNI allocation OOM");
}
else
{
- size_t signatureLength = (size_t)env->GetStringUTFLength(aSignature);
- size_t keyLength = (size_t)env->GetStringUTFLength(aKey);
- size_t messageLength = (size_t)env->GetStringUTFLength(aMessage);
+ size_t signatureLength = (size_t)env->GetArrayLength(aSignatureBuffer);
+ size_t keyLength = (size_t)env->GetArrayLength(aKeyBuffer);
+ size_t messageLength = (size_t)env->GetArrayLength(aMessageBuffer);
LOGD(" ## verifyEd25519SignatureJni(): signatureLength=%lu keyLength=%lu messageLength=%lu",static_cast<long unsigned int>(signatureLength),static_cast<long unsigned int>(keyLength),static_cast<long unsigned int>(messageLength));
LOGD(" ## verifyEd25519SignatureJni(): key=%s",keyPtr);
@@ -144,17 +144,17 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, j
// free alloc
if (signaturePtr)
{
- env->ReleaseStringUTFChars(aSignature, signaturePtr);
+ env->ReleaseByteArrayElements(aSignatureBuffer, signaturePtr, JNI_ABORT);
}
if (keyPtr)
{
- env->ReleaseStringUTFChars(aKey, keyPtr);
+ env->ReleaseByteArrayElements(aKeyBuffer, keyPtr, JNI_ABORT);
}
if (messagePtr)
{
- env->ReleaseStringUTFChars(aMessage, messagePtr);
+ env->ReleaseByteArrayElements(aMessageBuffer, messagePtr, JNI_ABORT);
}
return errorMessageRetValue;
@@ -166,11 +166,11 @@ 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, jstring aMessageToHash)
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jbyteArray aMessageToHashBuffer)
{
jstring sha256RetValue = 0;
OlmUtility* utilityPtr = NULL;
- const char* messagePtr = NULL;
+ jbyte* messagePtr = NULL;
LOGD("## sha256Jni(): IN");
@@ -178,18 +178,18 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jst
{
LOGE(" ## sha256Jni(): failure - invalid utility ptr=NULL");
}
- else if(!aMessageToHash)
+ else if(!aMessageToHashBuffer)
{
LOGE(" ## sha256Jni(): failure - invalid message parameters ");
}
- else if(!(messagePtr = env->GetStringUTFChars(aMessageToHash, 0)))
+ else if(!(messagePtr = env->GetByteArrayElements(aMessageToHashBuffer, 0)))
{
LOGE(" ## sha256Jni(): failure - message JNI allocation OOM");
}
else
{
// get lengths
- size_t messageLength = (size_t)env->GetStringUTFLength(aMessageToHash);
+ size_t messageLength = (size_t)env->GetArrayLength(aMessageToHashBuffer);
size_t hashLength = olm_sha256_length(utilityPtr);
void* hashValuePtr = malloc((hashLength+1)*sizeof(uint8_t));
@@ -223,7 +223,7 @@ JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jst
if (messagePtr)
{
- env->ReleaseStringUTFChars(aMessageToHash, messagePtr);
+ env->ReleaseByteArrayElements(aMessageToHashBuffer, messagePtr, JNI_ABORT);
}
return sha256RetValue;
diff --git a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
index 2a534a3..7c3601d 100644
--- a/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
+++ b/java/android/OlmLibSdk/olm-sdk/src/main/jni/olm_utility.h
@@ -29,8 +29,8 @@ extern "C" {
#endif
JNIEXPORT jlong OLM_UTILITY_FUNC_DEF(initUtilityJni)(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);
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(verifyEd25519SignatureJni)(JNIEnv *env, jobject thiz, jbyteArray aSignature, jbyteArray aKey, jbyteArray aMessage);
+JNIEXPORT jstring OLM_UTILITY_FUNC_DEF(sha256Jni)(JNIEnv *env, jobject thiz, jbyteArray aMessageToHash);
#ifdef __cplusplus
}
#endif