draft-ietf-openpgp-formats-00.txt  -->   draft-ietf-openpgp-formats-01.txt

view Side-By-Side changes

Network Working Group                                        Jon Callas
Category: INTERNET-DRAFT                            Pretty Good Privacy
draft-ietf-openpgp-formats-00.txt                             Network Associates
draft-ietf-openpgp-formats-01.txt                      Lutz Donnerhacke
Expires May Aug 1998                     IN-Root-CA Individual Network e.V.
November
March 1997                                                   Hal Finney
                                                    Pretty Good Privacy
                                                     Network Associates
                                                          Rodney Thayer
                                                       Sable Technology

                  OP Formats - OpenPGP Message Format
                   draft-ietf-openpgp-formats-00.txt
                   draft-ietf-openpgp-formats-01.txt

Copyright 1997 1998 by The Internet Society.  All Rights Reserved.

Status of this Memo

This document is an Internet-Draft.  Internet-Drafts are working
documents of the Internet Engineering Task Force (IETF), its areas, and
its working groups.  Note that other groups may also distribute working
documents as Internet-Drafts.

Internet-Drafts are draft documents valid for a maximum of six months
and may be updated, replaced, or obsoleted by other documents at any
time.  It is inappropriate to use Internet-Drafts Internet- Drafts as reference
material or to cite them other than as "work in progress."

To learn view the current status entire list of any Internet-Draft, current Internet-Drafts, please check the
"1id-abstracts.txt" listing contained in the Internet-Drafts Shadow
Directories on ftp.is.co.za (Africa), nic.nordu.net (Europe), ftp.nordu.net (Northern Europe),
ftp.nis.garr.it (Southern Europe), munnari.oz.au (Pacific Rim), ds.internic.net
ftp.ietf.org (US East Coast), or ftp.isi.edu (US West Coast).

Abstract

This document is maintained in order to publish all necessary
information needed to develop interoperable applications based on the
OP format.  It is not a step-by-step cookbook for writing an
application, it describes only the format and methods needed to read,
check, generate and write conforming packets crossing any network.  It
does not deal with storing and implementation questions albeit it is
necessary to avoid security flaws.

OP (Open-PGP)

Open-PGP software uses a combination of strong public-key and
conventional cryptography to provide security services for electronic
communications and data storage.  These services include
confidentiality, key management, authentication and digital signatures.
This document specifies the message formats used in OP.







Callas, et. al.                Expires May Aug 1998                [Page 1]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998





Table of Contents

1.  Introduction
1.1 Terms
2.  General functions
2.1 Confidentiality via Encryption
2.2 Authentication via Digital signature
2.3 Compression
2.4 Conversion to Radix-64
2.4.1 Forming ASCII Armor
2.4.2 Encoding Binary in Radix-64
2.4.3 Decoding Radix-64
2.4.4 Examples of Radix-64
2.5 Example of an ASCII Armored Message
2.6 Cleartext signature framework
3.0
3.  Data Element Formats
3.1 Scalar numbers
3.2 Multi-Precision Integers
3.3 Counted Strings Key IDs
3.4 Text
3.5 Time fields
3.5
3.6 String-to-key (S2K) specifiers
3.5.1
3.6.1 String-to-key (S2k) specifier types
3.5.1.1
3.6.1.1 Simple S2K
3.5.1.2
3.6.1.2 Salted S2K
3.5.1.3
3.6.1.3 Iterated and Salted S2K
3.5.2
3.6.2 String-to-key usage
3.5.2.1
3.6.2.1 Secret key encryption
3.5.2.2
3.6.2.2 Conventional message encryption
3.5.3
3.6.3 String-to-key algorithms
3.5.3.1
3.6.3.1 Simple S2K algorithm
3.5.3.2
3.6.3.2 Salted S2K algorithm
3.5.3.3
3.6.3.3 Iterated-Salted S2K algorithm
4.0
4.  Packet Syntax
4.1 Overview
4.2 Packet Headers
4.3 Packet Tags
5.0
5.  Packet Types
5.1 Public-Key Encrypted Session Key Packets (Tag 1)
5.2 Signature Packet (Tag 2)
5.2.1 Version 3 Signature Packet Format
5.2.2 Version 4 Signature Packet Format
5.2.2.1 Signature Subpacket Specification
5.2.2.2 Signature Subpacket Types
5.2.3 Signature Types
5.2.4 Computing Signatures
5.3 Conventional Symmetric-Key Encrypted Session-Key Packets (Tag 3)
5.4 One-Pass Signature Packets (Tag 4)
5.5 Key Material Packet
5.5.1 Key Packet Variants
5.5.1.1 Public Key Packet (Tag 6)
5.5.1.2 Public Subkey Packet (Tag 14)
5.5.1.3 Secret Key Packet (Tag 5)
5.5.1.4 Secret Subkey Packet (Tag 7)
5.5.2 Public Key Packet Formats
5.5.3 Secret Key Packet Formats


Callas, et. al.                Expires May Aug 1998                [Page 2]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


5.5.3 Secret Key Packet Formats


5.6 Compressed Data Packet (Tag 8)
5.7 Symmetrically Encrypted Data Packet (Tag 9)
5.8 Marker Packet (Obsolete Literal Packet) (Tag 10)
5.9 Literal Data Packet (Tag 11)
5.10 Trust Packet (Tag 12)
5.11 User ID Packet (Tag 13)
5.12 Comment Packet (Tag 16)
6. Constants  Radix-64 Conversions
6.1 An Implementation of the CRC-24 in "C"
6.2 Forming ASCII Armor
6.3 Encoding Binary in Radix-64
6.4 Decoding Radix-64
6.5 Examples of Radix-64
6.6 Example of an ASCII Armored Message
7.  Cleartext signature framework
8.  Regular expressions
9.  Constants
9.1 Public Key Algorithms
6.2
9.2 Symmetric Key Algorithms
6.3
9.3 Compression Algorithms
6.4
9.4 Hash Algorithms
7.
10.  Packet Composition
7.1
10.1 Transferable Public Keys
7.2
10.2 OP Messages
8.
11.  Enhanced Key Formats
8.1
11.1 Key Structures
8.4
11.2 V4 Key IDs and Fingerprints
9.
12.  Security Considerations
10.
13.  Authors and Working Group Chair
11.
14.  References
12.
15.  Full Copyright Statement


1.  Introduction

This document provides information on the message-exchange packet
formats used by OP to provide encryption, decryption, signing, key
management and functions.  It builds on the foundation provided RFC
1991 "PGP Message Exchange Formats" [1]. Formats."

1.1 Terms

OP - OpenPGP.  This is a definition for security software that uses PGP
5.x as a basis.

PGP - Pretty Good Privacy.  PGP is a family of software systems
developed by Philip R.  Zimmermann from which OP is based.

PGP 2.6.x - This version of PGP has many variants, hence the term PGP
2.6.x.  It used only RSA and IDEA for its cryptography.






Callas, et. al.                Expires Aug 1998                [Page 3]
Internet Draft              OpenPGP Message Format              Mar 1998


PGP 5.x - This version of PGP is formerly known as "PGP 3" in the
community and also in the predecessor of this document, RFC1991.  It
has new formats and corrects a number of problems in the PGP 2.6.x.  It
is referred to here as PGP 5.x because that software was the first
release of the "PGP 3" code base.

"PGP", "Pretty Good", and "Pretty Good Privacy" are trademarks of
Pretty Good Privacy,
Network Associates, Inc.


2.  General functions


Callas, et. al.                Expires May 1998                [Page 3]
Internet Draft              OpenPGP Message Format              Nov 1998

OP provides data integrity services for messages and data files by
using these core technologies:

      -digital signature
      -encryption
      -compression
      -radix-64 conversion

In addition, OP provides key management and certificate services.

2.1 Confidentiality via Encryption

OP offers two encryption options to provide confidentiality:
conventional (symmetric-key) encryption and public key encryption.
With public-key encryption, the message is actually encrypted using a
conventional encryption algorithm.  In this mode, each conventional key
is used only once.  That is, a new key is generated as a random number
for each message.  Since it is used only once, the "session key" is
bound to the message and transmitted with it.  To protect the key, it
is encrypted with the receiver's public key.  The sequence is as
follows:

  1. The sender creates a message.
  2. The sending OP generates a random number to be used as a
        session key for this message only.
  3. The session key is encrypted using each recipient's public key.
        These "encrypted session keys" start the message.
  4. The sending OP encrypts the message using the session key, which
        forms the remainder of the message. Note that the message is
        also usually compressed.
  5. The receiving OP decrypts the session key using the recipient's
        private key.
  6. The receiving OP decrypts the message using the session key.
        If the message was compressed, it will be decompressed.

Both digital signature and confidentiality services may be applied to
the same message.  First, a signature is generated for the message and
attached to the message.  Then, the message plus signature is encrypted
using a conventional session key.  Finally, the session key is
encrypted using public-key encryption and prepended to the encrypted
block.


Callas, et. al.                Expires Aug 1998                [Page 4]
Internet Draft              OpenPGP Message Format              Mar 1998



2.2 Authentication via Digital signature

The digital signature uses a hash code or message digest algorithm, and
a public-key signature algorithm.  The sequence is as follows:

  1. The sender creates a message.
  2. The sending software generates a hash code of the message
  3. The sending software generates a signature from the hash code using
     the sender's private key.
  4. The binary signature is attached to the message.
  5. The receiving software keeps a copy of the message signature.
  6. The receiving software generates a new hash code for the received
     message and verifies it using the message's signature. If the 


Callas, et. al.                Expires May 1998                [Page 4]
Internet Draft              OpenPGP Message Format              Nov 1998
     verification is successful, the message is accepted as authentic.

2.3 Compression

OP implementations MAY compress the message after applying the
signature but before encryption.


2.4 Conversion to Radix-64

OP's underlying native representation for encrypted messages, signature
certificates, and keys is a stream of arbitrary octets.  Some systems
only permit the use of blocks consisting of seven-bit, printable text.
For transporting OP's native raw binary octets through email channels, channels that
are not safe to raw binary data, a printable encoding of these binary
octets is needed.  OP provides the service of converting the raw 8-bit
binary octet stream to a stream of printable ASCII characters, called
Radix-64 encoding or ASCII Armor.

In principle, any printable encoding scheme

Implementations SHOULD provide Radix-64 conversions.

Note that met the requirements
of the email channel would suffice, since it would not change the
underlying binary bit streams of many applications, particularly messaging applications, will
want more advanced features as described in the native OpenPGP-MIME document,
RFC2015.  An application that implements OP for messaging SHOULD also
implement OpenPGP-MIME.

3.  Data Element Formats

This section describes the data structures.  The OP
standard specifies one such printable encoding scheme elements used by OP.

3.1 Scalar numbers

Scalar numbers are unsigned, and are always stored in big-endian
format. Using n[k] to ensure
interoperability.

OP's Radix-64 encoding is composed refer to the kth octet being interpreted, the
value of two parts: a base64 encoding two-octet scalar is ((n[0] << 8) + n[1]).  The value of
the binary data, and a checksum.  The base64 encoding
four-octet scalar is identical ((n[0] << 24) + (n[1] << 16) + (n[2] << 8) +
n[3]).




Callas, et. al.                Expires Aug 1998                [Page 5]
Internet Draft              OpenPGP Message Format              Mar 1998




3.2 Multi-Precision Integers

Multi-Precision Integers (also called MPIs) are unsigned integers used
to hold large integers such as the MIME base64 content-transfer-encoding [RFC 2045, Section 6.8]. ones used in cryptographic
calculations.

An
OP implementation MAY use ASCII Armor to protect the raw binary data.

The checksum is MPI consists of two pieces: a 24-bit CRC converted to four characters two-octet scalar that is the length of radix-64
encoding by
the same MIME base64 transformation, preceded MPI in bits followed by a string of octets that contain the actual
integer.

These octets form a big-endian number; a big-endian number can be made
into an equals
sign (=).  The CRC is computed MPI by using prefixing it with the generator 0x864CFB and appropriate length.

Examples:

(all numbers are in hexadecimal)

The string of octets [00 01 01] forms an
initialization MPI with the value 1.  The
string [00 09 01 FF] forms an MPI with the value of 0xB704CE. 511.

Additional rules:

The accumulation size of an MPI is done on ((MPI.length + 7) / 8) + 2.

The length field of an MPI describes the data
before it is converted to radix-64, rather than on length starting from its most
significant non-zero bit.  Thus, the converted data.
(For more information on CRC functions, see chapter 19 of [CAMPBELL].)

{{Editor's note:  This MPI [00 02 01] is old text, dating back to RFC 1991.  I have
never liked the glib way the CRC has been dismissed, but I also know
that this not formed
correctly.  It should be [00 01 01].

3.3 Key IDs

A Key ID is no place to start a discussion of CRC theory.  Should we
construct a sample implementation in C and put it in an appendix? --
jdcc}}

The checksum with its leading equal sign MAY appear on the first line
after the Base64 encoded data.

Rationale for CRC-24: eight-octet number that identifies a key.
Implementations SHOULD NOT assume that Key IDs are unique.  The size of 24 bits fits evenly into printable
base64.
section, "Enhanced Key Formats" below describes how Key IDs are formed.

3.4 Text

The nonzero initialization can detect more errors than a zero
initialization.

2.4.1 Forming ASCII Armor

When OP encodes data into ASCII Armor, it puts specific headers around
the data, so OP can reconstruct the data later.  OP informs default character set for text is the user
what kind UTF-8 [RFC2044] encoding of data
Unicode [ISO10646].

3.5 Time fields

A time field is encoded in an unsigned four-octet number containing the ASCII armor through number of
seconds elapsed since midnight, 1 January 1970 UTC.

3.6 String-to-key (S2K) specifiers

String-to-key (S2K) specifiers are used to convert passphrase strings
into conventional encryption/decryption keys.  They are used in two
places, currently: to encrypt the use secret part of private keys in the
private keyring, and to convert passphrases to encryption keys for
conventionally encrypted messages.


Callas, et. al.                Expires May Aug 1998                [Page 5] 6]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


headers.

Concatenating the following data creates ASCII Armor:

- An Armor Header Line, appropriate for the type of data - Armor
Headers - A blank (zero-length, or containing only whitespace) line -
The ASCII-Armored data - An Armor Checksum - The Armor Tail, which
depends on the Armor Header Line.

An Armor Header Line consists



3.6.1 String-to-key (S2k) specifier types

There are three types of S2K specifiers currently supported, as
follows:

3.6.1.1 Simple S2K

This directly hashes the appropriate header line text
surrounded by five (5) dashes ('-', 0x2D) on either side of string to produce the header
line text.  The header line text key data.  See below for
how this hashing is chosen based upon done.

    Octet 0:        0x00
    Octet 1:        hash algorithm

3.6.1.2 Salted S2K

This includes a "salt" value in the type of S2K specifier -- some arbitrary
data -- that is being encoded in Armor, gets hashed along with the passphrase string, to help
prevent dictionary attacks.

    Octet 0:        0x01
    Octet 1:        hash algorithm
    Octets 2-9:     8-octet salt value

3.6.1.3 Iterated and how it Salted S2K

This includes both a salt and an octet count.  The salt is being encoded.  Header
line texts include the following strings:

BEGIN PGP MESSAGE used for signed, encrypted, or compressed files

BEGIN PGP PUBLIC KEY BLOCK used for armoring public keys

BEGIN PGP PRIVATE KEY BLOCK used for armoring private keys

BEGIN PGP MESSAGE, PART X/Y used for multi-part messages, where combined
with the
armor is split amongst Y parts, passphrase and this the resulting value is hashed repeatedly.  This
further increases the Xth part out amount of Y.

BEGIN PGP MESSAGE, PART X used for multi-part messages, where this is work an attacker must do to try
dictionary attacks.

    Octet 0:        0x04
    Octet 1:        hash algorithm
    Octets 2-9:     8-octet salt value
    Octets 10-13:   count, a four-octet, unsigned value

Note that the Xth part value 0x03 for octet 0 of a S2K specifier is reserved; it
denotes an unspecified number obsolete form of parts. Requires the MESSAGE-ID
Armor Header to be used.

BEGIN PGP SIGNATURE used for detached signatures, OP/MIME signatures, Interated and signatures following clearsigned messages

The Armor Headers Salted S2K.

3.6.2 String-to-key usage

Implementations SHOULD use salted or iterated-and-salted S2K
specifiers, as simple S2K specifiers are pairs of strings that more vulnerable to dictionary
attacks.

3.6.2.1 Secret key encryption

An S2K specifier can give the user or be stored in the
receiving OP message block some information about secret keyring to specify how to decode or use
the message.  The Armor Headers are a part of the armor, not a part of
convert the message, and hence are not protected by any signatures applied passphrase to
the message.

The format of an Armor Header is a key that unlocks the secret data.  Older
versions of PGP just stored a key-value pair.  A colon
(':' 0x38) and a single space (0x20) separate cipher algorithm octet preceding the key and value.  OP
should consider improperly formatted Armor Headers
secret data or a zero to be corruption of indicate that the ASCII Armor.  Unknown keys should be reported secret data was unencrypted.
The MD5 hash function was always used to convert the user, but OP
should continue passphrase to process the message.  Currently defined Armor Header
Keys include "Version" and "Comment", which define a
key for the OP Version used
to encode the message and a user-defined comment.

The "MessageID" Armor Header specifies a 32-character string of
printable characters.  The string must be the same for all parts of a
multi-part message that uses the "PART X" Armor Header.  MessageID
strings should be chosen with enough internal randomness that no two
messages would have the same MessageID string.

The MessageID should not appear unless it is in a multi-part message.
If it appears at all, it should be computed from the message in a specified cipher algorithm.


Callas, et. al.                Expires May Aug 1998                [Page 6] 7]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


deterministic fashion, rather than contain a purely random value.  This
is to allow anyone to determine that the MessageID cannot serve as a
covert means of leaking cryptographic key information.

{{Editor's note:  This needs to be cleaned up, with a table of the
defined headers.  Also, the MessageID description



For compatibility, when an S2K specifier is too vague about
how random used, the id has to be.}}

The Armor Tail Line special value 255
is composed stored in the same manner as position where the Armor Header
Line, except hash algorithm octet would have
been in the string "BEGIN" old data structure.  This is replaced then followed immediately by the string "END."

2.4.2 Encoding Binary in Radix-64

The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters.  Proceeding from left to right, a
24-bit input group is formed by concatenating three 8-bit input groups.
These 24 bits are
one-octet algorithm identifier, and then treated by the S2K specifier as four concatenated 6-bit groups, each
encoded above.

Therefore, preceding the secret data there will be one of which these
possibilities:

    0           secret data is translated into a single digit in unencrypted (no pass phrase)
    255         followed by algorithm octet and S2K specifier
    Cipher alg  use Simple S2K algorithm using MD5 hash

This last possibility, the Radix-64 alphabet.
When encoding a bit stream cipher algorithm number with an implicit use
of MD5 is provided for backward compatibility; it should be understood,
but not generated.

These are followed by an 8-octet Initial Vector for the Radix-64 encoding, decryption of
the bit stream
must secret values, if they are encrypted, and then the secret key
values themselves.

3.6.2.2 Conventional message encryption

PGP 2.X always used IDEA with Simple string-to-key conversion when
conventionally encrypting a message.  PGP 5 can create a Conventional
Encrypted Session Key packet at the front of a message.  This can be presumed
used to allow S2K specifiers to be ordered used for the passphrase conversion,
to allow other ciphers than IDEA to be used, or to create messages with
a mix of conventional ESKs and public key ESKs.  This allows a message
to be decrypted either with a passphrase or a public key.

3.6.3 String-to-key algorithms

3.6.3.1 Simple S2K algorithm

Simple S2K hashes the most-significant-bit first.
That is, passphrase to produce the first bit session key.  The
manner in which this is done depends on the stream will be size of the high-order bit in session key
(which will depend on the
first 8-bit byte, cipher used) and the eighth bit will be size of the low-order bit in hash
algorithm's output. If the
first 8-bit byte, and so on.

	     +--first octet--+-second octet--+--third octet--+
	     |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
	     +-----------+---+-------+-------+---+-----------+
	     |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
	     +--1.index--+--2.index--+--3.index--+--4.index--+

Each 6-bit group hash size is greater than or equal to the
session key size, the leftmost octets of the hash are used as an index into an array the key.

If the hash size is less than the key size, multiple instances of 64 printable
characters the
hash context are created -- enough to produce the required key data.
These instances are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet of zero, the third is preloaded with two octets
of zeros, and so forth).

As the data is hashed, it is given independently to each hash context.
Since the contexts have been initialized differently, they will each
produce different hash output.  Once the passphrase is hashed, the
output data from the table below.  The character referenced multiple hashes is concatenated, first hash


Callas, et. al.                Expires Aug 1998                [Page 8]
Internet Draft              OpenPGP Message Format              Mar 1998


leftmost, to produce the key data, with any excess octets on the right
discarded.

3.6.3.2 Salted S2K algorithm

Salted S2K is exactly like Simple S2K, except that the input to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed by the index passphrase.

3.6.3.3 Iterated-Salted S2K algorithm

Iterated-Salted S2K hashes the passphrase and salt data multiple times.
The total number of octets to be hashed is placed specified in the output string.

     Value Encoding  Value Encoding  Value Encoding  Value Encoding
         0 A            17 R            34 i            51 z
         1 B            18 S            35 j            52 0
         2 C            19 T            36 k            53 1
         3 D            20 U            37 l            54 2
         4 E            21 V            38 m            55 3
         5 F            22 W            39 n            56 4
         6 G            23 X            40 o            57 5
         7 H            24 Y            41 p            58 6
         8 I            25 Z            42 q            59 7
         9 J            26 a            43 r            60 8
        10 K            27 b            44 s            61 9
        11 L            28 c            45 t            62 +
        12 M            29 d            46 u            63 /
        13 N            30 e            47 v
        14 O            31 f            48 w         (pad) =
        15 P            32 g            49 x
        16 Q            33 h            50 y



Callas, et. al.                Expires May 1998                [Page 7]
Internet Draft              OpenPGP Message Format              Nov 1998


The encoded output stream must be represented four-octet
count in lines the S2K specifier.  Note that the resulting count value is an
octet count of no how many octets will be hashed, not an iteration count.

Initially, one or more than
76 characters each.

Special processing is performed if fewer than 24 bits hash contexts are available at set up as with the end other S2K
algorithms, depending on how many octets of the key data being encoded.  There are three possibilities:

- The last data group has 24 bits (3 octets).  No special processing is needed.

- The last  Then
the salt, followed by the passphrase data group has 16 bits (2 octets).  The first two 6-bit
groups are processed as above.  The third (incomplete) data group has
two zero-value bits added to it, and is processed as above.  A pad
character (=) is added to repeatedly hashed until
the output.

- The last data group number of octets specified by the octet count has 8 bits (1 octet). been hashed.  The first 6-bit group
one exception is
processed as above.  The second (incomplete) data group has four
zero-value bits added to it, and that if the octet count is processed as above.  Two pad
characters (=) are added to less than the output.

2.4.3 Decoding Radix-64

Any characters outside size of the base64 alphabet are ignored in Radix-64
data.  Decoding software must ignore all line breaks or other
characters not found in the table above.

In Radix-64 data, characters other than those in
salt plus passphrase, the table, line
breaks, and other white space probably indicate a transmission error,
about which a warning message or even a message rejection might full salt plus passphrase will be
appropriate under some circumstances.

Because it hashed even
though that is used only for padding at greater than the end of octet count.  After the data, hashing is done
the
occurrence of any "=" characters may be taken data is unloaded from the hash context(s) as evidence that with the end
of other S2K
algorithms.

4.  Packet Syntax

This section describes the data has been reached (without truncation in transit).  No such
assurance packets used by OP.

4.1 Overview

An OP message is possible, however, when the constructed from a number of octets transmitted
was records that are
traditionally called packets.  A packet is a multiple chunk of three data that has a
tag specifying its meaning.  An OP message, keyring, certificate, and no "=" characters are present.


2.4.4 Examples
so forth consists of Radix-64

Input data:  0x14fb9c03d97e
Hex:     1   4    f   b    9   c     | 0   3    d   9    7   e
8-bit:   00010100 11111011 10011100  | 00000011 11011001 11111110
6-bit:   000101 001111 101110 011100 | 000000 111101 100111 111110
Decimal: 5      15     46     28       0      61     37     63
Output:  F      P      u      c a number of packets.  Some of those packets may
contain other OP packets (for example, a compressed data packet, when
uncompressed, contains OP packets).

Each packet consists of a packet header, followed by the packet body.
The packet header is of variable length.

4.2 Packet Headers

The first octet of the packet header is called the "Packet Tag." It
determines the format of the header and denotes the packet contents.
The remainder of the packet header is the length of the packet.

Note that the most significant bit is the left-most bit, called bit 7.
A      9      l      /

Input data:  0x14fb9c03d9
Hex:     1   4    f   b    9   c     | 0   3    d   9
8-bit:   00010100 11111011 10011100  | 00000011 11011001
                                                pad with 00
6-bit:   000101 001111 101110 011100 | 000000 111101 100100
Decimal: 5      15     46     28       0      61     36
                                                   pad with = mask for this bit is 0x80 in hexadecimal.





Callas, et. al.                Expires May Aug 1998                [Page 8] 9]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


Output:  F      P      u      c        A      9      k      =

Input data:  0x14fb9c03
Hex:     1



       +---------------+
  PTag |7 6 5 4    f   b    9   c     | 0 3
8-bit:   00010100 11111011 10011100  | 00000011
                                       pad with 0000
6-bit:   000101 001111 101110 011100 | 000000 110000
Decimal: 5      15     46     28       0      48
                                            pad 2 1 0|
       +---------------+
  Bit 7 -- Always one
  Bit 6 -- New packet format if set


PGP 2.6.X only uses old format packets.  Thus, software that
interoperates with =      =
Output:  F      P      u      c        A      w      =      =


2.5 Example those versions of an ASCII Armored Message

  -----BEGIN PGP MESSAGE-----
  Version: OP V0.0

  owFbx8DAYFTCWlySkpkHZDKEFCXmFedmFhdn5ucpZKdWFiv4hgaHKPj5hygUpSbn
  l6UWpabo8XIBAA==
  =3m1o
  -----END PGP MESSAGE----- must only use old format
packets.  If interoperability is not an issue, either format may be
used.  Note that this example old format packets have four bits of content tags, and
new format packets have six; some features cannot be used and still be
backwards-compatible.

Old format packets contain:
  Bits 5-2 -- content tag
  Bits 1-0 - length-type

New format packets contain:
  Bits 5-0 -- content tag

The meaning of the length-type in old-format packets is:

0 - The packet has a one-octet length.  The header is indented by two spaces.

2.6 Cleartext signature framework

Sometimes it 2 octets long.

1 - The packet has a two-octet length.  The header is necessary to sign 3 octets long.

2 - The packet has a textual octet stream without ASCII
armoring four-octet length.  The header is 5 octets long.

3 - The packet is of indeterminate length.  The header is 1 byte long,
and the stream itself, so application must determine how long the signed text packet is.  If the
packet is still readable
without special software.  In order to bind a signature to such in a
cleartext, file, this framework is used. (Note means that RFC 2015 defines another
way to clear sign messages for environments that support MIME.)

The cleartext signed message consists of:
  - The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a
    single line,
  - Zero or more "Hash" Armor Headers (3.1.2.4),
  - Exactly one empty line the packet extends until the end
of the file.  In general, an application should not included into use indeterminate
length packets except where the message digest,
  - The dash-escaped cleartext that is included into end of the message digest,
  - The ASCII armored signature(s) including data will be clear from the Armor Header
context.

New format packets have three possible ways of encoding length.  A
one-octet Body Length header encodes packet lengths of up to 191
octets, and Armor
    Tail Lines.

If the "Hash" armor a two-octet Body Length header is given, encodes packet lengths of
192 to 8383 octets.  For cases where longer packet body lengths are
needed, or where the specified message digest
algorithm is used for length of the signature.  If this header is missing, SHA-1
is assumed.  If more than one message digest packet body is used not known in advance
by the signature, issuer, Partial Body Length headers can be used.  These are
one-octet length headers that encode the "Hash" armor length of only part of the
data packet.

Each Partial Body Length header contains is followed by a comma-delimited list portion of used message
digests.  As an abbreviation, the "Hash" armor packet
body data.  The Partial Body Length header may be placed on
the cleartext specifies this portion's
length.  Another length header line, inserting a comma after the word 'MESSAGE',
as follows:

'-----BEGIN PGP SIGNED MESSAGE, Hash:  MD5, SHA1'.

{{Editor's note:  Should (of one of the above armor header line stay or go?
There's no reason three types) follows that the "Hash:" armor
portion.  The last length header can't have multiple in the packet must always be a regular
Body Length header.  Partial Body Length headers may only be used for
the non-final parts of the packet.



Callas, et. al.                Expires May Aug 1998                [Page 9] 10]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


hashes in it.  I think anything that reduces parsing complexity is a
Good Thing. --jdcc}}

Current message digest names are:

	- "SHA1"
	- "MD5"
	- "RIPEMD160"

Dash escaped cleartext is the ordinary cleartext where every line
starting with





A one-octet Body Length header encodes a dash '-' (0x2D) is prepended by the sequence dash '-'
(0x2D) and space ' ' (0x20).  This prevents the parser length of from recognizing
armor headers 0 to 191
octets. This type of the cleartext itself.  The message digest length header is computed
using the cleartext itself, not the dash escaped form.

As with binary signatures on text documents (see below), recognized because the cleartext
signature one octet
value is calculated on the text using canonical <CR><LF> line
endings. less than 192.  The line ending (i.e. the <CR><LF>) before the '-----BEGIN
PGP SIGNATURE-----' line that terminates the signed text body length is not
considered part of the signed text.

Also, any trailing whitespace (spaces, and tabs, 0x09) at the end equal to:

bodyLen = length_octet;

A two-octet Body Length header encodes a length of
any line from 192 to 8383
octets.  It is ignored when the cleartext signature recognized because its first octet is calculated.

3.  Data Element Formats

This section describes the data elements used by OP.

3.1 Scalar numbers

Scalar numbers are unsigned, and are always stored in big-endian
format. Using n[k] the range 192
to refer 223.  The body length is equal to:

bodyLen = (1st_octet - 192) * 256 + (2nd_octet) + 192

A Partial Body Length header is one octet long and encodes a length
which is a power of 2, from 1 to 2147483648 (2 to the kth 31st power).  It
is recognized because its one octet being interpreted, the value of a two-octet scalar is ((n[0] << 8) + n[1]). greater than or equal to
224.  The value of a
four-octet scalar partial body length is ((n[0] << 24) + (n[1] << 16) + (n[2] equal to:

partialBodyLen = 1 << 8) +
n[3]).

3.2 Multi-Precision Integers

Multi-Precision Integers (also called MPIs) are unsigned integers used
to hold large integers such as the ones used (length_octet & 0x1f);

Examples:

A packet with length 100 may have its length encoded in cryptographic
calculations.

An MPI consists of two pieces: a two-octet scalar that one octet:
0x64. This is the length followed by 100 octets of
the MPI data.

A packet with length 1723 may have its length coded in bits two octets:
0xC5, 0xFB.  This header is followed by a string of octets that contain the actual
integer.

These 1723 octets form a big-endian number; a big-endian number can be made
into an MPI by prefixing it of data.

A packet with the appropriate length.

Examples:

(all numbers are length 100000 might be encoded in hexadecimal)



Callas, et. al.                Expires May 1998                [Page 10]
Internet Draft              OpenPGP Message Format              Nov 1998


The string the following octet
stream: 0xE1, first two octets of data, 0xE0, next one octet of data,
0xEF, next 32768 octets [00 01 01] forms an MPI with the value 1.  The
string [00 09 01 FF] forms an MPI with the value of 511.

Additional rules:

The size data, 0xF0, next 65536 octets of an MPI data, 0xC5,
0xDD, last 1693 octets of data.  This is ((MPI.length + 7) / 8) + 2.

The length field just one possible encoding,
and many variations are possible on the size of an MPI describes the length starting from its most
significant non-zero bit.  Thus, Partial Body Length
headers, as long as a regular Body Length header encodes the MPI [00 02 01] is not formed
correctly.  It should be [00 01 01].


3.3 Counted Strings

A counted string consists last
portion of the data.  Note also that the last Body Length header can be
a length and then N octets zero-length header.


Please note that in all of string data.
Its default character set is UTF-8 [RFC2044] encoding these explanations, the total length of Unicode
[ISO10646].

3.4 Time fields

A time field the
packet is an unsigned four-octet number containing the number length of
seconds elapsed since midnight, 1 January 1970 UTC.

3.5 String-to-key (S2K) specifiers

String-to-key (S2K) specifiers are used to convert passphrase strings
into conventional encryption/decryption keys.  They are used in two
places, currently: to encrypt the secret part of private keys in header(s) plus the
private keyring, and to convert passphrases to encryption keys for
conventionally encrypted messages.

3.5.1 String-to-key (S2k) specifier types

There are three types length of S2K specifiers currently supported, as
follows:

3.5.1.1 Simple S2K

This directly hashes the string to produce body.

4.3 Packet Tags

The packet tag denotes what type of packet the key data.  See below for
how this hashing is done.

	Octet 0:		0x00
	Octet 1:		hash algorithm

3.5.1.2 Salted S2K

This includes body holds.  Note that
old format packets can only have tags less than 16, whereas new format
packets can have tags as great as 63.  The defined tags (in decimal)
are:

0        -- Reserved. A packet must not have a "salt" value in the S2K specifier tag with this value.
1        -- some arbitrary
data Public-Key Encrypted Session Key Packet
2        -- that gets hashed along with the passphrase string, to help
prevent dictionary attacks.

	Octet 0:		0x01
	Octet 1:		hash algorithm
	Octets 2-9:		8-octet salt value Signature Packet


Callas, et. al.                Expires May Aug 1998                [Page 11]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998



3.5.1.3 Iterated and Salted S2K

This includes both


3        -- Symmetric-Key Encrypted Session Key Packet
4        -- One-Pass Signature Packet
5        -- Secret Key Packet
6        -- Public Key Packet
7        -- Secret Subkey Packet
8        -- Compressed Data Packet
9        -- Symmetrically Encrypted Data Packet
10       -- Marker Packet
11       -- Literal Data Packet
12       -- Trust Packet
13       -- Name Packet
14       -- Subkey Packet
15       -- Reserved
60 to 63 -- Private or Experimental Values

5.  Packet Types

5.1 Public-Key Encrypted Session Key Packets (Tag 1)

