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

Correct implementation of joaat hash. #5749

Closed
wants to merge 1 commit into from
Closed

Commits on Jun 21, 2020

  1. Correct implementation of joaat hash.

    Before this commit, the result produced by a joaat hash depended
    on how the input data was chunked. A hash produced by multiple
    `hash_update` operations was incorrect. For example, this code,
    which should produce three identical lines:
    
        var_dump(hash("joaat", "abcd"));
    
        $hash = hash_init("joaat");
        hash_update($hash, "ab");
        hash_update($hash, "cd");
        var_dump(hash_final($hash));
    
        $hash = hash_init("joaat");
        hash_update($hash, "abc");
        hash_update($hash, "d");
        var_dump(hash_final($hash));
    
    instead produced:
    
        string(8) "cd8b6206"
        string(8) "e590d137"
        string(8) "2d59d087"
    
    This is because the finalization step, involving shift operations
    and adds, was applied on every chunk, rather than once at the end
    as is required by the hash definition.
    
    After this commit, the code above produces:
    
        string(8) "cd8b6206"
        string(8) "cd8b6206"
        string(8) "cd8b6206"
    
    as expected.
    
    Some tests encoded the wrong behavior and were corrected.
    kohler committed Jun 21, 2020
    Configuration menu
    Copy the full SHA
    1642f2e View commit details
    Browse the repository at this point in the history