diff --git a/src/wolfcrypt/ciphers.py b/src/wolfcrypt/ciphers.py index b7ae17f..8beaea6 100644 --- a/src/wolfcrypt/ciphers.py +++ b/src/wolfcrypt/ciphers.py @@ -18,6 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# pylint: disable=no-member,no-name-in-module + from wolfcrypt._ffi import ffi as _ffi from wolfcrypt._ffi import lib as _lib from wolfcrypt.utils import t2b @@ -63,7 +65,7 @@ class _Cipher(object): if len(key) not in self._key_sizes: raise ValueError("key must be %s in length" % self._key_sizes) else: - if not len(key): + if not key: raise ValueError("key must not be 0 in length") if IV is not None and len(IV) != self.block_size: @@ -80,7 +82,7 @@ class _Cipher(object): self._IV = _ffi.new('byte[%d]' % self.block_size) @classmethod - def new(cls, key, mode, IV=None, **kwargs): + def new(cls, key, mode, IV=None, **kwargs): # pylint: disable=W0613 """ Returns a ciphering object, using the secret key contained in the string **key**, and using the feedback mode **mode**, which @@ -162,9 +164,9 @@ class Aes(_Cipher): if direction == _ENCRYPTION: return _lib.wc_AesSetKey( self._enc, self._key, len(self._key), self._IV, _ENCRYPTION) - else: - return _lib.wc_AesSetKey( - self._dec, self._key, len(self._key), self._IV, _DECRYPTION) + + return _lib.wc_AesSetKey( + self._dec, self._key, len(self._key), self._IV, _DECRYPTION) def _encrypt(self, destination, source): return _lib.wc_AesCbcEncrypt(self._enc, destination, @@ -190,9 +192,9 @@ class Des3(_Cipher): if direction == _ENCRYPTION: return _lib.wc_Des3_SetKey(self._enc, self._key, self._IV, _ENCRYPTION) - else: - return _lib.wc_Des3_SetKey(self._dec, self._key, - self._IV, _DECRYPTION) + + return _lib.wc_Des3_SetKey(self._dec, self._key, + self._IV, _DECRYPTION) def _encrypt(self, destination, source): return _lib.wc_Des3_CbcEncrypt(self._enc, destination, @@ -203,7 +205,7 @@ class Des3(_Cipher): source, len(source)) -class _Rsa(object): +class _Rsa(object): # pylint: disable=too-few-public-methods RSA_MIN_PAD_SIZE = 11 def __init__(self): @@ -226,7 +228,7 @@ class RsaPublic(_Rsa): def __init__(self, key): key = t2b(key) - _Rsa.__init__(self) + super(RsaPublic, self).__init__() idx = _ffi.new("word32*") idx[0] = 0 @@ -289,7 +291,7 @@ class RsaPrivate(RsaPublic): def __init__(self, key): key = t2b(key) - _Rsa.__init__(self) + super(RsaPrivate, self).__init__() idx = _ffi.new("word32*") idx[0] = 0 diff --git a/src/wolfcrypt/hashes.py b/src/wolfcrypt/hashes.py index fbfa9f8..1049634 100644 --- a/src/wolfcrypt/hashes.py +++ b/src/wolfcrypt/hashes.py @@ -18,6 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# pylint: disable=no-member,no-name-in-module, no-self-use + from wolfcrypt._ffi import ffi as _ffi from wolfcrypt._ffi import lib as _lib from wolfcrypt.utils import t2b, b2h @@ -36,7 +38,7 @@ class _Hash(object): if ret < 0: raise WolfCryptError("Hash init error (%d)" % ret) - if (string): + if string: self.update(string) @classmethod @@ -56,7 +58,7 @@ class _Hash(object): """ copy = self.new("") - _ffi.memmove(copy._native_object, + _ffi.memmove(copy._native_object, # pylint: disable=protected-access self._native_object, self._native_size) @@ -205,7 +207,7 @@ class _Hmac(_Hash): _native_type = "Hmac *" _native_size = _ffi.sizeof("Hmac") - def __init__(self, key, string=None): + def __init__(self, key, string=None): # pylint: disable=W0231 key = t2b(key) self._native_object = _ffi.new(self._native_type) @@ -213,11 +215,11 @@ class _Hmac(_Hash): if ret < 0: raise WolfCryptError("Hmac init error (%d)" % ret) - if (string): + if string: self.update(string) @classmethod - def new(cls, key, string=None): + def new(cls, key, string=None): # pylint: disable=W0221 """ Creates a new hashing object and returns it. **key** is a required parameter containing a string giving the key @@ -227,8 +229,8 @@ class _Hmac(_Hash): """ return cls(key, string) - def _init(self, type, key): - return _lib.wc_HmacSetKey(self._native_object, type, key, len(key)) + def _init(self, hmac, key): + return _lib.wc_HmacSetKey(self._native_object, hmac, key, len(key)) def _update(self, data): return _lib.wc_HmacUpdate(self._native_object, data, len(data)) diff --git a/src/wolfcrypt/random.py b/src/wolfcrypt/random.py index 5e5f1ad..0f07a3e 100644 --- a/src/wolfcrypt/random.py +++ b/src/wolfcrypt/random.py @@ -18,6 +18,8 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +# pylint: disable=no-member,no-name-in-module + from wolfcrypt._ffi import ffi as _ffi from wolfcrypt._ffi import lib as _lib