From 147fadd3c4a0e811a9358f1d4c83dbe86e86684a Mon Sep 17 00:00:00 2001 From: Kees Geluk Date: Mon, 30 Oct 2023 14:10:00 +0100 Subject: [PATCH] Changes after feedback from Jovche --- .../mdl/appreader/readercertgen/CertificateGenerator.kt | 8 +------- .../appreader/readercertgen/ReaderCertificateGenerator.kt | 7 +------ 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/CertificateGenerator.kt b/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/CertificateGenerator.kt index 0eece90e4..fc9efe1d1 100644 --- a/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/CertificateGenerator.kt +++ b/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/CertificateGenerator.kt @@ -17,7 +17,6 @@ import org.bouncycastle.cert.jcajce.JcaX509v3CertificateBuilder import org.bouncycastle.operator.OperatorCreationException import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder import java.io.IOException -import java.security.NoSuchAlgorithmException import java.security.cert.CertificateException import java.security.cert.X509Certificate import java.util.Optional @@ -49,12 +48,7 @@ object CertificateGenerator { // Extensions -------------------------- - val jcaX509ExtensionUtils: JcaX509ExtensionUtils - jcaX509ExtensionUtils = try { - JcaX509ExtensionUtils() - } catch (e: NoSuchAlgorithmException) { - throw RuntimeException(e) - } + val jcaX509ExtensionUtils = JcaX509ExtensionUtils() if (issuerCert.isPresent) { try { // adds 3 more fields, not present in other cert diff --git a/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/ReaderCertificateGenerator.kt b/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/ReaderCertificateGenerator.kt index 8ef7f72f5..4e7632856 100644 --- a/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/ReaderCertificateGenerator.kt +++ b/appverifier/src/main/java/com/android/mdl/appreader/readercertgen/ReaderCertificateGenerator.kt @@ -27,11 +27,7 @@ object ReaderCertificateGenerator { return try { // NOTE older devices may not have the right BC installed for this to work val kpg: KeyPairGenerator - if (curve.equals("Ed25519", ignoreCase = true) || curve.equals( - "Ed448", - ignoreCase = true - ) - ) { + if (listOf("Ed25519", "Ed448").any { it.equals(curve, ignoreCase = true) }) { kpg = KeyPairGenerator.getInstance(curve, BouncyCastleProvider()) } else { kpg = KeyPairGenerator.getInstance("EC", BouncyCastleProvider()) @@ -46,7 +42,6 @@ object ReaderCertificateGenerator { } } - @Throws(Exception::class) fun createReaderCertificate( dsKeyPair: KeyPair, issuerCert: X509Certificate, issuerPrivateKey: PrivateKey