-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Support for copy.deepcopy keys #13759
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
Changes from 7 commits
7417a8e
087b6f1
de8775e
1f952b5
0c86c73
9659cf9
0d652a5
29630e2
1e25239
828c95a
71abca4
4bbab09
f1fea09
b830922
7fa39b8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -247,6 +247,17 @@ impl DHPrivateKey { | |
| fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> { | ||
| slf | ||
| } | ||
|
|
||
| fn __deepcopy__<'p>( | ||
| slf: pyo3::PyRef<'p, Self>, | ||
| _memo: &pyo3::Bound<'p, pyo3::types::PyDict>, | ||
|
||
| ) -> CryptographyResult<Self> { | ||
| let new_key = Self { | ||
|
||
| pkey: slf.pkey.clone(), | ||
| }; | ||
|
|
||
| Ok(new_key) | ||
| } | ||
| } | ||
|
|
||
| #[pyo3::pymethods] | ||
|
|
@@ -312,6 +323,17 @@ impl DHPublicKey { | |
| fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> { | ||
| slf | ||
| } | ||
|
|
||
| fn __deepcopy__<'p>( | ||
| slf: pyo3::PyRef<'p, Self>, | ||
| _memo: &pyo3::Bound<'p, pyo3::types::PyDict>, | ||
| ) -> CryptographyResult<Self> { | ||
| let new_key = Self { | ||
| pkey: slf.pkey.clone(), | ||
| }; | ||
|
|
||
| Ok(new_key) | ||
| } | ||
| } | ||
|
|
||
| #[pyo3::pymethods] | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -153,9 +153,22 @@ impl DsaPrivateKey { | |
| ) | ||
| } | ||
|
|
||
| fn __eq__(&self, other: pyo3::PyRef<'_, Self>) -> bool { | ||
|
||
| self.pkey.public_eq(&other.pkey) | ||
| } | ||
|
|
||
| fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> { | ||
| slf | ||
| } | ||
|
|
||
| fn __deepcopy__<'p>( | ||
| slf: pyo3::PyRef<'p, Self>, | ||
| _memo: &pyo3::Bound<'p, pyo3::types::PyDict>, | ||
| ) -> CryptographyResult<Self> { | ||
| Ok(Self { | ||
| pkey: slf.pkey.clone(), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[pyo3::pymethods] | ||
|
|
@@ -229,6 +242,15 @@ impl DsaPublicKey { | |
| fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> { | ||
| slf | ||
| } | ||
|
|
||
| fn __deepcopy__<'p>( | ||
| slf: pyo3::PyRef<'p, Self>, | ||
| _memo: &pyo3::Bound<'p, pyo3::types::PyDict>, | ||
| ) -> CryptographyResult<Self> { | ||
| Ok(Self { | ||
| pkey: slf.pkey.clone(), | ||
| }) | ||
| } | ||
| } | ||
|
|
||
| #[pyo3::pymethods] | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't the
__deepcopy__expected to take in thememoas a second parameter as described on https://docs.python.org/3/library/copy.html#object.__deepcopy__ ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oof yes, not sure how I missed this. Will send a fix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case you missed it, the version in
docs/hazmat/primitives/asymmetric/cloudhsm.rsthas amemodict(not sure if anything cares about if it has that name ofmemo, but I'd at least change it to match the name in the documentation. And also note that the parameter is missing in not just this one I commented on, but all the *.py files.