Home | History | Annotate | Line # | Download | only in ref
rfc1991.txt revision 1.1
      1 
      2 
      3 
      4 
      5 
      6 
      7 Network Working Group                                          D. Atkins
      8 Request for Comments: 1991                                           MIT
      9 Category: Informational                                     W. Stallings
     10                                                     Comp-Comm Consulting
     11                                                            P. Zimmermann
     12                                             Boulder Software Engineering
     13                                                              August 1996
     14 
     15 
     16                       PGP Message Exchange Formats
     17 
     18 Status of This Memo
     19 
     20    This memo provides information for the Internet community.  This memo
     21    does not specify an Internet standard of any kind.  Distribution of
     22    this memo is unlimited.
     23 
     24 Table of Contents
     25 
     26    1.    Introduction............................................2
     27    2.    PGP Services............................................2
     28    2.1   Digital signature.......................................3
     29    2.2   Confidentiality.........................................3
     30    2.3   Compression.............................................4
     31    2.4   Radix-64 conversion.....................................4
     32    2.4.1 ASCII Armor Formats.....................................5
     33    3.    Data Element Formats....................................6
     34    3.1   Byte strings............................................6
     35    3.2   Whole number fields.....................................7
     36    3.3   Multiprecision fields...................................7
     37    3.4   String fields...........................................8
     38    3.5   Time fields.............................................8
     39    4.    Common Fields...........................................8
     40    4.1   Packet structure fields.................................8
     41    4.2   Number ID fields.......................................10
     42    4.3   Version fields.........................................10
     43    5.    Packets................................................10
     44    5.1   Overview...............................................10
     45    5.2   General Packet Structure...............................11
     46    5.2.1 Message component......................................11
     47    5.2.2 Signature component....................................11
     48    5.2.3 Session key component..................................11
     49    6.    PGP Packet Types.......................................12
     50    6.1   Literal data packets...................................12
     51    6.2   Signature packets......................................13
     52    6.2.1 Message-digest-related fields..........................14
     53    6.2.2 Public-key-related fields..............................15
     54    6.2.3 RSA signatures.........................................16
     55 
     56 
     57 
     58 Atkins, et. al.              Informational                      [Page 1]
     59 
     61 RFC 1991              PGP Message Exchange Formats           August 1996
     62 
     63 
     64    6.2.4 Miscellaneous fields...................................16
     65    6.3   Compressed data packets................................17
     66    6.4   Conventional-key-encrypted data packets................17
     67    6.4.1 Conventional-encryption type byte......................18
     68    6.5   Public-key-encrypted packets...........................18
     69    6.5.1 RSA-encrypted data encryption key (DEK)................19
     70    6.6   Public-key Packets.....................................19
     71    6.7   User ID packets........................................20
     72    7.    Transferable Public Keys...............................20
     73    8.    Acknowledgments........................................20
     74    9.    Security Considerations................................21
     75    10.   Authors' Addresses.....................................21
     76 
     77 1. Introduction
     78 
     79    PGP (Pretty Good Privacy) uses a combination of public-key and
     80    conventional encryption to provide security services for electronic
     81    mail messages and data files.  These services include confidentiality
     82    and digital signature.  PGP is widely used throughout the global
     83    computer community.  This document describes the format of "PGP
     84    files", i.e., messages that have been encrypted and/or signed with
     85    PGP.
     86 
     87    PGP was created by Philip Zimmermann and first released, in Version
     88    1.0, in 1991. Subsequent versions have been designed and implemented
     89    by an all-volunteer collaborative effort under the design guidance of
     90    Philip Zimmermann.  PGP and Pretty Good Privacy are trademarks of
     91    Philip Zimmermann.
     92 
     93    This document describes versions 2.x of PGP.  Specifically, versions
     94    2.6 and 2.7 conform to this specification.  Version 2.3 conforms to
     95    this specification with minor differences.
     96 
     97    A new release of PGP, known as PGP 3.0, is anticipated in 1995. To
     98    the maximum extent possible, this version will be upwardly compatible
     99    with version 2.x. At a minimum, PGP 3.0 will be able to read messages
    100    and signatures produced by version 2.x.
    101 
    102 2. PGP Services
    103 
    104    PGP provides four services related to the format of messages and data
    105    files: digital signature, confidentiality, compression, and radix-64
    106    conversion.
    107 
    108 
    109 
    110 
    111 
    112 
    113 
    114 
    115 Atkins, et. al.              Informational                      [Page 2]
    116 
    118 RFC 1991              PGP Message Exchange Formats           August 1996
    119 
    120 
    121 2.1 Digital signature
    122 
    123    The digital signature service involves the use of a hash code, or
    124    message digest, algorithm, and a public-key encryption algorithm. The
    125    sequence is as follows:
    126 
    127      -the sender creates a message
    128      -the sending PGP generates a hash code of the message
    129      -the sending PGP encrypts the hash code using the sender's private
    130       key
    131      -the encrypted hash code is prepended to the message
    132      -the receiving PGP decrypts the hash code using the sender's public
    133       key
    134      -the receiving PGP generates a new hash code for the received
    135       message and compares it to the decrypted hash code. If the two
    136       match, the message is accepted as authentic
    137 
    138    Although signatures normally are found attached to the message or
    139    file that they sign, this is not always the case: detached signatures
    140    are supported. A detached signature may be stored and transmitted
    141    separately from the message it signs.  This is useful in several
    142    contexts. A user may wish to maintain a separate signature log of all
    143    messages sent or received.  A detached signature of an executable
    144    program can detect subsequent virus infection. Finally, detached
    145    signatures can be used when more than one party must sign a document,
    146    such as a legal contract.  Each person's signature is independent and
    147    therefore is applied only to the document. Otherwise, signatures
    148    would have to be nested, with the second signer signing both the
    149    document and the first signature, and so on.
    150 
    151 2.2 Confidentiality
    152 
    153    PGP provides confidentiality by encrypting messages to be transmitted
    154    or data files to be stored locally using conventional encryption. In
    155    PGP, each conventional key is used only once. That is, a new key is
    156    generated as a random 128-bit number for each message. Since it is to
    157    be used only once, the session key is bound to the message and
    158    transmitted with it.  To protect the key, it is encrypted with the
    159    receiver's public key. The sequence is as follows:
    160 
    161      -the sender creates a message
    162      -the sending PGP generates a random number to be used as a session
    163       key for this message only
    164      -the sending PGP encrypts the message using the session key
    165      -the session key is encrypted using the recipient's public key and
    166       prepended to the encrypted message
    167      -the receiving PGP decrypts the session key using the recipient's
    168       private key
    169 
    170 
    171 
    172 Atkins, et. al.              Informational                      [Page 3]
    173 
    175 RFC 1991              PGP Message Exchange Formats           August 1996
    176 
    177 
    178      -the receiving PGP decrypts the message using the session key
    179 
    180    Both digital signature and confidentiality services may be applied to
    181    the same message. First, a signature is generated for the message and
    182    prepended to the message.  Then, the message plus signature is
    183    encrypted using a conventional session key. Finally, the session key
    184    is encrypted using public-key encryption and prepended to the
    185    encrypted block.
    186 
    187 2.3 Compression
    188 
    189    As a default, PGP compresses the message after applying the signature
    190    but before encryption.
    191 
    192 2.4 Radix-64 conversion
    193 
    194    When PGP is used, usually part of the block to be transmitted is
    195    encrypted. If only the signature service is used, then the message
    196    digest is encrypted (with the sender's private key). If the
    197    confidentiality service is used, the message plus signature (if
    198    present) are encrypted (with a one-time conventional key). Thus, part
    199    or all of the resulting block consists of a stream of arbitrary 8-bit
    200    bytes.  However, many electronic mail systems only permit the use of
    201    blocks consisting of ASCII text. To accommodate this restriction, PGP
    202    provides the service of converting the raw 8-bit binary stream to a
    203    stream of printable ASCII characters, called ASCII Armor.
    204 
    205    The scheme used for this purpose is radix-64 conversion. Each group
    206    of three bytes of binary data is mapped into 4 ASCII characters. This
    207    format also appends a CRC to detect transmission errors.  This
    208    radix-64 conversion, also called Ascii Armor, is a wrapper around the
    209    binary PGP messages, and is used to protect the binary messages
    210    during transmission over non-binary channels, such as Internet Email.
    211 
    212    The following table defines the mapping.  The characters used are the
    213    upper- and lower-case letters, the digits 0 through 9, and the
    214    characters + and /.  The carriage-return and linefeed characters
    215    aren't used in the conversion, nor is the tab or any other character
    216    that might be altered by the mail system. The result is a text file
    217    that is "immune" to the modifications inflicted by mail systems.
    218 
    219 
    220 
    221 
    222 
    223 
    224 
    225 
    226 
    227 
    228 
    229 Atkins, et. al.              Informational                      [Page 4]
    230 
    232 RFC 1991              PGP Message Exchange Formats           August 1996
    233 
    234 
    235    6-bit character   6-bit character   6-bit character   6-bit character
    236    value encoding  value  encoding    value   encoding    value encoding
    237    0        A        16        Q        32        g        48        w
    238    1        B        17        R        33        h        49        x
    239    2        C        18        S        34        i        50        y
    240    3        D        19        T        35        j        51        z
    241    4        E        20        U        36        k        52        0
    242    5        F        21        V        37        l        53        1
    243    6        G        22        W        38        m        54        2
    244    7        H        23        X        39        n        55        3
    245    8        I        24        Y        40        o        56        4
    246    9        J        25        Z        41        p        57        5
    247    1        K        26        a        42        q        58        6
    248    11       L        27        b        43        r        59        7
    249    12       M        28        c        44        s        60        8
    250    13       N        29        d        45        t        61        9
    251    14       O        30        e        46        u        62        +
    252    15       P        31        f        47        v        63        /
    253                                                          (pad)       =
    254 
    255    It is possible to use PGP to convert any arbitrary file to ASCII
    256    Armor.  When this is done, PGP tries to compress the data before it
    257    is converted to Radix-64.
    258 
    259 2.4.1 ASCII Armor Formats
    260 
    261    When PGP encodes data into ASCII Armor, it puts specific headers
    262    around the data, so PGP can reconstruct the data at a future time.
    263    PGP tries to inform the user what kind of data is encoded in the
    264    ASCII armor through the use of the headers.
    265 
    266    ASCII Armor is created by concatenating the following data:
    267 
    268         - An Armor Headerline, appropriate for the type of data
    269         - Armor Headers
    270         - A blank line
    271         - The ASCII-Armored data
    272         - An Armor Checksum
    273         - The Armor Tail (which depends on the Armor Headerline).
    274 
    275    An Armor Headerline is composed by taking the appropriate headerline
    276    text surrounded by five (5) dashes (-) on either side of the
    277    headerline text.  The headerline text is chosen based upon the type
    278    of data that is being encoded in Armor, and how it is being encoded.
    279    Headerline texts include the following strings:
    280 
    281     BEGIN PGP MESSAGE -- used for signed, encrypted, or compressed files
    282     BEGIN PGP PUBLIC KEY BLOCK -- used for transferring public keys
    283 
    284 
    285 
    286 Atkins, et. al.              Informational                      [Page 5]
    287 
    289 RFC 1991              PGP Message Exchange Formats           August 1996
    290 
    291 
    292     BEGIN PGP MESSAGE, PART X/Y -- used for multi-part messages, where
    293                                     the armor is split amongst Y files,
    294                                     and this is the Xth file out of Y.
    295 
    296    The Armor Headers are pairs of strings that can give the user or the
    297    receiving PGP program some information about how to decode or use the
    298    message.  The Armor Headers are a part of the armor, not a part of
    299    the message, and hence should not be used to convey any important
    300    information, since they can be changed in transport.
    301 
    302    The format of an Armor Header is that of a key-value pair, the
    303    encoding of RFC-822 headers.  PGP should consider improperly
    304    formatted Armor Headers to be corruption of the ASCII Armor.  Unknown
    305    Keys should be reported to the user, but so long as the RFC-822
    306    formatting is correct, PGP should continue to process the message.
    307    Currently defined Armor Header Keys include "Version" and "Comment",
    308    which define the PGP Version used to encode the message and a user-
    309    defined comment.
    310 
    311    The Armor Checksum is a 24-bit CRC converted to four bytes of radix-
    312    64 encoding, prepending an equal-sign (=) to the four-byte code.  The
    313    CRC is computed by using the generator 0x864CFB and an initialization
    314    of 0xB704CE.  The accumulation is done on the data before it is
    315    converted to radix-64, rather than on the converted data.  For more
    316    information on CRC functions, the reader is asked to look at chapter
    317    19 of the book "C Programmer's Guide to Serial Communications," by
    318    Joe Campbell.
    319 
    320    The Armor Tail is composed in the same manner as the Armor
    321    Headerline, except the string "BEGIN" is replaced by the string
    322    "END".
    323 
    324 3. Data Element Formats
    325 
    326 3.1 Byte strings
    327 
    328    The objects considered in this document are all "byte strings."  A
    329    byte string is a finite sequence of bytes.  The concatenation of byte
    330    string X of length M with byte string Y of length N is a byte string
    331    Z of length M + N; the first M bytes of Z are the bytes of X in the
    332    same order, and the remaining N bytes of Z are the bytes of Y in the
    333    same order.
    334 
    335    Literal byte strings are written from left to right, with pairs of
    336    hex nibbles separated by spaces, enclosed by angle brackets: for
    337    instance, <05 ff 07> is a byte string of length 3 whose bytes have
    338    numeric values 5, 255, and 7 in that order.  All numbers in this
    339    document outside angle brackets are written in decimal.
    340 
    341 
    342 
    343 Atkins, et. al.              Informational                      [Page 6]
    344 
    346 RFC 1991              PGP Message Exchange Formats           August 1996
    347 
    348 
    349    The byte string of length 0 is called "empty" and written <>.
    350 
    351 3.2 Whole number fields
    352 
    353    Purpose.  A whole number field can represent any nonnegative integer,
    354    in a format where the field length is known in advance.
    355 
    356    Definition.  A whole number field is any byte string.  It is stored
    357    in radix-256 MSB-first format.  This means that a whole number field
    358    of length N with bytes b_0 b_1 ...  b_{N-2} b_{N-1} in that order has
    359    value
    360 
    361       b_0 * 256^{N-1} + b_1 * 256^{N-2} + ... + b_{N-2} * 256 + b_{N-1}.
    362 
    363    Examples.  The byte string <00 0D 64 11 00 00> is a valid whole
    364    number field with value 57513410560.  The byte string <FF> is a valid
    365    whole number field with value 255.  The byte string <00 00> is a
    366    valid whole number field with value 0.  The empty byte string <> is a
    367    valid whole number field with value 0.
    368 
    369 3.3 Multiprecision fields
    370 
    371    Purpose.  A multiprecision field can represent any nonnegative
    372    integer which is not too large.  The field length need not be known
    373    in advance.  Multiprecision fields are designed to waste very little
    374    space: a small integer uses a short field.
    375 
    376    Definition.  A multiprecision field is the concatenation of two
    377    fields:
    378 
    379       (a) a whole number field of length 2, with value B;
    380       (b) a whole number field, with value V.
    381 
    382    Field (b) is of length [(B+7)/8], i.e., the greatest integer which is
    383    no larger than (B+7)/8.  The value of the multiprecision field is
    384    defined to be V.  V must be between 2^{B-1} and 2^B - 1 inclusive.
    385    In other words B must be exactly the number of significant bits in V.
    386 
    387    Some implementations may limit the possible range of B.  The
    388    implementor must document which values of B are allowed by an
    389    implementation.
    390 
    391    Examples.  The byte string <00 00> is a valid multiprecision integer
    392    with value 0.  The byte string <00 03 05> is a valid multiprecision
    393    field with value 5.  The byte strings <00 03 85> and <00 00 00> are
    394    not valid multiprecision fields.  The former is invalild because <85>
    395    has 8 significant bits, not 3; the latter is invalid because the
    396    second field has too many bytes of data given the value of the first
    397 
    398 
    399 
    400 Atkins, et. al.              Informational                      [Page 7]
    401 
    403 RFC 1991              PGP Message Exchange Formats           August 1996
    404 
    405 
    406    field.  The byte string <00 09 01 ff> is a valid multiprecision field
    407    with value 511.  The byte string <01 00 80 00 00 00 00 00 00 00 00 00
    408    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 07> is
    409    a valid multiprecision field with value 2^255 + 7.
    410 
    411 3.4  String fields
    412 
    413    Purpose.  A string field represents any sequence of bytes of length
    414    between 0 and 255 inclusive.  The length need not be known in
    415    advance.  By convention, the content of a string field is normally
    416    interpreted as ASCII codes when it is displayed.
    417 
    418    Definition.  A string field is the concatenation of the following:
    419 
    420      (a) a whole number field of length 1, with value L;
    421      (b) a byte string of length L.
    422 
    423    The content of the string field is defined to be field (b).
    424 
    425    Examples: <05 48 45 4c 4c 4f> is a valid string field which would
    426    normally be displayed as the string HELLO.  <00> is a valid string
    427    field which would normally be displayed as the empty string.  <01 00>
    428    is a valid string field.
    429 
    430 3.5  Time fields
    431 
    432    Purpose.  A time field represents the number of seconds elapsed since
    433    1970 Jan 1 00:00:00 GMT.  It is compatible with the usual
    434    representation of times under UNIX.
    435 
    436    Definition.  A time field is a whole number field of length 4, with
    437    value V.  The time represented by the time field is the one-second
    438    interval beginning V seconds after 1970 Jan 1 00:00:00 GMT.
    439 
    440 4. Common Fields
    441 
    442    This section defines fields found in more than one packet format.
    443 
    444 4.1  Packet structure fields
    445 
    446    Purpose.  The packet structure field distinguishes between different
    447    types of packets, and indicates the length of packets.
    448 
    449    Definition.  A packet structure field is a byte string of length 1,
    450    2, 3, or 5.  Its first byte is the cipher type byte (CTB), with bits
    451    labeled 76543210, 7 the most significant bit and 0 the least
    452    significant bit.  As indicated below the length of the packet
    453    structure field is determined by the CTB.
    454 
    455 
    456 
    457 Atkins, et. al.              Informational                      [Page 8]
    458 
    460 RFC 1991              PGP Message Exchange Formats           August 1996
    461 
    462 
    463       CTB bits 76 have values listed in the following table:
    464 
    465       10 - normal CTB
    466       11 - reserved for future experimental work
    467       all others - reserved
    468 
    469    CTB bits 5432, the "packet type bits", have values listed in the
    470    following table:
    471 
    472       0001 - public-key-encrypted packet
    473       0010 - signature packet
    474       0101 - secret-key certificate packet
    475       0110 - public-key certificate packet
    476       1000 - compressed data packet
    477       1001 - conventional-key-encrypted packet
    478       1011 - literal data packet
    479       1100 - keyring trust packet
    480       1101 - user id packet
    481       1110 - comment packet     (*)
    482       all others - reserved
    483 
    484    CTB bits 10, the "packet-length length bits", have values listed in
    485    the following table:
    486 
    487       00 - 1-byte packet-length field
    488       01 - 2-byte packet-length field
    489       10 - 4-byte packet-length field
    490       11 - no packet length supplied, unknown packet length
    491 
    492    As indicated in this table, depending on the packet-length length
    493    bits, the remaining 1, 2, 4, or 0 bytes of the packet structure field
    494    are a "packet-length field".  The packet-length field is a whole
    495    number field.  The value of the packet-length field is defined to be
    496    the value of the whole number field.
    497 
    498    A value of 11 is currently used in one place: on compressed data.
    499    That is, a compressed data block currently looks like <A3 01 . .  .>,
    500    where <A3>, binary 10 1000 11, is an indefinite-length packet. The
    501    proper interpretation is "until the end of the enclosing structure",
    502    although it should never appear outermost (where the enclosing
    503    structure is a file).
    504 
    505    Options marked with an asterisk (*) are not implemented yet; PGP
    506    2.6.2 will never output this packet type.
    507 
    508 
    509 
    510 
    511 
    512 
    513 
    514 Atkins, et. al.              Informational                      [Page 9]
    515 
    517 RFC 1991              PGP Message Exchange Formats           August 1996
    518 
    519 
    520 4.2  Number ID fields
    521 
    522    Purpose.  The ID of a whole number is its 64 least significant bits.
    523    The ID is a convenient way to distinguish between large numbers such
    524    as keys, without having to transmit the number itself. Thus, a number
    525    that may be hundreds or thousands of decimal digits in length can be
    526    identified with a 64-bit identifier. Two keys may have the same ID by
    527    chance or by malice; although the probability that two large keys
    528    chosen at random would have the same ID is extremely small.
    529 
    530    Definition.  A number ID field is a whole number field of length 8.
    531    The value of the number ID field is defined to be the value of the
    532    whole number field.
    533 
    534 4.3  Version fields
    535 
    536    Many packet types include a version number as the first byte of the
    537    body.  The format and meaning of the body depend on the version
    538    number.  More versions of packets, with new version numbers, may be
    539    defined in the future.  An implementation need not support every
    540    version of each packet type.  However, the implementor must document
    541    which versions of each packet type are supported by the
    542    implementation.
    543 
    544    A version number of 2 or 3 is currently allowed for each packet
    545    format.  New versions will probably be numbered sequentially up from
    546    3.  For backwards compatibility, implementations will usually be
    547    expected to support version N of a packet whenever they support
    548    version N+1.  Version 255 may be used for experimental purposes.
    549 
    550 5. Packets
    551 
    552 5.1 Overview
    553 
    554    A packet is a digital envelope with data inside.  A PGP file, by
    555    definition, is the concatenation of one or more packets. In addition,
    556    one or more of the packets in a file may be subject to a
    557    transformation using encryption, compression, or radix-64 conversion.
    558 
    559    A packet is the concatenation of the following:
    560 
    561       (a) a packet structure field;
    562       (b) a byte string of some length N.
    563 
    564    Byte string (b) is called the "body" of the packet.  The value of the
    565    packet-length field inside the packet structure field (a) must equal
    566    N, the length of the body.
    567 
    568 
    569 
    570 
    571 Atkins, et. al.              Informational                     [Page 10]
    572 
    574 RFC 1991              PGP Message Exchange Formats           August 1996
    575 
    576 
    577    Other characteristics of the packet are determined by the type of the
    578    packet.  See the definitions of particular packet types for further
    579    details.  The CTB packet-type bits inside the packet structure always
    580    indicate the packet type.
    581 
    582    Note that packets may be nested: one digital envelope may be placed
    583    inside another.  For example, a conventional-key-encrypted packet
    584    contains a disguised packet, which in turn might be a compressed data
    585    packet.
    586 
    587 5.2  General packet structure
    588 
    589    A pgp file consists of three components: a message component, a
    590    signature (optional), and a session key component (optional).
    591 
    592 5.2.1 Message component
    593 
    594    The message component includes the actual data to be stored or
    595    transmitted as well as a header that includes control information
    596    generated by PGP. The message component consists of a single literal
    597    data packet.
    598 
    599 5.2.2 Signature component
    600 
    601    The signature component is the signature of the message component,
    602    formed using a hash code of the message component and the public key
    603    of the sending PGP entity.  The signature component consists of a
    604    single signature packet.
    605 
    606    If the default option of compression is chosen, then the block
    607    consisting of the literal data packet and the signature packet is
    608    compressed to form a compressed data packet.
    609 
    610 5.2.3 Session key component
    611 
    612    The session key component includes the encrypted session key and the
    613    identifier of the recipients public key used by the sender to encrypt
    614    the session key.  The session key component consists of a single
    615    public-key-encrypted packet for each recipient of the message.
    616 
    617    If compression has been used, then conventional encryption is applied
    618    to the compressed data packet formed from the compression of the
    619    signature packet and the literal data packet. Otherwise, conventional
    620    encryption is applied to the block consisting of the signature packet
    621    and the literal data packet.  In either case, the cyphertext is
    622    referred to as a conventional-key-encrypted data packet.
    623 
    624 
    625 
    626 
    627 
    628 Atkins, et. al.              Informational                     [Page 11]
    629 
    631 RFC 1991              PGP Message Exchange Formats           August 1996
    632 
    633 
    634 6.  PGP Packet Types
    635 
    636    PGP includes the following types of packets:
    637 
    638        -literal data packet
    639        -signature packet
    640        -compressed data packet
    641        -conventional-key-encrypted data packet
    642        -public-key-encrypted packet
    643        -public-key packet
    644        -User ID packet
    645 
    646 6.1 Literal data packets
    647 
    648    Purpose.  A literal data packet is the lowest level of contents of a
    649    digital envelope.  The data inside a literal data packet is not
    650    subject to any further interpretation by PGP.
    651 
    652    Definition.  A literal data packet is the concatenation of the
    653    following fields:
    654 
    655       (a) a packet structure field;
    656       (b) a byte, giving a mode;
    657       (c) a string field, giving a filename;
    658       (d) a time field;
    659       (e) a byte string of literal data.
    660 
    661 
    662    Fields (b), (c), and (d) suggest how the data should be written to a
    663    file. Byte (b) is either ASCII b <62>, for binary, or ASCII t <74>,
    664    for text. Byte (b) may also take on the value ASCII 1, indicating a
    665    machine-local conversion. It is not defined how PGP will convert this
    666    across platforms.
    667 
    668    Field (c) suggests a filename. Field (d) should be the time at which
    669    the file was last modified, or the time at which the data packet was
    670    created, or 0.
    671 
    672    Note that only field (e) of a literal data packet is fed to a
    673    message-digest function for the formation of a signature. The
    674    exclusion of the other fields ensures that detached signatures are
    675    exactly the same as attached signatures prefixed to the message.
    676    Detached signatures are calculated on a separate file that has none
    677    of the literal data packet header fields.
    678 
    679 
    680 
    681 
    682 
    683 
    684 
    685 Atkins, et. al.              Informational                     [Page 12]
    686 
    688 RFC 1991              PGP Message Exchange Formats           August 1996
    689 
    690 
    691 6.2 Signature packet
    692 
    693    Purpose.  Signatures are attached to data, in such a way that only
    694    one entity, called the "writer," can create the signature.  The
    695    writer must first create a "public key" K and distribute it.  The
    696    writer keeps certain private data related to K.  Only someone
    697    cooperating with the writer can sign data using K, enveloping the
    698    data in a signature packet (also known as a private-key-encrypted
    699    packet).  Anyone can look through the glass in the envelope and
    700    verify that the signature was attached to the data using K.  If the
    701    data is altered in any way then the verification will fail.
    702 
    703    Signatures have different meanings.  For example, a signature might
    704    mean "I wrote this document," or "I received this document."  A
    705    signature packet includes a "classification" which expresses its
    706    meaning.
    707 
    708    Definition.  A signature packet, version 2 or 3, is the concatenation
    709    of the following fields:
    710 
    711       (a) packet structure field (2, 3, or 5 bytes);
    712       (b) version number = 2 or 3 (1 byte);
    713       (c) length of following material included in MD calculation
    714           (1 byte, always the value 5);
    715       (d1) signature classification (1 byte);
    716       (d2) signature time stamp (4 bytes);
    717       (e) key ID for key used for singing (8 bytes);
    718       (f) public-key-cryptosystem (PKC) type (1 byte);
    719       (g) message digest algorithm type (1 byte);
    720       (h) first two bytes of the MD output, used as a checksum
    721           (2 bytes);
    722       (i) a byte string of encrypted data holding the RSA-signed digest.
    723 
    724    The message digest is taken of the bytes of the file, followed by the
    725    bytes of field (d). It was originally intended that the length (c)
    726    could vary, but now it seems that it will alwaye remain a constant
    727    value of 5, and that is the only value that will be accepted.  Thus,
    728    only the fields (d1) and (d2) will be hashed into the signature along
    729    with the main message.
    730 
    731 
    732 
    733 
    734 
    735 
    736 
    737 
    738 
    739 
    740 
    741 
    742 Atkins, et. al.              Informational                     [Page 13]
    743 
    745 RFC 1991              PGP Message Exchange Formats           August 1996
    746 
    747 
    748 6.2.1 Message-digest-related fields
    749 
    750    The message digest algorithm is specified by the message digest (MD)
    751    number of field (g). The following MD numbers are currently defined:
    752 
    753       1 - MD5 (output length 16)
    754       255 - experimental
    755 
    756    More MD numbers may be defined in the future.  An implementation need
    757    not support every MD number.  The implementor must document the MD
    758    numbers understood by an implementation.
    759 
    760    A message digest algorithm reads a byte string of any length, and
    761    writes a byte string of some fixed length, as indicated in the table
    762    above.
    763 
    764    The input to the message digest algorithm is the concatenation of
    765    some "primary input" and some "appended input."
    766 
    767    The appended input is specified by field (c), which gives a number of
    768    bytes to be taken from the following fields: (d1), (d2), and so on.
    769    The current implementation uses the value 5 for this number, for
    770    fields (d1) and (d2).  Any field not included in the appended input
    771    is not "signed" by field (i).
    772 
    773    The primary input is determined by the signature classification byte
    774    (d1).  Byte (d1) is one of the following hex numbers, with these
    775    meanings:
    776 
    777      <00> - document signature, binary image ("I wrote this document")
    778      <01> - document signature, canonical text ("I wrote this document")
    779      <10> - public key packet and user ID packet, generic certification
    780           ("I think this key was created by this user, but I won't say
    781           how sure I am")
    782      <11> - public key packet and user ID packet, persona certification
    783           ("This key was created by someone who has told me that he is
    784           this user") (#)
    785      <12> - public key packet and user ID packet, casual certification
    786           ("This key was created by someone who I believe, after casual
    787           verification, to be this user")  (#)
    788      <13> - public key packet and user ID packet, positive certification
    789           ("This key was created by someone who I believe, after
    790           heavy-duty identification such as picture ID, to be this
    791           user")  (#)
    792      <20> - public key packet, key compromise ("This is my key, and I
    793           have revoked it")
    794 
    795 
    796 
    797 
    798 
    799 Atkins, et. al.              Informational                     [Page 14]
    800 
    802 RFC 1991              PGP Message Exchange Formats           August 1996
    803 
    804 
    805      <30> - public key packet and user ID packet, revocation ("I retract
    806           all my previous statements that this key is related to this
    807           user")  (*)
    808      <40> - time stamping ("I saw this document") (*)
    809 
    810    More classification numbers may be defined in the future to handle
    811    other meanings of signatures, but only the above numbers may be used
    812    with version 2 or version 3 of a signature packet.  It should be
    813    noted that PGP 2.6.2 has not implemented the packets marked with an
    814    asterisk (*), and the packets marked with a hash (#) are not output
    815    by PGP 2.6.2.
    816 
    817    Signature packets are used in two different contexts. One (signature
    818    type <00> or <01>) is of text (either the contents of a literal
    819    packet or a separate file), while types <10> through <1F> appear only
    820    in key files, after the keys and user IDs that they sign.  Type <20>
    821    appears in key files, after the keys that it signs, and type <30>
    822    also appears after a key/userid combination. Type <40> is intended to
    823    be a signature of a signature, as a notary seal on a signed document.
    824 
    825    The output of the message digest algorithm is a message digest, or
    826    hash code. Field i contains the cyphertext produced by encrypting the
    827    message digest with the signer's private key.  Field h contains the
    828    first two bytes of the unencrypted message digest. This enables the
    829    recipient to determine if the correct public key was used to decrypt
    830    the message digest for authentication, by comparing this plaintext
    831    copy of the first two byes with the first two bytes of the decrypted
    832    digest. These two bytes also serve as a 16-bit frame check sequence
    833    for the message.
    834 
    835 6.2.2 Public-key-related fields
    836 
    837    The message digest is signed by encrypting it using the writer's
    838    private key. Field (e) is the ID of the corresponding public key.
    839 
    840    The public-key-encryption algorithm is specified by the public-key
    841    cryptosystem (PKC) number of field (f). The following PKC numbers are
    842    currently defined:
    843 
    844       1 - RSA
    845       255 - experimental
    846 
    847    More PKC numbers may be defined in the future.  An implementation
    848    need not support every PKC number.  The implementor must document the
    849    PKC numbers understood by an implementation.
    850 
    851 
    852 
    853 
    854 
    855 
    856 Atkins, et. al.              Informational                     [Page 15]
    857 
    859 RFC 1991              PGP Message Exchange Formats           August 1996
    860 
    861 
    862    A PKC number identifies both a public-key encryption method and a
    863    signature method.  Both of these methods are fully defined as part of
    864    the definition of the PKC number.  Some cryptosystems are usable only
    865    for encryption, or only for signatures; if any such PKC numbers are
    866    defined in the future, they will be marked appropriately.
    867 
    868 6.2.3 RSA signatures
    869 
    870    An RSA-signed byte string is a multiprecision field that is formed by
    871    taking the message digest and filling in an ASN structure, and then
    872    encrypting the whole byte string in the RSA key of the signer.
    873 
    874    PGP versions 2.3 and later encode the MD into a PKCS-format signature
    875    string, which has the following format:
    876 
    877           MSB               .   .   .                    LSB
    878           0   1   <FF>(n bytes)   0   ASN(18 bytes)   MD(16 bytes)
    879 
    880    See RFC1423 for an explanation of the meaning of the ASN string.  It
    881    is the following 18 byte long hex value:
    882 
    883           <30 20 30 0C 06 08 2A 86 48 86 F7 0D 02 05 05 00 04 10>
    884 
    885    Enough bytes of <FF> padding are added to make the length of this
    886    whole string equal to the number of bytes in the modulus.
    887 
    888 6.2.4 Miscellaneous fields
    889 
    890    The timestamp field (d2) is analogous to the date box next to a
    891    signature box on a form.  It represents a time which is typically
    892    close to the moment that the signature packet was created.  However,
    893    this is not a requirement.  Users may choose to date their signatures
    894    as they wish, just as they do now in handwritten signatures.
    895 
    896    If an application requires the creation of trusted timestamps on
    897    signatures, a detached signature certificate with an untrusted
    898    timestamp may be submitted to a trusted timestamp notary service to
    899    sign the signature packet with another signature packet, creating a
    900    signature of a signature.  The notary's signature's timestamp could
    901    be used as the trusted "legal" time of the original signature.
    902 
    903 
    904 
    905 
    906 
    907 
    908 
    909 
    910 
    911 
    912 
    913 Atkins, et. al.              Informational                     [Page 16]
    914 
    916 RFC 1991              PGP Message Exchange Formats           August 1996
    917 
    918 
    919 6.3 Compressed data packets
    920 
    921    Purpose.  A compressed data packet is an envelope which safely
    922    squeezes its contents into a small space.
    923 
    924    Definition.  A compressed data packet is the concatenation of the
    925    following fields:
    926 
    927       (a) a packet structure field;
    928       (b) a byte, giving a compression type;
    929       (c) a byte string of compressed data.
    930 
    931    Byte string (c) is a packet which may be decompressed using the
    932    algorithm identified in byte (b).  Typically, the data that are
    933    compressed consist of a literal data packet or a signature packet
    934    concatenated to a literal data packet.
    935 
    936    A compression type selects a compression algorithm for use in
    937    compressed data packets.  The following compression numbers are
    938    currently defined.
    939 
    940       1 - ZIP
    941       255 - experimental
    942 
    943    More compression numbers may be defined in the future.  An
    944    implementation need not support every MD number.  The implementor
    945    must document the compression numbers understood by an
    946    implementation.
    947 
    948 6.4 Conventional-key-encrypted data packets
    949 
    950    Purpose.  A conventional-key-encrypted data packet is formed by
    951    encrypting a block of data with a conventional encryption algorithm
    952    using a one-time session key. Typically, the block to be encrypted is
    953    a compressed data packet.
    954 
    955    Definition.  A conventional-key-encrypted data packet is the
    956    concatenation of the following fields:
    957 
    958       (a) a packet structure field;
    959       (b) a byte string of encrypted data.
    960 
    961    The plaintext or compressed plaintext that is encrypted to form field
    962    (b) is first prepended with 64 bits of random data plus 16 "key
    963    check" bits.  The random prefix serves to start off the cipher
    964    feedback chaining process with 64 bits of random material; this
    965    serves the same function as an initialization vector (IV) for a
    966    cipher-block-chaining encryption scheme.  The key check prefix is
    967 
    968 
    969 
    970 Atkins, et. al.              Informational                     [Page 17]
    971 
    973 RFC 1991              PGP Message Exchange Formats           August 1996
    974 
    975 
    976    equal to the last 16 bits of the random prefix. During decryption, a
    977    comparison is made to see if the 7th and 8th byte of the decrypted
    978    material match the 9th and 10th bytes.  If so, then the conventional
    979    session key used for decryption is assumed to be correct.
    980 
    981 6.4.1 Conventional-encryption type byte
    982 
    983    Purpose.  The conventional-encryption type byte is used to determine
    984    what conventional encryption algorithm is in use.  The algorithm type
    985    byte will also define how long the conventional encryption key is,
    986    based upon the algorithm in use.
    987 
    988    Definition.  A conventional-encryption type byte is a single byte
    989    which defines the algorithm in use.  It is possible that the
    990    algorithm in use may require further definition, such as key-length.
    991    It is up to the implementor to document the supported key-length in
    992    such a situation.
    993 
    994       1 - IDEA (16-byte key)
    995       255 - experimental
    996 
    997 6.5 Public-key-encrypted packets
    998 
    999    Purpose.  The public-key-encrypted packet is the format for the
   1000    session key component of a message. The purpose of this packet is to
   1001    convey the one-time session key used to encrypt the message to the
   1002    recipient in a secure manner. This is done by encrypting the session
   1003    key with the recipient's public key, so that only the recipient can
   1004    recover the session key.
   1005 
   1006    Definition.  A public-key-encrypted packet, version 2 or 3, is the
   1007    concatenation of the following fields:
   1008 
   1009       (a) a packet structure field;
   1010       (b) a byte, giving the version number, 2 or 3;
   1011       (c) a number ID field, giving the ID of a key;
   1012       (d) a byte, giving a PKC number;
   1013       (e) a byte string of encrypted data (DEK).
   1014 
   1015    Byte string (e) represents the value of the session key, encrypted
   1016    using the reader's public key K, under the cryptosystem identified in
   1017    byte (d).
   1018 
   1019    The value of field (c) is the ID of K.
   1020 
   1021    Note that the packet does not actually identify K: two keys may have
   1022    the same ID, by chance or by malice.  Normally it will be obvious
   1023    from the context which key K was used to create the packet.  But
   1024 
   1025 
   1026 
   1027 Atkins, et. al.              Informational                     [Page 18]
   1028 
   1030 RFC 1991              PGP Message Exchange Formats           August 1996
   1031 
   1032 
   1033    sometimes it is not obvious.  In this case field (c) is useful.  If,
   1034    for example, a reader has created several keys, and receives a
   1035    message, then he should attempt to decrypt the message only with the
   1036    key whose ID matches the value of field (c).  If he has accidentally
   1037    generated two keys with the same ID, then he must attempt to decrypt
   1038    the message with both keys, but this case is highly unlikely to occur
   1039    by chance.
   1040 
   1041 6.5.1 RSA-encrypted data encryption key (DEK)
   1042 
   1043    The Data Encryption Key (DEK) is a multiprecision field which stores
   1044    an RSA encrypted byte string.  The byte string is a PKCS encoding of
   1045    the secret key used the encrypt the message, with random padding for
   1046    each Public-Key encrypted packet.
   1047 
   1048    PGP version 2.3 and later encode the DEK into an MPI using the
   1049    following format:
   1050 
   1051      MSB                       .   .   .                       LSB
   1052       0   2   RND(n bytes)   0  ALG(1 byte)  DEK(k bytes)  CSUM(2 bytes)
   1053 
   1054    ALG refers to the algorithm byte for the secret key algorithm used to
   1055    encrypt the data packet.  The DEK is the actual Data Encryption Key,
   1056    and its size is dependent upon the encryption algorithm defined by
   1057    ALG.  For the IDEA encryption algorithm, type byte 1, the DEK is 16
   1058    bytes long.  CSUM is a 16-bit checksum of the DEK, used to determine
   1059    that the correct Private key was used to decrypt this packet.  The
   1060    checksum is computed by the 16-bit sum of the bytes in the DEK.  RND
   1061    is random padding to expand the byte to fill the size of the RSA
   1062    Public Key that is used to encrypt the whole byte.
   1063 
   1064 6.6 Public Key Packet
   1065 
   1066    Purpose.  A public key packet defines an RSA public key.
   1067 
   1068    Definition.  A public key packet is the concatenation of the
   1069    following fields:
   1070 
   1071       (a) packet structure field (2 or 3 bytes);
   1072       (b) version number = 2 or 3 (1 byte);;
   1073       (c) time stamp of key creation (4 bytes);
   1074       (d) validity period in days (0 means forever) (2 bytes);
   1075       (e) public-key-cryptosystem (PKC) type (1 byte);
   1076       (f) MPI of RSA public modulus n;
   1077       (g) MPI of RSA public encryption exponent e.
   1078 
   1079     The validity period is always set to 0.
   1080 
   1081 
   1082 
   1083 
   1084 Atkins, et. al.              Informational                     [Page 19]
   1085 
   1087 RFC 1991              PGP Message Exchange Formats           August 1996
   1088 
   1089 
   1090 6.7 User ID Packet
   1091 
   1092    Purpose.  A user ID packet identifies a user and is associated with a
   1093    public or private key.
   1094 
   1095    Definition.  A user ID packet is the concatenation of the following
   1096    fields:
   1097 
   1098       (a) packet structure field (2 bytes);
   1099       (b) User ID string.
   1100 
   1101    The User ID string may be any string of printable ASCII characters.
   1102    However, since the purpose of this packet is to uniquely identify an
   1103    individual, the usual practice is for the User ID string to consist
   1104    of the user's name followed by an e-mail address for that user, the
   1105    latter enclosed in angle brackets.
   1106 
   1107 7. Transferable Public Keys
   1108 
   1109    Public keys may transferred between PGP users. The essential elements
   1110    of a transferable public key are
   1111 
   1112       (a) One public key packet;
   1113       (b) One or more user ID packets;
   1114       (c) Zero or more signature packets
   1115 
   1116    The public key packet occurs first.  Each of the following user ID
   1117    packets provides the identity of the owner of this public key.  If
   1118    there are multiple user ID packets, this corresponds to multiple
   1119    means of identifying the same unique individual user; for example, a
   1120    user may enjoy the use of more than one e-mail address, and construct
   1121    a user ID packet for each one.  Immediately following each user ID
   1122    packet, there are zero or more signature packets. Each signature
   1123    packet is calculated on the immediately preceding user ID packet and
   1124    the initial public key packet.  The signature serves to certify the
   1125    corresponding public key and user ID.  In effect, the signer is
   1126    testifying to his or her belief that this public key belongs to the
   1127    user identified by this user ID.
   1128 
   1129 8. Acknowledgments
   1130 
   1131    Philip Zimmermann is the creator of PGP 1.0, which is the precursor
   1132    of PGP 2.x.  Major parts of later versions of PGP have been
   1133    implemented by an international collaborative effort involving a
   1134    large number of contributors, under the design guidance of Philip
   1135    Zimmermann.
   1136 
   1137 
   1138 
   1139 
   1140 
   1141 Atkins, et. al.              Informational                     [Page 20]
   1142 
   1144 RFC 1991              PGP Message Exchange Formats           August 1996
   1145 
   1146 
   1147 9. Security Considerations
   1148 
   1149    Security issues are discussed throughout this memo.
   1150 
   1151 10. Authors' Addresses
   1152 
   1153    Derek Atkins
   1154    12 Rindge Ave. #1R
   1155    Cambridge, MA
   1156 
   1157    Phone: +1 617 868-4469
   1158    EMail: warlord (a] MIT.EDU
   1159 
   1160 
   1161    William Stallings
   1162    Comp-Comm Consulting
   1163    P. O. Box 2405
   1164    Brewster, MA 02631
   1165 
   1166    EMail: stallings (a] ACM.org
   1167 
   1168 
   1169    Philip Zimmermann
   1170    Boulder Software Engineering
   1171    3021 Eleventh Street
   1172    Boulder, Colorado 80304  USA
   1173 
   1174    Phone: +1-303-541-0140
   1175    EMail: prz (a] acm.org
   1176 
   1177 
   1178 
   1179 
   1180 
   1181 
   1182 
   1183 
   1184 
   1185 
   1186 
   1187 
   1188 
   1189 
   1190 
   1191 
   1192 
   1193 
   1194 
   1195 
   1196 
   1197 
   1198 Atkins, et. al.              Informational                     [Page 21]
   1199 
   1201