Skip to content

Commit

Permalink
Not converting timestamp to python dates helps
Browse files Browse the repository at this point in the history
  • Loading branch information
silverdaz committed Jul 11, 2024
1 parent 876cdcb commit 40099da
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 0 additions & 2 deletions crypt4gh/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,6 @@ def retrieve_private_key(args, generate=False):
return get_private_key(seckeypath, cb)

def make_timestamp(date):
# if date.startswith('+'):
# return int((datetime.datetime.now(datetime.UTC) + parse_deltatime(date[1:])).timestamp())
LOG.debug("expiration: %s", date)
return int(datetime.datetime.fromisoformat(date).timestamp())

Expand Down
3 changes: 2 additions & 1 deletion crypt4gh/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ def make_packet_timestamp(timestamp):
def parse_timestamp_packet(packet):
if len(packet) != 8:
raise ValueError('Invalid timestamp packet')
return datetime.datetime.fromtimestamp(int.from_bytes(packet, byteorder='little'), datetime.UTC)
# return datetime.datetime.fromtimestamp(int.from_bytes(packet, byteorder='little'))
return int.from_bytes(packet, byteorder='little')

# -------------------------------------
# link packet
Expand Down
5 changes: 3 additions & 2 deletions crypt4gh/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import collections
from itertools import chain
import datetime
import time

from nacl.bindings import (crypto_aead_chacha20poly1305_ietf_encrypt,
crypto_aead_chacha20poly1305_ietf_decrypt)
Expand Down Expand Up @@ -397,8 +398,8 @@ def decrypt(keys, infile, outfile, sender_pubkey=None, offset=0, span=None):

session_keys, edit_list, expiration, uri = header.deconstruct(infile, keys, sender_pubkey=sender_pubkey)

if expiration and (datetime.datetime.fromtimestamp(time.time()) > expiration):
raise ValueError(f'Expired on {expiration}')
if expiration and (time.time() > expiration): # now > expiration_timestamp
raise ValueError(f'Expired on {datetime.datetime.fromtimestamp(expiration)}')

# Infile in now positioned at the beginning of the data portion
# or we fetch the data portion from the URI.
Expand Down

0 comments on commit 40099da

Please sign in to comment.