Score:3

Cracking $f(x) = Cx \oplus Dx$

in flag

A program I reverse engineered is using $f(x) = Cx \oplus Dx$ where C = 0x20ef138e415 and D = 0xd3eafc3af14600 as a hash function. Given a byte array, the hash is is obtained by repeatedly applying $f$ to the current hash xor next byte.

Java code:

    public static long f(long x) {
        return (0x20ef138e415L * x) ^ (0xd3eafc3af14600L * x);
    }

    public static long hash(byte[] bytes) {
        long hash = 0;

        for (byte b : bytes) {
            hash = f(hash ^ ((b & 0xff) + 1));
        }

        return f(hash);
    }

Is there an easy way to generate hash collisions?

Meir Maor avatar
in flag
No need to do cryptanalsis, this has a 64 bit state and therefor finding collisions is trivial with ~ 2^32 operations. Thinking is hard finding collisions in this is easy.
Meir Maor avatar
in flag
I actually tried doing this for fun, and failed, but my failure lead to this question: https://crypto.stackexchange.com/questions/92280/many-near-collisions-but-no-full-collision (My comments still stands it shouldn't be hard to find collisions in any 64 bit hash, I simply have failed none the less).
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.