Re: Signature verification with capicom

From: Michel Gallant (neutron_at_NOSPAMistar.ca)
Date: 01/28/04


Date: Wed, 28 Jan 2004 11:15:19 -0500

This is a common problem., discussed several tims in CAPICOM list.
CAPICOM by default tends to want all
content signed, or encrypted, in UNICODE byte encoding and most
of the samples with CAPICOM 2.0.0.3 reflect that.

One approach is to acquire your file data as raw binary data
and then use CAPICOM.Utilities.ByteArrayToBinaryString
and pass this binary packed string as Content to SignedData (or EnvelopedData).

Most S/MIME applications that I have seen sign the raw binary data (not UNICODE
encoded) bytes.

For WSH scripting, you can also sign raw binary data files, but you need support
from MDAC .. e.g.
   Set oStream = WScript.CreateObject("ADODB.Stream")
along with ByteARrayToBinaryString

- Mitch Gallant
  MVP Security
  http://pages.istar.ca/~neutron

"Marco" <tiodemo@hotmail.com> wrote in message
news:74f999d4.0401280653.3ae6bf75@posting.google.com...
> Hi everybody,
>
> I'm developing an application that signs a pdf file with iaik
> libraries in java and verify the signature created in visual basic.
> I'm using the capicom libraries, the sign process goes well but in the
> verify process, capicom says that the hashes don't match. Iaik sends
> an ans1 object encoded in base64, that match with the one generated
> with capicom but the hash created from the original file.
> If I make the hash with iaik with a plain text file, it returns the
> correct hash, but i I do the same with capicom (with
> CAPICOM.hashedData object), it returns other hash, and I have to call
> this function (extracted from the capicom examples):
>
> Function Unicode2Ansi(unicodestring)
> Dim lngLoop
> Dim strChar
> Ustr2Bstr = ""
>
> For lngLoop = 1 To Len(unicodestring)
> strChar = Mid(unicodestring, lngLoop, 1)
> Unicode2Ansi = Unicode2Ansi & ChrB(AscB(strChar))
> Next
> End Function
>
> and later do the hash to get the correct value. Finally I will use pdf
> files (not plain text files, i use them only for tests). 'what can I
> do to sing pdf files and make capicom understand the hash that iaik
> creates (well created)??
>
> Thanks in advice,
>
> Marco Antonio Tabasco



Relevant Pages

  • Signature verification with capicom
    ... sign verify reverse the entire buffer. ... capicom says that the hashes don't match. ... Iaik sends ... >with capicom but the hash created from the original file. ...
    (microsoft.public.platformsdk.security)
  • Re: Signature verification with capicom
    ... > sign verify reverse the entire buffer. ... capicom says that the hashes don't match. ... > Iaik sends ... >>with capicom but the hash created from the original file. ...
    (microsoft.public.platformsdk.security)
  • VB Script Trying to use Capicom
    ... I had a script which used Capicom to calculate a MD5 hash for a file ... error loading DLL 'crypt.Algorithm' ... I installed Capicom and gave Everyone full access to it. ...
    (microsoft.public.scripting.vbscript)
  • Signature verification with capicom
    ... I'm developing an application that signs a pdf file with iaik ... I'm using the capicom libraries, the sign process goes well but in the ... If I make the hash with iaik with a plain text file, ...
    (microsoft.public.platformsdk.security)
  • Re: Java EnvelopedData --> CAPICOM.Decrypt
    ... > EnvelopedData created with Java IAIK toolkit. ... > CAPICOM doesn't understand, but don't know what it may be. ... You can use the dumpasn1 tool: ...
    (microsoft.public.platformsdk.security)