2008/8/15 Sam Laidler <[EMAIL PROTECTED]>:
> Hello, hope all is well.
>
>
>
> I was wondering if I might ask about hashing efficiency. I am reiteratively
> hashing values. Basic algorithm is:
>
>
>
>   digestCntxt = PK11_CreateDigestContext(algorithm);
>
>
>
>   while (counter < configuredIterations)
>
>   {
>
>     PK11_DigestBegin(digestCntxt);
>
>
>
>     PK11_DigestOp(digestCntxt, input, inputLgth);
>
>
>
>     PK11_DigestFinal(digestCntxt, digest, &digestLgth, 32);
>
>
>
>     /* On next iteration, the digest becomes the input */
>
>     Copy(input, digest, 32);
>
>   }
>
>
>
>   PK11_DestroyContext(digestCntxt, PR_TRUE);
>
>
>
> I was just wondering if this is the most efficient way.

Off the top of my head, I'm not sure if you can reuse
a digest context after PK11_DigestFinal.  Assuming
that works, the only optimization I can think of is
to use the 'input' buffer to receive the digest from
PK11_DigestFinal.  This eliminates the Copy calls:

    PK11_DigestFinal(digestCntxt, input, &digestLgth, 32);

This assumes the 'input' buffer is at least 32 byte long.
(Your Copy call makes the same assumption.)

Wan-Teh
_______________________________________________
dev-tech-crypto mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-crypto

Reply via email to