A Public-Key Encrypted Session Key packet holds the key used to encrypt
a salt and message that is itself encrypted with a public key.  Zero or more
Encrypted Session Key packets and/or Conventional Encrypted Session Key
packets may precede a Symmetrically Encrypted Data Packet, which holds
an octet count. encrypted message.  The salt message is combined encrypted with the passphrase a session key, and
the resulting value session key is hashed repeatedly.  This
further increases the amount of work an attacker must do to try
dictionary attacks.

	Octet 0:		0x03
	Octet 1:		hash algorithm
	Octets 2-9:		8-octet salt value
	Octet 10:		count, in special format (described below)

3.5.2 String-to-key usage

Implementations MUST implement simple S2K and salted S2K specifiers.
Implementations MAY implement iterated itself encrypted and salted S2K specifiers.
Implementations SHOULD use salted S2K specifiers, as simple S2K
specifiers are more vulnerable to dictionary attacks.

3.5.2.1 Secret key encryption

An S2K specifier can be stored in the secret keyring to specify how Encrypted Session
Key packet(s).  The Symmetrically Encrypted Data Packet is preceded by
one Public-Key Encrypted Session Key packet for each OP key to
convert which
the passphrase to message is encrypted.  The recipient of the message finds a session
key that unlocks is encrypted to their public key, decrypts the secret data.  Older
versions of PGP just stored a cipher algorithm octet preceding session key,
and then uses the
secret data or a zero session key to indicate that decrypt the secret data was unencrypted. message.

The MD5 hash function was always used to convert the passphrase to a
key for body of this packet consists of:

    - A one-octet number giving the specified cipher algorithm.

For compatibility, when an S2K specifier is used, version number of the special packet type.
      The currently defined value 255 for packet version is stored 3. An
        implementation should accept, but not generate a version of 2,
        which is equivalent to V3 in all other respects.
    - An eight-octet number that gives the position where key ID of the hash algorithm octet would have
been in public key that
      the old data structure.  This session key is then followed immediately by a encrypted to.
    - A one-octet algorithm identifier, and then by the S2K specifier as
encoded above.

Therefore, preceding the secret data there will be one of these
possibilities:

	0		secret data is unencrypted (no pass phrase)
	255		followed by algorithm octet and S2K specifier
	Cipher alg	use Simple S2K algorithm using MD5 hash

This last possibility, number giving the cipher public key algorithm number with an implicit use used.
    - A string of MD5 octets that is provided for backward compatibility; it should be understood,
but not generated.

These are followed by an 8-octet Initial Vector for the decryption encrypted session key. This
      string takes up the remainder of the secret values, if they are encrypted, packet, and then its contents are
      dependent on the secret public key
values themselves.

3.5.2.2 Conventional message algorithm used.

    Algorithm Specific Fields for RSA encryption

PGP 2.X always used IDEA with Simple string-to-key conversion when
    - multiprecision integer (MPI) of RSA encrypted value m**e mod n.

    Algorithm Specific Fields for Elgamal encryption:
    - MPI of DSA value g**k mod p.
    - MPI of DSA value m * y**k mod p.





Callas, et. al.                Expires May Aug 1998                [Page 12]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


conventionally encrypting a message.  PGP 5 can create a Conventional
Encrypted Session Key packet at



The encrypted value "m" in the front of a message.  This can be
used to allow S2K specifiers to be used for above formulas is derived from the passphrase conversion,
to allow other ciphers than IDEA to be used, or to create messages
session key as follows.  First the session key is prepended with a mix of
one-octet algorithm identifier that specifies the conventional ESKs and public key ESKs.  This allows a message
encryption algorithm used to be decrypted either with a passphrase or a public key.

3.5.3 String-to-key algorithms

3.5.3.1 Simple S2K algorithm

Simple S2K hashes the passphrase to produce encrypt the session key.  The
manner in following Symmetrically
Encrypted Data Packet.  Then a two-octet checksum is appended which this is done depends on
equal to the size sum of the session key
(which will depend on preceding octets, including the cipher used) algorithm
identifier and the size of the hash
algorithm's output. If the hash size session key, modulo 65536.  This value is greater than or equal then padded as
described in PKCS-1 block type 02 [PKCS1] to form the
session key size, "m" value used in
the leftmost octets formulas above.

An implementation MAY use a Key ID of the hash are used zero as a "wild card" or
"speculative" Key ID.  In this case, the implementation would try all
available private keys, checking for a valid decrypted session key.

If the hash size is less than the key size, multiple instances
This format helps reduce traffic analysis of the
hash context are created -- enough to produce the required messages.

5.2 Signature Packet (Tag 2)

A signature packet describes a binding between some public key and some
data.
These instances  The most common signatures are preloaded with 0, 1, 2, ... octets of zeros (that
is to say, the first instance has no preloading, the second gets
preloaded with 1 octet a signature of zero, the third is preloaded with two octets a file or a block
of zeros, text, and so forth).

As the data is hashed, it is given independently to each hash context.
Since the contexts have been initialized differently, they will each
produce different hash output.  Once the passphrase a signature that is hashed, the
output data from the multiple hashes is concatenated, first hash
leftmost, to produce the key data, a certification of a user ID.

Two versions of signature packets are defined.  Version 3 provides
basic signature information, while version 4 provides an expandable
format with any excess octets on the right
discarded.

3.5.3.2 Salted S2K algorithm

Salted S2K is exactly like Simple S2K, except subpackets that can specify more information about the input
signature. PGP 2.6.X only accepts version 3 signatures.

Implementations MUST accept V3 signatures.  Implementations SHOULD
generate V4 signatures, unless there is a need to the
hash function(s) consists of the 8 octets of salt from the S2K
specifier, followed generate a signature
that can be verified by the passphrase.

3.5.3.3 Iterated-Salted S2K algorithm

{{Editor's note:  This old implementations.

Note that if an implementation is very complex, with bizarre things like creating an
8-bit floating point format.  Should we just drop it? --jdcc}}

Iterated-Salted S2K hashes the passphrase encrypted and salt data multiple times.
The total number of octets to be hashed is encoded in the count octet signed
message that follows the salt in the S2K specifier.  The count value is stored
as a normalized floating-point value with 4 bits of exponent and 4 bits
of mantissa.  The formula encrypted to convert from the count octet a V3 key, it is reasonable to create a count of
the V3
signature.

5.2.1 Version 3 Signature Packet Format

A version 3 Signature packet contains:
    - One-octet version number (3).
    - One-octet length of octets to be following hashed is as follows, letting the high 4
bits of the count octet be CEXP and the low four bits material.  MUST be CMANT:

	count 5.
    - One-octet signature type.
    - Four-octet creation time.
    - Eight-octet key ID of octets to be hashed = (16 + CMANT) << (CEXP + 6)

This allows encoding signer.
    - One-octet public key algorithm.
    - One-octet hash counts as low as algorithm.
    - Two-octet field holding left 16 << 6 bits of signed hash value.
    - One or 1024 (using an more multi-precision integers comprising the signature.
      This portion is algorithm specific, as described below.

The data being signed is hashed, and then the signature type and
creation time from the signature packet are hashed (5 additional
octets).  The resulting hash value is used in the signature algorithm.
The high 16 bits (first two octets) of the hash are included in the


Callas, et. al.                Expires May Aug 1998                [Page 13]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


octet


signature packet to provide a quick test to reject some invalid
signatures.

    Algorithm Specific Fields for RSA signatures:
    - multiprecision integer (MPI) of RSA signature value m**d.

    Algorithm Specific Fields for DSA signatures:
    - MPI of DSA value r.
    - MPI of 0), and DSA value s.

The signature calculation is based on a hash of the signed data, as high
described above.  The details of the calculation are different for DSA
signature than for RSA signatures.

With RSA signatures, the hash value is encoded as 31 << 21 or 65011712 (using described in PKCS-1
section 10.1.2, "Data encoding", producing an octet ASN.1 value of 0xff).  Note that type
DigestInfo, and then padded using PKCS-1 block type 01 [PKCS1].  This
requires inserting the resulting count hash value is as an octet count
of how many octets will be hashed, not string into an iteration count.

Initially, one or more hash contexts are set up as with ASN.1
structure.  The object identifier for the other S2K
algorithms, depending on how many octets type of key data are needed.  Then hash being used is
included in the salt, followed by structure.  The hexadecimal representations for the passphrase data is repeatedly hashed until
currently defined hash algorithms are:

    - MD5:          0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05
    - SHA-1:        0x2b, 0x0e, 0x03, 0x02, 0x1a
    - RIPEMD-160:   0x2b, 0x24, 0x03, 0x02, 0x01

The ASN.1 OIDs are:
    - MD5:       1.2.840.113549.2.5
    - SHA-1:     1.3.14.3.2.26
    - RIPEMD160: 1.3.36.3.2.1


DSA signatures SHOULD use hashes with a size of 160 bits, to match q,
the number size of octets specified the group generated by the octet count has been hashed. DSA key's generator value.  The
one exception
hash function result is that if treated as a 160 bit number and used directly
in the DSA signature algorithm.

5.2.2 Version 4 Signature Packet Format

A version 4 Signature packet contains:
    - One-octet version number (4).
    - One-octet signature type.
    - One-octet public key algorithm.
    - One-octet hash algorithm.
    - Two-octet octet count is less than the size of the
salt plus passphrase, the full salt plus passphrase will be for following hashed even
though that is greater than the subpacket data.
    - Hashed subpacket data. (zero or more subpackets)
    - Two-octet octet count.  After count for following unhashed subpacket data.
    - Unhashed subpacket data. (zero or more subpackets)
    - Two-octet field holding left 16 bits of signed hash value.
    - One or more multi-precision integers comprising the hashing signature.
      This portion is done
the algorithm specific, as described above.




Callas, et. al.                Expires Aug 1998                [Page 14]
Internet Draft              OpenPGP Message Format              Mar 1998




The data being signed is unloaded from hashed, and then the hash context(s) as with signature data from the other S2K
algorithms.

4.  Packet Syntax

This section describes
version number through the packets used by OP.

4.1 Overview

An OP message hashed subpacket data is constructed from a number of records that are
traditionally called packets.  A packet hashed.  The
resulting hash value is a chunk of data that has a
tag specifying its meaning.  An OP message, keyring, certificate, and
so forth consists of a number of packets.  Some of those packets may
contain other OP packets (for example, a compressed data packet, when
uncompressed, contains OP packets).

Each packet consists what is signed.  The left 16 bits of a packet header, followed by the hash
are included in the signature packet body.
The packet header is to provide a quick test to reject
some invalid signatures.

There are two fields consisting of variable length.

4.2 Packet Headers signature subpackets.  The first octet of the packet header
field is called hashed with the "Packet Tag." It
determines rest of the format signature data, while the second
is unhashed.  The second set of subpackets is not cryptographically
protected by the header signature and denotes should include only advisory
information.

The algorithms for converting the packet contents. hash function result to a signature
are described above.

5.2.2.1 Signature Subpacket Specification

The remainder subpacket fields consist of the packet header zero or more signature subpackets.
Each set of subpackets is preceded by a two-octet count of the length
of the packet.

Note that the most significant bit is set of subpackets.

Each subpacket consists of a subpacket header and a body.  The header
consists of:

    - subpacket length (1 or 2 octets):
      Length includes the left-most bit, called bit 7.
A mask for type octet but not this bit length,
      1st octet <  192, then length is octet value
      1st octet >= 192, then length is 0x80 in hexadecimal.

       +---------------+
  PTag |7 6 5 4 3 2 1 0|
       +---------------+
  Bit 7 -- Always one
  Bit 6 -- New packet format if set


PGP 2.6.X only uses old format packets.  Thus, software that
interoperates with those versions of PGP must only use old format
packets. octets and equal to
        (1st octet - 192) * 256 + (2nd octet) + 192

    - subpacket type (1 octet):
      If interoperability bit 7 is not an issue, either format may be
used.

Old format packets contain:
  Bits 5-2 -- content tag set, subpacket understanding is critical,
       2 = signature creation time,
       3 = signature expiration time,
       4 = exportable,
       5 = trust signature,
       6 = regular expression,
       7 = revocable,
       9 = key expiration time,
      10 = placeholder for backwards compatibility
      11 = preferred symmetric algorithms,
      12 = revocation key,
      16 = issuer key ID,
      20 = notation data,
      21 = preferred hash algorithms,
      22 = preferred compression algorithms,
      23 = key server preferences,
      24 = preferred key server,
      25 = primary user id,
      26 = policy URL,



Callas, et. al.                Expires May Aug 1998                [Page 14] 15]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


  Bits 1-0




27 = key flags, 28 = Signer's user id

    - length-type

New format packets contain:
  Bits 5-0 -- content tag

The meaning subpacket specific data:

An implementation SHOULD ignore any subpacket that it does not
recognize.

Bit 7 of the length-type in old-format packets is:

0 - The packet has a one-octet length.  The header subpacket type is 2 octets long.

1 - The packet has a two-octet length.  The header the "critical" bit.  If set, it denotes
that the subpacket is 3 octets long.

2 - The packet has one which is critical that the evaluator of the
signature recognize.  If a four-octet length.  The header subpacket is 5 octets long.

3 - The packet encountered which is of indeterminate length.  The header marked
critical but is 1 byte long,
and unknown to the application must determine how long evaluating software, the packet is.  If evaluator
SHOULD consider the
packet is signature to be in error.

An evaluator may "recognize" a file, this means that the packet extends until the end
of the file.  In general, an application should subpacket, but not use indeterminate
length packets except where the end implement it.  The
purpose of the data will be clear from critical bit is to allow the
context.

New format packets have three possible ways of encoding length.  A
one-octet Body Length header encodes packet lengths of up signer to 191
octets, and tell an evaluator
that it would prefer a two-octet Body Length header encodes packet lengths of
192 new, unknown feature to 8383 octets.  For cases where longer packet body lengths generate an error than
be ignored.

5.2.2.2 Signature Subpacket Types

Several types of subpackets are
needed, or where currently defined.  Some subpackets
apply to the length signature itself and some are attributes of the packet body is not known in advance key.
Subpackets that are found on a self-signature are placed on a user name
certification made by the issuer, Partial Body Length headers can be used.  These are
one-octet length headers key itself.  Note that encode the length of only part of the
data packet.

Each Partial Body Length header is followed by a portion of the packet
body data.  The Partial Body Length header specifies this portion's
length.  Another length header (of one of the three types) follows that
portion.  The last length header in the packet must always be a regular
Body Length header.  Partial Body Length headers key may only be used for
the non-final parts of the packet.

A one-octet Body Length header encodes a length of from 0 to 191
octets. This type of length header is recognized because the have more
than one octet
value is less user name, and thus may have more than 192.  The body length is equal to:

bodyLen = length_octet; one self-signature, and
differing subpackets.

A two-octet Body Length header encodes self-signature is a length binding signature made by the key the signature
refers to.  There are three types of from 192 to 8383
octets.  It is recognized because its first octet is in self-signatures, the range 192
to 223.  The body length is equal to:

bodyLen = (1st_octet - 192) * 256 + (2nd_octet) + 192

A Partial Body Length header is one octet long certification
signatures (types 0x10-0x13), the direct-key signature (type 0x1f), and encodes
the subkey binding signature (type 0x18).  For certification
self-signatures, username may have a length
which is self-signature, and thus different
subpackets in those self-signatures.  For subkey binding signatures,
each subkey in fact has a power of 2, from 1 self-signature.  Subpackets that appear in a
certification self-signature apply to 2147483648 (2 the username, and subpackets that
appear in the subkey self-signature apply to the 31st power).  It
is recognized because its one octet value is greater than or equal subkey.  Lastly,
subpackets on the direct key signature apply to
224.  The partial body length the entire key.

Implementing software should interpret a self-signature's preference
subpackets as narrowly as possible.  For example, suppose a key has two
usernames, Alice and Bob.  Suppose that Alice prefers the symmetric
algorithm CAST5, and Bob prefers IDEA or Triple-DES.  If the software
locates this key via Alice's name, then the preferred algorithm is equal to:
CAST5, if software locates the key via Bob's name, then the preferred
algorithm is IDEA.  If the key is located by key id, then algorithm of
the default user name of the key provides the default symmetric
algorithm.






Callas, et. al.                Expires May Aug 1998                [Page 15] 16]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


partialBodyLen = 1 << (length_octet & 0x1f);

Examples:


A packet with length 100 subpacket may have its length encoded be found either in one octet:
0x64. This is followed by 100 octets the hashed or unhashed subpacket
sections of data.

A packet with length 1723 may have its length coded in two octets:
0xC5, 0xFB.  This header a signature.  If a subpacket is followed by not hashed, then the 1723 octets of data.

A packet with length 100000 might be encoded
information in it cannot be considered definitive because it is not
part of the following signature proper.

Subpacket types:

    Signature creation time (4 octet
stream: 0xE1, first two octets of data, 0xE0, next one time field)

        The time the signature was made.  Always included with new
        signatures.

    Issuer (8 octet key ID)

        The OP key ID of data,
0xEF, next 32768 octets the key issuing the signature.

    Key expiration time (4 octet time field)

        The validity period of data, 0xF0, next 65536 octets the key.  This is the number of data, 0xC5,
0xDD, last 1693 octets seconds
        after the key creation time that the key expires.  If this is
        not present or has a value of data. zero, the key never expires. This
        is just one possible encoding,
