diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-22 10:12:07 -0700 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-10-22 10:12:07 -0700 |
commit | d918580097506197e0aadaa60c4681536b5f4adf (patch) | |
tree | 2b58223f53302e0aa953c0fc203537dda879d1fc /cryptography/hazmat/primitives/hmac.py | |
parent | 633caacfe7e86f9098bb8cb64cfc12a9fe5cc35c (diff) | |
download | cryptography-d918580097506197e0aadaa60c4681536b5f4adf.tar.gz cryptography-d918580097506197e0aadaa60c4681536b5f4adf.tar.bz2 cryptography-d918580097506197e0aadaa60c4681536b5f4adf.zip |
Statically verify interface implementations, and fix all the resulting bugs
Diffstat (limited to 'cryptography/hazmat/primitives/hmac.py')
-rw-r--r-- | cryptography/hazmat/primitives/hmac.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/cryptography/hazmat/primitives/hmac.py b/cryptography/hazmat/primitives/hmac.py index 23292432..22a31391 100644 --- a/cryptography/hazmat/primitives/hmac.py +++ b/cryptography/hazmat/primitives/hmac.py @@ -33,7 +33,7 @@ class HMAC(object): if not isinstance(algorithm, interfaces.HashAlgorithm): raise TypeError("Expected instance of interfaces.HashAlgorithm.") - self.algorithm = algorithm + self._algorithm = algorithm self._backend = backend self._key = key @@ -42,12 +42,14 @@ class HMAC(object): else: self._ctx = ctx - def update(self, msg): + algorithm = utils.read_only_property("_algorithm") + + def update(self, data): if self._ctx is None: raise AlreadyFinalized("Context was already finalized.") - if not isinstance(msg, bytes): - raise TypeError("msg must be bytes.") - self._ctx.update(msg) + if not isinstance(data, bytes): + raise TypeError("data must be bytes.") + self._ctx.update(data) def copy(self): if self._ctx is None: |