Which openssl command is equivalent to DES_cfb64_encrypt function?

1.4k Views Asked by At

I am trying to decrypt programmatically encrypted file using OpenSSL. OpenSSL was used to encrypt the file and I know both the function and the key that was used:

//This declaration is just figurative
const char keybuf = "12345678";
// Prepare the key for use with DES_cfb64_encrypt
DES_cblock key2;
DES_key_schedule schedule;
// keybuf is the string key used as password
memcpy(key2, keybuf, 8);
DES_set_odd_parity(&key2);
DES_set_key_checked(&key2, &schedule);
int n = 0;
DES_cfb64_encrypt( ..., ..., length, &schedule, &key2, &n, DES_ENCRYPT );

First I converted the file to binary from base64 (which is how it's packed):

cat data.b64 | base64 --decode > data.cr

Now when I run command line on encrypted data (assuming des-cfb is algorighm I need):

openssl enc -d -des-cfb -in data.cr -out data.decr -k 12345678

this is what I get:

bad magic number

So what I'm doing wrong here? Maybe I converted the file wrongly from base64?

1

There are 1 best solutions below

3
On BEST ANSWER

Which openssl command is equivalent to DES_cfb64_encrypt function?

None

The CFB mode is a parametrized mode and the 64 in DES_cfb64_encrypt sets the size of the shift register or segment to 64 bit. The commandline interface only supports 3 segment sizes for CFB mode which are 1 bit, 8 bit and size of the cipher block size (64 bit for DES). Those three parametrized modes are incompatible between each other and they cannot be used to decrypt ciphertexts that were encrypted with CFB-64.