Re: Signing binary data with CAPICOM

From: Shawn Corey [MSFT] (shawncor_at_online.microsoft.com)
Date: 10/12/04


Date: Mon, 11 Oct 2004 19:32:50 -0700

You can place binary data in to the BSTR you are passing to CAPICOM. There
is also no problem with odd length strings, BSTRs do not have to be unicode
and CAPICOM treats all BSTRs passed into it as an array of bytes internally.
The only thing to watch out for is if you are using managed code, the
framework marshalls all BSTRs as Unicode so there can be problems with
compatability between managed and unmanaged because extra bytes may be added
in the managed code.

-- 
Thanks,
Shawn
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at 
http://www.microsoft.com/info/cpyright.htm
"Bill Brice" <BillBrice@discussions.microsoft.com> wrote in message 
news:9063FA8C-2ED0-4468-BF03-B699B5583BC4@microsoft.com...
> CAPICOM expects data to-be-signed to be stored in a BSTR in the
> SignedData.Content property. By definition this is a Unicode string.  If 
> you
> have binary data, it is possible to load it into a byte array and assign 
> the
> byte array to a string and then to SignedData.Content.  What if the binary
> data is an odd number of bytes in length?  Does CAPICOM handle this 
> properly,
> or does it always assume an even number of bytes, since the Content 
> property
> is a BSTR?  Please clarify and also identify any other issues with signing
> binary data using CAPICOM.  Thanks.
> -- 
> Bill Brice 


Relevant Pages

  • Re: How to pass a vc++ BSTR value to C#.Net
    ... So we might have a suitation where an encryption might take place using COM ... Actually I'm able to return the binary data in the form of BSTR by using ... Encryption of a string doesn't give you another string. ...
    (microsoft.public.dotnet.languages.csharp)
  • Signing binary data with CAPICOM
    ... CAPICOM expects data to-be-signed to be stored in a BSTR in the ... By definition this is a Unicode string. ... have binary data, it is possible to load it into a byte array and assign the ...
    (microsoft.public.platformsdk.security)
  • Re: Copying string to byte array
    ... >> VB strings cannot contain arbitrary binary data. ... > BSTR OLE automation data type for strings. ... since you are defining right and wrong. ...
    (microsoft.public.vb.general.discussion)
  • Wrong returned binary data stored in BSTR
    ... Dim retstring As String ... Dim buffer() As Byte ... thought that it was possible to put binary data in BSTR ?). ...
    (microsoft.public.vc.atl)
  • 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)