Skip to content

Undocumented API incompatibility in EC: renamed keyword argument in EllipticCurvePrivateKey.exchange() #10294

@MatthiasValvekens

Description

@MatthiasValvekens

Hi, I have the following snippet breaking on the latest version of cryptography (42.0.1):

        if isinstance(priv_key, EllipticCurvePrivateKey):
            ecdh_value = priv_key.exchange(
                ECDH(), peer_public_key=originator_pub_key
            )

Removing the usage of kwargs fixes it. Reproducible on Python 3.11, but probably the same issue exists everywhere (I can rerun my CI in fail-late mode if needed). From what I can tell, the breaking change was introduced here, in the initial migration of this code to Rust: f38eb4a#diff-868a141c8ba335a462dc768991ee88d95cad873c531d64b10a88385beac311b2R311, renaming peer_public_key to public_key. I see in the release notes for 42.0.1 that the sign function required a similar fix, so I suspect this was overlooked for similar reasons.

EDIT for completeness: the error raised is this one, on the call to exchange:

   TypeError: ECPrivateKey.exchange() got an unexpected keyword argument 'peer_public_key'

Thanks!

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