gpgã§ã®ãã¡ã¤ã«ã®æå·ååºç¤
ãªããªãSICPã«æãä»ããããªã®ã§ãä»äºã§å§ãã¦è§¦ã£ãGPGã®ã³ãã³ãã©ã¤ã³ä¸ã§ã®æå·å復å·åã«ã¤ãã¦ã¡ã¢ã£ã¦ãããã¨æãã
GPGã¨ã¯ãWikipediaã«ããã¨
GNU Privacy Guard (GnuPG) ã¨ã¯ãPretty Good Privacy (PGP) ã®å¥å®è£ ã¨ãã¦ãGPL ã«åºã¥ããæå·åã½ããã§ããã OpenPGP è¦æ ¼ (RFC4880) ã«å®å ¨æºæ ãã¦ããããå¤ã PGP ã¨ã®äºææ§ã¯å®å ¨ã§ã¯ãªãã
ã¨ãããã¨ãããã
èªèã§ã¯ãå
¬ééµæå·æ¹å¼ã§ãã¡ã¤ã«ãæå·åãããã®ã¨æã£ã¦ãã
éä¿¡ç³»ã«ã使ããã¦ãã®ããªï¼
ä»å使ããã¼ã¸ã§ã³ã¯ãããªæãã
$ gpg --version gpg (GnuPG) 1.4.11 Copyright (C) 2010 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Home: ~/.gnupg ãµãã¼ããã¦ããã¢ã«ã´ãªãºã : å ¬ééµ: RSA, RSA-E, RSA-S, ELG-E, DSA æå·æ³: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, CAMELLIA192, CAMELLIA256 ããã·ã¥: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 å§ç¸®: ç¡å§ç¸®, ZIP, ZLIB, BZIP2
ãããã£ã¦è¦ãã¨ããã£ã¨è²ã ãªãã¨ã«ä½¿ãããã ãããªãã
ä»æ¥ã®ã¡ã¢ã®æµããããªæãã
ããã¾ã詳ããã¯ããããªãã®ã§ã
ããã次第ã追è¨ãæ°ããè¨äºãæ¸ããã¨ã«ãããã
1. éµãã¢ãä½æ
2. ç¸æã«å
¬ééµã渡ã
3. ç¸æãå
¬ééµã§æå·å
4. éããã¦ããæå·åãã¼ã¿ãç§å¯éµã§å¾©å·å
ã¡ãªã¿ã«èªåã¯ãããããã¾ã§ãç§å¯éµã§æå·åãã¦å ¬ééµã§å¾©å·åãããã®ã ã¨æã£ã¦ã...
ã¤ã³ã¹ãã¼ã«
MacOSã§ã®ã¤ã³ã¹ãã¼ã«ã¯homebrewã使ã£ã¦ããã£ã¨ããã¾ããã
$ brew search gnupg gnupg gnupg2 $ sudo brew install gnupg
2å°æ¬²ããã®ã§ãããä¸å°ã¯Ubuntuããã§ãã
ãã£ã¡ã¯å
¥ããè¨æ¶ããªãã®ã«æåããå
¥ã£ã¦ãã
$ sudo apt-get install gnupg ããã±ã¼ã¸ãªã¹ããèªã¿è¾¼ãã§ãã¾ã... å®äº ä¾åé¢ä¿ããªã¼ãä½æãã¦ãã¾ã ç¶æ æ å ±ãèªã¿åã£ã¦ãã¾ã... å®äº gnupg ã¯ãã§ã«ææ°ãã¼ã¸ã§ã³ã§ãã
1. éµãã¢ãä½æ
ä»åã¯Macã§éµãã¢ãä½ã£ã¦ãå
¬ééµãUbuntuããã«æ¸¡ãã¾ãã
ã§ã¯éµãã¢ãæ©éã
éµãã¢ã¯--gen-keyã³ãã³ãã使ç¨ãã¦ä½æã§ãã¾ã
$ gpg --gen-key gpg (GnuPG) 1.4.11; Copyright (C) 2010 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. ãå¸æã®éµã®ç¨®é¡ãé¸æãã¦ãã ãã: (1) RSA and RSA (default) (2) DSA and Elgamal (3) DSA (ç½²åã®ã¿) (4) RSA (ç½²åã®ã¿) é¸æã¯?
ä»åã¯2çªãé¸æãã¾ãã
é¸æã¯? 2 DSA keys may be between 1024 and 3072 bits long. What keysize do you want? (2048)
1024ã§ä½æãã¾ãã
DSA keys may be between 1024 and 3072 bits long. What keysize do you want? (2048) 1024 è¦æ±ãããéµé·ã¯1024ããã éµã®æå¹æéãæå®ãã¦ãã ããã 0 = éµã¯ç¡æé <n> = éµã¯ n æ¥éã§æºäº <n>w = éµã¯ n é±éã§æºäº <n>m = éµã¯ n ãæéã§æºäº <n>y = éµã¯ n å¹´éã§æºäº éµã®æå¹æéã¯? (0)
æå¹æéã¯åãæ¢ããç¡å¶éã§è¡ãã
ãããªæå¹æéã§å¤§ä¸å¤«ãï¼ã¨èãããã®ã§yesã¨çãã
éµã®æå¹æéã¯? (0)0 Key does not expire at all ããã§æ£ããã§ãã? (y/N) y ããªãã®éµãåå®ããããã«ã¦ã¼ã¶ã¼IDãå¿ è¦ã§ãã ãã®ã½ããã¯æ¬åãã³ã¡ã³ããé»åã¡ã¼ã«ã»ã¢ãã¬ã¹ãã 次ã®æ¸å¼ã§ã¦ã¼ã¶ã¼IDãæ§æãã¾ã: "Heinrich Heine (Der Dichter) <[email protected]>" æ¬å: akihiro_ob é»åã¡ã¼ã«ã»ã¢ãã¬ã¹: [email protected] ã³ã¡ã³ã: for test 次ã®ã¦ã¼ã¶ã¼IDãé¸æãã¾ãã: âakihiro_ob (for test) <[email protected]>â åå(N)ãã³ã¡ã³ã(C)ãé»åã¡ã¼ã«(E)ã®å¤æ´ãã¾ãã¯OK(O)ãçµäº(Q)?
gpgã®äººãè¨ã£ã¦ãããããã§èãããæ¬åãéµã®ã¦ã¼ã¶IDã«ãªãã
ä»å¾ãéµãåé¤ãããããã®ã«ä½¿ç¨ãããã¨ã«ãªãã
OKãªã®ã§O(大æåã®ãªã¼)ãå
¥åãã
åå(N)ãã³ã¡ã³ã(C)ãé»åã¡ã¼ã«(E)ã®å¤æ´ãã¾ãã¯OK(O)ãçµäº(Q)? O ç§å¯éµãä¿è·ããããã«ãã¹ãã¬ã¼ãºãããã¾ãã ãã¹ãã¬ã¼ãºãå ¥å:
ãããå¦çãªã©ã§ä½¿ç¨ããå ´åã«ã¯ãã¹ãã¬ã¼ãºãå
¥ããªããã¨ãããã¿ããã
ä»åããããã«ãããªãã®ã§ãã¹ãã¬ã¼ãºã¯å
¥ããªãã§ãã ã¨ã³ã¿ã¼ãæ¼ãã
ãã¹ãã¬ã¼ãºãä¸å¿ è¦ãªããã§ãããããããããã¯ããã§ããªã èãã§ã! ãã¡ããç¶è¡ãã¾ãããã¹ãã¬ã¼ãºã¯ããã®ããã°ã©ã ã®â--edit-keyâãªãã·ã§ã³ã§ãã¤ã§ãå¤æ´ã§ãã¾ãã ä»ããé·ãä¹±æ°ãçæãã¾ãããã¼ãã¼ããæã¤ã¨ãããã¦ã¹ãåãã ã¨ãããã£ã¹ã¯ã«ã¢ã¯ã»ã¹ããã¨ãã®ä»ã®ãã¨ãããã¨ãä¹±æ°çæå㧠乱éãã®å¤§ããªããä¹±æ°ãçæãããããªãã®ã§ããå§ããããã¾ãã .+++++++++++++++++++++++++++++++++++.++++++++++++++++++++.+++++++++++++++++++++++++.+++++++++++++++++++++++++++++++++++.+++++++++++++++>++++++++++>+++++.............>.+++++....<+++++...............................+++++ ä»ããé·ãä¹±æ°ãçæãã¾ãããã¼ãã¼ããæã¤ã¨ãããã¦ã¹ãåãã ã¨ãããã£ã¹ã¯ã«ã¢ã¯ã»ã¹ããã¨ãã®ä»ã®ãã¨ãããã¨ãä¹±æ°çæå㧠乱éãã®å¤§ããªããä¹±æ°ãçæãããããªãã®ã§ããå§ããããã¾ãã +++++++++++++++.+++++.+++++++++++++++++++++++++++++++++++.++++++++++.+++++..++++++++++++++++++++++++++++++.+++++..++++++++++.+++++++++++++++................>++++++++++^^^ gpg: /Users/akihiro_ob/.gnupg/trustdb.gpg: ä¿¡ç¨ãã¼ã¿ãã¼ã¹ãã§ãã¾ãã gpg: éµA2A4EF37ã絶対çã«ä¿¡ç¨ããããè¨é²ãã¾ãã å ¬ééµã¨ç§å¯éµãä½æããç½²åãã¾ããã gpg: ä¿¡ç¨ãã¼ã¿ãã¼ã¹ã®æ¤æ» gpg: æå°ã®ãããç¨åº¦ã®ä¿¡ç¨ã3ãæå°ã®ãå ¨é¢çä¿¡ç¨ã1ãPGPä¿¡ç¨ã¢ãã« gpg: æ·±ã: 0 æå¹æ§: 1 ç½²å: 0 ä¿¡ç¨: 0-, 0q, 0n, 0m, 0f, 1u pub 1024D/A2A4EF37 2012-01-31 æç´ = CAD8 B6FB 2663 6103 8DBA 8A68 6BE5 3BC8 A2A4 EF37 uid akihiro_ob (for test) <[email protected]> sub 1024g/16B3F987 2012-01-31
ã²ã©ãè¨ããããã§å¿æ«ãããã«ãªã£ããã©ã
åãæ¢ããããã§éµãã¢ãå®æï¼
ä¸å¿ç¢ºèªããã¦ã¿ã
確èªã«ã¯--list-secret-keys(ç§å¯éµ)ã--list-keys(å
¬ééµ)ã³ãã³ãã使ç¨ãã
$ gpg --list-secret-keys /Users/akihiro_ob/.gnupg/secring.gpg ------------------------------------ sec 1024D/A2A4EF37 2012-01-31 uid akihiro_ob (for test) <[email protected]> ssb 1024g/16B3F987 2012-01-31
$ gpg --list-keys /Users/akihiro_ob/.gnupg/pubring.gpg ------------------------------------ pub 1024D/A2A4EF37 2012-01-31 uid akihiro_ob (for test) <[email protected]> sub 1024g/16B3F987 2012-01-31
ãããããåºæ¥ã¦ã¾ããã
2. ç¸æã«å ¬ééµã渡ã
ç¸æã«éµã渡ãããã«ãã¾ãexportããå¿ è¦ãããã
gpg [-a] [-o åºåãã¡ã¤ã«å] --export éµã¦ã¼ã¶ID $ gpg -o ./o_ob.pub --export akihiro_ob $ ls o_ob.pub o_ob.pub
- aã¯ASCIIã§ã®åºåããããã¡ã¼ã«ã§éã£ããããæã«ä½¿ãããããã
- oã¯åºåãã¡ã¤ã«åã®æå®ã ãã©ããªãã¤ã¬ã¯ã·ã§ã³ã§ä½æããäºãã§ããã£ã½ãã
ãã®æã¯-aãä»ããã®ãä¸è¬çèãã
$ gpg -a --export akihiro_ob > o_ob.pub
ã¡ãªã¿ã«ç§å¯éµã渡ãæã¯ããããªæãã
$ gpg -o o_ob.pri --export-secret-key akihiro_ob
ãªãã·ã§ã³ã¯åãã ãã
ãããç¸æã«éã£ã¦ãã£ã¦ãã¤ã³ãã¼ãããã
$ gpg --import o_ob.pub gpg: éµA2A4EF37: å ¬ééµâakihiro_ob (for test) <[email protected]>âãèªã¿è¾¼ã¿ã¾ãã gpg: å¦çæ°ã®åè¨: 1 gpg: èªè¾¼ã¿: 1
ã¡ãªã¿ã«ç§å¯éµãã¤ã³ãã¼ãããã¨ããåãããã ã
$ gpg --import o_ob.pri gpg: éµA2A4EF37: å ¬ééµâakihiro_ob (for test) <[email protected]>âãèªã¿è¾¼ã¿ã¾ãã gpg: å¦çæ°ã®åè¨: 1 gpg: èªè¾¼ã¿: 1 gpg: ç§å¯éµã®èªåºã: 1 gpg: ç§å¯éµã®èªè¾¼ã¿: 1
èªåã§å¤å¥ãã¦ããã¦ãã¿ããã
ãããããï¼
次ã«ãå
¬ééµãä¿¡ç¨ããã
ãããããªãã¨ãæå·åããã¨ãã«æ³¨æãããã
$ gpg --edit-key akihiro_ob gpg (GnuPG) 1.4.11; Copyright (C) 2010 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. pub 1024D/A2A4EF37 ä½æ: 2012-01-31 æºäº: ç¡æé å©ç¨æ³: SC ä¿¡ç¨: æªç¥ã® æå¹æ§: æªç¥ã® sub 1024g/16B3F987 ä½æ: 2012-01-31 æºäº: ç¡æé å©ç¨æ³: E [ unknown] (1). akihiro_ob (for test) <[email protected]> gpg>
ããã§å¯¾è©±å½¢å¼ã«ãªãã®ã§åãæ¢ããtrustã¨å
¥å
ãã®å¾ãä¿¡é ¼åº¦ãèãããã®ã§çµ¶å¯¾çã«ä¿¡é ¼ãããã¨ã«ãã
gpg> trust ä»ã®ã¦ã¼ã¶ã¼ã®éµãæ£ããæ¤è¨¼ããããã«ããã®ã¦ã¼ã¶ã¼ã®ä¿¡ç¨åº¦ã決ãã¦ãã ãã (ãã¹ãã¼ããè¦ãã¦ããã£ãããä»ããå¾ãæç´ãæ¤æ»ãããããªã©ãªã©) 1 = ç¥ããªããã¾ãã¯ä½ã¨ãè¨ããªã 2 = ä¿¡ç¨ã ãªã 3 = ããç¨åº¦ä¿¡ç¨ãã 4 = å®å ¨ã«ä¿¡ç¨ãã 5 = 絶対çã«ä¿¡ç¨ãã m = ã¡ã¼ã³ã»ã¡ãã¥ã¼ã«æ»ã ããªãã®æ±ºå®ã¯? 5 æ¬å½ã«ãã®éµã絶対çã«ä¿¡ç¨ãã¾ãã? (y/N) y pub 1024D/A2A4EF37 ä½æ: 2012-01-31 æºäº: ç¡æé å©ç¨æ³: SC ä¿¡ç¨: 絶対ç æå¹æ§: æªç¥ã® sub 1024g/16B3F987 ä½æ: 2012-01-31 æºäº: ç¡æé å©ç¨æ³: E [ unknown] (1). akihiro_ob (for test) <[email protected]> ããã°ã©ã ãåèµ·åããã¾ã§ã表示ãããéµã®æå¹æ§ã¯æ£ãããªããããããªãã ã¨ãããã¨ã念é ã«ããã¦ãã ããã gpg> quit
ä¿¡ç¨ã®æã絶対çã«ãªãã°OKã
çµããã°quitã§çµäºãã¦ãã ããã
ããã§ããã°è¨å®çãªãã®ãå®äºã
3. ç¸æãå ¬ééµã§æå·å
次ã«æå·åããã¾ãã
ãã®åã«ã¾ãæå·åãããã¡ã¤ã«ãä½æãã
$ echo "gpg test desu: o_ob" > test.txt
ã§ãããã¡ã¤ã«ã«å¯¾ãã¦gpgããã
gpg -e [-o åºåãã¡ã¤ã«å] [-r éµã¦ã¼ã¶ID] æå·åããããã¡ã¤ã« $ gpg -e -r akihiro_ob test.txt gpg: ä¿¡ç¨ãã¼ã¿ãã¼ã¹ã®æ¤æ» gpg: æå°ã®ãããç¨åº¦ã®ä¿¡ç¨ã3ãæå°ã®ãå ¨é¢çä¿¡ç¨ã1ãPGPä¿¡ç¨ã¢ãã« gpg: æ·±ã: 0 æå¹æ§: 1 ç½²å: 0 ä¿¡ç¨: 0-, 0q, 0n, 0m, 0f, 1u
- rãªãã·ã§ã³ã¯æå®ããªãã£ãã¢ã«ã¦ã³ãã®ãã®ã使ç¨ããã
ã§ããã¡ãã£ã¨è¨æ¶ãææ§ã
å
ã«ãè§ã«ããããã§ãã¡ã¤ã«ã®æå·åãåºæ¥ã¾ããã
ä¸å¿ãcatãã¦ã¿ãã
$ cat test.txt gpg test desu: o_ob $ cat test.txt.gpg ?D?U?n2?Į??^h?-?6y??ͻ6?F??e?<@?4-?Ϙ?UU?EP?#?Z2ބ@?䱬8?H???Ź???5p??9?????????o<QV*??_?ҝ$?? W????(:CY??^????>?2?p?H f??+-uKB?&UC?~?qCm?ÂxRd??Y ???*?? ?[??????',rd???
ãããå
¨ãããããï¼
ããã§æå·åã¯åºæ¥ã¾ããï¼
4. éããã¦ããæå·åãã¼ã¿ãç§å¯éµã§å¾©å·å
ã§ã¯ãåãåã£ãæå·åãã¡ã¤ã«ãæ©é復å·åãã¦ã¿ãã
gpg [-o ãã¡ã¤ã«å] [-r éµã¦ã¼ã¶ID] æå·åãã¡ã¤ã« $ gpg -o test.txt -r akihiro_ob -d test.txt.gpg gpg: 1024-ãããELG-Eéµ, ID 16B3F987, æ¥ä»2012-01-31ã«æå·åããã¾ãã âakihiro_ob (for test) <[email protected]>â
ãã£ããã¨å®äºã
ã¡ãªã¿ã«-dãªãã·ã§ã³ã¯æå·åãã¡ã¤ã«ã®æå®ç¨ã§ãã
çµæãè¦ã¦ã¿ãã¨ãã
$ cat test.txt
gpg test desu: o_ob
復å·åãã§ãã¦ãï¼
ããã§åç´ãªã²ã¨éãã®ãã¨ãåºæ¥ãã¯ãï¼
ã¡ã¢
ã·ã§ã«ã¹ã¯ãªããã§ãããã§åããã£ã¦æã¯ãããªæãã§ãã£ã¦ãã®ãã¡ã¢ã£ã¦ããããã
$ gpg --batch --no-tty --yes -o hukugouka -r akihiro_ob -d angouka
éµã®åé¤ã¯--delete-keysã¨--delete-secret-keysã§è¡ããã
gpg --delete-keys éµã¦ã¼ã¶ID gpg --delete-secret-keys éµã¦ã¼ã¶ID $ gpg --delete-keys akihiro_ob gpg (GnuPG) 1.4.11; Copyright (C) 2010 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. pub 1024D/A2A4EF37 2012-01-31 akihiro_ob (for test) <[email protected]> ãã®éµãéµè¼ªããåé¤ãã¾ãã? (y/N) y