a-sit-plus / signum

Kotlin Multiplatform Crypto/PKI Library and ASN1 Parser + Encoder
https://a-sit-plus.github.io/signum/
Apache License 2.0
76 stars 6 forks source link

COSE Signed API #194

Open nodh opened 1 week ago

nodh commented 1 week ago

Adds a type parameter to CoseSigned. While not as thorough as for JwsSigned, it's still worth it to provide some form of guidance to clients as which payload to expect.

See also https://github.com/a-sit-plus/vck/pull/165

JesusMcCloud commented 1 week ago

Why does this behave differently from JwsSigned, that has the typed payload as property? should not the seriializer handle conversion from/to bytestringwrapper?

In VCK, there's bytestringwrapper all over the place, i think we can do away with it and add this wrapping logic into the serializer, while we're at it

JesusMcCloud commented 1 week ago

@n0900 can this be made more convenient: as in: directly pass the typed payload to the constructor and have the serializer handle the byte string wrapping? I know it's different from your serialization foo, because it can by any type, but still…

nodh commented 1 week ago

Best I can do with my knowledge of kotlinx serialization ... CoseSignedSerializer can't handle the payload directly, because it doesn't know about the type of the payload, since it's referenced by annotation on CoseSigned. In contrast, JwsSigned itself is not annotated with @Serializable, so it is easier there. I'm happy for any suggestions on how to solve the shortcomings.