GithubHelp home page GithubHelp logo

aguilaair / vacdec Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hqjatu/vacdec

0.0 1.0 0.0 70 KB

Python script to decode the EU Covid-19 vaccine certificate

License: The Unlicense

Python 100.00%

vacdec's Introduction

vacdec

Python script to decode the EU Covid-19 vaccine certificate, as specified by the EU.

This script takes an image with a QR code of a vaccine certificate as the parameter and will show the certificate's content. It will also validate the digital signature.

The code is very short and should provide an easy way to understand how these certificates are encoded:

  • The QR code encodes a string starting with "HC1:".
  • The string following "HC1:" is base45 encoded.
  • Decoding the base45 leads to zlib-compressed data.
  • Decompression leads to a CBOR Web Token structure.

Setup

You will need:

  • pillow for image handling
  • pyzbar for reading QR-code
  • base45, cbor2 and cose packages for RFC-8152 data structure reading
  • Additionally, you need zbar
    • For Mac OS X, it can be installed via brew install zbar
    • Debian systems via apt install libzbar0. Source
    • Fedora / Red Hat dnf install zbar

Install them via your distribution or via pip:

pip install -r requirements.txt

usage

Run:

./vacdec --image-file [image]

[image] can be an image in any format pillow supports, including of course PNG and JPG.

Example run:

$ ./vacdec samples/Sweden-2.png
2021-08-05 19:33:39,927 [INFO ]  COVID certificate signed with X.509 certificate.
2021-08-05 19:33:39,927 [INFO ]  X.509 in DER form has SHA-256 beginning with: 5f74910195c5cecb
2021-08-05 19:36:24,800 [INFO ]  Found the key from DB!
2021-08-05 19:36:24,820 [INFO ]  Signature verified ok
2021-08-05 19:33:39,928 [INFO ]  Certificate as JSON: {
  "1": "SE",
  "4": 1625305802,
  "6": 1623750603,
  "-260": {
    "1": {
      "t": [
        {
          "ci": "URN:UVCI:01:SE:EHM/TARN89875439877",
          "co": "SE",
          "is": "Swedish eHealth Agency",
          "nm": "Roche LightCycler qPCR",
          "sc": "2021-06-15 09:24:02+00:00",
          "tc": "Arlanda Airport Covid Center 1",
          "tg": "840539006",
          "tr": "260415000",
          "tt": "LP6464-4"
        }
      ],
      "dob": "1958-11-11",
      "nam": {
        "fn": "Lövström",
        "gn": "Oscar",
        "fnt": "LOEVSTROEM",
        "gnt": "OSCAR"
      },
      "ver": "1.3.0"
    }
  }
}

EU Digital COVID Certificate

(Note: formerly known as Digital Green Certificate)

Specifications

What's in a EU Digital COVID/Green Certificate?

Sample data

Digital Green Certificate Gateway (DGCG) samples for all participating countries: https://github.com/eu-digital-green-certificates/dgc-testdata

Digital Signature X.509 Certificates

Fetch Signature Certificates in PEM-format

There is a tool fetch-signing-certificates.py which will read the entire list of signing certificates from Austria's endpoint.

Results are stored (by default) into directory certs/.

author

Written by Hanno Böck. Signature verification by Jari Turkia.

vacdec's People

Contributors

angelos avatar guerda avatar hannob avatar hqjatu avatar jugmac00 avatar landswellsong avatar

Watchers

 avatar

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.