mirror of
https://github.com/nextcloud/android.git
synced 2024-12-22 00:34:31 +03:00
add checks
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
d874881e13
commit
8b5bad1f33
1 changed files with 6 additions and 2 deletions
|
@ -959,6 +959,10 @@ class EncryptionUtilsV2 {
|
||||||
oldCounter: Long,
|
oldCounter: Long,
|
||||||
signature: String
|
signature: String
|
||||||
) {
|
) {
|
||||||
|
if (signature.isEmpty()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if (decryptedFolderMetadataFile.metadata.counter < oldCounter) {
|
if (decryptedFolderMetadataFile.metadata.counter < oldCounter) {
|
||||||
MainApp.showMessage(R.string.e2e_counter_too_old)
|
MainApp.showMessage(R.string.e2e_counter_too_old)
|
||||||
return
|
return
|
||||||
|
@ -968,7 +972,7 @@ class EncryptionUtilsV2 {
|
||||||
val certs = decryptedFolderMetadataFile.users.map { EncryptionUtils.convertCertFromString(it.certificate) }
|
val certs = decryptedFolderMetadataFile.users.map { EncryptionUtils.convertCertFromString(it.certificate) }
|
||||||
val signedData = getSignedData(signature, message)
|
val signedData = getSignedData(signature, message)
|
||||||
|
|
||||||
if (!verifySignedData(signedData, certs)) {
|
if (certs.isNotEmpty() && !verifySignedData(signedData, certs)) {
|
||||||
MainApp.showMessage(R.string.e2e_signature_does_not_match)
|
MainApp.showMessage(R.string.e2e_signature_does_not_match)
|
||||||
return
|
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 signature = EncryptionUtils.decodeStringToBase64Bytes(base64encodedSignature)
|
||||||
val asn1Signature = ASN1Sequence.fromByteArray(signature)
|
val asn1Signature = ASN1Sequence.fromByteArray(signature)
|
||||||
val contentInfo = ContentInfo.getInstance(asn1Signature)
|
val contentInfo = ContentInfo.getInstance(asn1Signature)
|
||||||
|
|
Loading…
Reference in a new issue