and many variations are possible found only on the size of the Partial Body Length
headers, as long as a regular Body Length header encodes the last
portion self-signature.

    Preferred symmetric algorithms (array of the data.  Note also one-octet values)

        Symmetric algorithm numbers that indicate which algorithms the last Body Length header can
        key holder prefers to use.  This is an ordered list of octets
        with the most preferred listed first.  It should be
a zero-length header.


Please note assumed
        that only algorithms listed are supported by the recipient's
        software.  Algorithm numbers in all section 6. This is only found
        on a self-signature.

    Preferred hash algorithms (array of these explanations, one-octet values)

        Message digest algorithm numbers that indicate which algorithms
        the total length of key holder prefers to receive.  Like the
packet is preferred
        symmetric algorithms, the length list is ordered. Algorithm numbers
        are in section 6. This is only found on a self-signature.

    Preferred compression algorithms (array of one-octet values)

        Compression algorithm numbers that indicate which algorithms
        the header(s) plus key holder prefers to use.  Like the length of preferred symmetric
        algorithms, the body.

4.3 Packet Tags

The packet tag list is ordered.  Algorithm numbers are in
        section 6.  If this subpacket is not included, ZIP is
        preferred. A zero denotes what type of packet the body holds.  Note that
old format packets can only have tags less than 16, whereas new format
packets can have tags as great as 63.  The defined tags (in decimal)
are:

0        -- Reserved. A packet must not uncompressed data is preferred;
        the key holder's software may not have compression software.
        This is only found on a tag with this value.
1        -- Encrypted Session Key Packet
2        -- Signature Packet
3        -- Conventionally Encrypted Session Key Packet
4        -- One-Pass self-signature.

    Signature Packet
5        -- Secret Key Packet
6        -- Public Key Packet
7        -- Secret Subkey Packet
8        -- Compressed Data Packet
9        -- Symmetrically Encrypted Data Packet
10       -- Marker Packet
11       -- Literal Data Packet
12       -- Trust Packet
13       -- Name Packet
14       -- Subkey Packet
15       -- Reserved
16       -- Comment Packet
60 to 63 -- Private or Experimental Values

5.  Packet Types

5.1 Encrypted Session Key Packets (Tag 1) expiration time (4 octet time field)





Callas, et. al.                Expires May Aug 1998                [Page 16] 17]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


An Encrypted Session Key packet holds



        The validity period of the key used to encrypt a message signature.  This is the number of
        seconds after the signature creation time that the signature
        expires.  If this is itself encrypted with a public key.  Zero not present or more Encrypted
Session Key packets and/or Conventional Encrypted Session Key packets
may precede has a Symmetrically Encrypted Data Packet, which holds an
encrypted message.  The message is encrypted with value of zero, it
        never expires.

    Exportable (1 octet of exportability, 0 for not, 1 for exportable)

        Signature's exportability status.  Packet body contains a session key, and
        boolean flag indicating whether the session key signature is itself encrypted exportable.
        Signatures which are not exportable are ignored during export
        and stored in the Encrypted Session
Key import operations.  If this packet or the Conventional Encrypted Session Key packet.  The
Symmetrically Encrypted Data Packet is preceded by one Encrypted
Session Key packet for each OP key to which not present the message
        signature is encrypted.
The recipient assumed to be exportable.

    Revocable (1 octet of the message finds revocability, 0 for not, 1 for revocable)

        Signature's revocability status.  Packet body contains a session key that is encrypted to
their public key, decrypts
        boolean flag indicating whether the session key, and then uses signature is revocable.
        Signatures which are not revocable have any later revocation
        signatures ignored.  They represent a commitment by the session
key to decrypt signer
        that he cannot revoke his signature for the message.

The body life of his key.
        If this packet consists of:

	- A one-octet number giving the version number of the packet type.
	  The currently defined value for packet version is 3. An 
        implementation should accept, but not generate a version of 2,
        which present, the signature is equivalent to V3 in all other respects.
	- An eight-octet number revocable.

    Trust signature (1 octet "level" (depth), 1 octet of trust amount)

        Signer asserts that gives the key ID of is not only valid, but also
        trustworthy, at the public key specified level.  Level 0 has the same
        meaning as an ordinary validity signature.  Level 1 means that
        the session signed key is encrypted to.
	- A one-octet number giving asserted to be a valid trusted introducer,
        with the public key algorithm used.
	- A string 2nd octet of octets that is the encrypted session key. This 
	  string takes up body specifying the remainder degree of trust.
        Level 2 means that the packet, and its contents are
	  dependent on the public signed key algorithm used.

    Algorithm Specific Fields for RSA encryption
	- multiprecision integer (MPI) of RSA encrypted value m**e.

    Algorithm Specific Fields for Elgamal encryption:
	- MPI of DSA value g**k.
	- MPI of DSA value m * y**k.

The encrypted value "m" in the above formulas is derived from the
session key as follows.  First the session key asserted to be trusted to
        issue level 1 trust signatures, i.e. that it is prepended with a
one-octet algorithm identifier "meta
        introducer".  Generally, a level n trust signature asserts that specifies the conventional
encryption algorithm used to encrypt the following Symmetrically
Encrypted Data Packet.  Then
        a two-octet checksum is appended which key is
equal trusted to the sum of the preceding octets, including the algorithm
identifier and session key, modulo 65536.  This value issue level n-1 trust signatures.  The
        trust amount is then padded as
described in PKCS-1 block type 02 [PKCS1] to form the "m" value used in
the formulas above.

5.2 Signature Packet (Tag 2)

A signature packet describes a binding between some public key range from 0-255, interpreted such that
        values less than 120 indicate partial trust and some
data.  The most common signatures are a signature values of a file 120
        or a block greater indicate complete trust.  Implementations SHOULD
        emit values of text, 60 for partial trust and a 120 for complete trust.

    Regular expression (null-terminated regular expression)

        Used in conjunction with trust signature that is a certification packets (of level > 0)
        to limit the scope of a trust which is extended.  Only signatures
        by the target key on user ID.

Two versions of signature packets are defined.  Version 3 provides
basic signature information, while version 4 provides an expandable
format with subpackets that can specify more information about IDs which match the
signature. PGP 2.6.X only accepts version 3 signatures. regular
        expression in the body of this packet have trust extended by
        the trust packet.  The regular expression uses the same syntax
        as the Henry Spencer's "almost public domain" regular
        expression package.  A description of the syntax in in a
        section below.






Callas, et. al.                Expires May Aug 1998                [Page 17] 18]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998



Implementations MUST accept V3 signatures.  Implementations SHOULD
generate V4 signatures, unless there is a need to generate a signature
that can be verified by PGP 2.6.x.

5.2.1 Version 3 Signature Packet Format

A version 3 Signature packet contains:
	- One-octet version number (3).
	- One-octet length of following hashed material.  MUST be 5.
	- One-octet signature type.
	- Four-octet creation time.
	- Eight-octet


    Revocation key ID (1 octet of signer.
	- One-octet public class, 1 octet of algid, 20 octets of
    fingerprint)

        Authorizes the specified key algorithm.
	- One-octet hash algorithm.
	- Two-octet field holding left 16 to issue revocation
        self-signatures for this key.  Class octet must have bit 0x80
        set, other bits are for future expansion to other kinds of signed hash value.
	- One or more multi-precision integers comprising the signature.
        signature authorizations. This portion is algorithm specific, as described below.

The data being signed found on a self-signature.

        Authorizes the specified key to issue revocation signatures for
        this key.  Class octet must have bit 0x80 set.  If the bit 0x40
        is hashed, and set, then this means that the signature type and
creation time from the signature packet revocation information is
        sensitive.  Other bits are hashed (5 additional
octets).  The resulting hash value for future expansion to other kinds
        of authorizations.  This is used in found on a self-signature.

        If the signature algorithm.
The high 16 bits (first two octets) of "sensitive" flag is set, the hash are included keyholder feels this
        subpacket contains private trust information that describes a
        real-world sensitive relationship.  If this flag is set,
        implementations SHOULD NOT export this signature to other users
        except in cases where the data needs to be available: when the
        signature packet is being sent to provide the designated revoker, or when it
        is accompanied by a quick test revocation signature from that revoker.
        Note that it may be appropriate to reject some invalid
signatures.

    Algorithm Specific Fields for RSA signatures:
	- multiprecision integer (MPI) of RSA isolate this subpacket
        within a separate signature value m**d.

    Algorithm Specific Fields for DSA signatures:
	- MPI so that it is not combined with
        other subpackets which need to be exported.



    Notation Data (4 octets of flags, 2 octets of name length,
                   2 octets of DSA value r.
	- MPI length, M octets of name data,
                   N octets of DSA value s.

The signature calculation is based on data)

        This subpacket describes a hash of "notation" on the signed data, as
described above. signature that the
        issuer wishes to make.  The details notation has a name and a value,
        each of the calculation which are different for DSA
signature strings of octets.  There may be more than
        one notation in a signature.  Notations can be used for RSA signatures.

With RSA signatures, any
        extension the hash value is encoded as described in PKCS-1
section 10.1.2, "Data encoding", producing an ASN.1 value issuer of type
DigestInfo, and then padded using PKCS-1 block type 01 [PKCS1].  This
requires inserting the hash value as an octet string into an ASN.1
structure. signature cares to make.  The object identifier for the type
        "flags" field holds four octets of hash being used flags.

        All undefined flags MUST be zero.  Defined flags are:
        First octet: 0x80 = human-readable. This note is
included in text, a note
                            from one person to another, and has no
                            meaning to software.
        Other octets: none.

    Key server preferences (N octets of flags)

        This is a list of flags that indicate preferences that the structure.  The hexadecimal representations for key
        holder has about how the key is handled on a key server.  All
        undefined flags MUST be zero.


       First octet: 0x80 = No-modify -- the key holder requests that
                           this key only be modified or updated by the
currently defined hash algorithms are:

	- SHA-1:	    0x2b, 0x0e, 0x03, 0x02, 0x1a
	- MD5:		    0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x02, 0x05
	- RIPEMD-160:	0x2b, 0x24, 0x03, 0x02, 0x01

The ASN.1 OIDs are:
	- MD5:       1.2.840.113549.2.5
	- SHA-1:     1.3.14.3.2.26
	- RIPEMD160: 1.3.36.3.2.1


Callas, et. al.                Expires May Aug 1998                [Page 18] 19]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998




DSA signatures SHOULD use hashes with a size of 160 bits, to match q,
the size


                           key holder or an authorized administrator of
                           the group generated by the DSA key's generator value.  The
hash function result key server.
       This is treated as found only on a 160 bit number and used directly
in the DSA signature algorithm.

5.2.2 Version 4 Signature Packet Format

A version 4 Signature packet contains:
	- One-octet version number (4).
	- One-octet signature type.
	- One-octet public self-signature.

    Preferred key algorithm.
	- One-octet hash algorithm.
	- Two-octet octet count server (String)

        This is a URL of a key server that the key holder prefers be
        used for following hashed subpacket data.
	- Hashed subpacket data.
	- Two-octet octet count updates.  Note that keys with multiple user names can
        have a preferred key server for following unhashed subpacket data.
	- Unhashed subpacket data.
	- Two-octet field holding left 16 bits each user name.  Note also that
        since this is a URL, the key server can actually be a copy of signed hash value.
	- One or more multi-precision integers comprising
        the signature. key retrieved by ftp, http, finger, etc.


    Primary user id (1 octet, boolean)

        This portion is algorithm specific, as described above.

The data being signed is hashed, and then the a flag in a user id's self signature data from that states
        whether this user id is the
version number through main user id for this key.  It is
        reasonable for an implementation to resolve ambiguities in
        preferences, etc. by referring to the hashed subpacket data primary user id.  If this
        flag is hashed.  The
resulting hash absent, its value is what zero.  If more than one user id in
        a key is signed.  The left 16 bits of marked as primary, the hash
are included in implementation may resolve the signature packet to provide
        ambiguity in any way it sees fit.

    Policy URL (String)

        This subpacket contains a quick test to reject
some invalid signatures.

There are two fields consisting URL of signature subpackets.  The first
field is hashed with a document that describes the rest of
        policy under which the signature data, while the second
is unhashed.  The second set was issued.

    Key Flags (Octet string)

        This subpacket contains a list of subpackets binary flags that hold
        information about a key.  It is not cryptographically
protected by the signature and should include only advisory
information.

The algorithms for converting the hash function result to a signature
are described above.

5.2.2.1 Signature Subpacket Specification

The subpacket fields consist of zero or more signature subpackets.
Each set string of subpackets octets, and an
        implementation MUST NOT assume a fixed size.  This is preceded by so it can
        grow over time.  If a two-octet count of the length
of list is shorter than an implementation
        expects, the set of subpackets.

Each subpacket consists of a subpacket header and a body. unstated flags are considered to be zero.  The header
consists of:
        defined flags are:


        First octet:
        0x01 - subpacket length (1 or 2 octets):
	  Length includes the type octet but not this length,
	  1st octet <  192, then length is octet value
	  1st octet >= 192, then length is 2 octets and equal This key may be used to
	    (1st octet certify other keys.
        0x02 - 192) * 256 + (2nd octet) + 192 This key may be used to sign data.
        0x04 - subpacket type (1 octet):
	  If bit 7 is set, subpacket understanding is critical, This key may be used to encrypt communications.
        0x08 - This key may be used to encrypt storage.
        0x10 - The private component of this key may have been split by
               a secret-sharing mechanism.
        0x80 - The private component of this key may be in the posession
               of more than one person.

        Usage notes:






Callas, et. al.                Expires May Aug 1998                [Page 19] 20]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


	   2 = signature creation time,
	   3 =


        The flags in this packet may appear in self-signatures or in
        certification signatures.  They mean different things depending
        on who is making the statement -- for example, a certification
        signature expiration time,
	   4 = exportable,
	   5 = trust signature,
	   6 = regular expression,
	   7 = revocable,
	   9 = key expiration time,
	  10 = additional recipient request,
	  11 = preferred symmetric algorithms,
	  12 = revocation key,
	  16 = issuer key ID,
      20 = notation data,
      21 = preferred hash algorithms,
      22 = preferred compression algorithms,
      23 = key server preferences,
      24 = preferred key server 

	- subpacket specific data:

Bit 7 of that has the subpacket type "sign data" flag is the "critical" bit.  If set, it implies stating that it the
        certification is critical for that use.  On the subpacket be one which is understood by other hand, the software.  If
        "communications encryption" flag in a subpacket is encountered which self-signature is marked critical
but the software does not understand, the handling depends on the
relationship between the issuing key and the key stating
        a preference that is signed.  If
the signature is a valid self-signature (for which the issuer is the given key be used for communications.  Note
        however, that it is being signed, either directly or via a username binding),
then the key should not be used.  In other cases, thorny issue to determine what is
        "communications" and what is "storage." This decision is left
        wholly up to the signature
containing implementation; the critical subpacket should be ignored.

5.2.2.2 Signature Subpacket Types

Several types authors of subpackets are currently defined.  Some subpackets
apply to this document
        do not claim any special wisdom on the signature itself issue, and some are attributes of the key.
Subpackets realize that
        accepted opinion may change.

        The "split key" (0x10) and "group key" (0x80) flags are found placed
        on a self-signature only; they are placed meaningless on a user name
        certification made by signature.  They SHOULD be placed only on a
        direct-key signature (type 0x1f) or a subkey signature (type
        0x18), one that refers to the key itself.  Note that the flag applies to.

    Signer's User ID

        This subpacket allows a key may have more
than one keyholder to state which user name, and thus may have more than one self-signature, and
differing subpackets.

Implementing software should interpret id is
        responsible for the signing.  Many keyholders use a self-signature's preference
subpackets single key
        for different purposes, such as narrowly business communications as possible.  For example, suppose well
        as personal communications.  This subpacket allows such a key has two
usernames, Alice and Bob.  Suppose that Alice prefers the symmetric
algorithm CAST5, and Bob prefers IDEA or Triple-DES.  If the software
locates this key via Alice's name, then the preferred algorithm is
CAST5, if software locates the key via Bob's name, then the preferred
algorithm is IDEA.  If the key is located by key id, then algorithm
        keyholder to state which of
the default user name their roles is making a signature.



Implementations SHOULD implement "preferences".


5.2.3 Signature Types

There are a number of the key provides the default symmetric
algorithm.

The descriptions below describe whether possible meanings for a subpacket is typically found signature, which are
specified in a signature type octet in any given signature.  These
meanings are:

    - 0x00: Signature of a binary document.

Typically, this means the hashed signer owns it, created it, or unhashed subpacket sections.  If a subpacket is certifies that
it has not
hashed, then been modified.

    - 0x01: Signature of a canonical text document.

Typically, this means the signer owns it, created it, or certifies that
it cannot has not been modified.  The signature will be trusted.

    Signature creation time (4 octet time field) (Hashed) calculated over the
text data with its line endings converted to <CR><LF>.

    - 0x02: Standalone signature.





Callas, et. al.                Expires May Aug 1998                [Page 20] 21]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998



The time the



This signature is a signature was made.  Always included with new signatures.

    Issuer (8 octet key ID) (Non-hashed)

The OP key ID of the key issuing the only its own subpacket contents.  It
is calculated identically to a signature over a zero-length binary
document.  Note that it doesn't make sense to have a V3 standalone
signature.

    - 0x10: The certification of a User ID and Public Key expiration time (4 octet time field) (Hashed) packet.

