From owner-freebsd-arm@freebsd.org Mon Jul 18 23:27:51 2016 Return-Path: Delivered-To: freebsd-arm@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A2304B9DCC4 for ; Mon, 18 Jul 2016 23:27:51 +0000 (UTC) (envelope-from stevek@juniper.net) Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0126.outbound.protection.outlook.com [104.47.40.126]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "mail.protection.outlook.com", Issuer "Microsoft IT SSL SHA2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 20B1A12E8 for ; Mon, 18 Jul 2016 23:27:50 +0000 (UTC) (envelope-from stevek@juniper.net) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=junipernetworks.onmicrosoft.com; s=selector1-juniper-net; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gsY1cAftivqoPdrRK/mnUPBfEDz9VlEdvoyt28/ShGo=; b=iNW+CFacxSwVWQhMjumzf6EEGO0LoQ60TlwtJ3ODJHGByAn/4ZzoArFm27VKEfuh4vhkyQMY1IJZsCgeL/sDRdWxTuzcyrz28pr+j53kiop1AdlDn9BSFl1aywt0NVyf1ZqXI5KrpFjWJHOxhcl8y2M2mxvk1Y6vYv+cD/Emg/E= Received: from SN1PR05CA0018.namprd05.prod.outlook.com (10.163.68.156) by CO2PR05MB2437.namprd05.prod.outlook.com (10.166.95.25) with Microsoft SMTP Server (TLS) id 15.1.528.16; Mon, 18 Jul 2016 15:52:49 +0000 Received: from BN1BFFO11FD010.protection.gbl (2a01:111:f400:7c10::1:171) by SN1PR05CA0018.outlook.office365.com (2a01:111:e400:5197::28) with Microsoft SMTP Server (TLS) id 15.1.539.14 via Frontend Transport; Mon, 18 Jul 2016 15:52:49 +0000 Authentication-Results: spf=softfail (sender IP is 66.129.239.18) smtp.mailfrom=juniper.net; freebsd.org; dkim=none (message not signed) header.d=none;freebsd.org; dmarc=none action=none header.from=juniper.net; Received-SPF: SoftFail (protection.outlook.com: domain of transitioning juniper.net discourages use of 66.129.239.18 as permitted sender) Received: from p-emfe01a-sac.jnpr.net (66.129.239.18) by BN1BFFO11FD010.mail.protection.outlook.com (10.58.144.73) with Microsoft SMTP Server (TLS) id 15.1.523.9 via Frontend Transport; Mon, 18 Jul 2016 15:52:49 +0000 Received: from localhost (172.25.4.217) by p-emfe01a-sac.jnpr.net (172.24.192.21) with Microsoft SMTP Server id 14.3.123.3; Mon, 18 Jul 2016 08:52:47 -0700 Date: Mon, 18 Jul 2016 11:54:55 -0400 From: Steve Kiernan To: "Jukka A. Ukkonen" CC: Jia-Shiun Li , "freebsd-arm@freebsd.org" Subject: Re: Random number generator on rpi Message-ID: <20160718115455.10fa95bb@juniper.net> In-Reply-To: <790435eb-f3fc-8d4c-4231-e3cfbf93157b@gmail.com> References: <5d8ec4d4-4c36-139d-6102-4fdb200fdf65@gmail.com> <790435eb-f3fc-8d4c-4231-e3cfbf93157b@gmail.com> Organization: Juniper Networks Inc. X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.29; amd64-portbld-freebsd10.3) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:66.129.239.18; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(7916002)(2980300002)(199003)(189002)(24454002)(377454003)(68736007)(76506005)(93886004)(4326007)(7846002)(2906002)(305945005)(87936001)(586003)(50986999)(33646002)(57986006)(230700001)(76176999)(19580405001)(19580395003)(69596002)(92566002)(77096005)(15975445007)(6806005)(104016004)(1411001)(47776003)(81156014)(81166006)(8676002)(46406003)(8936002)(105596002)(50466002)(356003)(23726003)(1076002)(86362001)(36756003)(50226002)(189998001)(2950100001)(11100500001)(106466001)(97736004)(5890100001)(110136002)(39210200001); DIR:OUT; SFP:1102; SCL:1; SRVR:CO2PR05MB2437; H:p-emfe01a-sac.jnpr.net; FPR:; SPF:SoftFail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD010; 1:HMuCdjvHhdr4di8iakdcrfV6bvgAYYUiq5wE7rWdgDg0Zl5Qn93iI0deBpLoDbCmxbMyg+m1XG30d15AizlhvXauTRXOy8FXMjerIbmVI6cBxmDr+AFsN/MToZAufnXwi2QORZgNszCZsMqcWZwPiCDkka8ixYhzjHj/MEjgE5FdWZqoAulhEHdU/jp9wXqs7yMOkCkNw+M4sx0EH6BZJmb3HkE5++VLwcGejuHjeqxDeMkKz1riw4KBGhe2o2k86GUKiVVqvjcr2SIAn9bxCBL4n9vZD/4xlMzy7DqOknEbSf7RErdwnavy+jsdJUsC8Shetioc/zMs7qwW6yltNFskxxDITv5UTp2zlh6hd5inPYIao1O1axtPbdYUXzD6bHSloICDzkXy38d4IBoel+y2zZAyXLeJ01TOTO1BBwQKAm6WiKhg+Ps2xQKMDzm9A3oMxUtQtHQLuLZpHTMt9PFNHIR4V2ahzhV0EiXqT86/Bia729Fl1CenBl1NvbpUiVqJOqvvJ1cjCfy0mCCKpDMpfxGxbBIdQGXVqQH6gSYbA2TvuL5v//gKVFJTRrWY X-MS-Office365-Filtering-Correlation-Id: a950089b-f394-456a-2502-08d3af2391df X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2437; 2:YI9DRfg1nXiUIURxUzvQVqNSGADmABWnZiifOmQnNyYxWbYws/SkkObDo57FbyFGyNfsoE9i1bKL+o8Vupz/qsAgDrr3ziFCueojSEpzQ6R57KZrrYRhl6dcbovaGcGWOiY+XMPj9Z7d5uHulV539lO70Jsxp6N5xzX7veBO9i/WH0SkoW10dX7Q6Gwc3mYi; 3:ChqI36NUlSog/azuHhD+BVMYKZdZr1xY1YNZ8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9jr0hcoTTqmvy8XybXadpgOcTG9fBXuf15hENrZ/8afuTOwi5ECSxmHf5nPbLEq0RtGAQ8Tl4bq8SmfsNWwt2rSnyT4+AzsPPc3ahfRpdVyCdyZhSPzDdBzzwr X-Microsoft-Exchange-Diagnostics: 1; CO2PR05MB2437; 31:LaYk+qF64nwRzbRzk+JXtiqGaKa/nHjrxtYu9LgWBWvHtvNVYBxA4kgylbMdMjd0FIPdDScU6mOTWD82MSXmpJCikTXB1XUTA/+L60g7graWDNxLMOeQ5HlMQkJS6253j+sYrFDYvc7eAbz0B6FNJtk43/H/+nXY5k8XNA9p1cuT3UcWmHI/AsR7PZfzgyB8bD5YUecHEzwIIMqUmDhXyw==; 20:T7MD8cxH4Pci7FEbtSTXgP6N+rG4h5Mv1NHy5+w7vCKrXKoZLUdlqDqVeHc6aSQgCkOmdAfp/gpV64m2HLd1Kaity5ScfP9VWWal5dvWWqqw8w+IVYEs+V1nIH6W9XQl21p/h5M4crBZWVMWYmA2a/9dkBSAcB7ra93e3ktjKnBLcyDqAXCWxttAPcVT1jKn18273IjjlmUywmp0GKqtgIFWOqrMRehLWfKFFbAoHAJ6/cjxtWP/qx4mSU07T+zB8cXvwizjM7jsaLxikYzJEyoLpqUSgerJD8+sqxBeTVfGQwL2pHlZQbivZiz+55aO6amw31ADetxgSIjNXZWRBS8e8C1SWzmegBErtgWhNpKlXXXdzYmDVhOP5yIKJkXopspjbr+XzMX0y/lGB5TuTdJDh9Z5UsBlbzQFksBCL3rFIcF9qdWsb2UyIYVt416VEsF/6IkgIK9RnjJ8kmcikKsur34LJKApktHNHv5iJ1c7mzWYGZKnGqwwHU0NhmAz X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(20558992708506); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(13023025)(13024025)(13018025)(13015025)(13017025)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:CO2PR05MB2437; BCL:0; PCL:0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nosticMetadata: NSPM X-OriginatorOrg: juniper.net X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Jul 2016 15:52:49.1664 (UTC) X-MS-Exchange-CrossTenant-Id: bea78b3c-4cdb-4130-854a-1d193232e5f4 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=bea78b3c-4cdb-4130-854a-1d193232e5f4; Ip=[66.129.239.18]; Helo=[p-emfe01a-sac.jnpr.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO2PR05MB2437 X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Jul 2016 23:27:51 -0000 On Sun, 17 Jul 2016 15:27:51 +0300 "Jukka A. Ukkonen" wrote: > On 07/15/16 07:32, Jia-Shiun Li wrote: > > sorry for replying so late. Turns out I need to attach rndtest device to > > hook it on. Updated patch attached. Also commented some code lines in > > rndtest to print report messages. You should be able to see repeated > > kernel messages like below: > > > > bcmrng0: rndtest: runs pass zeros interval 1 (2343 < 2543 < 2657) > > bcmrng0: rndtest: runs pass zeros interval 2 (1135 < 1255 < 1365) > > bcmrng0: rndtest: runs pass zeros interval 3 (542 < 624 < 708) > > bcmrng0: rndtest: runs pass zeros interval 4 (251 < 301 < 373) > > bcmrng0: rndtest: runs pass zeros interval 5 (111 < 158 < 201) > > bcmrng0: rndtest: runs pass zeros interval 6 (111 < 149 < 201) > > bcmrng0: rndtest: runs pass ones interval 1 (2343 < 2535 < 2657) > > bcmrng0: rndtest: runs pass ones interval 2 (1135 < 1265 < 1365) > > bcmrng0: rndtest: runs pass ones interval 3 (542 < 576 < 708) > > bcmrng0: rndtest: runs pass ones interval 4 (251 < 315 < 373) > > bcmrng0: rndtest: runs pass ones interval 5 (111 < 185 < 201) > > bcmrng0: rndtest: runs pass ones interval 6 (111 < 153 < 201) > > bcmrng0: rndtest: chi^2(4): pass (sum 1570182) > > bcmrng0: rndtest: longruns pass (15 ones, 12 zeros) > > > > > > by the rndtest result, guess I can safely conclude the hardware rng > > working correctly? > > > > > > On Thu, Jun 9, 2016 at 3:53 PM, Jukka A. Ukkonen > > wrote: > > > > > > So, does this somehow indicate that fortuna has attached the > > new random device as a source of true randomness? > > > > root@rpi2:~ # sysctl kern.random > > kern.random.fortuna.minpoolsize: 64 > > kern.random.harvest.mask_symbolic: > > [UMA],[FS_ATIME],SWI,INTERRUPT,NET_NG,NET_ETHER,NET_TUN,MOUSE,KEYBOARD,ATTACH,CACHED > > kern.random.harvest.mask_bin: 00111111111 > > kern.random.harvest.mask: 511 > > kern.random.random_sources: > > > > > > The mask only reports environmental sources, not hardware rng sources. > > I kind of guessed that. > > I tested the modified patch yesterday. Now I see the following couple > of lines during a verbose boot... > > bcmrng0: mem 0x104000-0x10400f on > simplebus0 > random: harvesting attach, 8 bytes (4 bits) from bcmrng0 > > So, at least random claims it tries to use bcmrng as a source of > randomness. Thanks. You might want to see my RPi rng driver review up on Phabricator. It is interrupt driven, which keeps the CPU utilization down to a fraction of a percent, whereas using a callout or other method easily consumes much more of the CPU. The review is here: https://reviews.freebsd.org/D6888 Note that for RBG (random bit generator) like the one in the RPi, they are not really RNGs themselves but random bit sources that must be processed by other algorithms to generate random numbers. So even if one were to grab the data to test for "randomness", one would need to not assume the rndtest would necessarily be appropriate, since the values returned by the RBG are not to be used directly as random numbers without post-processing. -Steve