Keith
Keith

Reputation: 679

How GPG find the corresponding private key

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 ?

Upvotes: 1

Views: 1480

Answers (2)

Maarten Bodewes
Maarten Bodewes

Reputation: 94108

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.

Upvotes: 3

David Schwartz
David Schwartz

Reputation: 182883

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.

Upvotes: 1

Related Questions