Skip to content

Commit

Permalink
Updated pypdf dependency and fixed expected filename for bulletin board.
Browse files Browse the repository at this point in the history
  • Loading branch information
mi-ki committed Dec 9, 2023
1 parent 70bb66b commit 9460cc6
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ dependencies:
- gmpy2
- pyqt5
- python-gnupg
- PyPDF2
- pypdf
- argparse

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ pycryptodome
gmpy2
pyqt5
python-gnupg
PyPDF2
pypdf
argparse

12 changes: 6 additions & 6 deletions src/polyas_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright © 2019-2023, Karlsruhe Institute of Technology (KIT), Maximilian Noppel, Christoph Niederbudde

import logging
import PyPDF2
import pypdf
import argparse
import hashlib
import json
Expand Down Expand Up @@ -624,9 +624,9 @@ def verify_second_device_public_parameters(path, phase1=None):
keygen = load_key_gen_election_key(path)
verificationKey = ""
try:
verificationKey = loadSecureJSON(path, "bbox-ballotbox-key-cp.json", sequence=False)
verificationKey = loadSecureJSON(path, "BBox-ballotbox-key-CP.json", sequence=False)
except Exception:
logger.info("No file with verification key found: bbox-ballotbox-key-cp.json")
logger.info("No file with verification key found: BBox-ballotbox-key-CP.json")
if phase1:
phase1.setValue(100)
phase1.setStyleSheet(redStyle)
Expand Down Expand Up @@ -682,7 +682,7 @@ def get_signature_if_valid(receiptPath: str, file: str, key: str, logTo=None):
Returns fingerprint if the file is valid, else None
"""
f = open(os.path.join(receiptPath, file), 'rb')
reader = PyPDF2.PdfReader(f)
reader = pypdf.PdfReader(f)
receipt = reader.pages[0].extract_text().replace("\n", "")
f.close()
fingerprintList = re.findall(r".*BEGIN FINGERPRINT----- ?([0-9|a-f]*) ?-----END FINGERPRINT.*", receipt)
Expand All @@ -706,11 +706,11 @@ def verify_receipts(path, phase1=None, log=False, logTo=None):
verificationKey = None
receiptPath = os.path.join(path, "receipts")
try:
verificationKey = loadSecureJSON(path, "bbox-ballotbox-key-cp.json", sequence=False)
verificationKey = loadSecureJSON(path, "BBox-ballotbox-key-CP.json", sequence=False)
if phase1:
phase1.setValue(25)
except Exception:
logger.info("No file with verification key found: bbox-ballotbox-key-cp.json")
logger.info("No file with verification key found: BBox-ballotbox-key-CP.json")
if phase1:
phase1.setValue(100)
phase1.setStyleSheet(redStyle)
Expand Down
4 changes: 2 additions & 2 deletions src/test/integrationtests.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ def testValidFingerprint(self):

def testValidReceipt(self):
path = "../data/full_doc_ext"
key = loadSecureJSON(path, "bbox-ballotbox-key-cp.json")
key = loadSecureJSON(path, "BBox-ballotbox-key-CP.json")
gpg = initialize_gpg([key])
self.assertNotEqual(get_signature_if_valid(path + "/receipts", "b1.pdf", gpg, key), None)

def testInvalidReceipt(self):
path = "../data/full_doc_ext"
key = loadSecureJSON(path, "bbox-ballotbox-key-cp.json")
key = loadSecureJSON(path, "BBox-ballotbox-key-CP.json")
gpg = initialize_gpg([key])
self.assertEqual(get_signature_if_valid(path + "/receipts", "b2.pdf", gpg, key), None)

Expand Down

0 comments on commit 9460cc6

Please sign in to comment.