There may be a better approach than this, but what I did was create a
new class derived from CryptoPP::HashTransformation. This new class
gets created with an already-calculated digest buffer. It has an empty
Update() method and implements TruncatedFinal(), DigestSize() and
TruncatedVerify() exactly as you'd think.

Then I have a factory function that takes the digest buffer and length
as parameters and returns a pointer to a newly allocated
CryptoPP::PK_MessageAccumulatorImpl<MyExternalDigestHashTransformation>.

That then gets fed to InputSignature() on a PK_Verifier or Sign() on a
PK_Signer. It's worth remembering that in the former case you own your
PK_MessageAccumulator and in the latter the PK_Signer takes ownership.

I don't think this is a particularly good way to use the library, but
it was the shortest path I could find to doing this in a
digest-agnostic fashion without inviting serious errors.

Geoff

On Thu, Feb 17, 2011 at 11:48, Magnus J <[email protected]> wrote:
> Hi,
>
> How do I go about using RSA for signing an already calculated hash?
>
> I've found the PK_Signer method Sign() but how do I get my hash into a
> PK_MessageAccumulator?
>
> Is there another or even correct way of doing this that I'm missing?
>
> --
> You received this message because you are subscribed to the "Crypto++ Users" 
> Google Group.
> To unsubscribe, send an email to [email protected].
> More information about Crypto++ and this group is available at 
> http://www.cryptopp.com.

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.

Reply via email to