Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
vsoftco committed Jul 14, 2020
1 parent 6cc2214 commit 8af801e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tests/test_kem.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def check_wrong_ciphertext(alg_name):
with oqs.KeyEncapsulation(alg_name) as kem:
public_key = kem.generate_keypair()
ciphertext, shared_secret_server = kem.encap_secret(public_key)
wrong_ciphertext = bytes(random.getrandbits(8) for _ in range(kem.details['length_ciphertext']))
wrong_ciphertext = bytes(random.getrandbits(8) for _ in range(len(ciphertext)))
shared_secret_client = kem.decap_secret(wrong_ciphertext)
assert shared_secret_client != shared_secret_server

Expand Down
6 changes: 3 additions & 3 deletions tests/test_sig.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def check_wrong_message(alg_name):
message = bytes(random.getrandbits(8) for _ in range(100))
public_key = sig.generate_keypair()
signature = sig.sign(message)
wrong_message = bytes(random.getrandbits(8) for _ in range(100))
wrong_message = bytes(random.getrandbits(8) for _ in range(len(message)))
assert not (sig.verify(wrong_message, signature, public_key))


Expand All @@ -52,7 +52,7 @@ def check_wrong_signature(alg_name):
message = bytes(random.getrandbits(8) for _ in range(100))
public_key = sig.generate_keypair()
signature = sig.sign(message)
wrong_signature = bytes(random.getrandbits(8) for _ in range(sig.details['length_signature']))
wrong_signature = bytes(random.getrandbits(8) for _ in range(len(signature)))
assert not (sig.verify(message, wrong_signature, public_key))


Expand All @@ -68,7 +68,7 @@ def check_wrong_public_key(alg_name):
message = bytes(random.getrandbits(8) for _ in range(100))
public_key = sig.generate_keypair()
signature = sig.sign(message)
wrong_public_key = bytes(random.getrandbits(8) for _ in range(sig.details['length_public_key']))
wrong_public_key = bytes(random.getrandbits(8) for _ in range(len(public_key)))
assert not (sig.verify(message, signature, wrong_public_key))


Expand Down

0 comments on commit 8af801e

Please sign in to comment.