Skip to content

Commit

Permalink
fix erroneous detection of overall encryption in pre_dec_vault
Browse files Browse the repository at this point in the history
Vault with no overall encryption may be mistaken as ECB encrypted by
`aes_decrypt_soft`.
Restrict detection of overall encryption to CBC mode only.
  • Loading branch information
cfbao committed May 28, 2018
1 parent 6b186ba commit f23ac2a
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lpparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ def read_from_db(path, email):

def pre_dec_vault(vaultAsc, key):
try:
vaultAsc = aes_decrypt_soft(vaultAsc, key, raiseCond=('format','padding','unicode'))
vaultEnc, mode = format_enc_data(vaultAsc)
except LpDecryptionError as e:
if e.args[0] == 'format':
pass
assert e.args[0] == 'format'
pass
else:
if mode.name == 'CBC':
try:
vaultAsc = aes_decrypt_str(vaultEnc, key, mode)
except LpDecryptionError:
raise LpParserFail(*VAULT_DECRYPT_FAIL)
else:
raise LpParserFail(*VAULT_DECRYPT_FAIL)
del vaultEnc
if vaultAsc.startswith('LPB64'):
vaultAsc = vaultAsc[5:]
try:
Expand Down

0 comments on commit f23ac2a

Please sign in to comment.