mirror of
https://github.com/PR0M3TH3AN/SeedPass.git
synced 2025-09-09 07:48:57 +00:00
Merge pull request #746 from PR0M3TH3AN/codex/improve-error-message-display
Streamline legacy decryption error output
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
# /src/seedpass.core/encryption.py
|
# /src/seedpass.core/encryption.py
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import traceback
|
|
||||||
import unicodedata
|
import unicodedata
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -109,7 +108,7 @@ class EncryptionManager:
|
|||||||
raise InvalidToken("AES-GCM payload too short")
|
raise InvalidToken("AES-GCM payload too short")
|
||||||
return self.cipher.decrypt(nonce, ciphertext, None)
|
return self.cipher.decrypt(nonce, ciphertext, None)
|
||||||
except InvalidTag as e:
|
except InvalidTag as e:
|
||||||
logger.error(
|
logger.debug(
|
||||||
"AES-GCM decryption failed: Invalid authentication tag."
|
"AES-GCM decryption failed: Invalid authentication tag."
|
||||||
)
|
)
|
||||||
try:
|
try:
|
||||||
@@ -137,7 +136,9 @@ class EncryptionManager:
|
|||||||
except (InvalidToken, InvalidTag) as e:
|
except (InvalidToken, InvalidTag) as e:
|
||||||
if isinstance(e, InvalidToken) and str(e) == "AES-GCM payload too short":
|
if isinstance(e, InvalidToken) and str(e) == "AES-GCM payload too short":
|
||||||
raise
|
raise
|
||||||
logger.error(f"FATAL: Could not decrypt data: {e}", exc_info=True)
|
if not self._legacy_migrate_flag:
|
||||||
|
raise
|
||||||
|
logger.debug(f"Could not decrypt data: {e}")
|
||||||
print(
|
print(
|
||||||
colored(
|
colored(
|
||||||
"Failed to decrypt with current key. This may be a legacy index.",
|
"Failed to decrypt with current key. This may be a legacy index.",
|
||||||
@@ -166,6 +167,7 @@ class EncryptionManager:
|
|||||||
password, iterations=50_000
|
password, iterations=50_000
|
||||||
)
|
)
|
||||||
legacy_mgr = EncryptionManager(legacy_key, self.fingerprint_dir)
|
legacy_mgr = EncryptionManager(legacy_key, self.fingerprint_dir)
|
||||||
|
legacy_mgr._legacy_migrate_flag = False
|
||||||
result = legacy_mgr.decrypt_data(encrypted_data)
|
result = legacy_mgr.decrypt_data(encrypted_data)
|
||||||
logger.warning(
|
logger.warning(
|
||||||
"Data decrypted using legacy password-only key derivation."
|
"Data decrypted using legacy password-only key derivation."
|
||||||
|
Reference in New Issue
Block a user