From 2cdc2248048392c5982c6ddb22cff9c4af886c81 Mon Sep 17 00:00:00 2001 From: Michael Avoyan Date: Wed, 14 Feb 2024 20:52:37 +0200 Subject: [PATCH] alg fixes --- .../java/io/velocitycareerlabs/api/VCLSignatureAlgorithm.kt | 2 +- .../api/entities/initialization/VCLCryptoServicesDescriptor.kt | 2 +- VCL/src/main/java/io/velocitycareerlabs/impl/GlobalConfig.kt | 2 +- .../io/velocitycareerlabs/usecases/JwtServiceUseCaseTest.kt | 2 ++ 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/VCL/src/main/java/io/velocitycareerlabs/api/VCLSignatureAlgorithm.kt b/VCL/src/main/java/io/velocitycareerlabs/api/VCLSignatureAlgorithm.kt index 2aa5abe..ad66f0f 100644 --- a/VCL/src/main/java/io/velocitycareerlabs/api/VCLSignatureAlgorithm.kt +++ b/VCL/src/main/java/io/velocitycareerlabs/api/VCLSignatureAlgorithm.kt @@ -29,7 +29,7 @@ enum class VCLSignatureAlgorithm(val value: String) { when (value) { ES256.value -> ES256 SECP256k1.value -> SECP256k1 - else -> ES256 + else -> SECP256k1 } } } \ No newline at end of file diff --git a/VCL/src/main/java/io/velocitycareerlabs/api/entities/initialization/VCLCryptoServicesDescriptor.kt b/VCL/src/main/java/io/velocitycareerlabs/api/entities/initialization/VCLCryptoServicesDescriptor.kt index c3edd0e..499c781 100644 --- a/VCL/src/main/java/io/velocitycareerlabs/api/entities/initialization/VCLCryptoServicesDescriptor.kt +++ b/VCL/src/main/java/io/velocitycareerlabs/api/entities/initialization/VCLCryptoServicesDescriptor.kt @@ -12,7 +12,7 @@ import io.velocitycareerlabs.api.VCLSignatureAlgorithm data class VCLCryptoServicesDescriptor( val cryptoServiceType: VCLCryptoServiceType = VCLCryptoServiceType.Local, - val signatureAlgorithm: VCLSignatureAlgorithm = VCLSignatureAlgorithm.ES256, + val signatureAlgorithm: VCLSignatureAlgorithm = VCLSignatureAlgorithm.SECP256k1, val injectedCryptoServicesDescriptor: VCLInjectedCryptoServicesDescriptor? = null, val remoteCryptoServicesUrlsDescriptor: VCLRemoteCryptoServicesUrlsDescriptor? = null ) \ No newline at end of file diff --git a/VCL/src/main/java/io/velocitycareerlabs/impl/GlobalConfig.kt b/VCL/src/main/java/io/velocitycareerlabs/impl/GlobalConfig.kt index 882012b..a36729a 100644 --- a/VCL/src/main/java/io/velocitycareerlabs/impl/GlobalConfig.kt +++ b/VCL/src/main/java/io/velocitycareerlabs/impl/GlobalConfig.kt @@ -17,7 +17,7 @@ internal object GlobalConfig { var CurrentEnvironment = VCLEnvironment.Prod var XVnfProtocolVersion = VCLXVnfProtocolVersion.XVnfProtocolVersion1 - var SignatureAlgorithm = VCLSignatureAlgorithm.ES256 + var SignatureAlgorithm = VCLSignatureAlgorithm.SECP256k1 var IsDebugOn = false //BuildConfig.DEBUG diff --git a/VCL/src/test/java/io/velocitycareerlabs/usecases/JwtServiceUseCaseTest.kt b/VCL/src/test/java/io/velocitycareerlabs/usecases/JwtServiceUseCaseTest.kt index 5da91e4..524d1cf 100644 --- a/VCL/src/test/java/io/velocitycareerlabs/usecases/JwtServiceUseCaseTest.kt +++ b/VCL/src/test/java/io/velocitycareerlabs/usecases/JwtServiceUseCaseTest.kt @@ -81,6 +81,7 @@ internal class JwtServiceUseCaseTest { ) { it.handleResult( { jwt -> + assert(jwt.header?.toJSONObject()?.get("alg") as? String == VCLSignatureAlgorithm.SECP256k1.jwsAlgorithm.name) assert(((jwt.header?.toJSONObject()?.get("jwk") as? Map<*, *>)!!["crv"] as? String) == VCLSignatureAlgorithm.SECP256k1.curve.name) assert(jwt.header?.toJSONObject()?.get("typ") as? String == "JWT") }, @@ -106,6 +107,7 @@ internal class JwtServiceUseCaseTest { ) { it.handleResult( { jwt -> + assert(jwt.header?.toJSONObject()?.get("alg") as? String == VCLSignatureAlgorithm.ES256.jwsAlgorithm.name) assert(((jwt.header?.toJSONObject()?.get("jwk") as? Map<*, *>)!!["crv"] as? String) == VCLSignatureAlgorithm.ES256.curve.name) assert(jwt.header?.toJSONObject()?.get("typ") as? String == "JWT") },