Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Be aware: Python example contains bugs on timestamps #78

Open
dh3wr opened this issue Jan 18, 2022 · 0 comments
Open

Be aware: Python example contains bugs on timestamps #78

dh3wr opened this issue Jan 18, 2022 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@dh3wr
Copy link

dh3wr commented Jan 18, 2022

Describe the bug

The calculation of the expiration timestamp is wrong in https://github.com/corona-warn-app/cwa-quicktest-onboarding/blob/master/src/testcenter_simulator/labsimulator.py starting line 86.

def dcc_cbor(self, certData, issuedAtTimestamp=None, expiredAfterSeconds=None ):
        if issuedAtTimestamp is None:
            issuedAtTimestamp = int(time())     # Wenn nichts angegeben, dann jetziger Zeitpunkt
        if expiredAfterSeconds is None:
            expiredAfterSeconds = 60 * 60 * 24  # Wenn nichts angegeben, 1 Tag Gültigkeit

Expected behaviour

  1. The expiration duration is 48 h, so 2 days. Not 1 day as in the example given
  2. The expiration time is not issuedTime expirationDuration , but sc + expirationDuration, so related to the sample collection

Steps to reproduce the issue

Implement the given example

Possible Fix

def dcc_cbor(certData, TestresultAtTimestamp=None, SCAtTimestamp=None, expiredAfterSeconds=None):
    if TestresultAtTimestamp is None:
        TestresultAtTimestamp = int(time.time())  # Wenn nichts angegeben, dann jetziger Zeitpunkt
    if SCAtTimestamp is None:
        SCAtTimestamp = int(time.time()) - (60 * 15)  # Wenn nichts angegeben, dann jetziger Zeitpunkt - 15 min
    if expiredAfterSeconds is None:
        expiredAfterSeconds = 60 * 60 * 24 * 2 # Wenn nichts angegeben, 2 Tage Gültigkeit

    ExpirationAtTimestamp = SCAtTimestamp + expiredAfterSeconds

    cborMap = {}
    cborMap[4] = ExpirationAtTimestamp # Ablaufzeitstempel
    cborMap[6] = TestresultAtTimestamp # Ausstellungszeitstempel = Zeitpunkt des Ergebnis-Eintragens

Additional context

The wiki is correct on this topic.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants