Imported GNU Classpath 0.92

2006-08-14  Mark Wielaard  <mark@klomp.org>

       Imported GNU Classpath 0.92
       * HACKING: Add more importing hints. Update automake version
       requirement.

       * configure.ac (gconf-peer): New enable AC argument.
       Add --disable-gconf-peer and --enable-default-preferences-peer
       to classpath configure when gconf is disabled.
       * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and
       gnu/java/awt/dnd/peer/gtk to bc. Classify
       gnu/java/security/Configuration.java as generated source file.

       * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java,
       gnu/java/lang/management/VMClassLoadingMXBeanImpl.java,
       gnu/java/lang/management/VMRuntimeMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java,
       gnu/java/lang/management/VMThreadMXBeanImpl.java,
       gnu/java/lang/management/VMMemoryMXBeanImpl.java,
       gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub
       classes.
       * java/lang/management/VMManagementFactory.java: Likewise.
       * java/net/VMURLConnection.java: Likewise.
       * gnu/java/nio/VMChannel.java: Likewise.

       * java/lang/Thread.java (getState): Add stub implementation.
       * java/lang/Class.java (isEnum): Likewise.
       * java/lang/Class.h (isEnum): Likewise.

       * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed.

       * javax/naming/spi/NamingManager.java: New override for StackWalker
       functionality.

       * configure, sources.am, Makefile.in, gcj/Makefile.in,
       include/Makefile.in, testsuite/Makefile.in: Regenerated.

