From cac2df7afb26b0d127bb58d9605dd79ede9a1441 Mon Sep 17 00:00:00 2001 From: Matthias Urhahn <matthias.urhahn@sap.com> Date: Mon, 31 May 2021 18:38:44 +0200 Subject: [PATCH] Base structures for decoding/decrypting the test certificate. (#3335) --- .../cryptography/AesCryptography.kt | 16 +++++++ .../test/TestCertificateData.kt | 8 ++++ .../test/TestCertificateDccV1.kt | 48 +++++++++++++++++++ .../test/TestCertificateQRCode.kt | 6 +++ .../test/TestCertificateQRCodeExtractor.kt | 26 ++++++++++ 5 files changed, 104 insertions(+) create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/cryptography/AesCryptography.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateData.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateDccV1.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCode.kt create mode 100644 Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCodeExtractor.kt diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/cryptography/AesCryptography.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/cryptography/AesCryptography.kt new file mode 100644 index 000000000..80ad40d4c --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/cryptography/AesCryptography.kt @@ -0,0 +1,16 @@ +package de.rki.coronawarnapp.covidcertificate.cryptography + +import dagger.Reusable +import okio.ByteString +import javax.inject.Inject + +@Reusable +class AesCryptography @Inject constructor() { + + fun decrypt( + decryptionKey: ByteArray, + encryptedData: ByteString + ): ByteArray { + throw NotImplementedError() + } +} diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateData.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateData.kt new file mode 100644 index 000000000..885829681 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateData.kt @@ -0,0 +1,8 @@ +package de.rki.coronawarnapp.covidcertificate.test + +import de.rki.coronawarnapp.vaccination.core.certificate.CoseCertificateHeader + +data class TestCertificateData( + val header: CoseCertificateHeader, + val certificate: TestCertificateDccV1, +) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateDccV1.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateDccV1.kt new file mode 100644 index 000000000..d66086dfe --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateDccV1.kt @@ -0,0 +1,48 @@ +package de.rki.coronawarnapp.covidcertificate.test + +import com.google.gson.annotations.SerializedName +import org.joda.time.Instant +import org.joda.time.LocalDate + +data class TestCertificateDccV1( + @SerializedName("ver") val version: String, + @SerializedName("nam") val nameData: NameData, + @SerializedName("dob") val dob: String, + @SerializedName("v") val testCertificateData: List<TestCertificateData>, +) { + data class NameData( + @SerializedName("fn") val familyName: String?, + @SerializedName("fnt") val familyNameStandardized: String, + @SerializedName("gn") val givenName: String?, + @SerializedName("gnt") val givenNameStandardized: String?, + ) + + data class TestCertificateData( + // Disease or agent targeted, e.g. "tg": "840539006" + @SerializedName("tg") val targetId: String, + // Vaccine or prophylaxis, e.g. "vp": "1119349007" + @SerializedName("vp") val vaccineId: String, + // Vaccine medicinal product,e.g. "mp": "EU/1/20/1528", + @SerializedName("mp") val medicalProductId: String, + // Marketing Authorization Holder, e.g. "ma": "ORG-100030215", + @SerializedName("ma") val marketAuthorizationHolderId: String, + // Date/Time of Sample Collection (required) + // "sc": "2021-04-13T14:20:00+00:00", + @SerializedName("sc") val sampleCollectedAt: Instant, + // Date/Time of Test Result + // "dr": "2021-04-13T14:40:01+00:00", + @SerializedName("dr") val testResultAt: Instant, + // Testing Center (required) + // "tc": "GGD Fryslân, L-Heliconweg", + @SerializedName("tc") val testCenter: String, + // Country of Vaccination, e.g. "co": "NL" + @SerializedName("co") val countryOfVaccination: String, + // Certificate Issuer, e.g. "is": "Ministry of Public Health, Welfare and Sport", + @SerializedName("is") val certificateIssuer: String, + // Unique Certificate Identifier, e.g. "ci": "urn:uvci:01:NL:PlA8UWS60Z4RZXVALl6GAZ" + @SerializedName("ci") val uniqueCertificateIdentifier: String + ) + + val dateOfBirth: LocalDate + get() = LocalDate.parse(dob) +} diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCode.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCode.kt new file mode 100644 index 000000000..6cc65a07b --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCode.kt @@ -0,0 +1,6 @@ +package de.rki.coronawarnapp.covidcertificate.test + +data class TestCertificateQRCode( + val qrCode: String, + val testCertificateData: TestCertificateData, +) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCodeExtractor.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCodeExtractor.kt new file mode 100644 index 000000000..e5c34fc64 --- /dev/null +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/covidcertificate/test/TestCertificateQRCodeExtractor.kt @@ -0,0 +1,26 @@ +package de.rki.coronawarnapp.covidcertificate.test + +import dagger.Reusable +import okio.ByteString +import javax.inject.Inject + +@Reusable +class TestCertificateQRCodeExtractor @Inject constructor() { + + /** + * May throw an **[InvalidHealthCertificateException]** + */ + fun extract( + decryptionKey: ByteArray, + encryptedCoseComponents: ByteString, + ): TestCertificateData { + throw NotImplementedError() + } + + /** + * May throw an **[InvalidHealthCertificateException]** + */ + fun extract(qrCode: String): TestCertificateQRCode { + throw NotImplementedError() + } +} -- GitLab