encryptiondes3desemv

Does .Net TDES do enc-dec-enc or end-enc-enc?


I am trying to authenticate a payment card in .Net 4.5. EMV Book 2 Annex B1.1 says that: DES3(K)[X] = DES(K L )[DES -1 (K R )[DES(K L )[X]]] or, 3DES of X means:

Blockquote

  1. encrypt X with the left half of the 16 byte key
  2. decrypt that ciphertext with the right half of the 16 byte key
  3. encrypt that supposed plaintext with the left half of the key.

which you could call enc-dec-enc. Can anyone assure me that .Net's TripleDESCryptoServiceProvider does it that way, as opposed to enc-enc-enc? The ms docs page doesn't say.


Solution

  • Irrespective of language, all implementations of TDES follow Encrypt-Decrypt-Encrypt. For a double length key, Encrypt data using first block[first 8 bytes], decrypt using the second block[second 8 bytes] and encrypt again using first block. For triple length key, in the last step of encrypting using the first block, third key block is used intead. If you want to make sure of the same, simply pass some test key and data to the library, and compare the value you get from any online free tools like https://paymentcardtools.com/des-calculator

    I can see it is mentioned in the documentation. Click on TripleDES in the begining and then read the remarks section.