title: Not able to decompress DES3 encrypted data using Gzip
body: <p>While porting python2 code to python3, we're facing an issue in the gzip section of the code that compresses a DES3 encrypted stream.</p>
  
  <p>Below is the code for encrypting data in DES3 and then writing to the gzip file:</p>
  
  <pre><code>def createEncryptedFile(key, enc_iv, path):
      checksum_generation = 'ciphertext'
      tmp_fd = open(path, 'w')
      encrypted_stream = utils.DES3Cipher(tmp_fd, key, enc_iv, checksum_generation)
      with gzip.GzipFile(fileobj=encrypted_stream, mode='w') as fo:
          fo.write(bytes('Testing Data For Gzip', 'latin-1'))
      encrypted_stream.close()
      tmp_fd.close()
  </code></pre>
  
  <p>Below is the code for decrypting and unzipping the contents:</p>
  
  <pre><code>def decryptFile(key, enc_iv, path):
      update_size = os.path.getsize(path)
      with open(path, 'r') as update_file:
          decrypted_data = ''.join(utils.decrypt_des3_cbc_stream(update_file, update_size, key, enc_iv))
          inner_data = io.BytesIO(decrypted_data.encode('latin-1'))
          with gzip.GzipFile(fileobj=inner_data, mode='rb') as fo:
              print("The unzipped data: ", fo.read())
  </code></pre>
  
  <p>I'm getting the following error:</p>
  
  <pre><code>  print("The unzipped data: ", fo.read())
    File "/usr/lib64/python3.7/gzip.py", line 276, in read
      return self._buffer.read(size)
    File "/usr/lib64/python3.7/gzip.py", line 463, in read
      if not self._read_gzip_header():
    File "/usr/lib64/python3.7/gzip.py", line 411, in _read_gzip_header
      raise OSError('Not a gzipped file (%r)' % magic)
  OSError: Not a gzipped file (b'\x08\x08')
  </code></pre>
  
  <p>I've tested the DES3 encryption/ decryption methods separately and have ruled out the possibility of error there.</p>
  
  <p>The error seems to be in the gzip section, any ideas ?</p>