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