-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JOSE support #16
Comments
Up |
Hi, is there anything we (walt.id) could maybe help implement here? |
Hey, @waltkb, thank you for the interest! That would be really nice! When we have all the base blocks from the serialisation part, then we can start thinking about how to integrate it with signing part of Thank you once more, I'm looking forward to it! |
I am currently in the progress of implementing a JWT library for Kotlin Multiplatform supporting all platforms this library also supports and have signing and verification done very easily so far. The current progress is avaiable here: https://github.com/Appstractive/jwt-kt Maybe the repository will be useful to you by using it as a playground to test the JWK implementation. |
Dear @whyoleg The branch that you mentioned (jose) is not present. Was this postponed for a future release? Can this be the case of jose? Can you please elaborate? |
Hey @babisRoutis !
Yeah, looks like I deleted it while preparing the release. Anyway, it was just the same as
It was planned for 0.5.0 (next "major") release for a long time, as I had other things to do.
Yeah, sure, I think so! At least initially we should have all data models for serialization (similar to how ASN.1/DER). Only after that we could start thinking about integration. The story with JWT is harder, as it will probably need more tight integration with Do you get the idea? P.S. The library size, complexity and amount of moving parts is only increasing and so working on it alone becomes harder and harder so I would really like if the work could be divided :) |
Hey @aschulz90 ! |
On additional note, last time I thought about how JWK is implemented currently in the library, I was not very sure if it's a good idea to have I don't know yet, just leaving my thoughts here. |
This is the reason that triggered my question. To my understanding, having a no-deps JWK serialization module, means that Perhaps, |
I have started to look into it some time ago, but I am not that deep into cryptography and was kinda ovewhelmed by the RFC and its terminology. From what I gathered, the model could look like this: import dev.whyoleg.cryptography.CryptographyAlgorithmId
import dev.whyoleg.cryptography.algorithms.digest.Digest
import dev.whyoleg.cryptography.algorithms.digest.SHA256
import dev.whyoleg.cryptography.algorithms.digest.SHA384
import dev.whyoleg.cryptography.algorithms.digest.SHA512
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
import kotlinx.serialization.json.JsonClassDiscriminator
enum class Algorithm {
HS256,
HS384,
HS512,
RS256,
RS384,
RS512,
PS256,
PS384,
PS512,
EC256,
EC384,
EC512,
}
val Algorithm.digest: CryptographyAlgorithmId<Digest>
get() =
when (this) {
Algorithm.EC256,
Algorithm.PS256,
Algorithm.RS256,
Algorithm.HS256 -> SHA256
Algorithm.EC384,
Algorithm.RS384,
Algorithm.PS384,
Algorithm.HS384 -> SHA384
Algorithm.EC512,
Algorithm.HS512,
Algorithm.RS512,
Algorithm.PS512 -> SHA512
}
enum class Curve {
@SerialName("P-256") P256,
@SerialName("P-384") P384,
@SerialName("P-521") P521,
}
@OptIn(ExperimentalSerializationApi::class)
@Serializable
@JsonClassDiscriminator("kty")
sealed interface JSONWebKey {
val alg: Algorithm?
val kid: String?
}
@Serializable
@SerialName("RSA")
data class JSONWebKeyRSA(
override val alg: Algorithm? = null,
override val kid: String,
val use: String,
val n: String,
val e: String,
val d: String? = null,
val p: String? = null,
val q: String? = null,
val dp: String? = null,
val dq: String? = null,
val qi: String? = null,
) : JSONWebKey
@Serializable
@SerialName("EC")
data class JSONWebKeyEC(
override val alg: Algorithm? = null,
override val kid: String,
val crv: Curve,
val x: String,
val y: String,
val d: String,
) : JSONWebKey
@Serializable
@SerialName("oct")
data class JSONWebKeyHMAC(
override val alg: Algorithm? = null,
override val kid: String,
val k: String,
) : JSONWebKey
@Serializable
data class JSONWebKeySet(
val keys: List<JSONWebKey>,
) But I am not sure about the parameters, or if they even are all required to genrate the public key from.
This is how I currently generate the verifier based on the above model class: JSONWebKeyExt.kt As for the actual generation of public keys: at least on JVM it seems to be pretty simple, e.g. like this: jwks-rsa-java |
Okay, I will try to expand on the ideas which I have right now in mind and may be this will help to understand what is the direction which I see for JOSE support in cryptography-kotlin (CK for short). This is not the final decision of course, more of a starting point. I see the solution which consists of three parts: 1. Data models for JOSE (a.k.a
|
@whyoleg thanks for the summary!
In a backend context, it would be nice to have the model classes exposed. |
Totally agree. Not only for back-end, though. For instance, in the context of EUDI Wallet there are several cases where working with JWKs is required on mobile side. |
Yeah, I understand that. I was not clear on what I mean by |
Introduce standalone JOSE support module with JWT/JWK/etc.
Support for JWK encoding/decoding can also be used afterwards in providers other than WebCrypto.
Full list of RFCs:
The text was updated successfully, but these errors were encountered: