Skip to content

Commit

Permalink
Avoid copy on raw pubkey objects
Browse files Browse the repository at this point in the history
These pubkey objects are immutable, as noted in
pyca/cryptography#9403, so it should be safe to just
assign.
  • Loading branch information
dkg committed Aug 18, 2023
1 parent 921f667 commit 522201a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pgpy/packet/packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1578,7 +1578,7 @@ def _extract_pubkey(self, pk: PubKey) -> None:
elif isinstance(self.keymaterial, (NativeEdDSAPub, NativeCFRGXPub)):
if not isinstance(pk.keymaterial, (NativeEdDSAPub, NativeCFRGXPub)):
raise TypeError(f"Expected CFRG public key, got {type(pk.keymaterial)} instead")
pk.keymaterial._raw_pubkey = copy.copy(self.keymaterial._raw_pubkey)
pk.keymaterial._raw_pubkey = self.keymaterial._raw_pubkey

pk.update_hlen()

Expand Down

0 comments on commit 522201a

Please sign in to comment.