ラベル cryptography の投稿を表示しています。 すべての投稿を表示
ラベル cryptography の投稿を表示しています。 すべての投稿を表示

2020年12月30日水曜日

/dev/random 関連

再びゴソゴソと検索

GCE だと virtio_rng とやらがあるらしい: Enabling Virtio RNG

いつからあるんだろうか、軽く調べた限りでは詳細はわからなかったものの GitHub 上のコメントをみると少なくとも 2019年初めにはあったようだ。

2016年の時点になかったらしいのが伺える https://github.com/travis-ci/travis-ci/issues/1913#issuecomment-205651263 この後 2019年2月にコメントあり、Red Hat の bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=1572944#c79 を書かれていてそこには "GCE (Google Cloud Engine) now supports project/instance metadata 'google-compute-enable-virtio-rng=true' to get a virtio-rng device." と。

2014年の時点でも issue あり https://github.com/cloudius-systems/osv/issues/376


virtio_rng つかわない/つかえない場合はここに書かれているような何かを使う。自分は rng-tools しか入れたことがないので rng-tools 周りを改めて見てみると、2018年に jitter をエントロピーソースに加える変更あり。 Add Jitter entropy source #17 で jitterentropy-libraryを取り込んで使うようにした、と。jitterentropy-library を作った人は作った人で jitterentrophy-rngd なるものを作っているという。

rng-tools の ChangeLog は全く更新されていない模様。v6.3 から件の変更がふくまれている。

The rng-tools official repository (formerly part of the gkernel project on sourceforge)  と書かれているので gkernel project とやらを調べれば v5 より前のバージョンの様子がわかるのかな。5 から 6 まで13年開いている・・?

 

Springdale 8.3 で最新のパッケージ入れて確認

