aboutsummaryrefslogtreecommitdiff
path: root/java/android/OlmLibSdk/olm-sdk/src/main
diff options
context:
space:
mode:
authorpedroGitt <pedro.contreiras@amdocs.com>2016-10-18 19:02:18 +0200
committerpedroGitt <pedro.contreiras@amdocs.com>2016-10-18 19:02:18 +0200
commit26d9934fc84f3da742e4c38f37ee50a9ddb5237b (patch)
tree43266ade9567cbcda83867282f22256ef14144d3 /java/android/OlmLibSdk/olm-sdk/src/main
parenta6913c49c26b54a4856f883daeb27970f9ab59a4 (diff)
Fix verifyEd25519Signature() API to properly return the error message in case signature verification failed
- update unit tests
Diffstat (limited to 'java/android/OlmLibSdk/olm-sdk/src/main')
-rw-r--r--java/android/OlmLibSdk/olm-sdk/src/main/java/org/matrix/olm/OlmUtility.java25
1 files changed, 17 insertions, 8 deletions
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 e2a085d..a6e9c4f 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
@@ -71,14 +71,14 @@ public class OlmUtility implements Serializable {
* If the key was too small, aError is set to "OLM.INVALID_BASE64".
* If the signature was invalid, aError is set to "OLM.BAD_MESSAGE_MAC".<br>
* @param aSignature the base64-encoded message signature to be checked.
- * @param aFingerprintKey the ed25519 key
- * @param aMessage the message which was signed
+ * @param aFingerprintKey the ed25519 key (fingerprint key)
+ * @param aMessage the signed message
* @param aError error message description
* @return true if the signature is verified, false otherwise
*/
- public boolean verifyEd25519Signature(String aSignature, String aFingerprintKey, String aMessage, String aError) {
+ public boolean verifyEd25519Signature(String aSignature, String aFingerprintKey, String aMessage, StringBuffer aError) {
boolean retCode = false;
- OlmUtility retObj=null;
+ String errorRetValue = null;
if(null == aError) {
Log.e(LOG_TAG, "## verifyEd25519Signature(): invalid input error parameter");
@@ -86,17 +86,26 @@ public class OlmUtility implements Serializable {
else if(TextUtils.isEmpty(aSignature) || TextUtils.isEmpty(aFingerprintKey) || TextUtils.isEmpty(aMessage)){
Log.e(LOG_TAG, "## verifyEd25519Signature(): invalid input parameters");
} else {
- String errorRetValue = verifyEd25519SignatureJni(aSignature,aFingerprintKey, aMessage);
- if(null == errorRetValue) {
- aError="";
+ aError.setLength(0);
+
+ if( null == (errorRetValue = verifyEd25519SignatureJni(aSignature,aFingerprintKey, aMessage))) {
retCode = true;
} else {
- aError = errorRetValue;
+ aError.append(errorRetValue);
}
}
return retCode;
}
+
+ /**
+ * Verify an ed25519 signature.
+ * Return a human readable error message in case of verification failure.
+ * @param aSignature the base64-encoded message signature to be checked.
+ * @param aFingerprintKey the ed25519 key
+ * @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);