Bug 143826 - Use CommonCrypto for SHA1 and MD5
Summary: Use CommonCrypto for SHA1 and MD5
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-04-16 06:02 PDT by Antti Koivisto
Modified: 2015-04-17 10:54 PDT (History)
3 users (show)

See Also:


Attachments
patch (6.28 KB, patch)
2015-04-16 06:11 PDT, Antti Koivisto
andersca: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Antti Koivisto 2015-04-16 06:02:13 PDT
It is faster.
Comment 1 Antti Koivisto 2015-04-16 06:11:18 PDT
Created attachment 250918 [details]
patch
Comment 2 Anders Carlsson 2015-04-16 09:33:06 PDT
Comment on attachment 250918 [details]
patch

Seems like computeHash could just return the Digest.
Comment 3 Antti Koivisto 2015-04-16 10:45:57 PDT
https://trac.webkit.org/r182895
Comment 4 Darin Adler 2015-04-17 09:18:47 PDT
Comment on attachment 250918 [details]
patch

View in context: https://bugs.webkit.org/attachment.cgi?id=250918&action=review

> Source/WTF/ChangeLog:22
> +            Remove the side effect where computeHash resets the state. No one relies on it.

All I see is the comment change and the new CommonCrypto. I don’t see a code change that makes that change for the non-CommonCrypto version. Is the idea that now computeHash might reset the state and might not? I think this is slightly untidy right now. I don’t know what the rules are about what you can and can’t do after calling computeHash and what behavior you should expect.
Comment 5 Antti Koivisto 2015-04-17 10:54:42 PDT
> All I see is the comment change and the new CommonCrypto. I don’t see a code
> change that makes that change for the non-CommonCrypto version. Is the idea
> that now computeHash might reset the state and might not? I think this is
> slightly untidy right now. I don’t know what the rules are about what you
> can and can’t do after calling computeHash and what behavior you should
> expect.

It seemed unnecessary to actually change the behavior of the existing implemention. It just calls reset() which sets the state back to initial state. This is not expensive and some sort of state cleanup is needed to not have computation left in memory. On the other hand I didn't want to introduce extra CC_SHA1_Init call to match this unused behavior. CC_SHA1_Final cleans up the state just fine.

The new behavior is that you create new SHA1 instance for each computation. This is how the clients seem to expect it to behave anyway and matches similar MD5 type.