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
2 changes: 1 addition & 1 deletion src/rust/src/asn1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn encode_dss_signature(
Ok(pyo3::types::PyBytes::new(py, &result).to_object(py))
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.asn1")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.asn1")]
struct TestCertificate {
#[pyo3(get)]
not_before_tag: u8,
Expand Down
6 changes: 3 additions & 3 deletions src/rust/src/backend/dh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ use foreign_types_shared::ForeignTypeRef;

const MIN_MODULUS_SIZE: u32 = 512;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.dh")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.dh")]
struct DHPrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.dh")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.dh")]
struct DHPublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.dh")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.dh")]
struct DHParameters {
dh: openssl::dh::Dh<openssl::pkey::Params>,
}
Expand Down
3 changes: 3 additions & 0 deletions src/rust/src/backend/dsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::exceptions;
use foreign_types_shared::ForeignTypeRef;

#[pyo3::prelude::pyclass(
frozen,
module = "cryptography.hazmat.bindings._rust.openssl.dsa",
name = "DSAPrivateKey"
)]
Expand All @@ -16,6 +17,7 @@ struct DsaPrivateKey {
}

#[pyo3::prelude::pyclass(
frozen,
module = "cryptography.hazmat.bindings._rust.openssl.dsa",
name = "DSAPublicKey"
)]
Expand All @@ -24,6 +26,7 @@ struct DsaPublicKey {
}

#[pyo3::prelude::pyclass(
frozen,
module = "cryptography.hazmat.bindings._rust.openssl.dsa",
name = "DSAParameters"
)]
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/ec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ use foreign_types_shared::ForeignTypeRef;
use pyo3::basic::CompareOp;
use pyo3::ToPyObject;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ec")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ec")]
struct ECPrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
#[pyo3(get)]
curve: pyo3::Py<pyo3::PyAny>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ec")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ec")]
struct ECPublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
#[pyo3(get)]
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use crate::error::{CryptographyError, CryptographyResult};
use crate::exceptions;
use foreign_types_shared::ForeignTypeRef;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ed25519")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ed25519")]
struct Ed25519PrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ed25519")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ed25519")]
struct Ed25519PublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/ed448.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ use crate::error::{CryptographyError, CryptographyResult};
use crate::exceptions;
use foreign_types_shared::ForeignTypeRef;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ed448")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ed448")]
struct Ed448PrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.ed448")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.ed448")]
struct Ed448PublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/x25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::buf::CffiBuf;
use crate::error::CryptographyResult;
use foreign_types_shared::ForeignTypeRef;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.x25519")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.x25519")]
struct X25519PrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.x25519")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.x25519")]
struct X25519PublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/backend/x448.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ use crate::buf::CffiBuf;
use crate::error::CryptographyResult;
use foreign_types_shared::ForeignTypeRef;

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.x448")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.x448")]
struct X448PrivateKey {
pkey: openssl::pkey::PKey<openssl::pkey::Private>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl.x448")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl.x448")]
struct X448PublicKey {
pkey: openssl::pkey::PKey<openssl::pkey::Public>,
}
Expand Down
1 change: 1 addition & 0 deletions src/rust/src/exceptions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// for complete details.

#[pyo3::prelude::pyclass(
frozen,
module = "cryptography.hazmat.bindings._rust.exceptions",
name = "_Reasons"
)]
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn raise_openssl_error() -> crate::error::CryptographyResult<()> {
Err(openssl::error::ErrorStack::get().into())
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.openssl")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.openssl")]
struct OpenSSLError {
e: openssl::error::Error,
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/oid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::error::CryptographyResult;
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust")]
pub(crate) struct ObjectIdentifier {
pub(crate) oid: asn1::ObjectIdentifier,
}
Expand Down
4 changes: 2 additions & 2 deletions src/rust/src/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ use std::cell::Cell;
// An object pool that can contain a single object and will dynamically
// allocate new objects to fulfill requests if the pool'd object is already in
// use.
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust")]
pub(crate) struct FixedPool {
create_fn: pyo3::PyObject,

value: Cell<Option<pyo3::PyObject>>,
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust")]
struct PoolAcquisition {
pool: pyo3::Py<FixedPool>,

Expand Down
1 change: 1 addition & 0 deletions src/rust/src/x509/certificate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ self_cell::self_cell!(
}
);

// TODO: can't be frozen because extensions takes `&mut self`
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.x509")]
pub(crate) struct Certificate {
pub(crate) raw: OwnedCertificate,
Expand Down
2 changes: 2 additions & 0 deletions src/rust/src/x509/crl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ self_cell::self_cell!(
}
);

// TODO: can't be frozen because extensions required `&mut self`.
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.x509")]
struct CertificateRevocationList {
owned: Arc<OwnedCertificateRevocationList>,
Expand Down Expand Up @@ -490,6 +491,7 @@ impl Clone for OwnedRevokedCertificate {
}
}

// TODO: can't be frozen because extensions required `&mut self`.
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.x509")]
struct RevokedCertificate {
owned: OwnedRevokedCertificate,
Expand Down
1 change: 1 addition & 0 deletions src/rust/src/x509/csr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ self_cell::self_cell!(
}
);

// TODO: can't be frozen extensions take `&mut self`
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.x509")]
struct CertificateSigningRequest {
raw: OwnedCsr,
Expand Down
1 change: 1 addition & 0 deletions src/rust/src/x509/ocsp_req.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fn load_der_ocsp_request(
})
}

// TODO: can't be frozen because extensions takes `&mut self`
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.ocsp")]
struct OCSPRequest {
raw: OwnedOCSPRequest,
Expand Down
3 changes: 2 additions & 1 deletion src/rust/src/x509/ocsp_resp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ self_cell::self_cell!(
}
);

// TODO: can't be frozen extensions and single_extensions take `&mut self`
#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.ocsp")]
struct OCSPResponse {
raw: Arc<OwnedOCSPResponse>,
Expand Down Expand Up @@ -790,7 +791,7 @@ self_cell::self_cell!(
}
);

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.ocsp")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.ocsp")]
struct OCSPSingleResponse {
raw: OwnedSingleResponse,
}
Expand Down
2 changes: 1 addition & 1 deletion src/rust/src/x509/sct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ impl TryFrom<u8> for SignatureAlgorithm {
}
}

#[pyo3::prelude::pyclass(module = "cryptography.hazmat.bindings._rust.x509")]
#[pyo3::prelude::pyclass(frozen, module = "cryptography.hazmat.bindings._rust.x509")]
pub(crate) struct Sct {
log_id: [u8; 32],
timestamp: u64,
Expand Down