mirror of
https://github.com/aljazceru/python-teos.git
synced 2025-12-17 14:14:22 +01:00
Some fixes based on review comments
This commit is contained in:
@@ -124,7 +124,7 @@ class Cryptographer:
|
|||||||
raise ValueError("Wrong return type. Return type must be 'hex' or 'bytes'")
|
raise ValueError("Wrong return type. Return type must be 'hex' or 'bytes'")
|
||||||
|
|
||||||
if not isinstance(sk, ec.EllipticCurvePrivateKey):
|
if not isinstance(sk, ec.EllipticCurvePrivateKey):
|
||||||
logger.error("Wrong public key.")
|
logger.error("The value passed as sk is not a private key (EllipticCurvePrivateKey).")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
else:
|
else:
|
||||||
@@ -138,7 +138,7 @@ class Cryptographer:
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def verify(message, signature, pk):
|
def verify(message, signature, pk):
|
||||||
if not isinstance(pk, ec.EllipticCurvePublicKey):
|
if not isinstance(pk, ec.EllipticCurvePublicKey):
|
||||||
logger.error("Wrong public key.")
|
logger.error("The value passed as pk is not a public key (EllipticCurvePublicKey).")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if isinstance(signature, str):
|
if isinstance(signature, str):
|
||||||
|
|||||||
@@ -2,4 +2,4 @@ import re
|
|||||||
|
|
||||||
|
|
||||||
def check_sha256_hex_format(value):
|
def check_sha256_hex_format(value):
|
||||||
return isinstance(value, str) and re.search(r"^[0-9A-Fa-f]{64}$", value) is not None
|
return isinstance(value, str) and re.match(r"^[0-9A-Fa-f]{64}$", value) is not None
|
||||||
|
|||||||
Reference in New Issue
Block a user