Decrypting symmetrically encrypted text in Command Line (CL) results in error message?
vedaal at nym.hush.com
vedaal at nym.hush.com
Wed Nov 27 19:45:25 CET 2013
On Wednesday, November 27, 2013 at 7:46 AM, "Sin Trenton" <biggles.trenton at gmail.com> wrote:
>If I want to decrypt a short text snippet, I have to
>
> 1. copy the snippet
> 2. paste it into a txt file
> 3. save the file
> 4. use "gpg -d file.txt"
>
>(The text is then read in the CL window, I have no interest in
>this case
>to save the decrypted text, just read it and e.g. check a
>reference)
>
>Is it possible to replace steps 2 and 3 by pasting in the text in
>the CL?
>
>I've tried "gpg [Enter]", but I always get the message "decryption
>failed: bad key" as you can see below.
>Everything below the encrypted message happened automatically when
>I
>pasted in the text first time, though next time it did wait for me
>to
>supply the passphrase, with same "bad key" result, however.
>
>Note that the last line "-----END PGP MESSAGE-----" disappears.
>Also,
>the prompt does not return to the standard ">", until I have done
>a
>Ctrl+Z or Ctrl+C.
>
> >gpg
> gpg: Go ahead and type your message ...
> -----BEGIN PGP MESSAGE-----
> Version: GnuPG v1.4.15 (MingW32)
>
> jA0ECgMCpM [snip] zHEHXtFP3
> =uNdz
> gpg: TWOFISH encrypted data
> gpg: encrypted with 1 passphrase
> gpg: decryption failed: bad key
=====
I get the same problem on windows,
It is very puzzling that it should work with a message encrypted to a public key, but not with a symmetrically encrypted message.
the same thing happens with cygwin and msys,
*but*
using msys, and printf you can accomplish what you want to do.
(you can either install msys on windows, or use portableApps (www.portableApps.com) and install MSYSPortable.
Once msys is installed, copy the following files into the MSYSPortable\Data\usr\local\bin\
gpg.exe , gpgsplit.exe , gpgv.exe gpg-zip )
Here is a symmetrical test message to try out:
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Acts of Kindness better the World, and protect the Soul
jA0ECgMIq6s05aP/yK+u0kYB/HlkU1MH0shFYGpzYZDUAklckj4WOGBNYSsqW1Kv
FAiTjIdj8vJCowfWIALk+5YrUoMgwHXYZsGLm1dbM8AwUmXt0GSD
=Xhjy
-----END PGP MESSAGE-----
Copy this into notepad, or any editor, and then add the line before the message and the line after the message to result in the following:
"
-----BEGIN PGP MESSAGE-----
Version: GnuPG v2.0.17 (MingW32)
Comment: Acts of Kindness better the World, and protect the Soul
jA0ECgMIq6s05aP/yK+u0kYB/HlkU1MH0shFYGpzYZDUAklckj4WOGBNYSsqW1Kv
FAiTjIdj8vJCowfWIALk+5YrUoMgwHXYZsGLm1dbM8AwUmXt0GSD
=Xhjy
-----END PGP MESSAGE-----
" | gpg -d
Copy the above segment into clipboard.
Now open the MSYS window, and type;
printf
(and add a space afterward)
Now, right-click on the border of the MSYS window, and a dropdown menu aooears,
click on 'edit' then on 'paste' and press enter
gpg then does the following:
gpg: armor: BEGIN PGP MESSAGE
gpg: armor header: Version: GnuPG v2.0.17 (MingW32)
gpg: armor header: Comment: Acts of Kindness better the World, and protect the S
oul
:symkey enc packet: version 4, cipher 10, s2k 3, hash 8
salt abab34e5a3ffc8af, count 1966080 (174)
gpg: TWOFISH encrypted data
Enter passphrase:
(the passphrase is: sss
after typing in sss gpg then does):
:encrypted data packet:
length: 70
mdc_method: 2
gpg: encrypted with 1 passphrase
:compressed packet: algo=1
:literal data packet:
mode b (62), created 1350586272, name="",
raw data: 17 bytes
gpg: original file name=''
just another testgpg: decryption okay
gpg: session key: `10:985CBBC1E03403B08D6A407AF06F87228248BCBCA0E0F0A3C3F0257821
E09D57'
The plaintext ('just another test') appears above in the MSMS window as the line:
just another testgpg: decryption okay
Maybe people here can figure out why it works this way, but not in the way you tried, and if this is a 'windows' issue ... ;-((
vedaal
More information about the Gnupg-users
mailing list