LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 05-06-2010, 09:03 AM   #1
methodtwo
Member
 
Registered: May 2007
Posts: 146

Rep: Reputation: 18
openssl base64 decrypt question


Hi
I need to be able to decrypt data, like simple text files, that have been encrypted and base64 encoded with my public key.I need to use openssl
so i do:
Code:
$cat encrypted | openssl enc -base64 -d > ./answer.txt
and i get exactly the same data as before the command was run.
Am i right in thinking that i need to decode before decrypting?
I tried decrypting, before i realized that i had to decode first,using this command:
Code:
$cat encrypted | openssl rsautl -decrypt -out answer.txt -inkey privatekey.pem
and i got this error:
Code:
RSA operation error
15850:error:0406506C:rsa routines:RSA_EAY_PRIVATE_DECRYPT:data greater than mod len:/on10/build-nd/G10U4B0/usr/src/common/openssl/crypto/rsa/rsa_eay.c:393
:I think my problems are related to base64 line length restrictions.So how do i get round base64 line length problems and base64 decode then decrypt using my privatekey?.I've looked on the openssl web site but i couldn't find anything about base64 line length restrictions and how that may effect decoding!.
Any help would be great.Thank you for your time
regards methodtwo
 
Old 05-06-2010, 01:25 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
The piping and redirection are not necessary. Try using the form:
Code:
$ openssl enc <cipher_here> -in encrypted -out answer.txt -d -a
(The -a switch is short form for base64 processing.)

Last edited by anomie; 05-06-2010 at 01:28 PM.
 
Old 05-12-2010, 10:29 AM   #3
methodtwo
Member
 
Registered: May 2007
Posts: 146

Original Poster
Rep: Reputation: 18
more openssl problems

I want to know how to base64 decode a given file then using my private key how to decrypt the same file.
it was suggested to me to try:
Code:
openssl enc -base64 -in ./deanswer.txt -out ./answer.txt -d -a
that just gave me an empty file as a result.
i tried running this command after the previous one:
Code:
openssl rsautl -decrypt -in encrypted -out answer.txt -inkey privatekey.pem
but just got an error saying:
Code:
Error reading input Data
I need to know how to first base64 decode a given file then how to decrypt the same file using my private key.I'm using openssl for this.I need to get to grips with openssl for tasks like this one.Any help would be great.Please don't merge this with my previous thread on the subject because then no one will see it!.Thank you for your time
regards methodtwo
 
Old 05-12-2010, 01:08 PM   #4
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Not sure why no one would see it. This thread is a logical continuation of your previous thread, and when you add a post to it, the entire thread is bumped to the top of the forum category.

It is not necessary to base64-decode your file first. openssl can do that for you.

But, if you insist, you can use the base64(1) program. Its manpages describe how to decode a file.
 
Old 05-12-2010, 01:10 PM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by methodtwo
I want to know how to base64 decode a given file then using my private key how to decrypt the same file.
it was suggested to me to try:
Code:
openssl enc -base64 -in ./deanswer.txt -out ./answer.txt -d -a
that just gave me an empty file as a result.
Also, that's not exactly what I suggested in the last thread. You need to provide the correct cipher to openssl enc. (The -a option already takes care of base64 decoding.)

-------

edit: Actually, if you're certain that your file is RSA-encrypted, you probably will need to base64-decode it first. Then decrypt it using rsautl(1) as you were trying previously.

Last edited by anomie; 05-12-2010 at 01:17 PM.
 
Old 05-12-2010, 06:33 PM   #6
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590Reputation: 3590
Creating two threads for the same topic is not useful or necessary: threads merged.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
oops openssl-0.9.8e over openssl-0.9.8d bad install now 2 copies? rcorkum Slackware 4 06-29-2007 02:58 AM
OpenSSL Problems Megatog615 Linux - Software 3 06-07-2006 07:13 PM
Having problems updating openssl-0.9.7 to 0.9.8 tequila13 Linux - Software 2 04-01-2006 07:25 AM
openssl problems with psybnc wallflower Slackware 0 09-24-2005 03:33 PM
Openssl Problems Savedadogs Linux - General 1 04-21-2002 02:47 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 05:00 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration