Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch decryption fails depending on size of downloaded batch. #10

Open
rgacote opened this issue Nov 3, 2019 · 0 comments
Open

Batch decryption fails depending on size of downloaded batch. #10

rgacote opened this issue Nov 3, 2019 · 0 comments

Comments

@rgacote
Copy link

rgacote commented Nov 3, 2019

Batch decryption fails because the decrypted file is overwriting the encrypted file that was downloaded. This works for small batch files, but causes decryption errors on larger batch files.

batch.py has two crypto.decryptFile calls.
Both calls set the encryptedFilepath and outputFilepath parameters to the same value.
This causes gpg to overwrite the downloaded/encrypted file and generate a decryption error which is returned as a File not found error (See #6 Batch download decryption failure raises "Cannot find file" error...)

I've mitigated this issue locally as follows:

# Decrypt an encrypted file.
  def decryptFile(self, passphrase, encryptedFilepath, outputFilepath):
    # Call gpg command line to decrypt the file.
    tmpFilepath = outfilepath + ".decrypted"  # RGAC!!
    try:
      check_output(["gpg",
      "--batch",
      "--yes",
      "--no-secmem-warning",
      "--no-mdc-warning",
      "--output", tmpFilepath,
      "--passphrase", passphrase,
      "--decrypt", encryptedFilepath])
      # Check for error code.
      os.replace(tmpFilepath, outputFilepath)  # RGAC!!
      print("\"%s\" has been decrypted to \"%s\"." % (encryptedFilepath, outputFilepath))
    except CalledProcessError as err:
      raise utils.VantivException("Decrypting the file has failed!\n%s" % err.output)

I'm running:
CentOS 7, Python 3.7.3, and SDK version 12.8.
My os.replace change only works on Python 3.5+

Note: Running gpg with from the command line returns a general error vs. the invalid radix64 errors documented in issue #6. Not sure why there is a difference. The command line error is much plainer.

$ gpg --batch --decrypt --no-secmem-warning --no-mdc-warning \
    --output=original  --passphrase-fd 0 original <key 
gpg: encrypted with 4096-bit RSA key, ID B39F0BF9, created 2019-06-14
      "Auric WorldPay Production Batch File (Auric production SFTP key for WorldPay.) <[email protected]>"
gpg: handle plaintext failed: General error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant