forked from p15670423/monkey
Island: Move EncryptionKey32Bytes to its own file
This commit is contained in:
parent
d55e7b1455
commit
0111dea47f
|
@ -14,3 +14,4 @@ from .data_store_encryptor import (
|
||||||
unlock_datastore_encryptor,
|
unlock_datastore_encryptor,
|
||||||
reset_datastore_encryptor,
|
reset_datastore_encryptor,
|
||||||
)
|
)
|
||||||
|
from .encryption_key_types import EncryptionKey32Bytes
|
||||||
|
|
|
@ -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.")
|
|
@ -15,22 +15,6 @@ logger = logging.getLogger(__name__)
|
||||||
# Note: password != key
|
# 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):
|
class KeyBasedEncryptor(IEncryptor):
|
||||||
def __init__(self, key: bytes):
|
def __init__(self, key: bytes):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue