Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am working on a little script that crypts a file to be sent to one of our suppliers.

The workflow is as follows:

  1. We created a key, which we asymetric crypt using the public key they have provided
  2. With crypted key, we make a symetric encryption of the file we need to send
  3. We then compress both files (key + file)
  4. Once received, they unzip the file
  5. They uncrypt the key using their private key
  6. Then they uncrypt the file by using the key decrypted

Here are the commands used:

ON LINUX

  • openssl rand -base64 30 > my.key
  • chmod 700 my.key
  • openssl enc -aes-256-cbc -in myfile.zip -out myfile.bin -kfile my.key
  • openssl rsautl -encrypt -pubin -inkey supplier_key.pem -in my.key -out encrypted.key

ON WINDOWS

  • openssl\bin\openssl.exe rand -base64 30 > my.key
  • openssl\bin\openssl.exe enc -aes-256-cbc -in myfile.zip -out myfile.bin -kfile my.key
  • openssl\bin\openssl.exe rsautl -encrypt -pubin -inkey supplier_key.pem -in my.key -out encrypted.key

We have to do this because the file is too big to be asymetric crypted.

To do that, I was at first on a cygwin environment, and it was working perfectly. But now, I have to make it run on a full Windows environment. I have adapted the script, and downloaded the openssl program for windows.

But, when our supplier receives the file, the step 6) is not working :/

They have this error :

> bad decrypt 6566:error:06065064:digital envelope
> routines:EVP_DecryptFinal_ex:bad decrypt:evp_enc.c:325:

I have changed absolutely nothing to the way of work, the script is basically the exact same, so I don't see why the decryption of the file is not working (they can though decrypt the key)

share|improve this question
    
What exact commands are you using for each encryption step? Have you tried decrypting the files yourself (if so, exactly what commands?) What version of OpenSSL are you using? What version is the supplier using? openssl version –  RedGrittyBrick Aug 30 '12 at 9:10
    
Are you sure the file is the same in both places? Transmit a checksum and have them verify it. –  Ignacio Vazquez-Abrams Aug 30 '12 at 9:21
    
hi, here are the command used: ON LINUX openssl rand -base64 30 > my.key chmod 700 my.key openssl enc -aes-256-cbc -in myfile.zip -out myfile.bin -kfile my.key openssl rsautl -encrypt -pubin -inkey supplier_key.pem -in my.key -out encrypted.key ON WINDOWS openssl\bin\openssl.exe rand -base64 30 > my.key openssl\bin\openssl.exe enc -aes-256-cbc -in myfile.zip -out myfile.bin -kfile my.key openssl\bin\openssl.exe rsautl -encrypt -pubin -inkey supplier_key.pem -in my.key -out encrypted.key openssl versions differs slighlty but, as they can decrypt the key, i assume it is not an issue. Thx. –  Zapp Aug 30 '12 at 13:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.