Ejemplo n.º 1
0
def rnp_decrypt_file(src, dst):
    ret = run_proc_fast(RNP, [
        '--homedir', RNPDIR, '--password', PASSWORD, '--decrypt', src,
        '--output', dst
    ])
    if ret != 0:
        raise_err('rnp decryption failed')
Ejemplo n.º 2
0
def gpg_decrypt_file(src, dst, keypass):
    ret = run_proc_fast(GPG, [
        '--homedir', GPGDIR, '--pinentry-mode=loopback', '--batch', '--yes',
        '--passphrase', keypass, '--trust-model', 'always', '-o', dst, '-d',
        src
    ])
    if ret != 0:
        raise_err('gpg decryption failed')
Ejemplo n.º 3
0
def rnp_symencrypt_file(src, dst, cipher, zlevel=6, zalgo='zip', armor=False):
    params = [
        '--homedir', RNPDIR, '--password', PASSWORD, '--cipher', cipher, '-z',
        str(zlevel), '--' + zalgo, '-c', src, '--output', dst
    ]
    if armor:
        params += ['--armor']
    ret = run_proc_fast(RNP, params)
    if ret != 0:
        raise_err('rnp symmetric encryption failed')
Ejemplo n.º 4
0
def gpg_symencrypt_file(src,
                        dst,
                        cipher='AES',
                        zlevel=6,
                        zalgo=1,
                        armor=False):
    params = [
        '--homedir', GPGDIR, '-c', '-z',
        str(zlevel), '--s2k-count', '524288', '--compress-algo',
        str(zalgo), '--batch', '--passphrase', PASSWORD, '--cipher-algo',
        cipher, '--output', dst, src
    ]
    if armor:
        params.insert(2, '--armor')
    ret = run_proc_fast(GPG, params)
    if ret != 0:
        raise_err('gpg symmetric encryption failed for cipher ' + cipher)