[katsuji@sdl8 ~]$ rpm -q rng-tools
rng-tools-6.8-3.el8.x86_64
[katsuji@sdl8 ~]$ rpm -qi rng-tools
Name        : rng-tools
Version     : 6.8
Release     : 3.el8
Architecture: x86_64
Install Date: 2020年12月18日 02時34分43秒
Group       : System Environment/Base
Size        : 120384
License     : GPLv2+
Signature   : RSA/SHA256, 2020年05月15日 00時53分41秒, Key ID 16cfc33341a40948
Source RPM  : rng-tools-6.8-3.el8.src.rpm
Build Date  : 2020年04月29日 15時57分15秒
Build Host  : focus.springdale.princeton.edu
Relocations : (not relocatable)
URL         : https://github.com/nhorman/rng-tools
Summary     : Random number generator related utilities
Description :
Hardware random number generation tools.
[katsuji@sdl8 ~]$ rngd --version
rngd 6.8
Copyright 2001-2004 Jeff Garzik
Copyright 2017 Neil Horman
Copyright (c) 2001 by Philipp Rumpf
This is free software; see the source for copying conditions.  There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[katsuji@sdl8 ~]$ sudo systemctl status rngd
● rngd.service - Hardware RNG Entropy Gatherer Daemon
   Loaded: loaded (/usr/lib/systemd/system/rngd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2020-12-30 01:15:23 JST; 2min 25s ago
 Main PID: 854 (rngd)
    Tasks: 2 (limit: 11218)
   Memory: 2.7M
   CGroup: /system.slice/rngd.service
           └─854 /sbin/rngd -f --fill-watermark=0

12月 30 01:15:23 sdl8.localdomain systemd[1]: Started Hardware RNG Entropy Gatherer Daemon.
12月 30 01:15:23 sdl8.localdomain rngd[854]: Initializing available sources
12月 30 01:15:23 sdl8.localdomain rngd[854]: Failed to init entropy source hwrng
12月 30 01:15:23 sdl8.localdomain rngd[854]: Enabling RDSEED rng support
12月 30 01:15:23 sdl8.localdomain rngd[854]: Initializing entropy source rdrand
12月 30 01:15:26 sdl8.localdomain rngd[854]: Initializing AES buffer
12月 30 01:15:26 sdl8.localdomain rngd[854]: Enabling JITTER rng support
12月 30 01:15:26 sdl8.localdomain rngd[854]: Initializing entropy source jitter
[katsuji@sdl8 ~]$ cat /etc/springdale-release
Springdale Open Enterprise Linux release 8.3 (Modena)

・・と、ログに Enabling JITTER rng support やら Initializing entropy source jitter が出てくる。


2020年9月25日金曜日

だいすきー ず

サイコロひと振りで、“推測不能”なマスターパスワードを生成:「DiceKeys」が打ち出すセキュリティの新機軸 https://wired.jp/2020/09/10/dicekeys-cryptography/

https://www.crowdsupply.com/dicekeys/dicekeys

アドバイザーにブルース・シュナイアーさんおる

https://dicekeys.com/

暗号関連の本

いくつか買った。お仕事にはほぼ関係なし。あるとしてもライブラリのバージョンが云々、、くらいだな。

 

1. 暗号技術のすべて https://www.amazon.co.jp/dp/4798148814/ 

700ページ。しばらくはこれを読む。日本語でこのような書籍がでてるのはありがたいことだ。擬似乱数生成器のところで entropy_avail やら rng-tools 出てきた。ラズパイで Linux というのがそれまで特に断りなく書かれていたような気がして、まぁどちらもそれだけ普通に使われるものということかな。Yarrow がどう、Fortuna がどう、というのは別の何かをあたる必要がある。ラズパイがハードウェア乱数生成器持ってるとは知らなかった。買ってみようかしら。なお

 

2. 暗号理論入門 原書第3版 https://www.amazon.co.jp/dp/4621061860/ 

学生向け講義に基づいて書き下ろされた書籍の邦訳。おそらく積ん読。


3. 改訂新版 暗号の数理―作り方と解読の原理 https://www.amazon.co.jp/dp/406257490X/

2005年刊。「初版刊行以来、四半世紀が経過した」と冒頭に書かれているので改定前のは1980年・・・?そのようだ https://www.amazon.co.jp/dp/B000J89VGC


4. 暗号技術 実践活用ガイド https://www.amazon.co.jp/dp/483996825X/

no starch press ででている書籍 Serious Cryptography の邦訳。原書は 2017年11月刊。さらさらっと原書で読めるなら3年前には読めていることになる。2章に Fortuna がチラッと書かれている。Apple の OS 群で使われているのは Fortuna 由来のもの https://support.apple.com/en-ie/guide/security/seca0c73a75b/1/web/1


5. 現代暗号入門 https://www.amazon.co.jp/dp/4065020352/

これはだいぶ前に買ってた。また読む。

2019年2月21日木曜日

ランダム

/dev/random を調べる機会が発生。

むかーし FreeBSD で rndcontrol なぞ設定したなと思いつつ。
FreeBSD だと Yarrow, その後の Fortuna(しばらく使ってなかったから Fortuna 知らなかったよ・・・)なんだけども、Linux だとこのへんどうなっているのかさっぱりわからず。

で冒頭の wikipedia です
https://en.wikipedia.org/wiki//dev/random

この辺見てればいいと思う。

It is also possible to write to /dev/random. This allows any user to mix random data into the pool. Non-random data is harmless, because only a privileged user can issue the ioctl needed to increase the entropy estimate. The current amount of entropy and the size of the Linux kernel entropy pool, both measured in bits, are available in /proc/sys/kernel/random/ and can be displayed by the command cat /proc/sys/kernel/random/entropy_avail and cat /proc/sys/kernel/random/poolsize respectively.

(snip)

The Linux kernel provides support for several hardware random number generators, should they be installed. The raw output of such a device may be obtained from /dev/hwrng.[8]

With Linux kernel 3.16 and newer,[9] the kernel itself mixes data from hardware random number generators into /dev/random on a sliding scale based on the definable entropy estimation quality of the HWRNG. This means that no userspace daemon, such as rngd from rng-tools, is needed to do that job. With Linux kernel 3.17+, the VirtIO RNG was modified to have a default quality defined above 0,[10] and as such, is currently the only HWRNG mixed into /dev/random by default.

The entropy pool can be improved by programs like timer_entropyd, haveged, randomsound etc. With rng-tools, hardware random number generators like Entropy Key, etc. can write to /dev/random. The programs dieharder, diehard and ent can test these random number generators.

(snip)

In October 2016 with the release of Linux kernel version 4.8 and newer, /dev/urandom was switched over to a ChaCha20-based implementation[16] by Theodore Ts'o, based on Bernstein's well-regarded stream cipher ChaCha20.


ChaCha20 とやらが出てきて DJB 先生の名を再び目にする、と。
ところで 暗号周り、それなりに「あっあれね」と理解できるにはなにが必要なんだろうな。
「40からはじめる暗号」とか「暗号の前に!この数学」みたいな何かあるといいのだけど。