Skip to content

Commit

Permalink
Refactor: Rollback format-only changes
Browse files Browse the repository at this point in the history
  • Loading branch information
acrusage-iaik committed Dec 17, 2024
1 parent b37bced commit 72ef6b9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
29 changes: 14 additions & 15 deletions vck/src/commonMain/kotlin/at/asitplus/wallet/lib/jws/JwsService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,15 @@ import at.asitplus.signum.indispensable.asn1.encoding.encodeTo4Bytes
import at.asitplus.signum.indispensable.asn1.encoding.encodeTo8Bytes
import at.asitplus.signum.indispensable.equalsCryptographically
import at.asitplus.signum.indispensable.io.Base64UrlStrict
import at.asitplus.signum.indispensable.josef.*
import at.asitplus.signum.indispensable.josef.ConfirmationClaim
import at.asitplus.signum.indispensable.josef.JsonWebKey
import at.asitplus.signum.indispensable.josef.JsonWebKeySet
import at.asitplus.signum.indispensable.josef.JweAlgorithm
import at.asitplus.signum.indispensable.josef.JweDecrypted
import at.asitplus.signum.indispensable.josef.JweEncrypted
import at.asitplus.signum.indispensable.josef.JweEncryption
import at.asitplus.signum.indispensable.josef.JweHeader
import at.asitplus.signum.indispensable.josef.JwsAlgorithm
import at.asitplus.signum.indispensable.josef.JwsExtensions.prependWith4BytesSize
import at.asitplus.signum.indispensable.josef.JwsHeader
import at.asitplus.signum.indispensable.josef.JwsSigned
Expand All @@ -17,7 +25,11 @@ import at.asitplus.signum.indispensable.josef.toJsonWebKey
import at.asitplus.signum.indispensable.josef.toJwsAlgorithm
import at.asitplus.signum.indispensable.toX509SignatureAlgorithm
import at.asitplus.signum.supreme.asKmmResult
import at.asitplus.wallet.lib.agent.*
import at.asitplus.wallet.lib.agent.CryptoService
import at.asitplus.wallet.lib.agent.DefaultVerifierCryptoService
import at.asitplus.wallet.lib.agent.EphemeralKeyHolder
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.VerifierCryptoService
import at.asitplus.wallet.lib.data.vckJsonSerializer
import io.github.aakira.napier.Napier
import io.matthewnelson.encoding.core.Encoder.Companion.encodeToByteArray
Expand Down Expand Up @@ -108,7 +120,6 @@ interface JwsService {
interface VerifierJwsService {

val supportedAlgorithms: List<JwsAlgorithm>
val supportedHeaders: Map<String, (Any) -> Boolean>

fun verifyJwsObject(jwsObject: JwsSigned<*>): Boolean

Expand Down Expand Up @@ -397,18 +408,6 @@ class DefaultVerifierJwsService(
override val supportedAlgorithms: List<JwsAlgorithm> =
cryptoService.supportedAlgorithms.map { it.toJwsAlgorithm().getOrThrow() }

override val supportedHeaders: Map<String, (Any) -> Boolean>
get() = mapOf(
JwsJsonWebKeyHeaderParameterSpecification.NAME to { true },
JwsJsonWebKeySetUrlHeaderParameterSpecification.NAME to { true },
JwsKeyIdHeaderParameterSpecification.NAME to { true },
JwsX509CertificateSha256ThumbprintHeaderParameterSpecification.NAME to { true },
JwsX509CertificateSha256ThumbprintHeaderParameterSpecification.NAME to { true },
JwsAlgorithmHeaderParameterSpecification.NAME to { alg ->
JwsAlgorithm.entries.first { it.identifier == alg } in supportedAlgorithms
},
)

/**
* Verifies the signature of [jwsObject], by extracting the public key from [JwsHeader.publicKey],
* or by using [jwkSetRetriever] if [JwsHeader.jsonWebKeySetUrl] is set.
Expand Down

0 comments on commit 72ef6b9

Please sign in to comment.