Skip to content

Commit

Permalink
Fix COSE serialization
Browse files Browse the repository at this point in the history
This might happen when parsing credential responses from OID4VCI in vc-k
  • Loading branch information
nodh committed Dec 10, 2024
1 parent 1f2acdc commit 685a7b4
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,22 @@ class CoseSignedSerializer<P : Any?>(
value.protectedHeader
)
encodeNullableSerializableElement(descriptor, 1, CoseHeader.serializer(), value.unprotectedHeader)
if (value.payload != null && value.payload::class != ByteArray::class) {
encodeNullableSerializableElement(
buildTag24SerialDescriptor(),
2,
ByteStringWrapperSerializer(parameterSerializer),
ByteStringWrapper(value.payload)
)
if (value.payload != null) {
if (value.payload::class == ByteArray::class) {
encodeNullableSerializableElement(
descriptor,
2,
ByteArraySerializer(),
value.payload as ByteArray
)
} else {
encodeNullableSerializableElement(
buildTag24SerialDescriptor(),
2,
ByteStringWrapperSerializer(parameterSerializer),
ByteStringWrapper(value.payload)
)
}
} else {
encodeNullableSerializableElement(descriptor, 2, parameterSerializer, value.payload)
}
Expand Down

0 comments on commit 685a7b4

Please sign in to comment.