Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/quite/humla-spongycastle.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/pg
diff options
context:
space:
mode:
authorDavid Hook <dgh@cryptoworkshop.com>2013-11-30 09:54:30 +0400
committerDavid Hook <dgh@cryptoworkshop.com>2013-11-30 09:54:30 +0400
commit90197854640cd4b47b254b2ef0e66a7c6f167aca (patch)
tree76bb46c28edb1997850f70ce362d805b9a25ac1e /pg
parent3ca360709d04133147c7da4e1478c24e59dbd030 (diff)
compatibility updates
Diffstat (limited to 'pg')
-rw-r--r--pg/src/main/jdk1.1/org/bouncycastle/openpgp/operator/jcajce/OperatorHelper.java73
1 files changed, 43 insertions, 30 deletions
diff --git a/pg/src/main/jdk1.1/org/bouncycastle/openpgp/operator/jcajce/OperatorHelper.java b/pg/src/main/jdk1.1/org/bouncycastle/openpgp/operator/jcajce/OperatorHelper.java
index 732518ac..6d966d72 100644
--- a/pg/src/main/jdk1.1/org/bouncycastle/openpgp/operator/jcajce/OperatorHelper.java
+++ b/pg/src/main/jdk1.1/org/bouncycastle/openpgp/operator/jcajce/OperatorHelper.java
@@ -2,10 +2,10 @@ package org.bouncycastle.openpgp.operator.jcajce;
import java.io.InputStream;
import java.security.GeneralSecurityException;
-import java.security.KeyFactory;
-import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.NoSuchProviderException;
+import java.security.KeyFactory;
+import java.security.MessageDigest;
import java.security.Signature;
import javax.crypto.Cipher;
@@ -15,6 +15,7 @@ import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import org.bouncycastle.bcpg.PublicKeyAlgorithmTags;
+import org.bouncycastle.bcpg.SymmetricKeyAlgorithmTags;
import org.bouncycastle.jcajce.JcaJceHelper;
import org.bouncycastle.openpgp.PGPException;
import org.bouncycastle.openpgp.PGPPublicKey;
@@ -33,22 +34,22 @@ class OperatorHelper
MessageDigest createDigest(int algorithm)
throws GeneralSecurityException, PGPException
{
- try
- {
MessageDigest dig;
- dig = helper.createDigest(PGPUtil.getDigestName(algorithm));
-
- return dig;
- }
- catch (NoSuchProviderException e)
+ try
{
- throw new GeneralSecurityException(e.toString());
+ dig = helper.createDigest(PGPUtil.getDigestName(algorithm));
}
catch (NoSuchAlgorithmException e)
{
- throw new GeneralSecurityException(e.toString());
+ throw new PGPException("cannot find provider: " + e.getMessage(), e);
+ }
+ catch (NoSuchProviderException e)
+ {
+ throw new PGPException("cannot find provider: " + e.getMessage(), e);
}
+
+ return dig;
}
KeyFactory createKeyFactory(String algorithm)
@@ -56,15 +57,15 @@ class OperatorHelper
{
try
{
- return helper.createKeyFactory(algorithm);
+ return helper.createKeyFactory(algorithm);
}
- catch (NoSuchProviderException e)
+ catch (NoSuchAlgorithmException e)
{
- throw new GeneralSecurityException(e.toString());
+ throw new PGPException("cannot find provider: " + e.getMessage(), e);
}
- catch (NoSuchAlgorithmException e)
+ catch (NoSuchProviderException e)
{
- throw new GeneralSecurityException(e.toString());
+ throw new PGPException("cannot find provider: " + e.getMessage(), e);
}
}
@@ -129,15 +130,7 @@ class OperatorHelper
{
return helper.createCipher(cipherName);
}
- catch (NoSuchProviderException e)
- {
- throw new PGPException("cannot create cipher: " + e.getMessage(), e);
- }
- catch (NoSuchAlgorithmException e)
- {
- throw new PGPException("cannot create cipher: " + e.getMessage(), e);
- }
- catch (GeneralSecurityException e)
+ catch (Exception e)
{
throw new PGPException("cannot create cipher: " + e.getMessage(), e);
}
@@ -163,20 +156,37 @@ class OperatorHelper
}
}
- private Signature createSignature(String cipherName)
+ Cipher createKeyWrapper(int encAlgorithm)
throws PGPException
{
try
{
- return helper.createSignature(cipherName);
+ switch (encAlgorithm)
+ {
+ case SymmetricKeyAlgorithmTags.AES_128:
+ case SymmetricKeyAlgorithmTags.AES_192:
+ case SymmetricKeyAlgorithmTags.AES_256:
+ return helper.createCipher("AESWrap");
+ default:
+ throw new PGPException("unknown wrap algorithm: " + encAlgorithm);
+ }
}
- catch (NoSuchProviderException e)
+ catch (Exception e)
{
throw new PGPException("cannot create cipher: " + e.getMessage(), e);
}
- catch (NoSuchAlgorithmException e)
+ }
+
+ private Signature createSignature(String cipherName)
+ throws PGPException
+ {
+ try
{
- throw new PGPException("cannot create cipher: " + e.getMessage(), e);
+ return helper.createSignature(cipherName);
+ }
+ catch (Exception e)
+ {
+ throw new PGPException("cannot create signature: " + e.getMessage(), e);
}
}
@@ -198,6 +208,9 @@ class OperatorHelper
case PublicKeyAlgorithmTags.ELGAMAL_GENERAL:
encAlg = "ElGamal";
break;
+ case PublicKeyAlgorithmTags.ECDSA:
+ encAlg = "ECDSA";
+ break;
default:
throw new PGPException("unknown algorithm tag in signature:" + keyAlgorithm);
}