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:
@@ -38,42 +38,39 @@ exception statement from your version. */
|
||||
|
||||
package gnu.java.security.key.rsa;
|
||||
|
||||
import gnu.classpath.SystemProperties;
|
||||
import gnu.java.security.Configuration;
|
||||
import gnu.java.security.action.GetPropertyAction;
|
||||
import gnu.java.security.Registry;
|
||||
import gnu.java.security.key.IKeyPairCodec;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivateKey;
|
||||
import java.security.interfaces.RSAPrivateCrtKey;
|
||||
import java.security.interfaces.RSAPrivateKey;
|
||||
|
||||
/**
|
||||
* <p>An object that embodies an RSA private key.</p>
|
||||
*
|
||||
* <p>References:</p>
|
||||
* An object that embodies an RSA private key.
|
||||
* <p>
|
||||
* References:
|
||||
* <ol>
|
||||
* <li><a href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
|
||||
* RSA-PSS Signature Scheme with Appendix, part B.</a><br>
|
||||
* Primitive specification and supporting documentation.<br>
|
||||
* Jakob Jonsson and Burt Kaliski.</li>
|
||||
* <li><a
|
||||
* href="http://www.cosic.esat.kuleuven.ac.be/nessie/workshop/submissions/rsa-pss.zip">
|
||||
* RSA-PSS Signature Scheme with Appendix, part B.</a><br>
|
||||
* Primitive specification and supporting documentation.<br>
|
||||
* Jakob Jonsson and Burt Kaliski.</li>
|
||||
* </ol>
|
||||
*/
|
||||
public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
RSAPrivateCrtKey
|
||||
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;
|
||||
|
||||
/** The second prime divisor of the modulus. */
|
||||
private final BigInteger q;
|
||||
|
||||
/** The public exponent of an RSA key. */
|
||||
// private final BigInteger e;
|
||||
/** The private exponent of an RSA private key. */
|
||||
private final BigInteger d;
|
||||
|
||||
@@ -89,21 +86,17 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
/** String representation of this key. Cached for speed. */
|
||||
private transient String str;
|
||||
|
||||
// Constructor(s)
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convenience constructor. Calls the constructor with 5 arguments passing
|
||||
* {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
|
||||
* encoding format.
|
||||
*
|
||||
*
|
||||
* @param p the modulus first prime divisor.
|
||||
* @param q the modulus second prime divisor.
|
||||
* @param e the public exponent.
|
||||
* @param d the private exponent.
|
||||
*/
|
||||
public GnuRSAPrivateKey(BigInteger p, BigInteger q, BigInteger e,
|
||||
BigInteger d)
|
||||
public GnuRSAPrivateKey(BigInteger p, BigInteger q, BigInteger e, BigInteger d)
|
||||
{
|
||||
this(Registry.RAW_ENCODING_ID, p, q, e, d);
|
||||
}
|
||||
@@ -122,7 +115,9 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
public GnuRSAPrivateKey(int preferredFormat, BigInteger p, BigInteger q,
|
||||
BigInteger e, BigInteger d)
|
||||
{
|
||||
this(preferredFormat, p.multiply(q), e, d, p, q,
|
||||
this(preferredFormat,
|
||||
p.multiply(q),
|
||||
e, d, p, q,
|
||||
e.modInverse(p.subtract(BigInteger.ONE)),
|
||||
e.modInverse(q.subtract(BigInteger.ONE)),
|
||||
q.modInverse(p));
|
||||
@@ -135,19 +130,20 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
* @param preferredFormat the indetifier of the preferred encoding format to
|
||||
* use when externalizing this key.
|
||||
* @param n the public modulus, which is also the product of <code>p</code>
|
||||
* and <code>q</code>.
|
||||
* and <code>q</code>.
|
||||
* @param e the public exponent.
|
||||
* @param d the private exponent.
|
||||
* @param p the modulus first prime divisor.
|
||||
* @param q the modulus second prime divisor.
|
||||
* @param dP the first prime's exponen. A positive integer less than
|
||||
* <code>p</code> and <code>q</code>, satisfying <code>e * dP = 1 (mod p-1)
|
||||
* </code>.
|
||||
* <code>p</code> and <code>q</code>, satisfying
|
||||
* <code>e * dP = 1 (mod p-1)</code>.
|
||||
* @param dQ the second prime's exponent. A positive integer less than
|
||||
* <code>p</code> and <code>q</code>, satisfying <code>e * dQ = 1 (mod p-1)
|
||||
* </code>.
|
||||
* <code>p</code> and <code>q</code>, satisfying
|
||||
* <code>e * dQ = 1 (mod p-1)</code>.
|
||||
* @param qInv the Chinese Remainder Theorem coefiicient. A positive integer
|
||||
* less than <code>p</code>, satisfying <code>q * qInv = 1 (mod p)</code>.
|
||||
* less than <code>p</code>, satisfying
|
||||
* <code>q * qInv = 1 (mod p)</code>.
|
||||
*/
|
||||
public GnuRSAPrivateKey(int preferredFormat, BigInteger n, BigInteger e,
|
||||
BigInteger d, BigInteger p, BigInteger q,
|
||||
@@ -156,24 +152,20 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
|
||||
: preferredFormat,
|
||||
n, e);
|
||||
|
||||
this.d = d;
|
||||
this.p = p;
|
||||
this.q = q;
|
||||
// the exponents dP and dQ are positive integers less than p and q
|
||||
// respectively satisfying
|
||||
// e * dP = 1 (mod p-1);
|
||||
// e * dQ = 1 (mod q-1),
|
||||
// e * dP = 1 (mod p-1);
|
||||
// e * dQ = 1 (mod q-1),
|
||||
this.dP = dP;
|
||||
this.dQ = dQ;
|
||||
// the CRT coefficient qInv is a positive integer less than p satisfying
|
||||
// q * qInv = 1 (mod p).
|
||||
// q * qInv = 1 (mod p).
|
||||
this.qInv = qInv;
|
||||
}
|
||||
|
||||
// Class methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* A class method that takes the output of the <code>encodePrivateKey()</code>
|
||||
* method of an RSA keypair codec object (an instance implementing
|
||||
@@ -198,14 +190,10 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
catch (IllegalArgumentException ignored)
|
||||
{
|
||||
}
|
||||
|
||||
// try PKCS#8 codec
|
||||
return (GnuRSAPrivateKey) new RSAKeyPairPKCS8Codec().decodePrivateKey(k);
|
||||
}
|
||||
|
||||
// Instance methods
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
public BigInteger getPrimeP()
|
||||
{
|
||||
return p;
|
||||
@@ -231,22 +219,18 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
return qInv;
|
||||
}
|
||||
|
||||
// java.security.interfaces.RSAPrivateKey interface implementation ---------
|
||||
|
||||
public BigInteger getPrivateExponent()
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
||||
// Other instance methods --------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns the encoded form of this private key according to the
|
||||
* designated format.
|
||||
*
|
||||
* Returns the encoded form of this private key according to the designated
|
||||
* format.
|
||||
*
|
||||
* @param format the desired format identifier of the resulting encoding.
|
||||
* @return the byte sequence encoding this key according to the designated
|
||||
* format.
|
||||
* format.
|
||||
* @throws IllegalArgumentException if the format is not supported.
|
||||
* @see RSAKeyPairRawCodec
|
||||
* @see RSAKeyPairPKCS8Codec
|
||||
@@ -270,19 +254,18 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns <code>true</code> if the designated object is an instance of
|
||||
* this class and has the same RSA parameter values as this one.</p>
|
||||
*
|
||||
* Returns <code>true</code> if the designated object is an instance of this
|
||||
* class and has the same RSA parameter values as this one.
|
||||
*
|
||||
* @param obj the other non-null RSA key to compare to.
|
||||
* @return <code>true</code> if the designated object is of the same type
|
||||
* and value as this one.
|
||||
* and value as this one.
|
||||
*/
|
||||
public boolean equals(final Object obj)
|
||||
{
|
||||
if (obj == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (obj instanceof RSAPrivateKey)
|
||||
{
|
||||
final RSAPrivateKey that = (RSAPrivateKey) obj;
|
||||
@@ -304,16 +287,24 @@ public class GnuRSAPrivateKey extends GnuRSAKey implements PrivateKey,
|
||||
{
|
||||
if (str == null)
|
||||
{
|
||||
String ls = SystemProperties.getProperty("line.separator");
|
||||
String ls = (String) AccessController.doPrivileged
|
||||
(new GetPropertyAction("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();
|
||||
.append("d=0x").append(Configuration.DEBUG ? d.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append("p=0x").append(Configuration.DEBUG ? p.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append("q=0x").append(Configuration.DEBUG ? q.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append("dP=0x").append(Configuration.DEBUG ? dP.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append("dQ=0x").append(Configuration.DEBUG ? dQ.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append("qInv=0x").append(Configuration.DEBUG ? qInv.toString(16)
|
||||
: "**...*").append(ls)
|
||||
.append(")")
|
||||
.toString();
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user