Class BcPublicKeyCryptoCallback
BcPublicKeyDataDecryptorFactory performs all packet parsing, length checking and KDF/key-unwrap
work itself and delegates only the private-key operation - an RSA or ElGamal decryption, or an
ECDH / X25519 / X448 agreement - to an instance of this class. A subclass may therefore route that one
operation to a hardware device (a smart card or HSM) without reimplementing any of the session-key
recovery logic. See org.bouncycastle.openpgp.api.operator.bc.BcExternalPublicKeyDataDecryptorFactory
for the externally-backed-key base class built on this seam.
This is the lightweight (.bc) binding: keys are passed as
AsymmetricKeyParameter. It deliberately lives in the .bc subpackage rather than
alongside AbstractPublicKeyDataDecryptorFactory, because the
top-level operator package is JCA-free and lightweight-crypto-free.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract byte[]decryptECDH(ECDHPublicBCPGKey pubKey, byte[] ephemeralKeyBytes, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) Perform an ECDH agreement to calculate a shared secret.abstract byte[]decryptElGamal(int keyAlgorithm, byte[][] secKeyData, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) Perform ElGamal decryption of an encrypted session key.abstract byte[]decryptRSA(int keyAlgorithm, byte[] pEnc, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) Perform RSA decryption of an encrypted session key.abstract byte[]decryptX25519(org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey, byte[] ephemeralKey) Perform an X25519 agreement to calculate a shared secret.abstract byte[]decryptX448(org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey, byte[] ephemeralKey) Perform an X448 agreement to calculate a shared secret.
-
Constructor Details
-
BcPublicKeyCryptoCallback
public BcPublicKeyCryptoCallback()
-
-
Method Details
-
decryptRSA
public abstract byte[] decryptRSA(int keyAlgorithm, byte[] pEnc, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) throws PGPException, org.bouncycastle.crypto.InvalidCipherTextException Perform RSA decryption of an encrypted session key.- Parameters:
keyAlgorithm- public key algorithmpEnc- encrypted session keyprivKey- RSA private key- Returns:
- decrypted session key
- Throws:
PGPException- if the message cannot be decryptedorg.bouncycastle.crypto.InvalidCipherTextException- if the ciphertext is invalid
-
decryptElGamal
public abstract byte[] decryptElGamal(int keyAlgorithm, byte[][] secKeyData, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) throws org.bouncycastle.crypto.InvalidCipherTextException, PGPException Perform ElGamal decryption of an encrypted session key.- Parameters:
keyAlgorithm- public key algorithmsecKeyData- encrypted session key dataprivKey- ElGamal private key- Returns:
- decrypted session key
- Throws:
org.bouncycastle.crypto.InvalidCipherTextException- if the ciphertext is invalidPGPException- if the message cannot be decrypted
-
decryptECDH
public abstract byte[] decryptECDH(ECDHPublicBCPGKey pubKey, byte[] ephemeralKeyBytes, org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey) throws PGPException Perform an ECDH agreement to calculate a shared secret.- Parameters:
pubKey- our ECDH public keyephemeralKeyBytes- encoded ephemeral public keyprivKey- private ECDH key- Returns:
- shared secret
- Throws:
PGPException- if the message cannot be decrypted
-
decryptX25519
public abstract byte[] decryptX25519(org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey, byte[] ephemeralKey) throws PGPException Perform an X25519 agreement to calculate a shared secret.- Parameters:
privKey- private X25519 keyephemeralKey- encoded ephemeral X25519 public key- Returns:
- shared secret
- Throws:
PGPException- if the message cannot be decrypted
-
decryptX448
public abstract byte[] decryptX448(org.bouncycastle.crypto.params.AsymmetricKeyParameter privKey, byte[] ephemeralKey) throws PGPException Perform an X448 agreement to calculate a shared secret.- Parameters:
privKey- private X448 keyephemeralKey- encoded ephemeral X448 public key- Returns:
- shared secret
- Throws:
PGPException- if the message cannot be decrypted
-