diff options
author | Pat Ferate <pferate+github@gmail.com> | 2016-07-21 14:42:27 -0700 |
---|---|---|
committer | Pat Ferate <pferate+github@gmail.com> | 2016-07-27 11:41:18 -0700 |
commit | f31e1e014fa9632fd5d71ccd03d19a14320c95d0 (patch) | |
tree | f0ec338c1f685db7c11f82a78727075384519e46 /oauth2client/_openssl_crypt.py | |
parent | 25165adbc18101567ac0b75b086a072745b07f41 (diff) | |
download | oauth2client-f31e1e014fa9632fd5d71ccd03d19a14320c95d0.tar.gz |
Update imports to only Packages or Modules
Also cleaned up some nested attribute access.
Diffstat (limited to 'oauth2client/_openssl_crypt.py')
-rw-r--r-- | oauth2client/_openssl_crypt.py | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/oauth2client/_openssl_crypt.py b/oauth2client/_openssl_crypt.py index 49b763b..77fac74 100644 --- a/oauth2client/_openssl_crypt.py +++ b/oauth2client/_openssl_crypt.py @@ -15,8 +15,7 @@ from OpenSSL import crypto -from oauth2client._helpers import _parse_pem_key -from oauth2client._helpers import _to_bytes +from oauth2client import _helpers class OpenSSLVerifier(object): @@ -43,8 +42,8 @@ class OpenSSLVerifier(object): True if message was signed by the private key associated with the public key that this object was constructed with. """ - message = _to_bytes(message, encoding='utf-8') - signature = _to_bytes(signature, encoding='utf-8') + message = _helpers._to_bytes(message, encoding='utf-8') + signature = _helpers._to_bytes(signature, encoding='utf-8') try: crypto.verify(self._pubkey, signature, message, 'sha256') return True @@ -66,7 +65,7 @@ class OpenSSLVerifier(object): Raises: OpenSSL.crypto.Error: if the key_pem can't be parsed. """ - key_pem = _to_bytes(key_pem) + key_pem = _helpers._to_bytes(key_pem) if is_x509_cert: pubkey = crypto.load_certificate(crypto.FILETYPE_PEM, key_pem) else: @@ -94,7 +93,7 @@ class OpenSSLSigner(object): Returns: string, The signature of the message for the given key. """ - message = _to_bytes(message, encoding='utf-8') + message = _helpers._to_bytes(message, encoding='utf-8') return crypto.sign(self._key, message, 'sha256') @staticmethod @@ -111,12 +110,12 @@ class OpenSSLSigner(object): Raises: OpenSSL.crypto.Error if the key can't be parsed. """ - key = _to_bytes(key) - parsed_pem_key = _parse_pem_key(key) + key = _helpers._to_bytes(key) + parsed_pem_key = _helpers._parse_pem_key(key) if parsed_pem_key: pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, parsed_pem_key) else: - password = _to_bytes(password, encoding='utf-8') + password = _helpers._to_bytes(password, encoding='utf-8') pkey = crypto.load_pkcs12(key, password).get_privatekey() return OpenSSLSigner(pkey) @@ -131,7 +130,7 @@ def pkcs12_key_as_pem(private_key_bytes, private_key_password): Returns: String. PEM contents of ``private_key_bytes``. """ - private_key_password = _to_bytes(private_key_password) + private_key_password = _helpers._to_bytes(private_key_password) pkcs12 = crypto.load_pkcs12(private_key_bytes, private_key_password) return crypto.dump_privatekey(crypto.FILETYPE_PEM, pkcs12.get_privatekey()) |