LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
LinkBack Search this Thread
Old 05-28-2008, 10:58 AM   #1
Marcidius
LQ Newbie
 
Registered: May 2008
Posts: 2

Rep: Reputation: 0
GnuPG Decryption Protocol Error!


I'm working on retrieving a PGP encrypted remote file from an ftp server, once the file is transferred I then go to decrypt the file. I am writing a Perl script to automate this decryption along with these other tasks.

I know my keys are properly set because I have been able to encrypt files using the script and command line, and decrypt using command line, but have NOT been able to decrypt using the Perl script. This error is really getting to me and would really appreciate any help. There seems to be VERY little out there about this specific issue.

Note, I am using GnuPG to handle the PGP encryption.

File to Decrypt: xxxx_26867_21052008171501.txt.asc

Decrypt sub:

Code:
sub decrypt_file {
	my $decrypt_fileName=@_[0];

    my $gpg = new GnuPG( trace => 1);
	my $output = substr($decrypt_fileName, 0, rindex($decrypt_fileName, "."));

    $gpg->decrypt (  output => $output,		ciphertext  => $decrypt_fileName, passphrase => $GPG_PASSPHRASE);
}
The exact error I am getting:

Quote:
protocol error: expected DECRYPTION_OKAY got PLAINTEXT:
at ./xxxxxxx.pl line 236




Contents of file xxxx_26867_21052008171501.txt.asc:

Quote:
-----BEGIN PGP MESSAGE-----
Version: McAfee E-Business Server v7.1.1 - Full License

a55^jh#2cnmpoiunvsampleencryptedcharshere
-----END PGP MESSAGE-----



Now, to test the BASIC functionality of the encrypt/decrypt to try and figure out the root of the problem, I created a test function. This function does a basic encrypt and decrypt of a basic test file. However, upon executing the script so it just runs this test function, it gives me the SAME error as above.

Below is the test function that I've tried to run:

Code:
######  FOR TESTING PURPOSES ONLY ###################################################
#
#
#
sub test_encrypt  {

	my $gpg = new GnuPG();

	$gpg->encrypt (  plaintext => "xxxxx.pl", output => "TEST.pl.gpg", armor => 1,
                     recipient => "yyyyyyy", sign => 1, 
                     local_user	=> "yyyyyyy", passphrase => $GPG_PASSPHRASE);

        $gpg->decrypt (  ciphertext  => "TEST.pl.gpg",			output	=> "TEST.pl",
					 passphrase  => $GPG_PASSPHRASE);

}

Keep in mind, a lot of substitutions were made for explicit file names and key ID's in the above code for obvious reasons.

Thank you for ANY help that you can provide. This really has stumped me for some time.
 
Old 05-28-2008, 02:57 PM   #2
Marcidius
LQ Newbie
 
Registered: May 2008
Posts: 2

Original Poster
Rep: Reputation: 0
Solution

I finally broke down and decided to go the only route that I have read about when trying to fix this problem.

Apparently its a bug in the latter versions of GnuPG and requires a code change to the module. Instructions are found here:

LINKY

I wasn't so sure this is the route I wanted to take. But due to the lack of any other solutions, I really had no other choice.

Just posting as a follow-up in case anyone else runs into this problem. It definitely has fixed my problem.
 
Old 05-30-2008, 04:43 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 26,529
Blog Entries: 51

Rep: Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601Reputation: 2601
Thanks for posting a fix follow-up.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
gnupg key generation error! gabsik Linux - Security 0 02-28-2008 09:08 PM
gnupg compile fatal error - how do I fix it? rkmason Linux - Software 3 06-07-2007 01:26 AM
Packman "Unknown GnuPG key" error erpe Suse/Novell 1 12-09-2006 11:33 AM
PHP GnuPG encryption/decryption on a production webserver ahelis Programming 2 05-28-2006 12:14 AM
PHP GnuPG encryption/decryption rblampain Programming 5 08-12-2005 10:10 AM


All times are GMT -5. The time now is 08:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration