List of Sha-1 - text.Baldanders.info
tag:text.Baldanders.info,2022-03-19:/tags
2022-03-19T14:17:32+09:00
帰ってきた「しっぽのさきっちょ」
https://text.baldanders.info/images/avatar.jpg
https://text.baldanders.info/images/avatar.jpg
golang.org/x/crypto/ssh パッケージをアップデートしましょう【セキュリティ・アップデート】
tag:text.Baldanders.info,2022-03-19:/remark/2022/03/update-ssh-package/
2022-03-19T05:17:32+00:00
2022-03-19T05:22:58+00:00
CVE-2022-27191 の改修を含む。
Spiegel
https://baldanders.info/profile/
<p><code>golang.org/x/crypto/ssh</code> パッケージをアップデートするようアナウンスが出ている。</p>
<ul>
<li><a href="https://groups.google.com/g/golang-announce/c/-cp44ypCT5s">An update of golang.org/x/crypto/ssh might be necessary</a></li>
</ul>
<p>ひとつは SSH 認証時の問題:</p>
<figure lang="en">
<blockquote><p>Version v0.0.0-20220315160706-3147a52a75dd of <a href="http://golang.org/x/crypto/ssh"><code>golang.org/x/crypto/ssh</code></a> implements client authentication support for signature algorithms based on SHA-2 for use with existing RSA keys.</p>
<p>Previously, a client would fail to authenticate with RSA keys to servers that reject signature algorithms based on SHA-1. This includes <a href="https://www.openssh.com/txt/release-8.8">OpenSSH 8.8</a> by default and—<a href="https://github.blog/changelog/2022-03-15-removed-unencrypted-git-protocol-and-certain-ssh-keys/">starting today March 15, 2022</a>—<a href="http://github.com/">github.com</a> for recently uploaded keys.</p>
</blockquote>
<figcaption><div>via <q><a href="https://groups.google.com/g/golang-announce/c/-cp44ypCT5s">An update of golang.org/x/crypto/ssh might be necessary</a></q></div></figcaption>
</figure>
<p>もうひとつは <code>golang.org/x/crypto/ssh</code> パッケージを使って SSH サービスを構成する場合の脆弱性で <a href="https://nvd.nist.gov/vuln/detail/CVE-2022-27191">CVE-2022-27191</a> が割り当てられている。</p>
<figure lang="en">
<blockquote><p>Version v0.0.0-20220314234659-1baeb1ce4c0b (included in the version above) also fixes a potential security issue where an attacker could cause a crash in a <a href="http://golang.org/x/crypto/ssh"><code>golang.org/x/crypto/ssh</code></a> server under these conditions:</p>
<ul>
<li>The server has been configured by passing a <a href="https://pkg.go.dev/golang.org/x/crypto/ssh#Signer"><code>Signer</code></a> to <a href="https://pkg.go.dev/golang.org/x/crypto/ssh#ServerConfig.AddHostKey"><code>ServerConfig.AddHostKey</code></a>.</li>
<li>The Signer passed to <code>AddHostKey</code> does not also implement <a href="https://pkg.go.dev/golang.org/x/crypto/ssh#AlgorithmSigner"><code>AlgorithmSigner</code></a>.</li>
<li>The Signer passed to <code>AddHostKey</code> does return a key of type “<code>ssh-rsa</code>” from its <code>PublicKey</code> method.</li>
</ul>
<p>Servers that only use <code>Signer</code> implementations provided by the ssh package are unaffected.</p>
</blockquote>
<figcaption><div>via <q><a href="https://groups.google.com/g/golang-announce/c/-cp44ypCT5s">An update of golang.org/x/crypto/ssh might be necessary</a></q></div></figcaption>
</figure>
<p><code>golang.org/x/crypto/ssh</code> パッケージを使って SSH サービスを利用している方はアップデートしましょう。</p>
<h2>ブックマーク</h2>
<ul>
<li><a href="https://zenn.dev/spiegel/articles/20201025-sayonara-sha1">さようなら SHA-1</a></li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B099928SJD?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/416Stewy0NS._SL160_.jpg" width="123" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B099928SJD?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">プログラミング言語Go</a></dt>
<dd>アラン・ドノバン (著), ブライアン・カーニハン (著), 柴田芳樹 (著)</dd>
<dd>丸善出版 2016-06-20 (Release 2021-07-13)</dd>
<dd>Kindle版</dd>
<dd>B099928SJD (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">Kindle 版出た! 一部内容が古びてしまったが,この本は Go 言語の教科書と言ってもいいだろう。感想は<a href="https://text.baldanders.info/remark/2016/07/go-programming-language/" >こちら</a>。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2021-05-22">2021-05-22</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- プログラミング言語Go -->
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
Git v2.29 がリリースされた
tag:text.Baldanders.info,2020-10-25:/release/2020/10/git-2_29-is-released/
2020-10-25T09:09:33+00:00
2020-11-02T23:24:36+00:00
SHA-2 コミット・ハッシュの実験的サポート / Windows 版 Git Credential Manager のアップグレード
Spiegel
https://baldanders.info/profile/
<p>先日 <a href="https://git-scm.com/">Git</a> v.2.29 がリリースされた。</p>
<ul>
<li><a href="https://lore.kernel.org/git/xmqqy2k2t77l.fsf@gitster.c.googlers.com/">[ANNOUNCE] Git v2.29.0</a></li>
</ul>
<h2>SHA-2 コミット・ハッシュの実験的サポート</h2>
<p>v2.29 ではコミット・ハッシュに関する重大な仕様変更がある。</p>
<figure lang="en">
<blockquote><q>Git 2.29 includes experimental support for writing your repository’s objects using a SHA-256 hash of their contents, instead of using SHA-1</q>.</blockquote>
<figcaption><div>via <q><a href="https://github.blog/2020-10-19-git-2-29-released/">Highlights from Git 2.29 - The GitHub Blog</a></q></div></figcaption>
</figure>
<p>といっても今回は実験的なサポート(experimental support)で,試すのであれば以下のような感じでできるらしい。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ git init --object-format=sha256 sample-repo
</span></span><span class="line"><span class="cl">Initialized empty Git repository in /home/username/sample-repo/.git/
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">$ cd sample-repo
</span></span><span class="line"><span class="cl">$ echo 'Hello, SHA-256!' >README.md
</span></span><span class="line"><span class="cl">$ git add README.md
</span></span><span class="line"><span class="cl">$ git commit -m "README.md: initial commit"
</span></span><span class="line"><span class="cl">[main (root-commit) 6d45449] README.md: initial commit
</span></span><span class="line"><span class="cl"> 1 file changed, 1 insertion(+)
</span></span><span class="line"><span class="cl"> create mode 100644 README.md
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl"> $ git rev-parse HEAD
</span></span><span class="line"><span class="cl"> 6d45449028a8e76500adbfe7330e779d5dc4a3a14fca58ff08ec354c58727b2c
</span></span></code></pre></div><p>当然ながら SHA-1 ベースのコミット・ハッシュと SHA-2 (SHA256) ベースのコミット・ハッシュとの間には互換性がない。
当面は2系統のリポジトリを使い分けて運用することになりそうだ。
ただし,将来的には両者を相互運用できるようにするらしい。</p>
<figure lang="en">
<blockquote><q>In future releases, Git will support interoperating between repositories with different object formats by computing both a SHA-1 and SHA-256 hash of each object it writes, and storing a translation table between them. This will eventually allow repositories that store their objects using SHA-256 to interact with (sufficiently up-to-date) SHA-1 clients, and vice-versa. It will also allow converted SHA-256 repositories to have their references to older SHA-1 commits still function as normal (e.g., if I write a commit whose message references an earlier commit by its SHA-1 name, then Git will still be able to follow that reference even after the repository is converted to use SHA-256 by consulting the translation table)</q>.</blockquote>
<figcaption><div>via <q><a href="https://github.blog/2020-10-19-git-2-29-released/">Highlights from Git 2.29 - The GitHub Blog</a></q></div></figcaption>
</figure>
<p>ここまで到達すれば SHA-2 ベースへ本格的に切り替えていってもいいかも知れない。</p>
<h2>Windows 版 Git Credential Manager のアップグレード</h2>
<p><a href="https://gitforwindows.org/">Git for Windows</a> では,もうひとつ重大な変更がある。</p>
<figure lang="en">
<blockquote><q>This version upgrades existing users of <a href="https://github.com/microsoft/Git-Credential-Manager-for-Windows/">Git Credential Manager for Windows</a> (which was just deprecated) to <a href="https://github.com/microsoft/Git-Credential-Manager-Core">Git Credential Manager Core</a> (“GCM Core”, which is the designated successor of the former). This is necessary because <a href="https://github.blog/changelog/2019-08-08-password-based-http-basic-authentication-deprecation-and-removal/">GitHub deprecated password-based authentication</a> and intends to remove support for it soon, and GCM Core is prepared for this change.</q>.</blockquote>
<figcaption><div>via <q><a href="https://github.com/git-for-windows/git/releases/tag/v2.29.0.windows.1">Release Git for Windows 2.29.0 · git-for-windows/git</a></q></div></figcaption>
</figure>
<p>GitHub リポジトリに HTTPS でアクセスしている場合は注意が必要かも知れない(<a href="https://gitforwindows.org/">Git for Windows</a> を使ってないので,どの程度影響するか分かってない。ゴメンペコン <abbr class="emoji-chars" title="ゴメン">🙇</abbr>)。</p>
<h2>ブックマーク</h2>
<ul>
<li>
<p><a href="https://lore.kernel.org/git/xmqq4kmlj9q9.fsf@gitster.c.googlers.com/">[ANNOUNCE] Git v2.29.1</a></p>
</li>
<li>
<p><a href="https://lore.kernel.org/git/xmqqlffo4qjw.fsf@gitster.c.googlers.com/">[ANNOUNCE] Git v2.29.2 - Junio C Hamano</a></p>
</li>
<li>
<p><a href="https://github.blog/2020-10-19-git-2-29-released/">Highlights from Git 2.29 - The GitHub Blog</a></p>
</li>
<li>
<p><a href="https://github.com/git-for-windows/git/releases/tag/v2.29.0.windows.1">Release Git for Windows 2.29.0 · git-for-windows/git · GitHub</a></p>
</li>
<li>
<p><a href="https://github.com/git-for-windows/git/releases/tag/v2.29.1.windows.1">Release Git for Windows 2.29.1 · git-for-windows/git · GitHub</a></p>
</li>
<li>
<p><a href="https://github.com/git-for-windows/git/releases/tag/v2.29.2.windows.1">Release Git for Windows 2.29.2 · git-for-windows/git · GitHub</a></p>
</li>
<li>
<p><a href="https://forest.watch.impress.co.jp/docs/news/1284871.html">「Git for Windows 2.29.0」が公開 ~セットアップ時にデフォルトブランチ名を設定可能 - 窓の杜</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2019/04/install-git-from-ppa/">PPA から Git をインストールする</a></p>
</li>
<li>
<p><a href="https://zenn.dev/spiegel/articles/20201025-sayonara-sha1">さようなら SHA-1</a> : SHA-1 の危殆化について Zenn でまとめ記事を書いてみた</p>
</li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
OpenSSH 鍵をアップグレードする【2020-01-11 改訂】
tag:text.Baldanders.info,2020-06-01:/remark/2020/06/upgrade-openssh-key/
2020-06-01T07:12:32+00:00
2024-01-26T21:38:55+00:00
どうせ鍵を新調するのなら楕円曲線暗号で構成するのがいいよね。
Spiegel
https://baldanders.info/profile/
<p><strong>【2020-01-11 改訂】</strong></p>
<p>2020-05-27 に <a href="https://www.openssh.com/">OpenSSH</a> 8.3 がリリースされた。</p>
<ul>
<li><a href="https://lwn.net/Articles/821544/">OpenSSH 8.3 released (and ssh-rsa deprecation notice) [LWN.net]</a></li>
</ul>
<p>この中で “Future deprecation notice” として</p>
<figure lang="en">
<blockquote><q>It is now possible to perform chosen-prefix attacks against the SHA-1 algorithm for less than USD$50K. For this reason, we will be disabling the “ssh-rsa” public key signature algorithm by default in a near-future release</q>.</blockquote>
<figcaption><div>via <q><a href="https://lwn.net/Articles/821544/">OpenSSH 8.3 released (and ssh-rsa deprecation notice)</a></q></div></figcaption>
</figure>
<p>と書かれていてた<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。
といっても,これはサーバ側の設定の話だそうでクライアントには関係ないそうだ(<a href="https://github.com/spiegel-im-spiegel/github-pages-env/discussions/85">フィードバック</a>感謝)。</p>
<!--
クライアント側はそろそろ古い RSA 鍵から交換したほうがよさそうである。
もっとも最近のバージョン[^sha1b] で作った鍵であれば特に問題ないようだ。
[^sha1b]: ちなみに,私は2011年に作った RSA 鍵を使っているが,ハッシュ・アルゴリズムは SHA256 だった。少なくとも10年以内に作った鍵なら問題なさそう? あとは鍵長かねぇ。
```text
$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/username/.ssh/id_rsa
Your public key has been saved in /home/username/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:qufsNjgco3QZNjE4eupwQiT6mD8fr2a7nXmU3ybxFHo username@hostname
The key's randomart image is:
+---[RSA 3072]----+
| . |
|..o o |
|+. . o |
|o.. + . |
|.* . + S. . . |
|* + = .o o E |
|o= +.+.. . * |
| .+ **+o. o + |
| =*XOo o |
+----[SHA256]-----+
```
ハッシュ・アルゴリズムが SHA256 以上になっているか,がポイント。
-->
<p>もし2048ビット以下の古い RSA 鍵を使ってるなら替えどきかな。
で,どうせ鍵を新調するのなら楕円曲線暗号(Elliptic Curve Cryptography; ECC)で構成するのがいいよね。</p>
<p>ちうわけで,ECC 鍵を作って登録するところまでやってみる。
ちゃんとメモっておかないと忘れるので(笑)</p>
<h2>前提条件【2021-01-09 変更】</h2>
<p>今回は <a href="https://www.ubuntu.com/" title="The leading operating system for PCs, IoT devices, servers and the cloud | Ubuntu">Ubuntu</a> 環境下での作業とし鍵管理を <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> で行うものとする。
<a href="https://www.ubuntu.com/" title="The leading operating system for PCs, IoT devices, servers and the cloud | Ubuntu">Ubuntu</a> での設定方法は以下を参考にどうぞ。</p>
<ul>
<li><a href="https://text.baldanders.info/openpgp/gpg-agent-in-ubuntu/">gpg-agent の設定: GnuPG in Ubuntu</a></li>
</ul>
<p>Windows 環境の場合は以下の拙文を参考にどうぞ。</p>
<ul>
<li><a href="https://text.baldanders.info/openpgp/using-gnupg-for-windows-2/">GnuPG for Windows : gpg-agent について</a></li>
</ul>
<p>ちなみに,今回は鍵の生成を <a href="https://www.openssh.com/">OpenSSH</a> で行っているが <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> でも生成できる。
詳しくは以下を参照のこと。</p>
<ul>
<li><a href="https://text.baldanders.info/openpgp/ssh-key-management-with-gnupg/">OpenSSH の認証鍵を GunPG で作成・管理する</a></li>
</ul>
<h2><a href="https://www.openssh.com/">OpenSSH</a> 鍵の生成</h2>
<p><a href="https://www.openssh.com/">OpenSSH</a> 鍵を生成するには <code>ssh-keygen</code> コマンドを使う。
たとえばこんな感じ。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ ssh-keygen -t ecdsa -b 256 -C "alice@example.com"
</span></span><span class="line"><span class="cl">Generating public/private ecdsa key pair.
</span></span><span class="line"><span class="cl">Enter file in which to save the key (/home/username/.ssh/id_ecdsa):
</span></span><span class="line"><span class="cl">Enter passphrase (empty for no passphrase):
</span></span><span class="line"><span class="cl">Enter same passphrase again:
</span></span><span class="line"><span class="cl">Your identification has been saved in /home/username/.ssh/id_ecdsa
</span></span><span class="line"><span class="cl">Your public key has been saved in /home/username/.ssh/id_ecdsa.pub
</span></span><span class="line"><span class="cl">The key fingerprint is:
</span></span><span class="line"><span class="cl">SHA256:DtXgQm9rz7Dc5M5yWu/CNVo341o1rcfN9UCyYu+SZU4 alice@example.com
</span></span><span class="line"><span class="cl">The key's randomart image is:
</span></span><span class="line"><span class="cl">+---[ECDSA 256]---+
</span></span><span class="line"><span class="cl">| . . |
</span></span><span class="line"><span class="cl">| . o o |
</span></span><span class="line"><span class="cl">| . = . . . |
</span></span><span class="line"><span class="cl">| + . + .|
</span></span><span class="line"><span class="cl">| . S + . ..+|
</span></span><span class="line"><span class="cl">| = X oE +*=|
</span></span><span class="line"><span class="cl">| +.*X.+oo*|
</span></span><span class="line"><span class="cl">| .+Bo.... |
</span></span><span class="line"><span class="cl">| .+o+=. |
</span></span><span class="line"><span class="cl">+----[SHA256]-----+
</span></span></code></pre></div><p>これで作成された <code>id_ecdsa</code> および <code>id_ecdsa.pub</code> ファイルが鍵ファイルである。
ちなみに <code>id_ecdsa</code> ファイルには秘密鍵, <code>id_ecdsa.pub</code> ファイルには公開鍵が格納されている。</p>
<p><code>-t</code> オプションで鍵種別を, <code>-b</code> で鍵長(ビット数)をセットする。
鍵種別と鍵長の組み合わせと,それぞれに対するセキュリティ強度(ビット数)は以下の通り<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>。</p>
<div>
<figure>
<style>
main table.sshkeys th {
vertical-align:middle;
text-align: center;
}
main table.sshkeys td {
vertical-align:middle;
//text-align: center;
}
</style>
<table class="sshkeys">
<thead>
<tr>
<th>鍵種別</th>
<th>鍵長</th>
<th>強度</th>
<th>楕円曲線名</th>
</tr>
</thead>
<tbody>
<tr>
<td><strike><code>dsa</code></strike></td>
<td class="right"><strike>1024</strike></td>
<td class="right">80</td>
<td>—</td>
</tr>
<tr>
<td rowspan="3"><code>ecdsa</code> / <code>ecdsa-sk</code></td>
<td class="right">256</td>
<td class="right">128</td>
<td><code>nistp256</code></td>
</tr>
<tr>
<td class="right">384</td>
<td class="right">192</td>
<td><code>nistp384</code></td>
</tr>
<tr>
<td class="right">521</td>
<td class="right">256</td>
<td><code>nistp521</code></td>
</tr>
<tr>
<td><code>ed25519</code> / <code>ed25519-sk</code></td>
<td class="right">—</td>
<td class="right">128</td>
<td><code>ed25519</code></td>
</tr>
<tr>
<td rowspan="3"><code>rsa</code></td>
<td class="right">3072</td>
<td class="right">128</td>
<td rowspan="3">—</td>
</tr>
<tr>
<td class="right">7680</td>
<td class="right">192</td>
</tr>
<tr>
<td class="right">15360</td>
<td class="right">256</td>
</tr>
</tbody>
</table>
</figure>
</div>
<p>この組み合わせの(<code>dsa</code> 以外の)いずれかであれば2031年以降も問題なく使える。
なお <code>ecdsa-sk</code> および <code>ed25519-sk</code> は暗号デバイスに登録する際に使うらしい(今回は割愛する)。</p>
<p>余談だが楕円曲線 <code>ed25519</code> に対応する電子署名アルゴリズムは EdDSA と呼ばれ <a href="https://tools.ietf.org/html/rfc8032" title="RFC 8032 - Edwards-Curve Digital Signature Algorithm (EdDSA)">RFC 8032</a> で規定されている<sup id="fnref:3"><a href="#fn:3" class="footnote-ref" role="doc-noteref">3</a></sup>。
なんで鍵種別を <code>eddsa</code> としなかったのかは知らない。
紛らわしかったのかな?</p>
<h3>楕円曲線と鍵長</h3>
<p>(「<a href="https://text.baldanders.info/openpgp/using-ecc-with-gnupg/">そろそろ GnuPG でも ECC を標準で使うのがいいんじゃないかな</a>」より抜粋)</p>
<p>ここでちょっと横道に逸れて鍵長の話をしておく。</p>
<p>たとえば RSA の(平文 $M$ から暗号文 $C$ への)暗号化は以下の式で表される。</p>
<figure><div class="mathjax box">
\[
C = M^e \bmod n
\]
</div></figure>
<p>$(e, n)$ のセットが公開鍵で, $n$ のサイズが鍵長に相当する。
実際の計算はともかく,感覚としては分かりやすいよね。</p>
<p>ECC の場合は暗号化の前に,まずベースとなる楕円曲線の(素数 $q$ で決められる)素体(prime fields)を決めなければならない<sup id="fnref:4"><a href="#fn:4" class="footnote-ref" role="doc-noteref">4</a></sup>。
これは以下の式で表される。</p>
<figure><div class="mathjax box">
\[
E : y^2 \equiv x^3 + ax + b \pmod{q}
\]
</div></figure>
<p>この素体上の有理点の数(位数)を $\#E$ とした時の $\#E$ のサイズが鍵長に相当する。
$(a,b,q)$ といったパラメータを眺めただけでは鍵長が分からないというのが面倒臭い感じである<sup id="fnref:5"><a href="#fn:5" class="footnote-ref" role="doc-noteref">5</a></sup>。</p>
<p>そこで ECC の場合は楕円曲線を表すパラメータのセットが標準化されている。
<a href="https://www.openssh.com/">OpenSSH</a> の場合は <code>nistp256</code>, <code>nistp384</code>, <code>nistp521</code>, <code>ed25519</code> といった楕円曲線名に対応している。
つまり楕円曲線名から楕円曲線の種類を特定し,そこから鍵長も分かる,というわけだ。</p>
<h2><a href="https://www.openssh.com/">OpenSSH</a> 鍵の登録(クライアント側)</h2>
<p>本題に戻る。
作成した <a href="https://www.openssh.com/">OpenSSH</a> 鍵ファイル <code>id_ecdsa</code> および <code>id_ecdsa.pub</code> を登録しよう。</p>
<p>クライアント側は <code>ssh-add</code> コマンドを使って秘密鍵ファイル <code>id_ecdsa</code> の内容を <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> の鍵束に永続的に登録できる。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ ssh-add ./id_ecdsa
</span></span><span class="line"><span class="cl">Enter passphrase for ./id_ecdsa:
</span></span><span class="line"><span class="cl">Identity added: ./id_ecdsa (alice@example.com)
</span></span></code></pre></div><p>この時 <code>ssh-add</code> コマンドによるパスフレーズ入力とは別に <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> の pinentry によるパスフレーズの設定が行われる(確認を含めて2回入力する必要あり)。</p>
<figure style='margin:0 auto;text-align:center;'><a href="./pinentry.png"><img src="./pinentry.png" srcset="./pinentry.png 500w" sizes="(min-width:600px) 500px, 80vw" alt="pinentry" loading="lazy"></a><figcaption><div><a href="./pinentry.png">pinentry</a></div></figcaption>
</figure>
<p>Pinentry で設定するパスフレーズは <code>id_ecdsa</code> ファイルに対するものとは管理が異なるので注意。
というか <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> の鍵束に登録したら <code>id_ecdsa</code> ファイルは不要になる。</p>
<p><a href="https://www.openssh.com/">OpenSSH</a> 秘密鍵が登録できたかどうかは <code>~/.gnupg/sshcontrol</code> ファイルで確認できる。
ちゃんと登録できていれば以下のような内容が追記される。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl"># ECDSA key added on: 2020-06-01 14:05:35
</span></span><span class="line"><span class="cl"># Fingerprints: MD5:e4:5b:66:a6:03:9a:a4:0e:f2:1b:a5:04:72:93:f3:f0
</span></span><span class="line"><span class="cl"># SHA256:DtXgQm9rz7Dc5M5yWu/CNVo341o1rcfN9UCyYu+SZU4
</span></span><span class="line"><span class="cl">A5353D587000D820669B0BD55A0B4AD6897458DB 0
</span></span></code></pre></div><p>また <code>ssh-add -L</code> コマンドでも登録した鍵を確認できる。</p>
<p>鍵の実体は <code>~/.gnupg/private-keys-v1.d/</code> ディレクトリにある。
上述の鍵の場合は</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">A5353D587000D820669B0BD55A0B4AD6897458DB.key
</span></span></code></pre></div><p>というファイル名で格納されているはずである。</p>
<h2><a href="https://www.openssh.com/">OpenSSH</a> 鍵の登録(サーバ側)</h2>
<p>ログイン先のサーバに公開鍵ファイル <code>id_ecdsa.pub</code> の中身を登録する。
つっても,どうにかして <code>id_ecdsa.pub</code> ファイルをサーバにアップロードして</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ cat ./id_ecdsa.pub >> ~/.ssh/authorized_keys
</span></span></code></pre></div><p>と <code>authorized_keys</code> ファイルに追記すればよい。
追記ではなく内容を書き換えるなら</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ cat ./id_ecdsa.pub > ~/.ssh/authorized_keys
</span></span></code></pre></div><p>でもよい。
書き換えるなら以前のファイルのバックアップはとってね。
パーミッションの設定も忘れずに。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ chmod 700 ~/.ssh
</span></span><span class="line"><span class="cl">$ chmod 600 ~/.ssh/authorized_keys
</span></span></code></pre></div><p>老婆心ながら,新しい鍵でログインできることを確認するまでは接続中のセッションは切らないこと。
設定を間違えてログイン不能になったら悲惨だからねぇ。</p>
<div class="box"><h3>【2021-12-13 追記】 ssh-copy-id を使う方法</h3>
<p><a href="https://github.com/spiegel-im-spiegel/github-pages-env/discussions/85#discussioncomment-1793423">フィードバックで教えてもらった</a>が(感謝!) <code>ssh-copy-id</code> コマンド(中身は shell スクリプト)を使うともっと簡単に登録できるそうだ。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ ssh-copy-id -h
</span></span><span class="line"><span class="cl">Usage: /usr/bin/ssh-copy-id [-h|-?|-f|-n] [-i [identity_file]] [-p port] [-F alternative ssh_config file] [[-o <ssh -o options>] ...] [user@]hostname
</span></span><span class="line"><span class="cl"> -f: force mode -- copy keys without trying to check if they are already installed
</span></span><span class="line"><span class="cl"> -n: dry run -- no keys are actually copied
</span></span><span class="line"><span class="cl"> -h|-?: print this help
</span></span></code></pre></div><p>ふむむ。
<code>-n</code> オプションで dry run できるのか。
ありがたい。</p>
<p><code>-i</code> オプションで公開鍵ファイルを指定するが,標準入力からも受け付けるようなので,パイプで繋いで</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ ssh-add -L | ssh-copy-id -n alice@hostname
</span></span><span class="line"><span class="cl">/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
</span></span><span class="line"><span class="cl">/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
</span></span><span class="line"><span class="cl">=-=-=-=-=-=-=-=
</span></span><span class="line"><span class="cl">Would have added the following key(s):
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFfjejx/Saej929myfZoBQAKgusPi2iiOxdZZfpCLxh5 (none)
</span></span><span class="line"><span class="cl">=-=-=-=-=-=-=-=
</span></span></code></pre></div><p>てな感じにできる(実際に登録する際は <code>-n</code> オプションを外してね)。</p>
<p>あるいは <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> で作った認証鍵であれば</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ gpg --export-ssh-key alice | ssh-copy-id -n alice@hostname
</span></span></code></pre></div><p>などとすることもできる(実際に登録する際は <code>-n</code> オプションを外してね)。</p>
<p>サーバ側に既に <code>~/.ssh/authorized_keys</code> ファイルがある場合は(公開鍵認証でログインした上で)ちゃんと追記してくれるし,パーミッションの心配も要らないようだ。</p>
<p>教えていただいて本当にありがとう <abbr class="emoji-chars" title="ペコン">🙇</abbr></p>
</div>
<h3>各種 <a href="https://git-scm.com/">Git</a> リポジトリ・サービスに公開鍵を登録する</h3>
<p><a href="https://github.com/">GitHub</a> ではリポジトリのアクセスに <a href="https://www.openssh.com/">OpenSSH</a> 認証が使える。
<a href="https://www.openssh.com/">OpenSSH</a> 認証に使う公開鍵は設定の “<a href="https://github.com/settings/keys">SSH and GPG keys</a>” で登録する(複数登録可能)。</p>
<p><a href="https://bitbucket.org/product/">Bitbucket</a> や <a href="https://gitlab.com/">GitLab</a> などの各種 <a href="https://git-scm.com/">git</a> リポジトリ・サービスでも同様に <a href="https://www.openssh.com/">OpenSSH</a> 公開鍵を登録できる。</p>
<p>よしゃあ! これで作業完了。</p>
<h2>ブックマーク</h2>
<ul>
<li>
<p><a href="https://orumin.blogspot.com/2020/05/ssh-rsa.html">ssh-rsa,非推奨のお知らせ</a></p>
</li>
<li>
<p><a href="https://japan.zdnet.com/article/35154545/">OpenSSH、将来のリリースでssh-rsa公開鍵の署名アルゴリズムをデフォルトで無効に - ZDNet Japan</a></p>
</li>
<li>
<p><a href="https://support.conoha.jp/v/openssh/">OpenSSHの認証に証明書を使う方法|ConoHa VPSサポート</a></p>
</li>
<li>
<p><a href="https://qiita.com/aat00000/items/a7973b104be9bfd3bb5c">SSHのCA認証 - Qiita</a></p>
</li>
<li>
<p><a href="https://gist.github.com/artizirk/d09ce3570021b0f65469cb450bee5e29">OpenPGP SSH access with Yubikey and GnuPG · GitHub</a></p>
</li>
<li>
<p><a href="https://developers.yubico.com/PIV/Guides/Securing_SSH_with_OpenPGP_or_PIV.html">Securing SSH with OpenPGP or PIV</a></p>
</li>
<li>
<p><a href="https://developers.yubico.com/SSH/">Securing SSH with the YubiKey</a></p>
</li>
<li>
<p><a href="https://dev.classmethod.jp/articles/ssh-ubuntu-ec2-with-fido-u2f-security-key/">セキュリティキー「YubiKey」でEC2へのSSHを2段階認証にしてみた | Developers.IO</a></p>
</li>
<li>
<p><a href="https://nulab.com/ja/blog/backlog/disables-rsa-sig-using-the-sha-1-in-openssh/">OpenSSHがSHA-1を使用したRSA署名を廃止、BacklogのGitで発生した問題と解決にいたるまでの道のり | 株式会社ヌーラボ(Nulab inc.)</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2017/10/key-parameters/">暗号鍵関連の各種変数について</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2020/01/sayonara-sha-1/">(何度目かの)さようなら SHA-1</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2020/06/eddsa/">Edwards-curve Digital Signature Algorithm</a></p>
</li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51ZRZ62WKCL._SL160_.jpg" width="108" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号化 プライバシーを救った反乱者たち</a></dt>
<dd>スティーブン・レビー (著), 斉藤 隆央 (翻訳)</dd>
<dd>紀伊國屋書店 2002-02-16</dd>
<dd>単行本</dd>
<dd>4314009071 (ASIN), 9784314009072 (EAN), 4314009071 (ISBN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">20世紀末,暗号技術の世界で何があったのか。知りたかったらこちらを読むべし!</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-03-09">2015-03-09</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号化 プライバシーを救った反乱者たち -->
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>実は同様の問題は <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> でも指摘されていて,半年前にリリースされた 2.2.18 で対応済みである(<a href="https://text.baldanders.info/release/2019/11/gnupg-2_2_18-is-released/">GnuPG 2.2.18 リリース: さようなら SHA-1</a>) <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:2">
<p><a href="https://github.com/spiegel-im-spiegel/github-pages-env/discussions/85">フィードバック</a>で教えていただいたが, <a href="https://www.openssh.com/">OpenSSH</a> は FIPS 186-3 以降の DSA に対応していないそうで,1024ビットの鍵長しか選択できないらしい。なので,最近の <a href="https://www.openssh.com/">OpenSSH</a> のデフォルト設定では DSA を無効にしているそうな。情報感謝です。あと <code>ecdsa-sk</code> では鍵長の指定はできない(無視される)ようだ。256ビット(<code>nistp256</code>)固定ってことかな? <a href="#fnref:2" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:3">
<p><code>ed25519</code> (edwards25519) は <a href="http://cr.yp.to/ecdh.html" title="Curve25519: high-speed elliptic-curve cryptography">Curve25519</a> と双有理同値な楕円曲線で,鍵長も <a href="http://cr.yp.to/ecdh.html" title="Curve25519: high-speed elliptic-curve cryptography">Curve25519</a> と同じく256ビット(セキュリティ強度128ビット)と見積もられている。ちなみに <a href="http://cr.yp.to/ecdh.html" title="Curve25519: high-speed elliptic-curve cryptography">Curve25519</a> は ECDH 用の楕円曲線およびそのライブラリで,公有(public domain)のソフトウェアとして公開されている。また <a href="https://text.baldanders.info/remark/2020/06/eddsa/" title="Edwards-curve Digital Signature Algorithm">EdDSA は FIPS 186-5 に組み込まれる予定</a>になっていて,そうなれば正式に NIST 標準となる。 <a href="#fnref:3" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:4">
<p>素体ではなく「標数2の体(binary fields)」を使う場合もあるが,ここでは割愛する。 <a href="#fnref:4" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:5">
<p>楕円曲線と楕円曲線暗号については結城浩さんの『<a href="https://www.amazon.co.jp/exec/obidos/ASIN/B015643CPE/baldandersinf-22/">暗号技術入門 第3版</a>』の付録に比較的分かりやすい解説が載っている。同じく結城浩さんの『<a href="https://www.amazon.co.jp/exec/obidos/ASIN/B00L0PDMK4/baldandersinf-22/">数学ガール ガロア理論</a>』が何となく分かれば楕円曲線についても何となく分かると思う。大丈夫。私も何となくしか分かっていない(笑) <a href="#fnref:5" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</div>
(何度目かの)さようなら SHA-1
tag:text.Baldanders.info,2020-01-09:/remark/2020/01/sayonara-sha-1/
2020-01-09T14:02:25+00:00
2020-10-26T10:24:45+00:00
思ったより騒がれてる感じなので記事を立ててみた。
Spiegel
https://baldanders.info/profile/
<p>2019年11月に書いた「<a href="https://text.baldanders.info/release/2019/11/gnupg-2_2_18-is-released/">GnuPG 2.2.18 リリース: さようなら SHA-1</a>」に追記してお終いにしようかと思ったが,思ったより騒がれてる感じなので記事を立ててみた。</p>
<p>というわけで:</p>
<ul>
<li><a href="https://eprint.iacr.org/2020/014">Cryptology ePrint Archive: Report 2020/014 - SHA-1 is a Shambles - First Chosen-Prefix Collision on SHA-1 and Application to the PGP Web of Trust</a></li>
<li><a href="https://sha-mbles.github.io/">SHA-1 is a Shambles</a></li>
<li><a href="https://arstechnica.com/information-technology/2020/01/pgp-keys-software-security-and-much-more-threatened-by-new-sha1-exploit/">PGP keys, software security, and much more threatened by new SHA1 exploit | Ars Technica</a></li>
<li><a href="https://www.schneier.com/blog/archives/2020/01/new_sha-1_attac.html">New SHA-1 Attack - Schneier on Security</a></li>
</ul>
<p>要約としては <a href="https://www.schneier.com/blog/archives/2020/01/new_sha-1_attac.html" title="New SHA-1 Attack - Schneier on Security">Bruce Schneier さんの記事</a>が分かりやすいので,これを起点に紹介していく。</p>
<h2>ハッシュ値の衝突問題</h2>
<p>(「<a href="https://text.baldanders.info/remark/2015/problem-of-sha1-collision/">SHA-1 衝突問題: 廃止の前倒し</a>」からの抜粋)</p>
<p>暗号技術におけるハッシュ関数とは,以下の機能を持ったアルゴリズムである</p>
<ol>
<li>任意のデータ列を一定の長さのデータ列(ハッシュ値)に「要約」する</li>
<li>ハッシュ値から元のデータ列を推測できない</li>
<li>ひとつのハッシュ値に対して複数のデータ列が(実時間で)見つからない</li>
</ol>
<p>ハッシュ関数はメッセージ認証符号(Message Authentication Code; MAC)や電子署名(digital signature)の中核技術のひとつであり,データの「完全性(Integrity)」を担保する重要な要素である。
特に3番目の「ひとつのハッシュ値に対して複数のデータ列が(実時間で)見つからない」という機能が破られると,そのハッシュ関数では完全性を担保できなくなってしまう。
これを「ハッシュ値の衝突問題」という。</p>
<h2>SHA-1 ハッシュ値を力づくで攻略してみる</h2>
<p>SHA-1 における「ハッシュ値の衝突問題」は<a href="https://baldanders.info/blog/000048/">2004年まで遡る</a>が,当時の攻略法は SHA-1 アルゴリズムの危殆化を狙ったもので,しかもその後の進展は殆どなかった。</p>
<p>この状況が変わったのが2015年の “<a href="https://sites.google.com/site/itstheshappening/">freestart collisions for SHA-1</a>” 論文である。</p>
<ul>
<li><a href="https://text.baldanders.info/remark/2015/problem-of-sha1-collision/">SHA-1 衝突問題: 廃止の前倒し</a></li>
</ul>
<p>ここで初めて「SHA-1 ハッシュ値を力づくで攻略」できる可能性が示された。
さらに2017年には Google によって最初の SHA-1 衝突例が公表された。</p>
<ul>
<li><a href="https://text.baldanders.info/remark/2017/02/sha-1-collision/">最初の SHA-1 衝突例</a></li>
</ul>
<p>今回の “<a href="https://sha-mbles.github.io/">SHA-1 is a Shambles</a>” の注目点は</p>
<ol>
<li>“chosen-prefix collision for SHA-1” なる手法により,衝突可能なデータを用意する際の自由度が高い</li>
<li>ハッシュ値を攻略する際の計算機パワーの調達コストが比較的実用的なレベルまで下がった</li>
</ol>
<p>の2つである。
特に2番目が重要で, “Nvidia GTX 1060GPU” × 900 の構成で2ヶ月ほどで攻略できたらしい。
コストにして 45k USD だそうだ<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。</p>
<h2><a href="https://www.openpgp.org/">OpenPGP</a> / <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> は既に SHA-1 を捨てつつある</h2>
<p>“<a href="https://sha-mbles.github.io/">SHA-1 is a Shambles</a>” では <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> が生成する公開鍵への電子署名をターゲットにしているが,実は現行の <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 2.2 系は既に SHA-1 を捨てつつあり,電子署名に使うハッシュ関数の既定は SHA256 である(“<a href="https://sha-mbles.github.io/">SHA-1 is a Shambles</a>” で指摘されているのはレガシー・バージョンの 1.4 系のほう)。</p>
<p>たとえば私が git コミットへの署名などで<a href="https://baldanders.info/pubkeys/">普段遣いしている OpenPGP 鍵</a>は2013年に作ったものだが,鍵への署名は SHA256 で行っている。
私の公開鍵をチェックするには以下のコマンドを実行すればよい(何気に拙作の <a href="https://github.com/spiegel-im-spiegel/gpgpdump" title="spiegel-im-spiegel/gpgpdump: OpenPGP packet visualizer">gpgpdump</a> を宣伝しておく<code>w</code>)。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ wget https://baldanders.info/pubkeys/spiegel.asc -O - | gpgpdump
</span></span></code></pre></div><p>また,次期 OpenPGP 標準となる <a href="https://datatracker.ietf.org/doc/draft-ietf-openpgp-rfc4880bis/" title="draft-ietf-openpgp-rfc4880bis - OpenPGP Message Format">RFC 4880bis</a> では新しい V5 パケットを策定中だが,鍵指紋(key fingerprint)に使うハッシュ関数の既定が SHA256 になるようだ。
<a href="https://datatracker.ietf.org/doc/draft-ietf-openpgp-rfc4880bis/" title="draft-ietf-openpgp-rfc4880bis - OpenPGP Message Format">RFC 4880bis</a> が正式に RFC 標準として公開されれば,かつての MD5 と同じく, SHA-1 は後方互換性のためだけに残されることになるだろう<sup id="fnref:2"><a href="#fn:2" class="footnote-ref" role="doc-noteref">2</a></sup>。</p>
<p><a href="https://www.openpgp.org/">OpenPGP</a> の実装は <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> だけではなく,今や<a href="https://www.symantec.com/products/encryption">シマンテック社のおまけプロダクトに成り下がった PGP</a> をはじめ <a href="http://openpgpjs.org/" title="OpenPGP.js | OpenPGP JavaScript Implementation">JsvaScript</a> や <a href="https://sequoia-pgp.org/" title="Sequoia-PGP">Rust</a> などによる実装がある。
これらの実装が SHA-1 をどのように取り扱っているかは分からない。
どなたか教えて!</p>
<div class="box"><p><strong>【2020-10-26 追記】</strong>
<a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 以外の実装でも議論が行われているようだ。</p>
<ul>
<li><a href="https://mailarchive.ietf.org/arch/msg/openpgp/Rp-inhYKT8A9H5E34iLTrc9I0gc/">[openpgp] Deprecating SHA1</a></li>
</ul></div>
<h2><a href="https://git-scm.com/">Git</a> のコミット・ハッシュはどうなるのか</h2>
<p>おそらく今回の件でもっとも議論を呼ぶのは <a href="https://git-scm.com/">git</a> なんじゃないだろうか。
<a href="https://git-scm.com/">Git</a> のコミット・ハッシュは SHA-1 を使って行われるが,ハッシュ値の衝突が比較的簡単にできるようになれば,ひとつのコミット・ハッシュに対して複数のコミットが重複してしまうという問題が現実的になるかもしれない(ならないかもしれない)。</p>
<p>ただ,コミットへの電子署名が正しく運用されているなら,<a href="https://text.baldanders.info/openpgp/web-of-trust/" title="OpenPGP の電子署名は「ユーザーの身元を保証し」ない">なりすましに対してはある程度は抑止(防止ではない)できる</a>だろう。</p>
<p>なので,個人的にはあまり心配はしていない。
<a href="https://git-scm.com/">Git</a> の今後の活躍にご期待ください,といったところだろうか(笑)</p>
<div class="box"><p><strong>【2020-10-26 追記】</strong>
[Git] 2.29 から SHA-2 ベースのコミット・ハッシュがサポートされるようになった。</p>
<ul>
<li><a href="https://text.baldanders.info/release/2020/10/git-2_29-is-released/">Git v2.29 がリリースされた</a></li>
</ul></div>
<h2>ブックマーク</h2>
<ul>
<li>
<p><a href="https://mailarchive.ietf.org/arch/msg/openpgp/h-6vCMDFFKhVXpXLC6gAt9tK7r8">“SHA-1 is a Shambles” and forging PGP WoT signatures</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/openpgp/algorithms-for-openpgp/">OpenPGP で利用可能なアルゴリズム(RFC 4880bis 対応版)</a></p>
</li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51ZRZ62WKCL._SL160_.jpg" width="108" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号化 プライバシーを救った反乱者たち</a></dt>
<dd>スティーブン・レビー (著), 斉藤 隆央 (翻訳)</dd>
<dd>紀伊國屋書店 2002-02-16</dd>
<dd>単行本</dd>
<dd>4314009071 (ASIN), 9784314009072 (EAN), 4314009071 (ISBN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">20世紀末,暗号技術の世界で何があったのか。知りたかったらこちらを読むべし!</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-03-09">2015-03-09</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号化 プライバシーを救った反乱者たち -->
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>単純に 1 USD = 110 JPY とするなら 45k USD = 4.95M JPY ほど。まぁ五百万円以下で攻略できてしまうわけですな。 <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
<li id="fn:2">
<p><a href="https://datatracker.ietf.org/doc/draft-ietf-openpgp-rfc4880bis/" title="draft-ietf-openpgp-rfc4880bis - OpenPGP Message Format">RFC 4880bis</a> では SHA-1 は “SHOULD NOT create messages” となる。<a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 2.2.18 以降では,これが前倒しで実装されたわけだ。ちなみに <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 2.2 系では MD5 は既にサポートされていない(1.4 系があるため)。 <a href="#fnref:2" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</div>
GnuPG 2.2.18 リリース: さようなら SHA-1
tag:text.Baldanders.info,2019-11-26:/release/2019/11/gnupg-2_2_18-is-released/
2019-11-26T13:12:19+00:00
2020-09-18T01:51:57+00:00
2019-01-19 以降に鍵に付与された SHA-1 ベースの電子署名を全て削除する(CVE-2019-14855)。
Spiegel
https://baldanders.info/profile/
<p><a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 2.2.18 がリリースされた。</p>
<ul>
<li><a href="https://lists.gnupg.org/pipermail/gnupg-announce/2019q4/000442.html">[Announce] GnuPG 2.2.18 released</a></li>
</ul>
<p>今回は(<a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 自体には)脆弱性もなく通常のメンテナンス・リリースなのだが,ひとつ大きな修正というか対策があって</p>
<figure lang="en">
<blockquote><q>This release also retires the use of SHA-1 key signatures created since this year.</q></blockquote>
<figcaption><div>via <q><a href="https://lists.gnupg.org/pipermail/gnupg-announce/2019q4/000442.html">GnuPG 2.2.18 released</a></q></div></figcaption>
</figure>
<p>らしい。
厳密には 2019-01-19 以降に鍵に付与された SHA-1 ベースの電子署名を全て削除するというもの(<a href="https://nvd.nist.gov/vuln/detail/CVE-2019-14855">CVE-2019-14855</a>)。</p>
<div class="box"><p><strong>【2020-09-18 追記】</strong>
<a href="https://nvd.nist.gov/vuln/detail/CVE-2019-14855">CVE-2019-14855</a> の CVSS 評価は以下の通り。</p>
<ul>
<li><code>CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N</code></li>
<li>深刻度: 重要 (7.5)</li>
</ul>
<table>
<thead>
<tr>
<th>基本評価基準</th>
<th>評価値</th>
</tr>
</thead>
<tbody>
<tr>
<td>攻撃元区分</td>
<td>ネットワーク</td>
</tr>
<tr>
<td>攻撃条件の複雑さ</td>
<td>低</td>
</tr>
<tr>
<td>必要な特権レベル</td>
<td>不要</td>
</tr>
<tr>
<td>ユーザ関与レベル</td>
<td>不要</td>
</tr>
<tr>
<td>スコープ</td>
<td>変更なし</td>
</tr>
<tr>
<td>機密性への影響</td>
<td>高</td>
</tr>
<tr>
<td>完全性への影響</td>
<td>なし</td>
</tr>
<tr>
<td>可用性への影響</td>
<td>なし</td>
</tr>
</tbody>
</table>
<p>ただし Red Hat はもう少し低めに見積もっているようで</p>
<ul>
<li><code>CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:N/A:N</code></li>
<li>深刻度: 警告 (5.3)</li>
</ul>
<table>
<thead>
<tr>
<th>基本評価基準</th>
<th>評価値</th>
</tr>
</thead>
<tbody>
<tr>
<td>攻撃元区分</td>
<td>ネットワーク</td>
</tr>
<tr>
<td>攻撃条件の複雑さ</td>
<td>高</td>
</tr>
<tr>
<td>必要な特権レベル</td>
<td>不要</td>
</tr>
<tr>
<td>ユーザ関与レベル</td>
<td>要</td>
</tr>
<tr>
<td>スコープ</td>
<td>変更なし</td>
</tr>
<tr>
<td>機密性への影響</td>
<td>高</td>
</tr>
<tr>
<td>完全性への影響</td>
<td>なし</td>
</tr>
<tr>
<td>可用性への影響</td>
<td>なし</td>
</tr>
</tbody>
</table>
<p>としている。</p>
</div>
<p>とはいえ,ずいぶん前から <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> が生成する電子署名は SHA2-256 ベースが既定なので影響は限定的だと思うが<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>, <strong>わざわざ</strong> SHA-1 ベースの電子署名を鍵に付与している方はご注意を。</p>
<p>一応 <code>--allow-weak-key-signatues</code> オプションを付けることで今回の措置を回避できるようだが,腹を括ったほうがいいだろう。
なお,鍵への電子署名にどのようなアルゴリズムが使われているかを調べるために拙作の <a href="https://github.com/spiegel-im-spiegel/gpgpdump" title="spiegel-im-spiegel/gpgpdump: OpenPGP packet visualizer">gpgpdump</a> を宣伝しておく(笑)</p>
<ul>
<li><a href="https://text.baldanders.info/release/gpgpdump/">OpenPGP パケットを可視化する gpgpdump</a></li>
</ul>
<p>例えば,こんな感じで鍵を取り出して調べることができる。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ gpg -a --export alice@example.com | gpgpdump
</span></span></code></pre></div><p>その他,詳細はこちら。</p>
<figure lang="en">
<blockquote><ul>
<li>gpg: Changed the way keys are detected on a smartcards; this allows the use of non-OpenPGP cards. In the case of a not very likely regression the new option <code>--use-only-openpgp-card</code> is available. [#4681]</li>
<li>gpg: The commands <code>--full-gen-key</code> and <code>--quick-gen-key</code> now allow direct key generation from supported cards. [#4681]</li>
<li>gpg: Prepare against chosen-prefix SHA-1 collisions in key signatures. This change removes all SHA-1 based key signature newer than 2019-01-19 from the web-of-trust. Note that this includes all key signature created with dsa1024 keys. The new option <code>--allow-weak-key-signatues</code> can be used to override the new and safer behaviour. [#4755,CVE-2019-14855]</li>
<li>gpg: Improve performance for import of large keyblocks. [#4592]</li>
<li>gpg: Implement a keybox compression run. [#4644]</li>
<li>gpg: Show warnings from dirmngr about redirect and certificate problems (details require <code>--verbose</code> as usual).</li>
<li>gpg: Allow to pass the empty string for the passphrase if the ‘<code>--passphase=</code>’ syntax is used. [#4633]</li>
<li>gpg: Fix printing of the KDF object attributes.</li>
<li>gpg: Avoid surprises with <code>--locate-external-key</code> and certain <code>--auto-key-locate</code> settings. [#4662]</li>
<li>gpg: Improve selection of best matching key. [#4713]</li>
<li>gpg: Delete key binding signature when deletring a subkey. [#4665,#4457]</li>
<li>gpg: Fix a potential loss of key sigantures during import with <code>self-sigs-only</code> active. [#4628]</li>
<li>gpg: Silence “marked as ultimately trusted” diagnostics if option <code>--quiet</code> is used. [#4634]</li>
<li>gpg: Silence some diagnostics during in key listsing even with option <code>--verbose</code>. [#4627]</li>
<li>gpg, gpgsm: Change parsing of agent’s pkdecrypt results. [#4652]</li>
<li>gpgsm: Support AES-256 keys.</li>
<li>gpgsm: Fix a bug in triggering a keybox compression run if <code>--faked-system-time</code> is used.</li>
<li>dirmngr: System CA certificates are no longer used for the SKS pool if GNUTLS instead of NTBTLS is used as TLS library. [#4594]</li>
<li>dirmngr: On Windows detect usability of IPv4 and IPv6 interfaces to avoid long timeouts. [#4165]</li>
<li>scd: Fix BWI value for APDU level transfers to make Gemalto Ezio Shield and Trustica Cryptoucan work. [#4654,#4566]</li>
<li>wkd: gpg-wks-client <code>--install-key</code> now installs the required policy file.</li>
</ul>
<p>Release-info: <a href="https://dev.gnupg.org/T4684">https://dev.gnupg.org/T4684</a></p></blockquote>
<figcaption><div>via <q><a href="https://lists.gnupg.org/pipermail/gnupg-announce/2019q4/000442.html">GnuPG 2.2.18 released</a></q></div></figcaption>
</figure>
<p>アップデートは計画的に。</p>
<h2>【2020-09-18 追記】 <a href="https://www.ubuntu.com/" title="The leading operating system for PCs, IoT devices, servers and the cloud | Ubuntu">Ubuntu</a> 18.04 LTS にてバックポート・パッチのリリースあり</h2>
<p>LTS 版 <a href="https://www.ubuntu.com/" title="The leading operating system for PCs, IoT devices, servers and the cloud | Ubuntu">Ubuntu</a> 18.04 にて <a href="https://nvd.nist.gov/vuln/detail/CVE-2019-14855">CVE-2019-14855</a> に対応したバックポートパッチが出ている。</p>
<ul>
<li><a href="https://ubuntu.com/security/notices/USN-4516-1">USN-4516-1: GnuPG vulnerability | Ubuntu security notices | Ubuntu</a></li>
</ul>
<p>今更どういうつもりなのか。
いや,まぁ,出るだけマシだけど。</p>
<p>ちなみに現時点で LTS 最新版である 20.04 では 2.2.19 が提供されている。</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">gpg --version
</span></span><span class="line"><span class="cl">gpg (GnuPG) 2.2.19
</span></span><span class="line"><span class="cl">libgcrypt 1.8.5
</span></span><span class="line"><span class="cl">Copyright (C) 2019 Free Software Foundation, Inc.
</span></span><span class="line"><span class="cl">License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
</span></span><span class="line"><span class="cl">This is free software: you are free to change and redistribute it.
</span></span><span class="line"><span class="cl">There is NO WARRANTY, to the extent permitted by law.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Home: /home/username/.gnupg
</span></span><span class="line"><span class="cl">サポートしているアルゴリズム:
</span></span><span class="line"><span class="cl">公開鍵: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
</span></span><span class="line"><span class="cl">暗号方式: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256,
</span></span><span class="line"><span class="cl"> TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256
</span></span><span class="line"><span class="cl">ハッシュ: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
</span></span><span class="line"><span class="cl">圧縮: 無圧縮, ZIP, ZLIB, BZIP2
</span></span></code></pre></div><p>現時点の <a href="https://gnupg.org/" title="The GNU Privacy Guard">GnuPG</a> 最新は 2.2.23 だけどね(笑)</p>
<p>しかし <a href="https://www.ubuntu.com/" title="The leading operating system for PCs, IoT devices, servers and the cloud | Ubuntu">Ubuntu</a> の足の遅さは何とかならないのかねぇ。
APT でも使う中核部品だろうに。</p>
<h2>ブックマーク</h2>
<ul>
<li>
<p><a href="https://mailarchive.ietf.org/arch/msg/openpgp/h-6vCMDFFKhVXpXLC6gAt9tK7r8">“SHA-1 is a Shambles” and forging PGP WoT signatures</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/openpgp/algorithms-for-openpgp/">OpenPGP で利用可能なアルゴリズム(RFC 4880bis 対応版)</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2015/problem-of-sha1-collision/">SHA-1 衝突問題: 廃止の前倒し</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2017/02/sha-1-collision/">最初の SHA-1 衝突例</a></p>
</li>
<li>
<p><a href="https://text.baldanders.info/remark/2020/01/sayonara-sha-1/">(何度目かの)さようなら SHA-1</a></p>
</li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51ZRZ62WKCL._SL160_.jpg" width="108" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号化 プライバシーを救った反乱者たち</a></dt>
<dd>スティーブン・レビー (著), 斉藤 隆央 (翻訳)</dd>
<dd>紀伊國屋書店 2002-02-16</dd>
<dd>単行本</dd>
<dd>4314009071 (ASIN), 9784314009072 (EAN), 4314009071 (ISBN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">20世紀末,暗号技術の世界で何があったのか。知りたかったらこちらを読むべし!</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-03-09">2015-03-09</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号化 プライバシーを救った反乱者たち -->
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>ちなみに私が<a href="https://baldanders.info/pubkeys/" title="OpenPGP 公開鍵リスト">普段遣いしている鍵</a>は2013年に作ったものだが, SHA2-256 ベースの電子署名が付与されている。 <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</div>
OpenPGP に関する話題
tag:text.Baldanders.info,2017-03-05:/remark/2017/03/topics-on-openpgp/
2017-03-05T08:19:39+00:00
2022-05-04T05:22:29+00:00
GnuPG 2.1.19 がリリース / 映像の証明 / 電子メールの暗号化 / SHA-1 の危殆化と OpenPGP V5
Spiegel
https://baldanders.info/profile/
<p>さてさて。
2月も逃げちゃいましたよ。</p>
<ol>
<li><a href="#gpg">GnuPG 2.1.19 がリリース</a></li>
<li><a href="#pm">映像の証明</a></li>
<li><a href="#em">電子メールの暗号化</a></li>
<li><a href="#v5">SHA-1 の危殆化と OpenPGP V5</a></li>
</ol>
<h2 id="gpg">GnuPG 2.1.19 がリリース</h2>
<ul>
<li><a href="https://lists.gnupg.org/pipermail/gnupg-announce/2017q1/000402.html">[Announce] GnuPG 2.1.19 released</a></li>
</ul>
<p>セキュリティアップデートはなし。
主な修正・変更点は以下の通り。</p>
<ul>
<li>gpg: Print a warning if Tor mode is requested but the Tor daemon is not running.</li>
<li>gpg: New status code <code>DECRYPTION_KEY</code> to print the actual private key used for decryption.</li>
<li>gpgv: New options <code>--log-file</code> and <code>--debug</code>.</li>
<li>gpg-agent: Revamp the prompts to ask for card PINs.</li>
<li>scd: Support for multiple card readers.</li>
<li>scd: Removed option <code>--debug-disable-ticker</code>. Ticker is used only when it is required to watch removal of device/card.</li>
<li>scd: Improved detection of card inserting and removal.</li>
<li>dirmngr: New option <code>--disable-ipv4</code>.</li>
<li>dirmngr: New option <code>--no-use-tor</code> to explicitly disable the use of Tor.</li>
<li>dirmngr: The option <code>--allow-version-check</code> is now required even if the option <code>--use-tor</code> is also used.</li>
<li>dirmngr: Handle a missing nsswitch.conf gracefully.</li>
<li>dirmngr: Avoid PTR lookups for keyserver pools. The are only done for the debug command “<code>keyserver --hosttable</code>”.</li>
<li>dirmngr: Rework the internal certificate cache to support classes of certificates. Load system provided certificates on startup. Add options <code>--tls</code>, <code>--no-crl</code>, and <code>--systrust</code> to the “<code>VALIDATE</code>” command.</li>
<li>dirmngr: Add support for the ntbtls library.</li>
<li>wks: Create mails with a “WKS-Phase” header. Fix detection of Draft-2 mode.</li>
<li>The Windows installer is now build with limited TLS support.</li>
<li>Many other bug fixes and new regression tests.</li>
</ul>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-text" data-lang="text"><span class="line"><span class="cl">$ gpg --version
</span></span><span class="line"><span class="cl">gpg (GnuPG) 2.1.19
</span></span><span class="line"><span class="cl">libgcrypt 1.7.6
</span></span><span class="line"><span class="cl">Copyright (C) 2017 Free Software Foundation, Inc.
</span></span><span class="line"><span class="cl">License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>
</span></span><span class="line"><span class="cl">This is free software: you are free to change and redistribute it.
</span></span><span class="line"><span class="cl">There is NO WARRANTY, to the extent permitted by law.
</span></span><span class="line"><span class="cl">
</span></span><span class="line"><span class="cl">Home: ********
</span></span><span class="line"><span class="cl">サポートしているアルゴリズム:
</span></span><span class="line"><span class="cl">公開鍵: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
</span></span><span class="line"><span class="cl">暗号方式: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
</span></span><span class="line"><span class="cl"> CAMELLIA128, CAMELLIA192, CAMELLIA256
</span></span><span class="line"><span class="cl">ハッシュ: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
</span></span><span class="line"><span class="cl">圧縮: 無圧縮, ZIP, ZLIB, BZIP2
</span></span></code></pre></div><h2 id="pm">映像の証明</h2>
<p><a href="https://guardianproject.info/" title="Guardian Project – People, Apps and Code You Can Trust">Guardian Project</a> が提供している <a href="https://guardianproject.info/apps/camerav/" title="CameraV: Secure Verifiable Photo & Video Camera – Guardian Project">CameraV</a> というカメラアプリがあるが,この中の Proof Mode という機能を有効にすることで写した写真やビデオの「証明」を作成することができるらしい。</p>
<ul>
<li><a href="https://guardianproject.info/2017/02/24/combating-fake-news-with-a-smartphone-proof-mode/">Combating “Fake News” With a Smartphone “Proof Mode” – Guardian Project</a></li>
<li><a href="https://www.schneier.com/blog/archives/2017/03/proof_mode_for_.html">“Proof Mode” for your Smartphone Camera - Schneier on Security</a></li>
</ul>
<figure lang="en">
<blockquote>
<q>On the technical front, what the app is doing is automatically generating an OpenPGP key for this installed instance of the app itself, and using that to automatically sign all photos and videos at time of capture. A sha256 hash is also generated, and combined with a snapshot of all available device sensor data, such as GPS location, wifi and mobile networks, altitude, device language, hardware type, and more. This is also signed, and stored with the media. All of this happens with no noticeable impact on battery life or performance, every time the user takes a photo or video.</q>
</blockquote>
<figcaption><div>via <q><a href="https://guardianproject.info/2017/02/24/combating-fake-news-with-a-smartphone-proof-mode/">Combating “Fake News” With a Smartphone “Proof Mode”</a></q></div></figcaption>
</figure>
<p>まぁ,いまどき映像であってもいくらでも捏造できるからねぇ。
こういう仕組みも必要になってくるというわけだ。
Proof Mode の設計目標は以下の通り。</p>
<ul>
<li>Run all of the time in the background without noticeable battery, storage or network impact</li>
<li>Provide a no-setup-required, automatic new user experience that works without requiring training</li>
<li>Use strong cryptography for strong identity and verification features, but not encryption</li>
<li>Produce “proof” sensor data formats that can be easily parse, imported by existing tools (CSV)</li>
<li>Do not modify the original media files; all proof metadata storied in separate file</li>
<li>Support chain of custody needs through automatic creation of sha256 hashes and PGP signatures</li>
<li>Do not require a persistent identity or account generation</li>
</ul>
<p>内部では映像毎に OpenPGP 電子署名を作成するが,鍵の生成や運用は自動でやってくれるようだ。
便利。
なのだが,イマイチ使い勝手がよく分からない。
使い方はおいおい覚えていくとしよう。</p>
<p>ちなみに <a href="https://guardianproject.info/apps/camerav/" title="CameraV: Secure Verifiable Photo & Video Camera – Guardian Project">CameraV</a> では撮った映像を暗号化したり panic 時に映像を全部消去できたりする機能もあるらしい。
最近いろいろ物騒だからねぇ。</p>
<ul>
<li><a href="https://techcrunch.com/2016/12/14/photojournalists-demand-encryption-light-is-giving-it-to-them/">フォトジャーナリストたちがプロ用カメラに暗号化機能を求めた | TechCrunch Japan</a></li>
<li><a href="https://techcrunch.com/2016/12/14/onpx-n-ovg-onpx-n-ovg-zber/">暗号化機能をカメラに追加しても写真ジャーナリストたちの問題は解決しない | TechCrunch Japan</a></li>
</ul>
<h2 id="em">電子メールの暗号化</h2>
<p>ここのところ暗号化電子メールの話題をよく見かける。</p>
<ul>
<li><a href="https://japan.zdnet.com/article/35097359/">グーグルのメール暗号化Chromeアプリケーション「E2EMail」がオープンソースに - ZDNet Japan</a></li>
<li><a href="http://getnews.jp/archives/1638152">Android版Gmail v7.2でS/MIMEの暗号化機能をサポート | ガジェット通信</a></li>
<li><a href="https://japan.techrepublic.com/article/35097236.htm">「Chromebook」で効率的に電子メールを暗号化する方法–「K-9 Mail」と「APG」を利用 - TechRepublic Japan</a></li>
</ul>
<p>「<a href="https://japan.zdnet.com/article/35097359/">グーグルのメール暗号化Chromeアプリケーション「E2EMail」がオープンソースに</a>」の最後の方に出てくる <a href="https://security.googleblog.com/2017/01/security-through-transparency.html" title="Google Online Security Blog: Security Through Transparency">Key Transparency</a> については以前に本家サイトで紹介したので参考にどうぞ。</p>
<ul>
<li><a href="https://baldanders.info/blog/000785/">Google による OpenPGP 鍵配送の解決提案 — Baldanders.info</a></li>
</ul>
<p>個人的には(OpenPGP ではないが)「<a href="http://getnews.jp/archives/1638152">Android版Gmail v7.2でS/MIMEの暗号化機能をサポート</a>」のほうに注目している。
S/MIME は X.509 型の PKI で鍵を運用するもので Web メールやケータイアプリでの鍵管理がやりやすいのが特徴。
こちらは暗号化より電子署名によるメールの証明がやりやすくなるのではないだろうか。</p>
<p>企業からのプロモーションメールを S/MIME 形式で電子署名することによって HTTPS の EV SSL と同様な効果が狙えると思う。
S/MIME 形式で電子署名が一般的になれば spam メールの排除もやりやすくなるかもしれない。</p>
<p>電子署名ではなく暗号化メールでいうなら,当面は <a href="https://protonmail.com/" title="Secure email: ProtonMail is free encrypted email.">ProtonMail</a> をお勧めする。</p>
<ul>
<li><a href="https://techcrunch.com/2016/11/11/signups-for-encrypted-mail-client-protonmail-double-after-election/">暗号化メールサービスProtonMailの新規ユーザーが選挙後に急増、トランプ新大統領の不寛容を懸念 | TechCrunch Japan</a></li>
</ul>
<p>私もしばらく前にアカウントを作っている。</p>
<ul>
<li><a href="https://text.baldanders.info/remark/2016/03/protonmail/">ProtonMail のアカウントを作りました</a></li>
</ul>
<h2 id="v5">SHA-1 の危殆化と OpenPGP V5</h2>
<p>現在の OpenPGP は鍵指紋に SHA-1 を使用しているが, <a href="https://text.baldanders.info/remark/2017/02/sha-1-collision/">SHA-1 の危殆化</a>に伴い「どーする?」ってな議論になってるようだ。</p>
<ul>
<li><a href="https://mailarchive.ietf.org/arch/msg/openpgp/_uV_coJ0CYayv_2ptJMuSraJhws">[openpgp] V5 Fingerprint again</a></li>
</ul>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
最初の SHA-1 衝突例
tag:text.Baldanders.info,2017-02-25:/remark/2017/02/sha-1-collision/
2017-02-25T03:38:07+00:00
2020-06-07T02:09:49+00:00
もうみんな SHA-1 とはオサラバしてるよね(笑)
Spiegel
https://baldanders.info/profile/
<p>いやぁ,ついにこの日が来たようです。</p>
<ul>
<li><a href="https://security.googleblog.com/2017/02/announcing-first-sha1-collision.html">Google Online Security Blog: Announcing the first SHA1 collision</a></li>
<li><a href="https://shattered.it/">SHAttered</a> : SHA-1 の衝突例</li>
<li><a href="https://www.schneier.com/blog/archives/2017/02/sha-1_collision.html">SHA-1 Collision Found - Schneier on Security</a></li>
<li><a href="http://www.itmedia.co.jp/enterprise/articles/1702/24/news067.html">SHA-1衝突攻撃がついに現実に、Google発表 90日後にコード公開 - ITmedia エンタープライズ</a></li>
<li><a href="https://blog.mozilla.org/security/2017/02/23/the-end-of-sha-1-on-the-public-web/">The end of SHA-1 on the Public Web | Mozilla Security Blog</a></li>
<li><a href="https://japan.zdnet.com/article/35097102/">グーグル、SHA-1衝突攻撃に成功–同一ハッシュ値の2つのPDFも公開 - ZDNet Japan</a></li>
<li><a href="https://mailarchive.ietf.org/arch/msg/openpgp/AjJ3BHzd2c9K2KQ3DTk9Ry_QVYM">Re: [openpgp] SHA1 collision found</a>
<ul>
<li><a href="https://mailarchive.ietf.org/arch/msg/openpgp/_uV_coJ0CYayv_2ptJMuSraJhws">[openpgp] V5 Fingerprint again</a></li>
</ul>
</li>
<li><a href="https://www.slideshare.net/herumi/googlesha1">GoogleのSHA-1のはなし</a> : 分かりやすい解説</li>
<li><a href="https://github.com/blog/2338-sha-1-collision-detection-on-github-com">SHA-1 collision detection on GitHub.com</a>
<ul>
<li><a href="http://internet.watch.impress.co.jp/docs/news/1050486.html">GitHub Enterprise、SHA-1衝突を実行不能にするパッチを適用へ -INTERNET Watch</a></li>
</ul>
</li>
</ul>
<figure lang="en">
<blockquote>
<q>This is not a surprise. We've all expected this for over a decade, watching computing power increase. This is why NIST standardized SHA-3 in 2012.</q>
</blockquote>
<figcaption><div>via <q><a href="https://www.schneier.com/blog/archives/2017/02/sha-1_collision.html">SHA-1 Collision Found</a></q></div></figcaption>
</figure>
<p>SHA-1 衝突問題については以下を参照のこと。
NIST などでは2014年以降 SHA-1 を電子署名等に使わないよう勧告している。</p>
<ul>
<li><a href="https://text.baldanders.info/remark/2015/problem-of-sha1-collision/">SHA-1 衝突問題: 廃止の前倒し</a></li>
<li><a href="http://www.cryptrec.go.jp/topics/cryptrec_20151218_sha1_cryptanalysis.html">CRYPTREC | SHA-1の安全性について</a></li>
</ul>
<p>現時点で主要な CA では証明書に SHA-1 は使っていないはずである。
また,主要なブラウザについても SHA-1 を使う証明書に対して警告を発するようになっている。</p>
<ul>
<li><a href="https://blogs.technet.microsoft.com/jpsecurity/2016/11/25/sha1countdown/">SHA-1 ウェブサーバー証明書は 2017 年2月から警告!ウェブサイト管理者は影響の最終確認を – 日本のセキュリティチーム</a></li>
<li><a href="http://forest.watch.impress.co.jp/docs/serial/yajiuma/1041798.html">「Google Chrome」の閲覧画面にエラーが! ~“https://”のサイトにアクセスできない - やじうまの杜 - 窓の杜</a></li>
</ul>
<p>もうみんな SHA-1 とはオサラバしてるよね(笑)</p>
<h2>追記というか補足</h2>
<p>たとえば git の commit hash 値は SHA-1 で付与されるが大丈夫なのか? とかいった意見が散見されるが,当面は問題ない。</p>
<p>今回の件はあくまでも電子署名や hash 値そのものを何かの証明に使おうとする場合に問題となる。
git の commit hash 値はあくまで identity として付与されるものである。
改ざんされたかどうかは commit hash 値ではなく差分情報によって容易に知ることができる。</p>
<p>git による悪意のなりすまし等を警戒する必要があるのなら commit hash 値を気にするのではなく commit にきちんと電子署名を行うことをお勧めする(チームで作業する人は是非習慣化するべきである)。</p>
<ul>
<li><a href="https://text.baldanders.info/remark/2016/04/git-commit-with-openpgp-signature/">Git Commit で OpenPGP 署名を行う</a></li>
</ul>
<p>ただし,かつて標準として使われていた MD5 が危殆化とともに廃れていったように,今後 SHA-1 は電子署名以外でも使われなくなると思われる。
念のため, NIST による現在の SHA アルゴリズムの評価と有効期限を以下に示す。</p>
<p><figure lang='en'>
<style>
main table.nist3 th {
vertical-align:middle;
text-align: center;
}
main table.nist3 td {
text-align: center;
}
</style>
<table class="nist3">
<thead>
<tr>
<th>Security <br>Strength</th>
<th>Digital Signatures and Other<br>Applications Requiring Collision<br>Resistance</th>
<th>HMAC, KMAC,<br>Key Derivation Functions,<br>Random Bit Generation</th>
</tr>
</thead>
<tbody>
<tr>
<td> $\le 8$0</td>
<td>SHA-1</td>
<td> </td>
</tr><tr>
<td>$112$</td>
<td>SHA-224, SHA-512/224, SHA3-224</td>
<td> </td>
</tr><tr>
<td>$128$</td>
<td>SHA-256, SHA-512/256, SHA3-256</td>
<td>SHA-1, KMAC128</td>
</tr><tr>
<td>$192$</td>
<td>SHA-384, SHA3-384</td>
<td>SHA-224, SHA-512/224, SHA3-224</td>
</tr><tr>
<td>$\ge 256$</td>
<td>SHA-512, SHA3-512</td>
<td>SHA-256, SHA-512/256, SHA-384, SHA-512, SHA3-256, SHA3-384, SHA3-512, KMAC256</td>
</tr>
</tbody>
</table>
<figcaption><div>Maximum security strengths for hash and hash-based functions (via <q><a href='https://doi.org/10.6028/NIST.SP.800-57pt1r5'>SP 800-57 Part 1 Revision 5 <sup><i class='far fa-file-pdf'></i></sup></a></q> 5.6.1.2)</div></figcaption>
</figure> <!-- 要 MathJax -->
<figure lang='en'>
<style>
main table.nist4 th {
vertical-align:middle;
text-align: center;
}
main table.nist4 td {
vertical-align:middle;
text-align: center;
}
</style>
<table class="nist4">
<thead>
<tr>
<th colspan='2'>Security Strength</th>
<th>Through<br> 2030</th>
<th>2031 and<br> Beyond</th>
</tr>
</thead>
<tbody>
<tr><td rowspan='2'>$\lt 112$</td><td>Applying</td> <td colspan='2'>Disallowed</td></tr>
<tr> <td>Processing</td> <td colspan='2'>Legacy use</td></tr>
<tr><td rowspan='2'>$112$</td> <td>Applying</td> <td rowspan='2'>Acceptable</td><td>Disallowed</td></tr>
<tr> <td>Processing</td> <td>Legacy use</td></tr>
<tr><td>$128$</td> <td rowspan='3'>Applying/Processing</td><td>Acceptable</td><td>Acceptable</td></tr>
<tr><td>$192$</td> <td>Acceptable</td><td>Acceptable</td></tr>
<tr><td>$256$</td> <td>Acceptable</td><td>Acceptable</td></tr>
</tbody>
</table>
<figcaption><div>Security-strength time frames (via <q><a href='https://doi.org/10.6028/NIST.SP.800-57pt1r5'>SP 800-57 Part 1 Revision 5 <sup><i class='far fa-file-pdf'></i></sup></a></q> 5.6.3)</div></figcaption>
</figure> <!-- 要 MathJax --></p>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
週末スペシャル: Go コンパイラのセキュリティアップデートがあるらしい
tag:text.Baldanders.info,2016-01-09:/remark/2016/01/09-stories/
2016-01-09T09:59:13+00:00
2020-01-05T11:59:50+00:00
Go コンパイラのセキュリティアップデートがあるらしい / GnuPG 1.4.20 released / GitLab.com にアカウントを作った / くそな「中間者デバイス」が SHA-1 廃止の邪魔をする
Spiegel
https://baldanders.info/profile/
<p>年末忙しくて書き損ねてるネタを回収中。</p>
<ol>
<li><a href="#go">Go コンパイラのセキュリティアップデートがあるらしい</a></li>
<li><a href="#gpg">GnuPG 1.4.20 released</a></li>
<li><a href="#gl">GitLab.com にアカウントを作った</a></li>
<li><a href="#mitm">くそな「中間者デバイス」が SHA-1 廃止の邪魔をする</a></li>
</ol>
<h2 id="go">Go コンパイラのセキュリティアップデートがあるらしい</h2>
<ul>
<li><a href="https://groups.google.com/forum/#!topic/golang-announce/MLaPAPFlCNY">[security] Go 1.5.3 pre-announcement - Google グループ</a></li>
</ul>
<p>詳細は示されてないが13日(日本時間だと14日かな)を待つことにしよう。
来週は月例のセキュリティ更新週間である。</p>
<h2 id="gpg">GnuPG 1.4.20 released</h2>
<p>昨年の話で申し訳ないが</p>
<ul>
<li><a href="https://lists.gnupg.org/pipermail/gnupg-announce/2015q4/000382.html">[Announce] GnuPG 1.4.20 released</a></li>
</ul>
<p>セキュリティアップデートではないが既定の動作が変わるようである。</p>
<ul>
<li>Reject signatures made using the MD5 hash algorithm unless the new option –allow-weak-digest-algos or –pgp2 are given.</li>
<li>New option –weak-digest to specify hash algorithms which should be considered weak.</li>
<li>Changed default cipher for symmetric-only encryption to AES-128.</li>
<li>Fix for DoS when importing certain garbled secret keys.</li>
<li>Improved error reporting for secret subkey w/o corresponding public subkey.</li>
<li>Improved error reporting in decryption due to wrong algorithm.</li>
<li>Fix cluttering of stdout with trustdb info in double verbose mode.</li>
<li>Pass a DBUS envvar to gpg-agent for use by gnome-keyring.</li>
</ul>
<p>GnuPG というか OpenPGP が後生大事に MD5 を残しているのは過去の資産への対応のためであろう。</p>
<p>ちなみに PGP の最初のリリースは1991年で,実に四半世紀も前である。
作者の <a href="https://www.philzimmermann.com/">Phil Zimmermann</a> は当時,米国内反核運動の活動家であった。
更に暗号技術に対する政治的圧力は現在と比較にならないほど厳しく,米国は長いあいだ彼をマークし続けた。
PGP の広まり方や改良のプロセスは実に「インターネット的」であった。
詳しくは Steven Levy の『<a href="https://www.amazon.co.jp/exec/obidos/ASIN/4314009071/baldandersinf-22/">暗号化(Crypto)</a>』をどうぞ。</p>
<p>あれからネットも随分変わったが,当時政府が何をしたか企業は何をしたか「暗号アナーキスト」たちはどうしたか。
現在のネットは先人の努力により「勝ち取った」ものであることを私たちは絶対に忘れてはならない。</p>
<p>自由そのものは自由ではない。
勝ち取ったものはいつか奪われる。
奪われたくなければ勝ち続けなければならない。</p>
<h2 id="gl">GitLab.com にアカウントを作った</h2>
<ul>
<li><a href="http://qiita.com/masakura/items/e679c094e8afea9a4879">GitLab/GitLab.com 勉強会 (2015/12/09) レポート - Qiita</a></li>
</ul>
<p>これ見て <a href="https://gitlab.com/" title="GitLab">GitLab.com</a> にアカウントを作ってみた。
とりあえず中身は空っぽ。
公開リポジトリを <a href="https://gitlab.com/" title="GitLab">GitLab.com</a> に作るメリットはない気もするが,容量が 10GB/repos あるのはありがたい。</p>
<p>まぁ,どう使うかはこれからおいおい考える。
今年あたり,どっかにサーバでも借りて私用リポジトリ・サービスを立ち上げてみたいのだが,これもおいおい。</p>
<h2 id="mitm">くそな「中間者デバイス」が SHA-1 廃止の邪魔をする</h2>
<p>いやもうこれは笑うところだよね。</p>
<ul>
<li><a href="http://japan.cnet.com/news/service/35075954/">「Firefox」、SHA-1証明書のサポートを一時的に復活–HTTPSサイトのアクセスに問題 - CNET Japan</a></li>
<li><a href="http://www.itmedia.co.jp/enterprise/articles/1601/08/news069.html">FirefoxのSHA-1廃止で一部ユーザーに障害、サポート復活 - ITmedia エンタープライズ</a></li>
</ul>
<figure>
<blockquote>
<q>Barnes氏は次のように説明している。「ユーザーがHTTPSサイトへの接続を試みると、中間者デバイスがFirefoxに対し、サーバの本物の証明書でなく新規のSHA-1証明書を送信する」<br>
「Firefoxは新規のSHA-1証明書を拒否するため、サーバに接続できない」(同氏)</q>
</blockquote>
<figcaption><div><q><a href="http://japan.cnet.com/news/service/35075954/">「Firefox」、SHA-1証明書のサポートを一時的に復活--HTTPSサイトのアクセスに問題</a></q>より</div></figcaption>
</figure>
<p>「<a href="https://text.baldanders.info/remark/2015/problem-of-sha1-collision/">SHA-1 衝突問題: 廃止の前倒し</a>」でも紹介したが, SHA-1 の危殆化はかなり現実的な問題になってきている。
いますぐどうこうというわけではないが,これ以上の先延ばしは出来ない状態である。
しかし CA やブラウザが頑張っても「中間者デバイス」なる覗き屋が邪魔をする。</p>
<p>やはりセキュリティ製品が暗号通信に対して「中間者攻撃」を仕掛けるのは筋が悪すぎると思うのだが,何とかならないものかねぇ。</p>
<h2>参考図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51ZRZ62WKCL._SL160_.jpg" width="108" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/4314009071?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号化 プライバシーを救った反乱者たち</a></dt>
<dd>スティーブン・レビー (著), 斉藤 隆央 (翻訳)</dd>
<dd>紀伊國屋書店 2002-02-16</dd>
<dd>単行本</dd>
<dd>4314009071 (ASIN), 9784314009072 (EAN), 4314009071 (ISBN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">20世紀末,暗号技術の世界で何があったのか。知りたかったらこちらを読むべし!</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-03-09">2015-03-09</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号化 プライバシーを救った反乱者たち -->
SHA-1 衝突問題: 廃止の前倒し
tag:text.Baldanders.info,2015-10-22:/remark/2015/problem-of-sha1-collision/
2015-10-22T05:35:22+00:00
2020-06-07T02:09:49+00:00
GPU をふんだんに使った専用ハードウェアやクラウド・サービスなどを組み合わせることにより,近い将来に実用的なコストで SHA-1 攻略が可能になると指摘されている。
Spiegel
https://baldanders.info/profile/
<p>SHA-1 の廃止プロセスが前倒しになるかもしれない。</p>
<h2>おさらい: SHA-1 衝突問題</h2>
<p>そもそもの発端は,2004年に複数の hash 関数において高い確率で hash 値を衝突(collision)させる攻略法が発表されたことだった。</p>
<ul>
<li><a href="http://eprint.iacr.org/2004/199">Collisions for Hash Functions MD4, MD5, HAVAL-128 and RIPEMD</a> : 発端となった論文。この中で SHA-0 も攻略可能であることが示されている</li>
</ul>
<p>その後の研究で SHA-1 も攻略可能であることが分かってきて暗号技術の周辺は大騒動になった。</p>
<ul>
<li><a href="https://www.schneier.com/blog/archives/2005/02/sha1_broken.html">SHA-1 Broken - Schneier on Security</a></li>
<li><a href="http://www.atmarkit.co.jp/ait/articles/0603/09/news117.html">デファクトスタンダード暗号技術の大移行(1):すべてはここから始まった~SHA-1の脆弱化 (1/2) - @IT</a></li>
</ul>
<h3>Hash 値の衝突問題</h3>
<p>暗号技術における hash 関数とは,以下の機能を持ったアルゴリズムである</p>
<ol>
<li>任意のデータ列を一定の長さのデータ列(hash 値)に「要約」する</li>
<li>Hash 値から元のデータ列を推測できない</li>
<li>ひとつの hash 値に対して複数のデータ列が(実時間で)見つからない</li>
</ol>
<p>Hash 関数はメッセージ認証符号(Message Authentication Code; MAC)や電子署名(digital signature)の中核技術のひとつであり,データの「完全性(Integrity)」を担保する重要な要素である。
特に3番目の「ひとつの hash 値に対して複数のデータ列が(実時間で)見つからない」という機能が破られると,その hash 関数では完全性を担保できなくなってしまう。
これを「Hash 値の衝突問題」という。</p>
<p>よくできた hash 関数であれば, hash 値のビット長を $n$ とすると,衝突の確率は $1 / 2^{\frac{n}{2}}$ であると言われている。
SHA-1 の hash 値の長さは $160\,\mathrm{bits}$ なので,衝突の確率は $1 / 2^{80}$ になるはずだが,実際にはそれよりもずっと大きい $1 / 2^{69}$ で可能,というのが当時の問題だった。</p>
<h3>2010年問題</h3>
<p>これを受けて, SHA-1 を2010年までに廃止し SHA-2 (SHA-224/256/364/512) に移行する措置がとられた。
これが暗号技術における「2010年問題」である<sup id="fnref:1"><a href="#fn:1" class="footnote-ref" role="doc-noteref">1</a></sup>。</p>
<p>ただ,現状では(特に legacy system において)アルゴリズムの置き換えがなかなか進まなかったことと SHA-1 の攻略があまり進展しなかったことにより,この期限は2013年まで延長された。
現在の SHA アルゴリズムの評価と有効期限は以下のとおり。</p>
<p><figure lang='en'>
<style>
main table.nist3 th {
vertical-align:middle;
text-align: center;
}
main table.nist3 td {
text-align: center;
}
</style>
<table class="nist3">
<thead>
<tr>
<th>Security <br>Strength</th>
<th>Digital Signatures and Other<br>Applications Requiring Collision<br>Resistance</th>
<th>HMAC, KMAC,<br>Key Derivation Functions,<br>Random Bit Generation</th>
</tr>
</thead>
<tbody>
<tr>
<td> $\le 8$0</td>
<td>SHA-1</td>
<td> </td>
</tr><tr>
<td>$112$</td>
<td>SHA-224, SHA-512/224, SHA3-224</td>
<td> </td>
</tr><tr>
<td>$128$</td>
<td>SHA-256, SHA-512/256, SHA3-256</td>
<td>SHA-1, KMAC128</td>
</tr><tr>
<td>$192$</td>
<td>SHA-384, SHA3-384</td>
<td>SHA-224, SHA-512/224, SHA3-224</td>
</tr><tr>
<td>$\ge 256$</td>
<td>SHA-512, SHA3-512</td>
<td>SHA-256, SHA-512/256, SHA-384, SHA-512, SHA3-256, SHA3-384, SHA3-512, KMAC256</td>
</tr>
</tbody>
</table>
<figcaption><div>Maximum security strengths for hash and hash-based functions (via <q><a href='https://doi.org/10.6028/NIST.SP.800-57pt1r5'>SP 800-57 Part 1 Revision 5 <sup><i class='far fa-file-pdf'></i></sup></a></q> 5.6.1.2)</div></figcaption>
</figure> <!-- 要 MathJax -->
<figure lang='en'>
<style>
main table.nist4 th {
vertical-align:middle;
text-align: center;
}
main table.nist4 td {
vertical-align:middle;
text-align: center;
}
</style>
<table class="nist4">
<thead>
<tr>
<th colspan='2'>Security Strength</th>
<th>Through<br> 2030</th>
<th>2031 and<br> Beyond</th>
</tr>
</thead>
<tbody>
<tr><td rowspan='2'>$\lt 112$</td><td>Applying</td> <td colspan='2'>Disallowed</td></tr>
<tr> <td>Processing</td> <td colspan='2'>Legacy use</td></tr>
<tr><td rowspan='2'>$112$</td> <td>Applying</td> <td rowspan='2'>Acceptable</td><td>Disallowed</td></tr>
<tr> <td>Processing</td> <td>Legacy use</td></tr>
<tr><td>$128$</td> <td rowspan='3'>Applying/Processing</td><td>Acceptable</td><td>Acceptable</td></tr>
<tr><td>$192$</td> <td>Acceptable</td><td>Acceptable</td></tr>
<tr><td>$256$</td> <td>Acceptable</td><td>Acceptable</td></tr>
</tbody>
</table>
<figcaption><div>Security-strength time frames (via <q><a href='https://doi.org/10.6028/NIST.SP.800-57pt1r5'>SP 800-57 Part 1 Revision 5 <sup><i class='far fa-file-pdf'></i></sup></a></q> 5.6.3)</div></figcaption>
</figure> <!-- 要 MathJax --></p>
<p>しかし現状は全くスケジュールどおりではなく, SHA-1 を使った証明書の発行が停止され始めたのはようやく昨年末頃からだ。
一方,主要ブラウザは2017年以降 SHA-1 を使った証明書を無効にする計画を発表している。</p>
<h2>SHA-1 Freestart Collision</h2>
<p>ところが最近になって SHA-1 の攻略について進展があった。</p>
<ul>
<li><a href="https://sites.google.com/site/itstheshappening/">The Shappening: freestart collisions for SHA-1</a></li>
<li><a href="https://www.schneier.com/blog/archives/2015/10/sha-1_freestart.html">SHA-1 Freestart Collision - Schneier on Security</a></li>
<li><a href="http://arstechnica.com/security/2015/10/sha1-crypto-algorithm-securing-internet-could-break-by-years-end/">SHA1 algorithm securing e-commerce and software could break by year’s end | Ars Technica</a></li>
<li><a href="http://www.itmedia.co.jp/enterprise/articles/1510/09/news054.html">「SHA-1の廃止前倒しを」 専門家チームが提言 - ITmedia エンタープライズ</a></li>
</ul>
<p>これは SHA-1 のアルゴリズム上の更なる危殆化を指すものではないが,最新の計算リソースを効率的に使って,いわば「力任せ」(って言うと御幣があるけど)で攻略している。
GPU をふんだんに使った専用ハードウェアやクラウド・サービスなどを組み合わせることにより,近い将来に実用的なコストで SHA-1 攻略が可能になると指摘されている。</p>
<figure lang="en">
<blockquote>
<q>Concretely, we estimate the SHA-1 collision cost today (i.e., Fall 2015) between 75K\$ and 120K\$ renting Amazon EC2 cloud computing over a few months. By contrast, security expert Bruce Schneier previously projected (based on calculations from Jesse Walker) the SHA-1 collision cost to be ~173K\$ by 2018. Note that he deems this to be within the resources of a criminal syndicate. Large corporations and governments may possess even greater resources and may not require Amazon EC2.</q>
</blockquote>
<figcaption><div>via <q><a href="https://sites.google.com/site/itstheshappening/">The Shappening: freestart collisions for SHA-1</a></q></div></figcaption>
</figure>
<p>Mozilla では SHA-1 を使った証明書の無効化を2016年7月以降に前倒しすることを検討している。</p>
<ul>
<li><a href="https://blog.mozilla.org/security/2015/10/20/continuing-to-phase-out-sha-1-certificates/">Continuing to Phase Out SHA-1 Certificates | Mozilla Security Blog</a></li>
<li><a href="http://news.mynavi.jp/news/2015/10/22/093/">Firefox、SHA-1対策を前倒し検討 | マイナビニュース</a></li>
</ul>
<p>GPU ベースのシステムやクラウド・サービス等による巨大計算リソースを使った攻撃は,指摘はありつつも,あまり重視されていなかった。
しかし,今回の例に見るように,攻撃手法として現実的な脅威になりつつある。
状況によっては SHA-1 以外でもセキュリティ・リスクの見直しを迫られるかもしれない。</p>
<h2>関連記事</h2>
<ul>
<li><a href="https://baldanders.info/blog/000048/">ハッシュ値の衝突問題 – 戯れ言++</a></li>
<li><a href="https://baldanders.info/blog/000204/">暗号の危殆化と新しいアルゴリズム – 戯れ言++</a></li>
<li><a href="https://baldanders.info/blog/000210/">「安全な鍵長の下限」とは – 戯れ言++</a></li>
<li><a href="https://baldanders.info/blog/000267/">“NIST’s Plan for New Cryptographic Hash Functions” — Baldanders.info</a></li>
<li><a href="https://baldanders.info/blog/000586/">『暗号をめぐる最近の話題』 — Baldanders.info</a></li>
<li><a href="https://baldanders.info/blog/000865/">SHA-3 が正式リリース: あれから10年も… — Baldanders.info</a></li>
<li><a href="http://blog.livedoor.jp/k_urushima/archives/1768181.html">自堕落な技術者の日記 : 「RFC 7525 TLSとDTLSの安全な利用に関する推奨事項」の公開 - livedoor Blog(ブログ)</a></li>
<li><a href="http://japan.cnet.com/news/service/35067422/">「Y!mobileケータイ」で一部サイトへ接続不能に–サーバ証明書の切り替えで - CNET Japan</a></li>
<li><a href="https://blog.visvirial.com/articles/519">scryptがGPUに破られる時 | びりあるの研究ノート</a> : GPU 耐性が高いと言われる scrypt も実時間で攻略できるようになってきたという話</li>
<li><a href="http://blog.livedoor.jp/k_urushima/archives/1782546.html">自堕落な技術者の日記 : SSL Pulseの統計情報で見るSSL/TLS (2015年10月版) - livedoor Blog(ブログ)</a> : Alexa 社によるアクセス世界トップ20万サイトを対象にした SSL/TLS 関連の統計情報</li>
<li><a href="http://blogs.technet.com/b/jpsecurity/archive/2015/11/02/faq-microsoft-policy-on-sha1-deprecation.aspx">FAQ: SHA-1 廃止/SHA-2 移行に関するマイクロソフトのポリシー - 日本のセキュリティチーム</a></li>
<li><a href="http://japan.zdnet.com/article/35072827/">「SHA-1」SSLサーバ証明書の廃止迫る–「SHA-2」への移行状況とその影響、課題 - ZDNet Japan</a></li>
<li><a href="http://www.cryptrec.go.jp/topics/cryptrec_20151218_sha1_cryptanalysis.html">CRYPTREC | SHA-1の安全性について</a>
<ul>
<li><span><a href="http://www.cryptrec.go.jp/report/c13_tech_guideline_SHA-1_web.pdf">CRYPTREC暗号技術ガイドライン(SHA-1) <sup><i class="far fa-file-pdf"></i></sup></a></span></li>
</ul>
</li>
<li><a href="http://blogs.technet.com/b/jpsecurity/archive/2016/02/08/sha1-deprecation-tls.aspx">[IT 管理者向け] 残っていませんか? SSL/TLS 証明書の SHA-1 廃止はもうすぐ - 日本のセキュリティチーム - Site Home - TechNet Blogs</a></li>
<li><a href="https://blogs.technet.microsoft.com/jpsecurity/2016/11/25/sha1countdown/">SHA-1 ウェブサーバー証明書は 2017 年2月から警告!ウェブサイト管理者は影響の最終確認を – 日本のセキュリティチーム</a></li>
<li><a href="http://forest.watch.impress.co.jp/docs/serial/yajiuma/1041798.html">「Google Chrome」の閲覧画面にエラーが! ~“https://”のサイトにアクセスできない - やじうまの杜 - 窓の杜</a></li>
<li><a href="https://text.baldanders.info/remark/2017/02/sha-1-collision/">最初の SHA-1 衝突例</a></li>
</ul>
<h2>関連図書</h2>
<div class="hreview">
<div class="photo"><a href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1"><img src="https://m.media-amazon.com/images/I/51t6yHHVwEL._SL160_.jpg" width="113" alt="photo"></a></div>
<dl>
<dt class="item"><a class="fn url" href="https://www.amazon.co.jp/dp/B015643CPE?tag=baldandersinf-22&linkCode=ogi&th=1&psc=1">暗号技術入門 第3版 秘密の国のアリス</a></dt>
<dd>結城 浩 (著)</dd>
<dd>SBクリエイティブ 2015-08-25 (Release 2015-09-17)</dd>
<dd>Kindle版</dd>
<dd>B015643CPE (ASIN)</dd>
<dd>評価<abbr class="rating fa-sm" title="5"> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i> <i class="fas fa-star"></i></abbr></dd>
</dl>
<p class="description">SHA-3 や Bitcoin/Blockchain など新しい知見や技術要素を大幅追加。暗号技術を使うだけならこれ1冊でとりあえず無問題。</p>
<p class="powered-by">reviewed by <a href='#maker' class='reviewer'>Spiegel</a> on <abbr class="dtreviewed" title="2015-09-20">2015-09-20</abbr> (powered by <a href="https://affiliate.amazon.co.jp/assoc_credentials/home">PA-APIv5</a>)</p>
</div> <!-- 暗号技術入門 第3版 -->
<div class="footnotes" role="doc-endnotes">
<hr>
<ol>
<li id="fn:1">
<p>他にも $1024\,\mathrm{bits}$ 以下の鍵長の RSA 公開鍵を廃止する,などの措置が盛り込まれていた。 <a href="#fnref:1" class="footnote-backref" role="doc-backlink">↩︎</a></p>
</li>
</ol>
</div>