What about `H(s || m || s)`?
What about `H(s || m || s)`?
[1] https://doi.org/10.1007/978-3-540-73458-1_26
Like if your db is mongo and the 12 byte ID != 12 byte of secure randomness:
https://www.mongodb.com/docs/manual/reference/method/ObjectI...
I think the OP point still stands, just use HMAC instead of inventing crypto schemes.
HMAC(secret, username || email)
Imagine you have `bob` and `bob@example.com` as inputs. This HMAC can trivially be reused (or learned) by registering `bobb` and `ob@example.com`.If you ever have multiple fields being concatenated, use fixed-width length prefixes before each field:
HMAC(secret, 0x0003 || bytes("bob") || 0x000e || bytes("bob@example.com"))I always just serialize the inputs with JSON or something. Any weirdness an attacker might try would just be escaped so they'll never be able to match the original input.
Completely valid point, I was asking purely out of curiosity since this isn't my area of expertise but I find these kinds of vulnerabilities intriguing.