From 6000fdcaf1c86b666d139017f4b54d419e6e65e9 Mon Sep 17 00:00:00 2001 From: Shreya Malviya Date: Tue, 19 Jul 2022 19:01:47 +0530 Subject: [PATCH] Island: Check type of 'key' in EncryptionKey32Bytes --- .../cc/server_utils/encryption/encryption_key_types.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/monkey/monkey_island/cc/server_utils/encryption/encryption_key_types.py b/monkey/monkey_island/cc/server_utils/encryption/encryption_key_types.py index 5fcc41f0b..65872ca5a 100644 --- a/monkey/monkey_island/cc/server_utils/encryption/encryption_key_types.py +++ b/monkey/monkey_island/cc/server_utils/encryption/encryption_key_types.py @@ -1,6 +1,8 @@ class EncryptionKey32Bytes(bytes): def __init__(self, key: bytes): + if not isinstance(key, bytes): + raise TypeError("Key is not of type `bytes`") if len(key) == 32: self.key = key else: - raise ValueError("Key size should be 32 bytes.") + raise ValueError("Key size should be 32 bytes")