The validity period issuer of this certification does not make any particular assertion
as to how well the key.  This is certifier has checked that the number owner of seconds after the key creation time that is
in fact the key expires.  If person described by the user ID.  Note that all PGP "key
signatures" are this type of certification.

    - 0x11: This is not present or
has a value persona certification of zero, a User ID and
            Public Key packet.

The issuer of this certification has not done any verification of the
claim that the owner of this key never expires. is the user ID specified.

    - 0x12: This is found only on the casual certification of a
self-signature.

    Preferred symmetric algorithms (array User ID and
            Public Key packet.

The issuer of this certification has done some casual verification of one-octet values) (Hashed)

Symmetric algorithm numbers that indicate which algorithms
the key
holder prefers to use. claim of identity.

    - 0x13: This is an ordered list the positive certification of a User ID and
            Public Key packet.

The issuer of this certification has done substantial verification of octets with
the most
preferred listed first.  It should be assumed claim of identity.

Please note that only algorithms
listed are supported by the recipient's software.  Algorithm numbers in
section 6. This vagueness of these certification claims is only found on not a self-signature.

    Preferred hash algorithms (array
flaw, but a feature of one-octet values) (Hashed)

Message digest algorithm numbers that indicate which algorithms the key
holder prefers to receive.  Like the preferred symmetric algorithms, system.  Because PGP places final authority
for validity upon the list is ordered. Algorithm numbers are in section 6. This is only
found on receiver of a self-signature.

{{Editor's note:  The above preference (hash algs) is controversial.  I
included certification, it in for symmetry, because if someone wants to build a
minimal OP implementation, there needs to may be a way to tell someone that
you won't one
authority's casual certification might be able to verify a signature unless it's made with more rigorous than some set
of algorithms.  It also permits other
authority's positive certification.  These classifications allow a
certification authority to prefer DSA with RIPEMD-160, issue fine-grained claims.

    - 0x18: This is used for
example. If you have an opinion, please state it.}}

    Preferred compression algorithms (array of one-octet values)
        (Hashed)

Compression algorithm numbers that indicate which algorithms the a signature by a signature key
holder prefers to use.  Like the preferred symmetric algorithms, the
list is ordered.  Algorithm numbers are in section 6.  If this
subpacket is not included, ZIP is preferred. A zero denotes that no
compression bind a
      subkey which will be used for encryption.

The signature is preferred; calculated directly on the key holder's software may subkey itself, not have
compression software. This is only found on a self-signature. any
User ID or other packets.

    - 0x1f: Signature expiration time (4 octet time field) (Hashed)

The validity period of the signature. directly on a key

This signature is calculated directly on a key.  It binds the number of seconds
after
information in the signature creation time that subpackets to the signature expires.  If this
is not present or has a value of zero, it never expires.

    Exportable (1 octet of exportability, 0 key, and is appropriate
to be used for not, 1 subpackets which provide information about the key, such
as the revocation key subpacket.  It is also appropriate for exportable) statements
that non-self certifiers want to make about the key itself, rather than
the binding between a key and a name.



Callas, et. al.                Expires May Aug 1998                [Page 21] 22]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


               (Hashed)

Signature's exportability status.  Packet body contains a boolean flag
indicating whether the signature is exportable. Signatures which are
not exportable are ignored during export and import operations.  If
this packet is not present the


    - 0x20: This signature is assumed used to be exportable.

    Revocable (1 octet of revocability, 0 for not, 1 for revocable)
        (Hashed)

Signature's revocability status.  Packet body contains revoke a boolean flag
indicating whether the key.

The signature is revocable.  Signatures which are calculated directly on the key being revoked.  A
revoked key is not revocable get any later to be used.  Only revocation signatures ignored.  They
represent a commitment by the signer that he cannot key
being revoked, or by an authorized revocation key, should be
considered.

    - 0x28: This is used to revoke his a subkey.

The signature for the life of his key.  If this packet is not present calculated directly on the
signature subkey being revoked.  A
revoked subkey is assumed not to be revocable.

    Trust signature (1 octet of "level" (depth), 1 octet of trust amount)
     (Hashed)
Signer asserts that used.  Only revocation signatures by the
top-level signature key which is not only valid, but also trustworthy, at
the specified level.  Level 0 has the same meaning as bound to this subkey, or by an ordinary
validity signature.  Level 1 means that
authorized revocation key, should be considered.

    - 0x30: This signature revokes an earlier user ID certification
      signature (signature class 0x10 through 0x13).

It should be issued by the signed same key is asserted to
be which issued the revoked signature,
and should have a valid trusted introducer, with later creation date than the 2nd octet of signature it revokes.

    - 0x40: Timestamp signature.

This signature is only meaningful for the body
specifying timestamp contained in it.

5.2.4 Computing Signatures

All signatures are formed by producing a hash over the degree of trust. Level 2 means that signature data,
and then using the signed key resulting hash in the signature algorithm.

The signature data is
asserted to be trusted simple to issue level 1 trust compute for document signatures (types
0x00 and 0x01), for which the document itself is the data.  For
standalone signatures, i.e. that it this is a "meta introducer".  Generally, null string.

When a level n trust signature asserts
that a key is trusted to issue level n-1 trust signatures.  The trust
amount is in made over a range from 0-255, interpreted such that values less than
120 indicate partial trust and values of 120 or greater indicate
complete trust.  Implementations SHOULD emit values of 60 for partial
trust and 120 for complete trust.

    Regular expression (null-terminated regular expression) (Hashed)

Used in conjunction key, the hash data starts with trust signature packets (of level > 0) to
limit the scope of trust which is extended.  Only signatures
octet 0x99, followed by a two-octet length of the
target key on user IDs which match the regular expression in the key, and then body of this packet have trust extended by
the trust key packet.

    Additional recipient request (1 octet of class, 1 octet of algid, 
                                  20 octets of fingerprint) (Hashed)

Key holder requests encryption to additional recipient when data is
encrypted to (Note that this username.  If the class octet contains 0x80, is an old-style packet header for a key
packet with two-octet length.) A subkey signature (type 0x18) then
hashes the subkey, using the same format as the main key.  Key
revocation signatures (types 0x20 and 0x28) hash only the key holder strongly requests that being
revoked.

A certification signature (type 0x10 through 0x13) then hashes the additional recipient be added user
name being bound to
an encryption.  Implementing software may treat this subpacket in the key.  A V3 certification hashes the contents of
the name packet, without any
way it sees fit. This header.  A V4 certification hashes the
constant 0xd4 (which is found only on an old-style CTB with the length-of-length set
to zero), a self-signature.

    Revocation key (1 octet of class, 1 octet four-octet number giving the length of algid, 20 the username, and
then the username data.

Once the data body is hashed, then a trailer is hashed.  A V3 signature
hashes five octets of
	              fingerprint) (Hashed)

Authorizes the specified key to issue revocation self-signatures on
this key.  Class octet must have bit 0x80 set, other bits are for packet body, starting from the signature type
field.  This data is the signature type, followed by the four-octet
signature time.  A V4 signature hashes the packet body starting from
its first field, the version number, through the end of the hashed


Callas, et. al.                Expires May Aug 1998                [Page 22] 23]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


future expansion to other kinds of


subpacket data.  Thus, the fields hashed are the signature authorizations. This is
found on a self-signature.

    Notation Data (4 octets of flags, 2 octets of name length, 
                   2 octets of value length, M octets of name data, 
                   N octets of value data) (Hashed)

This subpacket describes a "notation" on version, the
signature that type, the issuer
wishes to make.  The notation has a name public key algorithm, the hash algorithm, the
hashed subpacket length, and a value, each of which are
strings of octets.  There may be more than one notation in a signature.
Notations can be the hashed subpacket body.

After all this has been hashed, the resulting hash field is used for any extension in the issuer
signature algorithm, and placed at the end of the signature
cares to make. packet.


5.3 Symmetric-Key Encrypted Session-Key Packets (Tag 3)

The "flags" field Symmetric-Key Encrypted Session Key packet holds four octets the
conventional-cipher encryption of flags. All
undefined flags MUST be zero.  Defined flags are:
        First octet: 0x80 = human-readable. This note is text, a note
                            from one person to another, and has no 
                            meaning session key used to software.
        Other octets: none. encrypt a
message.  Zero or more Encrypted Session Key server preferences (N octets of flags) (Hashed)

This is packets and/or
Conventional Encrypted Session Key packets may precede a list of flags that indicate preferences Symmetrically
Encrypted Data Packet that the key holder
has about how the key holds an encrypted message.  The message is handled on
encrypted with a key server.  All undefined flags
MUST be zero.

       First octet: 0x80 = No-modify -- session key, and the session key holder requests that
                           this key only be modified or updated by is itself encrypted
and stored in the 
                           key holder Encrypted Session Key packet or an authorized administrator of the key server.
This is found only on a self-signature.

    Preferred key server (String) (Hashed)

This Conventional
Encrypted Session Key packet.

If the Symmetrically Encrypted Data Packet is preceded by one or more
Symmetric-Key Encrypted Session Key packets, each specifies a URL of a key server that the key holder prefers
passphrase which may be used for
updates.  Note that keys with multiple user names can have a preferred
key server for each user name. to decrypt the message.  This is found only on allows a self-signature.

Implementations SHOULD implement
message to be encrypted to a "preference" number of public keys, and MAY implement a
"request."

{{Editor's note:  None also to one or
more pass phrases.  This packet type is new, and is not generated by
PGP 2.x or PGP 5.0.

The body of this packet consists of:
    - A one-octet version number. The only currently defined version is
      4.
    - A one-octet number describing the preferences have a way to specify a
negative preference (for example, I like Triple-DES, don't use symmetric algorithm X).  Tacitly, used.
    - A string-to-key (S2K) specifier, length as defined above.
    - Optionally, the absence encrypted session key itself, which is decrypted
          with the string-to-key object.

If the encrypted session key is not present (which can be detected on
the basis of an packet length and S2K specifier size), then the S2K
algorithm applied to the passphrase produces the session key for
decrypting the file, using the symmetric cipher algorithm from a set the
Symmetric-Key Encrypted Session Key packet.

If the encrypted session key is a
negative preference, but should there be an explicit way present, the result of applying the S2K
algorithm to give a
negative preference? -jdcc}}

{{Editor's note:  A missing feature the passphrase is used to invalidate (or revoke) a user
id, rather than the entire key.  Lots of people want this, and many
people have keys cluttered with old work email addresses.  There is
another related issue, that decrypt just that is with encrypted
session key rollover -- suppose I'm
retiring field, using CFB mode with an old key, but I don't want to have to lose IV of all my
certification signatures.  It would be nice if there were a way for zeros.  The
decryption result consists of a
key to transfer itself one-octet algorithm identifier that
specifies the conventional encryption algorithm used to encrypt the
following Symmetrically Encrypted Data Packet, followed by the session
key octets themselves.

Note: because an all-zero IV is used for this decryption, the S2K
specifier MUST use a new one.  Lastly, if salt value, either (or both) of
these is desirable, do we handle them with a new signature type, a Salted S2K or an
Iterated-Salted S2K.  The salt value will insure that the decryption
key is not repeated even if the passphrase is reused.



Callas, et. al.                Expires May Aug 1998                [Page 23] 24]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


with notations, which are an extension mechanism.  I think that it
makes sense



5.4 One-Pass Signature Packets (Tag 4)

The One-Pass Signature packet precedes the signed data and contains
enough information to make a revocation type (because it's analogous allow the receiver to begin calculating any
hashes needed to verify the
other forms of revocation), but rollover might signature.  It allows the Signature Packet
to be best implemented as
an extension. --jdcc}}

{{Editor's note: placed at the end of the message, so that the signer can compute
the entire signed message in one pass.

A One-Pass Signature does not interoperate with PGP 3 designed, but never implemented a number 2.6.x or earlier.

The body of
other subpacket types.  They were: this packet consists of:
    - A signature one-octet version number; number. The current version is 3.
    - A set
of key usage flags (signing key, encryption key for communication, and
encryption one-octet signature type. Signature types are described
          in section 5.2.3.
    - A one-octet number describing the hash algorithm used.
    - A one-octet number describing the public key for storage); User ID of algorithm used.
    - An eight-octet number holding the signer; Policy URL; net
location key ID of the signing key.

Some of these options are things the WG has talked about as being a
Good Thing -- like flags denoting if
    - A one-octet number holding a key flag showing whether the signature
is a comm key or a storage
key.  My design of such a feature would be different than nested.  A zero value indicates that the other
one, though. I think it would be a great idea next packet is
another One-Pass Signature packet which describes another
signature to have a URL that's a
location be applied to find the key, so people who prefer to have same message data.


5.5 Key Material Packet

A key material packet contains all the information about a web, ftp, public or
finger location can use those.  However, some of them (like a URL) are
also perfect for designing in with extensions.  After all, we only have
128 subpacket constants.

--jdcc}}

5.2.3 Signature Types
private key.  There are a number four variants of possible meanings for a signature, which are
specified in this packet type, and two
major versions.  Consequently, this section is complex.

5.5.1 Key Packet Variants

5.5.1.1 Public Key Packet (Tag 6)

A Public Key packet starts a signature type octet in any given signature.  These
meanings are:

	- 0x00: Signature series of a binary document.
Typically, this means the signer owns it, created it, or certifies packets that
it forms an OP key
(sometimes called an OP certificate).

5.5.1.2 Public Subkey Packet (Tag 14)

A Public Subkey packet (tag 14) has not been modified.

	- 0x01: Signature of a canonical text document.
Typically, this means exactly the signer owns it, created it, same format as a Public
Key packet, but denotes a subkey.  One or certifies that
it has not been modified.  The signature will more subkeys may be calculated over the
textual data
associated with its line endings converted to <CR><LF>.

    - 0x02: Standalone signature.
This signature is a signature of only its own subpacket contents.  It
is calculated identically to a top-level key.  By convention, the top-level key
provides signature over a zero-length binary
document.

	- 0x10: The generic certification of a User ID services, and Public Key
	  packet.
The issuer of this certification does not make any particular assertion
as to how well the certifier has checked that the owner of the key is subkeys provide encryption
services.

Note: in fact the person described by the user ID.  Note that all PGP "key
signatures" are this type of certification.

	- 0x11: This is a persona certification of 2.6.X, tag 14 was intended to indicate a User ID and 
	  Public Key comment packet.
It means that the issuer
This tag was selected for reuse because no previous version of this certification has PGP ever
emitted comment packets but they did properly ignore them.  Public
Subkey packets are ignored by PGP 2.6.X and do not done any
verification of the claim that the owner cause it to fail,
providing a limited degree of this key is the user ID backwards compatibility.





Callas, et. al.                Expires May Aug 1998                [Page 24] 25]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


specified.  Note



5.5.1.3 Secret Key Packet (Tag 5)

A Secret Key packet contains all the information that no released version of PGP has generated this
type of certification.

	- 0x12: This is the casual certification of found in a User ID and
Public Key packet.
It means that packet, including the issuer of this certification has done some casual
verification of public key material, but also includes
the claim of identity.  Note that no version of PGP has
generated this type of certification, nor is there any definition of
what constitutes a casual certification.

	- 0x13: This secret key material after all the public key fields.

5.5.1.4 Secret Subkey Packet (Tag 7)

A Secret Subkey packet (tag 7) is the positive certification subkey analog of a User ID and 
	  Public Key packet.
It means that the issuer of this certification Secret Key
packet, and has done substantial
verification of exactly the claim of identity.  Note that no version same format.

5.5.2 Public Key Packet Formats

There are two versions of PGP has key-material packets.  Version 3 packets were
first generated this type of certification, nor is there any definition of
what constitutes a positive certification.  Please also note that the
vagueness of these certification systems is not a flaw, but a feature
of the system.  Because PGP places final authority for validity upon
the receiver of a certification, it may be that one authority's casual
certification might be more rigorous than some other authority's
positive certification.

{{Editor's note:  While there is a scale of identification signatures 2.6.  Version 2 packets are identical in the range 0x10 to 0x13, most of them have never been implemented or
used.  Current implementations only use 0x10, the "generic
certification." Should the others be removed?  RFC 1991 went to some
trouble format to explain which ones were defined
Version 3 packets, but not implemented, are generated by PGP 2.5 or read
but not generated.  I think we should before.  PGP 5.0
introduces version 4 packets, with new fields and semantics.  PGP 2.6.X
will not do that.  If we define them,
they should be accept key-material packets with versions greater than 3.

OP implementations SHOULD create keys with version 4 format.  An
implementation MAY features at the very least.  If we're not going generate a V3 key to
use them, they shouldn't be ensure interoperability with
old software; note, however, that V4 keys correct some security
deficiencies in the spec. --jdcc}}

	- 0x18: This is used for a signature by V3 keys.  These deficiencies are described below.  An
implementation MUST NOT create a signature V3 key to bind with a
	  subkey which will be used for encryption.
The signature is calculated directly on the subkey itself, not on any
User ID or public key algorithm
other packets. than RSA.

A version 3 public key or public subkey packet contains:
    - 0x20: This signature is used to revoke a key.
The signature is calculated directly on A one-octet version number (3).
    - A four-octet number denoting the time that the key being revoked. was created.
    - A
revoked two-octet number denoting the time in days that this key is
      valid. If this number is zero, then it does not to be used.  Only revocation signatures by expire.
    - A one-octet number denoting the public key algorithm of this key
being revoked, or by an authorized revocation key, should be
considered.
    - 0x28: This is used to revoke a subkey.
