Commit 7451c155 by Tom Tromey Committed by Tom Tromey

Makefile.in: Rebuilt.

	* Makefile.in: Rebuilt.
	* Makefile.am (ordinary_java_source_files): Added new files.
	* java/security/AlgorithmParameterGenerator.java,
	java/security/AlgorithmParameters.java, java/security/Engine.java,
	java/security/Identity.java, java/security/IdentityScope.java,
	java/security/KeyFactory.java,
	java/security/KeyPairGenerator.java, java/security/KeyStore.java,
	java/security/MessageDigest.java, java/security/Policy.java,
	java/security/ProtectionDomain.java,
	java/security/SecureRandom.java, java/security/Security.java,
	java/security/Signature.java, java/security/SignatureSpi.java,
	java/security/SignedObject.java, java/security/Signer.java,
	java/security/interfaces/RSAMultiPrimePrivateCrtKey.java,
	java/security/spec/PSSParameterSpec.java,
	java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java,
	java/security/spec/RSAOtherPrimeInfo.java: New versions from
	Classpath.

From-SVN: r65829
parent 9e9e2042
2003-04-19 Tom Tromey <tromey@redhat.com>
* Makefile.in: Rebuilt.
* Makefile.am (ordinary_java_source_files): Added new files.
* java/security/AlgorithmParameterGenerator.java,
java/security/AlgorithmParameters.java, java/security/Engine.java,
java/security/Identity.java, java/security/IdentityScope.java,
java/security/KeyFactory.java,
java/security/KeyPairGenerator.java, java/security/KeyStore.java,
java/security/MessageDigest.java, java/security/Policy.java,
java/security/ProtectionDomain.java,
java/security/SecureRandom.java, java/security/Security.java,
java/security/Signature.java, java/security/SignatureSpi.java,
java/security/SignedObject.java, java/security/Signer.java,
java/security/interfaces/RSAMultiPrimePrivateCrtKey.java,
java/security/spec/PSSParameterSpec.java,
java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java,
java/security/spec/RSAOtherPrimeInfo.java: New versions from
Classpath.
2003-04-19 Scott Gilbertson <scottg@mantatest.com>
* gnu/awt/xlib/XGraphics.java (XGraphics): Use new GC.create.
......
......@@ -2294,6 +2294,7 @@ java/security/DummySignature.java \
java/security/DigestInputStream.java \
java/security/DomainCombiner.java \
java/security/DummyMessageDigest.java \
java/security/Engine.java \
java/security/GeneralSecurityException.java \
java/security/Guard.java \
java/security/GuardedObject.java \
......@@ -2374,6 +2375,7 @@ java/security/interfaces/DSAParams.java \
java/security/interfaces/DSAPrivateKey.java \
java/security/interfaces/DSAPublicKey.java \
java/security/interfaces/RSAKey.java \
java/security/interfaces/RSAMultiPrimePrivateCrtKey.java \
java/security/interfaces/RSAPrivateCrtKey.java \
java/security/interfaces/RSAPrivateKey.java \
java/security/interfaces/RSAPublicKey.java \
......@@ -2386,7 +2388,10 @@ java/security/spec/InvalidKeySpecException.java \
java/security/spec/InvalidParameterSpecException.java \
java/security/spec/KeySpec.java \
java/security/spec/PKCS8EncodedKeySpec.java \
java/security/spec/PSSParameterSpec.java \
java/security/spec/RSAKeyGenParameterSpec.java \
java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java\
java/security/spec/RSAOtherPrimeInfo.java \
java/security/spec/RSAPrivateCrtKeySpec.java \
java/security/spec/RSAPrivateKeySpec.java \
java/security/spec/RSAPublicKeySpec.java \
......
......@@ -2056,6 +2056,7 @@ java/security/DummySignature.java \
java/security/DigestInputStream.java \
java/security/DomainCombiner.java \
java/security/DummyMessageDigest.java \
java/security/Engine.java \
java/security/GeneralSecurityException.java \
java/security/Guard.java \
java/security/GuardedObject.java \
......@@ -2136,6 +2137,7 @@ java/security/interfaces/DSAParams.java \
java/security/interfaces/DSAPrivateKey.java \
java/security/interfaces/DSAPublicKey.java \
java/security/interfaces/RSAKey.java \
java/security/interfaces/RSAMultiPrimePrivateCrtKey.java \
java/security/interfaces/RSAPrivateCrtKey.java \
java/security/interfaces/RSAPrivateKey.java \
java/security/interfaces/RSAPublicKey.java \
......@@ -2148,7 +2150,10 @@ java/security/spec/InvalidKeySpecException.java \
java/security/spec/InvalidParameterSpecException.java \
java/security/spec/KeySpec.java \
java/security/spec/PKCS8EncodedKeySpec.java \
java/security/spec/PSSParameterSpec.java \
java/security/spec/RSAKeyGenParameterSpec.java \
java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java\
java/security/spec/RSAOtherPrimeInfo.java \
java/security/spec/RSAPrivateCrtKeySpec.java \
java/security/spec/RSAPrivateKeySpec.java \
java/security/spec/RSAPublicKeySpec.java \
......@@ -3571,7 +3576,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/security/DomainCombiner.P \
.deps/java/security/DummyKeyPairGenerator.P \
.deps/java/security/DummyMessageDigest.P \
.deps/java/security/DummySignature.P \
.deps/java/security/DummySignature.P .deps/java/security/Engine.P \
.deps/java/security/GeneralSecurityException.P \
.deps/java/security/Guard.P .deps/java/security/GuardedObject.P \
.deps/java/security/Identity.P .deps/java/security/IdentityScope.P \
......@@ -3636,6 +3641,7 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/security/interfaces/DSAPrivateKey.P \
.deps/java/security/interfaces/DSAPublicKey.P \
.deps/java/security/interfaces/RSAKey.P \
.deps/java/security/interfaces/RSAMultiPrimePrivateCrtKey.P \
.deps/java/security/interfaces/RSAPrivateCrtKey.P \
.deps/java/security/interfaces/RSAPrivateKey.P \
.deps/java/security/interfaces/RSAPublicKey.P \
......@@ -3648,7 +3654,10 @@ DEP_FILES = .deps/$(srcdir)/$(CONVERT_DIR)/gen-from-JIS.P \
.deps/java/security/spec/InvalidParameterSpecException.P \
.deps/java/security/spec/KeySpec.P \
.deps/java/security/spec/PKCS8EncodedKeySpec.P \
.deps/java/security/spec/PSSParameterSpec.P \
.deps/java/security/spec/RSAKeyGenParameterSpec.P \
.deps/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.P \
.deps/java/security/spec/RSAOtherPrimeInfo.P \
.deps/java/security/spec/RSAPrivateCrtKeySpec.P \
.deps/java/security/spec/RSAPrivateKeySpec.P \
.deps/java/security/spec/RSAPublicKeySpec.P \
......
/* Engine -- generic getInstance method.
Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security;
/**
* Generic implementation of the getInstance methods in the various
* engine classes in java.security.
* <p>
* These classes ({@link java.security.Signature} for example) can be
* thought of as the "chrome, upholstery, and steering wheel", and the SPI
* (service provider interface, e.g. {@link java.security.SignatureSpi})
* classes can be thought of as the "engine" -- providing the actual
* functionality of whatever cryptographic algorithm the instance
* represents.
*
* @see Provider
* @author Casey Marshall
*/
final class Engine
{
// Constants.
// ------------------------------------------------------------------------
/** Prefix for aliases. */
private static final String ALG_ALIAS = "Alg.Alias.";
/** Maximum number of aliases to try. */
private static final int MAX_ALIASES = 5;
// Constructor.
// ------------------------------------------------------------------------
/** This class cannot be instantiated. */
private Engine() { }
// Class method.
// ------------------------------------------------------------------------
/**
* Get the implementation for <i>algorithm</i> for service
* <i>service</i> from <i>provider</i>. The service is e.g.
* "Signature", and the algorithm "DSA".
*
* @param service The service name.
* @param algorithm The name of the algorithm to get.
* @param provider The provider to get the implementation from.
* @return The engine class for the specified algorithm; the object
* returned is typically a subclass of the SPI class for that
* service, but callers should check that this is so.
* @throws NoSuchAlgorithmException If the implementation cannot be
* found or cannot be instantiated.
* @throws IllegalArgumentException If any of the three arguments are null.
*/
static Object
getInstance(String service, String algorithm, Provider provider)
throws NoSuchAlgorithmException
{
if (service == null || algorithm == null || provider == null)
throw new IllegalArgumentException();
// If there is no property "service.algorithm"
if (provider.getProperty(service + "." + algorithm) == null)
{
// Iterate through aliases, until we find the class name or resolve
// too many aliases.
String alias = null;
int count = 0;
while ((alias = provider.getProperty(
ALG_ALIAS + service + "." + algorithm)) != null)
{
if (algorithm.equals(alias)) // Refers to itself!
break;
algorithm = alias;
if (count++ > MAX_ALIASES)
throw new NoSuchAlgorithmException("too many aliases");
}
if (provider.getProperty(service + "." + algorithm) == null)
throw new NoSuchAlgorithmException(algorithm);
}
// Find and instantiate the implementation.
Class clazz = null;
ClassLoader loader = provider.getClass().getClassLoader();
String error = algorithm;
try
{
if (loader != null)
clazz = loader.loadClass(provider.getProperty(service+"."+algorithm));
else
clazz = Class.forName(provider.getProperty(service+"."+algorithm));
return clazz.newInstance();
}
catch (ClassNotFoundException cnfe)
{
error = "class not found: " + algorithm;
}
catch (IllegalAccessException iae)
{
error = "illegal access: " + iae.getMessage();
}
catch (InstantiationException ie)
{
error = "instantiation exception: " + ie.getMessage();
}
catch (ExceptionInInitializerError eiie)
{
error = "exception in initializer: " + eiie.getMessage();
}
catch (SecurityException se)
{
error = "security exception: " + se.getMessage();
}
throw new NoSuchAlgorithmException(error);
}
}
/* IdentityScope.java --- IdentityScope Class
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -36,33 +36,46 @@ obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security;
import java.util.Enumeration;
/**
IdentityScope represents a scope of an identity. IdentityScope
is also an Identity and can have a name and scope along with
the other qualitites identities posses.
An IdentityScope contains other Identity objects. All Identity
objects are manipulated in the scope the same way. The scope
is suppose to apply different scope to different type of
Identities.
No identity within the same scope can have the same public key.
@since JDK 1.1
@deprecated Use java.security.KeyStore, the java.security.cert
package, and java.security.Principal.
@author Mark Benvenuto
* <p>This class represents a scope for identities. It is an Identity itself,
* and therefore has a name and can have a scope. It can also optionally have a
* public key and associated certificates.</p>
*
* <p>An <code>IdentityScope</code> can contain {@link Identity} objects of all
* kinds, including {@link Signer}s. All types of <code>Identity</code> objects
* can be retrieved, added, and removed using the same methods. Note that it is
* possible, and in fact expected, that different types of identity scopes will
* apply different policies for their various operations on the various types of
* Identities.</p>
*
* <p>There is a one-to-one mapping between keys and identities, and there can
* only be one copy of one key per scope. For example, suppose Acme Software,
* Inc is a software publisher known to a user. Suppose it is an <i>Identity</i>,
* that is, it has a public key, and a set of associated certificates. It is
* named in the scope using the name "Acme Software". No other named <i>Identity
* </i> in the scope has the same public key. Of course, none has the same name
* as well.</p>
*
* @author Mark Benvenuto
* @see Identity
* @see Signer
* @see Principal
* @see Key
* @deprecated This class is no longer used. Its functionality has been replaced
* by <code>java.security.KeyStore</code>, the <code>java.security.cert</code>
* package, and <code>java.security.Principal</code>.
*/
public abstract class IdentityScope extends Identity
{
static final long serialVersionUID = -2337346281189773310L;
private static IdentityScope systemScope = null;
/**
Creates a new instance of IdentityScope from Serialized Data
* This constructor is used for serialization only and should not be used by
* subclasses.
*/
protected IdentityScope()
{
......@@ -70,10 +83,9 @@ public abstract class IdentityScope extends Identity
}
/**
Creates a new instance of IdentityScope with the specified name
and no scope.
@param name the name to use
* Constructs a new identity scope with the specified name.
*
* @param name the scope name.
*/
public IdentityScope(String name)
{
......@@ -81,14 +93,12 @@ public abstract class IdentityScope extends Identity
}
/**
Creates a new instance of IdentityScope with the specified name
and IdentityScope.
@param name the name to use
@param scope the scope to use
@throws KeyManagementException if the identity scope is already
present
* Constructs a new identity scope with the specified name and scope.
*
* @param name the scope name.
* @param scope the scope for the new identity scope.
* @throws KeyManagementException if there is already an identity with the
* same name in the scope.
*/
public IdentityScope(String name, IdentityScope scope)
throws KeyManagementException
......@@ -97,7 +107,10 @@ public abstract class IdentityScope extends Identity
}
/**
Gets the system's Scope.
* Returns the system's identity scope.
*
* @return the system's identity scope.
* @see #setSystemScope(IdentityScope)
*/
public static IdentityScope getSystemScope()
{
......@@ -110,15 +123,18 @@ public abstract class IdentityScope extends Identity
}
/**
Sets the scope of the system.
This class checks the security manager with the call
checkSecurityAccess with "setSystemScope".
@param scope the new sustem scope
@throws SecurityException - if the security manager denies
access to "setSystemScope"
* <p>Sets the system's identity scope.</p>
*
* <p>First, if there is a security manager, its <code>checkSecurityAccess()
* </code> method is called with <code>"setSystemScope"</code> as its argument
* to see if it's ok to set the identity scope.</p>
*
* @param scope the scope to set.
* @throws SecurityException if a security manager exists and its
* <code>checkSecurityAccess()<code> method doesn't allow setting the
* identity scope.
* @see #getSystemScope()
* @see SecurityManager#checkSecurityAccess(String)
*/
protected static void setSystemScope(IdentityScope scope)
{
......@@ -130,31 +146,29 @@ public abstract class IdentityScope extends Identity
}
/**
Gets the number of entries within this IdentityScope.
@returns the number of entries
* Returns the number of identities within this identity scope.
*
* @return the number of identities within this identity scope.
*/
public abstract int size();
/**
Gets the specified Identity within this scope
by specified name.
@param name name of Identity to get
@returns an identity representing the name or null if it
cannot be found
* Returns the identity in this scope with the specified name (if any).
*
* @param name the name of the identity to be retrieved.
* @return the identity named name, or <code>null</code> if there are no
* identities named name in this scope.
*/
public abstract Identity getIdentity(String name);
/**
Gets the specified Identity within this scope
by the specified Principal.
@param principal The Principal of the Identity to get
@returns an identity representing the principal or null if it
cannot be found
* Retrieves the identity whose name is the same as that of the specified
* principal. (Note: <code>Identity</code> implements <code>Principal</code>.)
*
* @param principal the principal corresponding to the identity to be
* retrieved.
* @return the identity whose name is the same as that of the principal, or
* <code>null</code> if there are no identities of the same name in this scope.
*/
public Identity getIdentity(Principal principal)
{
......@@ -162,55 +176,51 @@ public abstract class IdentityScope extends Identity
}
/**
Gets the specified Identity within this scope
by the specified public key.
@param key the PublicKey of the Identity to get
@returns an identity representing the public key or null if it
cannot be found
* Retrieves the identity with the specified public key.
*
* @param key the public key for the identity to be returned.
* @return the identity with the given key, or <code>null</code> if there are
* no identities in this scope with that key.
*/
public abstract Identity getIdentity(PublicKey key);
/**
Adds an identity to his scope.
@param identity the identity to add
@throws KeyManagementException if it is an invalid identity,
an identity with the same key exists, or another error
occurs.
* Adds an identity to this identity scope.
*
* @param identity the identity to be added.
* @throws KeyManagementException if the identity is not valid, a name
* conflict occurs, another identity has the same public key as the identity
* being added, or another exception occurs.
*/
public abstract void addIdentity(Identity identity)
throws KeyManagementException;
/**
Removes an identity to his scope.
@param identity the identity to remove
@throws KeyManagementException if it is a missing identity,
or another error occurs.
* Removes an identity from this identity scope.
*
* @param identity the identity to be removed.
* @throws KeyManagementException if the identity is missing, or another
* exception occurs.
*/
public abstract void removeIdentity(Identity identity)
throws KeyManagementException;
/**
Returns an Enumeration of identities.
@returns an enumeration of the identities.
* Returns an enumeration of all identities in this identity scope.
*
* @return an enumeration of all identities in this identity scope.
*/
public abstract Enumeration identities();
/**
Returns a string representing this IdentityScope.
It includes the name, the scope name, and number of identities.
@returns a string representing this IdentityScope.
* Returns a string representation of this identity scope, including its name,
* its scope name, and the number of identities in this identity scope.
*
* @return a string representation of this identity scope.
* @see SecurityManager#checkSecurityAccess(String)
*/
public String toString()
{
return (super.getName() + " " + super.getScope().getName()
+ " " + size());
return (super.getName() + " " + super.getScope().getName() + " " + size());
}
}
/* KeyStore.java --- Key Store Class
Copyright (C) 1999, 2002 Free Software Foundation, Inc.
Copyright (C) 1999, 2002, 2003 Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -44,37 +44,52 @@ import java.util.Date;
import java.util.Enumeration;
/**
Keystore represents an in-memory collection of keys and
certificates. There are two types of entries:
* Key Entry
This type of keystore entry store sensitive crytographic key
information in a protected format.Typically this is a secret
key or a private key with a certificate chain.
* Trusted Ceritificate Entry
This type of keystore entry contains a single public key
certificate belonging to annother entity. It is called trusted
because the keystore owner trusts that the certificates
belongs to the subject (owner) of the certificate.
The keystore contains an "alias" string for each entry.
The structure and persistentence of the key store is not
specified. Any method could be used to protect sensitive
(private or secret) keys. Smart cards or integrated
cryptographic engines could be used or the keystore could
be simply stored in a file.
* Keystore represents an in-memory collection of keys and
* certificates. There are two types of entries:
*
* <dl>
* <dt>Key Entry</dt>
*
* <dd><p>This type of keystore entry store sensitive crytographic key
* information in a protected format.Typically this is a secret
* key or a private key with a certificate chain.</p></dd>
*
* <dt>Trusted Ceritificate Entry</dt>
*
* <dd><p>This type of keystore entry contains a single public key
* certificate belonging to annother entity. It is called trusted
* because the keystore owner trusts that the certificates
* belongs to the subject (owner) of the certificate.</p></dd>
* </dl>
*
* <p>Entries in a key store are referred to by their "alias": a simple
* unique string.
*
* <p>The structure and persistentence of the key store is not
* specified. Any method could be used to protect sensitive
* (private or secret) keys. Smart cards or integrated
* cryptographic engines could be used or the keystore could
* be simply stored in a file.</p>
*
* @see java.security.cert.Certificate
* @see Key
*/
public class KeyStore
{
// Constants and fields.
// ------------------------------------------------------------------------
/** Service name for key stores. */
private static final String KEY_STORE = "KeyStore";
private KeyStoreSpi keyStoreSpi;
private Provider provider;
private String type;
// Constructors.
// ------------------------------------------------------------------------
/**
Creates an instance of KeyStore
......@@ -89,16 +104,18 @@ public class KeyStore
this.type = type;
}
/**
Gets an instance of the KeyStore class representing
the specified keystore. If the type is not
found then, it throws KeyStoreException.
@param type the type of keystore to choose
@return a KeyStore repesenting the desired type
// Class methods.
// ------------------------------------------------------------------------
@throws KeyStoreException if the type of keystore is not implemented by providers
/**
* Gets an instance of the KeyStore class representing
* the specified keystore. If the type is not
* found then, it throws KeyStoreException.
*
* @param type the type of keystore to choose
* @return a KeyStore repesenting the desired type
* @throws KeyStoreException if the type of keystore is not implemented
* by providers or the implementation cannot be instantiated.
*/
public static KeyStore getInstance(String type) throws KeyStoreException
{
......@@ -106,95 +123,102 @@ public class KeyStore
for (int i = 0; i < p.length; i++)
{
String classname = p[i].getProperty("KeyStore." + type);
if (classname != null)
return getInstance(classname, type, p[i]);
try
{
return getInstance(type, p[i]);
}
catch (KeyStoreException ignore)
{
}
}
throw new KeyStoreException(type);
}
/**
Gets an instance of the KeyStore class representing
the specified key store from the specified provider.
If the type is not found then, it throws KeyStoreException.
If the provider is not found, then it throws
NoSuchProviderException.
@param type the type of keystore to choose
@param provider the provider name
@return a KeyStore repesenting the desired type
@throws KeyStoreException if the type of keystore is not
implemented by the given provider
@throws NoSuchProviderException if the provider is not found
@throws IllegalArgumentException if the provider string is
null or empty
* Gets an instance of the KeyStore class representing
* the specified key store from the specified provider.
* If the type is not found then, it throws KeyStoreException.
* If the provider is not found, then it throws
* NoSuchProviderException.
*
* @param type the type of keystore to choose
* @param provider the provider name
* @return a KeyStore repesenting the desired type
* @throws KeyStoreException if the type of keystore is not
* implemented by the given provider
* @throws NoSuchProviderException if the provider is not found
* @throws IllegalArgumentException if the provider string is
* null or empty
*/
public static KeyStore getInstance(String type, String provider)
throws KeyStoreException, NoSuchProviderException
{
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("Illegal provider");
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException();
return getInstance(p.getProperty("KeyStore." + type), type, p);
return getInstance(type, p);
}
/**
Gets an instance of the KeyStore class representing
the specified key store from the specified provider.
If the type is not found then, it throws KeyStoreException.
If the provider is not found, then it throws
NoSuchProviderException.
@param type the type of keystore to choose
@param provider the keystore provider
@return a KeyStore repesenting the desired type
@throws KeyStoreException if the type of keystore is not
implemented by the given provider
@throws IllegalArgumentException if the provider object is null
@since 1.4
* Gets an instance of the KeyStore class representing
* the specified key store from the specified provider.
* If the type is not found then, it throws KeyStoreException.
* If the provider is not found, then it throws
* NoSuchProviderException.
*
* @param type the type of keystore to choose
* @param provider the keystore provider
* @return a KeyStore repesenting the desired type
* @throws KeyStoreException if the type of keystore is not
* implemented by the given provider
* @throws IllegalArgumentException if the provider object is null
* @since 1.4
*/
public static KeyStore getInstance(String type, Provider provider)
throws KeyStoreException
{
if (provider == null)
throw new IllegalArgumentException("Illegal provider");
return getInstance(provider.getProperty("KeyStore." + type),
type, provider);
}
private static KeyStore getInstance(String classname,
String type,
Provider provider)
throws KeyStoreException
{
try
{
return new KeyStore((KeyStoreSpi) Class.forName(classname).
newInstance(), provider, type);
return new KeyStore(
(KeyStoreSpi) Engine.getInstance(KEY_STORE, type, provider),
provider, type);
}
catch (ClassNotFoundException cnfe)
catch (NoSuchAlgorithmException nsae)
{
throw new KeyStoreException("Class not found");
throw new KeyStoreException(type);
}
catch (InstantiationException ie)
catch (ClassCastException cce)
{
throw new KeyStoreException("Class instantiation failed");
}
catch (IllegalAccessException iae)
{
throw new KeyStoreException("Illegal Access");
throw new KeyStoreException(type);
}
}
/**
* Returns the default KeyStore type. This method looks up the
* type in <JAVA_HOME>/lib/security/java.security with the
* property "keystore.type" or if that fails then "jks" .
*/
public static final String getDefaultType()
{
// Security reads every property in java.security so it
// will return this property if it exists.
String tmp = Security.getProperty("keystore.type");
if (tmp == null)
tmp = "jks";
return tmp;
}
// Instance methods.
// ------------------------------------------------------------------------
/**
Gets the provider that the class is from.
......@@ -471,21 +495,4 @@ public class KeyStore
keyStoreSpi.engineLoad(stream, password);
}
/**
Returns the default KeyStore type. This method looks up the
type in <JAVA_HOME>/lib/security/java.security with the
property "keystore.type" or if that fails then "jks" .
*/
public static final String getDefaultType()
{
String tmp;
//Security reads every property in java.security so it
//will return this property if it exists.
tmp = Security.getProperty("keystore.type");
if (tmp == null)
tmp = "jks";
return tmp;
}
}
......@@ -42,14 +42,24 @@ import java.util.Random;
import java.util.Enumeration;
/**
SecureRandom is the class interface for using SecureRandom
providers. It provides an interface to the SecureRandomSpi
engine so that programmers can generate pseudo-random numbers.
@author Mark Benvenuto <ivymccough@worldnet.att.net>
* An interface to a cryptographically secure pseudo-random number
* generator (PRNG). Random (or at least unguessable) numbers are used
* in all areas of security and cryptography, from the generation of
* keys and initialization vectors to the generation of random padding
* bytes.
*
* @author Mark Benvenuto <ivymccough@worldnet.att.net>
* @author Casey Marshall
*/
public class SecureRandom extends Random
{
// Constants and fields.
// ------------------------------------------------------------------------
/** Service name for PRNGs. */
private static final String SECURE_RANDOM = "SecureRandom";
static final long serialVersionUID = 4940670005562187L;
//Serialized Field
......@@ -60,6 +70,9 @@ public class SecureRandom extends Random
SecureRandomSpi secureRandomSpi = null;
byte[] state = null;
// Constructors.
// ------------------------------------------------------------------------
/**
Default constructor for SecureRandom. It constructs a
new SecureRandom by instantating the first SecureRandom
......@@ -69,7 +82,7 @@ public class SecureRandom extends Random
on the first call to getnextBytes it will force a seed.
It is maintained for backwards compatibility and programs
should use getInstance.
should use {@link #getInstance(java.lang.String)}.
*/
public SecureRandom()
{
......@@ -88,20 +101,20 @@ public class SecureRandom extends Random
{
key = (String) e.nextElement();
if (key.startsWith("SECURERANDOM."))
{
if ((classname = p[i].getProperty(key)) != null)
{
try
{
secureRandomSpi = (SecureRandomSpi) Class.
forName(classname).newInstance();
provider = p[i];
return;
}
catch (Throwable ignore) { }
}
}
}
{
if ((classname = p[i].getProperty(key)) != null)
{
try
{
secureRandomSpi = (SecureRandomSpi) Class.
forName(classname).newInstance();
provider = p[i];
return;
}
catch (Throwable ignore) { }
}
}
}
}
// Nothing found. Fall back to SHA1PRNG
......@@ -141,15 +154,17 @@ public class SecureRandom extends Random
this.provider = provider;
}
/**
Returns an instance of a SecureRandom. It creates the class
for the specified algorithm if it exists from a provider.
@param algorithm A SecureRandom algorithm to use
// Class methods.
// ------------------------------------------------------------------------
@return Returns a new SecureRandom implmenting the chosen algorithm
@throws NoSuchAlgorithmException if the algorithm cannot be found
/**
* Returns an instance of a SecureRandom. It creates the class from
* the first provider that implements it.
*
* @param algorithm The algorithm name.
* @return A new SecureRandom implmenting the given algorithm.
* @throws NoSuchAlgorithmException If no installed provider implements
* the given algorithm.
*/
public static SecureRandom getInstance(String algorithm) throws
NoSuchAlgorithmException
......@@ -157,11 +172,13 @@ public class SecureRandom extends Random
Provider p[] = Security.getProviders();
for (int i = 0; i < p.length; i++)
{
try
{
return getInstance(algorithm, p[i]);
}
catch (NoSuchAlgorithmException ignored) { }
try
{
return getInstance(algorithm, p[i]);
}
catch (NoSuchAlgorithmException ignored)
{
}
}
// None found.
......@@ -169,21 +186,26 @@ public class SecureRandom extends Random
}
/**
Returns an instance of a SecureRandom. It creates the class
for the specified algorithm from the specified provider.
@param algorithm A SecureRandom algorithm to use
@param provider A security provider to use
@return Returns a new SecureRandom implmenting the chosen algorithm
@throws NoSuchAlgorithmException if the algorithm cannot be found
@throws NoSuchProviderException if the provider cannot be found
* Returns an instance of a SecureRandom. It creates the class
* for the specified algorithm from the named provider.
*
* @param algorithm The algorithm name.
* @param provider The provider name.
* @return A new SecureRandom implmenting the chosen algorithm.
* @throws NoSuchAlgorithmException If the named provider does not implement
* the algorithm, or if the implementation cannot be
* instantiated.
* @throws NoSuchProviderException If no provider named
* <code>provider</code> is currently installed.
* @throws IllegalArgumentException If <code>provider</code> is null
* or is empty.
*/
public static SecureRandom getInstance(String algorithm,
String provider) throws
NoSuchAlgorithmException, NoSuchProviderException
public static SecureRandom getInstance(String algorithm, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException
{
if (provider == null || provider.length() == 0)
throw new IllegalArgumentException("Illegal provider");
Provider p = Security.getProvider(provider);
if (p == null)
throw new NoSuchProviderException();
......@@ -192,88 +214,35 @@ public class SecureRandom extends Random
}
/**
Returns an instance of a SecureRandom. It creates the class for
the specified algorithm from the given provider.
@param algorithm The SecureRandom algorithm to create.
@param provider The provider to get the instance from.
@throws NoSuchAlgorithmException If the algorithm cannot be found, or
if the class cannot be instantiated.
* Returns an instance of a SecureRandom. It creates the class for
* the specified algorithm from the given provider.
*
* @param algorithm The SecureRandom algorithm to create.
* @param provider The provider to get the instance from.
* @throws NoSuchAlgorithmException If the algorithm cannot be found, or
* if the class cannot be instantiated.
* @throws IllegalArgumentException If <code>provider</code> is null.
*/
public static SecureRandom getInstance(String algorithm,
Provider provider) throws
NoSuchAlgorithmException
public static SecureRandom getInstance(String algorithm, Provider provider)
throws NoSuchAlgorithmException
{
return getInstance(algorithm, provider, true);
}
/**
Creates the instance of SecureRandom, recursing to resolve aliases.
@param algorithm The SecureRandom algorithm to create.
@param provider The provider to get the implementation from.
@param recurse Whether or not to recurse to resolve aliases.
@throws NoSuchAlgorithmException If the algorithm cannot be found,
if there are too many aliases, or if the class cannot be
instantiated.
*/
private static SecureRandom getInstance(String algorithm,
Provider provider,
boolean recurse)
throws NoSuchAlgorithmException
{
String msg = algorithm;
for (Enumeration e = provider.propertyNames(); e.hasMoreElements(); )
if (provider == null)
throw new IllegalArgumentException("Illegal provider");
try
{
// We could replace the boolean with an integer, incrementing it
// every
String key = (String) e.nextElement();
if (key.startsWith("SECURERANDOM.")
&& key.substring(13).equalsIgnoreCase(algorithm))
{
try
{
Class c = Class.forName(provider.getProperty(key));
return new SecureRandom((SecureRandomSpi) c.newInstance(),
provider);
}
catch (Throwable ignored) { }
}
else if (key.startsWith("ALG.ALIAS.SECURERANDOM.")
&& key.substring(23).equalsIgnoreCase(algorithm) && recurse)
{
try
{
// First see if this alias refers to a class in this
// provider.
return getInstance(provider.getProperty(key), provider, false);
}
catch (NoSuchAlgorithmException nsae)
{
Provider[] provs = Security.getProviders();
for (int i = 0; i < provs.length; i++)
{
if (provs[i] == provider)
continue;
// Now try other providers for the implementation
try
{
return getInstance(provider.getProperty(key),
provs[i], false);
}
catch (NoSuchAlgorithmException nsae2)
{
msg = nsae2.getMessage();
}
}
}
}
return new SecureRandom((SecureRandomSpi)
Engine.getInstance(SECURE_RANDOM, algorithm, provider),
provider);
}
catch (ClassCastException cce)
{
throw new NoSuchAlgorithmException(algorithm);
}
throw new NoSuchAlgorithmException(algorithm);
}
// Instance methods.
// ------------------------------------------------------------------------
/**
Returns the provider being used by the current SecureRandom class.
......@@ -318,8 +287,8 @@ public class SecureRandom extends Random
(byte) (0xff & (seed >> 16)),
(byte) (0xff & (seed >> 8)),
(byte) (0xff & seed)
};
secureRandomSpi.engineSetSeed(tmp);
};
secureRandomSpi.engineSetSeed(tmp);
}
}
......
/* Signer.java --- Signer Class
Copyright (C) 1999 Free Software Foundation, Inc.
Copyright (C) 1999, 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
......@@ -38,28 +38,35 @@ exception statement from your version. */
package java.security;
/**
Signer is a subclass used to store a digital signature key with
an Identity.
@author Mark Benvenuto <ivymccough@worldnet.att.net>
@since JDK 1.1
* <p>This class is used to represent an {@link Identity} that can also
* digitally sign data.</p>
*
* <p>The management of a signer's private keys is an important and sensitive
* issue that should be handled by subclasses as appropriate to their intended
* use.</p>
*
* @author Mark Benvenuto <ivymccough@worldnet.att.net>
* @deprecated This class is no longer used. Its functionality has been replaced
* by <code>java.security.KeyStore</code>, the <code>java.security.cert</code>
* package, and <code>java.security.Principal</code>.
*/
public abstract class Signer extends Identity
{
static final long serialVersionUID = -1763464102261361480L;
private PrivateKey privateKey = null;
/**
Constructs a new Signer.
* Creates a <code>Signer</code>. This constructor should only be used for
* serialization.
*/
protected Signer()
{
}
/**
Constructs a new Signer with the specified name.
@param name the name of the identity.
* Creates a <code>Signer</code> with the specified identity name.
*
* @param name the identity name.
*/
public Signer(String name)
{
......@@ -67,31 +74,31 @@ public abstract class Signer extends Identity
}
/**
Constructs a new Signer with the specifid name and
IdentityScope.
@param name the name of the identity.
@scope the IdentityScope to use
@throws KeyManagementException if duplicate identity name
within scope
* Creates a <code>Signer</code> with the specified identity name and scope.
*
* @param name the identity name.
* @param scope the scope of the identity.
* @throws KeyManagementException if there is already an identity with the
* same name in the scope.
*/
public Signer(String name, IdentityScope scope)
throws KeyManagementException
public Signer(String name, IdentityScope scope) throws KeyManagementException
{
super(name, scope);
}
/**
Returns the private key for this signer.
This class checks the security manager with the call
checkSecurityAccess with "getSignerPrivateKey".
@returns the private key for the signer
@throws SecurityException - if the security manager denies
access to "getSignerPrivateKey"
* <p>Returns this signer's private key.</p>
*
* <p>First, if there is a security manager, its <code>checkSecurityAccess()
* </code> method is called with <code>"getSignerPrivateKey"</code> as its
* argument to see if it's ok to return the private key.</p>
*
* @return this signer's private key, or <code>null</code> if the private key
* has not yet been set.
* @throws SecurityException if a security manager exists and its
* <code>checkSecurityAccess()</code> method doesn't allow returning the
* private key.
* @see SecurityManager#checkSecurityAccess(String)
*/
public PrivateKey getPrivateKey()
{
......@@ -103,17 +110,20 @@ public abstract class Signer extends Identity
}
/**
Specifies the KeyPair associated with this Signer.
This class checks the security manager with the call
checkSecurityAccess with "setSignerKeyPair".
@param pair the keyPair
@throws InvalidParameterException invalidly intialized key pair
@throws KeyException another key error
@throws SecurityException - if the security manager denies
access to "getSignerPrivateKey"
* <p>Sets the key pair (public key and private key) for this signer.</p>
*
* <p>First, if there is a security manager, its <code>checkSecurityAccess()
* </code> method is called with <code>"setSignerKeyPair"</code> as its
* argument to see if it's ok to set the key pair.</p>
*
* @param pair an initialized key pair.
* @throws InvalidParameterException if the key pair is not properly
* initialized.
* @throws KeyException if the key pair cannot be set for any other reason.
* @throws SecurityException if a security manager exists and its
* <code>checkSecurityAccess()</code> method doesn't allow setting the key
* pair.
* @see SecurityManager#checkSecurityAccess(String)
*/
public final void setKeyPair(KeyPair pair)
throws InvalidParameterException, KeyException
......@@ -124,15 +134,15 @@ public abstract class Signer extends Identity
try
{
if (pair.getPublic() != null)
setPublicKey(pair.getPublic());
else
throw new InvalidParameterException();
if (pair.getPublic() != null)
setPublicKey(pair.getPublic());
else
throw new InvalidParameterException();
}
catch (KeyManagementException kme)
{
throw new KeyException();
throw new KeyException();
}
if (pair.getPrivate() != null)
......@@ -142,9 +152,10 @@ public abstract class Signer extends Identity
}
/**
Returns a string representing this Signer.
@returns a string representing this Signer.
* Returns a string of information about the signer.
*
* @return a string of information about the signer.
* @see SecurityManager#checkSecurityAccess(String)
*/
public String toString()
{
......
/* RSAMultiPrimePrivateCrtKey.java --
Copyright (C) 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security.interfaces;
import java.math.BigInteger;
import java.security.spec.RSAOtherPrimeInfo;
/**
* The interface to an RSA multi-prime private key, as defined in the PKCS#1
* v2.1, using the <i>Chinese Remainder Theorem</i> (CRT) information values.
*
* @since 1.4
* @see java.security.spec.RSAPrivateKeySpec
* @see java.security.spec.RSAMultiPrimePrivateCrtKeySpec
* @see RSAPrivateKey
* @see RSAPrivateCrtKey
*/
public interface RSAMultiPrimePrivateCrtKey extends RSAPrivateKey
{
// Constants
// --------------------------------------------------------------------------
// Methods
// --------------------------------------------------------------------------
/**
* Returns the public exponent.
*
* @return the public exponent.
*/
BigInteger getPublicExponent();
/**
* Returns the primeP.
*
* @return the primeP.
*/
BigInteger getPrimeP();
/**
* Returns the primeQ.
*
* @return the primeQ.
*/
BigInteger getPrimeQ();
/**
* Returns the primeExponentP.
*
* @return the primeExponentP.
*/
BigInteger getPrimeExponentP();
/**
* Returns the primeExponentQ.
*
* @return the primeExponentQ.
*/
BigInteger getPrimeExponentQ();
/**
* Returns the crtCoefficient.
*
* @return the crtCoefficient.
*/
BigInteger getCrtCoefficient();
/**
* Returns the otherPrimeInfo or <code>null</code> if there are only two
* prime factors (p and q).
*
* @return the otherPrimeInfo.
*/
RSAOtherPrimeInfo[] getOtherPrimeInfo();
}
/* PSSParameterSpec.java --
Copyright (C) 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security.spec;
/**
* This class specifies a parameter spec for RSA PSS encoding scheme, as
* defined in the PKCS#1 v2.1.
*
* @since 1.4
* @see AlgorithmParameterSpec
* @see java.security.Signature
*/
public class PSSParameterSpec implements AlgorithmParameterSpec
{
// Constants and fields
// --------------------------------------------------------------------------
private int saltLen;
// Constructor(s)
// --------------------------------------------------------------------------
/**
* Creates a new <code>PSSParameterSpec</code> given the salt length as
* defined in PKCS#1.
*
* @param saltLen the length of salt in bits to be used in PKCS#1 PSS encoding.
* @throws IllegalArgumentException if <code>saltLen</code> is less than
* <code>0</code>.
*/
public PSSParameterSpec(int saltLen)
{
super();
if (saltLen < 0)
throw new IllegalArgumentException();
this.saltLen = saltLen;
}
// Class methods
// --------------------------------------------------------------------------
// Instance methods
// --------------------------------------------------------------------------
/**
* Returns the salt length in bits.
*
* @return the salt length.
*/
public int getSaltLength()
{
return this.saltLen;
}
}
/* PSSParameterSpec.java --
Copyright (C) 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security.spec;
import java.math.BigInteger;
import java.security.spec.RSAOtherPrimeInfo;
/**
* This class specifies an RSA multi-prime private key, as defined in the
* PKCS#1 v2.1, using the <i>Chinese Remainder Theorem</i> (CRT) information
* values for efficiency.
*
* @since 1.4
* @see java.security.Key
* @see java.security.KeyFactory
* @see KeySpec
* @see PKCS8EncodedKeySpec
* @see RSAPrivateKeySpec
* @see RSAPublicKeySpec
* @see RSAOtherPrimeInfo
*/
public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec
{
// Constants and fields
// --------------------------------------------------------------------------
private BigInteger publicExponent;
private BigInteger primeP;
private BigInteger primeQ;
private BigInteger primeExponentP;
private BigInteger primeExponentQ;
private BigInteger crtCoefficient;
private RSAOtherPrimeInfo[] otherPrimeInfo;
// Constructor(s)
// --------------------------------------------------------------------------
/**
* <p>Creates a new <code>RSAMultiPrimePrivateCrtKeySpec</code> given the
* modulus, publicExponent, privateExponent, primeP, primeQ, primeExponentP,
* primeExponentQ, crtCoefficient, and otherPrimeInfo as defined in PKCS#1
* v2.1.</p>
*
* <p>Note that <code>otherPrimeInfo</code> is cloned when constructing this
* object.</p>
*
* @param modulus the modulus n.
* @param publicExponent the public exponent e.
* @param privateExponent the private exponent d.
* @param primeP the prime factor p of n.
* @param primeQ the prime factor q of n.
* @param primeExponentP this is d mod (p-1).
* @param primeExponentQ this is d mod (q-1).
* @param crtCoefficient the Chinese Remainder Theorem coefficient q-1 mod p.
* @param otherPrimeInfo triplets of the rest of primes, <code>null</code>
* can be specified if there are only two prime factors (p and q).
* @throws NullPointerException if any of the parameters, i.e. modulus,
* publicExponent, privateExponent, primeP, primeQ, primeExponentP,
* primeExponentQ, crtCoefficient, is <code>null</code>.
* @throws IllegalArgumentException if an empty, i.e. 0-length,
* otherPrimeInfo is specified.
*/
public RSAMultiPrimePrivateCrtKeySpec(BigInteger modulus,
BigInteger publicExponent,
BigInteger privateExponent,
BigInteger primeP,
BigInteger primeQ,
BigInteger primeExponentP,
BigInteger primeExponentQ,
BigInteger crtCoefficient,
RSAOtherPrimeInfo[] otherPrimeInfo)
{
super(modulus, privateExponent);
if (modulus == null)
throw new NullPointerException("modulus");
if (publicExponent == null)
throw new NullPointerException("publicExponent");
if (privateExponent == null)
throw new NullPointerException("privateExponent");
if (primeP == null)
throw new NullPointerException("primeP");
if (primeQ == null)
throw new NullPointerException("primeQ");
if (primeExponentP == null)
throw new NullPointerException("primeExponentP");
if (primeExponentQ == null)
throw new NullPointerException("primeExponentQ");
if (crtCoefficient == null)
throw new NullPointerException("crtCoefficient");
if (otherPrimeInfo != null)
if (otherPrimeInfo.length == 0)
throw new IllegalArgumentException();
else
this.otherPrimeInfo = (RSAOtherPrimeInfo[]) otherPrimeInfo.clone();
this.publicExponent = publicExponent;
this.primeP = primeP;
this.primeQ = primeQ;
this.primeExponentP = primeExponentP;
this.primeExponentQ = primeExponentQ;
this.crtCoefficient = crtCoefficient;
}
// Class methods
// --------------------------------------------------------------------------
// Instance methods
// --------------------------------------------------------------------------
/**
* Returns the public exponent.
*
* @return the public exponent.
*/
public BigInteger getPublicExponent()
{
return this.publicExponent;
}
/**
* Returns the primeP.
*
* @return the primeP.
*/
public BigInteger getPrimeP()
{
return this.primeP;
}
/**
* Returns the primeQ.
*
* @return the primeQ.
*/
public BigInteger getPrimeQ()
{
return this.primeQ;
}
/**
* Returns the primeExponentP.
*
* @return the primeExponentP.
*/
public BigInteger getPrimeExponentP()
{
return this.primeExponentP;
}
/**
* Returns the primeExponentQ.
*
* @return the primeExponentQ.
*/
public BigInteger getPrimeExponentQ()
{
return this.primeExponentQ;
}
/**
* Returns the crtCoefficient.
*
* @return the crtCoefficient.
*/
public BigInteger getCrtCoefficient()
{
return this.crtCoefficient;
}
/**
* Returns a copy of the otherPrimeInfo or <code>null</code> if there are
* only two prime factors (p and q).
*
* @return the otherPrimeInfo.
*/
public RSAOtherPrimeInfo[] getOtherPrimeInfo()
{
return this.otherPrimeInfo == null
? null
: (RSAOtherPrimeInfo[]) this.otherPrimeInfo.clone();
}
}
/* RSAOtherPrimeInfo.java --
Copyright (C) 2003, Free Software Foundation, Inc.
This file is part of GNU Classpath.
GNU Classpath is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GNU Classpath is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with GNU Classpath; see the file COPYING. If not, write to the
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
package java.security.spec;
import java.math.BigInteger;
/**
* This class represents the triplet (prime, exponent, and coefficient) inside
* RSA's OtherPrimeInfo structure, as defined in the PKCS#1 v2.1. The ASN.1
* syntax of RSA's OtherPrimeInfo is as follows:
*
* <pre>
* OtherPrimeInfo ::= SEQUENCE {
* prime INTEGER,
* exponent INTEGER,
* coefficient INTEGER
* }
* </pre>
*
* @since 1.4
* @see RSAPrivateCrtKeySpec
* @see java.security.interfaces.RSAMultiPrimePrivateCrtKey
*/
public class RSAOtherPrimeInfo
{
// Constants and fields
// --------------------------------------------------------------------------
private BigInteger prime;
private BigInteger primeExponent;
private BigInteger crtCoefficient;
// Constructor(s)
// --------------------------------------------------------------------------
/**
* Creates a new <code>RSAOtherPrimeInfo</code> given the prime,
* primeExponent, and crtCoefficient as defined in PKCS#1.
*
* @param prime the prime factor of n.
* @param primeExponent the exponent.
* @param crtCoefficient the Chinese Remainder Theorem coefficient.
* @throws NullPointerException if any of the parameters, i.e. prime,
* primeExponent, crtCoefficient, is <code>null</code>.
*/
public RSAOtherPrimeInfo(BigInteger prime, BigInteger primeExponent,
BigInteger crtCoefficient)
{
super();
if (prime == null)
throw new NullPointerException("prime");
if (primeExponent == null)
throw new NullPointerException("primeExponent");
if (crtCoefficient == null)
throw new NullPointerException("crtCoefficient");
this.prime = prime;
this.primeExponent = primeExponent;
this.crtCoefficient = crtCoefficient;
}
// Class methods
// --------------------------------------------------------------------------
// Instance methods
// --------------------------------------------------------------------------
/**
* Returns the prime.
*
* @return the prime.
*/
public final BigInteger getPrime()
{
return this.prime;
}
/**
* Returns the prime's exponent.
*
* @return the primeExponent.
*/
public final BigInteger getExponent()
{
return this.primeExponent;
}
/**
* Returns the prime's crtCoefficient.
*
* @return the crtCoefficient.
*/
public final BigInteger getCrtCoefficient()
{
return this.crtCoefficient;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment