Commit 765647cd authored by ylecollen's avatar ylecollen
Browse files

There is more GetStringUTFChars call.

parent de962ef8
......@@ -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.
......
......@@ -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>
......
......@@ -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);
/**
......
......@@ -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>
......
......@@ -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);
/**
......
......@@ -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);