Skip to content

Commit

Permalink
add checks
Browse files Browse the repository at this point in the history
Signed-off-by: alperozturk <alper_ozturk@proton.me>
  • Loading branch information
alperozturk96 authored and tobiasKaminsky committed Dec 4, 2024
1 parent 0ef9e0e commit 54ca238
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,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
Expand All @@ -962,7 +966,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
}
Expand All @@ -974,7 +978,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)
Expand Down

0 comments on commit 54ca238

Please sign in to comment.