From 77b80495c93fec92326e94a3a7e1afcb62b71015 Mon Sep 17 00:00:00 2001 From: Brian Warner Date: Fri, 24 Jul 2015 16:45:20 -0700 Subject: [PATCH] improve typechecking, nacl.utils.EncryptedMessage is not a bytestring but it derives from one --- src/wormhole/blocking/transcribe.py | 2 +- src/wormhole/twisted/transcribe.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wormhole/blocking/transcribe.py b/src/wormhole/blocking/transcribe.py index f19c18c..09292f6 100644 --- a/src/wormhole/blocking/transcribe.py +++ b/src/wormhole/blocking/transcribe.py @@ -135,7 +135,7 @@ class Wormhole: return channel_id 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) diff --git a/src/wormhole/twisted/transcribe.py b/src/wormhole/twisted/transcribe.py index c8e7f9b..9d4be6a 100644 --- a/src/wormhole/twisted/transcribe.py +++ b/src/wormhole/twisted/transcribe.py @@ -200,7 +200,7 @@ class SymmetricWormhole: if self.key is None: # call after get_verifier() or get_data() 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) def _encrypt_data(self, key, data):