Home All Groups Group Topic Archive Search About

How to decrypt CAPICOM data i .NET 2.0

Author
13 Nov 2006 12:07 PM
Karel Kral
Hello,
I have CAPICOM encrypted data. Data cames from VB6 application (see
sample bellow). Now I want to decrypt this data in VB.NET (or C#).

Are there native .NET 2.0 library to decrypt CAPICOM data or I must have
import CAPICOM interop and use this one?

Example of VB.NET encryption:
  Dim message As New EncryptedData
  message.Content = txtPrefix.Text & cbId.Text & txtHodnota
  message.SetSecret txtPwd.Text
  message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_DES
  CryptMsg message.Encrypt


Example of VB.NET decryption:
Set message = New EncryptedData
        message.SetSecret mvarKreditVerze
        message.Decrypt "Key"
        DecryptMsg = message.Content

Karel Kral

Author
13 Nov 2006 3:14 PM
Joe Kaplan
My understanding is that the CAPICOM encryption format is proprietary to
CAPICOM (unliked their signed and enveloped structures, which are standard),
so you must use CAPICOM to decrypt as well.  You can do this from .NET via
COM Interop.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
Show quoteHide quote
"Karel Kral" <kral.k***@volny.cz> wrote in message
news:%23y7VPxxBHHA.4680@TK2MSFTNGP04.phx.gbl...
> Hello,
> I have CAPICOM encrypted data. Data cames from VB6 application (see
> sample bellow). Now I want to decrypt this data in VB.NET (or C#).
>
> Are there native .NET 2.0 library to decrypt CAPICOM data or I must have
> import CAPICOM interop and use this one?
>
> Example of VB.NET encryption:
>  Dim message As New EncryptedData
>  message.Content = txtPrefix.Text & cbId.Text & txtHodnota
>  message.SetSecret txtPwd.Text
>  message.Algorithm.Name = CAPICOM_ENCRYPTION_ALGORITHM_DES
>  CryptMsg message.Encrypt
>
>
> Example of VB.NET decryption:
> Set message = New EncryptedData
>        message.SetSecret mvarKreditVerze
>        message.Decrypt "Key"
>        DecryptMsg = message.Content
>
> Karel Kral
Author
14 Nov 2006 7:44 AM
Karel Kral
Thanks, it is I was worry about. So I must to say goodbye to XCopy
deployment (CAPICOM must me registered ActiveX).

On 13.11.2006 16:14, Joe Kaplan wrote:
Show quoteHide quote
> My understanding is that the CAPICOM encryption format is proprietary to
> CAPICOM (unliked their signed and enveloped structures, which are standard),
> so you must use CAPICOM to decrypt as well.  You can do this from .NET via
> COM Interop.
>
> Joe K.
>
Author
14 Nov 2006 3:17 PM
Joe Kaplan
Or say goodbye to CAPICOM, yes.  Sorry.  Personally, I'd try to avoid using
this feature of CAPICOM as it is proprietary and just asking for trouble.
I'd use the Enveloped data support with EnvelopedCms in .NET 2.0 (or the
crypto message stuff in crypto API for native support).  You may be stuck
with an existing thing you can't change though.

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
Show quoteHide quote
"Karel Kral" <kral.k***@volny.cz> wrote in message
news:%23CR1wC8BHHA.4908@TK2MSFTNGP03.phx.gbl...
> Thanks, it is I was worry about. So I must to say goodbye to XCopy
> deployment (CAPICOM must me registered ActiveX).
>
> On 13.11.2006 16:14, Joe Kaplan wrote:
>> My understanding is that the CAPICOM encryption format is proprietary to
>> CAPICOM (unliked their signed and enveloped structures, which are
>> standard),
>> so you must use CAPICOM to decrypt as well.  You can do this from .NET
>> via
>> COM Interop.
>>
>> Joe K.
>>
Author
14 Nov 2006 8:26 PM
Karel Kral
> You may be stuck with an existing thing you can't change though.

Yes, this is exactly my case. The bigger part of our app is VB6 and must
to use CAPICOM. So newer .NET part must adapt to these crypted data data.

Joe Kaplan wrote:
Show quoteHide quote
> Or say goodbye to CAPICOM, yes.  Sorry.  Personally, I'd try to avoid using
> this feature of CAPICOM as it is proprietary and just asking for trouble.
> I'd use the Enveloped data support with EnvelopedCms in .NET 2.0 (or the
> crypto message stuff in crypto API for native support).  You may be stuck
> with an existing thing you can't change though.
>
> Joe K.
>