Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_check_key_value_matches_cert_public_key overwrites public_key variable for ECDSA #244

Open
msetina opened this issue Mar 16, 2024 · 1 comment

Comments

@msetina
Copy link
Contributor

msetina commented Mar 16, 2024

def _check_key_value_matches_cert_public_key(self, key_value, public_key, signature_alg: SignatureMethod):
        if signature_alg.name.startswith("ECDSA_") and isinstance(
            public_key.to_cryptography_key(), ec.EllipticCurvePublicKey
        ):
            ec_key_value = self._find(key_value, "dsig11:ECKeyValue")
            named_curve = self._find(ec_key_value, "dsig11:NamedCurve")
            public_key = self._find(ec_key_value, "dsig11:PublicKey")
            key_data = b64decode(public_key.text)[1:]
            x = bytes_to_long(key_data[: len(key_data) // 2])
            y = bytes_to_long(key_data[len(key_data) // 2 :])
            curve_class = self.known_ecdsa_curves[named_curve.get("URI")]

            pubk_curve = public_key.to_cryptography_key().public_numbers().curve
            pubk_x = public_key.to_cryptography_key().public_numbers().x
            pubk_y = public_key.to_cryptography_key().public_numbers().y

            return curve_class == pubk_curve and x == pubk_x and y == pubk_y

it overwrites public_key variable when getting "dsig11:PublicKey" from XML

@msetina
Copy link
Contributor Author

msetina commented Mar 16, 2024

fixed by #245

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant