Re: Capicom envelopeddata.decrypt failing when content > 64k
From: Michel Gallant (neutron_at_NOSPAMistar.ca)
Date: Wed, 24 Mar 2004 15:38:12 -0500
Well, there was a lot of discussion about this COM marshalling issue
in the capicom alias. Posted solution was dis/reass the COM iterop dll which
i didn't like. Doable but I wanted (and some customers too) "stalk" interop
assemblies with no customizations!
So, I opted for Pinvoke; e.g. for decrypting enveloped data:
(see CAPICOM note at bottom of that page).
"David Pinz" <firstname.lastname@example.org> wrote in message
> Hi Mitch,
> I am using CAPICOM 184.108.40.206, and the standard
> capicom.dll /namespace:CAPICOM /out:Interop.CAPICOM.dll
> I don't know why this is happening it works fine for sizes
> under 64k.
> Did you try de enveloping/deenveloping using .NET? It
> comes to my mind that this might be another interop issue,
> I'll keep trying to figure this out, if you have any other
> suggestion i'll be glad to hear it.
> >-----Original Message-----
> >What version of CAPICOM?
> >I just tried a vbs and enveloped/denveloped a bin file
> with 1,234,111 bytes
> >with no problems.
> >Maybe an implemention issue in your COM interop?
> >- Mitch
> >"David Pinz" <email@example.com> wrote
> in message
> >> Hi group,
> >> I am using C# and interop.Capicom to envelope and
> >> deenvelope data, the enveloped data is in binary format.
> >> All works fine until the enveloped content reaches a
> >> greater than 65536 bytes, when this happens the decrypt
> >> method fails. This happens for both even and odd count
> >> bytes (interop issue)
> >> This is the exception I'm getting:
> >> System.Runtime.InteropServices.COMException
> >> ASN1 unexpected end of data.
> >> at CAPICOM.EnvelopedDataClass.Decrypt(String
> >> EnvelopedMessage)
> >> I am clueless about this size limit, this behavior is
> >> happenning for both the interop.capicom and a workaround
> >> version of it that I am using (the binary interop
> >> workaround)
> >> Any insigth would be greatly appreciated.
> >> Code:
> >> EnvMessage.Content =
> >> System.Text.Encoding.Unicode.GetString (bytesMsg);
> >> EnvMessage.Recipients.Add(oCert);
> >> EnvMessage.Algorithm.Name =
> >> DES;
> >> result = EnvMessage.Encrypt
> >> (CAPICOM_ENCODING_TYPE.CAPICOM_ENCODE_BINARY);
> >> EnvMessage.Decrypt(result)