TL;DR
Yes, an OpenPGP master key can decrypt something encrypted to one of its subkeys. This is a core feature of how OpenPGP works – the master key holds the trust and can sign/decrypt on behalf of all its subkeys.
Understanding Master & Subkeys
Before we dive into decryption, let’s quickly recap:
- Master Key: Your primary, long-term key. It should be kept offline for maximum security.
- Subkey: Derived from your master key. Used for daily operations like signing emails or encrypting files. If a subkey is compromised, it can be revoked without affecting the master key.
Think of the master key as the original stamp and the subkeys as copies made from that stamp.
Decrypting with Master vs Subkey
- Encryption Process: When you encrypt a message for a specific OpenPGP key, you’re actually using the public part of that key. The encryption process creates ciphertext that can only be decrypted by the corresponding private key.
- Subkey Encryption: If you encrypt something to a subkey’s public key, it will only decrypt with the private key associated with that subkey… or its master key!
- Master Key Decryption: OpenPGP is designed so that your master key can act as a parent for all of its subkeys. This means if you have access to your master key’s private key, it will be able to decrypt data encrypted to any of its subkeys.
Practical Steps
Let’s assume you’ve already generated a master key and at least one subkey using GnuPG (GPG). These steps show how to decrypt something encrypted for a subkey using the master key.
1. Verify Your Keyring
First, list your keys to confirm you have both the master and subkeys:
gpg --list-secret-keys --keyid-format long
This will output a list of your private keys. Look for your master key (usually with a longer creation date) and its associated subkey(s).
2. Decrypt the File
Assuming you have a file named encrypted_file.gpg encrypted to one of your subkeys, use the following command:
gpg -d encrypted_file.gpg > decrypted_file.txt
GPG will automatically attempt to decrypt the file using any private keys in your keyring that match the encryption key ID. If you have both the master and subkey, it should prompt you for the passphrase associated with either key.
3. Passphrase Entry
Enter the passphrase for either your master key or the specific subkey used to encrypt the file. GPG will then decrypt the data.
Troubleshooting
- “No secret key” error: This means GPG can’t find a matching private key in your keyring. Double-check that you have imported both the master and subkey, and that they are listed with
gpg --list-secret-keys. - Incorrect Passphrase: Ensure you’re using the correct passphrase for the key you’re trying to use.
- Key Not Fully Trusted: If your key isn’t fully trusted, GPG might warn you about the authenticity of the decryption. You can adjust trust levels with
gpg --edit-trust(advanced).