On 2010-10-16 11:39 PDT, Matej Kurpel wrote:
>   On 16. 10. 2010 18:33, Nelson B Bolyard wrote:

>> The SignData method you're trying to use does all the above steps.
>> It wants the input to step 1.  Since you're implementing CKM_RSA_PKCS,
>> the data you're given is the input to step 3, the output from step 2.
>> You can deconstruct it and obtain from it the output from step 1, [...]

> Thank you, Nelson, it works now. I used the SignHash method instead, 
> with the OID string "1.3.14.3.2.26", which means SHA1. And I took just 
> the last 20 bytes of the provided data to sign - which is the hash.

You should not assume that the DigestInfo you're given will always contain
a SHA1 hash.  It may contain other hashes from other algorithms, of other
lengths.  It will always contain the proper OID string for the hash it has
used.  So, you should parse the DigestInfo you're given as input.  Take it
apart.  Pull out the OID string and the hash string using the explicit
lengths encoded in the DigestInfo, then pass those to SignHash.  Parsing
the DigestInfo is very straightforward.  I'm sure you can figure it out.

-- 
/Nelson Bolyard
-- 
dev-tech-crypto mailing list
dev-tech-crypto@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to