darjeeling / python-blake2

blake2 python module
26 stars 5 forks source link

Data with null bytes is not supported #2

Open veorq opened 11 years ago

veorq commented 11 years ago

Data that includes null bytes seems to throw an exception:

import blake2 blake2.blake2('\x02\x01') 'c9b2d35d76fb7c0d8ffe8d5342d869b2237569d57e1f9415ee732f802e17e9a384f390834addad4a04443bcfe91e985d6c2daddd16bd97471bd2c02cc47159cd' blake2.blake2('\x02\x00') Traceback (most recent call last): File "", line 1, in TypeError: argument 1 must be string without null bytes, not str blake2.blake2('\x00\x01') Traceback (most recent call last): File "", line 1, in TypeError: argument 1 must be string without null bytes, not str

Same with blake2.blake2b and blake2.blake2s.

darjeeling commented 11 years ago

updated if function get null string, it will return None

veorq commented 11 years ago

Still does not support arbitrary data (ie that includes null bytes); why be limited to strings?

darjeeling commented 11 years ago

sorry I'm still busy. =) I'll fix it in two days.

darjeeling commented 11 years ago

@pgonee fixed this. thx!

veorq commented 11 years ago

Thanks, but I still don't understand why strings with null bytes are not supported; why should the API be limited to strings of characters, rather than arbitrary byte strings?

On Tue, Feb 19, 2013 at 7:46 AM, Bae KwonHan notifications@github.comwrote:

@pgonee https://github.com/pgonee fixed this. thx!

— Reply to this email directly or view it on GitHubhttps://github.com/darjeeling/python-blake2/issues/2#issuecomment-13759225.

pgonee commented 11 years ago

@aumasson Still not working? perhaps I think the fixed version of python-blake2 is not yet uploaded to PyPI. Try to clone this repository directly or ask @darjeeling .

veorq commented 11 years ago

Have not tried the module, just read "Pull Request #3: string containing \x00 raises unexpected exception." on https://github.com/darjeeling/python-blake2/issues/2

On Tue, Feb 19, 2013 at 8:03 AM, EUNJO WI notifications@github.com wrote:

@aumasson Still not working? perhaps I think the fixed version of python-blake2 is not yet uploaded to PyPI. Try to clone this repository directly or ask @darjeeling .

— Reply to this email directly or view it on GitHub.

pgonee commented 11 years ago

@aumasson No. I'm afraid you misunderstood. There was a bug that the string containing \x00 raises unexpected exception, exactly what you experienced. and thus I fixed it. Check it out again.

In short, strings with null bytes are supported now. ^^

veorq commented 11 years ago

Ok, sorry for misunderstanding.

There is something strange though:

import blake2 blake2.blake2('\x00') '507ed301000000008fa05700000000004098d3010000000025c15700000000000005da01000000001c104135167f000078cabc00ff7f000080cabc00ff7f0000' blake2.blake2('\x00') '507ed301000000008fa057000000000050006637167f00008fa05700000000000005da01000000001c104135167f000078cabc00ff7f000080cabc00ff7f0000' blake2.blake2('\x01') '507ed301000000008fa05700000000008005da010000000000000000000000003005da01000000001c104135167f000078cabc00ff7f000080cabc00ff7f0000' blake2.blake2('\x01') '507ed301000000008fa05700000000005005da010000000000000000000000000005da01000000001c104135167f000078cabc00ff7f000080cabc00ff7f0000'

Note that the hash of \x00 is different when computed twice. Also, why do we have all those zeros?

On Tue, Feb 19, 2013 at 8:12 AM, EUNJO WI notifications@github.com wrote:

@aumasson https://github.com/aumasson No. I'm afraid you misunderstood. There was a bug that the string containing \x00 raises unexpected exception, exactly what you experienced. and thus I fixed it. Check it out again.

— Reply to this email directly or view it on GitHubhttps://github.com/darjeeling/python-blake2/issues/2#issuecomment-13759810.

bramcohen commented 7 years ago

The version in Pypi is still returning None when given a string containing a null character. This is a critical bug which renders the library completely unusable. Null strings are valid inputs for hash functions, and should result in hash outputs not None. It's utterly bizarre that this bug is in there, because it seems like something you'd have to specifically add.