質問

I am not sure if this is the correct place for this question as this might be more of a theory based question. But I was also interested in the C# implementation of the following. And how feasible it is

I am planning on using PGP for encryption and decryption of files. Is it possible to encrypt the file with two public keys (my public key and the receiver's public key) so that if i will be able to decrypt the file using either one of the private keys. Is this scenario feasible? Is so what is the direction I should take for a correct implementation of the same. Any help would be highly appreciated

役に立ちましたか?

解決

On high level (if you use any PGP API), yes, you can pass two or more public PGP keys to OpenPGP API (or software) and have the data encrypted. Then you would be able to use a PGP secret key that corresponds to any of used public PGP keys to decrypt the data.

On lower level - OpenPGP always generates a symmetric key for encryption of data, and then this key is encrypted using one or more public PGP keys, consequently there's no difference how many keys to use.

Now, what to use depends on what platform and development environment you are using (as this is a programming site we assume that you are going to encrypt data in code). For Linux and C there exists GnuPG library. For Java and C# there's some PGP support in BouncyCastle. Finally, OpenPGPBlackbox of our SecureBlackbox library provides full scope of OpenPGP functionality for a number of platforms and languages, including .NET, VCL, ActiveX and C++.

On a side note, the answer you've accepted is completely wrong so I strongly suggest de-accepting it.

他のヒント

Look at this wiki page:

http://en.wikipedia.org/wiki/Pretty_Good_Privacy

What you will see that actual data is encrypted/decrypt with random key and this random key is encrypted/decrypted with according public/private key.

So, as result you don't have to encrypt a file (data) using two keys. You still encrypt the data with one random key. The only difference is that you encrypt this random key with multiple public keys (as example your's and receiver's).

As result, any of you will be able to decrypt random key using private key and decrypt data.

The question could also belong to crypto.stackexchange.com but it is ok here, too. I am not sure whether you have understood the principles of PGP. A public key is used to encrypt and the private key is used to decrypt. So if you encrypt it by using your public key the receiver uses his/her private key to decrypt and/or sign.

For more information I recommend you should read about the RSA or ElGamal algorithm. Hope it helps you:

Both algorithms provide a good way where you could start. Or you maybe want to join some online courses provided by Stanford University:

The only way I can see it working is to have a zip or tar archive containing two files: one encrypted with key 1, the other with key 2.

If the file is text, you could paste two, differently encrypted versions of the same original file into one document.

There is no way to encrypt a file so it is decryptable with two different keys that I know of.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top