tags:

views:

44

answers:

1

hi all

i am porting opera recovery from alredy existed c++ code

http://pastebin.com/ViPf0yn6

i struck at this line

DES_set_key_unchecked((const_DES_cblock *)&hashSignature1[0],&key_schedule1);

where can i found a procedure/function similar to that in delphi

thanks in advance

A: 

Rather than worry about that specific function, take a step back and look at the overall goal of the code. The code is meant to encrypt something with 3DES. The behavior of any one function doesn't matter as long as you've 3DES-encrypted the message.

To that end, you should be asking for a library capable of doing 3DES encryption with Delphi. DCPcrypt is an example. Use its TDCP_3des class and call its Init method. The function expects the input key to be an array of three keys, each eight bytes wide. What DES_set_key_unchecked was doing in the original code was to fill a platform-specific DES_key_schedule structure with some of the bytes from the MD5 hashes calculated earlier. DCPcrypt uses a different platform-specific structure:

var
  keys: array[0..2, 0..7] of Byte;
  ThreeDes: TDCP_3des;

Move(hashSignature1[0], keys[0], SizeOf(keys[0]));
Move(hashSignature1[8], keys[1], SizeOf(keys[2]));
Move(hashSignature2[0], keys[2], SizeOf(keys[1]));
ThreeDes.Init(keys, SizeOf(keys) * 8, ...);
Rob Kennedy