From 8ad32e61d852a48fccbf5ad26aa59618bfbf6657 Mon Sep 17 00:00:00 2001 From: PascalDR Date: Fri, 9 Feb 2024 12:53:15 +0100 Subject: [PATCH] fix: random crash for missing y coordinate --- pymdoccbor/mso/verifier.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/pymdoccbor/mso/verifier.py b/pymdoccbor/mso/verifier.py index 7ccc4b8..a314491 100644 --- a/pymdoccbor/mso/verifier.py +++ b/pymdoccbor/mso/verifier.py @@ -2,7 +2,7 @@ import cryptography import logging -from pycose.keys import CoseKey, EC2Key +from pycose.keys import EC2Key from pycose.messages import Sign1Message from pymdoccbor.exceptions import ( @@ -52,7 +52,7 @@ def __init__(self, data: cbor2.CBORTag) -> None: f"MsoParser only supports raw bytes and list, a {type(data)} was provided" ) - self.object.key: CoseKey | None = None + self.object.key = None self.public_key: cryptography.hazmat.backends.openssl.ec._EllipticCurvePublicKey = None self.x509_certificates: list = [] @@ -130,9 +130,8 @@ def load_public_key(self) -> None: key = EC2Key( crv=settings.COSEKEY_HAZMAT_CRV_MAP[self.public_key.curve.name], - x=self.public_key.public_numbers().x.to_bytes( - settings.CRV_LEN_MAP[self.public_key.curve.name], 'big' - ) + x=self.public_key.public_numbers().x.to_bytes(settings.CRV_LEN_MAP[self.public_key.curve.name], 'big'), + y=self.public_key.public_numbers().y.to_bytes(settings.CRV_LEN_MAP[self.public_key.curve.name], 'big') ) self.object.key = key