Skip to content

Commit

Permalink
KeyWithCert -> KeyMaterial
Browse files Browse the repository at this point in the history
  • Loading branch information
JesusMcCloud committed Sep 11, 2024
1 parent f264ac5 commit dd7eab6
Show file tree
Hide file tree
Showing 41 changed files with 126 additions and 144 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import at.asitplus.signum.indispensable.josef.JweEncryption
import at.asitplus.signum.indispensable.josef.JwsSigned
import at.asitplus.signum.indispensable.josef.toJsonWebKey
import at.asitplus.wallet.lib.agent.DefaultCryptoService
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.jws.DefaultJwsService
import at.asitplus.wallet.lib.jws.DefaultVerifierJwsService
import at.asitplus.wallet.lib.jws.JwsContentTypeConstants
Expand All @@ -19,8 +19,8 @@ import at.asitplus.wallet.lib.msg.JsonWebMessage
import io.github.aakira.napier.Napier

class MessageWrapper(
private val keyWithCert: KeyWithCert,
private val jwsService: JwsService = DefaultJwsService(DefaultCryptoService(keyWithCert)),
private val keyMaterial: KeyMaterial,
private val jwsService: JwsService = DefaultJwsService(DefaultCryptoService(keyMaterial)),
private val verifierJwsService: VerifierJwsService = DefaultVerifierJwsService(),
) {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.Issuer
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.SubjectCredentialStore
import at.asitplus.wallet.lib.data.AtomicAttribute2023
Expand All @@ -18,7 +18,7 @@ import kotlinx.coroutines.launch

class IssueCredentialMessengerConcurrentTest : FreeSpec() {

private lateinit var issuerKeyPair: KeyWithCert
private lateinit var issuerKeyPair: KeyMaterial
private lateinit var issuer: Issuer
private lateinit var issuerServiceEndpoint: String
private lateinit var issuerMessenger: IssueCredentialMessenger
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.Issuer
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.SubjectCredentialStore
import at.asitplus.wallet.lib.data.AtomicAttribute2023
Expand All @@ -16,8 +16,8 @@ import io.kotest.matchers.types.shouldBeInstanceOf

class IssueCredentialMessengerTest : FreeSpec() {

private lateinit var issuerKeyPair: KeyWithCert
private lateinit var holderKeyPair: KeyWithCert
private lateinit var issuerKeyPair: KeyMaterial
private lateinit var holderKeyPair: KeyMaterial
private lateinit var issuer: Issuer
private lateinit var holder: Holder
private lateinit var issuerServiceEndpoint: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import io.kotest.matchers.types.shouldBeInstanceOf

class IssueCredentialProtocolTest : FreeSpec({

lateinit var issuerKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyWithCert
lateinit var issuerKeyPair: KeyMaterial
lateinit var holderKeyPair: KeyMaterial
lateinit var issuer: Issuer
lateinit var holder: Holder
lateinit var issuerProtocol: IssueCredentialProtocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import kotlin.time.toDuration

class PresentProofMessengerTest : FreeSpec() {

private lateinit var holderKeyPair: KeyWithCert
private lateinit var verifierKeyPair: KeyWithCert
private lateinit var issuerKeyPair: KeyWithCert
private lateinit var holderKeyPair: KeyMaterial
private lateinit var verifierKeyPair: KeyMaterial
private lateinit var issuerKeyPair: KeyMaterial
private lateinit var holderCredentialStore: SubjectCredentialStore
private lateinit var holder: Holder
private lateinit var verifier: Verifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import io.kotest.matchers.types.shouldBeInstanceOf

class PresentProofProtocolTest : FreeSpec({

lateinit var holderKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var verifierKeyPair: KeyMaterial
lateinit var holder: Holder
lateinit var verifier: Verifier
lateinit var holderProtocol: PresentProofProtocol
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package at.asitplus.wallet.lib.oidc

import at.asitplus.KmmResult
import at.asitplus.catching
import at.asitplus.signum.indispensable.CryptoPublicKey
import at.asitplus.signum.indispensable.josef.JsonWebKeySet
import at.asitplus.signum.indispensable.josef.JweEncrypted
import at.asitplus.signum.indispensable.josef.JwsHeader
Expand Down Expand Up @@ -31,10 +30,8 @@ import at.asitplus.dif.ConstraintFilter
import at.asitplus.dif.DifInputDescriptor
import at.asitplus.dif.FormatContainerJwt
import at.asitplus.dif.FormatHolder
import at.asitplus.dif.InputDescriptor
import at.asitplus.dif.PresentationDefinition
import at.asitplus.dif.PresentationSubmissionDescriptor
import at.asitplus.dif.SchemaReference
import at.asitplus.wallet.lib.jws.DefaultJwsService
import at.asitplus.wallet.lib.jws.DefaultVerifierJwsService
import at.asitplus.wallet.lib.jws.JwsService
Expand All @@ -53,8 +50,6 @@ import at.asitplus.wallet.lib.oidvci.*
import com.benasher44.uuid.uuid4
import io.github.aakira.napier.Napier
import io.ktor.http.*
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.datetime.Clock
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.JsonElement
Expand Down Expand Up @@ -103,7 +98,7 @@ class OidcSiopVerifier private constructor(
}

constructor(
keyPairAdapter: KeyWithCert = EphemeralKeyWithSelfSignedCert(),
keyPairAdapter: KeyMaterial = EphemeralKeyWithSelfSignedCert(),
verifier: Verifier = VerifierAgent(keyPairAdapter),
relyingPartyUrl: String? = null,
responseUrl: String? = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ class OidcSiopWallet(
private val scopePresentationDefinitionRetriever: ScopePresentationDefinitionRetriever,
) {
constructor(
keyWithCert: KeyWithCert = EphemeralKeyWithSelfSignedCert(),
holder: Holder = HolderAgent(keyWithCert),
jwsService: JwsService = DefaultJwsService(DefaultCryptoService(keyWithCert)),
keyMaterial: KeyMaterial = EphemeralKeyWithSelfSignedCert(),
holder: Holder = HolderAgent(keyMaterial),
jwsService: JwsService = DefaultJwsService(DefaultCryptoService(keyMaterial)),
clock: Clock = Clock.System,
clientId: String = "https://wallet.a-sit.at/",
/**
Expand All @@ -92,7 +92,7 @@ class OidcSiopWallet(
scopePresentationDefinitionRetriever: ScopePresentationDefinitionRetriever = { null },
) : this(
holder = holder,
agentPublicKey = keyWithCert.publicKey,
agentPublicKey = keyMaterial.publicKey,
jwsService = jwsService,
clock = clock,
clientId = clientId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import at.asitplus.signum.indispensable.josef.JwsHeader
import at.asitplus.signum.indispensable.josef.toJwsAlgorithm
import at.asitplus.wallet.lib.agent.CryptoService
import at.asitplus.wallet.lib.agent.DefaultCryptoService
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.cbor.CoseService
import at.asitplus.wallet.lib.cbor.DefaultCoseService
Expand Down Expand Up @@ -84,7 +84,7 @@ class WalletService(
constructor(
clientId: String,
redirectUrl: String,
keyPairAdapter: KeyWithCert,
keyPairAdapter: KeyMaterial,
remoteResourceRetriever: RemoteResourceRetrieverFunction = { null },
stateToCodeStore: MapStore<String, String> = DefaultMapStore(),
) : this(
Expand Down Expand Up @@ -521,7 +521,7 @@ class WalletService(
proofType = OpenIdConstants.ProofType.JWT,
jwt = jwsService.createSignedJwsAddingParams(
header = JwsHeader(
algorithm = cryptoService.keyWithCert.signatureAlgorithm.toJwsAlgorithm().getOrThrow(),
algorithm = cryptoService.keyMaterial.signatureAlgorithm.toJwsAlgorithm().getOrThrow(),
type = OpenIdConstants.ProofType.JWT_HEADER_TYPE.stringRepresentation,
),
payload = JsonWebToken(
Expand All @@ -544,9 +544,9 @@ class WalletService(
proofType = OpenIdConstants.ProofType.CWT,
cwt = coseService.createSignedCose(
protectedHeader = CoseHeader(
algorithm = cryptoService.keyWithCert.signatureAlgorithm.toCoseAlgorithm().getOrThrow(),
algorithm = cryptoService.keyMaterial.signatureAlgorithm.toCoseAlgorithm().getOrThrow(),
contentType = OpenIdConstants.ProofType.CWT_HEADER_TYPE.stringRepresentation,
certificateChain = cryptoService.keyWithCert.getCertificate()?.encodeToDerOrNull()
certificateChain = cryptoService.keyMaterial.getCertificate()?.encodeToDerOrNull()
),
payload = CborWebToken(
issuer = clientId, // omit when token was pre-authn?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import io.kotest.core.spec.style.FreeSpec
import io.kotest.matchers.shouldBe
import io.kotest.matchers.types.shouldBeInstanceOf
import io.ktor.http.*
import kotlinx.serialization.encodeToString

class AuthenticationRequestParameterFromSerializerTest : FreeSpec({

Expand All @@ -21,7 +20,7 @@ class AuthenticationRequestParameterFromSerializerTest : FreeSpec({

val holderKeyPair = EphemeralKeyWithSelfSignedCert()
val oidcSiopWallet = OidcSiopWallet(
keyWithCert = holderKeyPair,
keyMaterial = holderKeyPair,
holder = HolderAgent(holderKeyPair),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.InMemorySubjectCredentialStore
import at.asitplus.wallet.lib.agent.Issuer
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.SubjectCredentialStore
import at.asitplus.wallet.lib.agent.toStoreCredentialInput
Expand All @@ -20,7 +20,7 @@ import kotlinx.serialization.json.JsonPrimitive
@Suppress("unused")
class CredentialJsonInteropTest : FreeSpec({

lateinit var holderKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial

lateinit var issuerAgent: Issuer
lateinit var subjectCredentialStore: SubjectCredentialStore
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.dif.DifInputDescriptor
import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.Verifier
import at.asitplus.wallet.lib.agent.VerifierAgent
Expand All @@ -29,8 +29,8 @@ class OidcSiopCombinedProtocolTest : FreeSpec({

lateinit var relyingPartyUrl: String

lateinit var holderKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var verifierKeyPair: KeyMaterial

lateinit var holderAgent: Holder
lateinit var verifierAgent: Verifier
Expand Down Expand Up @@ -362,7 +362,7 @@ class OidcSiopCombinedProtocolTest : FreeSpec({
})

private suspend fun Holder.storeJwtCredential(
holderKeyPair: KeyWithCert,
holderKeyPair: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
Expand All @@ -378,7 +378,7 @@ private suspend fun Holder.storeJwtCredential(
}

private suspend fun Holder.storeSdJwtCredential(
holderKeyPair: KeyWithCert,
holderKeyPair: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
Expand All @@ -394,7 +394,7 @@ private suspend fun Holder.storeSdJwtCredential(
}

private suspend fun Holder.storeIsoCredential(
holderKeyPair: KeyWithCert,
holderKeyPair: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) = storeCredential(
IssuerAgent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import at.asitplus.wallet.lib.agent.CredentialSubmission
import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.SubjectCredentialStore
import at.asitplus.wallet.lib.agent.Verifier
Expand All @@ -26,8 +26,8 @@ class OidcSiopCombinedProtocolTwoStepTest : FreeSpec({

lateinit var relyingPartyUrl: String

lateinit var holderKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var verifierKeyPair: KeyMaterial

lateinit var holderAgent: Holder
lateinit var verifierAgent: Verifier
Expand Down Expand Up @@ -286,7 +286,7 @@ class OidcSiopCombinedProtocolTwoStepTest : FreeSpec({
})

private suspend fun Holder.storeSdJwtCredential(
holderKeyPair: KeyWithCert,
holderKeyPair: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
Expand All @@ -302,7 +302,7 @@ private suspend fun Holder.storeSdJwtCredential(
}

private suspend fun Holder.storeIsoCredential(
holderKeyPair: KeyWithCert,
holderKeyPair: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) = storeCredential(
IssuerAgent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import kotlinx.datetime.Instant
*/
class OidcSiopInteropTest : FreeSpec({

lateinit var holderKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var holderAgent: Holder
lateinit var holderSiop: OidcSiopWallet
lateinit var verifierKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyMaterial
lateinit var verifierAgent: Verifier
lateinit var verifierSiop: OidcSiopVerifier

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import at.asitplus.openid.OpenIdConstants
import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.Verifier
import at.asitplus.wallet.lib.agent.VerifierAgent
Expand All @@ -28,8 +28,8 @@ class OidcSiopIsoProtocolTest : FreeSpec({
lateinit var relyingPartyUrl: String
lateinit var walletUrl: String

lateinit var holderKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var verifierKeyPair: KeyMaterial

lateinit var holderAgent: Holder
lateinit var verifierAgent: Verifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ package at.asitplus.wallet.lib.oidc
import at.asitplus.openid.AuthenticationRequestParameters
import at.asitplus.openid.AuthenticationResponseParameters
import at.asitplus.openid.OpenIdConstants
import at.asitplus.signum.indispensable.io.Base64UrlStrict
import at.asitplus.signum.indispensable.josef.*
import at.asitplus.wallet.lib.agent.*
import at.asitplus.signum.indispensable.josef.JsonWebKey
import at.asitplus.signum.indispensable.josef.JsonWebToken
import at.asitplus.signum.indispensable.josef.JwsHeader
Expand All @@ -15,7 +12,7 @@ import at.asitplus.wallet.lib.agent.DefaultCryptoService
import at.asitplus.wallet.lib.agent.Holder
import at.asitplus.wallet.lib.agent.HolderAgent
import at.asitplus.wallet.lib.agent.IssuerAgent
import at.asitplus.wallet.lib.agent.KeyWithCert
import at.asitplus.wallet.lib.agent.KeyMaterial
import at.asitplus.wallet.lib.agent.EphemeralKeyWithSelfSignedCert
import at.asitplus.wallet.lib.agent.Verifier
import at.asitplus.wallet.lib.agent.VerifierAgent
Expand Down Expand Up @@ -49,8 +46,8 @@ class OidcSiopProtocolTest : FreeSpec({
lateinit var responseUrl: String
lateinit var walletUrl: String

lateinit var holderKeyPair: KeyWithCert
lateinit var verifierKeyPair: KeyWithCert
lateinit var holderKeyPair: KeyMaterial
lateinit var verifierKeyPair: KeyMaterial

lateinit var holderAgent: Holder
lateinit var verifierAgent: Verifier
Expand Down Expand Up @@ -293,7 +290,7 @@ class OidcSiopProtocolTest : FreeSpec({

holderSiop = OidcSiopWallet(
holder = holderAgent,
requestObjectJwsVerifier = verifierAttestationVerifier(sprsCryptoService.keyWithCert.jsonWebKey)
requestObjectJwsVerifier = verifierAttestationVerifier(sprsCryptoService.keyMaterial.jsonWebKey)
)
val authnResponse = holderSiop.createAuthnResponse(authnRequestWithRequestObject).getOrThrow()
authnResponse.shouldBeInstanceOf<AuthenticationResponseResult.Redirect>()
Expand Down Expand Up @@ -418,10 +415,10 @@ class OidcSiopProtocolTest : FreeSpec({
private suspend fun buildAttestationJwt(
sprsCryptoService: DefaultCryptoService,
relyingPartyUrl: String,
verifierKeyPair: KeyWithCert
verifierKeyPair: KeyMaterial
): JwsSigned = DefaultJwsService(sprsCryptoService).createSignedJws(
header = JwsHeader(
algorithm = sprsCryptoService.keyWithCert.signatureAlgorithm.toJwsAlgorithm().getOrThrow(),
algorithm = sprsCryptoService.keyMaterial.signatureAlgorithm.toJwsAlgorithm().getOrThrow(),
),
payload = JsonWebToken(
issuer = "sprs", // allows Wallet to determine the issuer's key
Expand Down
Loading

0 comments on commit dd7eab6

Please sign in to comment.