Skip to content

Commit

Permalink
fix conversion from int to bool in assert statement, thereby fixing t…
Browse files Browse the repository at this point in the history
…he error handling/reporting

Signed-off-by: Bruno Vavala <[email protected]>
  • Loading branch information
bvavala committed Apr 23, 2024
1 parent 9144ca6 commit 3d28539
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/crypto/sig_public_key.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ int pcrypto::sig::PublicKey::VerifySignature(
return -1;

// Verify
// ECDSA_do_verify() returns 1 for a valid sig, 0 for an invalid sig and -1 on error
return ECDSA_do_verify(hash.data(), hash.size(), sig.get(), key_);
} // pcrypto::sig::PublicKey::VerifySignature

Expand Down
5 changes: 3 additions & 2 deletions python/pdo/test/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def verify_store_signature(store_response, duration, verifying_key) :
decoded_signature = base64.urlsafe_b64decode(store_response['signature'])

vk = crypto.SIG_PublicKey(verifying_key)
# VerifySignature returns 1 for a valid sig, 0 for an invalid sig and -1 on error
return vk.VerifySignature(signing_hash, decoded_signature)

# -----------------------------------------------------------------
Expand All @@ -76,7 +77,7 @@ def verify_store_signature(store_response, duration, verifying_key) :
result = client.store_blocks([block_data], duration=default_duration)
assert result

assert verify_store_signature(result, default_duration, client.verifying_key)
assert (1 == verify_store_signature(result, default_duration, client.verifying_key))

block_ids = result['block_ids']
assert block_ids and len(block_ids) == 1
Expand Down Expand Up @@ -109,7 +110,7 @@ def verify_store_signature(store_response, duration, verifying_key) :
result = client.store_blocks(block_data, duration=default_duration)
assert result

assert verify_store_signature(result, default_duration, client.verifying_key)
assert (1 == verify_store_signature(result, default_duration, client.verifying_key))

block_ids = result['block_ids']
logger.info('RESULT: %s', result)
Expand Down

0 comments on commit 3d28539

Please sign in to comment.