Skip to content

Commit

Permalink
Added limitation for QR bytes amount: admin-ch/CovidCertificate-App-A…
Browse files Browse the repository at this point in the history
  • Loading branch information
oleksandrsarapulovgl authored Jul 27, 2021
1 parent 8d1a9bf commit 8edef54
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
Empty file.
Empty file.
Empty file.
8 changes: 7 additions & 1 deletion .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ class ClaimCertificateViewModel @Inject constructor(
private val _event = MutableLiveData<Event<ClaimCertEvent>>()
val event: LiveData<Event<ClaimCertEvent>> = _event

private var cose = ByteArray(0)
private var cose: ByteArray = ByteArray(0)
private var greenCertificate: GreenCertificate? = null

fun init(qrCodeText: String) {
Expand All @@ -85,7 +85,13 @@ class ClaimCertificateViewModel @Inject constructor(
val verificationResult = VerificationResult()
val plainInput = prefixValidationService.decode(qrCodeText, verificationResult)
val compressedCose = base45Service.decode(plainInput, verificationResult)
cose = compressorService.decode(compressedCose, verificationResult)
val coseResult: ByteArray? = compressorService.decode(compressedCose, verificationResult)

if (coseResult == null) {
Timber.d("Verification failed: Too many bytes read")
return@withContext
}
cose = coseResult

val coseData = coseService.decode(cose, verificationResult)
if (coseData == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ class RulesValidationViewModel @Inject constructor(
val verificationResult = VerificationResult()
val plainInput = prefixValidationService.decode(qrCodeText, verificationResult)
val compressedCose = base45Service.decode(plainInput, verificationResult)
val cose = compressorService.decode(compressedCose, verificationResult)
val cose: ByteArray? = compressorService.decode(compressedCose, verificationResult)

val coseData: CoseData? = coseService.decode(cose, verificationResult)
val coseData: CoseData? = cose?.let { coseService.decode(cose, verificationResult) }
val greenCertificateData: GreenCertificateData? =
coseData?.let { cborService.decodeData(it.cbor, verificationResult) }
val base64EncodedKid: String? = coseData?.kid?.toBase64()
Expand Down

0 comments on commit 8edef54

Please sign in to comment.