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