diff --git a/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py b/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py index 8a46f2620..65707303a 100644 --- a/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py +++ b/monkey/monkey_island/cc/server_utils/encryption/key_based_encryptor.py @@ -15,6 +15,22 @@ logger = logging.getLogger(__name__) # Note: password != key +class SizeError(Exception): + """ + Raised when an argument is not of the expected size during object creation. + """ + + pass + + +class EncryptionKey32Bit(bytes): + def __init__(self, key: bytes): + if len(key) == 32: + self.key = key + else: + raise SizeError("Key size should be 32 bytes.") + + class KeyBasedEncryptor(IEncryptor): def __init__(self, key: bytes): """