Skip to content

Commit

Permalink
Merge pull request #161 from olcf/import_export_legacy
Browse files Browse the repository at this point in the history
issue on encrypted legacy imports
  • Loading branch information
Noah Ginsburg authored Feb 7, 2020
2 parents 5297b0d + b33c8ab commit 11a0af2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
15 changes: 8 additions & 7 deletions libpkpass/commands/fileimport.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ def _run_command_execution(self):
def _file_handler(self, string):
"""This function handles the contents of a file"""
####################################################################
# try:
self._yaml_file(yaml.safe_load(string))
# except TypeError:
# try:
# self._flat_file(string.strip().split("\n"))
# except TypeError:
# raise LegacyImportFormatError
try:
self._yaml_file(yaml.safe_load(string))
except (TypeError, yaml.scanner.ScannerError):
try:
self._flat_file(string.strip().split("\n"))
except TypeError:
raise LegacyImportFormatError

####################################################################
def _flat_file(self, passwords):
Expand All @@ -61,6 +61,7 @@ def _flat_file(self, passwords):
print("INFO: Flat password file detected, using 'imported' as description \
you can manually change the description in the file if you would like")
db_len = len(passwords)
i = 0
for password in passwords:
psplit = password.split(":")
fname = psplit[0].strip()
Expand Down
7 changes: 6 additions & 1 deletion libpkpass/crypto.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ def sk_decrypt_string(ciphertext_string, key):
plaintext_string = fern.decrypt(base64.urlsafe_b64decode(handle_python_strings(ciphertext_string)))
return plaintext_string.decode("ASCII")
except InvalidToken:
raise DecryptionError("Incorrect Password")
# handle some legacy stuff from NCCS
try:
plaintext_string = fern.decrypt(ciphertext_string)
return plaintext_string.decode("ASCII")
except InvalidToken:
raise DecryptionError("Incorrect Password")

##############################################################################
def hash_password(password):
Expand Down

0 comments on commit 11a0af2

Please sign in to comment.