Skip to content

Commit

Permalink
Fix typos to make key decryption work (#148)
Browse files Browse the repository at this point in the history
* fix wrong variable use (password vs. pw)

* fix typo (encrypted_key vs encryted_key)

* fix typo

* correct docstring

---------

Co-authored-by: belamu <[email protected]>
  • Loading branch information
belamu and belamu authored Nov 7, 2024
1 parent 390b522 commit d544cc1
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions sigexport/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

PASSWORD_CMD_DARWIN = ["security", "find-generic-password", "-ws", "Signal Safe Storage"]
PASSWORD_CMD_GNOME = ["secret-tool", "lookup", "application", "Signal"]
PASSWARD_CMD_KDE = ["kwallet-query", "kdewallet", "-f",
PASSWORD_CMD_KDE = ["kwallet-query", "kdewallet", "-f",
"Chromium Keys", "-r", "Chromium Safe Storage"]


Expand All @@ -39,7 +39,7 @@ def get_key(file: Path, password: Optional[str]) -> str:
if "key" in data:
return data["key"]
elif "encryptedKey" in data:
encrypyed_key = data["encryptedKey"]
encrypted_key = data["encryptedKey"]
if sys.platform == "win32":
secho(
"Signal decryption isn't currently supported on Windows"
Expand All @@ -48,21 +48,20 @@ def get_key(file: Path, password: Optional[str]) -> str:
)
if sys.platform == "darwin":
if password:
return decrypt(password, encrypyed_key, b"v10", 1003)
return decrypt(password, encrypted_key, b"v10", 1003)
pw = get_password(PASSWORD_CMD_DARWIN, "macOS") # may raise error
return decrypt(pw, encrypyed_key, b"v10", 1003)
return decrypt(pw, encrypted_key, b"v10", 1003)
else: # linux
if password:
return decrypt(password, encrypyed_key, b"v11", 1)
return decrypt(password, encrypted_key, b"v11", 1)
elif "safeStorageBackend" in data:
if data["safeStorageBackend"] == "gnome_libsecret":
pw = get_password(PASSWORD_CMD_GNOME, "gnome") # may raise error
pw = get_password(PASSWORD_CMD_KDE, "KDE") # may raise error
return decrypt(password, encrypyed_key, b"v11", 1)
return decrypt(pw, encrypted_key, b"v11", 1)
elif data["safeStorageBackend"] in [
"gnome_libsecret", "kwallet", "kwallet5", "kwallet6"]:
pw = get_password(PASSWORD_CMD_KDE, "KDE") # may raise error
return decrypt(password, encrypyed_key, b"v11", 1)
return decrypt(pw, encrypted_key, b"v11", 1)
else:
secho("Your Signal data key is encrypted, and requires a password.")
secho(f"The safe storage backend is {data['safeStorageBackend']}")
Expand Down Expand Up @@ -90,7 +89,7 @@ def get_password(cmd: list[str], system: str) -> Optional[str]:
cmd: shell command as list of words
system: Name of the system we are on, for help message.
Returns:
password if found, None otherwise
password if found
Raises:
nondescript error: if no password was found
"""
Expand Down

0 comments on commit d544cc1

Please sign in to comment.