-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix #71890: Add support for crc32c Castagnoli's polynomial. #3913
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
Conversation
Implementation looks fine to me. Are there any official test vectors that can be included to check that the output is the right one? |
Should this really target PHP-7.2? After all, I don't think it's a bugfix. |
I think this should target 7.4 if anything. From a quick glance it looks great, if we could have a few more conforming tests like @nikic mentioned, it would be great. (Note: some bugs at the bugsweb is actually a feature request so we format it so) |
Thanks for the quick review. I guess I misread the instructions, as it suggested rebasing against the earliest supported version (which looked to be 7.2). Happy to rebase against I looked for testing vectors, but sadly there seems to be no golden set. The original academic paper lists none, the iSCSI RFC has a few. The best I could find is Go's implementation which has ~30, but they are all testing ASCII strings. So I can include what I've found in other implementations. Or an alternative. I write a quick program in another language (say Go), and generate samples that include all bytes (0-255) and use that to generate a canonical list. I have a day job, so I'll make the requested changes over the next day or so. Thanks. |
It's probably a bit late for 7.2, but I think we can land this on 7.3 under the "small self-contained feature" provision, if @cmb69 agrees. I think it would be good to include both those Go test vectors as well as the coverage for all bytes. If we have that shouldn't be much opportunity to go wrong :) |
7.2 would be appropriate if this was a bug; I don't think the lack of any particular hash algo is a bug, though. If you want to see this enhancement earlier than in PHP-7.4, I suggest you write to internals@lists.php.net; maybe there is some consensus about adding it to PHP-7.2 (or maybe 7.3). |
This variant of crc32 is heavily used by storage systems, such as iSCSI, SCTP, Btrfs, ext4, and is increasingly being used in API (such as Google Cloud Storage, and Apache Kafka).
I've rebased to master, and I've added additional tests (using Go to generate the golden hash values). For now I'll stick with 7.4, and I'll use a crc32c implementation written in php for earlier versions. Please take a look. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me :)
Looks great, thank you for your work! I suggest you hit a mail to internals@ to decide on what version to target, as this is a small and self contained feature, it should be fast to decide |
BTW Sent email to the internals@ list, awaiting a decision on what version(s) to merge into. |
It seems like the sentiment on list is to not merge into release branches, so I went ahead and merged this as c79ce48 into 7.4. We can always backport if necessary (the patch would have to be slightly different for older versions anyway). Thanks for adding this functionality :) |
Thanks! |
This variant of crc32 is heavily used by storage systems, such as iSCSI, SCTP,
Btrfs, ext4, and is increasingly being used in APIs (such as Google Cloud
Storage, and Apache Kafka).