From-SVN: r116139
This commit is contained in:
Mark Wielaard 2006-08-14 23:12:35 +00:00
parent abab460491
commit ac1ed908de
1294 changed files with 99479 additions and 35933 deletions

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* The implementation of the <code>HAVAL</code> <i>Service Provider Interface</i>
* (<b>SPI</b>) Adapter.<p>
* The implementation of the HAVAL <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
public class HavalSpi extends MessageDigestAdapter
public class HavalSpi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public HavalSpi()
{
super(Registry.HAVAL_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the MD2 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the MD2 <i>Service Provider Interface</i> (<b>SPI</b>)
* adapter.
*/
public class MD2Spi extends MessageDigestAdapter
public class MD2Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
/** Trivial 0-arguments constructor. */
public MD2Spi()
{
super(Registry.MD2_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the MD4 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the MD4 <i>Service Provider Interface</i> (<b>SPI</b>)
* adapter.
*/
public class MD4Spi extends MessageDigestAdapter
public class MD4Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
/** Trivial 0-arguments constructor. */
public MD4Spi()
{
super(Registry.MD4_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD5 <i>Service Provider Interface</i> (<b>SPI</b>)
* adapter.<p>
* adapter.
*/
public class MD5Spi extends MessageDigestAdapter
public class MD5Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public MD5Spi()
{
super(Registry.MD5_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -46,35 +46,30 @@ import java.security.MessageDigestSpi;
/**
* The implementation of a generic {@link java.security.MessageDigest} adapter
* class to wrap gnu.crypto hash instances.<p>
*
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
* {@link java.security.MessageDigest} class, which provides the functionality
* of a message digest algorithm, such as MD5 or SHA. Message digests are secure
* one-way hash functions that take arbitrary-sized data and output a fixed-
* length hash value.<p>
*
* All the abstract methods in the {@link java.security.MessageDigestSpi} class
* are implemented by this class and all its sub-classes.<p>
*
* class to wrap GNU hash instances.
* <p>
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link java.security.MessageDigest} class, which provides the
* functionality of a message digest algorithm, such as MD5 or SHA. Message
* digests are secure one-way hash functions that take arbitrary-sized data and
* output a fixed-length hash value.
* <p>
* All the abstract methods in the {@link MessageDigestSpi} class are
* implemented by this class and all its sub-classes.
* <p>
* All the implementations which subclass this object, and which are serviced by
* the GNU Crypto provider implement the {@link java.lang.Cloneable} interface.<p>
* the GNU provider implement the {@link Cloneable} interface.
*/
class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
class MessageDigestAdapter
extends MessageDigestSpi
implements Cloneable
{
// Constants and variables
// -------------------------------------------------------------------------
/** Our underlying hash instance. */
private IMessageDigest adaptee;
// Constructor(s)
// -------------------------------------------------------------------------
/**
* Trivial protected constructor.
*
*
* @param mdName the canonical name of the hash algorithm.
*/
protected MessageDigestAdapter(String mdName)
@ -84,7 +79,7 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
/**
* Private constructor for cloning purposes.
*
*
* @param adaptee a clone of the underlying hash algorithm instance.
*/
private MessageDigestAdapter(IMessageDigest adaptee)
@ -94,12 +89,6 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
this.adaptee = adaptee;
}
// Class methods
// -------------------------------------------------------------------------
// java.security.MessageDigestSpi interface implementation
// -------------------------------------------------------------------------
public Object clone()
{
return new MessageDigestAdapter((IMessageDigest) adaptee.clone());
@ -130,9 +119,8 @@ class MessageDigestAdapter extends MessageDigestSpi implements Cloneable
{
int result = adaptee.hashSize();
if (len < result)
{
throw new DigestException();
}
throw new DigestException();
byte[] md = adaptee.digest();
System.arraycopy(md, 0, buf, offset, result);
return result;

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD-128 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.<p>
* (<b>SPI</b>) adapter.
*/
public class RipeMD128Spi extends MessageDigestAdapter
public class RipeMD128Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RipeMD128Spi()
{
super(Registry.RIPEMD128_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD-160 <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.<p>
* (<b>SPI</b>) adapter.
*/
public class RipeMD160Spi extends MessageDigestAdapter
public class RipeMD160Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RipeMD160Spi()
{
super(Registry.RIPEMD160_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the SHA-1 (160-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.<p>
* (<b>SPI</b>) adapter.
*/
public class Sha160Spi extends MessageDigestAdapter
public class Sha160Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha160Spi()
{
super(Registry.SHA160_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-2-1 (256-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-2-1 (256-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
public class Sha256Spi extends MessageDigestAdapter
public class Sha256Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha256Spi()
{
super(Registry.SHA256_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-2-2 (384-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-2-2 (384-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
public class Sha384Spi extends MessageDigestAdapter
public class Sha384Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha384Spi()
{
super(Registry.SHA384_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-2-3 (512-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-2-3 (512-bit) <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
public class Sha512Spi extends MessageDigestAdapter
public class Sha512Spi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha512Spi()
{
super(Registry.SHA512_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,27 +41,15 @@ package gnu.java.security.jce.hash;
import gnu.java.security.Registry;
/**
* <p>The implementation of the Tiger <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.</p>
* The implementation of the Tiger <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.
*/
public class TigerSpi extends MessageDigestAdapter
public class TigerSpi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
/** Trivial 0-arguments constructor. */
public TigerSpi()
{
super(Registry.TIGER_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Whirlpool <i>Service Provider Interface</i>
* (<b>SPI</b>) adapter.<p>
* (<b>SPI</b>) adapter.
*/
public class WhirlpoolSpi extends MessageDigestAdapter
public class WhirlpoolSpi
extends MessageDigestAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public WhirlpoolSpi()
{
super(Registry.WHIRLPOOL_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the HAVAL-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) Adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class HavalRandomSpi extends SecureRandomAdapter
public class HavalRandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public HavalRandomSpi()
{
super(Registry.HAVAL_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD2-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class MD2RandomSpi extends SecureRandomAdapter
public class MD2RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public MD2RandomSpi()
{
super(Registry.MD2_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD4-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class MD4RandomSpi extends SecureRandomAdapter
public class MD4RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public MD4RandomSpi()
{
super(Registry.MD4_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the MD5-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class MD5RandomSpi extends SecureRandomAdapter
public class MD5RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public MD5RandomSpi()
{
super(Registry.MD5_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
* <p>The implementation of the RIPEMD128-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* The implementation of the RIPEMD128-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.
*/
public class RipeMD128RandomSpi extends SecureRandomAdapter
public class RipeMD128RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RipeMD128RandomSpi()
{
super(Registry.RIPEMD128_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the RIPEMD160-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class RipeMD160RandomSpi extends SecureRandomAdapter
public class RipeMD160RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RipeMD160RandomSpi()
{
super(Registry.RIPEMD160_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -45,34 +45,28 @@ import java.security.SecureRandomSpi;
import java.util.Collections;
/**
* <p>The implementation of a generic {@link java.security.SecureRandom} adapter
* class to wrap gnu.crypto prng instances based on Message Digest algorithms.</p>
*
* <p>This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* The implementation of a generic {@link java.security.SecureRandom} adapter
* class to wrap GNU PRNG instances based on Message Digest algorithms.
* <p>
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link java.security.SecureRandom} class, which provides the
* functionality of a cryptographically strong pseudo-random number generator.</p>
*
* <p>All the abstract methods in the {@link SecureRandomSpi} class are
* implemented by this class and all its sub-classes.</p>
* functionality of a cryptographically strong pseudo-random number generator.
* <p>
* All the abstract methods in the {@link SecureRandomSpi} class are implemented
* by this class and all its sub-classes.
*/
abstract class SecureRandomAdapter extends SecureRandomSpi
abstract class SecureRandomAdapter
extends SecureRandomSpi
{
// Constants and variables
// -------------------------------------------------------------------------
/** Our underlying prng instance. */
private MDGenerator adaptee = new MDGenerator();
/** The name of the message digest algorithm used by the adaptee. */
private String mdName;
// Constructor(s)
// -------------------------------------------------------------------------
/**
* <p>Trivial protected constructor.</p>
*
* Trivial protected constructor.
*
* @param mdName the canonical name of the underlying hash algorithm.
*/
protected SecureRandomAdapter(String mdName)
@ -80,23 +74,14 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
super();
this.mdName = mdName;
adaptee.init (Collections.singletonMap (MDGenerator.MD_NAME, mdName));
adaptee.init(Collections.singletonMap(MDGenerator.MD_NAME, mdName));
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
// java.security.SecureRandomSpi interface implementation ------------------
public byte[] engineGenerateSeed(int numBytes)
{
if (numBytes < 1)
{
return new byte[0];
}
return new byte[0];
byte[] result = new byte[numBytes];
this.engineNextBytes(result);
return result;
@ -104,10 +89,8 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
public void engineNextBytes(byte[] bytes)
{
if (!adaptee.isInitialised())
{
this.engineSetSeed(new byte[0]);
}
if (! adaptee.isInitialised())
this.engineSetSeed(new byte[0]);
try
{
adaptee.nextBytes(bytes, 0, bytes.length);
@ -119,6 +102,6 @@ abstract class SecureRandomAdapter extends SecureRandomSpi
public void engineSetSeed(byte[] seed)
{
adaptee.addRandomBytes (seed);
adaptee.addRandomBytes(seed);
}
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the SHA1-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class Sha160RandomSpi extends SecureRandomAdapter
public class Sha160RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha160RandomSpi()
{
super(Registry.SHA160_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-256 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-256 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.
*/
public class Sha256RandomSpi extends SecureRandomAdapter
public class Sha256RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha256RandomSpi()
{
super(Registry.SHA256_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-384 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-384 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.
*/
public class Sha384RandomSpi extends SecureRandomAdapter
public class Sha384RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha384RandomSpi()
{
super(Registry.SHA384_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -41,26 +41,14 @@ package gnu.java.security.jce.prng;
import gnu.java.security.Registry;
/**
* <p>The implementation of the SHA-512 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.</p>
* The implementation of the SHA-512 based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.
*/
public class Sha512RandomSpi extends SecureRandomAdapter
public class Sha512RandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public Sha512RandomSpi()
{
super(Registry.SHA512_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Tiger based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class TigerRandomSpi extends SecureRandomAdapter
public class TigerRandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public TigerRandomSpi()
{
super(Registry.TIGER_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -42,25 +42,13 @@ import gnu.java.security.Registry;
/**
* The implementation of the Whirlpool-based SecureRandom <i>Service Provider
* Interface</i> (<b>SPI</b>) adapter.<p>
* Interface</i> (<b>SPI</b>) adapter.
*/
public class WhirlpoolRandomSpi extends SecureRandomAdapter
public class WhirlpoolRandomSpi
extends SecureRandomAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public WhirlpoolRandomSpi()
{
super(Registry.WHIRLPOOL_HASH);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -61,10 +61,11 @@ import java.security.spec.X509EncodedKeySpec;
/**
* DSA key factory.
*
*
* @author Casey Marshall (rsdio@metastatic.org)
*/
public class DSSKeyFactory extends KeyFactorySpi
public class DSSKeyFactory
extends KeyFactorySpi
{
// implicit 0-arguments constructor
@ -80,7 +81,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = spec.getY();
return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
}
if (keySpec instanceof X509EncodedKeySpec)
{
X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
@ -93,12 +93,9 @@ public class DSSKeyFactory extends KeyFactorySpi
}
catch (RuntimeException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
@ -114,7 +111,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = spec.getX();
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
if (keySpec instanceof PKCS8EncodedKeySpec)
{
PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
@ -127,12 +123,9 @@ public class DSSKeyFactory extends KeyFactorySpi
}
catch (RuntimeException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
@ -150,7 +143,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = dsaKey.getY();
return new DSAPublicKeySpec(y, p, q, g);
}
if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
{
if (key instanceof DSSPublicKey)
@ -159,19 +151,16 @@ public class DSSKeyFactory extends KeyFactorySpi
byte[] encoded = dssKey.getEncoded(Registry.X509_ENCODING_ID);
return new X509EncodedKeySpec(encoded);
}
if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new X509EncodedKeySpec(encoded);
}
throw new InvalidKeySpecException("Wrong key type or unsupported (public) key specification");
throw new InvalidKeySpecException(
"Wrong key type or unsupported (public) key specification");
}
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
if (key instanceof DSAPrivateKey)
{
if (keySpec.isAssignableFrom(DSAPrivateKeySpec.class))
@ -183,7 +172,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = dsaKey.getX();
return new DSAPrivateKeySpec(x, p, q, g);
}
if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
{
if (key instanceof DSSPrivateKey)
@ -192,19 +180,16 @@ public class DSSKeyFactory extends KeyFactorySpi
byte[] encoded = dssKey.getEncoded(Registry.PKCS8_ENCODING_ID);
return new PKCS8EncodedKeySpec(encoded);
}
if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new PKCS8EncodedKeySpec(encoded);
}
throw new InvalidKeySpecException("Wrong key type or unsupported (private) key specification");
throw new InvalidKeySpecException(
"Wrong key type or unsupported (private) key specification");
}
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
throw new InvalidKeySpecException("Wrong key type or unsupported key specification");
}
@ -222,7 +207,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger y = dsaKey.getY();
return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
}
if (key instanceof DSAPrivateKey)
{
DSAPrivateKey dsaKey = (DSAPrivateKey) key;
@ -232,7 +216,6 @@ public class DSSKeyFactory extends KeyFactorySpi
BigInteger x = dsaKey.getX();
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
throw new InvalidKeyException("Wrong key type");
}
}

View file

@ -52,33 +52,21 @@ import java.util.HashMap;
/**
* The implementation of a {@link java.security.KeyPairGenerator} adapter class
* to wrap gnu.crypto DSS keypair generator instances.<p>
*
* In case the client does not explicitly initialize the KeyPairGenerator (via
* a call to an <code>initialize()</code> method), the GNU Crypto provider
* uses a default <i>modulus</i> size (keysize) of 1024 bits.<p>
* to wrap GNU DSS keypair generator instances.
* <p>
* In case the client does not explicitly initialize the KeyPairGenerator (via a
* call to an <code>initialize()</code> method), the GNU provider uses a
* default <i>modulus</i> size (keysize) of 1024 bits.
*/
public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
DSAKeyPairGenerator
public class DSSKeyPairGeneratorSpi
extends KeyPairGeneratorAdapter
implements DSAKeyPairGenerator
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public DSSKeyPairGeneratorSpi()
{
super(Registry.DSS_KPG);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
public void initialize(int keysize, SecureRandom random)
{
this.initialize(keysize, false, random);
@ -90,43 +78,34 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
HashMap attributes = new HashMap();
if (params != null)
{
if (!(params instanceof DSAParameterSpec))
if (! (params instanceof DSAParameterSpec))
throw new InvalidAlgorithmParameterException(
"Parameters argument is not a non-null instance, or " +
"sub-instance, of java.security.spec.DSAParameterSpec");
"Parameters argument is not a non-null instance, or "
+ "sub-instance, of java.security.spec.DSAParameterSpec");
attributes.put(DSSKeyPairGenerator.DSS_PARAMETERS, params);
}
if (random != null)
{
attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
}
attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
new Integer(Registry.ASN1_ENCODING_ID));
Integer.valueOf(Registry.ASN1_ENCODING_ID));
try
{
adaptee.setup(attributes);
}
catch (IllegalArgumentException x)
{
InvalidAlgorithmParameterException y =
new InvalidAlgorithmParameterException();
y.initCause(x);
throw y;
throw new InvalidAlgorithmParameterException(x.getMessage(), x);
}
}
// java.security.interfaces.DSAKeyPairGenerator interface implementation -----
public void initialize(DSAParams params, SecureRandom random)
throws InvalidParameterException
{
if (params == null || !(params instanceof DSAParameterSpec))
throw new InvalidParameterException(
"Parameters argument is either null or is not an instance, or " +
"sub-instance, of java.security.spec.DSAParameterSpec");
"Parameters argument is either null or is not an instance, or "
+ "sub-instance, of java.security.spec.DSAParameterSpec");
DSAParameterSpec spec = (DSAParameterSpec) params;
try
{
@ -134,7 +113,7 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
}
catch (InvalidAlgorithmParameterException x)
{
InvalidParameterException y = new InvalidParameterException();
InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}
@ -144,22 +123,22 @@ public class DSSKeyPairGeneratorSpi extends KeyPairGeneratorAdapter implements
throws InvalidParameterException
{
HashMap attributes = new HashMap();
attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, new Integer(modlen));
attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(modlen));
if (random != null)
attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(DSSKeyPairGenerator.USE_DEFAULTS,
Boolean.valueOf(!genParams));
Boolean.valueOf(! genParams));
attributes.put(DSSKeyPairGenerator.STRICT_DEFAULTS, Boolean.TRUE);
attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
new Integer(Registry.ASN1_ENCODING_ID));
Integer.valueOf(Registry.ASN1_ENCODING_ID));
try
{
adaptee.setup(attributes);
}
catch (IllegalArgumentException x)
{
InvalidParameterException y = new InvalidParameterException();
InvalidParameterException y = new InvalidParameterException(x.getMessage());
y.initCause(x);
throw y;
}

View file

@ -136,7 +136,6 @@ public class DSSParameters
if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME))
throw new IOException("Unknown or unsupported format: " + format);
}
engineInit(params);
}
@ -191,7 +190,6 @@ public class DSSParameters
if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME))
throw new IOException("Unknown or unsupported format: " + format);
}
return engineGetEncoded();
}

View file

@ -42,27 +42,15 @@ import gnu.java.security.Registry;
import gnu.java.security.sig.dss.DSSSignatureRawCodec;
/**
* The implementation of <i>Service Provider Interface</i> (<b>SPI</b>) adapter
* for the DSS (Digital Signature Standard) signature scheme, encoded and/or
* decoded in RAW format.<p>
* The implementation of <i>Service Provider Interface</i> (<b>SPI</b>)
* adapter for the DSS (Digital Signature Standard) signature scheme, encoded
* and/or decoded in RAW format.
*/
public class DSSRawSignatureSpi extends SignatureAdapter
public class DSSRawSignatureSpi
extends SignatureAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public DSSRawSignatureSpi()
{
super(Registry.DSS_SIG, new DSSSignatureRawCodec());
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.jce.sig;
import gnu.java.security.Configuration;
import gnu.java.security.Registry;
import gnu.java.security.key.dss.DSSPrivateKey;
import gnu.java.security.key.dss.DSSPublicKey;
@ -79,11 +80,6 @@ public class EncodedKeyFactory
{
private static final Logger log = Logger.getLogger(EncodedKeyFactory.class.getName());
// implicit 0-arguments constructor
// Class methods
// --------------------------------------------------------------------------
private static Object invokeConstructor(String className, Object[] params)
throws InvalidKeySpecException
{
@ -96,21 +92,15 @@ public class EncodedKeyFactory
}
catch (InstantiationException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (IllegalAccessException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(y);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (InvocationTargetException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@ -124,9 +114,7 @@ public class EncodedKeyFactory
}
catch (ClassNotFoundException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@ -144,9 +132,7 @@ public class EncodedKeyFactory
}
catch (NoSuchMethodException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@ -162,15 +148,11 @@ public class EncodedKeyFactory
}
catch (IllegalAccessException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
catch (InvocationTargetException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
@ -184,20 +166,15 @@ public class EncodedKeyFactory
}
catch (NoSuchMethodException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
// Instance methods
// --------------------------------------------------------------------------
protected PublicKey engineGeneratePublic(KeySpec keySpec)
throws InvalidKeySpecException
{
log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec);
if (Configuration.DEBUG)
log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec);
PublicKey result = null;
if (keySpec instanceof DSAPublicKeySpec)
result = decodeDSSPublicKey((DSAPublicKeySpec) keySpec);
@ -220,10 +197,10 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore",
ignored);
if (Configuration.DEBUG)
log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore",
ignored);
}
if (! ok) // try RSA
try
{
@ -232,24 +209,24 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
log.log(Level.FINE,
"Exception in GnuRSAPublicKey.valueOf(). Ignore",
ignored);
if (Configuration.DEBUG)
log.log(Level.FINE,
"Exception in GnuRSAPublicKey.valueOf(). Ignore",
ignored);
}
if (! ok) // try DH
result = decodeDHPublicKey(input);
}
log.exiting(this.getClass().getName(), "engineGeneratePublic()", result);
if (Configuration.DEBUG)
log.exiting(this.getClass().getName(), "engineGeneratePublic()", result);
return result;
}
protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
throws InvalidKeySpecException
{
log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec);
if (Configuration.DEBUG)
log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec);
PrivateKey result = null;
if (keySpec instanceof DSAPrivateKeySpec)
result = decodeDSSPrivateKey((DSAPrivateKeySpec) keySpec);
@ -272,10 +249,10 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore",
ignored);
if (Configuration.DEBUG)
log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore",
ignored);
}
if (! ok) // try RSA
try
{
@ -284,16 +261,16 @@ public class EncodedKeyFactory
}
catch (InvalidParameterException ignored)
{
log.log(Level.FINE,
"Exception in GnuRSAPrivateKey.valueOf(). Ignore",
ignored);
if (Configuration.DEBUG)
log.log(Level.FINE,
"Exception in GnuRSAPrivateKey.valueOf(). Ignore",
ignored);
}
if (! ok) // try DH
result = decodeDHPrivateKey(input);
}
log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result);
if (Configuration.DEBUG)
log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result);
return result;
}
@ -321,7 +298,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link DSAPublicKeySpec} to decode.
* @return an instance of {@link DSSPublicKey} constructed from the
* information in the designated key-specification.
* information in the designated key-specification.
*/
private DSSPublicKey decodeDSSPublicKey(DSAPublicKeySpec spec)
{
@ -335,7 +312,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link RSAPublicKeySpec} to decode.
* @return an instance of {@link GnuRSAPublicKey} constructed from the
* information in the designated key-specification.
* information in the designated key-specification.
*/
private GnuRSAPublicKey decodeRSAPublicKey(RSAPublicKeySpec spec)
{
@ -358,7 +335,7 @@ public class EncodedKeyFactory
BigInteger p = spec.getP();
BigInteger g = spec.getG();
BigInteger y = spec.getY();
Object[] params = new Object[] {new Integer(Registry.X509_ENCODING_ID),
Object[] params = new Object[] {Integer.valueOf(Registry.X509_ENCODING_ID),
null, p, g, y};
Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPublicKey",
params);
@ -384,7 +361,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link DSAPrivateKeySpec} to decode.
* @return an instance of {@link DSSPrivateKey} constructed from the
* information in the designated key-specification.
* information in the designated key-specification.
*/
private PrivateKey decodeDSSPrivateKey(DSAPrivateKeySpec spec)
{
@ -398,7 +375,7 @@ public class EncodedKeyFactory
/**
* @param spec an instance of {@link RSAPrivateCrtKeySpec} to decode.
* @return an instance of {@link GnuRSAPrivateKey} constructed from the
* information in the designated key-specification.
* information in the designated key-specification.
*/
private PrivateKey decodeRSAPrivateKey(RSAPrivateCrtKeySpec spec)
{
@ -428,7 +405,7 @@ public class EncodedKeyFactory
BigInteger p = spec.getP();
BigInteger g = spec.getG();
BigInteger x = spec.getX();
Object[] params = new Object[] {new Integer(Registry.PKCS8_ENCODING_ID),
Object[] params = new Object[] {Integer.valueOf(Registry.PKCS8_ENCODING_ID),
null, p, g, x};
Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPrivateKey",
params);

View file

@ -49,36 +49,30 @@ import java.security.spec.AlgorithmParameterSpec;
/**
* The implementation of a generic {@link java.security.KeyPairGenerator}
* adapter class to wrap gnu.crypto keypair generator instances.<p>
*
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
* {@link java.security.KeyPairGenerator} class, which is used to generate pairs
* of public and private keys.<p>
*
* adapter class to wrap GNU keypair generator instances.
* <p>
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link java.security.KeyPairGenerator} class, which is used to generate
* pairs of public and private keys.
* <p>
* All the abstract methods in the {@link java.security.KeyPairGeneratorSpi}
* class are implemented by this class and all its sub-classes.<p>
*
* In case the client does not explicitly initialize the KeyPairGenerator (via
* a call to an <code>initialize()</code> method), the GNU Crypto provider
* supplies (and document) default values to be used. For example, the GNU
* Crypto provider uses a default <i>modulus</i> size (keysize) of 1024 bits for
* the DSS (Digital Signature Standard) a.k.a <i>DSA</i>.<p>
* class are implemented by this class and all its sub-classes.
* <p>
* In case the client does not explicitly initialize the KeyPairGenerator (via a
* call to an <code>initialize()</code> method), the GNU provider supplies
* (and document) default values to be used. For example, the GNU provider uses
* a default <i>modulus</i> size (keysize) of 1024 bits for the DSS (Digital
* Signature Standard) a.k.a <i>DSA</i>.
*/
public abstract class KeyPairGeneratorAdapter extends KeyPairGenerator
public abstract class KeyPairGeneratorAdapter
extends KeyPairGenerator
{
// Constants and variables
// -------------------------------------------------------------------------
/** Our underlying keypair instance. */
protected IKeyPairGenerator adaptee;
// Constructor(s)
// -------------------------------------------------------------------------
/**
* Trivial protected constructor.
*
*
* @param kpgName the canonical name of the keypair generator algorithm.
*/
protected KeyPairGeneratorAdapter(String kpgName)
@ -88,12 +82,6 @@ public abstract class KeyPairGeneratorAdapter extends KeyPairGenerator
this.adaptee = KeyPairGeneratorFactory.getInstance(kpgName);
}
// Class methods
// -------------------------------------------------------------------------
// java.security.KeyPairGeneratorSpi interface implementation
// -------------------------------------------------------------------------
public abstract void initialize(int keysize, SecureRandom random);
public abstract void initialize(AlgorithmParameterSpec params,

View file

@ -76,7 +76,6 @@ public class RSAKeyFactory
BigInteger e = spec.getPublicExponent();
return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
}
if (keySpec instanceof X509EncodedKeySpec)
{
X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
@ -88,12 +87,9 @@ public class RSAKeyFactory
}
catch (RuntimeException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
@ -114,16 +110,6 @@ public class RSAKeyFactory
return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
n, e, d, p, q, dP, dQ, qInv);
}
// if (keySpec instanceof RSAPrivateKeySpec)
// {
// RSAPrivateKeySpec spec = (RSAPrivateKeySpec) keySpec;
// BigInteger n = spec.getModulus();
// BigInteger d = spec.getPrivateExponent();
// return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
// n, null, d, null, null, null, null, null);
// }
if (keySpec instanceof PKCS8EncodedKeySpec)
{
PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
@ -135,12 +121,9 @@ public class RSAKeyFactory
}
catch (RuntimeException x)
{
InvalidKeySpecException y = new InvalidKeySpecException();
y.initCause(x);
throw y;
throw new InvalidKeySpecException(x.getMessage(), x);
}
}
throw new InvalidKeySpecException("Unsupported (private) key specification");
}
@ -156,7 +139,6 @@ public class RSAKeyFactory
BigInteger e = rsaKey.getPublicExponent();
return new RSAPublicKeySpec(n, e);
}
if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
{
if (key instanceof GnuRSAPublicKey)
@ -171,13 +153,11 @@ public class RSAKeyFactory
byte[] encoded = key.getEncoded();
return new X509EncodedKeySpec(encoded);
}
throw new InvalidKeySpecException("Wrong key type or unsupported (public) key specification");
throw new InvalidKeySpecException(
"Wrong key type or unsupported (public) key specification");
}
throw new InvalidKeySpecException("Unsupported (public) key specification");
}
if ((key instanceof RSAPrivateCrtKey)
&& keySpec.isAssignableFrom(RSAPrivateCrtKeySpec.class))
{
@ -192,7 +172,6 @@ public class RSAKeyFactory
BigInteger qInv = rsaKey.getCrtCoefficient();
return new RSAPrivateCrtKeySpec(n, e, d, p, q, dP, dQ, qInv);
}
if ((key instanceof RSAPrivateKey)
&& keySpec.isAssignableFrom(RSAPrivateKeySpec.class))
{
@ -201,7 +180,6 @@ public class RSAKeyFactory
BigInteger d = rsaKey.getPrivateExponent();
return new RSAPrivateKeySpec(n, d);
}
if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
{
if (key instanceof GnuRSAPrivateKey)
@ -210,17 +188,16 @@ public class RSAKeyFactory
byte[] encoded = rsaKey.getEncoded(Registry.PKCS8_ENCODING_ID);
return new PKCS8EncodedKeySpec(encoded);
}
if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
{
byte[] encoded = key.getEncoded();
return new PKCS8EncodedKeySpec(encoded);
}
throw new InvalidKeySpecException("Wrong key type or unsupported (private) key specification");
throw new InvalidKeySpecException(
"Wrong key type or unsupported (private) key specification");
}
throw new InvalidKeySpecException("Wrong key type or unsupported key specification");
throw new InvalidKeySpecException(
"Wrong key type or unsupported key specification");
}
protected Key engineTranslateKey(Key key) throws InvalidKeyException
@ -235,7 +212,6 @@ public class RSAKeyFactory
BigInteger e = rsaKey.getPublicExponent();
return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
}
if (key instanceof RSAPrivateCrtKey)
{
RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
@ -250,16 +226,6 @@ public class RSAKeyFactory
return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
n, e, d, p, q, dP, dQ, qInv);
}
// if (key instanceof RSAPrivateKey)
// {
// RSAPrivateKey rsaKey = (RSAPrivateKey) key;
// BigInteger n = rsaKey.getModulus();
// BigInteger d = rsaKey.getPrivateExponent();
// return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
// n, null, d, null, null, null, null, null);
// }
throw new InvalidKeyException("Unsupported key type");
}
}

View file

@ -49,43 +49,29 @@ import java.util.HashMap;
/**
* The implementation of a {@link java.security.KeyPairGenerator} adapter class
* to wrap gnu.crypto RSA keypair generator instances.<p>
*
* In case the client does not explicitly initialize the KeyPairGenerator (via
* a call to an <code>initialize()</code> method), the GNU Crypto provider
* uses a default <i>modulus</i> size (keysize) of 1024 bits.<p>
* to wrap GNU RSA keypair generator instances.
* <p>
* In case the client does not explicitly initialize the KeyPairGenerator (via a
* call to an <code>initialize()</code> method), the GNU provider uses a
* default <i>modulus</i> size (keysize) of 1024 bits.
*/
public class RSAKeyPairGeneratorSpi extends KeyPairGeneratorAdapter
public class RSAKeyPairGeneratorSpi
extends KeyPairGeneratorAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RSAKeyPairGeneratorSpi()
{
super(Registry.RSA_KPG);
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
public void initialize(int keysize, SecureRandom random)
{
HashMap attributes = new HashMap();
attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, new Integer(keysize));
attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(keysize));
if (random != null)
{
attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
}
attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
new Integer(Registry.ASN1_ENCODING_ID));
Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
@ -95,21 +81,16 @@ public class RSAKeyPairGeneratorSpi extends KeyPairGeneratorAdapter
HashMap attributes = new HashMap();
if (params != null)
{
if (!(params instanceof RSAKeyGenParameterSpec))
{
throw new InvalidAlgorithmParameterException("params");
}
if (! (params instanceof RSAKeyGenParameterSpec))
throw new InvalidAlgorithmParameterException("params");
attributes.put(RSAKeyPairGenerator.RSA_PARAMETERS, params);
}
if (random != null)
{
attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
}
attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
new Integer(Registry.ASN1_ENCODING_ID));
Integer.valueOf(Registry.ASN1_ENCODING_ID));
adaptee.setup(attributes);
}
}

View file

@ -42,26 +42,15 @@ import gnu.java.security.Registry;
import gnu.java.security.sig.rsa.RSAPSSSignatureRawCodec;
/**
* The implementation of <i>Service Provider Interface</i> (<b>SPI</b>) adapter
* for the RSA-PSS signature scheme, encoded and/or decoded in RAW format.<p>
* The implementation of <i>Service Provider Interface</i> (<b>SPI</b>)
* adapter for the RSA-PSS signature scheme, encoded and/or decoded in RAW
* format.
*/
public class RSAPSSRawSignatureSpi extends SignatureAdapter
public class RSAPSSRawSignatureSpi
extends SignatureAdapter
{
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public RSAPSSRawSignatureSpi()
{
super(Registry.RSA_PSS_SIG, new RSAPSSSignatureRawCodec());
}
// Class methods
// -------------------------------------------------------------------------
// Instance methods
// -------------------------------------------------------------------------
}

View file

@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.jce.sig;
import gnu.java.security.Configuration;
import gnu.java.security.sig.BaseSignature;
import gnu.java.security.sig.ISignature;
import gnu.java.security.sig.ISignatureCodec;
@ -57,38 +58,34 @@ import java.util.logging.Logger;
/**
* The implementation of a generic {@link java.security.Signature} adapter class
* to wrap gnu.crypto signature instances.<p>
*
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for the
* {@link java.security.Signature} class, which provides the functionality of a
* digital signature algorithm. Digital signatures are used for authentication
* and integrity assurance of digital data.<p>
*
* All the abstract methods in the {@link java.security.SignatureSpi} class are
* implemented by this class and all its sub-classes.<p>
*
* to wrap GNU signature instances.
* <p>
* This class defines the <i>Service Provider Interface</i> (<b>SPI</b>) for
* the {@link java.security.Signature} class, which provides the functionality
* of a digital signature algorithm. Digital signatures are used for
* authentication and integrity assurance of digital data.
* <p>
* All the abstract methods in the {@link SignatureSpi} class are implemented by
* this class and all its sub-classes.
* <p>
* All the implementations which subclass this object, and which are serviced by
* the GNU Crypto provider implement the {@link java.lang.Cloneable} interface.<p>
* the GNU provider implement the {@link Cloneable} interface.
*/
class SignatureAdapter extends SignatureSpi implements Cloneable
class SignatureAdapter
extends SignatureSpi
implements Cloneable
{
private static final Logger log = Logger.getLogger(SignatureAdapter.class.getName());
// Constants and variables
// -------------------------------------------------------------------------
/** Our underlying signature instance. */
private ISignature adaptee;
/** Our underlying signature encoder/decoder engine. */
private ISignatureCodec codec;
// Constructor(s)
// -------------------------------------------------------------------------
/**
* Trivial protected constructor.<p>
*
* Trivial protected constructor.
*
* @param sigName the canonical name of the signature scheme.
* @param codec the signature codec engine to use with this scheme.
*/
@ -98,8 +95,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
/**
* Private constructor for cloning purposes.<p>
*
* Private constructor for cloning purposes.
*
* @param adaptee a clone of the underlying signature scheme instance.
* @param codec the signature codec engine to use with this scheme.
*/
@ -111,12 +108,6 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
this.codec = codec;
}
// Class methods
// -------------------------------------------------------------------------
// java.security.SignatureSpi interface implementation
// -------------------------------------------------------------------------
public Object clone()
{
return new SignatureAdapter((ISignature) adaptee.clone(), codec);
@ -132,7 +123,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
throw new InvalidKeyException(String.valueOf(x));
throw new InvalidKeyException(x.getMessage(), x);
}
}
@ -146,7 +137,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
throw new InvalidKeyException(String.valueOf(x));
throw new InvalidKeyException(x.getMessage(), x);
}
}
@ -162,7 +153,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalArgumentException x)
{
throw new InvalidKeyException(String.valueOf(x));
throw new InvalidKeyException(x.getMessage(), x);
}
}
@ -174,7 +165,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
throw new SignatureException(String.valueOf(x));
throw new SignatureException(x.getMessage(), x);
}
}
@ -187,7 +178,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
throw new SignatureException(String.valueOf(x));
throw new SignatureException(x.getMessage(), x);
}
}
@ -200,9 +191,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
throw new SignatureException(String.valueOf(x));
throw new SignatureException(x.getMessage(), x);
}
byte[] result = codec.encodeSignature(signature);
return result;
}
@ -213,9 +203,7 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
byte[] signature = this.engineSign();
int result = signature.length;
if (result > len)
{
throw new SignatureException("len");
}
throw new SignatureException("Not enough room to store signature");
System.arraycopy(signature, 0, outbuf, offset, result);
return result;
@ -223,8 +211,8 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
public boolean engineVerify(byte[] sigBytes) throws SignatureException
{
log.entering("SignatureAdapter", "engineVerify");
if (Configuration.DEBUG)
log.entering(this.getClass().getName(), "engineVerify");
Object signature = codec.decodeSignature(sigBytes);
boolean result = false;
try
@ -233,10 +221,11 @@ class SignatureAdapter extends SignatureSpi implements Cloneable
}
catch (IllegalStateException x)
{
throw new SignatureException(String.valueOf(x));
throw new SignatureException(x.getMessage(), x);
}
log.exiting("SignatureAdapter", "engineVerify", new Boolean(result));
if (Configuration.DEBUG)
log.exiting(this.getClass().getName(), "engineVerify",
Boolean.valueOf(result));
return result;
}