EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Encrypt / Decrypt Value using 3DES

Posted: 07/27/2016 05:43:10
by koos smithel (Basic support level)
Joined: 07/27/2016
Posts: 2


I need some advice on decrypt and encrypt the following using 3 DES.

My key is = 0D5892DAF8D91A3DC8B5645D4AB92AC8
Padding = ANSI X9.23
IV = 0000000000000000
Data Input = Hex
Value to encrypt = 040037BFCFECADBF

I had a look at the samples in the forum but I cant get my code to work properly. I am getting the following error : "Invalid key material"

  Crypto : TElSymmetricCrypto;
  KM : TElSymmetricKeyMaterial;
  KeyStr : string = '0D5892DAF8D91A3DC8B5645D4AB92AC8';
  IVStr : string = '0000000000000000';
  InBuf, OutBuf: ByteArray;
  OutSize : integer;
  OutSize := 0;
  Crypto := TElSymmetricCrypto.Create(SB_ALGORITHM_CNT_3DES, cmECB);
  KM := TElSymmetricKeyMaterial.Create();
    KM.Key := BytesOfString(KeyStr);
    KM.IV := BytesOfString(IVStr);
    Crypto.Padding := cpANSIX923;
    InBuf := BytesOfString('040037BFCFECADBF');

    Crypto.KeyMaterial := KM;
    OutSize := Length(InBuf) * 6;
    SetLength(OutBuf, OutSize);
    Crypto.Encrypt(@InBuf[0], Length(InBuf), @OutBuf[0], OutSize);
    //SetLength(OutBuf, OutSize);

    Not_base64.Text :=  SBUtils.StringOfBytes(OutBuf);
   // edtNew_encrypt.Text := SBUtils.StringOfBytes(OutBuf);
    edtNew_encrypt.Text := SBEncoding.Base64EncodeArray(OutBuf, false);
    //Writeln(BinaryToString(@OutBuf[0], OutSize));
Posted: 07/27/2016 07:31:11
by Vsevolod Ievgiienko (Team)

Thank you for contacting us.

I’ve noticed there is no Support Access Ticket linked to your user account on EldoS site. Technical Support is provided to customers with the linked Support Access Ticket. You will find your Support Access Ticket together with all the details about how to use it in the registration e-mail that we’ve sent to you upon the purchase.

If you are evaluating the product and don't have a license yet, please let us know and then you can have support according to Basic support level. Basic support level includes answering basic technical questions that appear during product evaluation period. We also offer Premium support for a purchase from https://www.eldos.com/support/calc.php . You can use Premium Support to get higher level of assistance during your evaluation of our products.
Posted: 07/27/2016 08:09:26
by koos smithel (Basic support level)
Joined: 07/27/2016
Posts: 2

Good day,

Yes I am only evaluating your product to see if 3DES encryption/ decryption will work for us, but at this stage I cant see if it will work for us because I cant get your demo to work.
Posted: 07/27/2016 11:10:15
by Eugene Mayevski (Team)

For 3DES you must have key size of exactly 24 bytes and IV size of exactly bytes. Your values are different, and that's why you get the exception.

Your IV is 16 bytes, and looks like BASE16-encoded binary value of the IV. So far so good (after you decode it).

Now I see that your key is 32 bytes, which is not even a BASE16-encoded value of 24-byte key. I don't know what kind of transform you need to apply to get 24-byte key that matches the key of the other side.

Sincerely yours
Eugene Mayevski



Topic viewed 1307 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!