The signature is calculated directly on the subkey being revoked. A
revoked subkey is not to be used.  Only revocation signatures by series of multi-precision integers comprising the
top-level signature key which is bound to this subkey, or by an
authorized revocation key, should be considered.
      material:
    - 0x30: This signature revokes an earlier user ID certification
	  signature (signature class 0x10 a multiprecision integer (MPI) of RSA public modulus n;
    - 0x13).
It should be issued an MPI of RSA public encryption exponent e.

The fingerprint of the key is formed by hashing the body (but not the
two-octet length) of the MPIs that form the key material (public
modulus n, followed by exponent e) with MD5.

The eight-octet key ID of the key consists of the low 64 bits of the
public modulus of an RSA key.

Since the release of V3 keys, there have been a number of improvements
desired in the key format.  For example, if the key ID is a function of
the public modulus, it is easy for a person to create a key that has
the same key which issued ID as some existing key.  Similarly, MD5 is no longer the revoked signature,
preferred hash algorithm, and should have not hashing the length of an MPI with its
body increases the chances of a later creation date. fingerprint collision.




Callas, et. al.                Expires May Aug 1998                [Page 25] 26]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


    - 0x40: Timestamp signature.

{{Editor's note:




The timestamp signature version 4 format is left over from RFC 1991,
and has never been fully designed nor implemented.  Is this the sort of
thing best handled by notations? --jdcc}}

{{Editor's note:  It would be nice to have a signature that applied similar to the key alone, rather than a key plus a user name.  Perhaps this is
best done with a notation. --jdcc}}

{{Editor's note:  There is presently no way version 3 format except for a key-signer (a.k.a.
certifier) to sign a main key along with a subkey.  There are a number the
absence of useful situations for a set of keys (main plus subkeys) to all be
signed together.  How do we solve this? --jdcc}}

5.3 Conventional Encrypted Session-Key Packets (Tag 3)

The Conventional Encrypted Session Key packet holds the
conventional-cipher encryption of a session key used validity period.  This has been moved to encrypt a
message.  Zero or more Encrypted Session Key packets and/or
Conventional Encrypted Session Key packets may precede a Symmetrically
Encrypted Data Packet that holds an encrypted message.  The message is
encrypted with a session key, and the session key is itself encrypted
and stored in the Encrypted Session Key packet or the Conventional
Encrypted Session Key signature
packet.

If the Symmetrically Encrypted Data Packet is preceded by one or more
Conventional Encrypted Session Key packets, each specifies a passphrase
which may be used to decrypt the message.  This allows a message to be
encrypted to a number  In addition, fingerprints of public version 4 keys are calculated
differently from version 3 keys, and also to one or more pass
phrases.  This packet type is new, and is not generated by PGP 2.x or
PGP 5.0.

The body of this as described in section "Enhanced Key
Formats."

A version 4 packet consists of: contains:
    - A one-octet version number. The only currently defined version is
	  4. number (4).
    - A one-octet four-octet number describing denoting the symmetric algorithm used. time that the key was created.
    - A string-to-key (S2K) specifier, length as defined above.
	- Optionally, one-octet number denoting the encrypted session public key itself, which is decrypted
          with the string-to-key object.

If the encrypted session algorithm of this key is not present (which can be detected on
the basis
    - A series of packet length and S2K specifier size), then the S2K
algorithm applied to the passphrase produces multi-precision integers comprising the session key
      material.  This algorithm-specific portion is:

    Algorithm Specific Fields for
decrypting the file, using the symmetric cipher algorithm from the
Conventional Encrypted Session Key packet.

If the encrypted session RSA public keys:
    - multiprecision integer (MPI) of RSA public modulus n;
    - MPI of RSA public encryption exponent e.

    Algorithm Specific Fields for DSA public keys:
    - MPI of DSA prime p;
    - MPI of DSA group order q (q is a prime divisor of p-1);
    - MPI of DSA group generator g;
    - MPI of DSA public key value y (= g**x where x is present, the result secret).

    Algorithm Specific Fields for Elgamal public keys:
    - MPI of applying Elgamal prime p;
    - MPI of Elgamal group generator g;
    - MPI of Elgamal public key value y (= g**x where x
      is secret).


5.5.3 Secret Key Packet Formats

The Secret Key and Secret Subkey packets contain all the S2K
algorithm to data of the passphrase is used to decrypt just that encrypted
session key field, using CFB mode
Public Key and Public Subkey packets, with an IV of all zeros. additional
algorithm-specific secret key data appended, in encrypted form.

The
decryption result consists of a one-octet algorithm identifier packet contains:
    - A Public Key or Public Subkey packet, as described above
    - One octet indicating string-to-key usage conventions.  0 indicates
      that
specifies the secret key data is not encrypted.  255 indicates that a
      string-to-key specifier is being given.  Any other value
      is a conventional encryption algorithm used to encrypt the
following Symmetrically Encrypted Data Packet, followed specifier.
    - [Optional] If string-to-key usage octet was 255, a one-octet
      conventional encryption algorithm.
    - [Optional] If string-to-key usage octet was 255, a string-to-key
      specifier.  The length of the string-to-key specifier is implied
      by its type, as described above.
    - [Optional] If secret data is encrypted, eight-octet Initial Vector
      (IV).
    - Encrypted multi-precision integers comprising the session secret key data.
      These algorithm-specific fields are as described below.


Callas, et. al.                Expires May Aug 1998                [Page 26] 27]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


key octets themselves.

Note: because an all-zero IV is used


    - Two-octet checksum of the plaintext of the algorithm-specific
      portion (sum of all octets, mod 65536).

    Algorithm Specific Fields for this decryption, RSA secret keys:
    - multiprecision integer (MPI) of RSA secret exponent d.
    - MPI of RSA secret prime value p.
    - MPI of RSA secret prime value q (p < q).
    - MPI of u, the S2K
specifier MUST use a salt value, either multiplicative inverse of p, mod q.

    Algorithm Specific Fields for DSA secret keys:
    - MPI of DSA secret exponent x.

    Algorithm Specific Fields for Elgamal secret keys:
    - MPI of Elgamal secret exponent x.

Secret MPI values can be encrypted using a passphrase.  If a Salted S2K or an
Iterated-Salted S2K.  The salt value will insure
string-to-key specifier is given, that describes the decryption
key is not repeated even if algorithm for
converting the passphrase to a key, else a simple MD5 hash of the
passphrase is reused.


5.4 One-Pass Signature Packets (Tag 4) used.  Implementations SHOULD use a string-to-key
specifier; the simple hash is for backwards compatibility.  The One-Pass Signature packet precedes cipher
for encrypting the signed data and contains
enough information to allow MPIs is specified in the receiver to begin calculating any
hashes needed to verify secret key packet.

Encryption/decryption of the signature.  It allows secret data is done in CFB mode using the Signature Packet
to be placed
key created from the passphrase and the Initial Vector from the packet.
A different mode is used with RSA keys than with other key formats.
With RSA keys, the MPI bit count prefix (i.e., the first two octets) is
not encrypted.  Only the MPI non-prefix data is encrypted.
Furthermore, the CFB state is resynchronized at the end beginning of the message, each
new MPI value, so that the signer can compute
the entire signed message in one pass.

A One-Pass Signature does not interoperate CFB block boundary is aligned with PGP 2.6.x or earlier.

The body the start
of this packet consists of:
	- A one-octet version number. The current version the MPI data.

With non-RSA keys, a simpler method is 3.
	- A one-octet signature type. Signature types used.  All secret MPI values are described
encrypted in section 5.2.3.
	- A one-octet number describing CFB mode, including the hash algorithm used.
	- A one-octet number describing MPI bitcount prefix.

The 16-bit checksum that follows the public key algorithm used.
	- An eight-octet number holding algorithm-specific portion is the key ID
algebraic sum, mod 65536, of the signing key.
	- A one-octet number holding a flag showing whether plaintext of all the signature
algorithm-specific octets (including MPI prefix and data).  With RSA
keys, the checksum is nested.  A zero value indicates that stored in the next packet clear.  With non-RSA keys, the
checksum is
another One-Pass Signature packet which describes another 
signature to be applied to encrypted like the same message algorithm-specific data.


5.5 Key Material  This value is
used to check that the passphrase was correct.

5.6 Compressed Data Packet

A key material (Tag 8)

The Compressed Data packet contains all the information about a public or
private key.  There are four variants of compressed data.  Typically, this
packet type, and two
major versions.  Consequently, this section is complex.

5.5.1 Key Packet Variants

5.5.1.1 Public Key Packet (Tag 6)

A Public Key packet starts a series found as the contents of packets that forms an OP key
(sometimes called an OP certificate).

5.5.1.2 Public Subkey Packet (Tag 14)

A Public Subkey packet (tag 14) has exactly the same format as a Public
Key encrypted packet, but denotes a subkey.  One or more subkeys may be
associated with following a top-level key.  By convention, the top-level key
provides signature services,
Signature or One-Pass Signature packet, and contains literal data
packets.

The body of this packet consists of:
    - One octet that gives the subkeys provide encryption
services.

Note: in PGP 2.6.X, tag 14 was intended algorithm used to indicate a comment compress the packet.
    - The remainder of the packet is compressed data.




Callas, et. al.                Expires May Aug 1998                [Page 27] 28]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


This tag was selected for reuse because no previous version of PGP ever
emitted comment packets but they did properly ignore them.  Public
Subkey packets are ignored by PGP 2.6.X and do not cause it to fail,
providing a limited degree of backwards compatibility.

5.5.1.3 Secret Key Packet (Tag 5)




A Secret Key packet Compressed Data Packet's body contains all the information an RFC1951 DEFLATE block that is found in
compresses some set of packets.  See section "Packet Composition" for
details on how messages are formed.

5.7 Symmetrically Encrypted Data Packet (Tag 9)

The Symmetrically Encrypted Data packet contains data encrypted with a
Public
conventional (symmetric-key) algorithm.  When it has been decrypted, it
will typically contain other packets (often literal data packets or
compressed data packets).

The body of this packet consists of:

    - Encrypted data, the output of the selected conventional cipher
          operating in PGP's variant of Cipher Feedback (CFB) mode.

The conventional cipher used may be specified in an Encrypted Session
Key packet, including or Conventional Encrypted Session Key packet which precedes the public key material, but also includes
Symmetrically Encrypted Data Packet.  In that case, the secret cipher
algorithm octet is prepended to the session key material after all before it is encrypted.
If no packets of these types precede the public encrypted data, the IDEA
algorithm is used with the session key fields.

5.5.1.4 Secret Subkey Packet (Tag 7)

A Secret Subkey packet (tag 7) calculated as the MD5 hash of
the passphrase.

The data is encrypted in CFB mode, with a CFB shift size equal to the subkey analog
cipher's block size.  The Initial Vector (IV) is specified as all
zeros.  Instead of using an IV, OP prefixes a 10 octet string to the Secret Key
packet,
data before it is encrypted.  The first eight octets are random, and has exactly
the same format.

5.5.2 Public Key Packet Formats

There 9th and 10th octets are two versions copies of key-material packets.  Version 3 packets were the 7th and 8th octets,
respectivelly. After encrypting the first generated PGP 2.6.  Version 2 packets 10 octets, the CFB state is
resynchronized if the cipher block size is 8 octets or less.  The last
8 octets of ciphertext are identical passed through the cipher and the block
boundary is reset.

The repetition of 16 bits in format the 80 bits of random data prepended to
Version 3 packets, but are generated by PGP 2.5 or before.  PGP 5.0
introduces version 4 packets, with new fields and semantics.  PGP 2.6.X
will not accept key-material packets with versions greater than 3.

OP implementations SHOULD create keys with version 4 format.  An
implementation MAY generate a V3 key
the message allows the receiver to ensure interoperability with
old software; note, however, that V4 keys correct some security
deficiencies in V3 keys.  These deficiencies are described below.  An
implementation MUST NOT create a V3 key with a public immediately check whether the
session key algorithm
other than RSA.

A is correct.

5.8 Marker Packet (Obsolete Literal Packet) (Tag 10)

An experimental version 3 public key or public subkey of PGP used this packet contains:
    - A one-octet version number (3).
    - A four-octet number denoting the time that the key was created.
    - A two-octet number denoting as the time in days that Literal packet,
but no released version of PGP generated Literal packets with this key is
      valid. If tag.
With PGP 5.x, this number packet has been re-assigned and is zero, then it does not expire.
    - A one-octet number denoting reserved for use
as the public key algorithm Marker packet.

The body of this key packet consists of:
    - A series of multi-precision integers comprising the key      
      material:
    - a multiprecision integer (MPI) of RSA public modulus n;
    - an MPI of RSA public encryption exponent e.

The fingerprint of the key is formed by hashing the body (but not the
two-octet length) of the MPIs that form the key material (public
modulus n, followed by exponent e) with MD5. The eight-octet key ID of the key consists of the low 64 bits of the
public modulus of an RSA key.

Since the release of V3 keys, there have been a number of improvements
desired three octets 0x60, 0x47, 0x60 (which spell "PGP" in the key format.  For example, if the key ID is a function of
the public modulus, it is easy for a person to create a key that has
the same key ID as some existing key.  Similarly, MD5 is no longer the UTF-8).






Callas, et. al.                Expires May Aug 1998                [Page 28] 29]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


preferred hash algorithm, and not hashing the length of an MPI with its
body increases


Such a packet MUST be ignored when received.  It may be placed at the chances
beginning of a fingerprint collision.

The message that uses features not available in PGP 2.6.X in
order to cause that version 4 format is similar to report that newer software necessary to
process the version 3 format except for message.

5.9 Literal Data Packet (Tag 11)

A Literal Data packet contains the
absence body of a validity period.  This has been moved message; data that is not
to the signature
packet.  In addition, fingerprints be further interpreted.

The body of version 4 keys are calculated
differently from version 3 keys, as described elsewhere.

A version 4 this packet contains: consists of:
    - A one-octet version number (4).
    - A four-octet number denoting the time field that describes how the key was created.
    - A one-octet number denoting data is formatted.

If it is a 'b' (0x62), then the public key algorithm literal packet contains binary data. If
it is a 't' (0x74), then it contains text data, and thus may need line
ends converted to local form, or other text-mode changes.  RFC 1991
also defined a value of this key 'l' as a 'local' mode for machine-local
conversions.  This use is now deprecated.

    - A series of multi-precision integers comprising File name as a string (one-octet length, followed by file name),
      if the key      
      material. encrypted data should be saved as a file.

If the special name "_CONSOLE" is used, the message is considered to be
"for your eyes only".  This algorithm-specific portion is:

    Algorithm Specific Fields for RSA public keys:
    - multiprecision integer (MPI) of RSA public modulus n;
    - MPI of RSA public encryption exponent e.

    Algorithm Specific Fields advises that the message data is unusually
sensitive, and the receiving program should process it more carefully,
perhaps avoiding storing the received data to disk, for DSA public keys: example.

    - MPI A four-octet number that indicates the modification date of DSA prime p;
    - MPI the
file, or the creation time of DSA group order q (q is the packet, or a prime divisor of p-1);
    - MPI of DSA group generator g; zero that indicates the
present time.

    - MPI The remainder of DSA public key value y (= g**x where x the packet is secret).

    Algorithm Specific Fields for Elgamal public keys:
    - MPI of Elgamal prime p;
    - MPI of Elgamal group generator g;
    - MPI of Elgamal public key value y (= g**x where x literal data.

Text data is secret).


5.5.3 Secret Key stored with <CR><LF> text endings (i.e. network-normal
line endings).  These should be converted to native line endings by the
receiving software.

5.10 Trust Packet Formats (Tag 12)

The Secret Key Trust packet is used only within keyrings and Secret Subkey is not normally
exported.  Trust packets contain all the data of the
Public Key and Public Subkey packets, with additional
algorithm-specific secret key data appended, in encrypted form.

The packet contains:
    - A Public Key or Public Subkey packet, as described above
    - One octet indicating string-to-key usage conventions.  0 indicates that record the secret key data is not encrypted.  255 indicates that a
	  string-to-key specifier is being given.  Any other value
	  is a conventional encryption algorithm specifier.
	- [Optional] If string-to-key usage octet was 255, a one-octet
	  conventional encryption algorithm.
	- [Optional] If string-to-key usage octet was 255, a string-to-key
	  specifier.  The length user's
specifications of the string-to-key specifier is implied
	  by its type, as described above.
	- [Optional] If secret data is encrypted, eight-octet Initial Vector
      (IV).
	- Encrypted multi-precision integers comprising the secret which key data.
	  These algorithm-specific fields holders are as described below. trustworthy introducers, along
with other information that implementing software uses for trust
information.

Trust packets SHOULD NOT be emitted to output streams that are
transferred to other users, and they SHOULD be ignored on any input
other than local keyring files.







Callas, et. al.                Expires May Aug 1998                [Page 29] 30]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


	- Two-octet checksum


5.11 User ID Packet (Tag 13)

A User ID packet consists of data which is intended to represent the plaintext
name and email address of the algorithm-specific
	  portion (sum of all octets, mod 65536).
	
    Algorithm Specific Fields for RSA secret keys:
	- multiprecision integer (MPI) of RSA secret exponent d.
	- MPI of RSA secret prime value p.
	- MPI of RSA secret prime value q (p < q).
	- MPI of u, key holder.  By convention, it includes
