Skip to content

Commit

Permalink
Better runtime check for decryption
Browse files Browse the repository at this point in the history
  • Loading branch information
eXhumer committed May 11, 2020
1 parent b8c29b3 commit 24af29a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions TinGen/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,10 @@ def read_index(index_path: Path, rsa_priv_key_path: Path=None) -> dict:
flags = index_stream.read(1)[0]
encryption_flag = flags & 0xF0

if encryption_flag not in EncryptionFlag:
raise RuntimeError(f"Index is encrypted and private key doesn't exist. Unable to decrypt without private key.")
key_available = rsa_priv_key_path is not None and rsa_priv_key_path.is_file()

if encryption_flag == EncryptionFlag.ENCRYPT and not key_available:
raise RuntimeError(f"Unable to decrypt encrypted index without private key.")

compression_flag = flags & 0x0F

Expand Down

0 comments on commit 24af29a

Please sign in to comment.