-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hello
The link to the documentation isn't working: https://edgeengineer.github.io/cbor/documentation/cbor/
Also, I'm having some problems trying to encode a tagged value. I'm working on the new EU digital ID stuff, and I've come this far:
D8 18 # tag(24)
84 # array(4)
74 # text(20)
44657669636541757468656E7469636174696F6E # "DeviceAuthentication"
83 # array(3)
F6 # primitive(22)
F6 # primitive(22)
83 # array(3)
76 # text(22)
5175334D756B7434777768377670386B372D4B715141 # "Qu3Mukt4wwh7vp8k7-KqQA"
1A 68F8A7AF # unsigned(1761126319)
1A 68F8A863 # unsigned(1761126499)
71 # text(17)
65752E6575726F70612E65632E61762E31 # "eu.europa.ec.av.1"
D8 18 # tag(24)
A0 # map(0)
By doing this:
let deviceAuthentication = CBORItem.array([
CBORItem.textString("DeviceAuthentication"),
CBORItem.array([
CBORItem.null,
CBORItem.null,
CBORItem.array([
CBORItem.textString(qrPayload.mdocGeneratedNonce),
CBORItem.unsignedInt(qrPayload.validFrom),
CBORItem.unsignedInt(qrPayload.validTo)
])
]),
CBORItem.textString(Self.idDocType), // Document type
CBORItem.tagged(24, ArraySlice<UInt8>(CBORItem.map([]).encode()))
])
func dataToHexString(_ data: Data) -> String {
return data.map { String(format: "%02hhx", $0) }.joined()
}
let encoded = CBORItem.tagged(24, ArraySlice<UInt8>(deviceAuthentication.encode())).encode()
let cborData = Data(encoded)
print(dataToHexString(cborData))Which I am pretty sure should result in this - at least according to the documentation I've been given.
D8 18 # tag(24)
58 51 # bytes(81)
847444657669636541757468656E7469636174696F6E83F6F683765175334D756B7434777768377670386B372D4B7151411A68F8A7AF1A68F8A8637165752E6575726F70612E65632E61762E31D81841A0 # "\x84tDeviceAuthentication\x83\xF6\xF6\x83vQu3Mukt4wwh7vp8k7-KqQA\u001Ah\xF8\xA7\xAF\u001Ah\xF8\xA8cqeu.europa.ec.av.1\xD8\u0018A\xA0"
It seems like the entire thing isn't being wrapped in a tagged bstr like it should, but somehow prints as one object. I'm very new to CBOR, so maybe I did something wrong. Or is there a problem with the encoder? I specifically want the CBOR object to be encoded in a tag 24, as the standard requires it.
Metadata
Metadata
Assignees
Labels
No labels