Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/hazmat/primitives/asymmetric/cloudhsm.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ if you only need a subset of functionality.
... def __copy__(self) -> "CloudRSAPrivateKey":
... return self
...
... def __deepcopy__(self, memodict: dict) -> "CloudRSAPrivateKey":
... return self
...
>>> cloud_private_key = CloudRSAPrivateKey("creds", "key_id")
>>> sig = cloud_private_key.sign(b"message", PKCS1v15(), hashes.SHA256())
>>> isinstance(sig, bytes)
Expand Down
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/dh.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ def __copy__(self) -> DHPublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> DHPublicKey:
Copy link
Contributor

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 the memo as a second parameter as described on https://docs.python.org/3/library/copy.html#object.__deepcopy__ ?

Copy link
Member

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.

Copy link
Contributor

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.rst has a memodict (not sure if anything cares about if it has that name of memo, 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.

"""
Returns a deep copy.
"""


DHPublicKeyWithSerialization = DHPublicKey
DHPublicKey.register(rust_openssl.dh.DHPublicKey)
Expand Down Expand Up @@ -142,6 +148,12 @@ def __copy__(self) -> DHPrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> DHPrivateKey:
"""
Returns a deep copy.
"""


DHPrivateKeyWithSerialization = DHPrivateKey
DHPrivateKey.register(rust_openssl.dh.DHPrivateKey)
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/dsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ def __copy__(self) -> DSAPrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> DSAPrivateKey:
"""
Returns a deep copy.
"""


DSAPrivateKeyWithSerialization = DSAPrivateKey
DSAPrivateKey.register(rust_openssl.dsa.DSAPrivateKey)
Expand Down Expand Up @@ -142,6 +148,12 @@ def __copy__(self) -> DSAPublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> DSAPublicKey:
"""
Returns a deep copy.
"""


DSAPublicKeyWithSerialization = DSAPublicKey
DSAPublicKey.register(rust_openssl.dsa.DSAPublicKey)
Expand Down
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/ec.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,12 @@ def __copy__(self) -> EllipticCurvePrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> EllipticCurvePrivateKey:
"""
Returns a deep copy.
"""


EllipticCurvePrivateKeyWithSerialization = EllipticCurvePrivateKey
EllipticCurvePrivateKey.register(rust_openssl.ec.ECPrivateKey)
Expand Down Expand Up @@ -207,6 +213,12 @@ def __copy__(self) -> EllipticCurvePublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> EllipticCurvePublicKey:
"""
Returns a deep copy.
"""


EllipticCurvePublicKeyWithSerialization = EllipticCurvePublicKey
EllipticCurvePublicKey.register(rust_openssl.ec.ECPublicKey)
Expand Down
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/ed25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __copy__(self) -> Ed25519PublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> Ed25519PublicKey:
"""
Returns a deep copy.
"""


Ed25519PublicKey.register(rust_openssl.ed25519.Ed25519PublicKey)

Expand Down Expand Up @@ -125,5 +131,11 @@ def __copy__(self) -> Ed25519PrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> Ed25519PrivateKey:
"""
Returns a deep copy.
"""


Ed25519PrivateKey.register(rust_openssl.ed25519.Ed25519PrivateKey)
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/ed448.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ def __copy__(self) -> Ed448PublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> Ed448PublicKey:
"""
Returns a deep copy.
"""


if hasattr(rust_openssl, "ed448"):
Ed448PublicKey.register(rust_openssl.ed448.Ed448PublicKey)
Expand Down Expand Up @@ -126,6 +132,12 @@ def __copy__(self) -> Ed448PrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> Ed448PrivateKey:
"""
Returns a deep copy.
"""


if hasattr(rust_openssl, "x448"):
Ed448PrivateKey.register(rust_openssl.ed448.Ed448PrivateKey)
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/rsa.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ def __copy__(self) -> RSAPrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> RSAPrivateKey:
"""
Returns a deep copy.
"""


RSAPrivateKeyWithSerialization = RSAPrivateKey
RSAPrivateKey.register(rust_openssl.rsa.RSAPrivateKey)
Expand Down Expand Up @@ -139,6 +145,12 @@ def __copy__(self) -> RSAPublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> RSAPublicKey:
"""
Returns a deep copy.
"""


RSAPublicKeyWithSerialization = RSAPublicKey
RSAPublicKey.register(rust_openssl.rsa.RSAPublicKey)
Expand Down
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/x25519.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def __copy__(self) -> X25519PublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> X25519PublicKey:
"""
Returns a deep copy.
"""


X25519PublicKey.register(rust_openssl.x25519.X25519PublicKey)

Expand Down Expand Up @@ -118,5 +124,11 @@ def __copy__(self) -> X25519PrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> X25519PrivateKey:
"""
Returns a deep copy.
"""


X25519PrivateKey.register(rust_openssl.x25519.X25519PrivateKey)
12 changes: 12 additions & 0 deletions src/cryptography/hazmat/primitives/asymmetric/x448.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ def __copy__(self) -> X448PublicKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> X448PublicKey:
"""
Returns a deep copy.
"""


if hasattr(rust_openssl, "x448"):
X448PublicKey.register(rust_openssl.x448.X448PublicKey)
Expand Down Expand Up @@ -120,6 +126,12 @@ def __copy__(self) -> X448PrivateKey:
Returns a copy.
"""

@abc.abstractmethod
def __deepcopy__(self) -> X448PrivateKey:
"""
Returns a deep copy.
"""


if hasattr(rust_openssl, "x448"):
X448PrivateKey.register(rust_openssl.x448.X448PrivateKey)
14 changes: 14 additions & 0 deletions src/rust/src/backend/dh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,13 @@ 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::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -312,6 +319,13 @@ 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::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down
14 changes: 14 additions & 0 deletions src/rust/src/backend/dsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,13 @@ impl DsaPrivateKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -229,6 +236,13 @@ 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::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down
14 changes: 14 additions & 0 deletions src/rust/src/backend/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ impl ECPrivateKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -458,6 +465,13 @@ impl ECPublicKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pyclass(frozen, module = "cryptography.hazmat.primitives.asymmetric.ec")]
Expand Down
14 changes: 14 additions & 0 deletions src/rust/src/backend/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ impl Ed25519PrivateKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -161,6 +168,13 @@ impl Ed25519PublicKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymodule(gil_used = false)]
Expand Down
14 changes: 14 additions & 0 deletions src/rust/src/backend/ed448.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ impl Ed448PrivateKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -158,6 +165,13 @@ impl Ed448PublicKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymodule(gil_used = false)]
Expand Down
14 changes: 14 additions & 0 deletions src/rust/src/backend/rsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,6 +422,13 @@ impl RsaPrivateKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pymethods]
Expand Down Expand Up @@ -535,6 +542,13 @@ impl RsaPublicKey {
fn __copy__(slf: pyo3::PyRef<'_, Self>) -> pyo3::PyRef<'_, Self> {
slf
}

fn __deepcopy__<'p>(
slf: pyo3::PyRef<'p, Self>,
_memo: &pyo3::Bound<'p, pyo3::PyAny>,
) -> pyo3::PyRef<'p, Self> {
slf
}
}

#[pyo3::pyclass(
Expand Down
Loading
Loading