{"id":933,"date":"2015-05-10T20:04:22","date_gmt":"2015-05-10T11:04:22","guid":{"rendered":"https:\/\/blog.ymyzk.com\/?p=933"},"modified":"2015-05-10T20:04:22","modified_gmt":"2015-05-10T11:04:22","slug":"raspberry-pi-hardware-random-number-generator","status":"publish","type":"post","link":"https:\/\/blog.ymyzk.com\/2015\/05\/raspberry-pi-hardware-random-number-generator\/","title":{"rendered":"Raspberry Pi \u306e\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u5229\u7528\u3059\u308b"},"content":{"rendered":"

Raspberry Pi \u306b\u306f\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u304c\u642d\u8f09\u3055\u308c\u3066\u304a\u308a, Raspbian \u3067\u306f\u82e5\u5e72\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3053\u3068\u3067\u3053\u308c\u3092\u7c21\u5358\u306b\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059.
\n<\/p>\n

\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb<\/h2>\n

\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u5229\u7528\u3059\u308b\u305f\u3081\u306b\u306f, \u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb bcm2708-rng<\/code> \u3092\u8aad\u307f\u8fbc\u3080\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059.<\/p>\n

\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u4e00\u6642\u7684\u306b\u8aad\u307f\u8fbc\u3080\u5834\u5408\u306f\u4ee5\u4e0b\u3092\u5b9f\u884c\u3057\u307e\u3059.<\/p>\n

\r\nsudo modprobe bcm2708-rng\r\n<\/pre>\n

\u8d77\u52d5\u6642\u306b\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u81ea\u52d5\u7684\u306b\u8aad\u307f\u8fbc\u3080\u306b\u306f, \/etc\/modules<\/code> \u306b\u4ee5\u4e0b\u3092\u8ffd\u8a18\u3057\u307e\u3059.<\/p>\n

\r\nbcm2708-rng\r\n<\/pre>\n

\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u304c\u8aad\u307f\u8fbc\u307e\u308c\u3066\u3044\u308b\u304b\u3069\u3046\u304b\u78ba\u8a8d\u3057\u307e\u3059.<\/p>\n

\r\n$ lsmod | grep rng\r\nbcm2708_rng             1196  0\r\n<\/pre>\n

\u4e71\u6570\u306e\u53d6\u5f97<\/h2>\n

\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u306e\u30c7\u30fc\u30bf\u306f \/dev\/hwrng<\/code> \u304b\u3089\u8aad\u307f\u51fa\u3059\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u4ee5\u4e0b\u306f\u4e71\u6570\u3092 128 \u30d0\u30a4\u30c8\u53d6\u5f97\u3057\u3066, 16\u9032\u6570\u8868\u793a\u3059\u308b\u4f8b\u3067\u3059.<\/p>\n

\r\n$ sudo dd if=\/dev\/hwrng bs=1 count=128 | od -t x1\r\n0000000 7c 19 bf 0f fe ec 49 85 73 ae 4a dd 39 8c 21 5b\r\n0000020 53 71 56 2e 04 05 12 ff d7 ca a0 e4 66 28 7e 3a\r\n0000040 40 12 a8 d2 02 6b 03 70 53 34 ce 64 7d e6 80 c4\r\n0000060 12 6c 06 06 cf db c5 9c 20 a6 84 c2 d5 fe cf 0d\r\n0000100 a8 24 5f 30 f2 0d 4d e1 53 2b 0b af d8 03 c4 06\r\n0000120 b0 7a 73 80 fb 4c c9 40 d1 18 a4 fe e5 4b 63 c0\r\n0000140 f0 da 19 d1 ea 1e ef cf ff 26 cf d6 ad e1 49 8f\r\n0000160 51 69 e9 cb c8 93 43 ef 8a f7 40 42 5f 44 27 59\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u5165\u529b\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u51fa\u529b\r\n128 \u30d0\u30a4\u30c8 (128 B) \u30b3\u30d4\u30fc\u3055\u308c\u307e\u3057\u305f\u3001 0.0196065 \u79d2\u3001 6.5 kB\/\u79d2\r\n0000200\r\n<\/pre>\n

\u4e71\u6570\u306e\u5229\u7528<\/h2>\n

\u30ab\u30fc\u30cd\u30eb\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u8aad\u307f\u8fbc\u3080\u3060\u3051\u3067\u306f, \u3053\u306e\u4e71\u6570\u306f\u30ab\u30fc\u30cd\u30eb\u306b\u3088\u3063\u3066\u5229\u7528\u3055\u308c\u308b\u3053\u3068\u306f\u3042\u308a\u307e\u305b\u3093. \/dev\/random<\/code> \u3084 \/dev\/urandom<\/code> \u3067\u3053\u306e\u30c7\u30fc\u30bf\u3092\u7528\u3044\u308b\u306b\u306f\u8ffd\u52a0\u306e\u8a2d\u5b9a\u304c\u5fc5\u8981\u3067\u3059.<\/p>\n

\u4ee5\u4e0b\u3092\u5b9f\u884c\u3057\u3066\u30d1\u30c3\u30b1\u30fc\u30b8 rng-tools \u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059.<\/p>\n

\r\nsudo apt-get install rng-tools \r\n<\/pre>\n

\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5b8c\u4e86\u3059\u308b\u3068, \u30c7\u30fc\u30e2\u30f3 rngd \u304c\u81ea\u52d5\u7684\u306b\u8d77\u52d5\u3057\u307e\u3059. \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066\u78ba\u8a8d\u3067\u304d\u307e\u3059.<\/p>\n

\r\n$ ps aux | grep rngd\r\nroot       382  0.0  0.2  27528  1300 ?        SLsl 18:21   0:03 \/usr\/sbin\/rngd -r \/dev\/hwrng\r\npi        2870  0.0  0.4   5660  1988 pts\/0    S+   19:30   0:00 grep rngd\r\n<\/pre>\n

rngd \u306f \/dev\/hwrng<\/code> \u304b\u3089\u4e71\u6570\u3092\u5f97\u3066, \u30ab\u30fc\u30cd\u30eb\u306e\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u30d7\u30fc\u30eb\u306b\u4e71\u6570\u3092\u63d0\u4f9b\u3057\u307e\u3059. rngd \u306f\u3042\u304f\u307e\u3067\u30ab\u30fc\u30cd\u30eb\u306e\u30a8\u30f3\u30c8\u30ed\u30d4\u30fc\u30d7\u30fc\u30eb\u306b\u4e71\u6570\u3092\u63d0\u4f9b\u3059\u308b\u306e\u307f\u3067, \u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u306e\u30c7\u30fc\u30bf\u3092\u76f4\u63a5 \/dev\/random<\/code> \u7b49\u304b\u3089\u51fa\u529b\u3059\u308b\u306e\u3067\u3042\u308a\u307e\u305b\u3093. \u307e\u305f rngd \u306f\u5165\u529b\u3055\u308c\u305f\u30c7\u30fc\u30bf\u304c\u672c\u5f53\u306b\u30e9\u30f3\u30c0\u30e0\u304b\u3069\u3046\u304b, FIPS 140-2 (2002-10-10) \u30c6\u30b9\u30c8\u3092\u884c\u3063\u3066\u304f\u308c\u307e\u3059.<\/p>\n

\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u5229\u7528\u3059\u308b\u3053\u3068\u3067 \/dev\/random<\/code> \u304b\u3089\u3088\u308a\u9ad8\u901f\u306b\u4e71\u6570\u3092\u751f\u6210\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059. \u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u5229\u7528\u3057\u306a\u3044\u5834\u5408\u3068\u5229\u7528\u3059\u308b\u5834\u5408\u306e\u751f\u6210\u901f\u5ea6\u306e\u9055\u3044\u306f\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u306a\u308a\u307e\u3059.<\/p>\n

\r\n# \u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\r\n$ dd if=\/dev\/random of=\/dev\/null bs=1 count=128\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u5165\u529b\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u51fa\u529b\r\n128 \u30d0\u30a4\u30c8 (128 B) \u30b3\u30d4\u30fc\u3055\u308c\u307e\u3057\u305f\u3001 188.318 \u79d2\u3001 0.0 kB\/\u79d2\r\n\r\n# \u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u3092\u4f7f\u3046\u5834\u5408\r\n$ dd if=\/dev\/random of=\/dev\/null bs=1 count=128\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u5165\u529b\r\n128+0 \u30ec\u30b3\u30fc\u30c9\u51fa\u529b\r\n128 \u30d0\u30a4\u30c8 (128 B) \u30b3\u30d4\u30fc\u3055\u308c\u307e\u3057\u305f\u3001 0.0161016 \u79d2\u3001 7.9 kB\/\u79d2\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

Raspberry Pi \u306b\u306f\u30cf\u30fc\u30c9\u30a6\u30a7\u30a2\u4e71\u6570\u751f\u6210\u5668\u304c\u642d\u8f09\u3055\u308c\u3066\u304a\u308a, Raspbian \u3067\u306f\u82e5\u5e72\u306e\u8a2d\u5b9a\u3092\u884c\u3046\u3053\u3068\u3067\u3053\u308c\u3092\u7c21\u5358\u306b\u5229\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,39],"tags":[35,34,14],"_links":{"self":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/933"}],"collection":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/comments?post=933"}],"version-history":[{"count":7,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/933\/revisions"}],"predecessor-version":[{"id":940,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/posts\/933\/revisions\/940"}],"wp:attachment":[{"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/media?parent=933"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/categories?post=933"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ymyzk.com\/wp-json\/wp\/v2\/tags?post=933"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}