Setup:
- Linux with GnuPG or Windows with GPG4Win(OpenPGP)
- A 2048 RSA keypair has been created by a privileged user who can access the key ring
- A second lower privilege user has been created for a java application to run under
- Permission has been granted for this user to run GPG commands but cannot access physical key ring files
- The key IDs are known to the java application and so is the passphrase to extract private key
- Java application has imported Bouncycastle library
- The java program needs to perform an encryption and decryption using the key pair
Problem:
I have successfully performed encryption and decryption using Bouncycastle. But it involved trying to read the public and private keys from the pubring and secring files. For security, I would rather not have the java application have direct access to the key ring files.
What are my options. Are there any options in Bouncycastle to do this without reading the key rings or exporting the keys to separate files?
Note: Using Bouncy castle is not necessary.