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

IterBytes: Delimit sequences &[A] and ~str when hashing #8545

Merged
merged 3 commits into from
Aug 18, 2013
Merged

IterBytes: Delimit sequences &[A] and ~str when hashing #8545

merged 3 commits into from
Aug 18, 2013

Conversation

bluss
Copy link
Member

@bluss bluss commented Aug 15, 2013

Address issue #5257, for example these values all had the same hash value:

("aaa", "bbb", "ccc")
("aaab", "bb", "ccc")
("aaabbb", "", "ccc")

IterBytes for &[A] now includes the length, before calling iter_bytes on
each element.

IterBytes for &str is now terminated by a byte that does not appear in
UTF-8. This way only one more byte is processed when hashing strings.

@alexcrichton
Copy link
Member

Could you add tests for these types of collisions not happening again? Seems like we should always have reasonable guarantees that they don't crop up again.

@bluss
Copy link
Member Author

bluss commented Aug 16, 2013

I'll add that!

@bluss
Copy link
Member Author

bluss commented Aug 18, 2013

added testcase

blake2-ppc added 3 commits August 18, 2013 18:39
Address issue #5257, for example these values all had the same hash value:

	("aaa", "bbb", "ccc")
	("aaab", "bb", "ccc")
	("aaabbb", "", "ccc")

IterBytes for &[A] now includes the length, before calling iter_bytes on
each element.

IterBytes for &str is now terminated by a byte that does not appear in
UTF-8. This way only one more byte is processed when hashing strings.
Add a testcase that verifies that (s, t) and (u, v) don't collide even if
s + t == u + v (concatenation).
@bluss
Copy link
Member Author

bluss commented Aug 18, 2013

rebase to fix conflicts (with a documentation text change).

bors added a commit that referenced this pull request Aug 18, 2013
Address issue #5257, for example these values all had the same hash value:

	("aaa", "bbb", "ccc")
	("aaab", "bb", "ccc")
	("aaabbb", "", "ccc")

IterBytes for &[A] now includes the length, before calling iter_bytes on
each element.

IterBytes for &str is now terminated by a byte that does not appear in
UTF-8. This way only one more byte is processed when hashing strings.
@bors bors closed this Aug 18, 2013
@bors bors merged commit bfa1331 into rust-lang:master Aug 18, 2013
@bluss bluss deleted the iterbytes branch August 18, 2013 22:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants