Disclosing a key to a GPG-encrypted file without exposing your private key
I was recently reading Regulation of Investigatory Powers Bill -- Some Scenarios and scenario 2 about session keys perked my interest. I wondered if it could be done with GnuPG, and after researching for a while I discovered it can, and here's how:
As you probably know, in semi-new UK law, RIPA means that the police can demand that you hand over the plaintext of an encrypted file, or in certain circumstances demand that you hand over a key of your choice that decrypts the file.
Since public/private key encryption is several orders of magnitude slower than symmetric encryption, GnuPG generates a random symmetric key and encrypts the plaintext with this. The symmetric key is then encrypted with the public key of the recipient and tacked on the front of the output.
So, if the police want a key to a file, using your private key you can retrieve the symmetric key used for this particular file, and by handing this one-time key over you have satisfied the requirements under RIPA without compromising your main private key and allowing law enforcement to decrypt further messages without your knowledge or sign messages as you.
To get the one-time key, do this on an uncompromised machine:
$ gpg --show-session-key accomplises.ascYou need a passphrase to unlock the secret key for
user: "Martin Smith"
1024-bit ELG-E key, ID 941AAA41, created 2006-10-23 (main key ID 50CB07BC)gpg: encrypted with 1024-bit ELG-E key, ID 941AAA41, created 2006-10-23
"Martin Smith"
gpg: session key: `9:12D785497247CA3C929EC62EAB63BD8A8F0BB29E9B60CF11FC43788B197F6A11'
Now law enforcement can use this key to decrypt accomplises.asc without needing any public or private keys:
$gpg --override-session-key 9:12D785497247CA3C929EC62EAB63BD8A8F0BB29E9B60CF11FC43788B197F6A11 accomplises.asc
gpg: encrypted with 1024-bit ELG-E key, ID 941AAA41, created 2006-10-23
"Martin Smith"




comments