giuseppeM99 / GreenPassVerifyBot

A telegram bot to verify the DGC/DCC QR Code
GNU General Public License v3.0
15 stars 8 forks source link

HOW TO DECODE KID #3

Closed fedelake closed 3 years ago

fedelake commented 3 years ago

Hi, I want try to generate the same QR code of a valid Greenpass but once decoded the info, when recoded the QR generated is different... I have the header and the signature.

giuseppeM99 commented 3 years ago

First of all: you cannot generate a valid greenpass as you don't have the private keys for signing it You can reencode the decoded QR code back If you want to sign your own certifiate, check here for an example

fedelake commented 3 years ago

First of all: you cannot generate a valid greenpass as you don't have the private keys for signing it You can reencode the decoded QR code back If you want to sign your own certifiate, check here for an example

ok tnx, but when i lunch the command: qrdecode photo.jpg | python3 ./hc1_verify -v -U - i get this error on linux:

Command 'qrdecode' not found

what could be?

giuseppeM99 commented 3 years ago

you don't have qrdecode installed, i used zbarimg --raw -q --noxml instead of qrdecode you may need to install some package depending on your distro

fedelake commented 3 years ago

you don't have qrdecode installed, i used zbarimg --raw -q --noxml instead of qrdecode you may need to install some package depending on your distro

wow perfect! ok now i got the KID! And now what i can do to reencode it correctly?

giuseppeM99 commented 3 years ago

I'm sorry i don't understand, what do you mean by KID?

fedelake commented 3 years ago

I'm sorry i don't understand, what do you mean by KID?

Is the signature key

giuseppeM99 commented 3 years ago

So, if you have a cose object with the signing key (as you get after CoseMessage.decode(cose_document) and assigning it a key, as at greenpass.py#L155 you can manually encode the certificate

message = [
                      cose.phdr_encoded,
                      cose.uhdr_encoded,
                      cose.payload,
                      cose.signature
                   ]
encoded_message = cbor2.dumps(cbor2.CBORTag(cose.cbor_tag, message), default=cose._custom_cbor_encoder)
certificate = b45encode(zlib.compress(encoded_message))
fedelake commented 3 years ago

Ok tnx 👍