1

Here is what i have or as far as i know about GPG 1. when GPG encrypt using a public key , we need to specify a keyid/user_id to identity that key.

  1. but when decrypt, looks like we do not need to specify the keyid/user_id.

So my question is : How GPG identify or find out the corresponding private key of that encryption public key ? Is that information indicated in the encrypted file ?

1
  • Please react on answers and comments Keith. Dec 21, 2012 at 9:44

2 Answers 2

3

By using the key ID, normally a cryptographically secure hash over (part of) the key. Note that for e.g. RSA the modulus already identifies the public and private key, so normally a hash over the modulus suffices for identification. No direct need to store the ID.

1
  • You are right, GnuPG uses (part of) hash over public key part to identify the key. Also, KeyID is stored within encrypted data packet. Dec 18, 2012 at 13:56
1

The encrypted file contains a list of all the keys that can be used to decrypt it. If you have any of those private keys, you can decrypt it.

7
  • One public key could have more than one private key to decrypt it ? and from your context, the private key is actually put in the encrypted file, right ? when decrypt , GPG will search your private keyring to find if any of your private key match that private key in the file ?
    – Keith
    Dec 14, 2012 at 2:40
  • One encrypted file could be decrypted by more than one private key. The private key is not put in the encrypted file, the public key is. If you have the corresponding private key, then you can decrypt the file. Dec 14, 2012 at 3:52
  • The public key id (8 bytes) is put in the file along with public key-encrypted session key. Dec 14, 2012 at 23:23
  • @DavidSchwartz, can you show/guide me how to generate a public key with multiple private key ?I am interested about that .
    – Keith
    Mar 3, 2017 at 23:29
  • @Keith You can't, that's not how it works. For each private key that can decrypt the file, the ID of the corresponding public key and an encrypted session key (encrypted with that public key) is written to the file. Mar 3, 2017 at 23:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.