Code Monkey home page Code Monkey logo

dcc-green-pass-decoder's Introduction


Markdownify

EU Digital COVID Certificate decoder

A Progressive Web App that can read EU Digital COVID Certificate QR-codes.

This is just a toy app I made while being curious to look at what's inside my own Green Certificate. Unlike other decoders available online, it doesn't require to set up dependencies or upload the certificate to a remote server. It can be used by average users without having to interact with the terminal (scary! hacker stuff! πŸ±β€πŸ’»).

All the processing is done locally and your certificate never leaves your device.



Features

  • No need to set up an environment: just load the page and you're ready to scan! 😎
  • Progressive Web App, can work offline and be installed on many devices like a native app.
  • Can both display the raw certificate or parse it to make the fields human readable.
  • Can both load the QR-code from an existing file or scan it using the device camera
  • Signature validation. A list of the certificates used for this purpose can be found in docs/certificates.md

How to edit

Clone the repository:

git clone https://github.com/floysh/DCC-green-pass-decoder

Install dependencies:

cd ./DCC-green-pass-decoder
npm install

Run the watcher:

npm run watch

this will generate new builds of the JS bundle whenever it detects something has changed in the src/ folder.

Then start your favorite local webserver in public/

When you're satisfied with the edits, stop the watcher and make an optimized JS bundle:

npm run build

This will minify the javascript and reduce the bundle.js file size.


How does it work

Decoding the QR-code

It's fairly easy to decode an EU DCC. The official EU repository states that the certificate is a COSE message / CBOR Web Token (CWT).

The COSE message structure is the following:

  • protected (signed) header: this field contains some information about the certificate signature. The only interesting information here is the Key Identifier (KID), which can be used by a validator app to efficiently retrieve the correct key that needs to be used in the signature validation step.
  • unprotected header: non-critical information about the CWT may be stored here. This field is not signed, so its integrity cannot be guaranteed. It was empty on all the certificates I tried to decode.
  • payload: this field is a CBOR map containing the actual DCC JSON document.
  • signature: the signature is what ensures the authenticity of the certificate.

A more detailed description of this structure can be found on the Electronic Health Certificate Specification repository from the European Health Network.

This is the encoding pipeline:

docs/overview.png

so decoding can be done by following the same steps in reverse:

  • Read the QR-code
    • acquire an image of the code
    • decode it to string. It should be something like HC1:XXXXXXX...
  • Decode the certificate string
    • Remove the HC1: header
    • Decode with a Base45 decoder.
    • Decompress with zlib deflate to obtain the COSE message
  • Extract the certificate
    • Deserialize the COSE message.
    • Extract the COSE payload. It's a CBOR document
    • Decode the CBOR
      • The certificate JSON document can be found in the payload, at claim -260.

Signature validation

This was a bit more time consuming, mainly because there's no documented way to get some required files and I'm by no means an expert in dealing with crypto algorithms or digital signatures.

Further details on how this feature has been implemented can be found in docs/signature-validation.md.

Resources

dcc-green-pass-decoder's People

Contributors

cavebird avatar edo0 avatar floysh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dcc-green-pass-decoder's Issues

Error scanning Safari

Error Safari Version 15.1 (17612.2.9.1.20) Scanning does not work! Same problem with iphone and iPad ...

Adding a license

Thanks for creating such a clean project to read out Covid certificates. I'd like to use it as a basis for a small webapp. Could you please add a license to your code to make that possible?

Extarcting KID and signature

Hi,
where did you find documentation to implement this line of code?

let kid = cbor.decode(protected_header).get(4)

Does it exist similar documentation for decoding signature? I would like to manually decode it, rather than using a ready-made "signature.verify()" function copied from somewhere, by comparing its contents to the certificates found here:

https://raw.githubusercontent.com/lovasoa/sanipasse/master/src/assets/Digital_Green_Certificate_Signing_Keys.json

Its possible to create an script of encoding pipeline described in the readme?

It has helped me to understand more about how Qr reading works.

I am testing it with valid QR issued in Spain and your application returns error: "This is not an EU Digital COVID Certificate". What is the reason?

I work as a programmer in a small laboratory in Spain. Until now we have been performing rapid antigen tests and it was not necessary to issue qr codes, but the results on paper were enough. Now my boss has asked me to also generate the qr code with the test result so that the customer can use it, but the truth is that I can't find simple documentation for it.

As I see you have experience with it, I wonder if you could give me some repository references or some help with it.

I need my own script like this link: https://dgc.a-sit.at/ehn/
That is a private source and I cant set our owns certificates.

I want to do my best to avoid bugs and problems with my boss :)

Thank you very much.

Not working locally due to inability to load .json file of certificates

The app does not work if run locally, due to inability to load certificate using file:/// protocol; but certificates are not necessary to view the data, of course they are only needed to validate signature.
I would like to modify the source by myself, but in src folder I can't find index.html, so I don't understand how the app works.

Swiss Government Regulated CA 02 (CH) not trusted

A known good certificate with this KID was marked bad by this app:

'''
Signature details
Algorithm: PS256 (RSASSA-PSS w/ SHA-256)
Key identifier (KID): rTEJEs6D1ik=
Signer: CC_CH01_RecoveredCertificate_13_10 (CH), issued by Swiss Government Regulated CA 02 (CH)
'''

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.