Closed Bug 1560329 Opened 5 years ago Closed 5 years ago

drbg: add continuous self-test on entropy source

Categories

(NSS :: Libraries, defect, P1)

defect

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: ueno, Assigned: ueno)

Details

Attachments

(2 files, 2 obsolete files)

FIPS 140-2 section 4.9.2 requires a continuous self test of the entropy source, used as an input to DRBG. As getentropy() doesn't provide any checks on the output, the attached patch adds the self test at caller side.

Attachment #9073022 - Flags: review?(rrelyea)

Sorry, the previous patch was incorrect. According to FIPS 140-2, the check needs to be done against consecutive "blocks" in the same size. So the entropy gathering function must iteratively call getentropy (through RNG_SystemRNG).

Assignee: nobody → dueno
Attachment #9073022 - Attachment is obsolete: true
Attachment #9073022 - Flags: review?(rrelyea)
Attachment #9073183 - Flags: review?(rrelyea)

This is an alternative approach to the issue. Assuming the kernel DRBG accessed through AF_ALG has continuous random number generator test already, it prefers it over getentropy():
http://patchwork.lab.bos.redhat.com/patch/260889/

Attachment #9073209 - Flags: review?(rrelyea)
Status: NEW → ASSIGNED
Priority: -- → P1

FIPS 140-2 section 4.9.2 requires a conditional self test to check that consecutive entropy blocks from the system are different. As neither getentropy() nor /dev/urandom provides that check on the output, this adds the self test at caller side.

Attachment #9073183 - Attachment is obsolete: true
Attachment #9073183 - Flags: review?(rrelyea)
Summary: drbg: add continous self-test on entropy source → drbg: add continuous self-test on entropy source
Comment on attachment 9073209 [details] [diff] [review]
nss-unix-random-afalg.patch

Review of attachment 9073209 [details] [diff] [review]:
-----------------------------------------------------------------

Only one bikeshedding nit. In the old days it would be a stronger objection, but I don't think we depend on older C compiliers at this point. It's more of a style issue (this kind of usage does not show up in other locations in NSS.

::: lib/freebl/unix_urandom.c
@@ +42,5 @@
> +    struct sockaddr_alg sa = {
> +        .salg_family = AF_ALG,
> +        .salg_type = "rng",
> +        .salg_name = "stdrng"
> +    };

This is very C++ish for such a low level C function.
Attachment #9073209 - Flags: review?(rrelyea) → review+

Thank you for the review, but the AF_ALG patch has a couple of issues:

The fixes are trivial but I am rather leaning toward the other approach so as to avoid unnecessary assumptions on the kernel behavior.

There are some r+ patches which didn't land and no activity in this bug for 2 weeks.
:ueno, could you have a look please?
For more information, please visit auto_nag documentation.

Flags: needinfo?(dueno)
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Flags: needinfo?(dueno)
Resolution: --- → FIXED
Target Milestone: --- → 3.47

Backed out for new LSan failures:
https://hg.mozilla.org/projects/nss/rev/34a254dd1357

Status: RESOLVED → REOPENED
Resolution: FIXED → ---

Daiki, I think that those LSAN errors are a problem with taskcluster. The taskcluster team suggested a fix that I'm going to trial, but I hadn't had time to open the bug. I think that you can re-land these.

Bug 1579290 opened to track the LSAN problem.

Thank you, but I was suspecting that the patch itself might have a leak because the try result changes with/without the patch:

Yes, the patch from bug 1579290 fixes the issue, but doesn't it also disable LSan when running tests?

Re-landed now. Thank you for the CI fixes!
https://hg.mozilla.org/projects/nss/rev/c66dd879d16a

Status: REOPENED → RESOLVED
Closed: 5 years ago5 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: