Gnumed.pycommon.gmCrypto

Package Gnumed :: Package pycommon :: Module gmCrypto |
[frames] | no frames]

# Module gmCrypto

source code

    GNUmed crypto tools.

    First and only rule:

            DO NOT REIMPLEMENT ENCRYPTION

            Use existing tools.

Author: K. Hilbert <Karsten.Hilbert@gmx.net>

License: GPL v2 or later (details at http://www.gnu.org)

Functions
create_encrypted_zip_archive_from_dir(source_dir, comment=None, overwrite=True, passphrase=None, verbose=False) Use 7z to create an encrypted ZIP archive of a directory. | source code
create_zip_archive_from_dir(source_dir, archive_name=None, comment=None, overwrite=True, verbose=False) | source code
gpg_decrypt_file(filename=None, passphrase=None, verbose=False, target_ext=None) | source code
gpg_encrypt_file_symmetric(filename=None, comment=None, verbose=False, passphrase=None, remove_unencrypted=False) | source code
aes_encrypt_file(filename=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=False) | source code
encrypt_pdf(filename=None, passphrase=None, verbose=False, remove_unencrypted=False) | source code
encrypt_file_symmetric(filename=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=False, convert2pdf=False) Encrypt <filename> with a symmetric cipher. | source code
encrypt_file(filename=None, receiver_key_ids=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=False, convert2pdf=False) Encrypt an arbitrary file. | source code
encrypt_directory_content(directory=None, receiver_key_ids=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=True, convert2pdf=False) | source code

Variables
| __doc__ = `"""GNUmed crypto too`...``
| __package__ = ``'``Gnumed.pycommon``'``

Imports: sys, os, logging, tempfile, gmLog2, gmShellAPI, gmTools, gmMimeLib

Function Details

### create_encrypted_zip_archive_from_dir(source_dir, comment=None, overwrite=True, passphrase=None, verbose=False) | source code
    Use 7z to create an encrypted ZIP archive of a directory.

    <source_dir>            will be included into the archive
    <comment>                       included as a file containing the comment
    <overwrite>                     remove existing archive before creation, avoiding
                                            *updating* of those, and thereby including unintended data
    <passphrase>            minimum length of 5

    The resulting zip archive will always be named
    "datawrapper.zip" for confidentiality reasons. If callers
    want another name they will have to shutil.move() the zip
    file themselves. This archive will be compressed and
    AES256 encrypted with the given passphrase. Therefore,
    the result will not decrypt with earlier versions of
    unzip software. On Windows, 7z oder WinZip are needed.

    The zip format does not support header encryption thereby
    allowing attackers to gain knowledge of patient details
    by observing the names of files and directories inside
    the encrypted archive.

    To reduce that attack surface, GNUmed will create
    _another_ zip archive inside "datawrapper.zip", which
    eventually wraps up the patient data as "data.zip". That
    archive is not compressed and not encrypted, and can thus
    be unpacked with any old unzipper.

    Note that GNUmed does NOT remember the passphrase for
    you. You will have to take care of that yourself, and
    possibly also safely hand over the passphrase to any
    receivers of the zip archive.

### encrypt_file_symmetric(filename=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=False, convert2pdf=False) | source code
Encrypt <filename> with a symmetric cipher. <convert2pdf> - True: convert <filename> to PDF, if possible, and encrypt that.

### encrypt_file(filename=None, receiver_key_ids=None, passphrase=None, comment=None, verbose=False, remove_unencrypted=False, convert2pdf=False) | source code
    Encrypt an arbitrary file.

    <remove_unencrypted>
            True: remove unencrypted source file if encryption succeeded
    <convert2pdf>
            True: attempt conversion to PDF of input file before encryption
                    success: the PDF is encrypted (and the non-PDF source file is removed)
                    failure: the source file is encrypted

Variables Details

  ### __doc__ Value:
      """GNUmed crypto tools.

      First and only rule:

      	DO NOT REIMPLEMENT ENCRYPTION

      	Use existing tools.
      """