rfc2440.txt revision 1.1 1 1.1 agc
2 1.1 agc
3 1.1 agc
4 1.1 agc
5 1.1 agc
6 1.1 agc
7 1.1 agc Network Working Group J. Callas
8 1.1 agc Request for Comments: 2440 Network Associates
9 1.1 agc Category: Standards Track L. Donnerhacke
10 1.1 agc IN-Root-CA Individual Network e.V.
11 1.1 agc H. Finney
12 1.1 agc Network Associates
13 1.1 agc R. Thayer
14 1.1 agc EIS Corporation
15 1.1 agc November 1998
16 1.1 agc
17 1.1 agc
18 1.1 agc OpenPGP Message Format
19 1.1 agc
20 1.1 agc Status of this Memo
21 1.1 agc
22 1.1 agc This document specifies an Internet standards track protocol for the
23 1.1 agc Internet community, and requests discussion and suggestions for
24 1.1 agc improvements. Please refer to the current edition of the "Internet
25 1.1 agc Official Protocol Standards" (STD 1) for the standardization state
26 1.1 agc and status of this protocol. Distribution of this memo is unlimited.
27 1.1 agc
28 1.1 agc Copyright Notice
29 1.1 agc
30 1.1 agc Copyright (C) The Internet Society (1998). All Rights Reserved.
31 1.1 agc
32 1.1 agc IESG Note
33 1.1 agc
34 1.1 agc This document defines many tag values, yet it doesn't describe a
35 1.1 agc mechanism for adding new tags (for new features). Traditionally the
36 1.1 agc Internet Assigned Numbers Authority (IANA) handles the allocation of
37 1.1 agc new values for future expansion and RFCs usually define the procedure
38 1.1 agc to be used by the IANA. However, there are subtle (and not so
39 1.1 agc subtle) interactions that may occur in this protocol between new
40 1.1 agc features and existing features which result in a significant
41 1.1 agc reduction in over all security. Therefore, this document does not
42 1.1 agc define an extension procedure. Instead requests to define new tag
43 1.1 agc values (say for new encryption algorithms for example) should be
44 1.1 agc forwarded to the IESG Security Area Directors for consideration or
45 1.1 agc forwarding to the appropriate IETF Working Group for consideration.
46 1.1 agc
47 1.1 agc Abstract
48 1.1 agc
49 1.1 agc This document is maintained in order to publish all necessary
50 1.1 agc information needed to develop interoperable applications based on the
51 1.1 agc OpenPGP format. It is not a step-by-step cookbook for writing an
52 1.1 agc application. It describes only the format and methods needed to read,
53 1.1 agc check, generate, and write conforming packets crossing any network.
54 1.1 agc It does not deal with storage and implementation questions. It does,
55 1.1 agc
56 1.1 agc
57 1.1 agc
58 1.1 agc Callas, et. al. Standards Track [Page 1]
59 1.1 agc
61 1.1 agc RFC 2440 OpenPGP Message Format November 1998
62 1.1 agc
63 1.1 agc
64 1.1 agc however, discuss implementation issues necessary to avoid security
65 1.1 agc flaws.
66 1.1 agc
67 1.1 agc Open-PGP software uses a combination of strong public-key and
68 1.1 agc symmetric cryptography to provide security services for electronic
69 1.1 agc communications and data storage. These services include
70 1.1 agc confidentiality, key management, authentication, and digital
71 1.1 agc signatures. This document specifies the message formats used in
72 1.1 agc OpenPGP.
73 1.1 agc
74 1.1 agc Table of Contents
75 1.1 agc
76 1.1 agc Status of this Memo 1
77 1.1 agc IESG Note 1
78 1.1 agc Abstract 1
79 1.1 agc Table of Contents 2
80 1.1 agc 1. Introduction 4
81 1.1 agc 1.1. Terms 5
82 1.1 agc 2. General functions 5
83 1.1 agc 2.1. Confidentiality via Encryption 5
84 1.1 agc 2.2. Authentication via Digital signature 6
85 1.1 agc 2.3. Compression 7
86 1.1 agc 2.4. Conversion to Radix-64 7
87 1.1 agc 2.5. Signature-Only Applications 7
88 1.1 agc 3. Data Element Formats 7
89 1.1 agc 3.1. Scalar numbers 8
90 1.1 agc 3.2. Multi-Precision Integers 8
91 1.1 agc 3.3. Key IDs 8
92 1.1 agc 3.4. Text 8
93 1.1 agc 3.5. Time fields 9
94 1.1 agc 3.6. String-to-key (S2K) specifiers 9
95 1.1 agc 3.6.1. String-to-key (S2k) specifier types 9
96 1.1 agc 3.6.1.1. Simple S2K 9
97 1.1 agc 3.6.1.2. Salted S2K 10
98 1.1 agc 3.6.1.3. Iterated and Salted S2K 10
99 1.1 agc 3.6.2. String-to-key usage 11
100 1.1 agc 3.6.2.1. Secret key encryption 11
101 1.1 agc 3.6.2.2. Symmetric-key message encryption 11
102 1.1 agc 4. Packet Syntax 12
103 1.1 agc 4.1. Overview 12
104 1.1 agc 4.2. Packet Headers 12
105 1.1 agc 4.2.1. Old-Format Packet Lengths 13
106 1.1 agc 4.2.2. New-Format Packet Lengths 13
107 1.1 agc 4.2.2.1. One-Octet Lengths 14
108 1.1 agc 4.2.2.2. Two-Octet Lengths 14
109 1.1 agc 4.2.2.3. Five-Octet Lengths 14
110 1.1 agc 4.2.2.4. Partial Body Lengths 14
111 1.1 agc 4.2.3. Packet Length Examples 14
112 1.1 agc
113 1.1 agc
114 1.1 agc
115 1.1 agc Callas, et. al. Standards Track [Page 2]
116 1.1 agc
118 1.1 agc RFC 2440 OpenPGP Message Format November 1998
119 1.1 agc
120 1.1 agc
121 1.1 agc 4.3. Packet Tags 15
122 1.1 agc 5. Packet Types 16
123 1.1 agc 5.1. Public-Key Encrypted Session Key Packets (Tag 1) 16
124 1.1 agc 5.2. Signature Packet (Tag 2) 17
125 1.1 agc 5.2.1. Signature Types 17
126 1.1 agc 5.2.2. Version 3 Signature Packet Format 19
127 1.1 agc 5.2.3. Version 4 Signature Packet Format 21
128 1.1 agc 5.2.3.1. Signature Subpacket Specification 22
129 1.1 agc 5.2.3.2. Signature Subpacket Types 24
130 1.1 agc 5.2.3.3. Signature creation time 25
131 1.1 agc 5.2.3.4. Issuer 25
132 1.1 agc 5.2.3.5. Key expiration time 25
133 1.1 agc 5.2.3.6. Preferred symmetric algorithms 25
134 1.1 agc 5.2.3.7. Preferred hash algorithms 25
135 1.1 agc 5.2.3.8. Preferred compression algorithms 26
136 1.1 agc 5.2.3.9. Signature expiration time 26
137 1.1 agc 5.2.3.10.Exportable Certification 26
138 1.1 agc 5.2.3.11.Revocable 27
139 1.1 agc 5.2.3.12.Trust signature 27
140 1.1 agc 5.2.3.13.Regular expression 27
141 1.1 agc 5.2.3.14.Revocation key 27
142 1.1 agc 5.2.3.15.Notation Data 28
143 1.1 agc 5.2.3.16.Key server preferences 28
144 1.1 agc 5.2.3.17.Preferred key server 29
145 1.1 agc 5.2.3.18.Primary user id 29
146 1.1 agc 5.2.3.19.Policy URL 29
147 1.1 agc 5.2.3.20.Key Flags 29
148 1.1 agc 5.2.3.21.Signer's User ID 30
149 1.1 agc 5.2.3.22.Reason for Revocation 30
150 1.1 agc 5.2.4. Computing Signatures 31
151 1.1 agc 5.2.4.1. Subpacket Hints 32
152 1.1 agc 5.3. Symmetric-Key Encrypted Session-Key Packets (Tag 3) 32
153 1.1 agc 5.4. One-Pass Signature Packets (Tag 4) 33
154 1.1 agc 5.5. Key Material Packet 34
155 1.1 agc 5.5.1. Key Packet Variants 34
156 1.1 agc 5.5.1.1. Public Key Packet (Tag 6) 34
157 1.1 agc 5.5.1.2. Public Subkey Packet (Tag 14) 34
158 1.1 agc 5.5.1.3. Secret Key Packet (Tag 5) 35
159 1.1 agc 5.5.1.4. Secret Subkey Packet (Tag 7) 35
160 1.1 agc 5.5.2. Public Key Packet Formats 35
161 1.1 agc 5.5.3. Secret Key Packet Formats 37
162 1.1 agc 5.6. Compressed Data Packet (Tag 8) 38
163 1.1 agc 5.7. Symmetrically Encrypted Data Packet (Tag 9) 39
164 1.1 agc 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10) 39
165 1.1 agc 5.9. Literal Data Packet (Tag 11) 40
166 1.1 agc 5.10. Trust Packet (Tag 12) 40
167 1.1 agc 5.11. User ID Packet (Tag 13) 41
168 1.1 agc 6. Radix-64 Conversions 41
169 1.1 agc
170 1.1 agc
171 1.1 agc
172 1.1 agc Callas, et. al. Standards Track [Page 3]
173 1.1 agc
175 1.1 agc RFC 2440 OpenPGP Message Format November 1998
176 1.1 agc
177 1.1 agc
178 1.1 agc 6.1. An Implementation of the CRC-24 in "C" 42
179 1.1 agc 6.2. Forming ASCII Armor 42
180 1.1 agc 6.3. Encoding Binary in Radix-64 44
181 1.1 agc 6.4. Decoding Radix-64 46
182 1.1 agc 6.5. Examples of Radix-64 46
183 1.1 agc 6.6. Example of an ASCII Armored Message 47
184 1.1 agc 7. Cleartext signature framework 47
185 1.1 agc 7.1. Dash-Escaped Text 47
186 1.1 agc 8. Regular Expressions 48
187 1.1 agc 9. Constants 49
188 1.1 agc 9.1. Public Key Algorithms 49
189 1.1 agc 9.2. Symmetric Key Algorithms 49
190 1.1 agc 9.3. Compression Algorithms 50
191 1.1 agc 9.4. Hash Algorithms 50
192 1.1 agc 10. Packet Composition 50
193 1.1 agc 10.1. Transferable Public Keys 50
194 1.1 agc 10.2. OpenPGP Messages 52
195 1.1 agc 10.3. Detached Signatures 52
196 1.1 agc 11. Enhanced Key Formats 52
197 1.1 agc 11.1. Key Structures 52
198 1.1 agc 11.2. Key IDs and Fingerprints 53
199 1.1 agc 12. Notes on Algorithms 54
200 1.1 agc 12.1. Symmetric Algorithm Preferences 54
201 1.1 agc 12.2. Other Algorithm Preferences 55
202 1.1 agc 12.2.1. Compression Preferences 56
203 1.1 agc 12.2.2. Hash Algorithm Preferences 56
204 1.1 agc 12.3. Plaintext 56
205 1.1 agc 12.4. RSA 56
206 1.1 agc 12.5. Elgamal 57
207 1.1 agc 12.6. DSA 58
208 1.1 agc 12.7. Reserved Algorithm Numbers 58
209 1.1 agc 12.8. OpenPGP CFB mode 58
210 1.1 agc 13. Security Considerations 59
211 1.1 agc 14. Implementation Nits 60
212 1.1 agc 15. Authors and Working Group Chair 62
213 1.1 agc 16. References 63
214 1.1 agc 17. Full Copyright Statement 65
215 1.1 agc
216 1.1 agc 1. Introduction
217 1.1 agc
218 1.1 agc This document provides information on the message-exchange packet
219 1.1 agc formats used by OpenPGP to provide encryption, decryption, signing,
220 1.1 agc and key management functions. It builds on the foundation provided in
221 1.1 agc RFC 1991 "PGP Message Exchange Formats."
222 1.1 agc
223 1.1 agc
224 1.1 agc
225 1.1 agc
226 1.1 agc
227 1.1 agc
228 1.1 agc
229 1.1 agc Callas, et. al. Standards Track [Page 4]
230 1.1 agc
232 1.1 agc RFC 2440 OpenPGP Message Format November 1998
233 1.1 agc
234 1.1 agc
235 1.1 agc 1.1. Terms
236 1.1 agc
237 1.1 agc * OpenPGP - This is a definition for security software that uses
238 1.1 agc PGP 5.x as a basis.
239 1.1 agc
240 1.1 agc * PGP - Pretty Good Privacy. PGP is a family of software systems
241 1.1 agc developed by Philip R. Zimmermann from which OpenPGP is based.
242 1.1 agc
243 1.1 agc * PGP 2.6.x - This version of PGP has many variants, hence the term
244 1.1 agc PGP 2.6.x. It used only RSA, MD5, and IDEA for its cryptographic
245 1.1 agc transforms. An informational RFC, RFC 1991, was written
246 1.1 agc describing this version of PGP.
247 1.1 agc
248 1.1 agc * PGP 5.x - This version of PGP is formerly known as "PGP 3" in the
249 1.1 agc community and also in the predecessor of this document, RFC 1991.
250 1.1 agc It has new formats and corrects a number of problems in the PGP
251 1.1 agc 2.6.x design. It is referred to here as PGP 5.x because that
252 1.1 agc software was the first release of the "PGP 3" code base.
253 1.1 agc
254 1.1 agc "PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of
255 1.1 agc Network Associates, Inc. and are used with permission.
256 1.1 agc
257 1.1 agc This document uses the terms "MUST", "SHOULD", and "MAY" as defined
258 1.1 agc in RFC 2119, along with the negated forms of those terms.
259 1.1 agc
260 1.1 agc 2. General functions
261 1.1 agc
262 1.1 agc OpenPGP provides data integrity services for messages and data files
263 1.1 agc by using these core technologies:
264 1.1 agc
265 1.1 agc - digital signatures
266 1.1 agc
267 1.1 agc - encryption
268 1.1 agc
269 1.1 agc - compression
270 1.1 agc
271 1.1 agc - radix-64 conversion
272 1.1 agc
273 1.1 agc In addition, OpenPGP provides key management and certificate
274 1.1 agc services, but many of these are beyond the scope of this document.
275 1.1 agc
276 1.1 agc 2.1. Confidentiality via Encryption
277 1.1 agc
278 1.1 agc OpenPGP uses two encryption methods to provide confidentiality:
279 1.1 agc symmetric-key encryption and public key encryption. With public-key
280 1.1 agc encryption, the object is encrypted using a symmetric encryption
281 1.1 agc algorithm. Each symmetric key is used only once. A new "session key"
282 1.1 agc is generated as a random number for each message. Since it is used
283 1.1 agc
284 1.1 agc
285 1.1 agc
286 1.1 agc Callas, et. al. Standards Track [Page 5]
287 1.1 agc
289 1.1 agc RFC 2440 OpenPGP Message Format November 1998
290 1.1 agc
291 1.1 agc
292 1.1 agc only once, the session key is bound to the message and transmitted
293 1.1 agc with it. To protect the key, it is encrypted with the receiver's
294 1.1 agc public key. The sequence is as follows:
295 1.1 agc
296 1.1 agc 1. The sender creates a message.
297 1.1 agc
298 1.1 agc 2. The sending OpenPGP generates a random number to be used as a
299 1.1 agc session key for this message only.
300 1.1 agc
301 1.1 agc 3. The session key is encrypted using each recipient's public key.
302 1.1 agc These "encrypted session keys" start the message.
303 1.1 agc
304 1.1 agc 4. The sending OpenPGP encrypts the message using the session key,
305 1.1 agc which forms the remainder of the message. Note that the message
306 1.1 agc is also usually compressed.
307 1.1 agc
308 1.1 agc 5. The receiving OpenPGP decrypts the session key using the
309 1.1 agc recipient's private key.
310 1.1 agc
311 1.1 agc 6. The receiving OpenPGP decrypts the message using the session key.
312 1.1 agc If the message was compressed, it will be decompressed.
313 1.1 agc
314 1.1 agc With symmetric-key encryption, an object may be encrypted with a
315 1.1 agc symmetric key derived from a passphrase (or other shared secret), or
316 1.1 agc a two-stage mechanism similar to the public-key method described
317 1.1 agc above in which a session key is itself encrypted with a symmetric
318 1.1 agc algorithm keyed from a shared secret.
319 1.1 agc
320 1.1 agc Both digital signature and confidentiality services may be applied to
321 1.1 agc the same message. First, a signature is generated for the message and
322 1.1 agc attached to the message. Then, the message plus signature is
323 1.1 agc encrypted using a symmetric session key. Finally, the session key is
324 1.1 agc encrypted using public-key encryption and prefixed to the encrypted
325 1.1 agc block.
326 1.1 agc
327 1.1 agc 2.2. Authentication via Digital signature
328 1.1 agc
329 1.1 agc The digital signature uses a hash code or message digest algorithm,
330 1.1 agc and a public-key signature algorithm. The sequence is as follows:
331 1.1 agc
332 1.1 agc 1. The sender creates a message.
333 1.1 agc
334 1.1 agc 2. The sending software generates a hash code of the message.
335 1.1 agc
336 1.1 agc 3. The sending software generates a signature from the hash code
337 1.1 agc using the sender's private key.
338 1.1 agc
339 1.1 agc 4. The binary signature is attached to the message.
340 1.1 agc
341 1.1 agc
342 1.1 agc
343 1.1 agc Callas, et. al. Standards Track [Page 6]
344 1.1 agc
346 1.1 agc RFC 2440 OpenPGP Message Format November 1998
347 1.1 agc
348 1.1 agc
349 1.1 agc 5. The receiving software keeps a copy of the message signature.
350 1.1 agc
351 1.1 agc 6. The receiving software generates a new hash code for the
352 1.1 agc received message and verifies it using the message's signature.
353 1.1 agc If the verification is successful, the message is accepted as
354 1.1 agc authentic.
355 1.1 agc
356 1.1 agc 2.3. Compression
357 1.1 agc
358 1.1 agc OpenPGP implementations MAY compress the message after applying the
359 1.1 agc signature but before encryption.
360 1.1 agc
361 1.1 agc 2.4. Conversion to Radix-64
362 1.1 agc
363 1.1 agc OpenPGP's underlying native representation for encrypted messages,
364 1.1 agc signature certificates, and keys is a stream of arbitrary octets.
365 1.1 agc Some systems only permit the use of blocks consisting of seven-bit,
366 1.1 agc printable text. For transporting OpenPGP's native raw binary octets
367 1.1 agc through channels that are not safe to raw binary data, a printable
368 1.1 agc encoding of these binary octets is needed. OpenPGP provides the
369 1.1 agc service of converting the raw 8-bit binary octet stream to a stream
370 1.1 agc of printable ASCII characters, called Radix-64 encoding or ASCII
371 1.1 agc Armor.
372 1.1 agc
373 1.1 agc Implementations SHOULD provide Radix-64 conversions.
374 1.1 agc
375 1.1 agc Note that many applications, particularly messaging applications,
376 1.1 agc will want more advanced features as described in the OpenPGP-MIME
377 1.1 agc document, RFC 2015. An application that implements OpenPGP for
378 1.1 agc messaging SHOULD implement OpenPGP-MIME.
379 1.1 agc
380 1.1 agc 2.5. Signature-Only Applications
381 1.1 agc
382 1.1 agc OpenPGP is designed for applications that use both encryption and
383 1.1 agc signatures, but there are a number of problems that are solved by a
384 1.1 agc signature-only implementation. Although this specification requires
385 1.1 agc both encryption and signatures, it is reasonable for there to be
386 1.1 agc subset implementations that are non-comformant only in that they omit
387 1.1 agc encryption.
388 1.1 agc
389 1.1 agc 3. Data Element Formats
390 1.1 agc
391 1.1 agc This section describes the data elements used by OpenPGP.
392 1.1 agc
393 1.1 agc
394 1.1 agc
395 1.1 agc
396 1.1 agc
397 1.1 agc
398 1.1 agc
399 1.1 agc
400 1.1 agc Callas, et. al. Standards Track [Page 7]
401 1.1 agc
403 1.1 agc RFC 2440 OpenPGP Message Format November 1998
404 1.1 agc
405 1.1 agc
406 1.1 agc 3.1. Scalar numbers
407 1.1 agc
408 1.1 agc Scalar numbers are unsigned, and are always stored in big-endian
409 1.1 agc format. Using n[k] to refer to the kth octet being interpreted, the
410 1.1 agc value of a two-octet scalar is ((n[0] << 8) + n[1]). The value of a
411 1.1 agc four-octet scalar is ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
412 1.1 agc n[3]).
413 1.1 agc
414 1.1 agc 3.2. Multi-Precision Integers
415 1.1 agc
416 1.1 agc Multi-Precision Integers (also called MPIs) are unsigned integers
417 1.1 agc used to hold large integers such as the ones used in cryptographic
418 1.1 agc calculations.
419 1.1 agc
420 1.1 agc An MPI consists of two pieces: a two-octet scalar that is the length
421 1.1 agc of the MPI in bits followed by a string of octets that contain the
422 1.1 agc actual integer.
423 1.1 agc
424 1.1 agc These octets form a big-endian number; a big-endian number can be
425 1.1 agc made into an MPI by prefixing it with the appropriate length.
426 1.1 agc
427 1.1 agc Examples:
428 1.1 agc
429 1.1 agc (all numbers are in hexadecimal)
430 1.1 agc
431 1.1 agc The string of octets [00 01 01] forms an MPI with the value 1. The
432 1.1 agc string [00 09 01 FF] forms an MPI with the value of 511.
433 1.1 agc
434 1.1 agc Additional rules:
435 1.1 agc
436 1.1 agc The size of an MPI is ((MPI.length + 7) / 8) + 2 octets.
437 1.1 agc
438 1.1 agc The length field of an MPI describes the length starting from its
439 1.1 agc most significant non-zero bit. Thus, the MPI [00 02 01] is not formed
440 1.1 agc correctly. It should be [00 01 01].
441 1.1 agc
442 1.1 agc 3.3. Key IDs
443 1.1 agc
444 1.1 agc A Key ID is an eight-octet scalar that identifies a key.
445 1.1 agc Implementations SHOULD NOT assume that Key IDs are unique. The
446 1.1 agc section, "Enhanced Key Formats" below describes how Key IDs are
447 1.1 agc formed.
448 1.1 agc
449 1.1 agc 3.4. Text
450 1.1 agc
451 1.1 agc The default character set for text is the UTF-8 [RFC2279] encoding of
452 1.1 agc Unicode [ISO10646].
453 1.1 agc
454 1.1 agc
455 1.1 agc
456 1.1 agc
457 1.1 agc Callas, et. al. Standards Track [Page 8]
458 1.1 agc
460 1.1 agc RFC 2440 OpenPGP Message Format November 1998
461 1.1 agc
462 1.1 agc
463 1.1 agc 3.5. Time fields
464 1.1 agc
465 1.1 agc A time field is an unsigned four-octet number containing the number
466 1.1 agc of seconds elapsed since midnight, 1 January 1970 UTC.
467 1.1 agc
468 1.1 agc 3.6. String-to-key (S2K) specifiers
469 1.1 agc
470 1.1 agc String-to-key (S2K) specifiers are used to convert passphrase strings
471 1.1 agc into symmetric-key encryption/decryption keys. They are used in two
472 1.1 agc places, currently: to encrypt the secret part of private keys in the
473 1.1 agc private keyring, and to convert passphrases to encryption keys for
474 1.1 agc symmetrically encrypted messages.
475 1.1 agc
476 1.1 agc 3.6.1. String-to-key (S2k) specifier types
477 1.1 agc
478 1.1 agc There are three types of S2K specifiers currently supported, as
479 1.1 agc follows:
480 1.1 agc
481 1.1 agc 3.6.1.1. Simple S2K
482 1.1 agc
483 1.1 agc This directly hashes the string to produce the key data. See below
484 1.1 agc for how this hashing is done.
485 1.1 agc
486 1.1 agc Octet 0: 0x00
487 1.1 agc Octet 1: hash algorithm
488 1.1 agc
489 1.1 agc Simple S2K hashes the passphrase to produce the session key. The
490 1.1 agc manner in which this is done depends on the size of the session key
491 1.1 agc (which will depend on the cipher used) and the size of the hash
492 1.1 agc algorithm's output. If the hash size is greater than or equal to the
493 1.1 agc session key size, the high-order (leftmost) octets of the hash are
494 1.1 agc used as the key.
495 1.1 agc
496 1.1 agc If the hash size is less than the key size, multiple instances of the
497 1.1 agc hash context are created -- enough to produce the required key data.
498 1.1 agc These instances are preloaded with 0, 1, 2, ... octets of zeros (that
499 1.1 agc is to say, the first instance has no preloading, the second gets
500 1.1 agc preloaded with 1 octet of zero, the third is preloaded with two
501 1.1 agc octets of zeros, and so forth).
502 1.1 agc
503 1.1 agc As the data is hashed, it is given independently to each hash
504 1.1 agc context. Since the contexts have been initialized differently, they
505 1.1 agc will each produce different hash output. Once the passphrase is
506 1.1 agc hashed, the output data from the multiple hashes is concatenated,
507 1.1 agc first hash leftmost, to produce the key data, with any excess octets
508 1.1 agc on the right discarded.
509 1.1 agc
510 1.1 agc
511 1.1 agc
512 1.1 agc
513 1.1 agc
514 1.1 agc Callas, et. al. Standards Track [Page 9]
515 1.1 agc
517 1.1 agc RFC 2440 OpenPGP Message Format November 1998
518 1.1 agc
519 1.1 agc
520 1.1 agc 3.6.1.2. Salted S2K
521 1.1 agc
522 1.1 agc This includes a "salt" value in the S2K specifier -- some arbitrary
523 1.1 agc data -- that gets hashed along with the passphrase string, to help
524 1.1 agc prevent dictionary attacks.
525 1.1 agc
526 1.1 agc Octet 0: 0x01
527 1.1 agc Octet 1: hash algorithm
528 1.1 agc Octets 2-9: 8-octet salt value
529 1.1 agc
530 1.1 agc Salted S2K is exactly like Simple S2K, except that the input to the
531 1.1 agc hash function(s) consists of the 8 octets of salt from the S2K
532 1.1 agc specifier, followed by the passphrase.
533 1.1 agc
534 1.1 agc 3.6.1.3. Iterated and Salted S2K
535 1.1 agc
536 1.1 agc This includes both a salt and an octet count. The salt is combined
537 1.1 agc with the passphrase and the resulting value is hashed repeatedly.
538 1.1 agc This further increases the amount of work an attacker must do to try
539 1.1 agc dictionary attacks.
540 1.1 agc
541 1.1 agc Octet 0: 0x03
542 1.1 agc Octet 1: hash algorithm
543 1.1 agc Octets 2-9: 8-octet salt value
544 1.1 agc Octet 10: count, a one-octet, coded value
545 1.1 agc
546 1.1 agc The count is coded into a one-octet number using the following
547 1.1 agc formula:
548 1.1 agc
549 1.1 agc #define EXPBIAS 6
550 1.1 agc count = ((Int32)16 + (c & 15)) << ((c >> 4) + EXPBIAS);
551 1.1 agc
552 1.1 agc The above formula is in C, where "Int32" is a type for a 32-bit
553 1.1 agc integer, and the variable "c" is the coded count, Octet 10.
554 1.1 agc
555 1.1 agc Iterated-Salted S2K hashes the passphrase and salt data multiple
556 1.1 agc times. The total number of octets to be hashed is specified in the
557 1.1 agc encoded count in the S2K specifier. Note that the resulting count
558 1.1 agc value is an octet count of how many octets will be hashed, not an
559 1.1 agc iteration count.
560 1.1 agc
561 1.1 agc Initially, one or more hash contexts are set up as with the other S2K
562 1.1 agc algorithms, depending on how many octets of key data are needed.
563 1.1 agc Then the salt, followed by the passphrase data is repeatedly hashed
564 1.1 agc until the number of octets specified by the octet count has been
565 1.1 agc hashed. The one exception is that if the octet count is less than
566 1.1 agc the size of the salt plus passphrase, the full salt plus passphrase
567 1.1 agc will be hashed even though that is greater than the octet count.
568 1.1 agc
569 1.1 agc
570 1.1 agc
571 1.1 agc Callas, et. al. Standards Track [Page 10]
572 1.1 agc
574 1.1 agc RFC 2440 OpenPGP Message Format November 1998
575 1.1 agc
576 1.1 agc
577 1.1 agc After the hashing is done the data is unloaded from the hash
578 1.1 agc context(s) as with the other S2K algorithms.
579 1.1 agc
580 1.1 agc 3.6.2. String-to-key usage
581 1.1 agc
582 1.1 agc Implementations SHOULD use salted or iterated-and-salted S2K
583 1.1 agc specifiers, as simple S2K specifiers are more vulnerable to
584 1.1 agc dictionary attacks.
585 1.1 agc
586 1.1 agc 3.6.2.1. Secret key encryption
587 1.1 agc
588 1.1 agc An S2K specifier can be stored in the secret keyring to specify how
589 1.1 agc to convert the passphrase to a key that unlocks the secret data.
590 1.1 agc Older versions of PGP just stored a cipher algorithm octet preceding
591 1.1 agc the secret data or a zero to indicate that the secret data was
592 1.1 agc unencrypted. The MD5 hash function was always used to convert the
593 1.1 agc passphrase to a key for the specified cipher algorithm.
594 1.1 agc
595 1.1 agc For compatibility, when an S2K specifier is used, the special value
596 1.1 agc 255 is stored in the position where the hash algorithm octet would
597 1.1 agc have been in the old data structure. This is then followed
598 1.1 agc immediately by a one-octet algorithm identifier, and then by the S2K
599 1.1 agc specifier as encoded above.
600 1.1 agc
601 1.1 agc Therefore, preceding the secret data there will be one of these
602 1.1 agc possibilities:
603 1.1 agc
604 1.1 agc 0: secret data is unencrypted (no pass phrase)
605 1.1 agc 255: followed by algorithm octet and S2K specifier
606 1.1 agc Cipher alg: use Simple S2K algorithm using MD5 hash
607 1.1 agc
608 1.1 agc This last possibility, the cipher algorithm number with an implicit
609 1.1 agc use of MD5 and IDEA, is provided for backward compatibility; it MAY
610 1.1 agc be understood, but SHOULD NOT be generated, and is deprecated.
611 1.1 agc
612 1.1 agc These are followed by an 8-octet Initial Vector for the decryption of
613 1.1 agc the secret values, if they are encrypted, and then the secret key
614 1.1 agc values themselves.
615 1.1 agc
616 1.1 agc 3.6.2.2. Symmetric-key message encryption
617 1.1 agc
618 1.1 agc OpenPGP can create a Symmetric-key Encrypted Session Key (ESK) packet
619 1.1 agc at the front of a message. This is used to allow S2K specifiers to
620 1.1 agc be used for the passphrase conversion or to create messages with a
621 1.1 agc mix of symmetric-key ESKs and public-key ESKs. This allows a message
622 1.1 agc to be decrypted either with a passphrase or a public key.
623 1.1 agc
624 1.1 agc
625 1.1 agc
626 1.1 agc
627 1.1 agc
628 1.1 agc Callas, et. al. Standards Track [Page 11]
629 1.1 agc
631 1.1 agc RFC 2440 OpenPGP Message Format November 1998
632 1.1 agc
633 1.1 agc
634 1.1 agc PGP 2.X always used IDEA with Simple string-to-key conversion when
635 1.1 agc encrypting a message with a symmetric algorithm. This is deprecated,
636 1.1 agc but MAY be used for backward-compatibility.
637 1.1 agc
638 1.1 agc 4. Packet Syntax
639 1.1 agc
640 1.1 agc This section describes the packets used by OpenPGP.
641 1.1 agc
642 1.1 agc 4.1. Overview
643 1.1 agc
644 1.1 agc An OpenPGP message is constructed from a number of records that are
645 1.1 agc traditionally called packets. A packet is a chunk of data that has a
646 1.1 agc tag specifying its meaning. An OpenPGP message, keyring, certificate,
647 1.1 agc and so forth consists of a number of packets. Some of those packets
648 1.1 agc may contain other OpenPGP packets (for example, a compressed data
649 1.1 agc packet, when uncompressed, contains OpenPGP packets).
650 1.1 agc
651 1.1 agc Each packet consists of a packet header, followed by the packet body.
652 1.1 agc The packet header is of variable length.
653 1.1 agc
654 1.1 agc 4.2. Packet Headers
655 1.1 agc
656 1.1 agc The first octet of the packet header is called the "Packet Tag." It
657 1.1 agc determines the format of the header and denotes the packet contents.
658 1.1 agc The remainder of the packet header is the length of the packet.
659 1.1 agc
660 1.1 agc Note that the most significant bit is the left-most bit, called bit
661 1.1 agc 7. A mask for this bit is 0x80 in hexadecimal.
662 1.1 agc
663 1.1 agc +---------------+
664 1.1 agc PTag |7 6 5 4 3 2 1 0|
665 1.1 agc +---------------+
666 1.1 agc Bit 7 -- Always one
667 1.1 agc Bit 6 -- New packet format if set
668 1.1 agc
669 1.1 agc PGP 2.6.x only uses old format packets. Thus, software that
670 1.1 agc interoperates with those versions of PGP must only use old format
671 1.1 agc packets. If interoperability is not an issue, either format may be
672 1.1 agc used. Note that old format packets have four bits of content tags,
673 1.1 agc and new format packets have six; some features cannot be used and
674 1.1 agc still be backward-compatible.
675 1.1 agc
676 1.1 agc Old format packets contain:
677 1.1 agc
678 1.1 agc Bits 5-2 -- content tag
679 1.1 agc Bits 1-0 - length-type
680 1.1 agc
681 1.1 agc
682 1.1 agc
683 1.1 agc
684 1.1 agc
685 1.1 agc Callas, et. al. Standards Track [Page 12]
686 1.1 agc
688 1.1 agc RFC 2440 OpenPGP Message Format November 1998
689 1.1 agc
690 1.1 agc
691 1.1 agc New format packets contain:
692 1.1 agc
693 1.1 agc Bits 5-0 -- content tag
694 1.1 agc
695 1.1 agc 4.2.1. Old-Format Packet Lengths
696 1.1 agc
697 1.1 agc The meaning of the length-type in old-format packets is:
698 1.1 agc
699 1.1 agc 0 - The packet has a one-octet length. The header is 2 octets long.
700 1.1 agc
701 1.1 agc 1 - The packet has a two-octet length. The header is 3 octets long.
702 1.1 agc
703 1.1 agc 2 - The packet has a four-octet length. The header is 5 octets long.
704 1.1 agc
705 1.1 agc 3 - The packet is of indeterminate length. The header is 1 octet
706 1.1 agc long, and the implementation must determine how long the packet
707 1.1 agc is. If the packet is in a file, this means that the packet
708 1.1 agc extends until the end of the file. In general, an implementation
709 1.1 agc SHOULD NOT use indeterminate length packets except where the end
710 1.1 agc of the data will be clear from the context, and even then it is
711 1.1 agc better to use a definite length, or a new-format header. The
712 1.1 agc new-format headers described below have a mechanism for precisely
713 1.1 agc encoding data of indeterminate length.
714 1.1 agc
715 1.1 agc 4.2.2. New-Format Packet Lengths
716 1.1 agc
717 1.1 agc New format packets have four possible ways of encoding length:
718 1.1 agc
719 1.1 agc 1. A one-octet Body Length header encodes packet lengths of up to
720 1.1 agc 191 octets.
721 1.1 agc
722 1.1 agc 2. A two-octet Body Length header encodes packet lengths of 192 to
723 1.1 agc 8383 octets.
724 1.1 agc
725 1.1 agc 3. A five-octet Body Length header encodes packet lengths of up to
726 1.1 agc 4,294,967,295 (0xFFFFFFFF) octets in length. (This actually
727 1.1 agc encodes a four-octet scalar number.)
728 1.1 agc
729 1.1 agc 4. When the length of the packet body is not known in advance by the
730 1.1 agc issuer, Partial Body Length headers encode a packet of
731 1.1 agc indeterminate length, effectively making it a stream.
732 1.1 agc
733 1.1 agc
734 1.1 agc
735 1.1 agc
736 1.1 agc
737 1.1 agc
738 1.1 agc
739 1.1 agc
740 1.1 agc
741 1.1 agc
742 1.1 agc Callas, et. al. Standards Track [Page 13]
743 1.1 agc
745 1.1 agc RFC 2440 OpenPGP Message Format November 1998
746 1.1 agc
747 1.1 agc
748 1.1 agc 4.2.2.1. One-Octet Lengths
749 1.1 agc
750 1.1 agc A one-octet Body Length header encodes a length of from 0 to 191
751 1.1 agc octets. This type of length header is recognized because the one
752 1.1 agc octet value is less than 192. The body length is equal to:
753 1.1 agc
754 1.1 agc bodyLen = 1st_octet;
755 1.1 agc
756 1.1 agc 4.2.2.2. Two-Octet Lengths
757 1.1 agc
758 1.1 agc A two-octet Body Length header encodes a length of from 192 to 8383
759 1.1 agc octets. It is recognized because its first octet is in the range 192
760 1.1 agc to 223. The body length is equal to:
761 1.1 agc
762 1.1 agc bodyLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
763 1.1 agc
764 1.1 agc 4.2.2.3. Five-Octet Lengths
765 1.1 agc
766 1.1 agc A five-octet Body Length header consists of a single octet holding
767 1.1 agc the value 255, followed by a four-octet scalar. The body length is
768 1.1 agc equal to:
769 1.1 agc
770 1.1 agc bodyLen = (2nd_octet << 24) | (3rd_octet << 16) |
771 1.1 agc (4th_octet << 8) | 5th_octet
772 1.1 agc
773 1.1 agc 4.2.2.4. Partial Body Lengths
774 1.1 agc
775 1.1 agc A Partial Body Length header is one octet long and encodes the length
776 1.1 agc of only part of the data packet. This length is a power of 2, from 1
777 1.1 agc to 1,073,741,824 (2 to the 30th power). It is recognized by its one
778 1.1 agc octet value that is greater than or equal to 224, and less than 255.
779 1.1 agc The partial body length is equal to:
780 1.1 agc
781 1.1 agc partialBodyLen = 1 << (1st_octet & 0x1f);
782 1.1 agc
783 1.1 agc Each Partial Body Length header is followed by a portion of the
784 1.1 agc packet body data. The Partial Body Length header specifies this
785 1.1 agc portion's length. Another length header (of one of the three types --
786 1.1 agc one octet, two-octet, or partial) follows that portion. The last
787 1.1 agc length header in the packet MUST NOT be a partial Body Length header.
788 1.1 agc Partial Body Length headers may only be used for the non-final parts
789 1.1 agc of the packet.
790 1.1 agc
791 1.1 agc 4.2.3. Packet Length Examples
792 1.1 agc
793 1.1 agc These examples show ways that new-format packets might encode the
794 1.1 agc packet lengths.
795 1.1 agc
796 1.1 agc
797 1.1 agc
798 1.1 agc
799 1.1 agc Callas, et. al. Standards Track [Page 14]
800 1.1 agc
802 1.1 agc RFC 2440 OpenPGP Message Format November 1998
803 1.1 agc
804 1.1 agc
805 1.1 agc A packet with length 100 may have its length encoded in one octet:
806 1.1 agc 0x64. This is followed by 100 octets of data.
807 1.1 agc
808 1.1 agc A packet with length 1723 may have its length coded in two octets:
809 1.1 agc 0xC5, 0xFB. This header is followed by the 1723 octets of data.
810 1.1 agc
811 1.1 agc A packet with length 100000 may have its length encoded in five
812 1.1 agc octets: 0xFF, 0x00, 0x01, 0x86, 0xA0.
813 1.1 agc
814 1.1 agc It might also be encoded in the following octet stream: 0xEF, first
815 1.1 agc 32768 octets of data; 0xE1, next two octets of data; 0xE0, next one
816 1.1 agc octet of data; 0xF0, next 65536 octets of data; 0xC5, 0xDD, last 1693
817 1.1 agc octets of data. This is just one possible encoding, and many
818 1.1 agc variations are possible on the size of the Partial Body Length
819 1.1 agc headers, as long as a regular Body Length header encodes the last
820 1.1 agc portion of the data. Note also that the last Body Length header can
821 1.1 agc be a zero-length header.
822 1.1 agc
823 1.1 agc An implementation MAY use Partial Body Lengths for data packets, be
824 1.1 agc they literal, compressed, or encrypted. The first partial length MUST
825 1.1 agc be at least 512 octets long. Partial Body Lengths MUST NOT be used
826 1.1 agc for any other packet types.
827 1.1 agc
828 1.1 agc Please note that in all of these explanations, the total length of
829 1.1 agc the packet is the length of the header(s) plus the length of the
830 1.1 agc body.
831 1.1 agc
832 1.1 agc 4.3. Packet Tags
833 1.1 agc
834 1.1 agc The packet tag denotes what type of packet the body holds. Note that
835 1.1 agc old format headers can only have tags less than 16, whereas new
836 1.1 agc format headers can have tags as great as 63. The defined tags (in
837 1.1 agc decimal) are:
838 1.1 agc
839 1.1 agc 0 -- Reserved - a packet tag must not have this value
840 1.1 agc 1 -- Public-Key Encrypted Session Key Packet
841 1.1 agc 2 -- Signature Packet
842 1.1 agc 3 -- Symmetric-Key Encrypted Session Key Packet
843 1.1 agc 4 -- One-Pass Signature Packet
844 1.1 agc 5 -- Secret Key Packet
845 1.1 agc 6 -- Public Key Packet
846 1.1 agc 7 -- Secret Subkey Packet
847 1.1 agc 8 -- Compressed Data Packet
848 1.1 agc 9 -- Symmetrically Encrypted Data Packet
849 1.1 agc 10 -- Marker Packet
850 1.1 agc 11 -- Literal Data Packet
851 1.1 agc 12 -- Trust Packet
852 1.1 agc
853 1.1 agc
854 1.1 agc
855 1.1 agc
856 1.1 agc Callas, et. al. Standards Track [Page 15]
857 1.1 agc
859 1.1 agc RFC 2440 OpenPGP Message Format November 1998
860 1.1 agc
861 1.1 agc
862 1.1 agc 13 -- User ID Packet
863 1.1 agc 14 -- Public Subkey Packet
864 1.1 agc 60 to 63 -- Private or Experimental Values
865 1.1 agc
866 1.1 agc 5. Packet Types
867 1.1 agc
868 1.1 agc 5.1. Public-Key Encrypted Session Key Packets (Tag 1)
869 1.1 agc
870 1.1 agc A Public-Key Encrypted Session Key packet holds the session key used
871 1.1 agc to encrypt a message. Zero or more Encrypted Session Key packets
872 1.1 agc (either Public-Key or Symmetric-Key) may precede a Symmetrically
873 1.1 agc Encrypted Data Packet, which holds an encrypted message. The message
874 1.1 agc is encrypted with the session key, and the session key is itself
875 1.1 agc encrypted and stored in the Encrypted Session Key packet(s). The
876 1.1 agc Symmetrically Encrypted Data Packet is preceded by one Public-Key
877 1.1 agc Encrypted Session Key packet for each OpenPGP key to which the
878 1.1 agc message is encrypted. The recipient of the message finds a session
879 1.1 agc key that is encrypted to their public key, decrypts the session key,
880 1.1 agc and then uses the session key to decrypt the message.
881 1.1 agc
882 1.1 agc The body of this packet consists of:
883 1.1 agc
884 1.1 agc - A one-octet number giving the version number of the packet type.
885 1.1 agc The currently defined value for packet version is 3. An
886 1.1 agc implementation should accept, but not generate a version of 2,
887 1.1 agc which is equivalent to V3 in all other respects.
888 1.1 agc
889 1.1 agc - An eight-octet number that gives the key ID of the public key
890 1.1 agc that the session key is encrypted to.
891 1.1 agc
892 1.1 agc - A one-octet number giving the public key algorithm used.
893 1.1 agc
894 1.1 agc - A string of octets that is the encrypted session key. This string
895 1.1 agc takes up the remainder of the packet, and its contents are
896 1.1 agc dependent on the public key algorithm used.
897 1.1 agc
898 1.1 agc Algorithm Specific Fields for RSA encryption
899 1.1 agc
900 1.1 agc - multiprecision integer (MPI) of RSA encrypted value m**e mod n.
901 1.1 agc
902 1.1 agc Algorithm Specific Fields for Elgamal encryption:
903 1.1 agc
904 1.1 agc - MPI of Elgamal (Diffie-Hellman) value g**k mod p.
905 1.1 agc
906 1.1 agc - MPI of Elgamal (Diffie-Hellman) value m * y**k mod p.
907 1.1 agc
908 1.1 agc
909 1.1 agc
910 1.1 agc
911 1.1 agc
912 1.1 agc
913 1.1 agc Callas, et. al. Standards Track [Page 16]
914 1.1 agc
916 1.1 agc RFC 2440 OpenPGP Message Format November 1998
917 1.1 agc
918 1.1 agc
919 1.1 agc The value "m" in the above formulas is derived from the session key
920 1.1 agc as follows. First the session key is prefixed with a one-octet
921 1.1 agc algorithm identifier that specifies the symmetric encryption
922 1.1 agc algorithm used to encrypt the following Symmetrically Encrypted Data
923 1.1 agc Packet. Then a two-octet checksum is appended which is equal to the
924 1.1 agc sum of the preceding session key octets, not including the algorithm
925 1.1 agc identifier, modulo 65536. This value is then padded as described in
926 1.1 agc PKCS-1 block type 02 [RFC2313] to form the "m" value used in the
927 1.1 agc formulas above.
928 1.1 agc
929 1.1 agc Note that when an implementation forms several PKESKs with one
930 1.1 agc session key, forming a message that can be decrypted by several keys,
931 1.1 agc the implementation MUST make new PKCS-1 padding for each key.
932 1.1 agc
933 1.1 agc An implementation MAY accept or use a Key ID of zero as a "wild card"
934 1.1 agc or "speculative" Key ID. In this case, the receiving implementation
935 1.1 agc would try all available private keys, checking for a valid decrypted
936 1.1 agc session key. This format helps reduce traffic analysis of messages.
937 1.1 agc
938 1.1 agc 5.2. Signature Packet (Tag 2)
939 1.1 agc
940 1.1 agc A signature packet describes a binding between some public key and
941 1.1 agc some data. The most common signatures are a signature of a file or a
942 1.1 agc block of text, and a signature that is a certification of a user ID.
943 1.1 agc
944 1.1 agc Two versions of signature packets are defined. Version 3 provides
945 1.1 agc basic signature information, while version 4 provides an expandable
946 1.1 agc format with subpackets that can specify more information about the
947 1.1 agc signature. PGP 2.6.x only accepts version 3 signatures.
948 1.1 agc
949 1.1 agc Implementations MUST accept V3 signatures. Implementations SHOULD
950 1.1 agc generate V4 signatures. Implementations MAY generate a V3 signature
951 1.1 agc that can be verified by PGP 2.6.x.
952 1.1 agc
953 1.1 agc Note that if an implementation is creating an encrypted and signed
954 1.1 agc message that is encrypted to a V3 key, it is reasonable to create a
955 1.1 agc V3 signature.
956 1.1 agc
957 1.1 agc 5.2.1. Signature Types
958 1.1 agc
959 1.1 agc There are a number of possible meanings for a signature, which are
960 1.1 agc specified in a signature type octet in any given signature. These
961 1.1 agc meanings are:
962 1.1 agc
963 1.1 agc 0x00: Signature of a binary document.
964 1.1 agc Typically, this means the signer owns it, created it, or
965 1.1 agc certifies that it has not been modified.
966 1.1 agc
967 1.1 agc
968 1.1 agc
969 1.1 agc
970 1.1 agc Callas, et. al. Standards Track [Page 17]
971 1.1 agc
973 1.1 agc RFC 2440 OpenPGP Message Format November 1998
974 1.1 agc
975 1.1 agc
976 1.1 agc 0x01: Signature of a canonical text document.
977 1.1 agc Typically, this means the signer owns it, created it, or
978 1.1 agc certifies that it has not been modified. The signature is
979 1.1 agc calculated over the text data with its line endings converted
980 1.1 agc to <CR><LF> and trailing blanks removed.
981 1.1 agc
982 1.1 agc 0x02: Standalone signature.
983 1.1 agc This signature is a signature of only its own subpacket
984 1.1 agc contents. It is calculated identically to a signature over a
985 1.1 agc zero-length binary document. Note that it doesn't make sense to
986 1.1 agc have a V3 standalone signature.
987 1.1 agc
988 1.1 agc 0x10: Generic certification of a User ID and Public Key packet.
989 1.1 agc The issuer of this certification does not make any particular
990 1.1 agc assertion as to how well the certifier has checked that the
991 1.1 agc owner of the key is in fact the person described by the user
992 1.1 agc ID. Note that all PGP "key signatures" are this type of
993 1.1 agc certification.
994 1.1 agc
995 1.1 agc 0x11: Persona certification of a User ID and Public Key packet.
996 1.1 agc The issuer of this certification has not done any verification
997 1.1 agc of the claim that the owner of this key is the user ID
998 1.1 agc specified.
999 1.1 agc
1000 1.1 agc 0x12: Casual certification of a User ID and Public Key packet.
1001 1.1 agc The issuer of this certification has done some casual
1002 1.1 agc verification of the claim of identity.
1003 1.1 agc
1004 1.1 agc 0x13: Positive certification of a User ID and Public Key packet.
1005 1.1 agc The issuer of this certification has done substantial
1006 1.1 agc verification of the claim of identity.
1007 1.1 agc
1008 1.1 agc Please note that the vagueness of these certification claims is
1009 1.1 agc not a flaw, but a feature of the system. Because PGP places
1010 1.1 agc final authority for validity upon the receiver of a
1011 1.1 agc certification, it may be that one authority's casual
1012 1.1 agc certification might be more rigorous than some other
1013 1.1 agc authority's positive certification. These classifications allow
1014 1.1 agc a certification authority to issue fine-grained claims.
1015 1.1 agc
1016 1.1 agc 0x18: Subkey Binding Signature
1017 1.1 agc This signature is a statement by the top-level signing key
1018 1.1 agc indicates that it owns the subkey. This signature is calculated
1019 1.1 agc directly on the subkey itself, not on any User ID or other
1020 1.1 agc packets.
1021 1.1 agc
1022 1.1 agc
1023 1.1 agc
1024 1.1 agc
1025 1.1 agc
1026 1.1 agc
1027 1.1 agc Callas, et. al. Standards Track [Page 18]
1028 1.1 agc
1030 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1031 1.1 agc
1032 1.1 agc
1033 1.1 agc 0x1F: Signature directly on a key
1034 1.1 agc This signature is calculated directly on a key. It binds the
1035 1.1 agc information in the signature subpackets to the key, and is
1036 1.1 agc appropriate to be used for subpackets that provide information
1037 1.1 agc about the key, such as the revocation key subpacket. It is also
1038 1.1 agc appropriate for statements that non-self certifiers want to
1039 1.1 agc make about the key itself, rather than the binding between a
1040 1.1 agc key and a name.
1041 1.1 agc
1042 1.1 agc 0x20: Key revocation signature
1043 1.1 agc The signature is calculated directly on the key being revoked.
1044 1.1 agc A revoked key is not to be used. Only revocation signatures by
1045 1.1 agc the key being revoked, or by an authorized revocation key,
1046 1.1 agc should be considered valid revocation signatures.
1047 1.1 agc
1048 1.1 agc 0x28: Subkey revocation signature
1049 1.1 agc The signature is calculated directly on the subkey being
1050 1.1 agc revoked. A revoked subkey is not to be used. Only revocation
1051 1.1 agc signatures by the top-level signature key that is bound to this
1052 1.1 agc subkey, or by an authorized revocation key, should be
1053 1.1 agc considered valid revocation signatures.
1054 1.1 agc
1055 1.1 agc 0x30: Certification revocation signature
1056 1.1 agc This signature revokes an earlier user ID certification
1057 1.1 agc signature (signature class 0x10 through 0x13). It should be
1058 1.1 agc issued by the same key that issued the revoked signature or an
1059 1.1 agc authorized revocation key The signature should have a later
1060 1.1 agc creation date than the signature it revokes.
1061 1.1 agc
1062 1.1 agc 0x40: Timestamp signature.
1063 1.1 agc This signature is only meaningful for the timestamp contained
1064 1.1 agc in it.
1065 1.1 agc
1066 1.1 agc 5.2.2. Version 3 Signature Packet Format
1067 1.1 agc
1068 1.1 agc The body of a version 3 Signature Packet contains:
1069 1.1 agc
1070 1.1 agc - One-octet version number (3).
1071 1.1 agc
1072 1.1 agc - One-octet length of following hashed material. MUST be 5.
1073 1.1 agc
1074 1.1 agc - One-octet signature type.
1075 1.1 agc
1076 1.1 agc - Four-octet creation time.
1077 1.1 agc
1078 1.1 agc - Eight-octet key ID of signer.
1079 1.1 agc
1080 1.1 agc - One-octet public key algorithm.
1081 1.1 agc
1082 1.1 agc
1083 1.1 agc
1084 1.1 agc Callas, et. al. Standards Track [Page 19]
1085 1.1 agc
1087 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1088 1.1 agc
1089 1.1 agc
1090 1.1 agc - One-octet hash algorithm.
1091 1.1 agc
1092 1.1 agc - Two-octet field holding left 16 bits of signed hash value.
1093 1.1 agc
1094 1.1 agc - One or more multi-precision integers comprising the signature.
1095 1.1 agc This portion is algorithm specific, as described below.
1096 1.1 agc
1097 1.1 agc The data being signed is hashed, and then the signature type and
1098 1.1 agc creation time from the signature packet are hashed (5 additional
1099 1.1 agc octets). The resulting hash value is used in the signature
1100 1.1 agc algorithm. The high 16 bits (first two octets) of the hash are
1101 1.1 agc included in the signature packet to provide a quick test to reject
1102 1.1 agc some invalid signatures.
1103 1.1 agc
1104 1.1 agc Algorithm Specific Fields for RSA signatures:
1105 1.1 agc
1106 1.1 agc - multiprecision integer (MPI) of RSA signature value m**d.
1107 1.1 agc
1108 1.1 agc Algorithm Specific Fields for DSA signatures:
1109 1.1 agc
1110 1.1 agc - MPI of DSA value r.
1111 1.1 agc
1112 1.1 agc - MPI of DSA value s.
1113 1.1 agc
1114 1.1 agc The signature calculation is based on a hash of the signed data, as
1115 1.1 agc described above. The details of the calculation are different for
1116 1.1 agc DSA signature than for RSA signatures.
1117 1.1 agc
1118 1.1 agc With RSA signatures, the hash value is encoded as described in PKCS-1
1119 1.1 agc section 10.1.2, "Data encoding", producing an ASN.1 value of type
1120 1.1 agc DigestInfo, and then padded using PKCS-1 block type 01 [RFC2313].
1121 1.1 agc This requires inserting the hash value as an octet string into an
1122 1.1 agc ASN.1 structure. The object identifier for the type of hash being
1123 1.1 agc used is included in the structure. The hexadecimal representations
1124 1.1 agc for the currently defined hash algorithms are:
1125 1.1 agc
1126 1.1 agc - MD2: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x02
1127 1.1 agc
1128 1.1 agc - MD5: 0x2A, 0x86, 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05
1129 1.1 agc
1130 1.1 agc - RIPEMD-160: 0x2B, 0x24, 0x03, 0x02, 0x01
1131 1.1 agc
1132 1.1 agc - SHA-1: 0x2B, 0x0E, 0x03, 0x02, 0x1A
1133 1.1 agc
1134 1.1 agc
1135 1.1 agc
1136 1.1 agc
1137 1.1 agc
1138 1.1 agc
1139 1.1 agc
1140 1.1 agc
1141 1.1 agc Callas, et. al. Standards Track [Page 20]
1142 1.1 agc
1144 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1145 1.1 agc
1146 1.1 agc
1147 1.1 agc The ASN.1 OIDs are:
1148 1.1 agc
1149 1.1 agc - MD2: 1.2.840.113549.2.2
1150 1.1 agc
1151 1.1 agc - MD5: 1.2.840.113549.2.5
1152 1.1 agc
1153 1.1 agc - RIPEMD-160: 1.3.36.3.2.1
1154 1.1 agc
1155 1.1 agc - SHA-1: 1.3.14.3.2.26
1156 1.1 agc
1157 1.1 agc The full hash prefixes for these are:
1158 1.1 agc
1159 1.1 agc MD2: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
1160 1.1 agc 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x02, 0x05, 0x00,
1161 1.1 agc 0x04, 0x10
1162 1.1 agc
1163 1.1 agc MD5: 0x30, 0x20, 0x30, 0x0C, 0x06, 0x08, 0x2A, 0x86,
1164 1.1 agc 0x48, 0x86, 0xF7, 0x0D, 0x02, 0x05, 0x05, 0x00,
1165 1.1 agc 0x04, 0x10
1166 1.1 agc
1167 1.1 agc RIPEMD-160: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2B, 0x24,
1168 1.1 agc 0x03, 0x02, 0x01, 0x05, 0x00, 0x04, 0x14
1169 1.1 agc
1170 1.1 agc SHA-1: 0x30, 0x21, 0x30, 0x09, 0x06, 0x05, 0x2b, 0x0E,
1171 1.1 agc 0x03, 0x02, 0x1A, 0x05, 0x00, 0x04, 0x14
1172 1.1 agc
1173 1.1 agc DSA signatures MUST use hashes with a size of 160 bits, to match q,
1174 1.1 agc the size of the group generated by the DSA key's generator value.
1175 1.1 agc The hash function result is treated as a 160 bit number and used
1176 1.1 agc directly in the DSA signature algorithm.
1177 1.1 agc
1178 1.1 agc 5.2.3. Version 4 Signature Packet Format
1179 1.1 agc
1180 1.1 agc The body of a version 4 Signature Packet contains:
1181 1.1 agc
1182 1.1 agc - One-octet version number (4).
1183 1.1 agc
1184 1.1 agc - One-octet signature type.
1185 1.1 agc
1186 1.1 agc - One-octet public key algorithm.
1187 1.1 agc
1188 1.1 agc - One-octet hash algorithm.
1189 1.1 agc
1190 1.1 agc - Two-octet scalar octet count for following hashed subpacket
1191 1.1 agc data. Note that this is the length in octets of all of the hashed
1192 1.1 agc subpackets; a pointer incremented by this number will skip over
1193 1.1 agc the hashed subpackets.
1194 1.1 agc
1195 1.1 agc
1196 1.1 agc
1197 1.1 agc
1198 1.1 agc Callas, et. al. Standards Track [Page 21]
1199 1.1 agc
1201 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1202 1.1 agc
1203 1.1 agc
1204 1.1 agc - Hashed subpacket data. (zero or more subpackets)
1205 1.1 agc
1206 1.1 agc - Two-octet scalar octet count for following unhashed subpacket
1207 1.1 agc data. Note that this is the length in octets of all of the
1208 1.1 agc unhashed subpackets; a pointer incremented by this number will
1209 1.1 agc skip over the unhashed subpackets.
1210 1.1 agc
1211 1.1 agc - Unhashed subpacket data. (zero or more subpackets)
1212 1.1 agc
1213 1.1 agc - Two-octet field holding left 16 bits of signed hash value.
1214 1.1 agc
1215 1.1 agc - One or more multi-precision integers comprising the signature.
1216 1.1 agc This portion is algorithm specific, as described above.
1217 1.1 agc
1218 1.1 agc The data being signed is hashed, and then the signature data from the
1219 1.1 agc version number through the hashed subpacket data (inclusive) is
1220 1.1 agc hashed. The resulting hash value is what is signed. The left 16 bits
1221 1.1 agc of the hash are included in the signature packet to provide a quick
1222 1.1 agc test to reject some invalid signatures.
1223 1.1 agc
1224 1.1 agc There are two fields consisting of signature subpackets. The first
1225 1.1 agc field is hashed with the rest of the signature data, while the second
1226 1.1 agc is unhashed. The second set of subpackets is not cryptographically
1227 1.1 agc protected by the signature and should include only advisory
1228 1.1 agc information.
1229 1.1 agc
1230 1.1 agc The algorithms for converting the hash function result to a signature
1231 1.1 agc are described in a section below.
1232 1.1 agc
1233 1.1 agc 5.2.3.1. Signature Subpacket Specification
1234 1.1 agc
1235 1.1 agc The subpacket fields consist of zero or more signature subpackets.
1236 1.1 agc Each set of subpackets is preceded by a two-octet scalar count of the
1237 1.1 agc length of the set of subpackets.
1238 1.1 agc
1239 1.1 agc Each subpacket consists of a subpacket header and a body. The header
1240 1.1 agc consists of:
1241 1.1 agc
1242 1.1 agc - the subpacket length (1, 2, or 5 octets)
1243 1.1 agc
1244 1.1 agc - the subpacket type (1 octet)
1245 1.1 agc
1246 1.1 agc and is followed by the subpacket specific data.
1247 1.1 agc
1248 1.1 agc The length includes the type octet but not this length. Its format is
1249 1.1 agc similar to the "new" format packet header lengths, but cannot have
1250 1.1 agc partial body lengths. That is:
1251 1.1 agc
1252 1.1 agc
1253 1.1 agc
1254 1.1 agc
1255 1.1 agc Callas, et. al. Standards Track [Page 22]
1256 1.1 agc
1258 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1259 1.1 agc
1260 1.1 agc
1261 1.1 agc if the 1st octet < 192, then
1262 1.1 agc lengthOfLength = 1
1263 1.1 agc subpacketLen = 1st_octet
1264 1.1 agc
1265 1.1 agc if the 1st octet >= 192 and < 255, then
1266 1.1 agc lengthOfLength = 2
1267 1.1 agc subpacketLen = ((1st_octet - 192) << 8) + (2nd_octet) + 192
1268 1.1 agc
1269 1.1 agc if the 1st octet = 255, then
1270 1.1 agc lengthOfLength = 5
1271 1.1 agc subpacket length = [four-octet scalar starting at 2nd_octet]
1272 1.1 agc
1273 1.1 agc The value of the subpacket type octet may be:
1274 1.1 agc
1275 1.1 agc 2 = signature creation time
1276 1.1 agc 3 = signature expiration time
1277 1.1 agc 4 = exportable certification
1278 1.1 agc 5 = trust signature
1279 1.1 agc 6 = regular expression
1280 1.1 agc 7 = revocable
1281 1.1 agc 9 = key expiration time
1282 1.1 agc 10 = placeholder for backward compatibility
1283 1.1 agc 11 = preferred symmetric algorithms
1284 1.1 agc 12 = revocation key
1285 1.1 agc 16 = issuer key ID
1286 1.1 agc 20 = notation data
1287 1.1 agc 21 = preferred hash algorithms
1288 1.1 agc 22 = preferred compression algorithms
1289 1.1 agc 23 = key server preferences
1290 1.1 agc 24 = preferred key server
1291 1.1 agc 25 = primary user id
1292 1.1 agc 26 = policy URL
1293 1.1 agc 27 = key flags
1294 1.1 agc 28 = signer's user id
1295 1.1 agc 29 = reason for revocation
1296 1.1 agc 100 to 110 = internal or user-defined
1297 1.1 agc
1298 1.1 agc An implementation SHOULD ignore any subpacket of a type that it does
1299 1.1 agc not recognize.
1300 1.1 agc
1301 1.1 agc Bit 7 of the subpacket type is the "critical" bit. If set, it
1302 1.1 agc denotes that the subpacket is one that is critical for the evaluator
1303 1.1 agc of the signature to recognize. If a subpacket is encountered that is
1304 1.1 agc marked critical but is unknown to the evaluating software, the
1305 1.1 agc evaluator SHOULD consider the signature to be in error.
1306 1.1 agc
1307 1.1 agc
1308 1.1 agc
1309 1.1 agc
1310 1.1 agc
1311 1.1 agc
1312 1.1 agc Callas, et. al. Standards Track [Page 23]
1313 1.1 agc
1315 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1316 1.1 agc
1317 1.1 agc
1318 1.1 agc An evaluator may "recognize" a subpacket, but not implement it. The
1319 1.1 agc purpose of the critical bit is to allow the signer to tell an
1320 1.1 agc evaluator that it would prefer a new, unknown feature to generate an
1321 1.1 agc error than be ignored.
1322 1.1 agc
1323 1.1 agc Implementations SHOULD implement "preferences".
1324 1.1 agc
1325 1.1 agc 5.2.3.2. Signature Subpacket Types
1326 1.1 agc
1327 1.1 agc A number of subpackets are currently defined. Some subpackets apply
1328 1.1 agc to the signature itself and some are attributes of the key.
1329 1.1 agc Subpackets that are found on a self-signature are placed on a user id
1330 1.1 agc certification made by the key itself. Note that a key may have more
1331 1.1 agc than one user id, and thus may have more than one self-signature, and
1332 1.1 agc differing subpackets.
1333 1.1 agc
1334 1.1 agc A self-signature is a binding signature made by the key the signature
1335 1.1 agc refers to. There are three types of self-signatures, the
1336 1.1 agc certification signatures (types 0x10-0x13), the direct-key signature
1337 1.1 agc (type 0x1f), and the subkey binding signature (type 0x18). For
1338 1.1 agc certification self-signatures, each user ID may have a self-
1339 1.1 agc signature, and thus different subpackets in those self-signatures.
1340 1.1 agc For subkey binding signatures, each subkey in fact has a self-
1341 1.1 agc signature. Subpackets that appear in a certification self-signature
1342 1.1 agc apply to the username, and subpackets that appear in the subkey
1343 1.1 agc self-signature apply to the subkey. Lastly, subpackets on the direct
1344 1.1 agc key signature apply to the entire key.
1345 1.1 agc
1346 1.1 agc Implementing software should interpret a self-signature's preference
1347 1.1 agc subpackets as narrowly as possible. For example, suppose a key has
1348 1.1 agc two usernames, Alice and Bob. Suppose that Alice prefers the
1349 1.1 agc symmetric algorithm CAST5, and Bob prefers IDEA or Triple-DES. If the
1350 1.1 agc software locates this key via Alice's name, then the preferred
1351 1.1 agc algorithm is CAST5, if software locates the key via Bob's name, then
1352 1.1 agc the preferred algorithm is IDEA. If the key is located by key id,
1353 1.1 agc then algorithm of the default user id of the key provides the default
1354 1.1 agc symmetric algorithm.
1355 1.1 agc
1356 1.1 agc A subpacket may be found either in the hashed or unhashed subpacket
1357 1.1 agc sections of a signature. If a subpacket is not hashed, then the
1358 1.1 agc information in it cannot be considered definitive because it is not
1359 1.1 agc part of the signature proper.
1360 1.1 agc
1361 1.1 agc
1362 1.1 agc
1363 1.1 agc
1364 1.1 agc
1365 1.1 agc
1366 1.1 agc
1367 1.1 agc
1368 1.1 agc
1369 1.1 agc Callas, et. al. Standards Track [Page 24]
1370 1.1 agc
1372 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1373 1.1 agc
1374 1.1 agc
1375 1.1 agc 5.2.3.3. Signature creation time
1376 1.1 agc
1377 1.1 agc (4 octet time field)
1378 1.1 agc
1379 1.1 agc The time the signature was made.
1380 1.1 agc
1381 1.1 agc MUST be present in the hashed area.
1382 1.1 agc
1383 1.1 agc 5.2.3.4. Issuer
1384 1.1 agc
1385 1.1 agc (8 octet key ID)
1386 1.1 agc
1387 1.1 agc The OpenPGP key ID of the key issuing the signature.
1388 1.1 agc
1389 1.1 agc 5.2.3.5. Key expiration time
1390 1.1 agc
1391 1.1 agc (4 octet time field)
1392 1.1 agc
1393 1.1 agc The validity period of the key. This is the number of seconds after
1394 1.1 agc the key creation time that the key expires. If this is not present
1395 1.1 agc or has a value of zero, the key never expires. This is found only on
1396 1.1 agc a self-signature.
1397 1.1 agc
1398 1.1 agc 5.2.3.6. Preferred symmetric algorithms
1399 1.1 agc
1400 1.1 agc (sequence of one-octet values)
1401 1.1 agc
1402 1.1 agc Symmetric algorithm numbers that indicate which algorithms the key
1403 1.1 agc holder prefers to use. The subpacket body is an ordered list of
1404 1.1 agc octets with the most preferred listed first. It is assumed that only
1405 1.1 agc algorithms listed are supported by the recipient's software.
1406 1.1 agc Algorithm numbers in section 9. This is only found on a self-
1407 1.1 agc signature.
1408 1.1 agc
1409 1.1 agc 5.2.3.7. Preferred hash algorithms
1410 1.1 agc
1411 1.1 agc (array of one-octet values)
1412 1.1 agc
1413 1.1 agc Message digest algorithm numbers that indicate which algorithms the
1414 1.1 agc key holder prefers to receive. Like the preferred symmetric
1415 1.1 agc algorithms, the list is ordered. Algorithm numbers are in section 6.
1416 1.1 agc This is only found on a self-signature.
1417 1.1 agc
1418 1.1 agc
1419 1.1 agc
1420 1.1 agc
1421 1.1 agc
1422 1.1 agc
1423 1.1 agc
1424 1.1 agc
1425 1.1 agc
1426 1.1 agc Callas, et. al. Standards Track [Page 25]
1427 1.1 agc
1429 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1430 1.1 agc
1431 1.1 agc
1432 1.1 agc 5.2.3.8. Preferred compression algorithms
1433 1.1 agc
1434 1.1 agc (array of one-octet values)
1435 1.1 agc
1436 1.1 agc Compression algorithm numbers that indicate which algorithms the key
1437 1.1 agc holder prefers to use. Like the preferred symmetric algorithms, the
1438 1.1 agc list is ordered. Algorithm numbers are in section 6. If this
1439 1.1 agc subpacket is not included, ZIP is preferred. A zero denotes that
1440 1.1 agc uncompressed data is preferred; the key holder's software might have
1441 1.1 agc no compression software in that implementation. This is only found on
1442 1.1 agc a self-signature.
1443 1.1 agc
1444 1.1 agc 5.2.3.9. Signature expiration time
1445 1.1 agc
1446 1.1 agc (4 octet time field)
1447 1.1 agc
1448 1.1 agc The validity period of the signature. This is the number of seconds
1449 1.1 agc after the signature creation time that the signature expires. If this
1450 1.1 agc is not present or has a value of zero, it never expires.
1451 1.1 agc
1452 1.1 agc 5.2.3.10. Exportable Certification
1453 1.1 agc
1454 1.1 agc (1 octet of exportability, 0 for not, 1 for exportable)
1455 1.1 agc
1456 1.1 agc This subpacket denotes whether a certification signature is
1457 1.1 agc "exportable", to be used by other users than the signature's issuer.
1458 1.1 agc The packet body contains a boolean flag indicating whether the
1459 1.1 agc signature is exportable. If this packet is not present, the
1460 1.1 agc certification is exportable; it is equivalent to a flag containing a
1461 1.1 agc 1.
1462 1.1 agc
1463 1.1 agc Non-exportable, or "local", certifications are signatures made by a
1464 1.1 agc user to mark a key as valid within that user's implementation only.
1465 1.1 agc Thus, when an implementation prepares a user's copy of a key for
1466 1.1 agc transport to another user (this is the process of "exporting" the
1467 1.1 agc key), any local certification signatures are deleted from the key.
1468 1.1 agc
1469 1.1 agc The receiver of a transported key "imports" it, and likewise trims
1470 1.1 agc any local certifications. In normal operation, there won't be any,
1471 1.1 agc assuming the import is performed on an exported key. However, there
1472 1.1 agc are instances where this can reasonably happen. For example, if an
1473 1.1 agc implementation allows keys to be imported from a key database in
1474 1.1 agc addition to an exported key, then this situation can arise.
1475 1.1 agc
1476 1.1 agc Some implementations do not represent the interest of a single user
1477 1.1 agc (for example, a key server). Such implementations always trim local
1478 1.1 agc certifications from any key they handle.
1479 1.1 agc
1480 1.1 agc
1481 1.1 agc
1482 1.1 agc
1483 1.1 agc Callas, et. al. Standards Track [Page 26]
1484 1.1 agc
1486 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1487 1.1 agc
1488 1.1 agc
1489 1.1 agc 5.2.3.11. Revocable
1490 1.1 agc
1491 1.1 agc (1 octet of revocability, 0 for not, 1 for revocable)
1492 1.1 agc
1493 1.1 agc Signature's revocability status. Packet body contains a boolean flag
1494 1.1 agc indicating whether the signature is revocable. Signatures that are
1495 1.1 agc not revocable have any later revocation signatures ignored. They
1496 1.1 agc represent a commitment by the signer that he cannot revoke his
1497 1.1 agc signature for the life of his key. If this packet is not present,
1498 1.1 agc the signature is revocable.
1499 1.1 agc
1500 1.1 agc 5.2.3.12. Trust signature
1501 1.1 agc
1502 1.1 agc (1 octet "level" (depth), 1 octet of trust amount)
1503 1.1 agc
1504 1.1 agc Signer asserts that the key is not only valid, but also trustworthy,
1505 1.1 agc at the specified level. Level 0 has the same meaning as an ordinary
1506 1.1 agc validity signature. Level 1 means that the signed key is asserted to
1507 1.1 agc be a valid trusted introducer, with the 2nd octet of the body
1508 1.1 agc specifying the degree of trust. Level 2 means that the signed key is
1509 1.1 agc asserted to be trusted to issue level 1 trust signatures, i.e. that
1510 1.1 agc it is a "meta introducer". Generally, a level n trust signature
1511 1.1 agc asserts that a key is trusted to issue level n-1 trust signatures.
1512 1.1 agc The trust amount is in a range from 0-255, interpreted such that
1513 1.1 agc values less than 120 indicate partial trust and values of 120 or
1514 1.1 agc greater indicate complete trust. Implementations SHOULD emit values
1515 1.1 agc of 60 for partial trust and 120 for complete trust.
1516 1.1 agc
1517 1.1 agc 5.2.3.13. Regular expression
1518 1.1 agc
1519 1.1 agc (null-terminated regular expression)
1520 1.1 agc
1521 1.1 agc Used in conjunction with trust signature packets (of level > 0) to
1522 1.1 agc limit the scope of trust that is extended. Only signatures by the
1523 1.1 agc target key on user IDs that match the regular expression in the body
1524 1.1 agc of this packet have trust extended by the trust signature subpacket.
1525 1.1 agc The regular expression uses the same syntax as the Henry Spencer's
1526 1.1 agc "almost public domain" regular expression package. A description of
1527 1.1 agc the syntax is found in a section below.
1528 1.1 agc
1529 1.1 agc 5.2.3.14. Revocation key
1530 1.1 agc
1531 1.1 agc (1 octet of class, 1 octet of algid, 20 octets of fingerprint)
1532 1.1 agc
1533 1.1 agc Authorizes the specified key to issue revocation signatures for this
1534 1.1 agc key. Class octet must have bit 0x80 set. If the bit 0x40 is set,
1535 1.1 agc then this means that the revocation information is sensitive. Other
1536 1.1 agc bits are for future expansion to other kinds of authorizations. This
1537 1.1 agc
1538 1.1 agc
1539 1.1 agc
1540 1.1 agc Callas, et. al. Standards Track [Page 27]
1541 1.1 agc
1543 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1544 1.1 agc
1545 1.1 agc
1546 1.1 agc is found on a self-signature.
1547 1.1 agc
1548 1.1 agc If the "sensitive" flag is set, the keyholder feels this subpacket
1549 1.1 agc contains private trust information that describes a real-world
1550 1.1 agc sensitive relationship. If this flag is set, implementations SHOULD
1551 1.1 agc NOT export this signature to other users except in cases where the
1552 1.1 agc data needs to be available: when the signature is being sent to the
1553 1.1 agc designated revoker, or when it is accompanied by a revocation
1554 1.1 agc signature from that revoker. Note that it may be appropriate to
1555 1.1 agc isolate this subpacket within a separate signature so that it is not
1556 1.1 agc combined with other subpackets that need to be exported.
1557 1.1 agc
1558 1.1 agc 5.2.3.15. Notation Data
1559 1.1 agc
1560 1.1 agc (4 octets of flags, 2 octets of name length (M),
1561 1.1 agc 2 octets of value length (N),
1562 1.1 agc M octets of name data,
1563 1.1 agc N octets of value data)
1564 1.1 agc
1565 1.1 agc This subpacket describes a "notation" on the signature that the
1566 1.1 agc issuer wishes to make. The notation has a name and a value, each of
1567 1.1 agc which are strings of octets. There may be more than one notation in a
1568 1.1 agc signature. Notations can be used for any extension the issuer of the
1569 1.1 agc signature cares to make. The "flags" field holds four octets of
1570 1.1 agc flags.
1571 1.1 agc
1572 1.1 agc All undefined flags MUST be zero. Defined flags are:
1573 1.1 agc
1574 1.1 agc First octet: 0x80 = human-readable. This note is text, a note
1575 1.1 agc from one person to another, and has no
1576 1.1 agc meaning to software.
1577 1.1 agc Other octets: none.
1578 1.1 agc
1579 1.1 agc 5.2.3.16. Key server preferences
1580 1.1 agc
1581 1.1 agc (N octets of flags)
1582 1.1 agc
1583 1.1 agc This is a list of flags that indicate preferences that the key holder
1584 1.1 agc has about how the key is handled on a key server. All undefined flags
1585 1.1 agc MUST be zero.
1586 1.1 agc
1587 1.1 agc First octet: 0x80 = No-modify
1588 1.1 agc the key holder requests that this key only be modified or updated
1589 1.1 agc by the key holder or an administrator of the key server.
1590 1.1 agc
1591 1.1 agc This is found only on a self-signature.
1592 1.1 agc
1593 1.1 agc
1594 1.1 agc
1595 1.1 agc
1596 1.1 agc
1597 1.1 agc Callas, et. al. Standards Track [Page 28]
1598 1.1 agc
1600 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1601 1.1 agc
1602 1.1 agc
1603 1.1 agc 5.2.3.17. Preferred key server
1604 1.1 agc
1605 1.1 agc (String)
1606 1.1 agc
1607 1.1 agc This is a URL of a key server that the key holder prefers be used for
1608 1.1 agc updates. Note that keys with multiple user ids can have a preferred
1609 1.1 agc key server for each user id. Note also that since this is a URL, the
1610 1.1 agc key server can actually be a copy of the key retrieved by ftp, http,
1611 1.1 agc finger, etc.
1612 1.1 agc
1613 1.1 agc 5.2.3.18. Primary user id
1614 1.1 agc
1615 1.1 agc (1 octet, boolean)
1616 1.1 agc
1617 1.1 agc This is a flag in a user id's self signature that states whether this
1618 1.1 agc user id is the main user id for this key. It is reasonable for an
1619 1.1 agc implementation to resolve ambiguities in preferences, etc. by
1620 1.1 agc referring to the primary user id. If this flag is absent, its value
1621 1.1 agc is zero. If more than one user id in a key is marked as primary, the
1622 1.1 agc implementation may resolve the ambiguity in any way it sees fit.
1623 1.1 agc
1624 1.1 agc 5.2.3.19. Policy URL
1625 1.1 agc
1626 1.1 agc (String)
1627 1.1 agc
1628 1.1 agc This subpacket contains a URL of a document that describes the policy
1629 1.1 agc that the signature was issued under.
1630 1.1 agc
1631 1.1 agc 5.2.3.20. Key Flags
1632 1.1 agc
1633 1.1 agc (Octet string)
1634 1.1 agc
1635 1.1 agc This subpacket contains a list of binary flags that hold information
1636 1.1 agc about a key. It is a string of octets, and an implementation MUST NOT
1637 1.1 agc assume a fixed size. This is so it can grow over time. If a list is
1638 1.1 agc shorter than an implementation expects, the unstated flags are
1639 1.1 agc considered to be zero. The defined flags are:
1640 1.1 agc
1641 1.1 agc First octet:
1642 1.1 agc
1643 1.1 agc 0x01 - This key may be used to certify other keys.
1644 1.1 agc
1645 1.1 agc 0x02 - This key may be used to sign data.
1646 1.1 agc
1647 1.1 agc 0x04 - This key may be used to encrypt communications.
1648 1.1 agc
1649 1.1 agc 0x08 - This key may be used to encrypt storage.
1650 1.1 agc
1651 1.1 agc
1652 1.1 agc
1653 1.1 agc
1654 1.1 agc Callas, et. al. Standards Track [Page 29]
1655 1.1 agc
1657 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1658 1.1 agc
1659 1.1 agc
1660 1.1 agc 0x10 - The private component of this key may have been split by a
1661 1.1 agc secret-sharing mechanism.
1662 1.1 agc
1663 1.1 agc 0x80 - The private component of this key may be in the possession
1664 1.1 agc of more than one person.
1665 1.1 agc
1666 1.1 agc Usage notes:
1667 1.1 agc
1668 1.1 agc The flags in this packet may appear in self-signatures or in
1669 1.1 agc certification signatures. They mean different things depending on who
1670 1.1 agc is making the statement -- for example, a certification signature
1671 1.1 agc that has the "sign data" flag is stating that the certification is
1672 1.1 agc for that use. On the other hand, the "communications encryption" flag
1673 1.1 agc in a self-signature is stating a preference that a given key be used
1674 1.1 agc for communications. Note however, that it is a thorny issue to
1675 1.1 agc determine what is "communications" and what is "storage." This
1676 1.1 agc decision is left wholly up to the implementation; the authors of this
1677 1.1 agc document do not claim any special wisdom on the issue, and realize
1678 1.1 agc that accepted opinion may change.
1679 1.1 agc
1680 1.1 agc The "split key" (0x10) and "group key" (0x80) flags are placed on a
1681 1.1 agc self-signature only; they are meaningless on a certification
1682 1.1 agc signature. They SHOULD be placed only on a direct-key signature (type
1683 1.1 agc 0x1f) or a subkey signature (type 0x18), one that refers to the key
1684 1.1 agc the flag applies to.
1685 1.1 agc
1686 1.1 agc 5.2.3.21. Signer's User ID
1687 1.1 agc
1688 1.1 agc This subpacket allows a keyholder to state which user id is
1689 1.1 agc responsible for the signing. Many keyholders use a single key for
1690 1.1 agc different purposes, such as business communications as well as
1691 1.1 agc personal communications. This subpacket allows such a keyholder to
1692 1.1 agc state which of their roles is making a signature.
1693 1.1 agc
1694 1.1 agc 5.2.3.22. Reason for Revocation
1695 1.1 agc
1696 1.1 agc (1 octet of revocation code, N octets of reason string)
1697 1.1 agc
1698 1.1 agc This subpacket is used only in key revocation and certification
1699 1.1 agc revocation signatures. It describes the reason why the key or
1700 1.1 agc certificate was revoked.
1701 1.1 agc
1702 1.1 agc The first octet contains a machine-readable code that denotes the
1703 1.1 agc reason for the revocation:
1704 1.1 agc
1705 1.1 agc
1706 1.1 agc
1707 1.1 agc
1708 1.1 agc
1709 1.1 agc
1710 1.1 agc
1711 1.1 agc Callas, et. al. Standards Track [Page 30]
1712 1.1 agc
1714 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1715 1.1 agc
1716 1.1 agc
1717 1.1 agc 0x00 - No reason specified (key revocations or cert revocations)
1718 1.1 agc 0x01 - Key is superceded (key revocations)
1719 1.1 agc 0x02 - Key material has been compromised (key revocations)
1720 1.1 agc 0x03 - Key is no longer used (key revocations)
1721 1.1 agc 0x20 - User id information is no longer valid (cert revocations)
1722 1.1 agc
1723 1.1 agc Following the revocation code is a string of octets which gives
1724 1.1 agc information about the reason for revocation in human-readable form
1725 1.1 agc (UTF-8). The string may be null, that is, of zero length. The length
1726 1.1 agc of the subpacket is the length of the reason string plus one.
1727 1.1 agc
1728 1.1 agc 5.2.4. Computing Signatures
1729 1.1 agc
1730 1.1 agc All signatures are formed by producing a hash over the signature
1731 1.1 agc data, and then using the resulting hash in the signature algorithm.
1732 1.1 agc
1733 1.1 agc The signature data is simple to compute for document signatures
1734 1.1 agc (types 0x00 and 0x01), for which the document itself is the data.
1735 1.1 agc For standalone signatures, this is a null string.
1736 1.1 agc
1737 1.1 agc When a signature is made over a key, the hash data starts with the
1738 1.1 agc octet 0x99, followed by a two-octet length of the key, and then body
1739 1.1 agc of the key packet. (Note that this is an old-style packet header for
1740 1.1 agc a key packet with two-octet length.) A subkey signature (type 0x18)
1741 1.1 agc then hashes the subkey, using the same format as the main key. Key
1742 1.1 agc revocation signatures (types 0x20 and 0x28) hash only the key being
1743 1.1 agc revoked.
1744 1.1 agc
1745 1.1 agc A certification signature (type 0x10 through 0x13) hashes the user id
1746 1.1 agc being bound to the key into the hash context after the above data. A
1747 1.1 agc V3 certification hashes the contents of the name packet, without any
1748 1.1 agc header. A V4 certification hashes the constant 0xb4 (which is an
1749 1.1 agc old-style packet header with the length-of-length set to zero), a
1750 1.1 agc four-octet number giving the length of the username, and then the
1751 1.1 agc username data.
1752 1.1 agc
1753 1.1 agc Once the data body is hashed, then a trailer is hashed. A V3
1754 1.1 agc signature hashes five octets of the packet body, starting from the
1755 1.1 agc signature type field. This data is the signature type, followed by
1756 1.1 agc the four-octet signature time. A V4 signature hashes the packet body
1757 1.1 agc starting from its first field, the version number, through the end of
1758 1.1 agc the hashed subpacket data. Thus, the fields hashed are the signature
1759 1.1 agc version, the signature type, the public key algorithm, the hash
1760 1.1 agc algorithm, the hashed subpacket length, and the hashed subpacket
1761 1.1 agc body.
1762 1.1 agc
1763 1.1 agc
1764 1.1 agc
1765 1.1 agc
1766 1.1 agc
1767 1.1 agc
1768 1.1 agc Callas, et. al. Standards Track [Page 31]
1769 1.1 agc
1771 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1772 1.1 agc
1773 1.1 agc
1774 1.1 agc V4 signatures also hash in a final trailer of six octets: the version
1775 1.1 agc of the signature packet, i.e. 0x04; 0xFF; a four-octet, big-endian
1776 1.1 agc number that is the length of the hashed data from the signature
1777 1.1 agc packet (note that this number does not include these final six
1778 1.1 agc octets.
1779 1.1 agc
1780 1.1 agc After all this has been hashed, the resulting hash field is used in
1781 1.1 agc the signature algorithm, and placed at the end of the signature
1782 1.1 agc packet.
1783 1.1 agc
1784 1.1 agc 5.2.4.1. Subpacket Hints
1785 1.1 agc
1786 1.1 agc An implementation SHOULD put the two mandatory subpackets, creation
1787 1.1 agc time and issuer, as the first subpackets in the subpacket list,
1788 1.1 agc simply to make it easier for the implementer to find them.
1789 1.1 agc
1790 1.1 agc It is certainly possible for a signature to contain conflicting
1791 1.1 agc information in subpackets. For example, a signature may contain
1792 1.1 agc multiple copies of a preference or multiple expiration times. In most
1793 1.1 agc cases, an implementation SHOULD use the last subpacket in the
1794 1.1 agc signature, but MAY use any conflict resolution scheme that makes more
1795 1.1 agc sense. Please note that we are intentionally leaving conflict
1796 1.1 agc resolution to the implementer; most conflicts are simply syntax
1797 1.1 agc errors, and the wishy-washy language here allows a receiver to be
1798 1.1 agc generous in what they accept, while putting pressure on a creator to
1799 1.1 agc be stingy in what they generate.
1800 1.1 agc
1801 1.1 agc Some apparent conflicts may actually make sense -- for example,
1802 1.1 agc suppose a keyholder has an V3 key and a V4 key that share the same
1803 1.1 agc RSA key material. Either of these keys can verify a signature created
1804 1.1 agc by the other, and it may be reasonable for a signature to contain an
1805 1.1 agc issuer subpacket for each key, as a way of explicitly tying those
1806 1.1 agc keys to the signature.
1807 1.1 agc
1808 1.1 agc 5.3. Symmetric-Key Encrypted Session-Key Packets (Tag 3)
1809 1.1 agc
1810 1.1 agc The Symmetric-Key Encrypted Session Key packet holds the symmetric-
1811 1.1 agc key encryption of a session key used to encrypt a message. Zero or
1812 1.1 agc more Encrypted Session Key packets and/or Symmetric-Key Encrypted
1813 1.1 agc Session Key packets may precede a Symmetrically Encrypted Data Packet
1814 1.1 agc that holds an encrypted message. The message is encrypted with a
1815 1.1 agc session key, and the session key is itself encrypted and stored in
1816 1.1 agc the Encrypted Session Key packet or the Symmetric-Key Encrypted
1817 1.1 agc Session Key packet.
1818 1.1 agc
1819 1.1 agc If the Symmetrically Encrypted Data Packet is preceded by one or more
1820 1.1 agc Symmetric-Key Encrypted Session Key packets, each specifies a
1821 1.1 agc passphrase that may be used to decrypt the message. This allows a
1822 1.1 agc
1823 1.1 agc
1824 1.1 agc
1825 1.1 agc Callas, et. al. Standards Track [Page 32]
1826 1.1 agc
1828 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1829 1.1 agc
1830 1.1 agc
1831 1.1 agc message to be encrypted to a number of public keys, and also to one
1832 1.1 agc or more pass phrases. This packet type is new, and is not generated
1833 1.1 agc by PGP 2.x or PGP 5.0.
1834 1.1 agc
1835 1.1 agc The body of this packet consists of:
1836 1.1 agc
1837 1.1 agc - A one-octet version number. The only currently defined version
1838 1.1 agc is 4.
1839 1.1 agc
1840 1.1 agc - A one-octet number describing the symmetric algorithm used.
1841 1.1 agc
1842 1.1 agc - A string-to-key (S2K) specifier, length as defined above.
1843 1.1 agc
1844 1.1 agc - Optionally, the encrypted session key itself, which is decrypted
1845 1.1 agc with the string-to-key object.
1846 1.1 agc
1847 1.1 agc If the encrypted session key is not present (which can be detected on
1848 1.1 agc the basis of packet length and S2K specifier size), then the S2K
1849 1.1 agc algorithm applied to the passphrase produces the session key for
1850 1.1 agc decrypting the file, using the symmetric cipher algorithm from the
1851 1.1 agc Symmetric-Key Encrypted Session Key packet.
1852 1.1 agc
1853 1.1 agc If the encrypted session key is present, the result of applying the
1854 1.1 agc S2K algorithm to the passphrase is used to decrypt just that
1855 1.1 agc encrypted session key field, using CFB mode with an IV of all zeros.
1856 1.1 agc The decryption result consists of a one-octet algorithm identifier
1857 1.1 agc that specifies the symmetric-key encryption algorithm used to encrypt
1858 1.1 agc the following Symmetrically Encrypted Data Packet, followed by the
1859 1.1 agc session key octets themselves.
1860 1.1 agc
1861 1.1 agc Note: because an all-zero IV is used for this decryption, the S2K
1862 1.1 agc specifier MUST use a salt value, either a Salted S2K or an Iterated-
1863 1.1 agc Salted S2K. The salt value will insure that the decryption key is
1864 1.1 agc not repeated even if the passphrase is reused.
1865 1.1 agc
1866 1.1 agc 5.4. One-Pass Signature Packets (Tag 4)
1867 1.1 agc
1868 1.1 agc The One-Pass Signature packet precedes the signed data and contains
1869 1.1 agc enough information to allow the receiver to begin calculating any
1870 1.1 agc hashes needed to verify the signature. It allows the Signature
1871 1.1 agc Packet to be placed at the end of the message, so that the signer can
1872 1.1 agc compute the entire signed message in one pass.
1873 1.1 agc
1874 1.1 agc A One-Pass Signature does not interoperate with PGP 2.6.x or earlier.
1875 1.1 agc
1876 1.1 agc The body of this packet consists of:
1877 1.1 agc
1878 1.1 agc
1879 1.1 agc
1880 1.1 agc
1881 1.1 agc
1882 1.1 agc Callas, et. al. Standards Track [Page 33]
1883 1.1 agc
1885 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1886 1.1 agc
1887 1.1 agc
1888 1.1 agc - A one-octet version number. The current version is 3.
1889 1.1 agc
1890 1.1 agc - A one-octet signature type. Signature types are described in
1891 1.1 agc section 5.2.1.
1892 1.1 agc
1893 1.1 agc - A one-octet number describing the hash algorithm used.
1894 1.1 agc
1895 1.1 agc - A one-octet number describing the public key algorithm used.
1896 1.1 agc
1897 1.1 agc - An eight-octet number holding the key ID of the signing key.
1898 1.1 agc
1899 1.1 agc - A one-octet number holding a flag showing whether the signature
1900 1.1 agc is nested. A zero value indicates that the next packet is
1901 1.1 agc another One-Pass Signature packet that describes another
1902 1.1 agc signature to be applied to the same message data.
1903 1.1 agc
1904 1.1 agc Note that if a message contains more than one one-pass signature,
1905 1.1 agc then the signature packets bracket the message; that is, the first
1906 1.1 agc signature packet after the message corresponds to the last one-pass
1907 1.1 agc packet and the final signature packet corresponds to the first one-
1908 1.1 agc pass packet.
1909 1.1 agc
1910 1.1 agc 5.5. Key Material Packet
1911 1.1 agc
1912 1.1 agc A key material packet contains all the information about a public or
1913 1.1 agc private key. There are four variants of this packet type, and two
1914 1.1 agc major versions. Consequently, this section is complex.
1915 1.1 agc
1916 1.1 agc 5.5.1. Key Packet Variants
1917 1.1 agc
1918 1.1 agc 5.5.1.1. Public Key Packet (Tag 6)
1919 1.1 agc
1920 1.1 agc A Public Key packet starts a series of packets that forms an OpenPGP
1921 1.1 agc key (sometimes called an OpenPGP certificate).
1922 1.1 agc
1923 1.1 agc 5.5.1.2. Public Subkey Packet (Tag 14)
1924 1.1 agc
1925 1.1 agc A Public Subkey packet (tag 14) has exactly the same format as a
1926 1.1 agc Public Key packet, but denotes a subkey. One or more subkeys may be
1927 1.1 agc associated with a top-level key. By convention, the top-level key
1928 1.1 agc provides signature services, and the subkeys provide encryption
1929 1.1 agc services.
1930 1.1 agc
1931 1.1 agc Note: in PGP 2.6.x, tag 14 was intended to indicate a comment packet.
1932 1.1 agc This tag was selected for reuse because no previous version of PGP
1933 1.1 agc ever emitted comment packets but they did properly ignore them.
1934 1.1 agc Public Subkey packets are ignored by PGP 2.6.x and do not cause it to
1935 1.1 agc fail, providing a limited degree of backward compatibility.
1936 1.1 agc
1937 1.1 agc
1938 1.1 agc
1939 1.1 agc Callas, et. al. Standards Track [Page 34]
1940 1.1 agc
1942 1.1 agc RFC 2440 OpenPGP Message Format November 1998
1943 1.1 agc
1944 1.1 agc
1945 1.1 agc 5.5.1.3. Secret Key Packet (Tag 5)
1946 1.1 agc
1947 1.1 agc A Secret Key packet contains all the information that is found in a
1948 1.1 agc Public Key packet, including the public key material, but also
1949 1.1 agc includes the secret key material after all the public key fields.
1950 1.1 agc
1951 1.1 agc 5.5.1.4. Secret Subkey Packet (Tag 7)
1952 1.1 agc
1953 1.1 agc A Secret Subkey packet (tag 7) is the subkey analog of the Secret Key
1954 1.1 agc packet, and has exactly the same format.
1955 1.1 agc
1956 1.1 agc 5.5.2. Public Key Packet Formats
1957 1.1 agc
1958 1.1 agc There are two versions of key-material packets. Version 3 packets
1959 1.1 agc were first generated by PGP 2.6. Version 2 packets are identical in
1960 1.1 agc format to Version 3 packets, but are generated by PGP 2.5 or before.
1961 1.1 agc V2 packets are deprecated and they MUST NOT be generated. PGP 5.0
1962 1.1 agc introduced version 4 packets, with new fields and semantics. PGP
1963 1.1 agc 2.6.x will not accept key-material packets with versions greater than
1964 1.1 agc 3.
1965 1.1 agc
1966 1.1 agc OpenPGP implementations SHOULD create keys with version 4 format. An
1967 1.1 agc implementation MAY generate a V3 key to ensure interoperability with
1968 1.1 agc old software; note, however, that V4 keys correct some security
1969 1.1 agc deficiencies in V3 keys. These deficiencies are described below. An
1970 1.1 agc implementation MUST NOT create a V3 key with a public key algorithm
1971 1.1 agc other than RSA.
1972 1.1 agc
1973 1.1 agc A version 3 public key or public subkey packet contains:
1974 1.1 agc
1975 1.1 agc - A one-octet version number (3).
1976 1.1 agc
1977 1.1 agc - A four-octet number denoting the time that the key was created.
1978 1.1 agc
1979 1.1 agc - A two-octet number denoting the time in days that this key is
1980 1.1 agc valid. If this number is zero, then it does not expire.
1981 1.1 agc
1982 1.1 agc - A one-octet number denoting the public key algorithm of this key
1983 1.1 agc
1984 1.1 agc - A series of multi-precision integers comprising the key
1985 1.1 agc material:
1986 1.1 agc
1987 1.1 agc - a multiprecision integer (MPI) of RSA public modulus n;
1988 1.1 agc
1989 1.1 agc - an MPI of RSA public encryption exponent e.
1990 1.1 agc
1991 1.1 agc
1992 1.1 agc
1993 1.1 agc
1994 1.1 agc
1995 1.1 agc
1996 1.1 agc Callas, et. al. Standards Track [Page 35]
1997 1.1 agc
1999 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2000 1.1 agc
2001 1.1 agc
2002 1.1 agc V3 keys SHOULD only be used for backward compatibility because of
2003 1.1 agc three weaknesses in them. First, it is relatively easy to construct a
2004 1.1 agc V3 key that has the same key ID as any other key because the key ID
2005 1.1 agc is simply the low 64 bits of the public modulus. Secondly, because
2006 1.1 agc the fingerprint of a V3 key hashes the key material, but not its
2007 1.1 agc length, which increases the opportunity for fingerprint collisions.
2008 1.1 agc Third, there are minor weaknesses in the MD5 hash algorithm that make
2009 1.1 agc developers prefer other algorithms. See below for a fuller discussion
2010 1.1 agc of key IDs and fingerprints.
2011 1.1 agc
2012 1.1 agc The version 4 format is similar to the version 3 format except for
2013 1.1 agc the absence of a validity period. This has been moved to the
2014 1.1 agc signature packet. In addition, fingerprints of version 4 keys are
2015 1.1 agc calculated differently from version 3 keys, as described in section
2016 1.1 agc "Enhanced Key Formats."
2017 1.1 agc
2018 1.1 agc A version 4 packet contains:
2019 1.1 agc
2020 1.1 agc - A one-octet version number (4).
2021 1.1 agc
2022 1.1 agc - A four-octet number denoting the time that the key was created.
2023 1.1 agc
2024 1.1 agc - A one-octet number denoting the public key algorithm of this key
2025 1.1 agc
2026 1.1 agc - A series of multi-precision integers comprising the key
2027 1.1 agc material. This algorithm-specific portion is:
2028 1.1 agc
2029 1.1 agc Algorithm Specific Fields for RSA public keys:
2030 1.1 agc
2031 1.1 agc - multiprecision integer (MPI) of RSA public modulus n;
2032 1.1 agc
2033 1.1 agc - MPI of RSA public encryption exponent e.
2034 1.1 agc
2035 1.1 agc Algorithm Specific Fields for DSA public keys:
2036 1.1 agc
2037 1.1 agc - MPI of DSA prime p;
2038 1.1 agc
2039 1.1 agc - MPI of DSA group order q (q is a prime divisor of p-1);
2040 1.1 agc
2041 1.1 agc - MPI of DSA group generator g;
2042 1.1 agc
2043 1.1 agc - MPI of DSA public key value y (= g**x where x is secret).
2044 1.1 agc
2045 1.1 agc Algorithm Specific Fields for Elgamal public keys:
2046 1.1 agc
2047 1.1 agc - MPI of Elgamal prime p;
2048 1.1 agc
2049 1.1 agc - MPI of Elgamal group generator g;
2050 1.1 agc
2051 1.1 agc
2052 1.1 agc
2053 1.1 agc Callas, et. al. Standards Track [Page 36]
2054 1.1 agc
2056 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2057 1.1 agc
2058 1.1 agc
2059 1.1 agc - MPI of Elgamal public key value y (= g**x where x is
2060 1.1 agc secret).
2061 1.1 agc
2062 1.1 agc 5.5.3. Secret Key Packet Formats
2063 1.1 agc
2064 1.1 agc The Secret Key and Secret Subkey packets contain all the data of the
2065 1.1 agc Public Key and Public Subkey packets, with additional algorithm-
2066 1.1 agc specific secret key data appended, in encrypted form.
2067 1.1 agc
2068 1.1 agc The packet contains:
2069 1.1 agc
2070 1.1 agc - A Public Key or Public Subkey packet, as described above
2071 1.1 agc
2072 1.1 agc - One octet indicating string-to-key usage conventions. 0
2073 1.1 agc indicates that the secret key data is not encrypted. 255
2074 1.1 agc indicates that a string-to-key specifier is being given. Any
2075 1.1 agc other value is a symmetric-key encryption algorithm specifier.
2076 1.1 agc
2077 1.1 agc - [Optional] If string-to-key usage octet was 255, a one-octet
2078 1.1 agc symmetric encryption algorithm.
2079 1.1 agc
2080 1.1 agc - [Optional] If string-to-key usage octet was 255, a string-to-key
2081 1.1 agc specifier. The length of the string-to-key specifier is implied
2082 1.1 agc by its type, as described above.
2083 1.1 agc
2084 1.1 agc - [Optional] If secret data is encrypted, eight-octet Initial
2085 1.1 agc Vector (IV).
2086 1.1 agc
2087 1.1 agc - Encrypted multi-precision integers comprising the secret key
2088 1.1 agc data. These algorithm-specific fields are as described below.
2089 1.1 agc
2090 1.1 agc - Two-octet checksum of the plaintext of the algorithm-specific
2091 1.1 agc portion (sum of all octets, mod 65536).
2092 1.1 agc
2093 1.1 agc Algorithm Specific Fields for RSA secret keys:
2094 1.1 agc
2095 1.1 agc - multiprecision integer (MPI) of RSA secret exponent d.
2096 1.1 agc
2097 1.1 agc - MPI of RSA secret prime value p.
2098 1.1 agc
2099 1.1 agc - MPI of RSA secret prime value q (p < q).
2100 1.1 agc
2101 1.1 agc - MPI of u, the multiplicative inverse of p, mod q.
2102 1.1 agc
2103 1.1 agc Algorithm Specific Fields for DSA secret keys:
2104 1.1 agc
2105 1.1 agc - MPI of DSA secret exponent x.
2106 1.1 agc
2107 1.1 agc
2108 1.1 agc
2109 1.1 agc
2110 1.1 agc Callas, et. al. Standards Track [Page 37]
2111 1.1 agc
2113 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2114 1.1 agc
2115 1.1 agc
2116 1.1 agc Algorithm Specific Fields for Elgamal secret keys:
2117 1.1 agc
2118 1.1 agc - MPI of Elgamal secret exponent x.
2119 1.1 agc
2120 1.1 agc Secret MPI values can be encrypted using a passphrase. If a string-
2121 1.1 agc to-key specifier is given, that describes the algorithm for
2122 1.1 agc converting the passphrase to a key, else a simple MD5 hash of the
2123 1.1 agc passphrase is used. Implementations SHOULD use a string-to-key
2124 1.1 agc specifier; the simple hash is for backward compatibility. The cipher
2125 1.1 agc for encrypting the MPIs is specified in the secret key packet.
2126 1.1 agc
2127 1.1 agc Encryption/decryption of the secret data is done in CFB mode using
2128 1.1 agc the key created from the passphrase and the Initial Vector from the
2129 1.1 agc packet. A different mode is used with V3 keys (which are only RSA)
2130 1.1 agc than with other key formats. With V3 keys, the MPI bit count prefix
2131 1.1 agc (i.e., the first two octets) is not encrypted. Only the MPI non-
2132 1.1 agc prefix data is encrypted. Furthermore, the CFB state is
2133 1.1 agc resynchronized at the beginning of each new MPI value, so that the
2134 1.1 agc CFB block boundary is aligned with the start of the MPI data.
2135 1.1 agc
2136 1.1 agc With V4 keys, a simpler method is used. All secret MPI values are
2137 1.1 agc encrypted in CFB mode, including the MPI bitcount prefix.
2138 1.1 agc
2139 1.1 agc The 16-bit checksum that follows the algorithm-specific portion is
2140 1.1 agc the algebraic sum, mod 65536, of the plaintext of all the algorithm-
2141 1.1 agc specific octets (including MPI prefix and data). With V3 keys, the
2142 1.1 agc checksum is stored in the clear. With V4 keys, the checksum is
2143 1.1 agc encrypted like the algorithm-specific data. This value is used to
2144 1.1 agc check that the passphrase was correct.
2145 1.1 agc
2146 1.1 agc 5.6. Compressed Data Packet (Tag 8)
2147 1.1 agc
2148 1.1 agc The Compressed Data packet contains compressed data. Typically, this
2149 1.1 agc packet is found as the contents of an encrypted packet, or following
2150 1.1 agc a Signature or One-Pass Signature packet, and contains literal data
2151 1.1 agc packets.
2152 1.1 agc
2153 1.1 agc The body of this packet consists of:
2154 1.1 agc
2155 1.1 agc - One octet that gives the algorithm used to compress the packet.
2156 1.1 agc
2157 1.1 agc - The remainder of the packet is compressed data.
2158 1.1 agc
2159 1.1 agc A Compressed Data Packet's body contains an block that compresses
2160 1.1 agc some set of packets. See section "Packet Composition" for details on
2161 1.1 agc how messages are formed.
2162 1.1 agc
2163 1.1 agc
2164 1.1 agc
2165 1.1 agc
2166 1.1 agc
2167 1.1 agc Callas, et. al. Standards Track [Page 38]
2168 1.1 agc
2170 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2171 1.1 agc
2172 1.1 agc
2173 1.1 agc ZIP-compressed packets are compressed with raw RFC 1951 DEFLATE
2174 1.1 agc blocks. Note that PGP V2.6 uses 13 bits of compression. If an
2175 1.1 agc implementation uses more bits of compression, PGP V2.6 cannot
2176 1.1 agc decompress it.
2177 1.1 agc
2178 1.1 agc ZLIB-compressed packets are compressed with RFC 1950 ZLIB-style
2179 1.1 agc blocks.
2180 1.1 agc
2181 1.1 agc 5.7. Symmetrically Encrypted Data Packet (Tag 9)
2182 1.1 agc
2183 1.1 agc The Symmetrically Encrypted Data packet contains data encrypted with
2184 1.1 agc a symmetric-key algorithm. When it has been decrypted, it will
2185 1.1 agc typically contain other packets (often literal data packets or
2186 1.1 agc compressed data packets).
2187 1.1 agc
2188 1.1 agc The body of this packet consists of:
2189 1.1 agc
2190 1.1 agc - Encrypted data, the output of the selected symmetric-key cipher
2191 1.1 agc operating in PGP's variant of Cipher Feedback (CFB) mode.
2192 1.1 agc
2193 1.1 agc The symmetric cipher used may be specified in an Public-Key or
2194 1.1 agc Symmetric-Key Encrypted Session Key packet that precedes the
2195 1.1 agc Symmetrically Encrypted Data Packet. In that case, the cipher
2196 1.1 agc algorithm octet is prefixed to the session key before it is
2197 1.1 agc encrypted. If no packets of these types precede the encrypted data,
2198 1.1 agc the IDEA algorithm is used with the session key calculated as the MD5
2199 1.1 agc hash of the passphrase.
2200 1.1 agc
2201 1.1 agc The data is encrypted in CFB mode, with a CFB shift size equal to the
2202 1.1 agc cipher's block size. The Initial Vector (IV) is specified as all
2203 1.1 agc zeros. Instead of using an IV, OpenPGP prefixes a 10-octet string to
2204 1.1 agc the data before it is encrypted. The first eight octets are random,
2205 1.1 agc and the 9th and 10th octets are copies of the 7th and 8th octets,
2206 1.1 agc respectively. After encrypting the first 10 octets, the CFB state is
2207 1.1 agc resynchronized if the cipher block size is 8 octets or less. The
2208 1.1 agc last 8 octets of ciphertext are passed through the cipher and the
2209 1.1 agc block boundary is reset.
2210 1.1 agc
2211 1.1 agc The repetition of 16 bits in the 80 bits of random data prefixed to
2212 1.1 agc the message allows the receiver to immediately check whether the
2213 1.1 agc session key is incorrect.
2214 1.1 agc
2215 1.1 agc 5.8. Marker Packet (Obsolete Literal Packet) (Tag 10)
2216 1.1 agc
2217 1.1 agc An experimental version of PGP used this packet as the Literal
2218 1.1 agc packet, but no released version of PGP generated Literal packets with
2219 1.1 agc this tag. With PGP 5.x, this packet has been re-assigned and is
2220 1.1 agc reserved for use as the Marker packet.
2221 1.1 agc
2222 1.1 agc
2223 1.1 agc
2224 1.1 agc Callas, et. al. Standards Track [Page 39]
2225 1.1 agc
2227 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2228 1.1 agc
2229 1.1 agc
2230 1.1 agc The body of this packet consists of:
2231 1.1 agc
2232 1.1 agc - The three octets 0x50, 0x47, 0x50 (which spell "PGP" in UTF-8).
2233 1.1 agc
2234 1.1 agc Such a packet MUST be ignored when received. It may be placed at the
2235 1.1 agc beginning of a message that uses features not available in PGP 2.6.x
2236 1.1 agc in order to cause that version to report that newer software is
2237 1.1 agc necessary to process the message.
2238 1.1 agc
2239 1.1 agc 5.9. Literal Data Packet (Tag 11)
2240 1.1 agc
2241 1.1 agc A Literal Data packet contains the body of a message; data that is
2242 1.1 agc not to be further interpreted.
2243 1.1 agc
2244 1.1 agc The body of this packet consists of:
2245 1.1 agc
2246 1.1 agc - A one-octet field that describes how the data is formatted.
2247 1.1 agc
2248 1.1 agc If it is a 'b' (0x62), then the literal packet contains binary data.
2249 1.1 agc If it is a 't' (0x74), then it contains text data, and thus may need
2250 1.1 agc line ends converted to local form, or other text-mode changes. RFC
2251 1.1 agc 1991 also defined a value of 'l' as a 'local' mode for machine-local
2252 1.1 agc conversions. This use is now deprecated.
2253 1.1 agc
2254 1.1 agc - File name as a string (one-octet length, followed by file name),
2255 1.1 agc if the encrypted data should be saved as a file.
2256 1.1 agc
2257 1.1 agc If the special name "_CONSOLE" is used, the message is considered to
2258 1.1 agc be "for your eyes only". This advises that the message data is
2259 1.1 agc unusually sensitive, and the receiving program should process it more
2260 1.1 agc carefully, perhaps avoiding storing the received data to disk, for
2261 1.1 agc example.
2262 1.1 agc
2263 1.1 agc - A four-octet number that indicates the modification date of the
2264 1.1 agc file, or the creation time of the packet, or a zero that
2265 1.1 agc indicates the present time.
2266 1.1 agc
2267 1.1 agc - The remainder of the packet is literal data.
2268 1.1 agc
2269 1.1 agc Text data is stored with <CR><LF> text endings (i.e. network-normal
2270 1.1 agc line endings). These should be converted to native line endings by
2271 1.1 agc the receiving software.
2272 1.1 agc
2273 1.1 agc 5.10. Trust Packet (Tag 12)
2274 1.1 agc
2275 1.1 agc The Trust packet is used only within keyrings and is not normally
2276 1.1 agc exported. Trust packets contain data that record the user's
2277 1.1 agc specifications of which key holders are trustworthy introducers,
2278 1.1 agc
2279 1.1 agc
2280 1.1 agc
2281 1.1 agc Callas, et. al. Standards Track [Page 40]
2282 1.1 agc
2284 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2285 1.1 agc
2286 1.1 agc
2287 1.1 agc along with other information that implementing software uses for
2288 1.1 agc trust information.
2289 1.1 agc
2290 1.1 agc Trust packets SHOULD NOT be emitted to output streams that are
2291 1.1 agc transferred to other users, and they SHOULD be ignored on any input
2292 1.1 agc other than local keyring files.
2293 1.1 agc
2294 1.1 agc 5.11. User ID Packet (Tag 13)
2295 1.1 agc
2296 1.1 agc A User ID packet consists of data that is intended to represent the
2297 1.1 agc name and email address of the key holder. By convention, it includes
2298 1.1 agc an RFC 822 mail name, but there are no restrictions on its content.
2299 1.1 agc The packet length in the header specifies the length of the user id.
2300 1.1 agc If it is text, it is encoded in UTF-8.
2301 1.1 agc
2302 1.1 agc 6. Radix-64 Conversions
2303 1.1 agc
2304 1.1 agc As stated in the introduction, OpenPGP's underlying native
2305 1.1 agc representation for objects is a stream of arbitrary octets, and some
2306 1.1 agc systems desire these objects to be immune to damage caused by
2307 1.1 agc character set translation, data conversions, etc.
2308 1.1 agc
2309 1.1 agc In principle, any printable encoding scheme that met the requirements
2310 1.1 agc of the unsafe channel would suffice, since it would not change the
2311 1.1 agc underlying binary bit streams of the native OpenPGP data structures.
2312 1.1 agc The OpenPGP standard specifies one such printable encoding scheme to
2313 1.1 agc ensure interoperability.
2314 1.1 agc
2315 1.1 agc OpenPGP's Radix-64 encoding is composed of two parts: a base64
2316 1.1 agc encoding of the binary data, and a checksum. The base64 encoding is
2317 1.1 agc identical to the MIME base64 content-transfer-encoding [RFC2231,
2318 1.1 agc Section 6.8]. An OpenPGP implementation MAY use ASCII Armor to
2319 1.1 agc protect the raw binary data.
2320 1.1 agc
2321 1.1 agc The checksum is a 24-bit CRC converted to four characters of radix-64
2322 1.1 agc encoding by the same MIME base64 transformation, preceded by an
2323 1.1 agc equals sign (=). The CRC is computed by using the generator 0x864CFB
2324 1.1 agc and an initialization of 0xB704CE. The accumulation is done on the
2325 1.1 agc data before it is converted to radix-64, rather than on the converted
2326 1.1 agc data. A sample implementation of this algorithm is in the next
2327 1.1 agc section.
2328 1.1 agc
2329 1.1 agc The checksum with its leading equal sign MAY appear on the first line
2330 1.1 agc after the Base64 encoded data.
2331 1.1 agc
2332 1.1 agc Rationale for CRC-24: The size of 24 bits fits evenly into printable
2333 1.1 agc base64. The nonzero initialization can detect more errors than a
2334 1.1 agc zero initialization.
2335 1.1 agc
2336 1.1 agc
2337 1.1 agc
2338 1.1 agc Callas, et. al. Standards Track [Page 41]
2339 1.1 agc
2341 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2342 1.1 agc
2343 1.1 agc
2344 1.1 agc 6.1. An Implementation of the CRC-24 in "C"
2345 1.1 agc
2346 1.1 agc #define CRC24_INIT 0xb704ceL
2347 1.1 agc #define CRC24_POLY 0x1864cfbL
2348 1.1 agc
2349 1.1 agc typedef long crc24;
2350 1.1 agc crc24 crc_octets(unsigned char *octets, size_t len)
2351 1.1 agc {
2352 1.1 agc crc24 crc = CRC24_INIT;
2353 1.1 agc int i;
2354 1.1 agc
2355 1.1 agc while (len--) {
2356 1.1 agc crc ^= (*octets++) << 16;
2357 1.1 agc for (i = 0; i < 8; i++) {
2358 1.1 agc crc <<= 1;
2359 1.1 agc if (crc & 0x1000000)
2360 1.1 agc crc ^= CRC24_POLY;
2361 1.1 agc }
2362 1.1 agc }
2363 1.1 agc return crc & 0xffffffL;
2364 1.1 agc }
2365 1.1 agc
2366 1.1 agc 6.2. Forming ASCII Armor
2367 1.1 agc
2368 1.1 agc When OpenPGP encodes data into ASCII Armor, it puts specific headers
2369 1.1 agc around the data, so OpenPGP can reconstruct the data later. OpenPGP
2370 1.1 agc informs the user what kind of data is encoded in the ASCII armor
2371 1.1 agc through the use of the headers.
2372 1.1 agc
2373 1.1 agc Concatenating the following data creates ASCII Armor:
2374 1.1 agc
2375 1.1 agc - An Armor Header Line, appropriate for the type of data
2376 1.1 agc
2377 1.1 agc - Armor Headers
2378 1.1 agc
2379 1.1 agc - A blank (zero-length, or containing only whitespace) line
2380 1.1 agc
2381 1.1 agc - The ASCII-Armored data
2382 1.1 agc
2383 1.1 agc - An Armor Checksum
2384 1.1 agc
2385 1.1 agc - The Armor Tail, which depends on the Armor Header Line.
2386 1.1 agc
2387 1.1 agc An Armor Header Line consists of the appropriate header line text
2388 1.1 agc surrounded by five (5) dashes ('-', 0x2D) on either side of the
2389 1.1 agc header line text. The header line text is chosen based upon the type
2390 1.1 agc of data that is being encoded in Armor, and how it is being encoded.
2391 1.1 agc Header line texts include the following strings:
2392 1.1 agc
2393 1.1 agc
2394 1.1 agc
2395 1.1 agc Callas, et. al. Standards Track [Page 42]
2396 1.1 agc
2398 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2399 1.1 agc
2400 1.1 agc
2401 1.1 agc BEGIN PGP MESSAGE
2402 1.1 agc Used for signed, encrypted, or compressed files.
2403 1.1 agc
2404 1.1 agc BEGIN PGP PUBLIC KEY BLOCK
2405 1.1 agc Used for armoring public keys
2406 1.1 agc
2407 1.1 agc BEGIN PGP PRIVATE KEY BLOCK
2408 1.1 agc Used for armoring private keys
2409 1.1 agc
2410 1.1 agc BEGIN PGP MESSAGE, PART X/Y
2411 1.1 agc Used for multi-part messages, where the armor is split amongst Y
2412 1.1 agc parts, and this is the Xth part out of Y.
2413 1.1 agc
2414 1.1 agc BEGIN PGP MESSAGE, PART X
2415 1.1 agc Used for multi-part messages, where this is the Xth part of an
2416 1.1 agc unspecified number of parts. Requires the MESSAGE-ID Armor Header
2417 1.1 agc to be used.
2418 1.1 agc
2419 1.1 agc BEGIN PGP SIGNATURE
2420 1.1 agc Used for detached signatures, OpenPGP/MIME signatures, and
2421 1.1 agc natures following clearsigned messages. Note that PGP 2.x s BEGIN
2422 1.1 agc PGP MESSAGE for detached signatures.
2423 1.1 agc
2424 1.1 agc The Armor Headers are pairs of strings that can give the user or the
2425 1.1 agc receiving OpenPGP implementation some information about how to decode
2426 1.1 agc or use the message. The Armor Headers are a part of the armor, not a
2427 1.1 agc part of the message, and hence are not protected by any signatures
2428 1.1 agc applied to the message.
2429 1.1 agc
2430 1.1 agc The format of an Armor Header is that of a key-value pair. A colon
2431 1.1 agc (':' 0x38) and a single space (0x20) separate the key and value.
2432 1.1 agc OpenPGP should consider improperly formatted Armor Headers to be
2433 1.1 agc corruption of the ASCII Armor. Unknown keys should be reported to
2434 1.1 agc the user, but OpenPGP should continue to process the message.
2435 1.1 agc
2436 1.1 agc Currently defined Armor Header Keys are:
2437 1.1 agc
2438 1.1 agc - "Version", that states the OpenPGP Version used to encode the
2439 1.1 agc message.
2440 1.1 agc
2441 1.1 agc - "Comment", a user-defined comment.
2442 1.1 agc
2443 1.1 agc - "MessageID", a 32-character string of printable characters. The
2444 1.1 agc string must be the same for all parts of a multi-part message
2445 1.1 agc that uses the "PART X" Armor Header. MessageID strings should be
2446 1.1 agc
2447 1.1 agc
2448 1.1 agc
2449 1.1 agc
2450 1.1 agc
2451 1.1 agc
2452 1.1 agc Callas, et. al. Standards Track [Page 43]
2453 1.1 agc
2455 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2456 1.1 agc
2457 1.1 agc
2458 1.1 agc unique enough that the recipient of the mail can associate all
2459 1.1 agc the parts of a message with each other. A good checksum or
2460 1.1 agc cryptographic hash function is sufficient.
2461 1.1 agc
2462 1.1 agc - "Hash", a comma-separated list of hash algorithms used in this
2463 1.1 agc message. This is used only in clear-signed messages.
2464 1.1 agc
2465 1.1 agc - "Charset", a description of the character set that the plaintext
2466 1.1 agc is in. Please note that OpenPGP defines text to be in UTF-8 by
2467 1.1 agc default. An implementation will get best results by translating
2468 1.1 agc into and out of UTF-8. However, there are many instances where
2469 1.1 agc this is easier said than done. Also, there are communities of
2470 1.1 agc users who have no need for UTF-8 because they are all happy with
2471 1.1 agc a character set like ISO Latin-5 or a Japanese character set. In
2472 1.1 agc such instances, an implementation MAY override the UTF-8 default
2473 1.1 agc by using this header key. An implementation MAY implement this
2474 1.1 agc key and any translations it cares to; an implementation MAY
2475 1.1 agc ignore it and assume all text is UTF-8.
2476 1.1 agc
2477 1.1 agc The MessageID SHOULD NOT appear unless it is in a multi-part
2478 1.1 agc message. If it appears at all, it MUST be computed from the
2479 1.1 agc finished (encrypted, signed, etc.) message in a deterministic
2480 1.1 agc fashion, rather than contain a purely random value. This is to
2481 1.1 agc allow the legitimate recipient to determine that the MessageID
2482 1.1 agc cannot serve as a covert means of leaking cryptographic key
2483 1.1 agc information.
2484 1.1 agc
2485 1.1 agc The Armor Tail Line is composed in the same manner as the Armor
2486 1.1 agc Header Line, except the string "BEGIN" is replaced by the string
2487 1.1 agc "END."
2488 1.1 agc
2489 1.1 agc 6.3. Encoding Binary in Radix-64
2490 1.1 agc
2491 1.1 agc The encoding process represents 24-bit groups of input bits as output
2492 1.1 agc strings of 4 encoded characters. Proceeding from left to right, a
2493 1.1 agc 24-bit input group is formed by concatenating three 8-bit input
2494 1.1 agc groups. These 24 bits are then treated as four concatenated 6-bit
2495 1.1 agc groups, each of which is translated into a single digit in the
2496 1.1 agc Radix-64 alphabet. When encoding a bit stream with the Radix-64
2497 1.1 agc encoding, the bit stream must be presumed to be ordered with the
2498 1.1 agc most-significant-bit first. That is, the first bit in the stream will
2499 1.1 agc be the high-order bit in the first 8-bit octet, and the eighth bit
2500 1.1 agc will be the low-order bit in the first 8-bit octet, and so on.
2501 1.1 agc
2502 1.1 agc
2503 1.1 agc
2504 1.1 agc
2505 1.1 agc
2506 1.1 agc
2507 1.1 agc
2508 1.1 agc
2509 1.1 agc Callas, et. al. Standards Track [Page 44]
2510 1.1 agc
2512 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2513 1.1 agc
2514 1.1 agc
2515 1.1 agc +--first octet--+-second octet--+--third octet--+
2516 1.1 agc |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
2517 1.1 agc +-----------+---+-------+-------+---+-----------+
2518 1.1 agc |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
2519 1.1 agc +--1.index--+--2.index--+--3.index--+--4.index--+
2520 1.1 agc
2521 1.1 agc Each 6-bit group is used as an index into an array of 64 printable
2522 1.1 agc characters from the table below. The character referenced by the
2523 1.1 agc index is placed in the output string.
2524 1.1 agc
2525 1.1 agc Value Encoding Value Encoding Value Encoding Value Encoding
2526 1.1 agc 0 A 17 R 34 i 51 z
2527 1.1 agc 1 B 18 S 35 j 52 0
2528 1.1 agc 2 C 19 T 36 k 53 1
2529 1.1 agc 3 D 20 U 37 l 54 2
2530 1.1 agc 4 E 21 V 38 m 55 3
2531 1.1 agc 5 F 22 W 39 n 56 4
2532 1.1 agc 6 G 23 X 40 o 57 5
2533 1.1 agc 7 H 24 Y 41 p 58 6
2534 1.1 agc 8 I 25 Z 42 q 59 7
2535 1.1 agc 9 J 26 a 43 r 60 8
2536 1.1 agc 10 K 27 b 44 s 61 9
2537 1.1 agc 11 L 28 c 45 t 62 +
2538 1.1 agc 12 M 29 d 46 u 63 /
2539 1.1 agc 13 N 30 e 47 v
2540 1.1 agc 14 O 31 f 48 w (pad) =
2541 1.1 agc 15 P 32 g 49 x
2542 1.1 agc 16 Q 33 h 50 y
2543 1.1 agc
2544 1.1 agc The encoded output stream must be represented in lines of no more
2545 1.1 agc than 76 characters each.
2546 1.1 agc
2547 1.1 agc Special processing is performed if fewer than 24 bits are available
2548 1.1 agc at the end of the data being encoded. There are three possibilities:
2549 1.1 agc
2550 1.1 agc 1. The last data group has 24 bits (3 octets). No special
2551 1.1 agc processing is needed.
2552 1.1 agc
2553 1.1 agc 2. The last data group has 16 bits (2 octets). The first two 6-bit
2554 1.1 agc groups are processed as above. The third (incomplete) data group
2555 1.1 agc has two zero-value bits added to it, and is processed as above.
2556 1.1 agc A pad character (=) is added to the output.
2557 1.1 agc
2558 1.1 agc 3. The last data group has 8 bits (1 octet). The first 6-bit group
2559 1.1 agc is processed as above. The second (incomplete) data group has
2560 1.1 agc four zero-value bits added to it, and is processed as above. Two
2561 1.1 agc pad characters (=) are added to the output.
2562 1.1 agc
2563 1.1 agc
2564 1.1 agc
2565 1.1 agc
2566 1.1 agc Callas, et. al. Standards Track [Page 45]
2567 1.1 agc
2569 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2570 1.1 agc
2571 1.1 agc
2572 1.1 agc 6.4. Decoding Radix-64
2573 1.1 agc
2574 1.1 agc Any characters outside of the base64 alphabet are ignored in Radix-64
2575 1.1 agc data. Decoding software must ignore all line breaks or other
2576 1.1 agc characters not found in the table above.
2577 1.1 agc
2578 1.1 agc In Radix-64 data, characters other than those in the table, line
2579 1.1 agc breaks, and other white space probably indicate a transmission error,
2580 1.1 agc about which a warning message or even a message rejection might be
2581 1.1 agc appropriate under some circumstances.
2582 1.1 agc
2583 1.1 agc Because it is used only for padding at the end of the data, the
2584 1.1 agc occurrence of any "=" characters may be taken as evidence that the
2585 1.1 agc end of the data has been reached (without truncation in transit). No
2586 1.1 agc such assurance is possible, however, when the number of octets
2587 1.1 agc transmitted was a multiple of three and no "=" characters are
2588 1.1 agc present.
2589 1.1 agc
2590 1.1 agc 6.5. Examples of Radix-64
2591 1.1 agc
2592 1.1 agc Input data: 0x14fb9c03d97e
2593 1.1 agc Hex: 1 4 f b 9 c | 0 3 d 9 7 e
2594 1.1 agc 8-bit: 00010100 11111011 10011100 | 00000011 11011001
2595 1.1 agc 11111110
2596 1.1 agc 6-bit: 000101 001111 101110 011100 | 000000 111101 100111
2597 1.1 agc 111110
2598 1.1 agc Decimal: 5 15 46 28 0 61 37 62
2599 1.1 agc Output: F P u c A 9 l +
2600 1.1 agc
2601 1.1 agc Input data: 0x14fb9c03d9
2602 1.1 agc Hex: 1 4 f b 9 c | 0 3 d 9
2603 1.1 agc 8-bit: 00010100 11111011 10011100 | 00000011 11011001
2604 1.1 agc pad with 00
2605 1.1 agc 6-bit: 000101 001111 101110 011100 | 000000 111101 100100
2606 1.1 agc Decimal: 5 15 46 28 0 61 36
2607 1.1 agc pad with =
2608 1.1 agc Output: F P u c A 9 k =
2609 1.1 agc
2610 1.1 agc Input data: 0x14fb9c03
2611 1.1 agc Hex: 1 4 f b 9 c | 0 3
2612 1.1 agc 8-bit: 00010100 11111011 10011100 | 00000011
2613 1.1 agc pad with 0000
2614 1.1 agc 6-bit: 000101 001111 101110 011100 | 000000 110000
2615 1.1 agc Decimal: 5 15 46 28 0 48
2616 1.1 agc pad with = =
2617 1.1 agc Output: F P u c A w = =
2618 1.1 agc
2619 1.1 agc
2620 1.1 agc
2621 1.1 agc
2622 1.1 agc
2623 1.1 agc Callas, et. al. Standards Track [Page 46]
2624 1.1 agc
2626 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2627 1.1 agc
2628 1.1 agc
2629 1.1 agc 6.6. Example of an ASCII Armored Message
2630 1.1 agc
2631 1.1 agc
2632 1.1 agc -----BEGIN PGP MESSAGE-----
2633 1.1 agc Version: OpenPrivacy 0.99
2634 1.1 agc
2635 1.1 agc yDgBO22WxBHv7O8X7O/jygAEzol56iUKiXmV+XmpCtmpqQUKiQrFqclFqUDBovzS
2636 1.1 agc vBSFjNSiVHsuAA==
2637 1.1 agc =njUN
2638 1.1 agc -----END PGP MESSAGE-----
2639 1.1 agc
2640 1.1 agc Note that this example is indented by two spaces.
2641 1.1 agc
2642 1.1 agc 7. Cleartext signature framework
2643 1.1 agc
2644 1.1 agc It is desirable to sign a textual octet stream without ASCII armoring
2645 1.1 agc the stream itself, so the signed text is still readable without
2646 1.1 agc special software. In order to bind a signature to such a cleartext,
2647 1.1 agc this framework is used. (Note that RFC 2015 defines another way to
2648 1.1 agc clear sign messages for environments that support MIME.)
2649 1.1 agc
2650 1.1 agc The cleartext signed message consists of:
2651 1.1 agc
2652 1.1 agc - The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a
2653 1.1 agc single line,
2654 1.1 agc
2655 1.1 agc - One or more "Hash" Armor Headers,
2656 1.1 agc
2657 1.1 agc - Exactly one empty line not included into the message digest,
2658 1.1 agc
2659 1.1 agc - The dash-escaped cleartext that is included into the message
2660 1.1 agc digest,
2661 1.1 agc
2662 1.1 agc - The ASCII armored signature(s) including the '-----BEGIN PGP
2663 1.1 agc SIGNATURE-----' Armor Header and Armor Tail Lines.
2664 1.1 agc
2665 1.1 agc If the "Hash" armor header is given, the specified message digest
2666 1.1 agc algorithm is used for the signature. If there are no such headers,
2667 1.1 agc MD5 is used, an implementation MAY omit them for V2.x compatibility.
2668 1.1 agc If more than one message digest is used in the signature, the "Hash"
2669 1.1 agc armor header contains a comma-delimited list of used message digests.
2670 1.1 agc
2671 1.1 agc Current message digest names are described below with the algorithm
2672 1.1 agc IDs.
2673 1.1 agc
2674 1.1 agc 7.1. Dash-Escaped Text
2675 1.1 agc
2676 1.1 agc The cleartext content of the message must also be dash-escaped.
2677 1.1 agc
2678 1.1 agc
2679 1.1 agc
2680 1.1 agc Callas, et. al. Standards Track [Page 47]
2681 1.1 agc
2683 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2684 1.1 agc
2685 1.1 agc
2686 1.1 agc Dash escaped cleartext is the ordinary cleartext where every line
2687 1.1 agc starting with a dash '-' (0x2D) is prefixed by the sequence dash '-'
2688 1.1 agc (0x2D) and space ' ' (0x20). This prevents the parser from
2689 1.1 agc recognizing armor headers of the cleartext itself. The message digest
2690 1.1 agc is computed using the cleartext itself, not the dash escaped form.
2691 1.1 agc
2692 1.1 agc As with binary signatures on text documents, a cleartext signature is
2693 1.1 agc calculated on the text using canonical <CR><LF> line endings. The
2694 1.1 agc line ending (i.e. the <CR><LF>) before the '-----BEGIN PGP
2695 1.1 agc SIGNATURE-----' line that terminates the signed text is not
2696 1.1 agc considered part of the signed text.
2697 1.1 agc
2698 1.1 agc Also, any trailing whitespace (spaces, and tabs, 0x09) at the end of
2699 1.1 agc any line is ignored when the cleartext signature is calculated.
2700 1.1 agc
2701 1.1 agc 8. Regular Expressions
2702 1.1 agc
2703 1.1 agc A regular expression is zero or more branches, separated by '|'. It
2704 1.1 agc matches anything that matches one of the branches.
2705 1.1 agc
2706 1.1 agc A branch is zero or more pieces, concatenated. It matches a match for
2707 1.1 agc the first, followed by a match for the second, etc.
2708 1.1 agc
2709 1.1 agc A piece is an atom possibly followed by '*', '+', or '?'. An atom
2710 1.1 agc followed by '*' matches a sequence of 0 or more matches of the atom.
2711 1.1 agc An atom followed by '+' matches a sequence of 1 or more matches of
2712 1.1 agc the atom. An atom followed by '?' matches a match of the atom, or the
2713 1.1 agc null string.
2714 1.1 agc
2715 1.1 agc An atom is a regular expression in parentheses (matching a match for
2716 1.1 agc the regular expression), a range (see below), '.' (matching any
2717 1.1 agc single character), '^' (matching the null string at the beginning of
2718 1.1 agc the input string), '$' (matching the null string at the end of the
2719 1.1 agc input string), a '\' followed by a single character (matching that
2720 1.1 agc character), or a single character with no other significance
2721 1.1 agc (matching that character).
2722 1.1 agc
2723 1.1 agc A range is a sequence of characters enclosed in '[]'. It normally
2724 1.1 agc matches any single character from the sequence. If the sequence
2725 1.1 agc begins with '^', it matches any single character not from the rest of
2726 1.1 agc the sequence. If two characters in the sequence are separated by '-',
2727 1.1 agc this is shorthand for the full list of ASCII characters between them
2728 1.1 agc (e.g. '[0-9]' matches any decimal digit). To include a literal ']' in
2729 1.1 agc the sequence, make it the first character (following a possible '^').
2730 1.1 agc To include a literal '-', make it the first or last character.
2731 1.1 agc
2732 1.1 agc
2733 1.1 agc
2734 1.1 agc
2735 1.1 agc
2736 1.1 agc
2737 1.1 agc Callas, et. al. Standards Track [Page 48]
2738 1.1 agc
2740 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2741 1.1 agc
2742 1.1 agc
2743 1.1 agc 9. Constants
2744 1.1 agc
2745 1.1 agc This section describes the constants used in OpenPGP.
2746 1.1 agc
2747 1.1 agc Note that these tables are not exhaustive lists; an implementation
2748 1.1 agc MAY implement an algorithm not on these lists.
2749 1.1 agc
2750 1.1 agc See the section "Notes on Algorithms" below for more discussion of
2751 1.1 agc the algorithms.
2752 1.1 agc
2753 1.1 agc 9.1. Public Key Algorithms
2754 1.1 agc
2755 1.1 agc ID Algorithm
2756 1.1 agc -- ---------
2757 1.1 agc 1 - RSA (Encrypt or Sign)
2758 1.1 agc 2 - RSA Encrypt-Only
2759 1.1 agc 3 - RSA Sign-Only
2760 1.1 agc 16 - Elgamal (Encrypt-Only), see [ELGAMAL]
2761 1.1 agc 17 - DSA (Digital Signature Standard)
2762 1.1 agc 18 - Reserved for Elliptic Curve
2763 1.1 agc 19 - Reserved for ECDSA
2764 1.1 agc 20 - Elgamal (Encrypt or Sign)
2765 1.1 agc
2766 1.1 agc
2767 1.1 agc
2768 1.1 agc
2769 1.1 agc
2770 1.1 agc 21 - Reserved for Diffie-Hellman (X9.42,
2771 1.1 agc as defined for IETF-S/MIME)
2772 1.1 agc 100 to 110 - Private/Experimental algorithm.
2773 1.1 agc
2774 1.1 agc Implementations MUST implement DSA for signatures, and Elgamal for
2775 1.1 agc encryption. Implementations SHOULD implement RSA keys.
2776 1.1 agc Implementations MAY implement any other algorithm.
2777 1.1 agc
2778 1.1 agc 9.2. Symmetric Key Algorithms
2779 1.1 agc
2780 1.1 agc ID Algorithm
2781 1.1 agc -- ---------
2782 1.1 agc 0 - Plaintext or unencrypted data
2783 1.1 agc 1 - IDEA [IDEA]
2784 1.1 agc 2 - Triple-DES (DES-EDE, as per spec -
2785 1.1 agc 168 bit key derived from 192)
2786 1.1 agc 3 - CAST5 (128 bit key, as per RFC 2144)
2787 1.1 agc 4 - Blowfish (128 bit key, 16 rounds) [BLOWFISH]
2788 1.1 agc 5 - SAFER-SK128 (13 rounds) [SAFER]
2789 1.1 agc 6 - Reserved for DES/SK
2790 1.1 agc 7 - Reserved for AES with 128-bit key
2791 1.1 agc
2792 1.1 agc
2793 1.1 agc
2794 1.1 agc Callas, et. al. Standards Track [Page 49]
2795 1.1 agc
2797 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2798 1.1 agc
2799 1.1 agc
2800 1.1 agc 8 - Reserved for AES with 192-bit key
2801 1.1 agc 9 - Reserved for AES with 256-bit key
2802 1.1 agc 100 to 110 - Private/Experimental algorithm.
2803 1.1 agc
2804 1.1 agc Implementations MUST implement Triple-DES. Implementations SHOULD
2805 1.1 agc implement IDEA and CAST5.Implementations MAY implement any other
2806 1.1 agc algorithm.
2807 1.1 agc
2808 1.1 agc 9.3. Compression Algorithms
2809 1.1 agc
2810 1.1 agc ID Algorithm
2811 1.1 agc -- ---------
2812 1.1 agc 0 - Uncompressed
2813 1.1 agc 1 - ZIP (RFC 1951)
2814 1.1 agc 2 - ZLIB (RFC 1950)
2815 1.1 agc 100 to 110 - Private/Experimental algorithm.
2816 1.1 agc
2817 1.1 agc Implementations MUST implement uncompressed data. Implementations
2818 1.1 agc SHOULD implement ZIP. Implementations MAY implement ZLIB.
2819 1.1 agc
2820 1.1 agc 9.4. Hash Algorithms
2821 1.1 agc
2822 1.1 agc ID Algorithm Text Name
2823 1.1 agc -- --------- ---- ----
2824 1.1 agc 1 - MD5 "MD5"
2825 1.1 agc 2 - SHA-1 "SHA1"
2826 1.1 agc 3 - RIPE-MD/160 "RIPEMD160"
2827 1.1 agc 4 - Reserved for double-width SHA (experimental)
2828 1.1 agc 5 - MD2 "MD2"
2829 1.1 agc 6 - Reserved for TIGER/192 "TIGER192"
2830 1.1 agc 7 - Reserved for HAVAL (5 pass, 160-bit)
2831 1.1 agc "HAVAL-5-160"
2832 1.1 agc 100 to 110 - Private/Experimental algorithm.
2833 1.1 agc
2834 1.1 agc Implementations MUST implement SHA-1. Implementations SHOULD
2835 1.1 agc implement MD5.
2836 1.1 agc
2837 1.1 agc 10. Packet Composition
2838 1.1 agc
2839 1.1 agc OpenPGP packets are assembled into sequences in order to create
2840 1.1 agc messages and to transfer keys. Not all possible packet sequences are
2841 1.1 agc meaningful and correct. This describes the rules for how packets
2842 1.1 agc should be placed into sequences.
2843 1.1 agc
2844 1.1 agc 10.1. Transferable Public Keys
2845 1.1 agc
2846 1.1 agc OpenPGP users may transfer public keys. The essential elements of a
2847 1.1 agc transferable public key are:
2848 1.1 agc
2849 1.1 agc
2850 1.1 agc
2851 1.1 agc Callas, et. al. Standards Track [Page 50]
2852 1.1 agc
2854 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2855 1.1 agc
2856 1.1 agc
2857 1.1 agc - One Public Key packet
2858 1.1 agc
2859 1.1 agc - Zero or more revocation signatures
2860 1.1 agc
2861 1.1 agc - One or more User ID packets
2862 1.1 agc
2863 1.1 agc - After each User ID packet, zero or more signature packets
2864 1.1 agc (certifications)
2865 1.1 agc
2866 1.1 agc - Zero or more Subkey packets
2867 1.1 agc
2868 1.1 agc - After each Subkey packet, one signature packet, optionally a
2869 1.1 agc revocation.
2870 1.1 agc
2871 1.1 agc The Public Key packet occurs first. Each of the following User ID
2872 1.1 agc packets provides the identity of the owner of this public key. If
2873 1.1 agc there are multiple User ID packets, this corresponds to multiple
2874 1.1 agc means of identifying the same unique individual user; for example, a
2875 1.1 agc user may have more than one email address, and construct a User ID
2876 1.1 agc for each one.
2877 1.1 agc
2878 1.1 agc Immediately following each User ID packet, there are zero or more
2879 1.1 agc signature packets. Each signature packet is calculated on the
2880 1.1 agc immediately preceding User ID packet and the initial Public Key
2881 1.1 agc packet. The signature serves to certify the corresponding public key
2882 1.1 agc and user ID. In effect, the signer is testifying to his or her
2883 1.1 agc belief that this public key belongs to the user identified by this
2884 1.1 agc user ID.
2885 1.1 agc
2886 1.1 agc After the User ID packets there may be one or more Subkey packets.
2887 1.1 agc In general, subkeys are provided in cases where the top-level public
2888 1.1 agc key is a signature-only key. However, any V4 key may have subkeys,
2889 1.1 agc and the subkeys may be encryption-only keys, signature-only keys, or
2890 1.1 agc general-purpose keys.
2891 1.1 agc
2892 1.1 agc Each Subkey packet must be followed by one Signature packet, which
2893 1.1 agc should be a subkey binding signature issued by the top level key.
2894 1.1 agc
2895 1.1 agc Subkey and Key packets may each be followed by a revocation Signature
2896 1.1 agc packet to indicate that the key is revoked. Revocation signatures
2897 1.1 agc are only accepted if they are issued by the key itself, or by a key
2898 1.1 agc that is authorized to issue revocations via a revocation key
2899 1.1 agc subpacket in a self-signature by the top level key.
2900 1.1 agc
2901 1.1 agc Transferable public key packet sequences may be concatenated to allow
2902 1.1 agc transferring multiple public keys in one operation.
2903 1.1 agc
2904 1.1 agc
2905 1.1 agc
2906 1.1 agc
2907 1.1 agc
2908 1.1 agc Callas, et. al. Standards Track [Page 51]
2909 1.1 agc
2911 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2912 1.1 agc
2913 1.1 agc
2914 1.1 agc 10.2. OpenPGP Messages
2915 1.1 agc
2916 1.1 agc An OpenPGP message is a packet or sequence of packets that
2917 1.1 agc corresponds to the following grammatical rules (comma represents
2918 1.1 agc sequential composition, and vertical bar separates alternatives):
2919 1.1 agc
2920 1.1 agc OpenPGP Message :- Encrypted Message | Signed Message |
2921 1.1 agc Compressed Message | Literal Message.
2922 1.1 agc
2923 1.1 agc Compressed Message :- Compressed Data Packet.
2924 1.1 agc
2925 1.1 agc Literal Message :- Literal Data Packet.
2926 1.1 agc
2927 1.1 agc ESK :- Public Key Encrypted Session Key Packet |
2928 1.1 agc Symmetric-Key Encrypted Session Key Packet.
2929 1.1 agc
2930 1.1 agc ESK Sequence :- ESK | ESK Sequence, ESK.
2931 1.1 agc
2932 1.1 agc Encrypted Message :- Symmetrically Encrypted Data Packet |
2933 1.1 agc ESK Sequence, Symmetrically Encrypted Data Packet.
2934 1.1 agc
2935 1.1 agc One-Pass Signed Message :- One-Pass Signature Packet,
2936 1.1 agc OpenPGP Message, Corresponding Signature Packet.
2937 1.1 agc
2938 1.1 agc Signed Message :- Signature Packet, OpenPGP Message |
2939 1.1 agc One-Pass Signed Message.
2940 1.1 agc
2941 1.1 agc In addition, decrypting a Symmetrically Encrypted Data packet and
2942 1.1 agc
2943 1.1 agc decompressing a Compressed Data packet must yield a valid OpenPGP
2944 1.1 agc Message.
2945 1.1 agc
2946 1.1 agc 10.3. Detached Signatures
2947 1.1 agc
2948 1.1 agc Some OpenPGP applications use so-called "detached signatures." For
2949 1.1 agc example, a program bundle may contain a file, and with it a second
2950 1.1 agc file that is a detached signature of the first file. These detached
2951 1.1 agc signatures are simply a signature packet stored separately from the
2952 1.1 agc data that they are a signature of.
2953 1.1 agc
2954 1.1 agc 11. Enhanced Key Formats
2955 1.1 agc
2956 1.1 agc 11.1. Key Structures
2957 1.1 agc
2958 1.1 agc The format of an OpenPGP V3 key is as follows. Entries in square
2959 1.1 agc brackets are optional and ellipses indicate repetition.
2960 1.1 agc
2961 1.1 agc
2962 1.1 agc
2963 1.1 agc
2964 1.1 agc
2965 1.1 agc Callas, et. al. Standards Track [Page 52]
2966 1.1 agc
2968 1.1 agc RFC 2440 OpenPGP Message Format November 1998
2969 1.1 agc
2970 1.1 agc
2971 1.1 agc RSA Public Key
2972 1.1 agc [Revocation Self Signature]
2973 1.1 agc User ID [Signature ...]
2974 1.1 agc [User ID [Signature ...] ...]
2975 1.1 agc
2976 1.1 agc Each signature certifies the RSA public key and the preceding user
2977 1.1 agc ID. The RSA public key can have many user IDs and each user ID can
2978 1.1 agc have many signatures.
2979 1.1 agc
2980 1.1 agc The format of an OpenPGP V4 key that uses two public keys is similar
2981 1.1 agc except that the other keys are added to the end as 'subkeys' of the
2982 1.1 agc primary key.
2983 1.1 agc
2984 1.1 agc Primary-Key
2985 1.1 agc [Revocation Self Signature]
2986 1.1 agc [Direct Key Self Signature...]
2987 1.1 agc User ID [Signature ...]
2988 1.1 agc [User ID [Signature ...] ...]
2989 1.1 agc [[Subkey [Binding-Signature-Revocation]
2990 1.1 agc Primary-Key-Binding-Signature] ...]
2991 1.1 agc
2992 1.1 agc A subkey always has a single signature after it that is issued using
2993 1.1 agc the primary key to tie the two keys together. This binding signature
2994 1.1 agc may be in either V3 or V4 format, but V4 is preferred, of course.
2995 1.1 agc
2996 1.1 agc In the above diagram, if the binding signature of a subkey has been
2997 1.1 agc revoked, the revoked binding signature may be removed, leaving only
2998 1.1 agc one signature.
2999 1.1 agc
3000 1.1 agc In a key that has a main key and subkeys, the primary key MUST be a
3001 1.1 agc key capable of signing. The subkeys may be keys of any other type.
3002 1.1 agc There may be other constructions of V4 keys, too. For example, there
3003 1.1 agc may be a single-key RSA key in V4 format, a DSA primary key with an
3004 1.1 agc RSA encryption key, or RSA primary key with an Elgamal subkey, etc.
3005 1.1 agc
3006 1.1 agc It is also possible to have a signature-only subkey. This permits a
3007 1.1 agc primary key that collects certifications (key signatures) but is used
3008 1.1 agc only used for certifying subkeys that are used for encryption and
3009 1.1 agc signatures.
3010 1.1 agc
3011 1.1 agc 11.2. Key IDs and Fingerprints
3012 1.1 agc
3013 1.1 agc For a V3 key, the eight-octet key ID consists of the low 64 bits of
3014 1.1 agc the public modulus of the RSA key.
3015 1.1 agc
3016 1.1 agc The fingerprint of a V3 key is formed by hashing the body (but not
3017 1.1 agc the two-octet length) of the MPIs that form the key material (public
3018 1.1 agc modulus n, followed by exponent e) with MD5.
3019 1.1 agc
3020 1.1 agc
3021 1.1 agc
3022 1.1 agc Callas, et. al. Standards Track [Page 53]
3023 1.1 agc
3025 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3026 1.1 agc
3027 1.1 agc
3028 1.1 agc A V4 fingerprint is the 160-bit SHA-1 hash of the one-octet Packet
3029 1.1 agc Tag, followed by the two-octet packet length, followed by the entire
3030 1.1 agc Public Key packet starting with the version field. The key ID is the
3031 1.1 agc low order 64 bits of the fingerprint. Here are the fields of the
3032 1.1 agc hash material, with the example of a DSA key:
3033 1.1 agc
3034 1.1 agc a.1) 0x99 (1 octet)
3035 1.1 agc
3036 1.1 agc a.2) high order length octet of (b)-(f) (1 octet)
3037 1.1 agc
3038 1.1 agc a.3) low order length octet of (b)-(f) (1 octet)
3039 1.1 agc
3040 1.1 agc b) version number = 4 (1 octet);
3041 1.1 agc
3042 1.1 agc c) time stamp of key creation (4 octets);
3043 1.1 agc
3044 1.1 agc d) algorithm (1 octet): 17 = DSA (example);
3045 1.1 agc
3046 1.1 agc e) Algorithm specific fields.
3047 1.1 agc
3048 1.1 agc Algorithm Specific Fields for DSA keys (example):
3049 1.1 agc
3050 1.1 agc e.1) MPI of DSA prime p;
3051 1.1 agc
3052 1.1 agc e.2) MPI of DSA group order q (q is a prime divisor of p-1);
3053 1.1 agc
3054 1.1 agc e.3) MPI of DSA group generator g;
3055 1.1 agc
3056 1.1 agc e.4) MPI of DSA public key value y (= g**x where x is secret).
3057 1.1 agc
3058 1.1 agc Note that it is possible for there to be collisions of key IDs -- two
3059 1.1 agc different keys with the same key ID. Note that there is a much
3060 1.1 agc smaller, but still non-zero probability that two different keys have
3061 1.1 agc the same fingerprint.
3062 1.1 agc
3063 1.1 agc Also note that if V3 and V4 format keys share the same RSA key
3064 1.1 agc material, they will have different key ids as well as different
3065 1.1 agc fingerprints.
3066 1.1 agc
3067 1.1 agc 12. Notes on Algorithms
3068 1.1 agc
3069 1.1 agc 12.1. Symmetric Algorithm Preferences
3070 1.1 agc
3071 1.1 agc The symmetric algorithm preference is an ordered list of algorithms
3072 1.1 agc that the keyholder accepts. Since it is found on a self-signature, it
3073 1.1 agc is possible that a keyholder may have different preferences. For
3074 1.1 agc example, Alice may have TripleDES only specified for "alice (a] work.com"
3075 1.1 agc but CAST5, Blowfish, and TripleDES specified for "alice (a] home.org".
3076 1.1 agc
3077 1.1 agc
3078 1.1 agc
3079 1.1 agc Callas, et. al. Standards Track [Page 54]
3080 1.1 agc
3082 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3083 1.1 agc
3084 1.1 agc
3085 1.1 agc Note that it is also possible for preferences to be in a subkey's
3086 1.1 agc binding signature.
3087 1.1 agc
3088 1.1 agc Since TripleDES is the MUST-implement algorithm, if it is not
3089 1.1 agc explicitly in the list, it is tacitly at the end. However, it is good
3090 1.1 agc form to place it there explicitly. Note also that if an
3091 1.1 agc implementation does not implement the preference, then it is
3092 1.1 agc implicitly a TripleDES-only implementation.
3093 1.1 agc
3094 1.1 agc An implementation MUST not use a symmetric algorithm that is not in
3095 1.1 agc the recipient's preference list. When encrypting to more than one
3096 1.1 agc recipient, the implementation finds a suitable algorithm by taking
3097 1.1 agc the intersection of the preferences of the recipients. Note that the
3098 1.1 agc MUST-implement algorithm, TripleDES, ensures that the intersection is
3099 1.1 agc not null. The implementation may use any mechanism to pick an
3100 1.1 agc algorithm in the intersection.
3101 1.1 agc
3102 1.1 agc If an implementation can decrypt a message that a keyholder doesn't
3103 1.1 agc have in their preferences, the implementation SHOULD decrypt the
3104 1.1 agc message anyway, but MUST warn the keyholder than protocol has been
3105 1.1 agc violated. (For example, suppose that Alice, above, has software that
3106 1.1 agc implements all algorithms in this specification. Nonetheless, she
3107 1.1 agc prefers subsets for work or home. If she is sent a message encrypted
3108 1.1 agc with IDEA, which is not in her preferences, the software warns her
3109 1.1 agc that someone sent her an IDEA-encrypted message, but it would ideally
3110 1.1 agc decrypt it anyway.)
3111 1.1 agc
3112 1.1 agc An implementation that is striving for backward compatibility MAY
3113 1.1 agc consider a V3 key with a V3 self-signature to be an implicit
3114 1.1 agc preference for IDEA, and no ability to do TripleDES. This is
3115 1.1 agc technically non-compliant, but an implementation MAY violate the
3116 1.1 agc above rule in this case only and use IDEA to encrypt the message,
3117 1.1 agc provided that the message creator is warned. Ideally, though, the
3118 1.1 agc implementation would follow the rule by actually generating two
3119 1.1 agc messages, because it is possible that the OpenPGP user's
3120 1.1 agc implementation does not have IDEA, and thus could not read the
3121 1.1 agc message. Consequently, an implementation MAY, but SHOULD NOT use IDEA
3122 1.1 agc in an algorithm conflict with a V3 key.
3123 1.1 agc
3124 1.1 agc 12.2. Other Algorithm Preferences
3125 1.1 agc
3126 1.1 agc Other algorithm preferences work similarly to the symmetric algorithm
3127 1.1 agc preference, in that they specify which algorithms the keyholder
3128 1.1 agc accepts. There are two interesting cases that other comments need to
3129 1.1 agc be made about, though, the compression preferences and the hash
3130 1.1 agc preferences.
3131 1.1 agc
3132 1.1 agc
3133 1.1 agc
3134 1.1 agc
3135 1.1 agc
3136 1.1 agc Callas, et. al. Standards Track [Page 55]
3137 1.1 agc
3139 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3140 1.1 agc
3141 1.1 agc
3142 1.1 agc 12.2.1. Compression Preferences
3143 1.1 agc
3144 1.1 agc Compression has been an integral part of PGP since its first days.
3145 1.1 agc OpenPGP and all previous versions of PGP have offered compression.
3146 1.1 agc And in this specification, the default is for messages to be
3147 1.1 agc compressed, although an implementation is not required to do so.
3148 1.1 agc Consequently, the compression preference gives a way for a keyholder
3149 1.1 agc to request that messages not be compressed, presumably because they
3150 1.1 agc are using a minimal implementation that does not include compression.
3151 1.1 agc Additionally, this gives a keyholder a way to state that it can
3152 1.1 agc support alternate algorithms.
3153 1.1 agc
3154 1.1 agc Like the algorithm preferences, an implementation MUST NOT use an
3155 1.1 agc algorithm that is not in the preference vector. If the preferences
3156 1.1 agc are not present, then they are assumed to be [ZIP(1),
3157 1.1 agc UNCOMPRESSED(0)].
3158 1.1 agc
3159 1.1 agc 12.2.2. Hash Algorithm Preferences
3160 1.1 agc
3161 1.1 agc Typically, the choice of a hash algorithm is something the signer
3162 1.1 agc does, rather than the verifier, because a signer does not typically
3163 1.1 agc know who is going to be verifying the signature. This preference,
3164 1.1 agc though, allows a protocol based upon digital signatures ease in
3165 1.1 agc negotiation.
3166 1.1 agc
3167 1.1 agc Thus, if Alice is authenticating herself to Bob with a signature, it
3168 1.1 agc makes sense for her to use a hash algorithm that Bob's software uses.
3169 1.1 agc This preference allows Bob to state in his key which algorithms Alice
3170 1.1 agc may use.
3171 1.1 agc
3172 1.1 agc 12.3. Plaintext
3173 1.1 agc
3174 1.1 agc Algorithm 0, "plaintext", may only be used to denote secret keys that
3175 1.1 agc are stored in the clear. Implementations must not use plaintext in
3176 1.1 agc Symmetrically Encrypted Data Packets; they must use Literal Data
3177 1.1 agc Packets to encode unencrypted or literal data.
3178 1.1 agc
3179 1.1 agc 12.4. RSA
3180 1.1 agc
3181 1.1 agc There are algorithm types for RSA-signature-only, and RSA-encrypt-
3182 1.1 agc only keys. These types are deprecated. The "key flags" subpacket in a
3183 1.1 agc signature is a much better way to express the same idea, and
3184 1.1 agc generalizes it to all algorithms. An implementation SHOULD NOT create
3185 1.1 agc such a key, but MAY interpret it.
3186 1.1 agc
3187 1.1 agc An implementation SHOULD NOT implement RSA keys of size less than 768
3188 1.1 agc bits.
3189 1.1 agc
3190 1.1 agc
3191 1.1 agc
3192 1.1 agc
3193 1.1 agc Callas, et. al. Standards Track [Page 56]
3194 1.1 agc
3196 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3197 1.1 agc
3198 1.1 agc
3199 1.1 agc It is permissible for an implementation to support RSA merely for
3200 1.1 agc backward compatibility; for example, such an implementation would
3201 1.1 agc support V3 keys with IDEA symmetric cryptography. Note that this is
3202 1.1 agc an exception to the other MUST-implement rules. An implementation
3203 1.1 agc that supports RSA in V4 keys MUST implement the MUST-implement
3204 1.1 agc features.
3205 1.1 agc
3206 1.1 agc 12.5. Elgamal
3207 1.1 agc
3208 1.1 agc If an Elgamal key is to be used for both signing and encryption,
3209 1.1 agc extra care must be taken in creating the key.
3210 1.1 agc
3211 1.1 agc An ElGamal key consists of a generator g, a prime modulus p, a secret
3212 1.1 agc exponent x, and a public value y = g^x mod p.
3213 1.1 agc
3214 1.1 agc The generator and prime must be chosen so that solving the discrete
3215 1.1 agc log problem is intractable. The group g should generate the
3216 1.1 agc multiplicative group mod p-1 or a large subgroup of it, and the order
3217 1.1 agc of g should have at least one large prime factor. A good choice is
3218 1.1 agc to use a "strong" Sophie-Germain prime in choosing p, so that both p
3219 1.1 agc and (p-1)/2 are primes. In fact, this choice is so good that
3220 1.1 agc implementors SHOULD do it, as it avoids a small subgroup attack.
3221 1.1 agc
3222 1.1 agc In addition, a result of Bleichenbacher [BLEICHENBACHER] shows that
3223 1.1 agc if the generator g has only small prime factors, and if g divides the
3224 1.1 agc order of the group it generates, then signatures can be forged. In
3225 1.1 agc particular, choosing g=2 is a bad choice if the group order may be
3226 1.1 agc even. On the other hand, a generator of 2 is a fine choice for an
3227 1.1 agc encryption-only key, as this will make the encryption faster.
3228 1.1 agc
3229 1.1 agc While verifying Elgamal signatures, note that it is important to test
3230 1.1 agc that r and s are less than p. If this test is not done then
3231 1.1 agc signatures can be trivially forged by using large r values of
3232 1.1 agc approximately twice the length of p. This attack is also discussed
3233 1.1 agc in the Bleichenbacher paper.
3234 1.1 agc
3235 1.1 agc Details on safe use of Elgamal signatures may be found in [MENEZES],
3236 1.1 agc which discusses all the weaknesses described above.
3237 1.1 agc
3238 1.1 agc If an implementation allows Elgamal signatures, then it MUST use the
3239 1.1 agc algorithm identifier 20 for an Elgamal public key that can sign.
3240 1.1 agc
3241 1.1 agc An implementation SHOULD NOT implement Elgamal keys of size less than
3242 1.1 agc 768 bits. For long-term security, Elgamal keys should be 1024 bits or
3243 1.1 agc longer.
3244 1.1 agc
3245 1.1 agc
3246 1.1 agc
3247 1.1 agc
3248 1.1 agc
3249 1.1 agc
3250 1.1 agc Callas, et. al. Standards Track [Page 57]
3251 1.1 agc
3253 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3254 1.1 agc
3255 1.1 agc
3256 1.1 agc 12.6. DSA
3257 1.1 agc
3258 1.1 agc An implementation SHOULD NOT implement DSA keys of size less than 768
3259 1.1 agc bits. Note that present DSA is limited to a maximum of 1024 bit keys,
3260 1.1 agc which are recommended for long-term use.
3261 1.1 agc
3262 1.1 agc 12.7. Reserved Algorithm Numbers
3263 1.1 agc
3264 1.1 agc A number of algorithm IDs have been reserved for algorithms that
3265 1.1 agc would be useful to use in an OpenPGP implementation, yet there are
3266 1.1 agc issues that prevent an implementor from actually implementing the
3267 1.1 agc algorithm. These are marked in the Public Algorithms section as
3268 1.1 agc "(reserved for)".
3269 1.1 agc
3270 1.1 agc The reserved public key algorithms, Elliptic Curve (18), ECDSA (19),
3271 1.1 agc and X9.42 (21) do not have the necessary parameters, parameter order,
3272 1.1 agc or semantics defined.
3273 1.1 agc
3274 1.1 agc The reserved symmetric key algorithm, DES/SK (6), does not have
3275 1.1 agc semantics defined.
3276 1.1 agc
3277 1.1 agc The reserved hash algorithms, TIGER192 (6), and HAVAL-5-160 (7), do
3278 1.1 agc not have OIDs. The reserved algorithm number 4, reserved for a
3279 1.1 agc double-width variant of SHA1, is not presently defined.
3280 1.1 agc
3281 1.1 agc We have reserver three algorithm IDs for the US NIST's Advanced
3282 1.1 agc Encryption Standard. This algorithm will work with (at least) 128,
3283 1.1 agc 192, and 256-bit keys. We expect that this algorithm will be selected
3284 1.1 agc from the candidate algorithms in the year 2000.
3285 1.1 agc
3286 1.1 agc 12.8. OpenPGP CFB mode
3287 1.1 agc
3288 1.1 agc OpenPGP does symmetric encryption using a variant of Cipher Feedback
3289 1.1 agc Mode (CFB mode). This section describes the procedure it uses in
3290 1.1 agc detail. This mode is what is used for Symmetrically Encrypted Data
3291 1.1 agc Packets; the mechanism used for encrypting secret key material is
3292 1.1 agc similar, but described in those sections above.
3293 1.1 agc
3294 1.1 agc OpenPGP CFB mode uses an initialization vector (IV) of all zeros, and
3295 1.1 agc prefixes the plaintext with ten octets of random data, such that
3296 1.1 agc octets 9 and 10 match octets 7 and 8. It does a CFB "resync" after
3297 1.1 agc encrypting those ten octets.
3298 1.1 agc
3299 1.1 agc Note that for an algorithm that has a larger block size than 64 bits,
3300 1.1 agc the equivalent function will be done with that entire block. For
3301 1.1 agc example, a 16-octet block algorithm would operate on 16 octets, and
3302 1.1 agc then produce two octets of check, and then work on 16-octet blocks.
3303 1.1 agc
3304 1.1 agc
3305 1.1 agc
3306 1.1 agc
3307 1.1 agc Callas, et. al. Standards Track [Page 58]
3308 1.1 agc
3310 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3311 1.1 agc
3312 1.1 agc
3313 1.1 agc Step by step, here is the procedure:
3314 1.1 agc
3315 1.1 agc 1. The feedback register (FR) is set to the IV, which is all zeros.
3316 1.1 agc
3317 1.1 agc 2. FR is encrypted to produce FRE (FR Encrypted). This is the
3318 1.1 agc encryption of an all-zero value.
3319 1.1 agc
3320 1.1 agc 3. FRE is xored with the first 8 octets of random data prefixed to
3321 1.1 agc the plaintext to produce C1-C8, the first 8 octets of ciphertext.
3322 1.1 agc
3323 1.1 agc 4. FR is loaded with C1-C8.
3324 1.1 agc
3325 1.1 agc 5. FR is encrypted to produce FRE, the encryption of the first 8
3326 1.1 agc octets of ciphertext.
3327 1.1 agc
3328 1.1 agc 6. The left two octets of FRE get xored with the next two octets of
3329 1.1 agc data that were prefixed to the plaintext. This produces C9-C10,
3330 1.1 agc the next two octets of ciphertext.
3331 1.1 agc
3332 1.1 agc 7. (The resync step) FR is loaded with C3-C10.
3333 1.1 agc
3334 1.1 agc 8. FR is encrypted to produce FRE.
3335 1.1 agc
3336 1.1 agc 9. FRE is xored with the first 8 octets of the given plaintext, now
3337 1.1 agc that we have finished encrypting the 10 octets of prefixed data.
3338 1.1 agc This produces C11-C18, the next 8 octets of ciphertext.
3339 1.1 agc
3340 1.1 agc 10. FR is loaded with C11-C18
3341 1.1 agc
3342 1.1 agc 11. FR is encrypted to produce FRE.
3343 1.1 agc
3344 1.1 agc 12. FRE is xored with the next 8 octets of plaintext, to produce the
3345 1.1 agc next 8 octets of ciphertext. These are loaded into FR and the
3346 1.1 agc process is repeated until the plaintext is used up.
3347 1.1 agc
3348 1.1 agc 13. Security Considerations
3349 1.1 agc
3350 1.1 agc As with any technology involving cryptography, you should check the
3351 1.1 agc current literature to determine if any algorithms used here have been
3352 1.1 agc found to be vulnerable to attack.
3353 1.1 agc
3354 1.1 agc This specification uses Public Key Cryptography technologies.
3355 1.1 agc Possession of the private key portion of a public-private key pair is
3356 1.1 agc assumed to be controlled by the proper party or parties.
3357 1.1 agc
3358 1.1 agc Certain operations in this specification involve the use of random
3359 1.1 agc numbers. An appropriate entropy source should be used to generate
3360 1.1 agc these numbers. See RFC 1750.
3361 1.1 agc
3362 1.1 agc
3363 1.1 agc
3364 1.1 agc Callas, et. al. Standards Track [Page 59]
3365 1.1 agc
3367 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3368 1.1 agc
3369 1.1 agc
3370 1.1 agc The MD5 hash algorithm has been found to have weaknesses (pseudo-
3371 1.1 agc collisions in the compress function) that make some people deprecate
3372 1.1 agc its use. They consider the SHA-1 algorithm better.
3373 1.1 agc
3374 1.1 agc Many security protocol designers think that it is a bad idea to use a
3375 1.1 agc single key for both privacy (encryption) and integrity (signatures).
3376 1.1 agc In fact, this was one of the motivating forces behind the V4 key
3377 1.1 agc format with separate signature and encryption keys. If you as an
3378 1.1 agc implementor promote dual-use keys, you should at least be aware of
3379 1.1 agc this controversy.
3380 1.1 agc
3381 1.1 agc The DSA algorithm will work with any 160-bit hash, but it is
3382 1.1 agc sensitive to the quality of the hash algorithm, if the hash algorithm
3383 1.1 agc is broken, it can leak the secret key. The Digital Signature Standard
3384 1.1 agc (DSS) specifies that DSA be used with SHA-1. RIPEMD-160 is
3385 1.1 agc considered by many cryptographers to be as strong. An implementation
3386 1.1 agc should take care which hash algorithms are used with DSA, as a weak
3387 1.1 agc hash can not only allow a signature to be forged, but could leak the
3388 1.1 agc secret key. These same considerations about the quality of the hash
3389 1.1 agc algorithm apply to Elgamal signatures.
3390 1.1 agc
3391 1.1 agc If you are building an authentication system, the recipient may
3392 1.1 agc specify a preferred signing algorithm. However, the signer would be
3393 1.1 agc foolish to use a weak algorithm simply because the recipient requests
3394 1.1 agc it.
3395 1.1 agc
3396 1.1 agc Some of the encryption algorithms mentioned in this document have
3397 1.1 agc been analyzed less than others. For example, although CAST5 is
3398 1.1 agc presently considered strong, it has been analyzed less than Triple-
3399 1.1 agc DES. Other algorithms may have other controversies surrounding them.
3400 1.1 agc
3401 1.1 agc Some technologies mentioned here may be subject to government control
3402 1.1 agc in some countries.
3403 1.1 agc
3404 1.1 agc 14. Implementation Nits
3405 1.1 agc
3406 1.1 agc This section is a collection of comments to help an implementer,
3407 1.1 agc particularly with an eye to backward compatibility. Previous
3408 1.1 agc implementations of PGP are not OpenPGP-compliant. Often the
3409 1.1 agc differences are small, but small differences are frequently more
3410 1.1 agc vexing than large differences. Thus, this list of potential problems
3411 1.1 agc and gotchas for a developer who is trying to be backward-compatible.
3412 1.1 agc
3413 1.1 agc * PGP 5.x does not accept V4 signatures for anything other than
3414 1.1 agc key material.
3415 1.1 agc
3416 1.1 agc * PGP 5.x does not recognize the "five-octet" lengths in new-format
3417 1.1 agc headers or in signature subpacket lengths.
3418 1.1 agc
3419 1.1 agc
3420 1.1 agc
3421 1.1 agc Callas, et. al. Standards Track [Page 60]
3422 1.1 agc
3424 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3425 1.1 agc
3426 1.1 agc
3427 1.1 agc * PGP 5.0 rejects an encrypted session key if the keylength differs
3428 1.1 agc from the S2K symmetric algorithm. This is a bug in its validation
3429 1.1 agc function.
3430 1.1 agc
3431 1.1 agc * PGP 5.0 does not handle multiple one-pass signature headers and
3432 1.1 agc trailers. Signing one will compress the one-pass signed literal
3433 1.1 agc and prefix a V3 signature instead of doing a nested one-pass
3434 1.1 agc signature.
3435 1.1 agc
3436 1.1 agc * When exporting a private key, PGP 2.x generates the header "BEGIN
3437 1.1 agc PGP SECRET KEY BLOCK" instead of "BEGIN PGP PRIVATE KEY BLOCK".
3438 1.1 agc All previous versions ignore the implied data type, and look
3439 1.1 agc directly at the packet data type.
3440 1.1 agc
3441 1.1 agc * In a clear-signed signature, PGP 5.0 will figure out the correct
3442 1.1 agc hash algorithm if there is no "Hash:" header, but it will reject
3443 1.1 agc a mismatch between the header and the actual algorithm used. The
3444 1.1 agc "standard" (i.e. Zimmermann/Finney/et al.) version of PGP 2.x
3445 1.1 agc rejects the "Hash:" header and assumes MD5. There are a number of
3446 1.1 agc enhanced variants of PGP 2.6.x that have been modified for SHA-1
3447 1.1 agc signatures.
3448 1.1 agc
3449 1.1 agc * PGP 5.0 can read an RSA key in V4 format, but can only recognize
3450 1.1 agc it with a V3 keyid, and can properly use only a V3 format RSA
3451 1.1 agc key.
3452 1.1 agc
3453 1.1 agc * Neither PGP 5.x nor PGP 6.0 recognize Elgamal Encrypt and Sign
3454 1.1 agc keys. They only handle Elgamal Encrypt-only keys.
3455 1.1 agc
3456 1.1 agc * There are many ways possible for two keys to have the same key
3457 1.1 agc material, but different fingerprints (and thus key ids). Perhaps
3458 1.1 agc the most interesting is an RSA key that has been "upgraded" to V4
3459 1.1 agc format, but since a V4 fingerprint is constructed by hashing the
3460 1.1 agc key creation time along with other things, two V4 keys created at
3461 1.1 agc different times, yet with the same key material will have
3462 1.1 agc different fingerprints.
3463 1.1 agc
3464 1.1 agc * If an implementation is using zlib to interoperate with PGP 2.x,
3465 1.1 agc then the "windowBits" parameter should be set to -13.
3466 1.1 agc
3467 1.1 agc
3468 1.1 agc
3469 1.1 agc
3470 1.1 agc
3471 1.1 agc
3472 1.1 agc
3473 1.1 agc
3474 1.1 agc
3475 1.1 agc
3476 1.1 agc
3477 1.1 agc
3478 1.1 agc Callas, et. al. Standards Track [Page 61]
3479 1.1 agc
3481 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3482 1.1 agc
3483 1.1 agc
3484 1.1 agc 15. Authors and Working Group Chair
3485 1.1 agc
3486 1.1 agc The working group can be contacted via the current chair:
3487 1.1 agc
3488 1.1 agc John W. Noerenberg, II
3489 1.1 agc Qualcomm, Inc
3490 1.1 agc 6455 Lusk Blvd
3491 1.1 agc San Diego, CA 92131 USA
3492 1.1 agc
3493 1.1 agc Phone: +1 619-658-3510
3494 1.1 agc EMail: jwn2 (a] qualcomm.com
3495 1.1 agc
3496 1.1 agc
3497 1.1 agc The principal authors of this memo are:
3498 1.1 agc
3499 1.1 agc Jon Callas
3500 1.1 agc Network Associates, Inc.
3501 1.1 agc 3965 Freedom Circle
3502 1.1 agc Santa Clara, CA 95054, USA
3503 1.1 agc
3504 1.1 agc Phone: +1 408-346-5860
3505 1.1 agc EMail: jon (a] pgp.com, jcallas (a] nai.com
3506 1.1 agc
3507 1.1 agc
3508 1.1 agc Lutz Donnerhacke
3509 1.1 agc IKS GmbH
3510 1.1 agc Wildenbruchstr. 15
3511 1.1 agc 07745 Jena, Germany
3512 1.1 agc
3513 1.1 agc Phone: +49-3641-675642
3514 1.1 agc EMail: lutz (a] iks-jena.de
3515 1.1 agc
3516 1.1 agc
3517 1.1 agc Hal Finney
3518 1.1 agc Network Associates, Inc.
3519 1.1 agc 3965 Freedom Circle
3520 1.1 agc Santa Clara, CA 95054, USA
3521 1.1 agc
3522 1.1 agc EMail: hal (a] pgp.com
3523 1.1 agc
3524 1.1 agc
3525 1.1 agc Rodney Thayer
3526 1.1 agc EIS Corporation
3527 1.1 agc Clearwater, FL 33767, USA
3528 1.1 agc
3529 1.1 agc EMail: rodney (a] unitran.com
3530 1.1 agc
3531 1.1 agc
3532 1.1 agc
3533 1.1 agc
3534 1.1 agc
3535 1.1 agc Callas, et. al. Standards Track [Page 62]
3536 1.1 agc
3538 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3539 1.1 agc
3540 1.1 agc
3541 1.1 agc This memo also draws on much previous work from a number of other
3542 1.1 agc authors who include: Derek Atkins, Charles Breed, Dave Del Torto,
3543 1.1 agc Marc Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Raph
3544 1.1 agc Levien, Colin Plumb, Will Price, William Stallings, Mark Weaver, and
3545 1.1 agc Philip R. Zimmermann.
3546 1.1 agc
3547 1.1 agc 16. References
3548 1.1 agc
3549 1.1 agc [BLEICHENBACHER] Bleichenbacher, Daniel, "Generating ElGamal
3550 1.1 agc signatures without knowing the secret key,"
3551 1.1 agc Eurocrypt 96. Note that the version in the
3552 1.1 agc proceedings has an error. A revised version is
3553 1.1 agc available at the time of writing from
3554 1.1 agc <ftp://ftp.inf.ethz.ch/pub/publications/papers/ti/isc
3555 1.1 agc /ElGamal.ps>
3556 1.1 agc
3557 1.1 agc [BLOWFISH] Schneier, B. "Description of a New Variable-Length
3558 1.1 agc Key, 64-Bit Block Cipher (Blowfish)" Fast Software
3559 1.1 agc Encryption, Cambridge Security Workshop Proceedings
3560 1.1 agc (December 1993), Springer-Verlag, 1994, pp191-204
3561 1.1 agc
3562 1.1 agc <http://www.counterpane.com/bfsverlag.html>
3563 1.1 agc
3564 1.1 agc [DONNERHACKE] Donnerhacke, L., et. al, "PGP263in - an improved
3565 1.1 agc international version of PGP", ftp://ftp.iks-
3566 1.1 agc jena.de/mitarb/lutz/crypt/software/pgp/
3567 1.1 agc
3568 1.1 agc [ELGAMAL] T. ElGamal, "A Public-Key Cryptosystem and a
3569 1.1 agc Signature Scheme Based on Discrete Logarithms," IEEE
3570 1.1 agc Transactions on Information Theory, v. IT-31, n. 4,
3571 1.1 agc 1985, pp. 469-472.
3572 1.1 agc
3573 1.1 agc [IDEA] Lai, X, "On the design and security of block
3574 1.1 agc ciphers", ETH Series in Information Processing, J.L.
3575 1.1 agc Massey (editor), Vol. 1, Hartung-Gorre Verlag
3576 1.1 agc Knostanz, Technische Hochschule (Zurich), 1992
3577 1.1 agc
3578 1.1 agc [ISO-10646] ISO/IEC 10646-1:1993. International Standard --
3579 1.1 agc Information technology -- Universal Multiple-Octet
3580 1.1 agc Coded Character Set (UCS) -- Part 1: Architecture
3581 1.1 agc and Basic Multilingual Plane. UTF-8 is described in
3582 1.1 agc Annex R, adopted but not yet published. UTF-16 is
3583 1.1 agc described in Annex Q, adopted but not yet published.
3584 1.1 agc
3585 1.1 agc [MENEZES] Alfred Menezes, Paul van Oorschot, and Scott
3586 1.1 agc Vanstone, "Handbook of Applied Cryptography," CRC
3587 1.1 agc Press, 1996.
3588 1.1 agc
3589 1.1 agc
3590 1.1 agc
3591 1.1 agc
3592 1.1 agc Callas, et. al. Standards Track [Page 63]
3593 1.1 agc
3595 1.1 agc RFC 2440 OpenPGP Message Format November 1998
3596 1.1 agc
3597 1.1 agc
3598 1.1 agc [RFC822] Crocker, D., "Standard for the format of ARPA
3599 1.1 agc Internet text messages", STD 11, RFC 822, August
3600 1.1 agc 1982.
3601 1.1 agc
3602 1.1 agc [RFC1423] Balenson, D., "Privacy Enhancement for Internet
3603 1.1 agc Electronic Mail: Part III: Algorithms, Modes, and
3604 1.1 agc Identifiers", RFC 1423, October 1993.
3605 1.1 agc
3606 1.1 agc [RFC1641] Goldsmith, D. and M. Davis, "Using Unicode with
3607 1.1 agc MIME", RFC 1641, July 1994.
3608 1.1 agc
3609 1.1 agc [RFC1750] Eastlake, D., Crocker, S. and J. Schiller,
3610 1.1 agc "Randomness Recommendations for Security", RFC 1750,
3611 1.1 agc December 1994.
3612 1.1 agc
3613 1.1 agc [RFC1951] Deutsch, P., "DEFLATE Compressed Data Format
3614 1.1 agc Specification version 1.3.", RFC 1951, May 1996.
3615 1.1 agc
3616 1.1 agc [RFC1983] Malkin, G., "Internet Users' Glossary", FYI 18, RFC
3617 1.1 agc 1983, August 1996.
3618 1.1 agc
3619 1.1 agc [RFC1991] Atkins, D., Stallings, W. and P. Zimmermann, "PGP
3620 1.1 agc Message Exchange Formats", RFC 1991, August 1996.
3621 1.1 agc
3622 1.1 agc [RFC2015] Elkins, M., "MIME Security with Pretty Good Privacy
3623 1.1 agc (PGP)", RFC 2015, October 1996.
3624 1.1 agc
3625 1.1 agc [RFC2231] Borenstein, N. and N. Freed, "Multipurpose Internet
3626 1.1 agc Mail Extensions (MIME) Part One: Format of Internet
3627 1.1 agc Message Bodies.", RFC 2231, November 1996.
3628 1.1 agc
3629 1.1 agc [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
3630 1.1 agc Requirement Level", BCP 14, RFC 2119, March 1997.
3631 1.1 agc
3632 1.1 agc [RFC2144] Adams, C., "The CAST-128 Encryption Algorithm", RFC
3633 1.1 agc 2144, May 1997.
3634 1.1 agc
3635 1.1 agc [RFC2279] Yergeau., F., "UTF-8, a transformation format of
3636 1.1 agc Unicode and ISO 10646", RFC 2279, January 1998.
3637 1.1 agc
3638 1.1 agc [RFC2313] Kaliski, B., "PKCS #1: RSA Encryption Standard
3639 1.1 agc version 1.5", RFC 2313, March 1998.
3640 1.1 agc
3641 1.1 agc [SAFER] Massey, J.L. "SAFER K-64: One Year Later", B.
3642 1.1 agc Preneel, editor, Fast Software Encryption, Second
3643 1.1 agc International Workshop (LNCS 1008) pp212-241,
3644 Springer-Verlag 1995
3645
3646
3647
3648
3649 Callas, et. al. Standards Track [Page 64]
3650
3652 RFC 2440 OpenPGP Message Format November 1998
3653
3654
3655 17. Full Copyright Statement
3656
3657 Copyright (C) The Internet Society (1998). All Rights Reserved.
3658
3659 This document and translations of it may be copied and furnished to
3660 others, and derivative works that comment on or otherwise explain it
3661 or assist in its implementation may be prepared, copied, published
3662 and distributed, in whole or in part, without restriction of any
3663 kind, provided that the above copyright notice and this paragraph are
3664 included on all such copies and derivative works. However, this
3665 document itself may not be modified in any way, such as by removing
3666 the copyright notice or references to the Internet Society or other
3667 Internet organizations, except as needed for the purpose of
3668 developing Internet standards in which case the procedures for
3669 copyrights defined in the Internet Standards process must be
3670 followed, or as required to translate it into languages other than
3671 English.
3672
3673 The limited permissions granted above are perpetual and will not be
3674 revoked by the Internet Society or its successors or assigns.
3675
3676 This document and the information contained herein is provided on an
3677 "AS IS" basis and THE INTERNET SOCIETY AND THE INTERNET ENGINEERING
3678 TASK FORCE DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING
3679 BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION
3680 HEREIN WILL NOT INFRINGE ANY RIGHTS OR ANY IMPLIED WARRANTIES OF
3681 MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
3682
3683
3684
3685
3686
3687
3688
3689
3690
3691
3692
3693
3694
3695
3696
3697
3698
3699
3700
3701
3702
3703
3704
3705
3706 Callas, et. al. Standards Track [Page 65]
3707
3709