Binary data in CAPICOM through C#

From: Kaare Langedrag (kare.langedrag_at_ergo.no)
Date: 09/26/03


Date: Fri, 26 Sep 2003 15:39:07 +0200


I want to sign and verify (and encrypt and decrypt) binary data with capicom
through C#.
I have found most parts of the solution (1-5 below), but i miss the last
part (6).

I hope someone could help me with the right code-lines to get the IntPtr
value from the dll back into a C# array.....

what i have done so far is:

1) i dissassembled the default created interop dll for capicom

2) i replaced "string " to "native int" in:
        .property string Content()
        .get instance string CAPICOM.SignedDataClass::get_Content()
        .set instance void CAPICOM.SignedDataClass::set_Content(string)
        .get instance string CAPICOM.ISignedData::get_Content()
        .set instance void CAPICOM.ISignedData::set_Content(string)
        .get instance string CAPICOM.EnvelopedDataClass::get_Content()
        .set instance void CAPICOM.EnvelopedDataClass::set_Content(string)
        .set instance void CAPICOM.IEnvelopedData::set_Content(string)
        .get instance string CAPICOM.IEnvelopedData::get_Content()
        .get instance string CAPICOM.EncryptedDataClass::get_Content()
        .set instance void CAPICOM.EncryptedDataClass::set_Content(string)
        .get instance string CAPICOM.IEncryptedData::get_Content()
        .set instance void CAPICOM.IEncryptedData::set_Content(string)
3) i replaced "string marshal( bstr)" to "native int" in:
        instance void set_Content([in] string marshal( bstr) pVal) runtime

4) i assembled a new interop dll

5) I load binary data to be signed or enveloped. (data is a signeddata or
envelopeddata object)

byte []dataContentByte;
unsafe
{
 fixed(byte * bstrPtr = &dataContentByte[0])
 {
  data.Content = new IntPtr (bstrPtr);
 }
}

6) I have not figured how to get the resulting (signed or enveloped) read
the data from the resulting IntPtr (data.sign() and data.envelop())......



Relevant Pages

  • Re: Signing binary data with CAPICOM
    ... You can place binary data in to the BSTR you are passing to CAPICOM. ... By definition this is a Unicode string. ...
    (microsoft.public.platformsdk.security)
  • Re: Binary data in CAPICOM through C#
    ... and the appropriate dis/ass workaround was discussed ... Search for thread "How do we sign binary data". ... > I want to sign and verify binary data with capicom ... > 1) i dissassembled the default created interop dll for capicom ...
    (microsoft.public.platformsdk.security)
  • Re: Binary data in CAPICOM through C#
    ... and the appropriate dis/ass workaround was discussed ... Search for thread "How do we sign binary data". ... > I want to sign and verify binary data with capicom ... > 1) i dissassembled the default created interop dll for capicom ...
    (microsoft.public.platformsdk.security)
  • Re: Binary data in CAPICOM through C#
    ... and the appropriate dis/ass workaround was discussed ... Search for thread "How do we sign binary data". ... > I want to sign and verify binary data with capicom ... > 1) i dissassembled the default created interop dll for capicom ...
    (microsoft.public.platformsdk.security)
  • CAPICOM: how to encode binary data
    ... I'm trying to use capicom, from VB6, to encode binary data: ...
    (microsoft.public.platformsdk.security)