an RFC822 mail name, but there are no restrictions on its content.  The
packet length in the multiplicative inverse of p, mod q.

    Algorithm Specific Fields for DSA secret keys:
	- MPI of DSA secret exponent x.

    Algorithm Specific Fields for Elgamal secret keys:
	- MPI header specifies the length of Elgamal secret exponent x.

Secret MPI values can be encrypted using a passphrase. the user name.  If a
string-to-key specifier
it is given, that describes text, it is encoded in UTF-8.


6.  Radix-64 Conversions

As stated in the algorithm introduction, OP's underlying native representation
for
converting the passphrase to a key, else a simple MD5 hash of the
passphrase objects is used.  Implementations SHOULD use a string-to-key
specifier; stream of arbitrary octets, and some systems desire
these objects to be immune to damage caused by character set
translation, data conversions, etc.

In principle, any printable encoding scheme that met the simple hash is for backwards compatibility.  The cipher
for encrypting requirements
of the MPIs is specified in unsafe channel would suffice, since it would not change the secret key packet.

Encryption/decryption
underlying binary bit streams of the secret native OP data is done in CFB mode using the
key created from the passphrase structures.  The OP
standard specifies one such printable encoding scheme to ensure
interoperability.

OP's Radix-64 encoding is composed of two parts: a base64 encoding of
the binary data, and a checksum.  The base64 encoding is identical to
the Initial Vector from MIME base64 content-transfer-encoding [RFC 2045, Section 6.8].  An
OP implementation MAY use ASCII Armor to protect the packet. raw binary data.

The checksum is a 24-bit CRC converted to four characters of radix-64
encoding by the same MIME base64 transformation, preceded by an equals
sign (=).  The CRC is computed by using the generator 0x864CFB and an
initialization of 0xB704CE.  The accumulation is done on the data
before it is converted to radix-64, rather than on the converted data.
A different mode sample implementation of this algorithm is used in the next section.

The checksum with RSA keys its leading equal sign MAY appear on the first line
after the Base64 encoded data.

Rationale for CRC-24:  The size of 24 bits fits evenly into printable
base64.  The nonzero initialization can detect more errors than a zero
initialization.

6.1 An Implementation of the CRC-24 in "C"

#define CRC24_INIT 0xb704ce
#define CRC24_POLY 0x1864cfb

crc24 crc_bytes(unsigned char *bytes, size_t len)
{
    crc24 crc = CRC_INIT;
    int i;

    while (len--) {
        crc ^= *bytes++;


Callas, et. al.                Expires Aug 1998                [Page 31]
Internet Draft              OpenPGP Message Format              Mar 1998


        for (i = 0; i < 8; i++) {
            crc <<= 1;
            if (crc & 0x1000000)
                crc ^= CRC24_POLY;
        }
    }
    return crc;
}


6.2 Forming ASCII Armor

When OP encodes data into ASCII Armor, it puts specific headers around
the data, so OP can reconstruct the data later.  OP informs the user
what kind of data is encoded in the ASCII armor through the use of the
headers.

Concatenating the following data creates ASCII Armor:

        - An Armor Header Line, appropriate for the type of data
        - Armor Headers
        - A blank (zero-length, or containing only whitespace) line
        - The ASCII-Armored data
        - An Armor Checksum
        - The Armor Tail, which depends on the Armor Header Line.

An Armor Header Line consists of the appropriate header line text
surrounded by five (5) dashes ('-', 0x2D) on either side of the header
line text.  The header line text is chosen based upon the type of data
that is being encoded in Armor, and how it is being encoded.  Header
line texts include the following strings:

    BEGIN PGP MESSAGE               used for signed, encrypted, or
                                    compressed files

    BEGIN PGP PUBLIC KEY BLOCK      used for armoring public keys

    BEGIN PGP PRIVATE KEY BLOCK     used for armoring private keys

    BEGIN PGP MESSAGE, PART X/Y     used for multi-part messages, where
                                    the armor is split amongst Y parts,
                                    and this is the Xth part out of Y.

    BEGIN PGP MESSAGE, PART X       used for multi-part messages, where
                                    this is the Xth part of an
                                    unspecified number of parts.
                                    Requires the MESSAGE-ID Armor
                                    Header to be used.

    BEGIN PGP SIGNATURE             used for detached signatures,
                                    OP/MIME signatures, and signatures
                                    following clearsigned messages



Callas, et. al.                Expires Aug 1998                [Page 32]
Internet Draft              OpenPGP Message Format              Mar 1998





The Armor Headers are pairs of strings that can give the user or the
receiving OP message block some information about how to decode or use
the message.  The Armor Headers are a part of the armor, not a part of
the message, and hence are not protected by any signatures applied to
the message.

The format of an Armor Header is that of a key-value pair.  A colon
(':' 0x38) and a single space (0x20) separate the key and value.  OP
should consider improperly formatted Armor Headers to be corruption of
the ASCII Armor.  Unknown keys should be reported to the user, but OP
should continue to process the message.

Currently defined Armor Header Keys are:

    - "Version", which states the OP Version used to encode the
    message.

    - "Comment", a user-defined comment.

    - "MessageID", a 32-character string of printable characters.  The
    string must be the same for all parts of a multi-part message that
    uses the "PART X" Armor Header.  MessageID strings should be unique
    enough that the recipient of the mail can associate all the parts
    of a message with each other.  A good checksum or cryptographic
    hash function is sufficent.

    The MessageID should not appear unless it is in a multi-part
    message. If it appears at all, it MUST be computed from the message
    in a deterministic fashion, rather than contain a purely random
    value.  This is to allow anyone to determine that the MessageID
    cannot serve as a covert means of leaking cryptographic key
    information.

The Armor Tail Line is composed in the same manner as the Armor Header
Line, except the string "BEGIN" is replaced by the string "END."

6.3 Encoding Binary in Radix-64

The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters.  Proceeding from left to right, a
24-bit input group is formed by concatenating three 8-bit input groups.
These 24 bits are then treated as four concatenated 6-bit groups, each
of which is translated into a single digit in the Radix-64 alphabet.
When encoding a bit stream with the Radix-64 encoding, the bit stream
must be presumed to be ordered with the most-significant-bit first.
That is, the first bit in the stream will be the high-order bit in the
first 8-bit byte, and the eighth bit will be the low-order bit in the
first 8-bit byte, and so on.




Callas, et. al.                Expires Aug 1998                [Page 33]
Internet Draft              OpenPGP Message Format              Mar 1998


         +--first octet--+-second octet--+--third octet--+
         |7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|7 6 5 4 3 2 1 0|
         +-----------+---+-------+-------+---+-----------+
         |5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|5 4 3 2 1 0|
         +--1.index--+--2.index--+--3.index--+--4.index--+

Each 6-bit group is used as an index into an array of 64 printable
characters from the table below.  The character referenced by the index
is placed in the output string.

     Value Encoding  Value Encoding  Value Encoding  Value Encoding
         0 A            17 R            34 i            51 z
         1 B            18 S            35 j            52 0
         2 C            19 T            36 k            53 1
         3 D            20 U            37 l            54 2
         4 E            21 V            38 m            55 3
         5 F            22 W            39 n            56 4
         6 G            23 X            40 o            57 5
         7 H            24 Y            41 p            58 6
         8 I            25 Z            42 q            59 7
         9 J            26 a            43 r            60 8
        10 K            27 b            44 s            61 9
        11 L            28 c            45 t            62 +
        12 M            29 d            46 u            63 /
        13 N            30 e            47 v
        14 O            31 f            48 w         (pad) =
        15 P            32 g            49 x
        16 Q            33 h            50 y

The encoded output stream must be represented in lines of no more than with other key formats.
With RSA keys, the MPI bit count prefix (i.e., the first two octets) is
not encrypted.  Only the MPI non-prefix data is encrypted.
Furthermore, the CFB state
76 characters each.

Special processing is resynchronized performed if fewer than 24 bits are available at
the beginning of each
new MPI value, so that the CFB block boundary is aligned with the start end of the MPI data.

With non-RSA keys, a simpler method is used.  All secret MPI values data being encoded.  There are
encrypted in CFB mode, including the MPI bitcount prefix. three possibilities:

- The 16-bit checksum that follows the algorithm-specific portion is the
algebraic sum, mod 65536, of the plaintext of all the
algorithm-specific octets (including MPI prefix and data).  With RSA
keys, the checksum is stored in the clear.  With non-RSA keys, the
checksum is encrypted like the algorithm-specific data.  This value last data group has 24 bits (3 octets).  No special processing is
used to check that the passphrase was correct.

5.6 Compressed Data Packet (Tag 8)
needed.

- The Compressed Data packet contains compressed data.  Typically, this
packet is found as the contents of an encrypted packet, or following a
Signature or One-Pass Signature packet, and contains literal last data
packets. group has 16 bits (2 octets).  The body of this packet consists of:
	- One octet that gives the algorithm used first two 6-bit
groups are processed as above.  The third (incomplete) data group has
two zero-value bits added to it, and is processed as above.  A pad
character (=) is added to compress the packet. output.

- The remainder last data group has 8 bits (1 octet).  The first 6-bit group is
processed as above.  The second (incomplete) data group has four
zero-value bits added to it, and is processed as above.  Two pad
characters (=) are added to the output.

6.4 Decoding Radix-64

Any characters outside of the packet is compressed base64 alphabet are ignored in Radix-64
data.

A Compressed Data Packet's body contains an RFC1951 DEFLATE block that  Decoding software must ignore all line breaks or other
characters not found in the table above.


Callas, et. al.                Expires May Aug 1998                [Page 30] 34]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


compresses some set of packets.  See section 7 for details on how
messages are formed.

5.7 Symmetrically Encrypted Data Packet (Tag 9)

The Symmetrically Encrypted Data packet contains data encrypted with a
conventional (symmetric-key) algorithm.  When it has been decrypted, it
will typically contain other packets (often literal data packets or
compressed data packets).

The body of this packet consists of:

	- Encrypted





In Radix-64 data, the output of the selected conventional cipher
          operating in PGP's variant of Cipher Feedback (CFB) mode.

The conventional cipher used may be specified characters other than those in an Encrypted Session
Key or Conventional Encrypted Session Key packet which precedes the
Symmetrically Encrypted Data Packet.  In that case, the cipher
algorithm octet is prepended to the session key before table, line
breaks, and other white space probably indicate a transmission error,
about which a warning message or even a message rejection might be
appropriate under some circumstances.

Because it is encrypted.
If no packets used only for padding at the end of these types precede the encrypted data, the IDEA
algorithm is used with the session key calculated
occurrence of any "=" characters may be taken as evidence that the MD5 hash end
of the passphrase.

The data is encrypted has been reached (without truncation in CFB mode, with a CFB shift size equal to the
cipher's block size [Ref].  The Initial Vector (IV) is specified as all
zeros.  Instead of using an IV, OP prepends a 10 octet string to the
data before it transit).  No such
assurance is encrypted.  The first eight octets are random, and possible, however, when the 9th and 10th octets are copies number of the 7th and 8th octets,
respectivelly. After encrypting the first 10 octets, the CFB state is
resynchronized if the cipher block size is 8 octets or less.  The last
8 octets transmitted
was a multiple of ciphertext are passed through the cipher three and the block
boundary is reset.

The repetition of 16 bits in the 80 bits of random data prepended to
the message allows the receiver to immediately check whether the
session key is correct.

5.8 Marker Packet (Obsolete Literal Packet) (Tag 10)

An experimental version of PGP used this packet as the Literal packet,
but no released version "=" characters are present.


6.5 Examples of PGP generated Literal packets Radix-64

Input data:  0x14fb9c03d97e
Hex:     1   4    f   b    9   c     | 0   3    d   9    7   e
8-bit:   00010100 11111011 10011100  | 00000011 11011001 11111110
6-bit:   000101 001111 101110 011100 | 000000 111101 100111 111110
Decimal: 5      15     46     28       0      61     37     63
Output:  F      P      u      c        A      9      l      /

Input data:  0x14fb9c03d9
Hex:     1   4    f   b    9   c     | 0   3    d   9
8-bit:   00010100 11111011 10011100  | 00000011 11011001
                                                pad with this tag.
With PGP 5.x, this packet has been re-assigned and is reserved for use
as the Marker packet.

The body of this packet consists of:
	- The three octets 0x60, 0x47, 0x60 (which spell "PGP" in UTF-8).

Such a packet should be ignored on input.  It may be placed at the
beginning 00
6-bit:   000101 001111 101110 011100 | 000000 111101 100100
Decimal: 5      15     46     28       0      61     36
                                                   pad with =
Output:  F      P      u      c        A      9      k      =

Input data:  0x14fb9c03
Hex:     1   4    f   b    9   c     | 0   3
8-bit:   00010100 11111011 10011100  | 00000011
                                       pad with 0000
6-bit:   000101 001111 101110 011100 | 000000 110000
Decimal: 5      15     46     28       0      48
                                            pad with =      =
Output:  F      P      u      c        A      w      =      =


6.6 Example of a message that uses features not available in an ASCII Armored Message

  -----BEGIN PGP 2.6.X in
order to cause that version to report that newer software necessary to
process the message.

5.9 Literal Data Packet (Tag 11) MESSAGE-----
  Version: OP V0.0

  owFbx8DAYFTCWlySkpkHZDKEFCXmFedmFhdn5ucpZKdWFiv4hgaHKPj5hygUpSbn
  l6UWpabo8XIBAA==
  =3m1o
  -----END PGP MESSAGE-----



Callas, et. al.                Expires May Aug 1998                [Page 31] 35]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998



A Literal Data packet contains





Note that this example is indented by two spaces.

7.  Cleartext signature framework

It is desirable to sign a textual octet stream without ASCII armoring
the body of stream itself, so the signed text is still readable without special
software.  In order to bind a message; data that signature to such a cleartext, this
framework is not used. (Note that RFC 2015 defines another way to be further interpreted. clear
sign messages for environments that support MIME.)

The body of this packet cleartext signed message consists of:
  - A one-octet field that describes how the data is formatted.
If it is a 'b' (0x62), then the literal packet contains binary data. If
it is The cleartext header '-----BEGIN PGP SIGNED MESSAGE-----' on a 't' (0x74), then it contains text data, and thus may need line
ends converted to local form,
    single line,
  - Zero or other text-mode changes.  RFC 1991
also defined a value of 'l' as a 'local' mode for machine-local
conversions.  This use more "Hash" Armor Headers,
  - Exactly one empty line not included into the message digest,
  - The dash-escaped cleartext that is now deprecated. included into the message digest,
  - File name as a string (one-octet length, followed by file name),
	  if The ASCII armored signature(s) including the encrypted data should be saved as a file. Armor Header and Armor
    Tail Lines.

If the special name "_CONSOLE" "Hash" armor header is used, given, the specified message digest
algorithm is considered to be
"for your eyes only".  This advises that used for the message data signature.  If there are no such headers,
SHA-1 is unusually
sensitive, and the receiving program should process it used.  If more carefully,
perhaps avoiding storing the received data to disk, for example.

	- A four-octet number that indicates the modification date of the
file, or the creation time of than one message digest is used in the packet, or a zero that indicates
signature, the
present time. "Hash" armor header contains a comma-delimited list of
used message digests.

Current message digest names are:

    - "SHA1"
    - "MD5"
    - "RIPEMD160"

The remainder cleartext content of the packet is literal data.

Text data is stored with <CR><LF> text endings.  This should message must also be
converted to native dash-escaped.

Dash escaped cleartext is the ordinary cleartext where every line endings
starting with a dash '-' (0x2D) is prefixed by the receiving software.

5.10 Trust Packet (Tag 12)

The Trust packet is used only within keyrings sequence dash '-'
(0x2D) and space ' ' (0x20).  This prevents the parser from recognizing
armor headers of the cleartext itself.  The message digest is computed
using the cleartext itself, not normally
exported.  Trust packets contain data that record the user's
specifications of which key holders are trustworthy introducers, along dash escaped form.

As with other information that implementing software uses for trust
information.

Trust packets SHOULD NOT be emitted to output streams that are
transferred to other users, and they SHOULD be ignored binary signatures on text documents, a cleartext signature is
calculated on any input
other than local keyring files.

