Imported GNU Classpath 0.90

Imported GNU Classpath 0.90
       * scripts/makemake.tcl: LocaleData.java moved to gnu/java/locale.

       * sources.am: Regenerated.
       * gcj/javaprims.h: Regenerated.
       * Makefile.in: Regenerated.
       * gcj/Makefile.in: Regenerated.
       * include/Makefile.in: Regenerated.
       * testsuite/Makefile.in: Regenerated.

       * gnu/java/lang/VMInstrumentationImpl.java: New override.
       * gnu/java/net/local/LocalSocketImpl.java: Likewise.
       * gnu/classpath/jdwp/VMMethod.java: Likewise.
       * gnu/classpath/jdwp/VMVirtualMachine.java: Update to latest
       interface.
       * java/lang/Thread.java: Add UncaughtExceptionHandler.
       * java/lang/reflect/Method.java: Implements GenericDeclaration and
       isSynthetic(),
       * java/lang/reflect/Field.java: Likewise.
       * java/lang/reflect/Constructor.java
       * java/lang/Class.java: Implements Type, GenericDeclaration,
       getSimpleName() and getEnclosing*() methods.
       * java/lang/Class.h: Add new public methods.
       * java/lang/Math.java: Add signum(), ulp() and log10().
       * java/lang/natMath.cc (log10): New function.
       * java/security/VMSecureRandom.java: New override.
       * java/util/logging/Logger.java: Updated to latest classpath
       version.
       * java/util/logging/LogManager.java: New override.

