Skip to content
This repository has been archived by the owner on Feb 7, 2023. It is now read-only.

expose API for further hashing operations: process(), finish() and reset() #55

Closed
pohutukawa opened this issue Sep 2, 2014 · 10 comments

Comments

@pohutukawa
Copy link

When computing message digests of large amounts of data, the currently exposed hashing functions (e. g. SHA256.bytes(data)) are not sufficient. One needs to obtain an instance on a message digest object, and then process(data) on the object as it comes in, to finally get the result via a finish() call on it. It then could be reused for other/future message digest operations.

src/sha256/exports.js for example does this already with the sha256_bytes(data) function (mapped to asmCrypto.SHA256.bytes(data):

return get_sha256_instance().reset().process(data).finish().result;

So I guess it's a matter of just exposing this part of the implementation to the outside API.

@vibornoff
Copy link
Member

Not exactly: #38

Firefox had a bug preventing asm.js module being re-linked with another heap object. That's why current API reuses static objects and exposes only one-shot operations.

@alippai
Copy link
Member

alippai commented Sep 2, 2014

@vibornoff
Copy link
Member

Oh, that's awesome.

I had a try with FF 31 and it works. Do you know the exact FF version from which we can be sure this bug is fixed?

@pohutukawa
Copy link
Author

OK, good to know the reasoning for statically fixing this.

But, now that it's resolved, it would be really good to get access to a digest object instance and use the different methods on it as needed.

@pohutukawa
Copy link
Author

I think this might be the Firefox bug link in question:
https://bugzilla.mozilla.org/show_bug.cgi?id=973725

Maybe that helps in finding out when it was resolved. This link suggests, that it might have been fixed in a nightly of 30a1:

http://forums.mozillazine.org/viewtopic.php?f=23&t=2802749

@alippai
Copy link
Member

alippai commented Sep 4, 2014

It seems we can safely remove this support, Firefox 29 has practically zero usage now.
This practice also matches the common Google policy, that last two versions of the browsers are supported (the latest stable Firefox release is version 32).

vibornoff added a commit that referenced this issue Sep 12, 2014
@pohutukawa
Copy link
Author

Is there some kind of expectation, when a constructor to a hashing instance will be exported through the public API?

@vibornoff
Copy link
Member

It's already done with 63fa6aa and as for other potentially unsafe things turned off by default. Also I'd like to put some tests for this feature. Suppose it'll be finished till the end of this week.

@pohutukawa
Copy link
Author

Excellent. Thanks for that.

So I suppose one would create a new instance using new asmCrypto.SHA256(), and then process(), finish() and reset() methods are available on that object. Correct?

@vibornoff
Copy link
Member

Yep, you right.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants