From 9c8bc7eb6e981368ec219f95e099c94ffd058b4f Mon Sep 17 00:00:00 2001 From: tuxxy Date: Thu, 12 Oct 2017 14:58:03 -0600 Subject: [PATCH] Add _decrypt_key --- nkms/crypto/powers.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/nkms/crypto/powers.py b/nkms/crypto/powers.py index 3fdcbbc94..ea7cf2fd8 100644 --- a/nkms/crypto/powers.py +++ b/nkms/crypto/powers.py @@ -184,6 +184,26 @@ class EncryptingPower(CryptoPowerUp): enc_key_data = API.symm_encrypt(plain_key_data, data_key) return (enc_key_data, enc_key_path) + def _decrypt_key( + self, + enc_data_key: bytes, + enc_path_key: bytes, + priv_key: bytes + ) -> bytes: + """ + Decrypts the enc_data_key via ECIES decapsulation. + + TODO: Name these params better + + :param enc_data_key: Encrypted key to decrypt + :param enc_path_key: ECIES encapsulated key + :param priv_key: Private key to use in ECIES decapsulate + + :return: decrypted key + """ + dec_symm_key = API.ecies_decapsulate(priv_key, enc_path_key) + return API.symm_decrypt(dec_symm_key, enc_data_key) + def encrypt( self, data: bytes, @@ -191,7 +211,7 @@ class EncryptingPower(CryptoPowerUp): M: int, N: int, path: bytes = None - ) -> Tuple[Tuple[bytes, bytes], bytes, List[umbral.RekeyFrag]]: + ) -> Tuple[Tuple[bytes, bytes, bytes], bytes, List[umbral.RekeyFrag]]: """ Encrypts data using ECIES.