GPG 101 簡單、沒意義教學 - 資安

Table of Contents

不知道這年頭還有沒有人使用 GPG [0] 不過就在剛剛寄信的時候

因為對方要求 所以還是使用了一下 順便簡單分享一下使用方式跟背後的含義



# 使用情境 #
今天當你需要寄送機密資料給對方時 會遇到的一個情境是 (其實是兩個問題)

- 如何證明這是你寄出去的 (不可否認)
- 如何避免其他人閱讀內容 (保密)



使用 GPG 是其中的一種方式來滿足上面兩個需求

GPG 使用非對稱密碼學[1] 分別產生 Public Key 跟 Private Key

特色是另一方就算拿到 PubKey (情感上) 沒辦法得到你手上的那把 Key

因此在加密上有一定的優點:內容可以透過 PubKey 加密 但僅有 PriKey 的人可以解開

這得到的結果就是可以盡可能公開你的 PubKey 給大家知道

有需要的人可以使用 PubKey 加密 將資料寄送給你 且確保只有你打得開

相反的 如果要驗證這是來自你的內容 就可以使用 PriKey *加密*

大家都可以拿到 PubKey 來驗證你的加密內容 而唯持有 PriKey 的人才能夠產生加密的內容



快速的指令介紹

gpg --gen-key generate a new GPG key-pair
gpg --list-keys list all public key
gpg --send-keys --keyserver pgp.mit.edu [key hash] send the GPG key to Key Server (e.g. gpg.mit.edu)
gpg --armor --detach-sign FILE sign the file via detech-sign
gpg --local-user USER --recipient RECIPIENT FILE sign by the USER's PriKey and encrypt by the RECIPIENT PubKey


[0]: https://zh.wikipedia.org/zh-tw/GnuPG
[1]: https://en.wikipedia.org/wiki/Public-key_cryptography

--

All Comments

Brianna avatarBrianna2020-11-01
以前有用GPG去簽git commit 後來懶就沒有繼續了XD