From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4CFD93858283 for ; Tue, 12 Jul 2022 09:20:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4CFD93858283 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-400-BGJx1IjLMhilo90jtvDKww-1; Tue, 12 Jul 2022 05:20:46 -0400 X-MC-Unique: BGJx1IjLMhilo90jtvDKww-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B266829ABA38; Tue, 12 Jul 2022 09:20:42 +0000 (UTC) Received: from oldenburg.str.redhat.com (unknown [10.39.192.160]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 06A5D492CA5; Tue, 12 Jul 2022 09:20:41 +0000 (UTC) From: Florian Weimer To: Adhemerval Zanella Cc: libc-alpha@sourceware.org Subject: Re: [PATCH v8 2/9] stdlib: Add arc4random tests References: <20220629213428.3065430-1-adhemerval.zanella@linaro.org> <20220629213428.3065430-3-adhemerval.zanella@linaro.org> Date: Tue, 12 Jul 2022 11:20:40 +0200 In-Reply-To: <20220629213428.3065430-3-adhemerval.zanella@linaro.org> (Adhemerval Zanella's message of "Wed, 29 Jun 2022 18:34:21 -0300") Message-ID: <87r12qu1p3.fsf@oldenburg.str.redhat.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jul 2022 09:20:54 -0000 * Adhemerval Zanella: > The basic tst-arc4random-chacha20.c checks if the output of ChaCha20 > implementation matches the reference test vectors from RFC8439. > > The tst-arc4random-fork.c check if subprocesses generate distinct > streams of randomness (if fork handling is done correctly). > > The tst-arc4random-stats.c is a statistical test to the randomness of > arc4random, arc4random_buf, and arc4random_uniform. > > The tst-arc4random-thread.c check if threads generate distinct streams > of randomness (if function are thread-safe). Maybe mention in the commit message that the tests are based on a previous implementation, so the locking and race detection stuff is not necessarily relevant with the per-thread state? > --- /dev/null > +++ b/stdlib/tst-arc4random-chacha20.c > @@ -0,0 +1,167 @@ > +#include > +#include > +#include > + > +/* The test does not define CHACHA20_XOR_FINAL to mimic what arc4random > + actual does. */ Missing space after . > diff --git a/stdlib/tst-arc4random-fork.c b/stdlib/tst-arc4random-fork.c > new file mode 100644 > index 0000000000..a7f7fee671 > --- /dev/null > +++ b/stdlib/tst-arc4random-fork.c > @@ -0,0 +1,198 @@ > +/* Test that subprocesses generate distinct streams of randomness. > + Copyright (C) 2022 Free Software Foundation, Inc. > + This file is part of the GNU C Library. > + > + The GNU C Library is free software; you can redistribute it and/or > + modify it under the terms of the GNU Lesser General Public > + License as published by the Free Software Foundation; either > + version 2.1 of the License, or (at your option) any later version. > + > + The GNU C Library is distributed in the hope that it will be useful, > + but WITHOUT ANY WARRANTY; without even the implied warranty of > + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + Lesser General Public License for more details. > + > + You should have received a copy of the GNU Lesser General Public > + License along with the GNU C Library; if not, see > + . */ http:// instead of https://. (There are more occurrences.) > +/* Collect random data from subprocesses and check that all the > + results are unique. */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* Perform multiple runs. The subsequent runs start with an > + already-initialized random number generator. (The number 1500 was > + seen to reproduce failures reliable in case of a race condition in > + the fork detection code.) */ > +enum { runs = 1500 }; Comment is outdated, there is no fork detection code anymore. > diff --git a/stdlib/tst-arc4random-thread.c b/stdlib/tst-arc4random-thread.c > new file mode 100644 > index 0000000000..935cdcaf12 > --- /dev/null > +++ b/stdlib/tst-arc4random-thread.c > @@ -0,0 +1,341 @@ > +/* Test that threads generate distinct streams of randomness. > + Copyright (C) 2018 Free Software Foundation, Inc. Should be 2022. Thanks, Florian