From-SVN: r113887
This commit is contained in:
Mark Wielaard
2006-05-18 17:29:21 +00:00
parent eaec4980e1
commit 4f9533c772
1640 changed files with 126485 additions and 104808 deletions
@@ -48,8 +48,6 @@ import java.security.PublicKey;
* cryptographic asymmetric keypairs. Codecs are useful for (a) externalising
* public and private keys for storage and on-the-wire transmission, as well as
* (b) re-creating their internal Java representation from external sources.</p>
*
* @version $Revision: 1.2 $
*/
public interface IKeyPairCodec
{
@@ -43,8 +43,6 @@ import java.util.Map;
/**
* The visible methods of every asymmetric keypair generator.<p>
*
* @version $Revision: 1.1 $
*/
public interface IKeyPairGenerator
{
@@ -49,8 +49,6 @@ import java.util.Set;
/**
* <p>A Factory to instantiate asymmetric keypair generators.</p>
*
* @version $Revision: 1.1 $
*/
public class KeyPairGeneratorFactory
{
@@ -87,7 +85,7 @@ public class KeyPairGeneratorFactory
name = name.trim();
IKeyPairGenerator result = null;
if (name.equalsIgnoreCase(Registry.DSA_KPG)
|| name.equals(Registry.DSS_KPG))
|| name.equalsIgnoreCase(Registry.DSS_KPG))
{
result = new DSSKeyPairGenerator();
}
@@ -118,6 +116,7 @@ public class KeyPairGeneratorFactory
{
HashSet hs = new HashSet();
hs.add(Registry.DSS_KPG);
hs.add(Registry.DSA_KPG);
hs.add(Registry.RSA_KPG);
hs.add(Registry.DH_KPG);
hs.add(Registry.SRP_KPG);
@@ -135,11 +134,9 @@ public class KeyPairGeneratorFactory
}
catch (Exception x)
{
IllegalArgumentException iae =
new IllegalArgumentException ("strong crypto key pair generator not available: "
+ clazz);
iae.initCause (x);
throw iae;
throw new IllegalArgumentException(
"strong crypto key pair generator not available: " + clazz,
x);
}
}
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.dss;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.util.FormatUtil;
@@ -59,7 +60,6 @@ import java.security.spec.DSAParameterSpec;
* the relevant <code>getEncoded()</code> methods of each of the private and
* public keys.</p>
*
* @version $Revision: 1.4 $
* @see DSSPrivateKey#getEncoded
* @see DSSPublicKey#getEncoded
*/
@@ -95,6 +95,9 @@ public abstract class DSSKey implements Key, DSAKey
*/
protected final int defaultFormat;
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -176,6 +179,22 @@ public abstract class DSSKey implements Key, DSAKey
&& g.equals(that.getParams().getG());
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder().append(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("p=0x").append(p.toString(16)).append(",").append(ls)
.append("q=0x").append(q.toString(16)).append(",").append(ls)
.append("g=0x").append(g.toString(16))
.toString();
}
return str;
}
// abstract methods to be implemented by subclasses ------------------------
public abstract byte[] getEncoded(int format);
@@ -55,6 +55,7 @@ import java.security.InvalidParameterException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.logging.Logger;
/**
* An implementation of an {@link IKeyPairCodec} that knows how to encode /
@@ -65,6 +66,7 @@ import java.util.ArrayList;
public class DSSKeyPairPKCS8Codec
implements IKeyPairCodec
{
private static final Logger log = Logger.getLogger(DSSKeyPairPKCS8Codec.class.getName());
private static final OID DSA_ALG_OID = new OID(Registry.DSA_OID_STRING);
// implicit 0-arguments constructor
@@ -137,7 +139,9 @@ public class DSSKeyPairPKCS8Codec
DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
algorithmID);
DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, Util.trim(x));
// The OCTET STRING is the DER encoding of an INTEGER.
DERValue derX = new DERValue(DER.INTEGER, x);
DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, derX.getEncoded());
ArrayList pki = new ArrayList(3);
pki.add(derVersion);
@@ -180,6 +184,8 @@ public class DSSKeyPairPKCS8Codec
*/
public PrivateKey decodePrivateKey(byte[] input)
{
log.entering("DSSKeyPairPKCS8Codec", "decodePrivateKey");
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
@@ -220,8 +226,13 @@ public class DSSKeyPairPKCS8Codec
g = (BigInteger) val.getValue();
val = der.read();
log.finest("val = " + val);
byte[] xBytes = (byte[]) val.getValue();
x = new BigInteger(1, xBytes);
log.finest(Util.dumpString(xBytes, "xBytes: "));
DERReader der2 = new DERReader(xBytes);
val = der2.read();
DerUtil.checkIsBigInteger(val, "Wrong X field");
x = (BigInteger) val.getValue();
}
catch (IOException e)
{
@@ -230,6 +241,7 @@ public class DSSKeyPairPKCS8Codec
throw y;
}
log.exiting("DSSKeyPairPKCS8Codec", "decodePrivateKey");
return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
}
}
@@ -49,8 +49,6 @@ import java.security.PublicKey;
/**
* <p>An object that implements the {@link IKeyPairCodec} operations for the
* <i>Raw</i> format to use with DSS keypairs.</p>
*
* @version $Revision: 1.1 $
*/
public class DSSKeyPairRawCodec implements IKeyPairCodec
{
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.dss;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
@@ -48,21 +49,24 @@ import java.security.interfaces.DSAPrivateKey;
/**
* <p>An object that embodies a DSS (Digital Signature Standard) private key.</p>
*
* @version $Revision: 1.2 $
* @see #getEncoded
*/
public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
{
// Constants and variables
// -------------------------------------------------------------------------
private static final boolean DEBUG = false;
/**
* <p>A randomly or pseudorandomly generated integer with <code>0 &lt; x &lt;
* q</code>.</p>
*/
private final BigInteger x;
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -198,4 +202,18 @@ public class DSSPrivateKey extends DSSKey implements PrivateKey, DSAPrivateKey
DSAPrivateKey that = (DSAPrivateKey) obj;
return super.equals(that) && x.equals(that.getX());
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("x=0x").append(DEBUG ? x.toString(16) : "**...*").append(ls)
.append(")").toString();
}
return str;
}
}
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.dss;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
@@ -48,12 +49,10 @@ import java.security.interfaces.DSAPublicKey;
/**
* <p>An object that embodies a DSS (Digital Signature Standard) public key.</p>
*
* @version $Revision: 1.2 $
* @see #getEncoded
*/
public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
{
// Constants and variables
// -------------------------------------------------------------------------
@@ -63,6 +62,9 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
*/
private final BigInteger y;
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -198,4 +200,18 @@ public class DSSPublicKey extends DSSKey implements PublicKey, DSAPublicKey
DSAPublicKey that = (DSAPublicKey) obj;
return super.equals(that) && y.equals(that.getY());
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("y=0x").append(y.toString(16)).append(ls)
.append(")").toString();
}
return str;
}
}
@@ -53,8 +53,6 @@ import java.security.SecureRandom;
* <a href="http://www.itl.nist.gov/fipspubs/fip186.htm">Digital Signature
* Standard (DSS)</a>, Federal Information Processing Standards Publication 186.
* National Institute of Standards and Technology.
*
* @version $Revision: 1.2 $
*/
public class FIPS186
{
@@ -38,8 +38,8 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
import gnu.java.security.util.FormatUtil;
import java.math.BigInteger;
@@ -48,8 +48,6 @@ import java.security.interfaces.RSAKey;
/**
* <p>A base asbtract class for both public and private RSA keys.</p>
*
* @version $Revision: 1.3 $
*/
public abstract class GnuRSAKey implements Key, RSAKey
{
@@ -69,6 +67,9 @@ public abstract class GnuRSAKey implements Key, RSAKey
*/
protected final int defaultFormat;
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -113,7 +114,7 @@ public abstract class GnuRSAKey implements Key, RSAKey
/** @deprecated see getEncoded(int). */
public byte[] getEncoded()
{
return getEncoded(IKeyPairCodec.RAW_FORMAT);
return getEncoded(defaultFormat);
}
public String getFormat()
@@ -175,6 +176,20 @@ public abstract class GnuRSAKey implements Key, RSAKey
return n.equals(that.getModulus());
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder().append(ls)
.append("defaultFormat=").append(defaultFormat).append(",").append(ls)
.append("n=0x").append(n.toString(16)).append(",").append(ls)
.append("e=0x").append(e.toString(16))
.toString();
}
return str;
}
// abstract methods to be implemented by subclasses ------------------------
public abstract byte[] getEncoded(int format);
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
@@ -56,16 +57,15 @@ import java.security.interfaces.RSAPrivateKey;
* Primitive specification and supporting documentation.<br>
* Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*
* @version $Revision: 1.3 $
*/
public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
RSAPrivateCrtKey
{
// Constants and variables
// -------------------------------------------------------------------------
private static final boolean DEBUG = false;
/** The first prime divisor of the modulus. */
private final BigInteger p;
@@ -86,6 +86,9 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
/** The CRT (Chinese Remainder Theorem) coefficient. */
private final BigInteger qInv;
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -296,4 +299,22 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
}
return false;
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append("d=0x").append(DEBUG ? d.toString(16) : "**...*").append(ls)
.append("p=0x").append(DEBUG ? p.toString(16) : "**...*").append(ls)
.append("q=0x").append(DEBUG ? q.toString(16) : "**...*").append(ls)
.append("dP=0x").append(DEBUG ? dP.toString(16) : "**...*").append(ls)
.append("dQ=0x").append(DEBUG ? dQ.toString(16) : "**...*").append(ls)
.append("qInv=0x").append(DEBUG ? qInv.toString(16) : "**...*").append(ls)
.append(")").toString();
}
return str;
}
}
@@ -38,6 +38,7 @@ exception statement from your version. */
package gnu.java.security.key.rsa;
import gnu.classpath.SystemProperties;
import gnu.java.security.Registry;
import gnu.java.security.key.IKeyPairCodec;
@@ -55,16 +56,16 @@ import java.security.interfaces.RSAPublicKey;
* Primitive specification and supporting documentation.<br>
* Jakob Jonsson and Burt Kaliski.</li>
* </ol>
*
* @version $Revision: 1.2 $
*/
public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
RSAPublicKey
{
// Constants and variables
// -------------------------------------------------------------------------
/** String representation of this key. Cached for speed. */
private transient String str;
// Constructor(s)
// -------------------------------------------------------------------------
@@ -182,4 +183,16 @@ public class GnuRSAPublicKey extends GnuRSAKey implements PublicKey,
return super.equals(that)
&& getPublicExponent().equals(that.getPublicExponent());
}
public String toString()
{
if (str == null)
{
String ls = SystemProperties.getProperty("line.separator");
str = new StringBuilder(this.getClass().getName()).append("(")
.append(super.toString()).append(",").append(ls)
.append(")").toString();
}
return str;
}
}
@@ -50,6 +50,7 @@ import java.security.PublicKey;
import java.security.SecureRandom;
import java.security.spec.RSAKeyGenParameterSpec;
import java.util.Map;
import java.util.logging.Logger;
/**
* <p>A key-pair generator for asymetric keys to use in conjunction with the RSA
@@ -68,10 +69,11 @@ import java.util.Map;
*/
public class RSAKeyPairGenerator implements IKeyPairGenerator
{
// Constants and variables
// -------------------------------------------------------------------------
private static final Logger log = Logger.getLogger(RSAKeyPairGenerator.class.getName());
/** The BigInteger constant 1. */
private static final BigInteger ONE = BigInteger.ONE;
@@ -150,6 +152,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
*/
public void setup(Map attributes)
{
log.entering(this.getClass().getName(), "setup", attributes);
// do we have a SecureRandom, or should we use our own?
rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
@@ -177,6 +181,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
: formatID.intValue();
log.exiting(this.getClass().getName(), "setup");
}
/**
@@ -187,6 +193,8 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
*/
public KeyPair generate()
{
log.entering(this.getClass().getName(), "generate");
BigInteger p, q, n, d;
// 1. Generate a prime p in the interval [2**(M-1), 2**M - 1], where
@@ -234,7 +242,9 @@ public class RSAKeyPairGenerator implements IKeyPairGenerator
PublicKey pubK = new GnuRSAPublicKey(preferredFormat, n, e);
PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d);
return new KeyPair(pubK, secK);
KeyPair result = new KeyPair(pubK, secK);
log.exiting(this.getClass().getName(), "generate", result);
return result;
}
// helper methods ----------------------------------------------------------
@@ -45,6 +45,7 @@ import java.security.InvalidParameterException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.util.ArrayList;
import java.util.logging.Logger;
import gnu.java.security.OID;
import gnu.java.security.Registry;
@@ -62,6 +63,7 @@ import gnu.java.security.util.DerUtil;
public class RSAKeyPairPKCS8Codec
implements IKeyPairCodec
{
private static final Logger log = Logger.getLogger(RSAKeyPairPKCS8Codec.class.getName());
private static final OID RSA_ALG_OID = new OID(Registry.RSA_OID_STRING);
// implicit 0-arguments constructor
@@ -120,6 +122,8 @@ public class RSAKeyPairPKCS8Codec
*/
public byte[] encodePrivateKey(PrivateKey key)
{
log.entering(this.getClass().getName(), "encodePrivateKey()", key);
if (! (key instanceof GnuRSAPrivateKey))
throw new InvalidParameterException("Wrong key type");
@@ -187,6 +191,7 @@ public class RSAKeyPairPKCS8Codec
throw y;
}
log.exiting(this.getClass().getName(), "encodePrivateKey()", result);
return result;
}
@@ -208,6 +213,8 @@ public class RSAKeyPairPKCS8Codec
*/
public PrivateKey decodePrivateKey(byte[] input)
{
log.entering(this.getClass().getName(), "decodePrivateKey()", input);
if (input == null)
throw new InvalidParameterException("Input bytes MUST NOT be null");
@@ -278,7 +285,9 @@ public class RSAKeyPairPKCS8Codec
throw y;
}
return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, n, e, d, p, q,
dP, dQ, qInv);
PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, n, e,
d, p, q, dP, dQ, qInv);
log.exiting(this.getClass().getName(), "decodePrivateKey()", result);
return result;
}
}
@@ -128,8 +128,9 @@ public class RSAKeyPairX509Codec
DERValue derN = new DERValue(DER.INTEGER, n);
DERValue derE = new DERValue(DER.INTEGER, e);
ArrayList algorithmID = new ArrayList(1);
ArrayList algorithmID = new ArrayList(2);
algorithmID.add(derOID);
algorithmID.add(new DERValue(DER.NULL, null));
DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
algorithmID);