-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
318 lines (243 loc) · 11.5 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
<!DOCTYPE html>
<html lang="zh-TW">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>GPG 金钥原理与实践</title>
<!-- <link rel="stylesheet" href="css/reset.css"> -->
<link rel="stylesheet" href="css/reveal.css">
<link rel="stylesheet" href="css/theme/wx.css" id="theme">
<!-- Theme used for syntax highlighting of code -->
<link rel="stylesheet" href="lib/css/zenburn.css">
</head>
<body>
<div class="reveal">
<div class="slides">
<section data-markdown>
# GPG 金钥原理与实践
License: [*GPL v2*](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
Github: [*junyussh/GPG-introduction*](https://github.com/junyussh/GPG-introduction.git)
</section>
<section data-markdown>
## 你可能会问:
---
- 什么是 GPG?
- 为什么我们需要 GPG?
</section>
<section data-markdown>
## 什么是 GPG
全名为 [GNU Privacy Guard (GnuPG)](https://gnupg.org/),于 1997 年自由软体基金会以 GPL 协议释出的开源免费加、解密工具,兼容 OpenPGP 标准。
</section>
<section data-markdown>
## 概念
1. 公钥加密
2. 数字签名
3. 信任网路
4. 安全边界
</section>
<section data-markdown>
### 公钥加密
---
- 密钥与公钥
- 公钥不能得出密钥
- 发出讯息者以接收讯息者的公钥将讯息加密
- 接收者以自己的密钥解密
- **密钥必须保持秘密**
千万不要将你的密钥在网路上传输,另外别在 telnet 上使用 GnuPG
</section>
<section data-markdown>
### 数字签名
---
概念:证明一则讯息确实是宣称发出讯息的人所发。
得到讯息者可以确认:讯息来自该发出讯息者,而且在传递过程中其内容没有改变
- 一个数字签名是通过密钥和讯息本身而得来
- 讯息可以通过发出讯息者的公钥来验证
</section>
<section data-markdown>
### 信任网络
---
简介:信任网络是密码学中的一个概念,可以用来验证一个公钥的持有者身份。
- 为了解决可能的虚假身份入侵,GnuPG 通过对公共钥匙签名来分辨。当你信任给这把钥匙签名的人时,你认为这把钥匙是可信的,并确信这把钥匙确实属于拥有相应用户身份的人。
- 信任网的要点是“不依赖认证机构,而是建立每个人之间的信任关系”。换言之,就是能够自己决定要信任哪些公钥。
</section>
<section data-markdown>
### 安全边界
---
简介:边界防护的安全理念,边界防护技术等。
- 如果你有数据想要保密,你所需做的远不止选择加密算法这一件事。你应该统筹考虑你的系统安全。
- 此时使用 PGP 是很好的选择,一般我们认为 PGP 是安全的。但 PGP 也并不能做到完全“无法破译”。
</section>
<section data-markdown>
## 安装
GPG 是跨平台开源的免费软件,接下来教大家如何在各种操作系统安装 GPG。
</section>
<section data-markdown>
### MacOS
在 Mac 上可以直接利用 homebrew 安装 GPG 套件。
```bash
$ brew install gpg
```
---
### Windows
如果你在安装 Git 时选择 Git bash,那里面就有内建 GnuPG 工具了,或是去 [GPG 官网](https://gnupg.org/download/index.html)下载安装包。
</section>
<section data-markdown>
### Linux
有些发行版会内建 GPG 工具来验证安装套件,你可以在终端机输入 `gpg` 检查是否已安装 GPG 工具。
#### Red Hat / CentOS
```bash
$ sudo yum install gnupg
```
#### Ubuntu / Debian
```bash
$ sudo apt-get install gnupg2
```
#### Arch Linux
```bash
$ sudo pacman -S gnupg
```
</section>
<section data-markdown>
## 使用
以下介绍 GPG 核心功能的使用
- 金钥产生
- 加解密讯息
- 数位签证
</section>
<section data-markdown>
### 产生一组金钥
---
此动作会分别产生公钥及私钥(密钥)。
```bash=
$ gpg --gen-key
```
</section>
<section data-markdown>
### 管理金钥
---
列出此电脑目前保存的公钥,Key ID 为 fingerprint 末 8 位,可用 `gpg --list-keys` 指令查看,后文以 `keyid` 代称。
```bash=
$ gpg --list-keys # 显示保存的公钥
$ gpg --fingerprint # 列出金钥及其指纹
$ gpg -K # 显示已保存的密钥
```
</section>
<section data-markdown>
### 撤销凭证
---
建议产生完金钥就去建立一张撤销凭证,当金钥不被信任时可以利用这张去撤销你的金钥,产生的 `revoke.asc` 请像密钥一样妥善保管。
```bash=
$ gpg --gen-revoke -o revoke.asc keyid # keyid 记得替换成自己的
```
</section>
<section data-markdown>
### 公钥服务器
---
如果收件人把公钥上传到金钥服务器,可以直接在服务器上搜寻。
```bash
$ gpg --search-keys [email protected] # 用 Email 搜寻
$ gpg --send-keys 24AB50C1 # 把自己的公钥传到金钥服务器
```
</section>
<section data-markdown>
### 加密讯息
---
用户可以用自己的公钥加密重要文件,而**只能透过用户自己的密钥解密**,加密完后会产生一个 `test.txt.gpg` 文件。
```bash=
$ gpg -e test.txt # 将 test.txt 加密
$ gpg -r keyid -e test.txt # -r 参数指定使用者的公钥
```
</section>
<section data-markdown>
### 解密
---
输入用户密钥后输出解密结果,不加 `-o` 指定输出文件会默认在终端机内显示解密结果。
```bash=
$ gpg -d test.txt.gpg
$ gpg -r keyid -d test.txt.gpg # 指定要解密的用户身份
$ gpg -o decrypt.txt -r keyid -d test.txt.gpg # 将解密内容写入到 decrypt.txt
```
</section>
<section data-markdown>
### 加解密流程
---
![GPG 加解密流程](./img/gpgprocess.jpg)
</section>
<section data-markdown>
### 数字签名
---
当寄件者向你发送文件,可以利用寄件者公钥验证是否为寄件者本人所寄,签名产生使用用户密钥加密。
主要分为两种签证方式:文本签名和分离式签名,文本签名会将签名资讯写入文件中,分离式签名则将签名资讯独立成一个文件。
```bash
$ gpg --clearsign test.txt # 文本签名产生 test.txt.asc
$ gpg -o test.sig -ab test.txt # 分离式签名
$ gpg -u F0C17F5F -o test.sig -ab test.txt # 指定私钥签章
$ gpg --verify test.sig test.txt # 验证签名
```
</section>
<section data-markdown>
## Demo Time
讲了这么多,我想大家可能还是不明白 GPG 的用法,不如带亲身体验一下 GPG 的强大之处。
</section>
<section data-markdown>
## Questions?
如果没有就结束了喔。
</section>
<section data-markdown>
## End
This slide is released in [*GPL v2 License*](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html), you can view the source code on
[Github](https://github.com/junyussh/GPG-introduction).
The presentation is powered by [*Reveal.js*](https://revealjs.com/).
---
### Reference
- [玩具乌托邦: 使用 GnuPG 建立你的 PGP 金钥,让别人能够私密寄信给你](https://newtoypia.blogspot.com/2013/12/gnupg-pgp.html)
- [GPG 官方引导文件(中文版)](https://gnupg.org/howtos/zh/index.html)
- [GPG(pgp)加解密中文完整教程 | Alex's Station](http://www.alexgao.com/2009/01/24/gpg/)
</section>
</div>
</div>
<script src="./lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>
<script>
// More info https://github.com/hakimel/reveal.js#configuration
Reveal.initialize({
controls: true,
progress: true,
center: true,
hash: true,
transition: 'slide', // none/fade/slide/convex/concave/zoom
// More info https://github.com/hakimel/reveal.js#dependencies
dependencies: [{
src: 'plugin/markdown/marked.js',
condition: function () {
return !!document.querySelector('[data-markdown]');
}
},
{
src: 'plugin/markdown/markdown.js',
condition: function () {
return !!document.querySelector('[data-markdown]');
}
},
{
src: 'plugin/highlight/highlight.js',
async: true
},
{
src: 'plugin/search/search.js',
async: true
},
{
src: 'plugin/zoom-js/zoom.js',
async: true
},
{
src: 'plugin/notes/notes.js',
async: true
}
]
});
</script>
</body>
</html>