Skip to content

_check_key_value_matches_cert_public_key overwrites public_key variable for ECDSA #244

Open
@msetina

Description

@msetina
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions