Re: 3DES between .NET and VB

From: Rob Teixeira (RobTeixeira_at_@msn.com)
Date: 11/06/04


Date: Sat, 6 Nov 2004 16:54:27 -0500

The .NET TripleDESCryptoServiceProvider is just a wrapper for the win32
CryptoAPI version of TripleDES.
You can try using the CryptoAPI from VB6 as one solution (though I don't
really recommend that).

Another is to create a COM-visible class from .NET that exposes the
TripleDES functionality. Then use RegAsm to register the .NET assembly and
reference it from VB6 just like it was a COM component.

However, all this is just skirting the issue. The .NET TripleDES class
creates standard Triple DES cipher data. Any other DES implementation should
be able to work with it. I think your biggest problem is understanding all
the options - particularly the options for CipherMode and Padding.
Obviously, you MUST use the same key and IV from both sides, and I hope
you're doing that already. After that, you must be aware that .NET
automatically uses CBC (cipher block chaining) mode and PKCS#7 padding by
default.

Cipher mode on the .NET side tells the algorithm what feedback mode to use.
You can use ECB (no feedback), CBC, OFB, CFB, or CTS. The decryption
algorithm must be able to use the same mode.

Then, you have padding. If your input isn't evenly divisible by the block
size, then padding is applied to the end before it is encrypted. The .NET
class uses PKCS#7 padding by default, but you can choose to pad with Zeros
or use no padding at all. Again, the decryption algorithm must support the
same padding you used for encryption.

-Rob Teixeira

"Joshua Ellul" <jellul@onvol.net> wrote in message
news:OTFcGk1wEHA.3024@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> I have recently implemented the 3DES algorithm using .NET. However, all
> implementations I have found in VB 6 do not work correctly with this
> version. I imagine it is due to different string bases or some
> architectural difference. Could someone point me to some material that
> could help me implement the 3DES for VB that would comply with the .NET
> version.
>
> Best Regards,
>
> Joshua Ellul
>
>