(122) PGP公開鍵を相手に渡す。

投稿者: | 2021年1月25日

688 views

この記事は最終更新から 1178日 が経過しています。

1. やりたいこと

取引相手の方から
資料を送りたいのでPGP公開鍵をちょうだい。
と言われた。

で…
早速作ってみた。

2. やってみる

PGP公開鍵の生成を Ubuntu上の GnuPG で実行してみた。

https://gnupg.org/

この Ubuntuマシンは、以下の記事で作ったものだ。
(103) Intel NUCを Subversionサーバーにする。 【採用決定】

(1) gpgをインストール

user@intel-nuc:~$ sudo apt install gpg
[sudo] password for user:
Reading package lists... Done
Building dependency tree
Reading state information... Done
gpg is already the newest version (2.2.4-1ubuntu1.3).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
user@intel-nuc:~$

すでにインストールされていた。

(2) 鍵を生成

鍵の有効期限などを設定したいので –full-gen-key オプションを指定する。

user@intel-nuc:~$ gpg --full-gen-key
gpg (GnuPG) 2.2.4; Copyright (C) 2017 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

鍵種別は RSA and RSA を指定した。

Please select what kind of key you want:
   (1) RSA and RSA (default)
   (2) DSA and Elgamal
   (3) DSA (sign only)
   (4) RSA (sign only)
Your selection? 1

鍵長は 2048[bits] を指定した。

RSA keys may be between 1024 and 4096 bits long.
What keysize do you want? (3072) 2048
Requested keysize is 2048 bits

有効期間は、今から 20日間 を指定した。

Please specify how long the key should be valid.
         0 = key does not expire
        = key expires in n days
      w = key expires in n weeks
      m = key expires in n months
      y = key expires in n years
Key is valid for? (0) 20
Key expires at Sun 14 Feb 2021 11:57:10 AM JST

これで生成を開始!

Is this correct? (y/N) y

暗号鍵の生成が開始されたが、乱数シードを与えよとのこと。

We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.

キーボード上で適当にキーを押し続ける。

ssfe$536'3r65eroioierogerg;l,;vsopkpefokpokkpPpokrgr_\/sf.@wepl3\l,wef;l,p3rofpeosf,mkgreg
pokpowkefpok3kr0kfpokpowekfpokp3ro2kpowfekpwokefpokpok)#")%pfokwpefok
pokpokpokpokp8998989)()#"(RJkfwefoiej
oioivweoijoi3rjoijo)(UR)#"joifejowef
vdoiwoifjowi3jfijoi....+++..++++
;oirgjior
('RH#(7hiufwjoiwjefo
od,bpodrk,p
)(Rjoifweoifjweofiw
rgp,oerk,gp
PFOWEKPEWOKFpo32rkpokrp84984
POFKQPfw[[@;[@;wef

上でご紹介した Celeron搭載の Intel NUC環境ではなかなかキーの生成が完了せず…

(3) 公開鍵ファイルを出力

後日追記

3. 実際に使ってみる

(1) 受信した資料を複合化する。

後日追記

(2) 送信する資料を暗号化する。

後日追記

.

4. 所感

後日追記
・ちなみに Thunderbird ならもっと簡単にできる。手順は以下の通り。
 1) ハンバーガーメニューを押す。
 2) [ツール]-[OpenPGP 鍵マネージャー] メニューを選択する。
 3) [生成]-[新しい鍵ペア] メニューを選択する。
 後は画面の指示に従えばよい。

5. 謝辞

有用な情報をありがとうございます。m(_ _)m
https://qiita.com/umi/items/2074aac509a6e78c4ef4
https://qiita.com/kanatatsu64/items/c6f612b34ec69809fbb6
https://zenn.dev/spiegel/articles/20200920-gnupg-cheat-sheet


コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です