Coverage for oarepo_c4gh/crypt4gh/dek.py: 100%
14 statements
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 12:05 +0000
« prev ^ index » next coverage.py v7.10.2, created at 2025-08-07 12:05 +0000
1"""
2Module with Data Encryption Key wrapper.
3"""
5from ..key import Key
6from ..exceptions import Crypt4GHDEKException
9class DEK:
10 """Data Encryption Key with reference to the Key that unlocked
11 it.
13 """
15 def __init__(self, dek: bytes, key: bytes) -> None:
16 """Initializes the wrapper.
18 Parameters:
19 dek: the symmetric Data Encryption Key
20 key: public key that unlocked this DEK
21 """
22 if len(dek) != 32:
23 raise Crypt4GHDEKException("DEK must be 32 bytes")
24 self._dek = dek
25 self._key = key
27 @property
28 def dek(self) -> bytes:
29 """The Data Encryption Key - directly usable by symmetric
30 cryptography functions.
32 """
33 return self._dek
35 @property
36 def key(self) -> Key:
37 """Bytes representation of the public key that unlocked this
38 DEK.
40 """
41 return self._key