summaryrefslogtreecommitdiff
path: root/gnu/javax/crypto/jce
diff options
context:
space:
mode:
Diffstat (limited to 'gnu/javax/crypto/jce')
-rw-r--r--gnu/javax/crypto/jce/cipher/CipherAdapter.java4
-rw-r--r--gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java7
-rw-r--r--gnu/javax/crypto/jce/keyring/GnuKeyring.java105
-rw-r--r--gnu/javax/crypto/jce/mac/OMacImpl.java1
-rw-r--r--gnu/javax/crypto/jce/prng/CSPRNGSpi.java3
-rw-r--r--gnu/javax/crypto/jce/spec/TMMHParameterSpec.java2
13 files changed, 73 insertions, 98 deletions
diff --git a/gnu/javax/crypto/jce/cipher/CipherAdapter.java b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
index 5eaa31b77..f8adedce7 100644
--- a/gnu/javax/crypto/jce/cipher/CipherAdapter.java
+++ b/gnu/javax/crypto/jce/cipher/CipherAdapter.java
@@ -118,9 +118,9 @@ class CipherAdapter extends CipherSpi
/**
* <p>Protected constructor to be called by subclasses. The cipher name
- * argument should be the appropriate one listed in {@link gnu.crypto.Registry}.
+ * argument should be the appropriate one listed in {@link gnu.java.security.Registry}.
* The basic cipher instance is created, along with an instance of the
- * {@link gnu.crypto.mode.ECB} mode and no padding.</p>
+ * {@link gnu.javax.crypto.mode.ECB} mode and no padding.</p>
*
* @param cipherName The cipher to instantiate.
* @param blockLen The block length to use.
diff --git a/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
index f9725eae0..6442cd696 100644
--- a/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/AnubisSecretKeyFactoryImpl.java
@@ -38,13 +38,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class AnubisSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public AnubisSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
index 4b3620bc1..91f97af36 100644
--- a/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/BlowfishSecretKeyFactoryImpl.java
@@ -38,13 +38,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class BlowfishSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public BlowfishSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
index 4bd31711e..048b54474 100644
--- a/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/Cast5SecretKeyFactoryImpl.java
@@ -38,13 +38,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class Cast5SecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public Cast5SecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
index c86e01110..6c7ab42f7 100644
--- a/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/KhazadSecretKeyFactoryImpl.java
@@ -37,13 +37,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class KhazadSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public KhazadSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
index 4aab584a2..d46191644 100644
--- a/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/RijndaelSecretKeyFactoryImpl.java
@@ -37,13 +37,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class RijndaelSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public RijndaelSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
index 6e80671fa..9f06bf329 100644
--- a/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/SerpentSecretKeyFactoryImpl.java
@@ -37,13 +37,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class SerpentSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public SerpentSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
index d1d5d5514..fce7375b3 100644
--- a/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/SquareSecretKeyFactoryImpl.java
@@ -37,13 +37,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class SquareSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public SquareSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java b/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
index e6ca80b63..a182d4116 100644
--- a/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
+++ b/gnu/javax/crypto/jce/key/TwofishSecretKeyFactoryImpl.java
@@ -37,13 +37,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.key;
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-
-import javax.crypto.SecretKey;
-import javax.crypto.SecretKeyFactorySpi;
-import javax.crypto.spec.SecretKeySpec;
-
public class TwofishSecretKeyFactoryImpl extends SecretKeyFactoryImpl
{
public TwofishSecretKeyFactoryImpl()
diff --git a/gnu/javax/crypto/jce/keyring/GnuKeyring.java b/gnu/javax/crypto/jce/keyring/GnuKeyring.java
index d2501f893..5eeb2a306 100644
--- a/gnu/javax/crypto/jce/keyring/GnuKeyring.java
+++ b/gnu/javax/crypto/jce/keyring/GnuKeyring.java
@@ -90,30 +90,44 @@ public class GnuKeyring
public Enumeration engineAliases()
{
+ log.entering(this.getClass().getName(), "engineAliases");
ensureLoaded();
Enumeration result;
if (privateKR == null)
result = Collections.enumeration(Collections.EMPTY_SET);
- else
- {
- Set aliases = new HashSet();
- for (Enumeration e = privateKR.aliases(); e.hasMoreElements();)
- {
- String alias = (String) e.nextElement();
- if (alias != null)
- aliases.add(alias);
- }
-
- for (Enumeration e = publicKR.aliases(); e.hasMoreElements();)
- {
- String alias = (String) e.nextElement();
- if (alias != null)
- aliases.add(alias);
- }
-
- result = Collections.enumeration(aliases);
- }
-
+ else
+ {
+ Set aliases = new HashSet();
+ for (Enumeration e = privateKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ {
+ alias = alias.trim();
+ if (alias.length() > 0)
+ {
+ log.finest("Adding alias (from private keyring): " + alias);
+ aliases.add(alias);
+ }
+ }
+ }
+ for (Enumeration e = publicKR.aliases(); e.hasMoreElements();)
+ {
+ String alias = (String) e.nextElement();
+ if (alias != null)
+ {
+ alias = alias.trim();
+ if (alias.length() > 0)
+ {
+ log.finest("Adding alias (from public keyring): " + alias);
+ aliases.add(alias);
+ }
+ }
+ }
+ log.finest("Will enumerate: " + aliases);
+ result = Collections.enumeration(aliases);
+ }
+ log.exiting(this.getClass().getName(), "engineAliases");
return result;
}
@@ -181,13 +195,23 @@ public class GnuKeyring
}
public void engineSetCertificateEntry(String alias, Certificate cert)
+ throws KeyStoreException
{
log.entering(this.getClass().getName(), "engineSetCertificateEntry",
new Object[] { alias, cert });
-
ensureLoaded();
- publicKR.putCertificate(alias, cert);
+ if (privateKR.containsAlias(alias))
+ throw new KeyStoreException("Alias [" + alias
+ + "] already exists and DOES NOT identify a "
+ + "Trusted Certificate Entry");
+ if (publicKR.containsCertificate(alias))
+ {
+ log.fine("Public keyring already contains Alias [" + alias
+ + "]. Will remove it");
+ publicKR.remove(alias);
+ }
+ publicKR.putCertificate(alias, cert);
log.exiting(this.getClass().getName(), "engineSetCertificateEntry");
}
@@ -218,9 +242,7 @@ public class GnuKeyring
public Key engineGetKey(String alias, char[] password)
throws UnrecoverableKeyException
{
- log.entering(this.getClass().getName(), "engineGetKey",
- String.valueOf(password));
-
+ log.entering(this.getClass().getName(), "engineGetKey", alias);
ensureLoaded();
Key result = null;
if (password == null)
@@ -231,7 +253,8 @@ public class GnuKeyring
else if (privateKR.containsPrivateKey(alias))
result = privateKR.getPrivateKey(alias, password);
- log.exiting(this.getClass().getName(), "engineGetKey", result);
+ log.exiting(this.getClass().getName(), "engineGetKey",
+ result == null ? "null" : result.getClass().getName());
return result;
}
@@ -240,20 +263,28 @@ public class GnuKeyring
throws KeyStoreException
{
log.entering(this.getClass().getName(), "engineSetKeyEntry",
- new Object[] { alias, key, password, chain });
+ new Object[] { alias, key.getClass().getName(), chain });
ensureLoaded();
+ if (publicKR.containsAlias(alias))
+ throw new KeyStoreException("Alias [" + alias
+ + "] already exists and DOES NOT identify a "
+ + "Key Entry");
if (key instanceof PublicKey)
- privateKR.putPublicKey(alias, (PublicKey) key);
+ {
+ privateKR.remove(alias);
+ PublicKey pk = (PublicKey) key;
+ privateKR.putPublicKey(alias, pk);
+ }
else
{
if (! (key instanceof PrivateKey) && ! (key instanceof SecretKey))
throw new KeyStoreException("cannot store keys of type "
+ key.getClass().getName());
+ privateKR.remove(alias);
privateKR.putCertPath(alias, chain);
log.finest("About to put private key in keyring...");
privateKR.putPrivateKey(alias, key, password);
}
-
log.exiting(this.getClass().getName(), "engineSetKeyEntry");
}
@@ -292,7 +323,7 @@ public class GnuKeyring
public void engineLoad(InputStream in, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "engineLoad", String.valueOf(password));
+ log.entering(this.getClass().getName(), "engineLoad");
if (in != null)
{
if (! in.markSupported())
@@ -305,14 +336,12 @@ public class GnuKeyring
createNewKeyrings();
loaded = true;
-
log.exiting(this.getClass().getName(), "engineLoad");
}
public void engineStore(OutputStream out, char[] password) throws IOException
{
- log.entering(this.getClass().getName(), "engineStore", String.valueOf(password));
-
+ log.entering(this.getClass().getName(), "engineStore");
ensureLoaded();
HashMap attr = new HashMap();
attr.put(IKeyring.KEYRING_DATA_OUT, out);
@@ -320,14 +349,18 @@ public class GnuKeyring
privateKR.store(attr);
publicKR.store(attr);
-
log.exiting(this.getClass().getName(), "engineStore");
}
public int engineSize()
{
- ensureLoaded();
- return privateKR.size() + publicKR.size();
+ log.entering(this.getClass().getName(), "engineSize");
+ int result = 0;
+ for (Enumeration e = engineAliases(); e.hasMoreElements(); result++)
+ e.nextElement();
+
+ log.exiting(this.getClass().getName(), "engineSize", Integer.valueOf(result));
+ return result;
}
/**
diff --git a/gnu/javax/crypto/jce/mac/OMacImpl.java b/gnu/javax/crypto/jce/mac/OMacImpl.java
index f91902ae5..bf30d8e13 100644
--- a/gnu/javax/crypto/jce/mac/OMacImpl.java
+++ b/gnu/javax/crypto/jce/mac/OMacImpl.java
@@ -39,7 +39,6 @@ exception statement from your version. */
package gnu.javax.crypto.jce.mac;
import gnu.java.security.Registry;
-import javax.crypto.MacSpi;
public abstract class OMacImpl extends MacAdapter
{
diff --git a/gnu/javax/crypto/jce/prng/CSPRNGSpi.java b/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
index c0aa015b0..acc0c8e84 100644
--- a/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
+++ b/gnu/javax/crypto/jce/prng/CSPRNGSpi.java
@@ -38,10 +38,9 @@ exception statement from your version. */
package gnu.javax.crypto.jce.prng;
-import gnu.java.security.Registry;
-import gnu.javax.crypto.prng.CSPRNG;
import gnu.java.security.prng.IRandom;
import gnu.java.security.prng.LimitReachedException;
+import gnu.javax.crypto.prng.CSPRNG;
import java.net.MalformedURLException;
import java.security.SecureRandomSpi;
diff --git a/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java b/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
index 0ebec0991..a3b5f26e8 100644
--- a/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
+++ b/gnu/javax/crypto/jce/spec/TMMHParameterSpec.java
@@ -45,7 +45,7 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* This class represents the algorithm parameters for the Truncated
* Multi-Modular Hash function for use with JCE-derived instances of
- * {@link gnu.crypto.mac.TMMH16}.
+ * {@link gnu.javax.crypto.mac.TMMH16}.
*
* <p>This class is little more than a container for the key stream, tag
* length, and prefix parameters for the TMMH algorithm.