From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oi1-x229.google.com (mail-oi1-x229.google.com [IPv6:2607:f8b0:4864:20::229]) by sourceware.org (Postfix) with ESMTPS id 410B5385842B for ; Tue, 12 Jul 2022 17:17:51 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 410B5385842B Received: by mail-oi1-x229.google.com with SMTP id p132so5177030oif.9 for ; Tue, 12 Jul 2022 10:17:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=9TW5i4PSFe7p3KRHCRDi9MHo7+5Osv76HnRKt29WJc8=; b=yJrOda2cSQZkbptGRudJi+6FwSW6uOnsVwVlQtBe0a7CGy2BFzXKtyqIdS5XRLvSXl TbZWLakScf9EygceX+p7SNeUbAlstmxvOkAohiAt+GYD+yWUyRXjXVlrp/gh5PyhPAcT PEZhUFHLdg5PyZcJARpi2pu/+VdyPgYXbMFcy5eo7EcKKH7kMTGEhDfBxn6eMLe01e1W iqOY151ah7/lk1QAMrclAvOOPohXJsgtW7HKFS9N4ccGoRmO4jq5thsz9yexiF4C/oKp aU92PKZZehZ9kxAW0wbhC7UvngGnTcVtPEnBi5xAQZMY73u19BzViIXobl7VuB9nt2yo yXSg== X-Gm-Message-State: AJIora8Q8+Vg3ZqZ+oufjZ8gj2orDvJ8Udk7xgusL26z1AUy+xWDVOdy QU3yk5oGD+vEbnyqD7jnkftLtNae9f0GZg== X-Google-Smtp-Source: AGRyM1vUudecIVWRp4tuQPBoCII88UovrlsczVyPTKpk0Xmysr7QhyhtPaK46Dsqqiuh6h5/AFsQ8w== X-Received: by 2002:a05:6808:14d0:b0:33a:25ea:766f with SMTP id f16-20020a05680814d000b0033a25ea766fmr358012oiw.235.1657646270422; Tue, 12 Jul 2022 10:17:50 -0700 (PDT) Received: from [12.18.8.156] ([201.46.27.6]) by smtp.gmail.com with ESMTPSA id h1-20020a056808014100b00325cda1ffa6sm4194885oie.37.2022.07.12.10.17.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 12 Jul 2022 10:17:50 -0700 (PDT) Message-ID: Date: Tue, 12 Jul 2022 14:17:48 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.0.2 Subject: Re: [PATCH v8 2/9] stdlib: Add arc4random tests Content-Language: en-US To: Florian Weimer Cc: libc-alpha@sourceware.org References: <20220629213428.3065430-1-adhemerval.zanella@linaro.org> <20220629213428.3065430-3-adhemerval.zanella@linaro.org> <87r12qu1p3.fsf@oldenburg.str.redhat.com> From: Adhemerval Zanella Netto Organization: Linaro In-Reply-To: <87r12qu1p3.fsf@oldenburg.str.redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, 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 17:17:53 -0000 On 12/07/22 06:20, Florian Weimer wrote: > * 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 . Ack. > >> 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.) Ack. > >> +/* 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. Ok, I removed the fork-detection part. > > >> 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. > Ack. > Thanks, > Florian >