stealth / greenday

DGC forensics
14 stars 0 forks source link

json value given in README.md seems to be invalid #1

Closed saschaludwig closed 3 years ago

saschaludwig commented 3 years ago

Hi

i tried the given json string with the following python code, but I always get an VC_HC_COSE_TAG_INVALID error in CWA.

import cbor2, base45, zlib, json, pyqrcode

data = '{ "ver": "1.2.1", "nam": { "fn": "RAMBO", "gn": "John", "fnt": "RAMBO", "gnt": "John" }, "dob": "1990-11-11", "v":[{"tg": "840539006", "vp": "1119349007", "mp": "EU/1/20/1528", "ma": "ORG-7350", "dn": 2, "sd": 2, "dt" : "2021-04-21", "co": "DE", "is": "c-skills","ci": "urn:uvci:01:NL:PlA8UWS60Z4RZXVALl6GAZ" }]}'
j = json.loads(data)
qrdata = b"HC1:"+base45.b45encode(zlib.compress(cbor2.encoder.dumps(j)))
qr = pyqrcode.create(qrdata)
print(qr.terminal())

What am I missing, or is the json format wrong?

saschaludwig commented 3 years ago

Okay, I realized that I missed the CBORTag. So I modified the code:

qrdata = b"HC1:"+base45.b45encode(zlib.compress(cbor2.dumps(cbor2.CBORTag(18, j))))

But that gives me an VC_HC_COSE_MESSAGE_INVALID.

stealth commented 3 years ago

Hi! The json is correct. I used https://github.com/ehn-dcc-development/ehn-sign-verify-python-trivial with small patches to make the pip modules load. I think the problem is that you miss to cbor tags 1,4,6, -260 which is expected by the kotlin cose code, although the tags are unused.

saschaludwig commented 3 years ago

JFI: Found out that the QR Code from the readme doesn't work on iOS but works on Android. iOS Error Message while scanning the QR Code from the readme: VC_JSON_SCHEMA_INVALID