{{Editor's note:  I have brushed aside the description of text using canonical <CR><LF> line endings.  The line
ending (i.e. the old <CR><LF>) before the '-----BEGIN PGP
trust packets for a number of reasons.  They are context dependent;
their meaning depends on SIGNATURE-----'
line that terminates the packet preceding them in a keyring.

There signed text is also a security problem with trust packets.  For example,
malicious software can write a new public key into a user's key ring
with trust packets that make it trusted.

A number not considered part of us have discussed this problem, the
signed text.

Also, any trailing whitespace (spaces, and think that trust
information should always be self-signed to act as an integrity check,
but other people may have other solutions.

My solution tabs, 0x09) at the end of
any line is to make trust packets implementation dependent.  They ignored when the cleartext signature is calculated.





Callas, et. al.                Expires May Aug 1998                [Page 32] 36]
Internet Draft              OpenPGP Message Format              Nov              Mar 1998


are not emitted on export and ignored on import.  Because of this, they
are arguably out of scope of this document anyway.  Given



8.  Regular Expressions

A regular expression is zero or more branches, separated by `|'.  It
matches anything that the PGP
implementation matches one of trust packets has security flaws, this seems to be the best way to deal with them.

--jdcc}}

5.11 User ID Packet (Tag 13) branches.

A User ID packet consists of data which branch is intended to represent zero or more pieces, concatenated.  It matches a match for
the
name and email address of first, followed by a match for the key holder.  By convention, it includes second, etc.

A piece is an RFC822 mail name, but there are no restrictions on its content.  The
packet length in the header specifies the length atom possibly followed by `*', `+', or `?'. An atom
followed by `*' matches a sequence of the user name.  If
it is text, it is encoded in UTF-8.

{{Editor's note:  PRZ thinks there should be 0 or more types of "user ids"
other than the traditional name, such as photos, and so on.  The above
definition, which assiduously avoids saying that the content matches of the
packet is a counted string, is one potential way to handle it.  Another
would be to explicitly state that this packet is a string, and
introduce atom.
An atom followed by `+' matches a free-form user identification packet.

A related issue with this document is that sometimes it says "user id"
and sometimes "user name." We need some work here.  Present plan is to
use "User ID" everywhere. --jdcc}}

{{Editor's note:  Carl Ellison pointed out to me that if we have
non-exportable (local to one's own keyring) usernames that I can assign
to keys I use, then essentially we have SDSI naming in PGP.  This sequence of 1 or more matches of the
atom.  An atom fol- lowed by `?' matches a match of the atom, or the
null string.

An atom is a
Good Thing, regular expression in my opinion, but we have to have parentheses (matching a way to define it.
--jdcc}}

5.12 Comment Packet (Tag 16)

A Comment packet is used match for holding data that is not relevant to
software.  Comment packets should be ignored.

{{Editor's note: should?  Must?  What does it mean to ignore them?  For
example, if it's desirable to show
the regular expression), a comment to range (see below), `.' (matching any single
character), `^' (matching the null string at the beginning of the input
string), `$' (matching the null string at the end of the input string),
a user, then how does `\' followed by a single character (matching that interact with should/must and char- acter), or a suitable definition of "ignore." I
believe
single character with no other significance (matching that they MUST be ignored, but displaying them to character).

A range is a user sequence of characters enclosed in `[]'.  It normally
matches any single character from the sequence. If the sequence begins
with `^', it matches any single character not from the rest of the
sequence.  If two char- acters in the sequence are separated by `-',
this is
ignoring them.  Looking inside them shorthand for cryptographic content (like OP
packets) is *not* ignoring them.}}

{{Editor's note: should we put the full list of ASCII characters between them
(e.g. `[0-9]' matches any decimal digit).  To include a literal `]' in an X.509 encapsulation packet type?}}

6.
the sequence, make it the first character (following a possible `^').
To include a literal `-', make it the first or last character.




9.  Constants

This section describes the constants used in OP.

Note that these tables are not exhaustive lists; an implementation MAY
implement an algorithm not on these lists.



Callas, et. al.                Expires May 1998                [Page 33]
Internet Draft              OpenPGP Message Format              Nov 1998


6.1

9.1 Public Key Algorithms

1          - RSA (Encrypt or Sign)
2          - RSA Encrypt-Only
3          - RSA Sign-Only
16         - Elgamal Elgamal, see [ELGAMAL]
17         - DSA (Digital Signature Standard)
18         - Elliptic Curve
19         - ECDSA
21         - Diffie-Hellman (X9.42)
100 to 110 - Private/Experimental algorithm.



Callas, et. al.                Expires Aug 1998                [Page 37]
Internet Draft              OpenPGP Message Format              Mar 1998





Implementations MUST implement DSA for signatures, and Elgamal for
encryption.  Implementations SHOULD implement RSA encryption.
Implementations MAY implement any other algorithm.

{{Editor's note: reserve an algorithm for elliptic curve?  Note that
I've left Elgamal signatures completely unmentioned.  I think this is
good. --jdcc}}

6.2

9.2 Symmetric Key Algorithms

0          - Plaintext
1          - IDEA
2          - Triple-DES (DES-EDE, as per spec -
             168 bit key derived from 192)
3          - CAST5 (128 bit key)
4          - Blowfish (128 bit key) key, 16 rounds)
5          - ROT-N (128 bit N)
6          - SAFER-SK128
7          - DES/SK
100 to 110 - Private/Experimental algorithm.

Implementations MUST implement Triple-DES. Implementations SHOULD
implement IDEA and CAST5.Implementations MAY implement any other
algorithm.

6.3

9.3 Compression Algorithms

0          - Uncompressed
1          - ZIP
100 to 110 - Private/Experimental algorithm.

Implementations MUST implement uncompressed data. Implementations
SHOULD implement ZIP.

6.4

9.4 Hash Algorithms

1          - MD5
2          - SHA-1
3          - RIPE-MD/160
4          - HAVAL
100 to 110 - Private/Experimental algorithm.

Implementations MUST implement SHA-1. Implementations SHOULD implement
MD5.


Callas, et. al.                Expires May 1998                [Page 34]
Internet Draft              OpenPGP Message Format              Nov 1998



7.


10.  Packet Composition

OP packets may be are assembled into sequences in order to create messages and
to transfer keys.  Not all possible packet sequences are meaningful and
correct.  This describes the rules for how packets should be placed
into sequences.

7.1




Callas, et. al.                Expires Aug 1998                [Page 38]
Internet Draft              OpenPGP Message Format              Mar 1998




10.1 Transferable Public Keys

OP users may transfer public keys.  The essential elements of a
transferable public key are:

    - One Public Key packet
    - Zero or more revocation signatures
    - One or more User ID packets
    - After each User ID packet, zero or more Signature packets
    - Zero or more Subkey packets
    - After each Subkey packet, one or more Signature packets

The Public Key packet occurs first.  Each of the following User ID
packets provides the identity of the owner of this public key.  If
there are multiple User ID packets, this corresponds to multiple means
of identifying the same unique individual user; for example, a user may
enjoy the use of more than one e-mail address, and construct a User ID
packet for each one.

Immediately following each User ID packet, there are zero or more
signature packets.  Each signature packet is calculated on the
immediately preceding User ID packet and the initial Public Key packet.
The signature serves to certify the corresponding public key and user
ID.  In effect, the signer is testifying to his or her belief that this
public key belongs to the user identified by this user ID.

After the User ID packets there may be one or more Subkey packets.
Subkeys In
general, subkeys are used provided in cases where the top-level public key
is a signature-only key.  The  However, any V4 key may have subkeys, and the
subkeys are then may be encryption-only keys that are
bound to the signature key. keys, signature-only keys, or
general-purpose keys.

Each Subkey packet must be followed by at least one Signature packet,
which should be of the subkey binding signature type, and issued by the top
level key.

{{Editor's note:  I think it is a good idea to have signature-only
subkeys, too (or even encrypt-and-sign subkeys), but no implementation
does this.  Should we generalize here? --jdcc}}

Subkey and Key packets may each be followed by a revocation Signature
packet to indicate that the key is revoked.  Revocation signatures are
only accepted if they are issued by the key itself, or by a key which
is authorized to issue revocations via a revocation key subpacket in a
self-signature by the top level key.

Transferable public key packet sequences may be concatenated to allow
transferring multiple public keys in one operation.


Callas, et. al.                Expires May 1998                [Page 35]
Internet Draft              OpenPGP Message Format              Nov 1998



7.2

10.2 OP Messages

An OP message is a packet or sequence of packets that corresponds to
the following grammatical rules (comma represents sequential
composition, and vertical bar separates alternatives):



Callas, et. al.                Expires Aug 1998                [Page 39]
Internet Draft              OpenPGP Message Format              Mar 1998


   OP Message :- Encrypted Message | Signed Message | Compressed Message
                                   | Literal Message.

   Compressed Message :- Compressed Data Packet.

   Literal Message :- Literal Data Packet.

   ESK :- Pubic Key Encrypted Session Key Packet |
          Conventionally Encrypted Session Key Packet.

   ESK Sequence :- ESK | ESK Sequence, ESK.

   Encrypted Message :- Symmetrically Encrypted Data Packet |
               ESK Sequence, Symmetrically Encrypted Data Packet.

   One-Pass Signed Message :- One-Pass Signature Packet, OP Message,
               Signature Packet.

   Signed Message :- Signature Packet, OP Message |
               One-Pass Signed Message.

In addition, the decrypting a Symmetrically Encrypted Data packet and
decompressing a Compressed Data packet must yield a valid OP Message.


8.


11.  Enhanced Key Formats

8.1

11.1 Key Structures

The format of V3 OP key using RSA is as follows.  Entries in square
brackets are optional and ellipses indicate repetition.

    RSA Public Key
       [Revocation Self Signature]
        User ID [Signature ...]
       [User ID [Signature ...] ...]

Each signature certifies the RSA public key and the preceding user ID.
The RSA public key can have many user IDs and each user ID can have
many signatures.

The format of an OP V4 key that uses two public keys is very similar
except that the second key is added to the end as a 'subkey' of the
primary key.

    Primary-Key


Callas, et. al.                Expires May 1998                [Page 36]
Internet Draft              OpenPGP Message Format              Nov 1998
       [Revocation Self Signature]
       [Direct Key Self Signature...]
        User ID [Signature ...]
       [User ID [Signature ...] ...]





Callas, et. al.                Expires Aug 1998                [Page 40]
Internet Draft              OpenPGP Message Format              Mar 1998


[Subkey Primary-Key-Signature]

The subkey always has a single signature after it that is issued using
the primary key to tie the two keys together.  The new format can use
either the new signature packets or the old signature packets.

In an Elgamal/DSA key, the DSA public key is that has a main key and subkeys, the primary key, the
Elgamal public key is the subkey, MUST be a
key capable of signing.  The subkeys may be keys of any other type, and
either version 3 or 4 of the signature packet can be used.  There may
be other types of V4 keys, too. For example, there may be a single-key
RSA key in V4 format, a DSA primary key with an RSA encryption key,
etc, or RSA primary key with an Elgamal subkey.

It is also possible to have a signature-only subkey.  This permits a
primary key that collects certifications (key signatures) but is used
only used for certifying subkeys that are used for encryption and
signatures.


8.2


11.2 V4 Key IDs and Fingerprints

A V4 fingerprint is the 160-bit SHA-1 hash of the one-octet Packet Tag,
followed by the two-octet packet length, followed by the entire Public
Key packet starting with the version field.  The key ID is either the
low order 32 bits or 64 bits of the fingerprint.  Here are the fields
of the hash material, with the example of a DSA key:

    a.1) 0x99 (1 byte)
    a.2) high order length byte of (b)-(f) (1 byte)
    a.3) low order length byte of (b)-(f) (1 byte)
    b) version number = 4 (1 byte);
    c) time stamp of key creation (4 bytes);
    e) algorithm (1 byte):
         17 = DSA;
    f) Algorithm specific fields.

    Algorithm Specific Fields for DSA keys (example):
    f.1) MPI of DSA prime p;
    f.2) MPI of DSA group order q (q is a prime divisor of p-1);
    f.3) MPI of DSA group generator g;
    f.4) MPI of DSA public key value y (= g**x where x is secret).


9.


12.  Security Considerations

As with any technology involving cryptography, you should check the
current literature to determine if any algorithms used here have been
found to be vulnerable to attack.

This specification uses Public Key Cryptography technologies.


Callas, et. al.                Expires May 1998                [Page 37]
Internet Draft              OpenPGP Message Format              Nov 1998
Possession of the private key portion of a public-private key pair is
assumed to be controlled by the proper party or parties.



Callas, et. al.                Expires Aug 1998                [Page 41]
Internet Draft              OpenPGP Message Format              Mar 1998





Certain operations in this specification involve the use of random
numbers.  An appropriate entropy source should be used to generate
these numbers.  See RFC 1750.

The MD5 hash algorithm has been found to have weaknesses
(pseudo-collisions in the compress function) that make some people
deprecate its use.  They consider the SHA-1 algorithm better.

If you are building an authentication system, the recipient may specify
a preferred signing algorithm.  However, the signer would be foolish to
use a weak algorithm simply because the recipient requests it.

Some of the encryption algorithms mentioned in this document have been
analyzed less than others.  For example, although CAST5 is presently
considered strong, it has been analyzed less than Triple-DES.  Other
algorithms may have other controversies surrounding them.

Some technologies mentioned here may be subject to government control
in some countries.

10.

13.  Authors and Working Group Chair

The working group can be contacted via the current chair:

John W. Noerenberg, II
Qualcomm, Inc
6455 Lusk Blvd
San Diego, CA 92131 USA
Email: jwn2@qualcomm.com
Tel: +1 619 658 3510 619-658-3510

The principal authors of this draft are (in alphabetical order):

Jon Callas Pretty Good Privacy,
Network Associates, Inc. 555 Twin Dolphin Drive, #570
Redwood Shores,
4200 Bohannon Drive
Menlo Park, CA 94065, 94025, USA
Email: jon@pgp.com
Tel: +1-650-596-1960 +1-650-473-2860

Lutz Donnerhacke
IKS GmbH
Wildenbruchstr. 15
07745 Jena, Germany
EMail: lutz@iks-jena.de
Tel: +49-3641-675642

Hal Finney Pretty Good Privacy,
Network Associates, Inc. 555 Twin Dolphin Drive, #570
Redwood Shores,
4200 Bohannon Drive


Callas, et. al.                Expires Aug 1998                [Page 42]
Internet Draft              OpenPGP Message Format              Mar 1998


Menlo Park, CA 94065, 94025, USA
Email: hal@pgp.com Tel: +1-650-572-0430

Rodney Thayer
Sable Technology Corporation
246 Walnut Street
Newton, MA  02160 USA
Email: rodney@sabletech.com
Tel: +1-617-332-7292



This draft also draws on much previous work from a number of other
authors who include:  Derek Atkins, Charles Breed, Dave Del Torto, Marc
Dyksterhouse, Gail Haspert, Gene Hoffman, Paul Hoffman, Raph Levine,
Colin Plumb, Will Price, William Stallings, Mark Weaver, and Philip R.
Zimmermann.

11.

14.  References


Callas, et. al.                Expires May 1998                [Page 38]
Internet Draft              OpenPGP Message Format              Nov 1998



[CAMPBELL} Campbell, Joe, "C Programmer's Guide to Serial
Communications"

[DONNERHACKE] Donnerhacke, L., et. al, "PGP263in - an improved
international version of PGP",
ftp://ftp.iks-jena.de/mitarb/lutz/crypt/software/pgp/

[ELGAMAL] T.  ElGamal, "A Public-Key Cryptosystem and a Signature
Scheme Based on Discrete Logarithms," IEEE Transactions on Information
Theory, v.  IT-31, n. 4, 1985, pp. 469-472.

[ISO-10646] ISO/IEC 10646-1:1993.  International Standard --
Information technology -- Universal Multiple-Octet Coded Character Set
(UCS) -- Part 1:  Architecture and Basic Multilingual Plane.  UTF-8 is
described in Annex R, adopted but not yet published.  UTF-16 is
described in Annex Q, adopted but not yet published.

[PKCS1] RSA Laboratories, "PKCS #1:  RSA Encryption Standard," version
1.5, November 1993

[RFC822] D.  Crocker, "Standard for the format of ARPA Internet text
messages", RFC 822, August 1982

[RFC1423] D.  Balenson, "Privacy Enhancement for Internet Electronic
Mail:  Part III:  Algorithms, Modes, and Identifiers", RFC 1423,
October 1993

[RFC1641] Goldsmith, D., and M.  Davis, "Using Unicode with MIME", RFC
1641, Taligent inc., July 1994.

[RFC1750] Eastlake, Crocker, & Schiller., Randomness Recommendations
for Security.  December 1994.






Callas, et. al.                Expires Aug 1998                [Page 43]
Internet Draft              OpenPGP Message Format              Mar 1998


[RFC1951] Deutsch, P., DEFLATE Compressed Data Format Specification
version 1.3.  May 1996.

[RFC1983] G.  Malkin., Internet Users' Glossary.  August 1996.

[RFC1991] Atkins, D., Stallings, W., and P.  Zimmermann, "PGP Message
Exchange Formats", RFC 1991, August 1996.

[RFC2015] Elkins, M., "MIME Security with Pretty Good Privacy (PGP)",
RFC 2015, October 1996.

[RFC2044] F.  Yergeau., UTF-8, a transformation format of Unicode and
ISO 10646.  October 1996.

[RFC2045] Borenstein, N., and Freed, N., "Multipurpose Internet Mail
Extensions (MIME) Part One:  Format of Internet Message Bodies.",
November 1996

[RFC2119] Bradner, S., Key words for use in RFCs to Indicate
Requirement Level.  March 1997.

12.

15.  Full Copyright Statement



Callas, et. al.                Expires May 1998                [Page 39]
Internet Draft              OpenPGP Message Format              Nov 1998

Copyright 1997 1998 by The Internet Society.  All Rights Reserved.

This document and translations of it may be copied and furnished to
others, and derivative works that comment on or otherwise explain it or
assist in its implementation may be prepared, copied, published and
distributed, in whole or in part, without restriction of any kind,
provided that the above copyright notice and this paragraph are
included on all such copies and derivative works.  However, this
document itself may not be modified in any way, such as by removing the
copyright notice or references to the Internet Society or other
Internet organizations, except as needed for the purpose of developing
Internet standards in which case the procedures for copyrights defined
in the Internet Standards process must be followed, or as required to
translate it into languages other than English.

The limited permissions granted above are perpetual and will not be
revoked by the Internet Society or its successors or assigns.















Callas, et. al.                Expires May Aug 1998                [Page 40] 44]



----