From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ua1-x92b.google.com (mail-ua1-x92b.google.com [IPv6:2607:f8b0:4864:20::92b]) by sourceware.org (Postfix) with ESMTPS id C46D73856DE8 for ; Tue, 2 Aug 2022 12:34:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C46D73856DE8 Received: by mail-ua1-x92b.google.com with SMTP id s7so5723939uao.4 for ; Tue, 02 Aug 2022 05:34:11 -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:from:to:references:organization:in-reply-to :content-transfer-encoding; bh=q6lzbnz5AdINHsK8qIiqudzTe7rvdq0XHbOkaeDgVVo=; b=cze+dPqz69SBJM1VmQrubuXhXRlMDJ1dzrRRnk8XZnSd9WRjh4mJMK8T48u1Eodnkf aZNfcASlvWeHCsySBEAZhI9jju1X/v46ni+x1NJ+QC0t21HTut/KVLCONdKyQv+mYtSS GGTZrNerakfbhS6sXXG5TcO42VhGCYu+1qmXEQk4j44uhh0dZdagIFYjmo8O9wo/WgYT +INwqHPYHNQSNbydi/r/AoVZCNXaV9NOq8FGlCmykvJCx4STM9uiVc16cWa26pefcZfB JWd5bpoUwdBYXhdC1ZHU5HQ23BoO023Hq/bOotAvJvh+qXTWo2wG3zIbRFIAoYPBQEJP 7n0w== X-Gm-Message-State: ACgBeo2gg4Ufxti1RP6iScDw54g6YXITuK24GF8R/UHH+0aScTlHY45H sYsNya0QCYdRRw60klcRUH8pB4M3U+nXkA== X-Google-Smtp-Source: AA6agR6wbV+m/MvlwmXpzoOsh10h/20Vbw+/vPfJqPUpw1mikbklGrQ1PgFH0v/ImZFNgE6yIm7W0g== X-Received: by 2002:a9f:3fce:0:b0:383:7e:58a2 with SMTP id m14-20020a9f3fce000000b00383007e58a2mr8256546uaj.103.1659443650958; Tue, 02 Aug 2022 05:34:10 -0700 (PDT) Received: from ?IPV6:2804:431:c7cb:1e34:a813:f55c:8e00:64cd? ([2804:431:c7cb:1e34:a813:f55c:8e00:64cd]) by smtp.gmail.com with ESMTPSA id r22-20020ab03a96000000b00385e2d7dd7csm8059808uaw.11.2022.08.02.05.34.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 02 Aug 2022 05:34:10 -0700 (PDT) Message-ID: <1457c4a7-f353-ef2f-d498-a214503c642e@linaro.org> Date: Tue, 2 Aug 2022 09:34:07 -0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.1.0 Subject: Re: [PATCH] stdlib: Remove possible bias in arc4random_uniform Content-Language: en-US From: Adhemerval Zanella Netto To: libc-alpha@sourceware.org, Yann Droneaud References: <20220802122526.1235666-1-adhemerval.zanella@linaro.org> Organization: Linaro In-Reply-To: <20220802122526.1235666-1-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-6.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP 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, 02 Aug 2022 12:34:13 -0000 On 02/08/22 09:25, Adhemerval Zanella wrote: > It turned out that the shift optimziation to reuse the discarded bits > might introduce bias [1]. This patch removes is and just issue another > round if the condition can not be satisfied. > > Checked on x86_64-linux-gnu. > > [1] https://crypto.stackexchange.com/questions/101325/uniform-rejection-sampling-by-shifting-or-rotating-bits-from-csprng-output-safe I understand wrongly the question on the crypto.stackexchange, the issues is to reuse the already discarded bits after the test, which is not the case in glibc implementation.