summaryrefslogtreecommitdiff
path: root/manual/html_node/OpenPGP-certificates.html
blob: c538fe86f47bdd828c9d14732a52d4d943424516 (plain)
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
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- This manual is last updated 4 March 2015 for version
3.5.3 of GnuTLS.

Copyright (C) 2001-2015 Free Software Foundation, Inc.\\
Copyright (C) 2001-2015 Nikos Mavrogiannopoulos

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled "GNU Free
Documentation License". -->
<!-- Created by GNU Texinfo 6.1, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GnuTLS 3.5.3: OpenPGP certificates</title>

<meta name="description" content="GnuTLS 3.5.3: OpenPGP certificates">
<meta name="keywords" content="GnuTLS 3.5.3: OpenPGP certificates">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Function-and-Data-Index.html#Function-and-Data-Index" rel="index" title="Function and Data Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Certificate-authentication.html#Certificate-authentication" rel="up" title="Certificate authentication">
<link href="Advanced-certificate-verification.html#Advanced-certificate-verification" rel="next" title="Advanced certificate verification">
<link href="Verification-using-PKCS11.html#Verification-using-PKCS11" rel="prev" title="Verification using PKCS11">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.indentedblock {margin-right: 0em}
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smalllisp {margin-left: 3.2em}
kbd {font-style: oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nolinebreak {white-space: nowrap}
span.roman {font-family: initial; font-weight: normal}
span.sansserif {font-family: sans-serif; font-weight: normal}
ul.no-bullet {list-style: none}
body { 
	margin: 2%;
	padding: 0 5%;
	background: #ffffff;
}
h1,h2,h3,h4,h5 {
    font-weight: bold;
    padding: 5px 5px 5px 5px;
    background-color: #c2e0ff;
    color: #336699;
}
h1 {
    padding: 2em 2em 2em 5%;
    color: white;
    background: #336699;
    text-align: center;
    letter-spacing: 3px;
}
h2 { text-decoration: underline; }
pre {
  margin: 0 5%;
  padding: 0.5em;
}
pre.example,pre.verbatim {
  padding-bottom: 1em;

  border: solid #c2e0ff;
  background: #f0faff;
  border-width: 1px 1px 1px 5px;
  margin: 1em auto;
  width: 90%;
}

div.node {
  margin: 0 -5% 0 -2%;
  padding: 0.5em 0.5em;
  margin-top: 0.5em;
  margin-bottom: 0.5em;
  font-weight: bold;
}
dd, li {
  padding-top: 0.1em;
  padding-bottom: 0.1em;
}
div.float {

  margin-bottom: 0.5em;
  text-align: center;
}

table {
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  border-spacing: 7px;
  width: 50%;
}

th {
  padding: 0;
  color: #336699;
  background-color: #c2e0ff;
  border: solid #000000;
  border-width: 0px;
  margin: 1em auto;
  text-align: center;
  margin-left:auto;
  margin-right:auto;
}

td {
  padding: 0;
  border: solid #000000;
  background-color: #f0faff;
  border-width: 0px;
  margin: 1em auto;
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  padding-left: 1em;
}

dl {
  text-align: left;
  margin-left:auto;
  margin-right:auto;
  width: 50%;

  padding-left: 1em;
  border: solid #c2e0ff;
  background: #f0faff;
  border-width: 5px 1px 1px 1px;
  margin: 1em auto;
}

-->
</style>


</head>

<body lang="en">
<a name="OpenPGP-certificates"></a>
<div class="header">
<p>
Next: <a href="Advanced-certificate-verification.html#Advanced-certificate-verification" accesskey="n" rel="next">Advanced certificate verification</a>, Previous: <a href="X_002e509-certificates.html#X_002e509-certificates" accesskey="p" rel="prev">X.509 certificates</a>, Up: <a href="Certificate-authentication.html#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Data-Index.html#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="OpenPGP-certificates-1"></a>
<h4 class="subsection">4.1.2 <acronym>OpenPGP</acronym> certificates</h4>
<a name="index-OpenPGP-certificates"></a>

<p>The <acronym>OpenPGP</acronym> key authentication relies on a distributed trust
model, called the &ldquo;web of trust&rdquo;. The &ldquo;web of trust&rdquo; uses a
decentralized system of trusted introducers, which are the same as a
CA. <acronym>OpenPGP</acronym> allows anyone to sign anyone else&rsquo;s public
key. When Alice signs Bob&rsquo;s key, she is introducing Bob&rsquo;s key to
anyone who trusts Alice. If someone trusts Alice to introduce keys,
then Alice is a trusted introducer in the mind of that observer.
For example in <a href="#fig_002dopenpgp">Figure 4.4</a>, David trusts Alice to be an introducer and Alice
signed Bob&rsquo;s key thus Dave trusts Bob&rsquo;s key to be the real one.
</p>
<div class="float"><a name="fig_002dopenpgp"></a>
<img src="gnutls-pgp.png" alt="gnutls-pgp">

<div class="float-caption"><p><strong>Figure 4.4: </strong>An example of the OpenPGP trust model.</p></div></div>
<p>There are some key points that are important in that model. In the
example Alice has to sign Bob&rsquo;s key, only if she is sure that the key
belongs to Bob. Otherwise she may also make Dave falsely believe that
this is Bob&rsquo;s key. Dave has also the responsibility to know who to
trust.  This model is similar to real life relations.
</p>
<p>Just see how Charlie behaves in the previous example. Although he has
signed Bob&rsquo;s key - because he knows, somehow, that it belongs to Bob -
he does not trust Bob to be an introducer. Charlie decided to trust
only Kevin, for some reason. A reason could be that Bob is lazy
enough, and signs other people&rsquo;s keys without being sure that they
belong to the actual owner.
</p>
<div class="float"><a name="tab_003aopenpgp_002dcertificate"></a>
<table>
<thead><tr><th width="20%">Field</th><th width="70%">Description</th></tr></thead>
<tr><td width="20%">version</td><td width="70%">The field that indicates the version of the OpenPGP structure.</td></tr>
<tr><td width="20%">user ID</td><td width="70%">An RFC 2822 string that identifies the owner of the key. There may be
multiple user identifiers in a key.</td></tr>
<tr><td width="20%">public key</td><td width="70%">The main public key of the certificate.</td></tr>
<tr><td width="20%">expiration</td><td width="70%">The expiration time of the main public key.</td></tr>
<tr><td width="20%">public subkey</td><td width="70%">An additional public key of the certificate. There may be multiple subkeys
in a certificate.</td></tr>
<tr><td width="20%">public subkey expiration</td><td width="70%">The expiration time of the subkey.</td></tr>
</table>

<div class="float-caption"><p><strong>Table 4.5: </strong>OpenPGP certificate fields.</p></div></div>

<a name="OpenPGP-certificate-structure"></a>
<h4 class="subsubsection">4.1.2.1 <acronym>OpenPGP</acronym> certificate structure</h4>

<p>In <acronym>GnuTLS</acronym> the <acronym>OpenPGP</acronym> certificate structures
[<em>RFC2440</em>] are handled using the <code>gnutls_openpgp_crt_t</code> type.
A typical certificate contains the user ID, which is an RFC 2822
mail and name address, a public key, possibly a number of additional
public keys (called subkeys), and a number of signatures. The various
fields are shown in <a href="#tab_003aopenpgp_002dcertificate">Table 4.5</a>.
</p>
<p>The additional subkeys may provide key for various different purposes,
e.g. one key to encrypt mail, and another to sign a TLS key exchange.
Each subkey is identified by a unique key ID.
The keys that are to be used in a TLS key exchange that requires
signatures are called authentication keys in the OpenPGP jargon.
The mapping of TLS key exchange methods to public keys is shown in
<a href="#tab_003aopenpgp_002dkey_002dexchange">Table 4.6</a>.
</p>
<div class="float"><a name="tab_003aopenpgp_002dkey_002dexchange"></a>
<table>
<thead><tr><th width="20%">Key exchange</th><th width="70%">Public key requirements</th></tr></thead>
<tr><td width="20%">RSA</td><td width="70%">An RSA public key that allows encryption.</td></tr>
<tr><td width="20%">DHE_RSA</td><td width="70%">An RSA public key that is marked for authentication.</td></tr>
<tr><td width="20%">ECDHE_RSA</td><td width="70%">An RSA public key that is marked for authentication.</td></tr>
<tr><td width="20%">DHE_DSS</td><td width="70%">A DSA public key that is marked for authentication.</td></tr>
</table>

<div class="float-caption"><p><strong>Table 4.6: </strong>The types of (sub)keys required for the various TLS key exchange methods.</p></div></div>
<p>The corresponding private keys are stored in the
<code>gnutls_openpgp_privkey_t</code> type. All the prototypes for the key
handling functions can be found in <samp>gnutls/openpgp.h</samp>.
</p>
<a name="Verifying-an-OpenPGP-certificate"></a>
<h4 class="subsubsection">4.1.2.2 Verifying an <acronym>OpenPGP</acronym> certificate</h4>

<p>The verification functions of <acronym>OpenPGP</acronym> keys, included in
<acronym>GnuTLS</acronym>, are simple ones, and do not use the features of the
&ldquo;web of trust&rdquo;.  For that reason, if the verification needs are
complex, the assistance of external tools like <acronym>GnuPG</acronym> and
GPGME<a name="DOCF9" href="#FOOT9"><sup>9</sup></a> is
recommended.
</p>
<p>In GnuTLS there is a verification function for OpenPGP certificates,
the <a href="OpenPGP-API.html#gnutls_005fopenpgp_005fcrt_005fverify_005fring">gnutls_openpgp_crt_verify_ring</a>.  This checks an
<acronym>OpenPGP</acronym> key against a given set of public keys (keyring) and
returns the key status. The key verification status is the same as in
<acronym>X.509</acronym> certificates, although the meaning and interpretation
are different. For example an <acronym>OpenPGP</acronym> key may be valid, if
the self signature is ok, even if no signers were found.  The meaning
of verification status flags is the same as in the <acronym>X.509</acronym> certificates
(see <a href="Verifying-a-certificate-in-the-context-of-TLS-session.html#gnutls_005fcertificate_005fverify_005fflags">Figure 4.3</a>).
</p>




<dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fring"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_ring</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, gnutls_openpgp_keyring_t <var>keyring</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>keyring</var>: holds the keyring to check against
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the certificate verification output.
</p>
<p>Verify all signatures in the key, using the given set of keys
(keyring).
</p>
<p>The key verification output will be put in  <code>verify</code> and will be one
or more of the <code>gnutls_certificate_status_t</code>  enumerated elements
bitwise or&rsquo;d.
</p>
<p>Note that this function does not verify using any &quot;web of trust&quot;.
You may use GnuPG for that purpose, or any other external PGP
application.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  on success, or an error code.
</p></dd></dl>





<dl>
<dt><a name="index-gnutls_005fopenpgp_005fcrt_005fverify_005fself"></a>Function: <em>int</em> <strong>gnutls_openpgp_crt_verify_self</strong> <em>(gnutls_openpgp_crt_t <var>key</var>, unsigned int <var>flags</var>, unsigned int * <var>verify</var>)</em></dt>
<dd><p><var>key</var>: the structure that holds the key.
</p>
<p><var>flags</var>: unused (should be 0)
</p>
<p><var>verify</var>: will hold the key verification output.
</p>
<p>Verifies the self signature in the key.  The key verification
output will be put in  <code>verify</code> and will be one or more of the
gnutls_certificate_status_t enumerated elements bitwise or&rsquo;d.
</p>
<p><strong>Returns:</strong> <code>GNUTLS_E_SUCCESS</code>  on success, or an error code.
</p></dd></dl>

<a name="Verifying-a-certificate-in-the-context-of-a-TLS-session"></a>
<h4 class="subsubsection">4.1.2.3 Verifying a certificate in the context of a TLS session</h4>

<p>Similarly with X.509 certificates, one needs to specify
the OpenPGP keyring file in the credentials structure. The certificates
in this file will be  used by <a href="Core-TLS-API.html#gnutls_005fcertificate_005fverify_005fpeers3">gnutls_certificate_verify_peers3</a>
to verify the signatures in the certificate sent by the peer.
</p>




<dl>
<dt><a name="index-gnutls_005fcertificate_005fset_005fopenpgp_005fkeyring_005ffile"></a>Function: <em>int</em> <strong>gnutls_certificate_set_openpgp_keyring_file</strong> <em>(gnutls_certificate_credentials_t <var>c</var>, const char * <var>file</var>, gnutls_openpgp_crt_fmt_t <var>format</var>)</em></dt>
<dd><p><var>c</var>: A certificate credentials structure
</p>
<p><var>file</var>: filename of the keyring.
</p>
<p><var>format</var>: format of keyring.
</p>
<p>The function is used to set keyrings that will be used internally
by various OpenPGP functions. For example to find a key when it
is needed for an operations. The keyring will also be used at the
verification functions.
</p>
<p><strong>Returns:</strong> On success, <code>GNUTLS_E_SUCCESS</code>  (0) is returned, otherwise a
negative error value.
</p></dd></dl>

<div class="footnote">
<hr>
<h4 class="footnotes-heading">Footnotes</h4>

<h3><a name="FOOT9" href="#DOCF9">(9)</a></h3>
<p><a href="http://www.gnupg.org/related_software/gpgme/">http://www.gnupg.org/related_software/gpgme/</a></p>
</div>
<hr>
<div class="header">
<p>
Next: <a href="Advanced-certificate-verification.html#Advanced-certificate-verification" accesskey="n" rel="next">Advanced certificate verification</a>, Previous: <a href="X_002e509-certificates.html#X_002e509-certificates" accesskey="p" rel="prev">X.509 certificates</a>, Up: <a href="Certificate-authentication.html#Certificate-authentication" accesskey="u" rel="up">Certificate authentication</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Function-and-Data-Index.html#Function-and-Data-Index" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>