improve typechecking, nacl.utils.EncryptedMessage is not a bytestring

but it derives from one
This commit is contained in:
Brian Warner 2015-07-24 16:45:20 -07:00
parent a46a405487
commit 77b80495c9
2 changed files with 2 additions and 2 deletions

View File

@ -135,7 +135,7 @@ class Wormhole:
return channel_id return channel_id
def derive_key(self, purpose, length=SecretBox.KEY_SIZE): def derive_key(self, purpose, length=SecretBox.KEY_SIZE):
if type(purpose) is not type(b""): raise UsageError if not isinstance(purpose, type(b"")): raise UsageError
return HKDF(self.key, length, CTXinfo=purpose) return HKDF(self.key, length, CTXinfo=purpose)

View File

@ -200,7 +200,7 @@ class SymmetricWormhole:
if self.key is None: if self.key is None:
# call after get_verifier() or get_data() # call after get_verifier() or get_data()
raise UsageError raise UsageError
if type(purpose) is not type(b""): raise UsageError if not isinstance(purpose, type(b"")): raise UsageError
return HKDF(self.key, length, CTXinfo=purpose) return HKDF(self.key, length, CTXinfo=purpose)
def _encrypt_data(self, key, data): def _encrypt_data(self, key, data):