Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Long string input produces "all zero" md5 digest #17

Open
GoogleCodeExporter opened this issue Mar 12, 2015 · 4 comments
Open

Long string input produces "all zero" md5 digest #17

GoogleCodeExporter opened this issue Mar 12, 2015 · 4 comments

Comments

@GoogleCodeExporter
Copy link

See http://code.google.com/p/crypto-js/source/detail?r=205 for issue & related 
fix.

What steps will reproduce the problem?
1. Create an md5 digest for a 4000 char string.
2. ???
3. Is it all zeroes?

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.

In order to prevent GWT from optimizing out the shift by zero fix, I needed a 
variable for which it couldn't infer the value.

        int zeroAndNothingElse = Math.sqrt(2) < 5 ? 0 : 1;
        H1 = (H1 + a) >>> zeroAndNothingElse;
        H2 = (H2 + b) >>> zeroAndNothingElse;
        H3 = (H3 + c) >>> zeroAndNothingElse;
        H4 = (H4 + d) >>> zeroAndNothingElse;

This fixed the issue for me in 
com.googlecode.gwt.crypto.bouncycastle.digests.MD5Digest

I don't know why the zero-shift causes the desired side-effect, or what the 
other side effects may be.

Original issue reported on code.google.com by dearm...@gmail.com on 11 Apr 2012 at 1:30

@GoogleCodeExporter
Copy link
Author

fwiw, User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:11.0) 
Gecko/20100101 Firefox/11.0

Original comment by dearm...@gmail.com on 11 Apr 2012 at 1:33

@GoogleCodeExporter
Copy link
Author

I'm currently experiencing this same problem.

I"d like a little more clarification about where you applied your zero-shift 
fix.  Was this towards the bottom of the processBlock() method where it's doing:

H1 += a;
H2 += b;
H3 += c;
H4 += d;

???  Did you simply replace these 4 lines with your zero-shift changes you 
mention?

Original comment by drfoste...@gmail.com on 18 Oct 2012 at 5:42

@GoogleCodeExporter
Copy link
Author

I just copied the src into our tree, renamed it MD5DigestEx, and replaced those 
lines, yes.

I don't recall where I read about the shift by zero working, it was in some 
other JS-crypto lib.  

All of the other sqrt nonsense is there because GWT is really good at 
optimizing out shift by 0 and in turn everything that evaluates to 0.

FWIW versions, gwt 2.3.0 and gwt-crypto 2.3.0

Original comment by dearm...@gmail.com on 18 Oct 2012 at 7:09

@GoogleCodeExporter
Copy link
Author

Could you confirm the error on GWT 2.5, unfortunately GWT is producing a lot of 
weird in terms of optimizations which can be harmful for mathematical libraries 
such as this one. Please submit a patch if you've found the solution.

Original comment by rame...@gmail.com on 22 Jan 2013 at 9:00

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

No branches or pull requests

1 participant