From a7eb22626e4e5d1ae2778bd0b06ba7fef54fe952 Mon Sep 17 00:00:00 2001 From: Sergi Delgado Segura Date: Mon, 16 Dec 2019 11:58:14 +0100 Subject: [PATCH] Some fixes based on review comments --- common/cryptographer.py | 4 ++-- common/tools.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/cryptographer.py b/common/cryptographer.py index 18cca23..512fff6 100644 --- a/common/cryptographer.py +++ b/common/cryptographer.py @@ -124,7 +124,7 @@ class Cryptographer: raise ValueError("Wrong return type. Return type must be 'hex' or 'bytes'") 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 else: @@ -138,7 +138,7 @@ class Cryptographer: @staticmethod def verify(message, signature, pk): 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 if isinstance(signature, str): diff --git a/common/tools.py b/common/tools.py index d89bbdf..66aeb2c 100644 --- a/common/tools.py +++ b/common/tools.py @@ -2,4 +2,4 @@ import re 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