Understanding PGP Key Architecture
When you first created your PGP key pair, you may have noticed that the process actually generated multiple keys. This isn't a coincidence—modern PGP implementations use a sophisticated key architecture with multiple components serving different functions.
The default key structure includes:
Master Key (Primary Key)
The master key is the root of your PGP identity. Its fingerprint is what uniquely identifies you in the PGP ecosystem.
Capabilities
Treatment
Subkeys
Subkeys are additional keys that are cryptographically bound to your master key but serve specific functions. They can be independently revoked without affecting your master key.
Encryption Subkey
Signing Subkey
Authentication Subkey
The Benefits of Subkeys
The subkey architecture provides several important security and practical benefits:
Security Compartmentalization
Practical Advantages
Security Alert
The master/subkey architecture is a powerful implementation of defense-in-depth. Even if an attacker compromises your daily-use subkeys, your cryptographic identity remains intact as long as your master key is secure.
This is why high-security PGP setups often keep the master key completely offline on airgapped systems.
Reviewing Your Key Structure
Before making any changes, let's examine your current key structure to understand what you're working with.
In Secure Mail Client
To view your key details in Secure Mail Client:
- Navigate to Settings → Keys
- Select your key from the list
- Click "View Details" or a similar option
- Look for a section showing "Master Key" and "Subkeys"
Using the Command Line
For more detailed information, you can use the command line with GPG:
gpg --list-secret-keys --keyid-format LONG
This command will show output similar to:
sec rsa4096/0x3AA5C34371567BD2 2025-04-08 [SC] [expires: 2027-04-08] Key fingerprint = 867F BB5C 9407 9D74 EB8C 5358 3AA5 C343 7156 7BD2 uid [ultimate] Your Name <[email protected]> ssb rsa4096/0x4BB6D45482678BE3 2025-04-08 [E] [expires: 2026-04-08]
In this example:
sec
refers to the master (secret) key with ID3AA5C34371567BD2
and capabilities[SC]
(Sign and Certify)ssb
refers to a subkey with ID4BB6D45482678BE3
and capability[E]
(Encryption)
For even more detailed information, examine a specific key:
gpg --edit-key [email protected]
At the GPG prompt, type:
gpg> list
This will show all keys with their capabilities, creation dates, expiration dates, and more.
Type quit
to exit without making changes.
The Optimal Key Structure
For most users, the recommended PGP key structure consists of:
Recommended Configuration
- Master Key:
- 4096-bit RSA key
- Capabilities: Certify only (C)
- 2-3 year expiration period
- Stored securely offline
- Encryption Subkey:
- 4096-bit RSA key
- Capability: Encrypt only (E)
- 1-2 year expiration period
- Used for daily encrypted communications
- Signing Subkey:
- 4096-bit RSA key
- Capability: Sign only (S)
- 1-2 year expiration period
- Used for signing messages and files
- Authentication Subkey (optional):
- 4096-bit RSA key
- Capability: Authenticate only (A)
- 1 year expiration period
- Used for SSH authentication and system logins
This structure achieves the ideal balance between security, usability, and key management.
Creating the Optimal Key Structure
If your key doesn't already have this structure, you can modify it to align with these best practices. There are two main approaches:
Approach 1: Modify Your Existing Key
If you already have a PGP key and want to adapt it to the recommended structure:
Warning
Before making changes to your key structure, create a secure backup of your entire keyring. This ensures you can recover if something goes wrong during the process.
Step 1: Back up your keys
# Export your secret keys
gpg --export-secret-keys --armor [email protected] > master_and_subkeys_backup.asc
# Export your public key
gpg --export --armor [email protected] > public_key_backup.asc
Step 2: Restrict your master key to Certify only
If your master key has signing capability, you should remove it to follow best practices:
gpg --edit-key [email protected]
At the GPG prompt:
Step 3: Add a dedicated signing subkey (if needed)
gpg --edit-key [email protected]
At the GPG prompt:
Step 4: Add an authentication subkey (optional)
gpg --expert --edit-key [email protected]
At the GPG prompt:
Approach 2: Create a New Key with the Optimal Structure
If you prefer to start fresh with an optimal key structure, you can create a new key with the correct configuration from the beginning:
gpg --expert --full-generate-key
Follow these steps during the interactive process:
- Select option (8) RSA (set your own capabilities)
- Toggle capabilities until only Certify remains
- Set keysize to 4096 bits
- Set expiration to 2-3 years
- Enter your user information (name, email, comment)
- Create a strong passphrase
Once your master key is created, follow the steps above to add encryption, signing, and authentication subkeys.
If you create a new key and want to transition from your old key, you should:
- Sign your new key with your old key to establish trust
- Publish your new key to key servers
- Notify your contacts of your key transition
- Consider creating a transition statement signed by both keys
Note
If you're creating a new key as a replacement for an existing one, it's generally best to keep your old key active during a transition period so you can still decrypt messages sent to it.
Securing Your Master Key
The most important outcome of the master/subkey architecture is that you can keep your master key offline and secure while using only your subkeys for daily operations.
Secure Storage Options
Consider these options for secure master key storage:
Encrypted USB Drive
- Create an encrypted volume on a USB drive
- Store your master key (exported from your keyring)
- Keep the drive in a physically secure location
- Consider using VeraCrypt or similar for encryption
Air-gapped Computer
- Use a dedicated computer never connected to the internet
- Boot from a secure OS like Tails for key operations
- Transfer operations via USB drives
- Highest security but more complex workflow
Paper Backup
- Use paperkey to create a minimal backup
- Store in a secure physical location
- Waterproof and fireproof container
- Emergency recovery option
Exporting Your Master Key
To move your master key offline, you need to:
- Export your entire keyring
gpg --export-secret-keys --armor [email protected] > master_key_backup.asc
- Move this file to your secure storage medium
- Create a revocation certificate
gpg --gen-revoke --armor [email protected] > revocation_certificate.asc
Store this separately from your master key for emergency use if your key is compromised.
- Remove the master key from your daily-use keyring
gpg --export-secret-subkeys [email protected] > subkeys_only.gpg gpg --delete-secret-keys [email protected] gpg --import subkeys_only.gpg
This sequence exports just your subkeys, deletes your entire secret keyring, then imports only the subkeys.
- Verify that only subkeys remain
gpg --list-secret-keys [email protected]
You should see a "#" after "sec" indicating the master key is not available.
Security Alert
Once you've removed your master key from your daily-use keyring, you'll need to temporarily import it from your secure storage whenever you need to:
- Sign someone else's key
- Add a new subkey
- Extend the expiration date of existing keys
- Add or remove user IDs (email addresses)
For all other operations (encrypting, decrypting, signing messages), your subkeys will be sufficient.
Subkey Rotation Practices
A key advantage of the subkey architecture is the ability to rotate keys periodically for enhanced security. Here's a recommended process:
Extending Key Expirations
Before subkeys expire, you should extend their expiration dates:
- Import your master key from your secure storage
- Edit your key
gpg --edit-key [email protected]
- Select the key to modify gpg> key 1 # Select first subkey
- Set a new expiration gpg> expire Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 1y
- Repeat for all subkeys using
key 1
,key 2
, etc. - Save your changes gpg> save
- Remove the master key from your daily-use keyring again
- Publish your updated key to key servers
Creating New Subkeys
For maximum security, you may want to periodically create entirely new subkeys:
- Import your master key from your secure storage
- Revoke the old subkey (optional, but recommended for clarity)
gpg --edit-key [email protected]
gpg> key 1 gpg> revkey - Add new subkeys following the procedures described earlier
- Export your updated public key and publish it
- Secure your keyring by removing the master key again
Tip
When creating a new encryption subkey, you should keep the old one active for a transition period. This ensures you can still decrypt messages that were encrypted to your old subkey.
For signing and authentication subkeys, transition is simpler as there are no legacy encrypted messages to worry about.
Conclusion
The master/subkey architecture is one of the most powerful features of modern PGP implementations, allowing you to maintain a secure, long-term cryptographic identity while minimizing day-to-day exposure of your critical key material.
By implementing the practices outlined in this module, you've significantly enhanced the security of your PGP setup and reduced the risk of catastrophic key compromise.
In the next module, we'll explore how to further enhance your security by moving your subkeys to a hardware security device like a YubiKey, creating a nearly impenetrable encryption system.
Key Takeaways
- Master keys establish your cryptographic identity and should be kept secure and offline
- Subkeys handle daily operations (encryption, signing, authentication) and can be securely stored on your computer or hardware devices
- The optimal key structure includes a certification-only master key with purpose-specific subkeys
- Regular subkey rotation enhances security while maintaining your continuous identity
- Proper backup and storage of all key material is essential for both security and availability