siddolo / eHealthDecoder

eHealth EU Digital Green Certificate Decoder
GNU General Public License v3.0
16 stars 4 forks source link

unable to decode base45 #2

Open zeph opened 3 years ago

zeph commented 3 years ago

decoding the base45 string obtained by my tool https://github.com/zeph/qr_encode_disaster_recovery from the Green Pass I just got on my Immuni App fails miserably with a decode error... same happens attempting with the official test data at this address https://github.com/eu-digital-green-certificates/dgc-testdata/tree/main/IT/2DCode/raw (at least with example 1.json)

any luck?

zeph commented 3 years ago

after the pip install -f requirements.txt present in this project... $ curl https://raw.githubusercontent.com/eu-digital-green-certificates/dgc-testdata/main/IT/2DCode/raw/1.json|jq .BASE45|base45 --decode

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  8093  100  8093    0     0  64934      0 --:--:-- --:--:-- --:--:-- 65266
Traceback (most recent call last):
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 32, in b45decode
    buf = [BASE45_CHARSET.index(c) for c in s]
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 32, in <listcomp>
    buf = [BASE45_CHARSET.index(c) for c in s]
ValueError: substring not found

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/bin/base45", line 8, in <module>
    sys.exit(main())
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/cli.py", line 28, in main
    sys.stdout.buffer.write(b45decode(data.decode()))
  File "/home/gms/tmp/local/qr_encode_disaster_recovery/.p3/lib/python3.9/site-packages/base45/__init__.py", line 45, in b45decode
    raise ValueError("Invalid base45 string")
ValueError: Invalid base45 string
zeph commented 3 years ago

it got me base45 0.2.1 ...I'll open a ticket there too if it looks more appropriate

Verg92 commented 3 years ago

Do I need to put all the text from the QR, as argument? Or only a portion? If I put all the text... image

PS: Esiste un modo invece per generare la stringa, dal Json?

siddolo commented 3 years ago

Do I need to put all the text from the QR, as argument? Or only a portion? If I put all the text...

according to "2D Barcode Specifications" the string must start with "HC1" or "HC2". What did you use to read your QR?

siddolo commented 3 years ago

PS: Esiste un modo invece per generare la stringa, dal Json?

Implementare gli step al contrario. Chiaramente non puoi generare una firma valida poichè non disponi delle chiavi private.