From 8b5bad1f335c4d2a49b0430c1dccec8f32797e05 Mon Sep 17 00:00:00 2001 From: alperozturk Date: Fri, 15 Nov 2024 13:18:44 +0100 Subject: [PATCH] add checks Signed-off-by: alperozturk --- .../java/com/owncloud/android/utils/EncryptionUtilsV2.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt index 999ffe7aac..25b4ced20b 100644 --- a/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt +++ b/app/src/main/java/com/owncloud/android/utils/EncryptionUtilsV2.kt @@ -959,6 +959,10 @@ class EncryptionUtilsV2 { oldCounter: Long, signature: String ) { + if (signature.isEmpty()) { + return + } + if (decryptedFolderMetadataFile.metadata.counter < oldCounter) { MainApp.showMessage(R.string.e2e_counter_too_old) return @@ -968,7 +972,7 @@ class EncryptionUtilsV2 { val certs = decryptedFolderMetadataFile.users.map { EncryptionUtils.convertCertFromString(it.certificate) } val signedData = getSignedData(signature, message) - if (!verifySignedData(signedData, certs)) { + if (certs.isNotEmpty() && !verifySignedData(signedData, certs)) { MainApp.showMessage(R.string.e2e_signature_does_not_match) return } @@ -980,7 +984,7 @@ class EncryptionUtilsV2 { } } - fun getSignedData(base64encodedSignature: String, message: String): CMSSignedData { + private fun getSignedData(base64encodedSignature: String, message: String): CMSSignedData { val signature = EncryptionUtils.decodeStringToBase64Bytes(base64encodedSignature) val asn1Signature = ASN1Sequence.fromByteArray(signature) val contentInfo = ContentInfo.getInstance(asn1Signature)