Unix/Linux Go Back    


Security Discuss UNIX and Linux computer and network security, cyber security, cyber attacks, IT security, and more.

OpenSSL

Security


Tags
des, file encryption, openssl, rc4, solved

Closed    
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 09-19-2015
Ultrix Ultrix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 26 October 2015, 5:05 PM EDT
Location: The bash shell
Posts: 61
Thanks: 8
Thanked 0 Times in 0 Posts
OpenSSL

I just started playing around with Unix's OpenSSL utility. I can't seem to get the hang of it, and the man page isn't helping much. I wanted to experiment with file encryption, so I created a dummy text file with one line of text and tried to encrypt it using DES. I used the following command:


Code:
openssl des -in Encrypt.txt -out Encrypted.txt

As expected, this produced an encrypted file whose contents were illegible. Then I tried to decrypt the file. I figured since most of these encryption algorithms are based on XORing the key with the message, I would be able to apply the same command to get the original plaintext. So I used a variation of the same command.


Code:
openssl des -in Encrypted.txt -out Decrypted.txt

I opened the file Decrypted.txt and found that it was still illegible. I hadn't gotten the original plaintext back. "Okay," I thought, "I guess I don't know much about how to use DES, since it's a block cypher. Maybe I'll try a stream cypher, since I'm more familiar with how they work, and I know for a fact that for a stream cypher, encryption and decryption use the same algorithm."

I used the following commands:


Code:
openssl rc4 -in Encrypt.txt -out Encrypted.txt
openssl rc4 -in Encrypted.txt -out Decrypted.txt

Still doesn't work.

Then I noticed something strange when looking at the files. The encryption algorithm had added a human-readable prefix to the encrypted file, reading "Salted__". So it looks like what happened was the encryption algorithm added that prefix, when meant that when the same algorithm was applied again, it had a different starting point, so when it started decrypting the original message, after XORing the first eight bytes of the key with the prefix, it would be XORing a completely different part of the key with the same characters, resulting in a gibberish result.

So my question is, what is the proper way to encrypt and decrypt files using OpenSSL? Can anyone point me to any good tutorials? Because, as I said, the man page isn't providing much help.
Sponsored Links
    #2  
Old Unix and Linux 09-19-2015
RudiC RudiC is offline Forum Staff  
Moderator
 
Join Date: Jul 2012
Last Activity: 25 June 2017, 2:06 PM EDT
Location: Aachen, Germany
Posts: 10,955
Thanks: 280
Thanked 3,367 Times in 3,100 Posts
How about using the -d option? (-e is the default)
The Following User Says Thank You to RudiC For This Useful Post:
Ultrix (09-20-2015)
Sponsored Links
    #3  
Old Unix and Linux 09-20-2015
Ultrix Ultrix is offline
Registered User
 
Join Date: Feb 2010
Last Activity: 26 October 2015, 5:05 PM EDT
Location: The bash shell
Posts: 61
Thanks: 8
Thanked 0 Times in 0 Posts
Thank you. That works.
Sponsored Links
Closed

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
openSSL command help shade917 Shell Programming and Scripting 2 06-14-2012 10:35 AM
openssl issue newaix AIX 3 03-15-2012 04:24 PM
Openssl 0.9.8r callmebob Solaris 2 03-16-2011 11:04 AM
Using openssl MichaelInDC UNIX for Advanced & Expert Users 7 03-14-2011 11:28 AM
openssl help hassan2 UNIX for Advanced & Expert Users 2 10-31-2002 12:59 PM



All times are GMT -4. The time now is 03:08 PM.