简体   繁体   中英

Can you manually add a comment to a PGP public key block and not break it?

Pretend that the following is a valid PGP PUBLIC KEY BLOCK :

-----BEGIN PGP PUBLIC KEY BLOCK-----

UBStcXNLrrB3CTV429OmCB35xiYZNCckQZ8LQ+RkcIetcWUTY5n4oYn+3WGGTvv6
ALCiRIKQgCjV9wFawAUAIPn4Otq+amdvmQYbCTgvWxxpZLHNu2Ixc2z0XsUnKRF3
7Ar3BK0Y72430x4XNtgxePKSeM6yChXyJ5NMGLf7zYBs3al+dpa8HxiWZwyaslRF
moZ3GljtkcRYiVTvDdROwItP
=G3b9

-----END PGP PUBLIC KEY BLOCK-----

Can I manually add a comment as illustrated below -- say, with vim -- and it still be valid? I know I can rerun the gpg(1) command to do this, but I don't have it handy.

-----BEGIN PGP PUBLIC KEY BLOCK-----

Comment: Hello, World!

UBStcXNLrrB3CTV429OmCB35xiYZNCckQZ8LQ+RkcIetcWUTY5n4oYn+3WGGTvv6
ALCiRIKQgCjV9wFawAUAIPn4Otq+amdvmQYbCTgvWxxpZLHNu2Ixc2z0XsUnKRF3
7Ar3BK0Y72430x4XNtgxePKSeM6yChXyJ5NMGLf7zYBs3al+dpa8HxiWZwyaslRF
moZ3GljtkcRYiVTvDdROwItP
=G3b9

-----END PGP PUBLIC KEY BLOCK-----

Thank you.

Yes that's valid,

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: SKS 1.1.6+
Comment: Hostname: pgp.key-server.io

As above, both comment and version tags are regularly used, including others, as per RFC4880 , allowed Armor Header Keys include:

 - "Version", which states the OpenPGP implementation and version
   used to encode the message.

 - "Comment", a user-defined comment.  OpenPGP defines all text to
   be in UTF-8.  A comment may be any UTF-8 string.  However, the
   whole point of armoring is to provide seven-bit-clean data.
   Consequently, if a comment has characters that are outside the
   US-ASCII range of UTF, they may very well not survive transport.

 - "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 sufficient.

   The MessageID SHOULD NOT appear unless it is in a multi-part
   message.  If it appears at all, it MUST be computed from the
   finished (encrypted, signed, etc.) message in a deterministic
   fashion, rather than contain a purely random value.  This is to
   allow the legitimate recipient to determine that the MessageID
   cannot serve as a covert means of leaking cryptographic key
   information.

 - "Hash", a comma-separated list of hash algorithms used in this
   message.  This is used only in cleartext signed messages.

 - "Charset", a description of the character set that the plaintext
   is in.  Please note that OpenPGP defines text to be in UTF-8.  An
   implementation will get best results by translating into and out
   of UTF-8.  However, there are many instances where this is easier
   said than done.  Also, there are communities of users who have no
   need for UTF-8 because they are all happy with a character set
   like ISO Latin-5 or a Japanese character set.  In such instances,
   an implementation MAY override the UTF-8 default by using this
   header key.  An implementation MAY implement this key and any
   translations it cares to; an implementation MAY ignore it and
   assume all text is UTF-8.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM