string to _bstr_t conversion

From: Marco (tiodemo_at_hotmail.com)
Date: 02/04/04


Date: 4 Feb 2004 10:34:29 -0800

Hi everybody,

  I'm developing an application that reads a text file delimited with
fields. The application must verify a signature that is inserted in
one of the fields. In another field is the entire content of the
signed file in base 64.

I'm using the Capicom libraries to verify the signature. I decode the
content of the file and insert it into a type string. The signedData
object of Capicom needs to recive in the property content a type
_bstr_t.

My problem is how to convert my string into a _bstr_t. I have made
some test like this:
        
       string str = base64decode(example variable);
       _bstr_t bs = str.c_str();

I can't use The following code 'cause I need to use a variable instead
of plain text as the parameter of SysAllocString. This variable must
be the decoded message (str in the above example):

       BSTR strFoo = SysAllocString(L"This is a test");
       _bstr_t bstrFoo = strFoo;
       SysFreeString(strFoo);
       std::string sstrFoo = bstrFoo;

Can anybody help me, please? Is there any other way of convert this
kind of string for insert the decode message to a signedData object?
Can my problem be in loosing data 'cause the data is binary format
(the file is a pdf document)?

This is the code i'm using now:

CString m_ContenidoFactura; ---> the base64 encoded content of the pdf
CString m_FirmaFactura; ---> the base64 encoded signature

string sContenidoFactura = b64->decode ((string)m_ContenidoFactura);
CString csContenidoFactura(sContenidoFactura.c_str());
                        
_bstr_t bsContenidoFactura(csContenidoFactura.AllocSysString());
                                                                
_bstr_t bsSig = pISignedData->Verify
(m_FirmaFactura.AllocSysString(),true,CAPICOM_VERIFY_SIGNATURE_ONLY );

Thanks to all, any reply will be wellcomed.

Marco Antonio Tabasco.



Relevant Pages

  • Re: Reply with attachment macro
    ... the Insert -> Signature menu. ... Sub ReplyWithTemplateFromOutlook() ... Dim objReply As Outlook.MailItem ... Dim strSignatureText As String ...
    (microsoft.public.outlook.program_vba)
  • Re: how can we restrict what certificate WSE will use?
    ... > X509SecurityTokenManager to verify the request is from a trusted client. ... > certificate to build a valid signature and encrypted data section. ...
    (microsoft.public.dotnet.framework.webservices.enhancements)
  • Re: Keyed hash vs Digital signature ????
    ... For DSIGs you usually use certificates. ... Otherwise it is not possible to verify that you are really using the right public key ... Certs can be made available in various ways - e.g. you can embed them in the signature, make them downloadable and so forth. ... I have understand that hashing a file with a keyed Hash class, ...
    (microsoft.public.dotnet.security)
  • RE: problem verifying XML signature
    ... I've just tried to verify your signature using v2.0, ...
    (microsoft.public.dotnet.security)
  • Re: Check EXE for MY signature only
    ... signature - but at least the code-signing certificate would reveal WHO ... I am trying to figure out how to verify that a dll is signed by my own ... I should probably compare the public key, ...
    (microsoft.public.platformsdk.security)