singpolyma / openpgp-php

OpenPGP.php is a pure-PHP implementation of the OpenPGP Message Format (RFC 4880).
http://singpolyma.github.io/openpgp-php/
The Unlicense
179 stars 69 forks source link

Add a keygen example with multiple UIDs and a separate encryption subkey #94

Closed jstanden closed 3 years ago

jstanden commented 4 years ago

This commit adds a new example to demonstrate how to generate a keypair with the recommended structure. The root secret key is signing only. It is used to sign multiple UIDs and an encryption-only subkey.

The current examples generate a root signing key without the encryption bit and without a subkey. There was a discussion in #40 about adding the encryption bit to the root key by passing in a signature packet. However, this is not the recommended structure.

This example could be used to generate a master signing key which is kept offline, with separate subkeys for signing and encryption (e.g. laptop keypair for daily use).

This may also potentially be important from a legal standpoint, since in some jurisdictions a person can be legally ordered to divulge their encryption key, but not the signing key that proves their identity (e.g. United Kingdom).

Subkeys also simplify key rotation and expiration.