From a445c16f652696acf0e158b769af45e337131392 Mon Sep 17 00:00:00 2001 From: Daniel Kahn Gillmor Date: Fri, 11 Aug 2023 10:05:07 -0400 Subject: [PATCH] Avoid copy on raw pubkey objects These pubkey objects are immutable, as noted in https://github.com/pyca/cryptography/issues/9403, so it should be safe to just assign. --- pgpy/packet/packets.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pgpy/packet/packets.py b/pgpy/packet/packets.py index 49aa04c0..695392ee 100644 --- a/pgpy/packet/packets.py +++ b/pgpy/packet/packets.py @@ -1577,7 +1577,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()