Skip to content

Commit

Permalink
Consistently use 'self' in backend.py (#5261)
Browse files Browse the repository at this point in the history
There happens to be global var named 'backend'
so backend._lib works, but is confusing.
  • Loading branch information
markokr authored May 27, 2020
1 parent bf17545 commit dbe247c
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/cryptography/hazmat/backends/openssl/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def create_x509_certificate(self, builder, private_key, algorithm):

# Create an empty certificate.
x509_cert = self._lib.X509_new()
x509_cert = self._ffi.gc(x509_cert, backend._lib.X509_free)
x509_cert = self._ffi.gc(x509_cert, self._lib.X509_free)

# Set the x509 version.
res = self._lib.X509_set_version(x509_cert, builder._version.value)
Expand Down Expand Up @@ -953,7 +953,7 @@ def create_x509_crl(self, builder, private_key, algorithm):

# Create an empty CRL.
x509_crl = self._lib.X509_CRL_new()
x509_crl = self._ffi.gc(x509_crl, backend._lib.X509_CRL_free)
x509_crl = self._ffi.gc(x509_crl, self._lib.X509_CRL_free)

# Set the x509 CRL version. We only support v2 (integer value 1).
res = self._lib.X509_CRL_set_version(x509_crl, 1)
Expand Down Expand Up @@ -1058,7 +1058,7 @@ def _create_x509_extension(self, handlers, extension):
nid = self._lib.OBJ_txt2nid(
extension.oid.dotted_string.encode("ascii")
)
backend.openssl_assert(nid != self._lib.NID_undef)
self.openssl_assert(nid != self._lib.NID_undef)
return self._lib.X509V3_EXT_i2d(
nid, 1 if extension.critical else 0, ext_struct
)
Expand Down Expand Up @@ -2166,11 +2166,11 @@ def x25519_load_public_bytes(self, data):

evp_pkey = self._create_evp_pkey_gc()
res = self._lib.EVP_PKEY_set_type(evp_pkey, self._lib.NID_X25519)
backend.openssl_assert(res == 1)
self.openssl_assert(res == 1)
res = self._lib.EVP_PKEY_set1_tls_encodedpoint(
evp_pkey, data, len(data)
)
backend.openssl_assert(res == 1)
self.openssl_assert(res == 1)
return _X25519PublicKey(self, evp_pkey)

def x25519_load_private_bytes(self, data):
Expand Down Expand Up @@ -2198,7 +2198,7 @@ def x25519_load_private_bytes(self, data):
ba[0:16] = pkcs8_prefix
ba[16:] = data
bio = self._bytes_to_bio(ba)
evp_pkey = backend._lib.d2i_PrivateKey_bio(bio.bio, self._ffi.NULL)
evp_pkey = self._lib.d2i_PrivateKey_bio(bio.bio, self._ffi.NULL)

self.openssl_assert(evp_pkey != self._ffi.NULL)
evp_pkey = self._ffi.gc(evp_pkey, self._lib.EVP_PKEY_free)
Expand Down

0 comments on commit dbe247c

Please sign in to comment.