How can I decrypt a file encrypted with the FreeBSD bdes(1) command using openssl?

1

The file was encrypted using the FreeBSD bdes(1) command with the default parameters.

Diomidis Spinellis

Posted 2012-10-04T11:53:36.620

Reputation: 532

Answers

1

Assuming $KEY contains the key used for the bdes(1) encryption, the following sequence does the job.

 HEXKEY=`echo -n $KEY | 
   dd conv=parodd | 
   od -t x1 2>/dev/null | 
   awk '{$1=""; print}' |
   sed 's/ //g'` 
 openssl enc -d -K $HEXKEY -iv 0 -des-cbc

One remaining problem, is that openssl complains when it reaches the end of the file.

Diomidis Spinellis

Posted 2012-10-04T11:53:36.620

Reputation: 532

1Specify -n to echo, in order to avoid including a spurious newline in the key. Otherwise modern openssl versions issue an error message, hex string is too long, and fail to decrypt. – Diomidis Spinellis – 2017-11-21T14:57:53.070

I corrected the command invocation. – Diomidis Spinellis – 2017-11-21T15:03:43.333