Wan-Teh Chang wrote:
That should work because we start with a new DigestBegin, which does the C_DigestInit. Doing it this way saves creating a new Session (whch happens in PK11_CreateDigestContext) as well as the malloc for the context itself.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 reusea 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.)
Yes, this is definately allowed and saves a copy. bob
Wan-Teh _______________________________________________ dev-tech-crypto mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-crypto
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ dev-tech-crypto mailing list [email protected] https://lists.mozilla.org/listinfo/dev-tech-crypto

