jamessan / vim-gnupg

This script implements transparent editing of gpg encrypted files.
http://www.vim.org/scripts/script.php?script_id=3645
729 stars 73 forks source link

Unable to write to encrypted file. Error: Message could not be encrypted! (Press ENTER) #123

Closed roxyland closed 2 years ago

roxyland commented 2 years ago

gnupg.vim 2.7.1 gpg (GnuPG) 2.0.22 libgcrypt 1.5.3

vim opens the encrypted file, but I cannot save. It errors out with Message could not be encrypted! (Press ENTER)

Enabling :let g:GPGDebugLevel=2 and :let g:GPGDebugLog='gpg.log' produces this log:

GnuPG: gnupg.vim 2.7.1
GnuPG: command: gpg --trust-model always --version 2>/dev/null
GnuPG: rc: 0
GnuPG: output: gpg (GnuPG) 2.0.22^@libgcrypt 1.5.3^@Copyright (C) 2013 Free Software Foundation, Inc.^@License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>^@This is free software: you are free to change and redistribute it.^@There is NO WARRANTY, to the extent permitted by law.^@^@Home: ~/.gnupg^@Supported algorithms:^@Pubkey: RSA, ?, ?, ELG, DSA^@Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,^@        CAMELLIA128, CAMELLIA192, CAMELLIA256^@Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224^@Compression: Uncompressed, ZIP, ZLIB, BZIP2^@
GnuPG: public key algorithms: RSA, ?, ?, ELG, DSA
GnuPG: cipher algorithms: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
GnuPG: hashing algorithms: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
GnuPG: compression algorithms: Uncompressed, ZIP, ZLIB, BZIP2
GnuPG: this file is symmetric encrypted
GnuPG: cipher-algo is CAST5
GnuPG: called BufReadPre autocommand for /home/XXXXXXXXX/file
GnuPG: decrypting file
GnuPG: command: silent read ++edit !gpg --trust-model always --no-use-agent --quiet --decrypt '/home/XXXXXXXXX/file.gpg' 2>/dev/null
GnuPG: rc: 0
GnuPG: called BufReadPost autocommand for /home/XXXXXXXXX/file
GnuPG: called BufWritePre autocommand for /home/XXXXXXXXX/file
GnuPG: recipients are: []
GnuPG: unknown recipients are: []
GnuPG: command: write !gpg --trust-model always --no-use-agent --quiet --no-encrypt-to  --symmetric  --cipher-algo CAST5   >'/tmp/vD00eO1/4' 2>/dev/null
GnuPG: rc: 2
GnuPG: called BufWritePre autocommand for /home/XXXXXXXXX/file
GnuPG: recipients are: []
GnuPG: unknown recipients are: []
GnuPG: command: write !gpg --trust-model always --no-use-agent --quiet --no-encrypt-to  --symmetric  --cipher-algo CAST5   >'/tmp/vD00eO1/6' 2>/dev/null
GnuPG: rc: 2
GnuPG: called BufWritePre autocommand for /home/XXXXXXXXX/file
GnuPG: recipients are: []
GnuPG: unknown recipients are: []
GnuPG: command: write !gpg --trust-model always --no-use-agent --quiet --no-encrypt-to  --symmetric  --cipher-algo CAST5   >'/tmp/vD00eO1/8' 2>/dev/null
GnuPG: rc: 2
GnuPG: called BufWritePre autocommand for /home/XXXXXXXXX/file
GnuPG: recipients are: []
GnuPG: unknown recipients are: []
GnuPG: command: write !gpg --trust-model always --no-use-agent --quiet --no-encrypt-to  --symmetric  --cipher-algo CAST5   >'/tmp/vD00eO1/10' 2>/dev/null
GnuPG: rc: 2
GnuPG: called BufWritePre autocommand for /home/XXXXXXXXX/file
GnuPG: recipients are: []
GnuPG: unknown recipients are: []
GnuPG: command: write !gpg --trust-model always --no-use-agent --quiet --no-encrypt-to  --symmetric  --cipher-algo CAST5   >'/tmp/vD00eO1/12' 2>/dev/null
GnuPG: rc: 2
pubkey commented 2 years ago

@roxyland

Do not @ me please.

jamessan commented 2 years ago

@roxyland, what error do you get when running echo foo | gpg --trust-model always --no-use-agent --quiet --no-encrypt-to --symmetric --cipher-algo CAST5 > foo.gpg?

roxyland commented 2 years ago

echo foo | gpg --trust-model always --no-use-agent --quiet --no-encrypt-to --symmetric --cipher-algo CAST5 > foo.gpg gpg: WARNING: "--no-use-agent" is an obsolete option - it has no effect gpg: cancelled by user gpg: error creating passphrase: Operation cancelled gpg: symmetric encryption of `[stdin]' failed: Operation cancelled

jamessan commented 2 years ago

Ok, so it's not specific to the plugin. Sounds like you don't have a working pinentry installed that can be used to enter the password.