You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It seems the failures start occurring once the string length gets larger than 240 bytes. This is when the DeriveSecretFromSeed routine gets first involved, and on initial glance this doesn't appear to be endian safe:
for (int i = 0; i < SecretLengthBytes; i += sizeof(ulong) * 2)
{
Unsafe.WriteUnaligned(destinationSecret + i, Unsafe.ReadUnaligned<ulong>(defaultSecret + i) + seed);
Unsafe.WriteUnaligned(destinationSecret + i + 8, Unsafe.ReadUnaligned<ulong>(defaultSecret + i + 8) - seed);
}
The original C implementation has here:
for (i=0; i < nbRounds; i++) {
xxh_u64 lo = XXH_readLE64(kSecretPtr + 16*i) + seed64;
xxh_u64 hi = XXH_readLE64(kSecretPtr + 16*i + 8) - seed64;
XXH_writeLE64((xxh_u8*)customSecret + 16*i, lo);
XXH_writeLE64((xxh_u8*)customSecret + 16*i + 8, hi);
}
Looks like this needs byte-swaps at the loads and stores on a big-endian system.
e.g. https://dev.azure.com/dnceng-public/public/_build/results?buildId=76403&view=ms.vss-test-web.build-test-results-tab&runId=1580894&resultId=130159&paneView=debug
/cc @nealef @uweigand
The text was updated successfully, but these errors were encountered: