Bug 1440195 Do not check for NSS Initialization before performing jitter
Previously we needed this check because we were jittering before NSS was initialized
and this was causing tests to fail (primarily xpcshell and Marionette) because
NSS was being initialied before there was a profile directory.
In
Bug 1443943 we only jitter non-System Principal calls and that reduces the early
jitter causes. Ultimately we got to a place where everything was looking okay whether
or not NSS was initialized by the time we got here, so we can simply this code and
simply always perform jittering (if it's enabled and we're not in System Principal
code.)
MozReview-Commit-ID: Dgfi8Z1hHfB
--- a/toolkit/components/resistfingerprinting/nsRFPService.cpp
+++ b/toolkit/components/resistfingerprinting/nsRFPService.cpp
@@ -522,23 +522,17 @@ nsRFPService::ReduceTimePrecisionImpl(
// constant (e.g. 10s) that are across the zero barrier will no longer work. We need to
// round consistently towards positive infinity or negative infinity (we chose negative.)
// This can't be done with a truncation, it must be done with floor.
long long clamped = floor(double(timeAsInt) / resolutionAsInt) * resolutionAsInt;
long long midpoint = 0,
clampedAndJittered = clamped;
- // RandomMidpoint uses crypto functions from NSS. But we wind up in this code _very_ early
- // on in and we don't want to initialize NSS earlier than it would be initialized naturally.
- // Doing so caused nearly every xpcshell test to fail, as well as Marionette.
- // This is safe, because we're not going to be doing any web context stuff before NSS is
- // initialized, so anything that winds up here won't be exposed to content so we don't
- // really need to worry about fuzzing its value.
- if (sJitter && NSS_IsInitialized()) {
+ if (sJitter) {
if(!NS_FAILED(RandomMidpoint(clamped, resolutionAsInt, aContextMixin, &midpoint)) &&
timeAsInt >= clamped + midpoint) {
clampedAndJittered += resolutionAsInt;
}
}
// Cast it back to a double and reduce it to the correct units.
double ret = double(clampedAndJittered) / (1000000.0 / aTimeScale);