Island: Move EncryptionKey32Bytes to its own file

This commit is contained in:
Shreya Malviya 2022-07-19 18:09:24 +05:30
parent d55e7b1455
commit 0111dea47f
3 changed files with 15 additions and 16 deletions

View File

@ -14,3 +14,4 @@ from .data_store_encryptor import (
unlock_datastore_encryptor,
reset_datastore_encryptor,
)
from .encryption_key_types import EncryptionKey32Bytes

View File

@ -0,0 +1,14 @@
class SizeError(Exception):
"""
Raised when an argument is not of the expected size during object creation.
"""
pass
class EncryptionKey32Bytes(bytes):
def __init__(self, key: bytes):
if len(key) == 32:
self.key = key
else:
raise SizeError("Key size should be 32 bytes.")

View File

@ -15,22 +15,6 @@ 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):
"""