My client provided PGP public key for data encryption. Can I use any OpenSSL [RSA or AES or any encryption] APIs to encrypt the data with this key?

What are the different types of keys available for asymmetric key encryptions? Is it possible to convert keys from one format to another?

  • Key reuse is not a good idea. – kelalaka Nov 19 at 8:52

My client provided PGP public key for data encryption. Can I use any OpenSSL [RSA or AES or any encryption] APIs to encrypt the data with this key?

That depends. If the key is an RSA key or - to use the more modern method - contains an RSA encryption subkey, then you should be able to do this.

OpenPGP certainly allows hybrid encryption that uses AES.

What are the different types of keys available for asymmetric key encryptions?

You can use either the old ElGamal or you can use RSA with PKCS#1 v1.5 padding. Note that sometimes ElGamal is sometimes (incorrectly) also referred to as DH as it uses the same underlying Discrete Logarithm problem (DLP).

There is also an old proposed internet standard RFC-6637: Elliptic Curve Cryptography (ECC) in OpenPGP that indicates how you can use ECIES to derive session keys rather than to wrap / unwrap them.

Is it possible to convert keys from one format to another?

No. Calculating the public key requires the private key - the public key must be part of a key pair after all. So it is not possible to derive a public key using a public key that uses a different algorithm.

But PGP does allow the holder of the private key to define subkeys. These subkeys could be using any algorithm. Those subkeys need to be signed by the main private key. The sender can then choose any of the valid subkeys to encrypt. Of course this does require you to retrieve an updated "certificate" (PGP container with the public key) containing the public keys.


Beware that OpenPGP may be vulnerable to padding oracle attacks on several levels. You'd better make sure that you do not automate decryption procedures.

If you have the PGP public key then you can encrypt your data, as shown here. Your client can then decrypt the data with his private key.

What are the different types of keys available for asymmetric key encryptions?

Some examples of asymmetric cryptography schemes:

Is it possible to convert keys from one format to another?

If you mean that you can use keys from one scheme for another scheme then the answer is No. You should always create new keys for different schemes.

In addition, keys of different schemes can be very different, because they rely on different principles (multiplication for RSA and exponential calculation for Diffie-Hellman).

  • Is PGP not part of asymmetric cryptography schemes? – Raman Ch Nov 19 at 11:52

To DECRYPT data you need pair of the keys. Your private and provider's public.

Anyway, openssl is not compatible with PGP messages. related link

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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