Obfuscate just a tiny bit more.
@@ -838,8 +838,8 @@ uint64_t picoquic_crypto_uniform_random(picoquic_quic_t* quic, uint64_t rnd_max)
*
* In order to provide a minimum of protection against casual analysis, we run
* an obfuscation step before providing the result. The obfuscation involves
- * an XOR with the obfuscator, then multiply by a constant modulo 2^64,
- * then XOR the result with the obfuscator again. The obfuscator changes
+ * an XOR with obfuscator, then multiply by a constant modulo,
+ * then XOR the result with obfuscator again. The obfuscator changes
* each time the random generator is seeded.
*
* If we were really paranoid, we would want to break possible discovery by passing
@@ -853,7 +853,7 @@ uint64_t picoquic_crypto_uniform_random(picoquic_quic_t* quic, uint64_t rnd_max)
static uint64_t public_random_seed[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
static int public_random_index = 0;
static const uint64_t public_random_multiplier = 1181783497276652981ull;
-static uint64_t public_random_obfuscator[2] = { 0xcafe1234deadbeefull, 0xaaaa5555aaaa5555ull };
+static uint64_t public_random_obfuscator = 0xcafe1234deadbeefull;
static uint64_t picoquic_public_random_step(void)
{
@@ -871,7 +871,12 @@ static uint64_t picoquic_public_random_step(void)
uint64_t picoquic_public_random_64(void)
{
uint64_t s1 = picoquic_public_random_step();
- return (public_random_obfuscator[0] ^ (public_random_multiplier * (s1 ^ public_random_obfuscator[1])));
+ s1 ^= public_random_obfuscator;
+ s1 ^= (((s1 >> 32)* public_random_multiplier) & 0xffffffff);
+ s1 ^= (((s1 & 0xFFFFFFFF) * public_random_multiplier) << 32);
+ s1 ^= (((s1 >> 32)* public_random_multiplier) & 0xffffffff);
+ s1 ^= public_random_obfuscator;
+ return s1;
}
void picoquic_public_random_seed_64(uint64_t seed, int reset)
@@ -897,8 +902,7 @@ void picoquic_public_random_seed(picoquic_quic_t* quic)
picoquic_crypto_random(quic, &seed, sizeof(seed));
picoquic_public_random_seed_64(seed[0], 0);
- public_random_obfuscator[0] ^= seed[1];
- public_random_obfuscator[1] ^= seed[2];
+ public_random_obfuscator = seed[1];
}
void picoquic_public_random(void* buf, size_t len)
