diff options
author | David Hook <dgh@cryptoworkshop.com> | 2013-11-30 09:19:10 +0400 |
---|---|---|
committer | David Hook <dgh@cryptoworkshop.com> | 2013-11-30 09:19:10 +0400 |
commit | 3ca360709d04133147c7da4e1478c24e59dbd030 (patch) | |
tree | c8be04ac0a8071b08f78e8bdf6f3d053f8b47507 /pkix/src | |
parent | 2d62c610b33e39204eb3542535a7c5cccecf5306 (diff) |
removed unnecessary file
Diffstat (limited to 'pkix/src')
-rw-r--r-- | pkix/src/main/jdk1.1/org/bouncycastle/operator/jcajce/JceAsymmetricKeyWrapper.java | 133 |
1 files changed, 0 insertions, 133 deletions
diff --git a/pkix/src/main/jdk1.1/org/bouncycastle/operator/jcajce/JceAsymmetricKeyWrapper.java b/pkix/src/main/jdk1.1/org/bouncycastle/operator/jcajce/JceAsymmetricKeyWrapper.java deleted file mode 100644 index bc837a55..00000000 --- a/pkix/src/main/jdk1.1/org/bouncycastle/operator/jcajce/JceAsymmetricKeyWrapper.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.bouncycastle.operator.jcajce; - -import java.security.GeneralSecurityException; -import java.security.InvalidKeyException; -import java.security.Provider; -import java.security.ProviderException; -import java.security.PublicKey; -import java.security.SecureRandom; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Map; - -import javax.crypto.Cipher; - -import org.bouncycastle.asn1.ASN1ObjectIdentifier; -import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo; -import org.bouncycastle.jcajce.DefaultJcaJceHelper; -import org.bouncycastle.jcajce.NamedJcaJceHelper; -import org.bouncycastle.jcajce.ProviderJcaJceHelper; -import org.bouncycastle.operator.AsymmetricKeyWrapper; -import org.bouncycastle.operator.GenericKey; -import org.bouncycastle.operator.OperatorException; - -public class JceAsymmetricKeyWrapper - extends AsymmetricKeyWrapper -{ - private OperatorHelper helper = new OperatorHelper(new DefaultJcaJceHelper()); - private Map extraMappings = new HashMap(); - private PublicKey publicKey; - private SecureRandom random; - - public JceAsymmetricKeyWrapper(PublicKey publicKey) - { - super(SubjectPublicKeyInfo.getInstance(publicKey.getEncoded()).getAlgorithm()); - - this.publicKey = publicKey; - } - - public JceAsymmetricKeyWrapper(X509Certificate certificate) - { - this(certificate.getPublicKey()); - } - - public JceAsymmetricKeyWrapper setProvider(Provider provider) - { - this.helper = new OperatorHelper(new ProviderJcaJceHelper(provider)); - - return this; - } - - public JceAsymmetricKeyWrapper setProvider(String providerName) - { - this.helper = new OperatorHelper(new NamedJcaJceHelper(providerName)); - - return this; - } - - public JceAsymmetricKeyWrapper setSecureRandom(SecureRandom random) - { - this.random = random; - - return this; - } - - /** - * Internally algorithm ids are converted into cipher names using a lookup table. For some providers - * the standard lookup table won't work. Use this method to establish a specific mapping from an - * algorithm identifier to a specific algorithm. - * <p> - * For example: - * <pre> - * unwrapper.setAlgorithmMapping(PKCSObjectIdentifiers.rsaEncryption, "RSA"); - * </pre> - * </p> - * @param algorithm OID of algorithm in recipient. - * @param algorithmName JCE algorithm name to use. - * @return the current Wrapper. - */ - public JceAsymmetricKeyWrapper setAlgorithmMapping(ASN1ObjectIdentifier algorithm, String algorithmName) - { - extraMappings.put(algorithm, algorithmName); - - return this; - } - - public byte[] generateWrappedKey(GenericKey encryptionKey) - throws OperatorException - { - Cipher keyEncryptionCipher = helper.createAsymmetricWrapper(getAlgorithmIdentifier().getAlgorithm(), extraMappings); - byte[] encryptedKeyBytes = null; - - try - { - keyEncryptionCipher.init(Cipher.WRAP_MODE, publicKey, random); - encryptedKeyBytes = keyEncryptionCipher.wrap(OperatorUtils.getJceKey(encryptionKey)); - } - catch (InvalidKeyException e) - { - } - catch (GeneralSecurityException e) - { - } - catch (IllegalStateException e) - { - } - catch (UnsupportedOperationException e) - { - } - catch (ProviderException e) - { - } - - // some providers do not support WRAP (this appears to be only for asymmetric algorithms) - if (encryptedKeyBytes == null) - { - try - { - keyEncryptionCipher.init(Cipher.ENCRYPT_MODE, publicKey, random); - encryptedKeyBytes = keyEncryptionCipher.doFinal(OperatorUtils.getJceKey(encryptionKey).getEncoded()); - } - catch (InvalidKeyException e) - { - throw new OperatorException("unable to encrypt contents key", e); - } - catch (GeneralSecurityException e) - { - throw new OperatorException("unable to encrypt contents key", e); - } - } - - return encryptedKeyBytes; - } -} |