aboutsummaryrefslogtreecommitdiffstats
path: root/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java
diff options
context:
space:
mode:
Diffstat (limited to 'libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java')
-rw-r--r--libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java68
1 files changed, 0 insertions, 68 deletions
diff --git a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java b/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java
deleted file mode 100644
index 224c3733f..000000000
--- a/libraries/spongycastle/pg/src/main/java/org/spongycastle/openpgp/operator/bc/BcPublicKeyKeyEncryptionMethodGenerator.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.spongycastle.openpgp.operator.bc;
-
-import java.security.SecureRandom;
-
-import org.spongycastle.crypto.AsymmetricBlockCipher;
-import org.spongycastle.crypto.InvalidCipherTextException;
-import org.spongycastle.crypto.params.AsymmetricKeyParameter;
-import org.spongycastle.crypto.params.ParametersWithRandom;
-import org.spongycastle.openpgp.PGPException;
-import org.spongycastle.openpgp.PGPPublicKey;
-import org.spongycastle.openpgp.operator.PublicKeyKeyEncryptionMethodGenerator;
-
-/**
- * A method generator for supporting public key based encryption operations.
- */
-public class BcPublicKeyKeyEncryptionMethodGenerator
- extends PublicKeyKeyEncryptionMethodGenerator
-{
- private SecureRandom random;
- private BcPGPKeyConverter keyConverter = new BcPGPKeyConverter();
-
- /**
- * Create a public key encryption method generator with the method to be based on the passed in key.
- *
- * @param key the public key to use for encryption.
- */
- public BcPublicKeyKeyEncryptionMethodGenerator(PGPPublicKey key)
- {
- super(key);
- }
-
- /**
- * Provide a user defined source of randomness.
- *
- * @param random the secure random to be used.
- * @return the current generator.
- */
- public BcPublicKeyKeyEncryptionMethodGenerator setSecureRandom(SecureRandom random)
- {
- this.random = random;
-
- return this;
- }
-
- protected byte[] encryptSessionInfo(PGPPublicKey pubKey, byte[] sessionInfo)
- throws PGPException
- {
- try
- {
- AsymmetricBlockCipher c = BcImplProvider.createPublicKeyCipher(pubKey.getAlgorithm());
-
- AsymmetricKeyParameter key = keyConverter.getPublicKey(pubKey);
-
- if (random == null)
- {
- random = new SecureRandom();
- }
-
- c.init(true, new ParametersWithRandom(key, random));
-
- return c.processBlock(sessionInfo, 0, sessionInfo.length);
- }
- catch (InvalidCipherTextException e)
- {
- throw new PGPException("exception encrypting session info: " + e.getMessage(), e);
- }
- }
-}