|
From: <ls...@us...> - 2007-11-17 21:07:24
|
Revision: 3593
http://jnode.svn.sourceforge.net/jnode/?rev=3593&view=rev
Author: lsantha
Date: 2007-11-17 13:07:23 -0800 (Sat, 17 Nov 2007)
Log Message:
-----------
OpenJDK integration.
Added Paths:
-----------
trunk/core/src/openjdk/java/java/security/spec/AlgorithmParameterSpec.java
trunk/core/src/openjdk/java/java/security/spec/DSAParameterSpec.java
trunk/core/src/openjdk/java/java/security/spec/DSAPrivateKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/DSAPublicKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/EncodedKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/InvalidKeySpecException.java
trunk/core/src/openjdk/java/java/security/spec/InvalidParameterSpecException.java
trunk/core/src/openjdk/java/java/security/spec/KeySpec.java
trunk/core/src/openjdk/java/java/security/spec/MGF1ParameterSpec.java
trunk/core/src/openjdk/java/java/security/spec/PKCS8EncodedKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/PSSParameterSpec.java
trunk/core/src/openjdk/java/java/security/spec/RSAKeyGenParameterSpec.java
trunk/core/src/openjdk/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/RSAOtherPrimeInfo.java
trunk/core/src/openjdk/java/java/security/spec/RSAPrivateCrtKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/RSAPrivateKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/RSAPublicKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/X509EncodedKeySpec.java
trunk/core/src/openjdk/java/java/security/spec/package.html
Removed Paths:
-------------
trunk/core/src/classpath/java/java/security/spec/
Added: trunk/core/src/openjdk/java/java/security/spec/AlgorithmParameterSpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/AlgorithmParameterSpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/AlgorithmParameterSpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+/**
+ * A (transparent) specification of cryptographic parameters.
+ *
+ * <P> This interface contains no methods or constants. Its only purpose
+ * is to group (and provide type safety for) all parameter specifications.
+ * All parameter specifications must implement this interface.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.21, 05/05/07
+ *
+ * @see java.security.AlgorithmParameters
+ * @see DSAParameterSpec
+ *
+ * @since 1.2
+ */
+
+public interface AlgorithmParameterSpec { }
Added: trunk/core/src/openjdk/java/java/security/spec/DSAParameterSpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/DSAParameterSpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/DSAParameterSpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,90 @@
+/*
+ * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+
+/**
+ * This class specifies the set of parameters used with the DSA algorithm.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.23, 05/05/07
+ *
+ * @see AlgorithmParameterSpec
+ *
+ * @since 1.2
+ */
+
+public class DSAParameterSpec implements AlgorithmParameterSpec,
+java.security.interfaces.DSAParams {
+
+ BigInteger p;
+ BigInteger q;
+ BigInteger g;
+
+ /**
+ * Creates a new DSAParameterSpec with the specified parameter values.
+ *
+ * @param p the prime.
+ *
+ * @param q the sub-prime.
+ *
+ * @param g the base.
+ */
+ public DSAParameterSpec(BigInteger p, BigInteger q, BigInteger g) {
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ * Returns the prime <code>p</code>.
+ *
+ * @return the prime <code>p</code>.
+ */
+ public BigInteger getP() {
+ return this.p;
+ }
+
+ /**
+ * Returns the sub-prime <code>q</code>.
+ *
+ * @return the sub-prime <code>q</code>.
+ */
+ public BigInteger getQ() {
+ return this.q;
+ }
+
+ /**
+ * Returns the base <code>g</code>.
+ *
+ * @return the base <code>g</code>.
+ */
+ public BigInteger getG() {
+ return this.g;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/DSAPrivateKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/DSAPrivateKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/DSAPrivateKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+
+/**
+ * This class specifies a DSA private key with its associated parameters.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.25, 05/05/07
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see DSAPublicKeySpec
+ * @see PKCS8EncodedKeySpec
+ *
+ * @since 1.2
+ */
+
+public class DSAPrivateKeySpec implements KeySpec {
+
+ private BigInteger x;
+ private BigInteger p;
+ private BigInteger q;
+ private BigInteger g;
+
+ /**
+ * Creates a new DSAPrivateKeySpec with the specified parameter values.
+ *
+ * @param x the private key.
+ *
+ * @param p the prime.
+ *
+ * @param q the sub-prime.
+ *
+ * @param g the base.
+ */
+ public DSAPrivateKeySpec(BigInteger x, BigInteger p, BigInteger q,
+ BigInteger g) {
+ this.x = x;
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ * Returns the private key <code>x</code>.
+ *
+ * @return the private key <code>x</code>.
+ */
+ public BigInteger getX() {
+ return this.x;
+ }
+
+ /**
+ * Returns the prime <code>p</code>.
+ *
+ * @return the prime <code>p</code>.
+ */
+ public BigInteger getP() {
+ return this.p;
+ }
+
+ /**
+ * Returns the sub-prime <code>q</code>.
+ *
+ * @return the sub-prime <code>q</code>.
+ */
+ public BigInteger getQ() {
+ return this.q;
+ }
+
+ /**
+ * Returns the base <code>g</code>.
+ *
+ * @return the base <code>g</code>.
+ */
+ public BigInteger getG() {
+ return this.g;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/DSAPublicKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/DSAPublicKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/DSAPublicKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,107 @@
+/*
+ * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+
+/**
+ * This class specifies a DSA public key with its associated parameters.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.25, 05/05/07
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see DSAPrivateKeySpec
+ * @see X509EncodedKeySpec
+ *
+ * @since 1.2
+ */
+
+public class DSAPublicKeySpec implements KeySpec {
+
+ private BigInteger y;
+ private BigInteger p;
+ private BigInteger q;
+ private BigInteger g;
+
+ /**
+ * Creates a new DSAPublicKeySpec with the specified parameter values.
+ *
+ * @param y the public key.
+ *
+ * @param p the prime.
+ *
+ * @param q the sub-prime.
+ *
+ * @param g the base.
+ */
+ public DSAPublicKeySpec(BigInteger y, BigInteger p, BigInteger q,
+ BigInteger g) {
+ this.y = y;
+ this.p = p;
+ this.q = q;
+ this.g = g;
+ }
+
+ /**
+ * Returns the public key <code>y</code>.
+ *
+ * @return the public key <code>y</code>.
+ */
+ public BigInteger getY() {
+ return this.y;
+ }
+
+ /**
+ * Returns the prime <code>p</code>.
+ *
+ * @return the prime <code>p</code>.
+ */
+ public BigInteger getP() {
+ return this.p;
+ }
+
+ /**
+ * Returns the sub-prime <code>q</code>.
+ *
+ * @return the sub-prime <code>q</code>.
+ */
+ public BigInteger getQ() {
+ return this.q;
+ }
+
+ /**
+ * Returns the base <code>g</code>.
+ *
+ * @return the base <code>g</code>.
+ */
+ public BigInteger getG() {
+ return this.g;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/EncodedKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/EncodedKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/EncodedKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+/**
+ * This class represents a public or private key in encoded format.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.29, 05/05/07
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see X509EncodedKeySpec
+ * @see PKCS8EncodedKeySpec
+ *
+ * @since 1.2
+ */
+
+public abstract class EncodedKeySpec implements KeySpec {
+
+ private byte[] encodedKey;
+
+ /**
+ * Creates a new EncodedKeySpec with the given encoded key.
+ *
+ * @param encodedKey the encoded key. The contents of the
+ * array are copied to protect against subsequent modification.
+ * @exception NullPointerException if <code>encodedKey</code>
+ * is null.
+ */
+ public EncodedKeySpec(byte[] encodedKey) {
+ this.encodedKey = (byte[])encodedKey.clone();
+ }
+
+ /**
+ * Returns the encoded key.
+ *
+ * @return the encoded key. Returns a new array each time
+ * this method is called.
+ */
+ public byte[] getEncoded() {
+ return (byte[])this.encodedKey.clone();
+ }
+
+ /**
+ * Returns the name of the encoding format associated with this
+ * key specification.
+ *
+ * <p>If the opaque representation of a key
+ * (see {@link java.security.Key Key}) can be transformed
+ * (see {@link java.security.KeyFactory KeyFactory})
+ * into this key specification (or a subclass of it),
+ * <code>getFormat</code> called
+ * on the opaque key returns the same value as the
+ * <code>getFormat</code> method
+ * of this key specification.
+ *
+ * @return a string representation of the encoding format.
+ */
+ public abstract String getFormat();
+}
Added: trunk/core/src/openjdk/java/java/security/spec/InvalidKeySpecException.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/InvalidKeySpecException.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/InvalidKeySpecException.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This is the exception for invalid key specifications.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.23, 05/05/07
+ *
+ * @see KeySpec
+ *
+ * @since 1.2
+ */
+
+public class InvalidKeySpecException extends GeneralSecurityException {
+
+ private static final long serialVersionUID = 3546139293998810778L;
+
+ /**
+ * Constructs an InvalidKeySpecException with no detail message. A
+ * detail message is a String that describes this particular
+ * exception.
+ */
+ public InvalidKeySpecException() {
+ super();
+ }
+
+ /**
+ * Constructs an InvalidKeySpecException with the specified detail
+ * message. A detail message is a String that describes this
+ * particular exception.
+ *
+ * @param msg the detail message.
+ */
+ public InvalidKeySpecException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a <code>InvalidKeySpecException</code> with the specified
+ * detail message and cause.
+ *
+ * @param message the detail message (which is saved for later retrieval
+ * by the {@link #getMessage()} method).
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A <tt>null</tt> value is permitted,
+ * and indicates that the cause is nonexistent or unknown.)
+ * @since 1.5
+ */
+ public InvalidKeySpecException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ /**
+ * Creates a <code>InvalidKeySpecException</code> with the specified cause
+ * and a detail message of <tt>(cause==null ? null : cause.toString())</tt>
+ * (which typically contains the class and detail message of
+ * <tt>cause</tt>).
+ *
+ * @param cause the cause (which is saved for later retrieval by the
+ * {@link #getCause()} method). (A <tt>null</tt> value is permitted,
+ * and indicates that the cause is nonexistent or unknown.)
+ * @since 1.5
+ */
+ public InvalidKeySpecException(Throwable cause) {
+ super(cause);
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/InvalidParameterSpecException.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/InvalidParameterSpecException.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/InvalidParameterSpecException.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,67 @@
+/*
+ * Copyright 1997-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.security.GeneralSecurityException;
+
+/**
+ * This is the exception for invalid parameter specifications.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.22, 05/05/07
+ *
+ * @see java.security.AlgorithmParameters
+ * @see AlgorithmParameterSpec
+ * @see DSAParameterSpec
+ *
+ * @since 1.2
+ */
+
+public class InvalidParameterSpecException extends GeneralSecurityException {
+
+ private static final long serialVersionUID = -970468769593399342L;
+
+ /**
+ * Constructs an InvalidParameterSpecException with no detail message. A
+ * detail message is a String that describes this particular
+ * exception.
+ */
+ public InvalidParameterSpecException() {
+ super();
+ }
+
+ /**
+ * Constructs an InvalidParameterSpecException with the specified detail
+ * message. A detail message is a String that describes this
+ * particular exception.
+ *
+ * @param msg the detail message.
+ */
+ public InvalidParameterSpecException(String msg) {
+ super(msg);
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/KeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/KeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/KeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,63 @@
+/*
+ * Copyright 1997-1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+/**
+ * A (transparent) specification of the key material
+ * that constitutes a cryptographic key.
+ *
+ * <p>If the key is stored on a hardware device, its
+ * specification may contain information that helps identify the key on the
+ * device.
+ *
+ * <P> A key may be specified in an algorithm-specific way, or in an
+ * algorithm-independent encoding format (such as ASN.1).
+ * For example, a DSA private key may be specified by its components
+ * <code>x</code>, <code>p</code>, <code>q</code>, and <code>g</code>
+ * (see {@link DSAPrivateKeySpec}), or it may be
+ * specified using its DER encoding
+ * (see {@link PKCS8EncodedKeySpec}).
+ *
+ * <P> This interface contains no methods or constants. Its only purpose
+ * is to group (and provide type safety for) all key specifications.
+ * All key specifications must implement this interface.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.24, 05/05/07
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see EncodedKeySpec
+ * @see X509EncodedKeySpec
+ * @see PKCS8EncodedKeySpec
+ * @see DSAPrivateKeySpec
+ * @see DSAPublicKeySpec
+ *
+ * @since 1.2
+ */
+
+public interface KeySpec { }
Added: trunk/core/src/openjdk/java/java/security/spec/MGF1ParameterSpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/MGF1ParameterSpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/MGF1ParameterSpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,108 @@
+/*
+ * Copyright 2003-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This class specifies the set of parameters used with mask generation
+ * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as
+ * defined in the
+ * <a href="http://www.ietf.org/rfc/rfc3447.txt">PKCS #1 v2.1</a>
+ * standard.
+ *
+ * <p>Its ASN.1 definition in PKCS#1 standard is described below:
+ * <pre>
+ * MGF1Parameters ::= OAEP-PSSDigestAlgorthms
+ * </pre>
+ * where
+ * <pre>
+ * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
+ * { OID id-sha1 PARAMETERS NULL }|
+ * { OID id-sha256 PARAMETERS NULL }|
+ * { OID id-sha384 PARAMETERS NULL }|
+ * { OID id-sha512 PARAMETERS NULL },
+ * ... -- Allows for future expansion --
+ * }
+ * </pre>
+ * @see PSSParameterSpec
+ * @see javax.crypto.spec.OAEPParameterSpec
+ *
+ * @author Valerie Peng
+ *
+ * @version 1.11, 05/05/07
+ * @since 1.5
+ */
+public class MGF1ParameterSpec implements AlgorithmParameterSpec {
+
+ /**
+ * The MGF1ParameterSpec which uses "SHA-1" message digest.
+ */
+ public static final MGF1ParameterSpec SHA1 =
+ new MGF1ParameterSpec("SHA-1");
+ /**
+ * The MGF1ParameterSpec which uses "SHA-256" message digest.
+ */
+ public static final MGF1ParameterSpec SHA256 =
+ new MGF1ParameterSpec("SHA-256");
+ /**
+ * The MGF1ParameterSpec which uses "SHA-384" message digest.
+ */
+ public static final MGF1ParameterSpec SHA384 =
+ new MGF1ParameterSpec("SHA-384");
+ /**
+ * The MGF1ParameterSpec which uses SHA-512 message digest.
+ */
+ public static final MGF1ParameterSpec SHA512 =
+ new MGF1ParameterSpec("SHA-512");
+
+ private String mdName;
+
+ /**
+ * Constructs a parameter set for mask generation function MGF1
+ * as defined in the PKCS #1 standard.
+ *
+ * @param mdName the algorithm name for the message digest
+ * used in this mask generation function MGF1.
+ * @exception NullPointerException if <code>mdName</code> is null.
+ */
+ public MGF1ParameterSpec(String mdName) {
+ if (mdName == null) {
+ throw new NullPointerException("digest algorithm is null");
+ }
+ this.mdName = mdName;
+ }
+
+ /**
+ * Returns the algorithm name of the message digest used by the mask
+ * generation function.
+ *
+ * @return the algorithm name of the message digest.
+ */
+ public String getDigestAlgorithm() {
+ return mdName;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/PKCS8EncodedKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/PKCS8EncodedKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/PKCS8EncodedKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,97 @@
+/*
+ * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+/**
+ * This class represents the ASN.1 encoding of a private key,
+ * encoded according to the ASN.1 type <code>PrivateKeyInfo</code>.
+ * The <code>PrivateKeyInfo</code> syntax is defined in the PKCS#8 standard
+ * as follows:
+ *
+ * <pre>
+ * PrivateKeyInfo ::= SEQUENCE {
+ * version Version,
+ * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
+ * privateKey PrivateKey,
+ * attributes [0] IMPLICIT Attributes OPTIONAL }
+ *
+ * Version ::= INTEGER
+ *
+ * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
+ *
+ * PrivateKey ::= OCTET STRING
+ *
+ * Attributes ::= SET OF Attribute
+ * </pre>
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.28, 05/05/07
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see EncodedKeySpec
+ * @see X509EncodedKeySpec
+ *
+ * @since 1.2
+ */
+
+public class PKCS8EncodedKeySpec extends EncodedKeySpec {
+
+ /**
+ * Creates a new PKCS8EncodedKeySpec with the given encoded key.
+ *
+ * @param encodedKey the key, which is assumed to be
+ * encoded according to the PKCS #8 standard. The contents of
+ * the array are copied to protect against subsequent modification.
+ * @exception NullPointerException if <code>encodedKey</code>
+ * is null.
+ */
+ public PKCS8EncodedKeySpec(byte[] encodedKey) {
+ super(encodedKey);
+ }
+
+ /**
+ * Returns the key bytes, encoded according to the PKCS #8 standard.
+ *
+ * @return the PKCS #8 encoding of the key. Returns a new array
+ * each time this method is called.
+ */
+ public byte[] getEncoded() {
+ return super.getEncoded();
+ }
+
+ /**
+ * Returns the name of the encoding format associated with this
+ * key specification.
+ *
+ * @return the string <code>"PKCS#8"</code>.
+ */
+ public final String getFormat() {
+ return "PKCS#8";
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/PSSParameterSpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/PSSParameterSpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/PSSParameterSpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2001-2006 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+import java.security.spec.MGF1ParameterSpec;
+
+/**
+ * This class specifies a parameter spec for RSA-PSS signature scheme,
+ * as defined in the
+ * <a href="http://www.ietf.org/rfc/rfc3447.txt">PKCS#1 v2.1</a>
+ * standard.
+ *
+ * <p>Its ASN.1 definition in PKCS#1 standard is described below:
+ * <pre>
+ * RSASSA-PSS-params ::= SEQUENCE {
+ * hashAlgorithm [0] OAEP-PSSDigestAlgorithms DEFAULT sha1,
+ * maskGenAlgorithm [1] PKCS1MGFAlgorithms DEFAULT mgf1SHA1,
+ * saltLength [2] INTEGER DEFAULT 20,
+ * trailerField [3] INTEGER DEFAULT 1
+ * }
+ * </pre>
+ * where
+ * <pre>
+ * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
+ * { OID id-sha1 PARAMETERS NULL }|
+ * { OID id-sha256 PARAMETERS NULL }|
+ * { OID id-sha384 PARAMETERS NULL }|
+ * { OID id-sha512 PARAMETERS NULL },
+ * ... -- Allows for future expansion --
+ * }
+ *
+ * PKCS1MGFAlgorithms ALGORITHM-IDENTIFIER ::= {
+ * { OID id-mgf1 PARAMETERS OAEP-PSSDigestAlgorithms },
+ * ... -- Allows for future expansion --
+ * }
+ * </pre>
+ * <p>Note: the PSSParameterSpec.DEFAULT uses the following:
+ * message digest -- "SHA-1"
+ * mask generation function (mgf) -- "MGF1"
+ * parameters for mgf -- MGF1ParameterSpec.SHA1
+ * SaltLength -- 20
+ * TrailerField -- 1
+ *
+ * @see MGF1ParameterSpec
+ * @see AlgorithmParameterSpec
+ * @see java.security.Signature
+ *
+ * @author Valerie Peng
+ *
+ * @version 1.15 07/05/05
+ *
+ * @since 1.4
+ */
+
+public class PSSParameterSpec implements AlgorithmParameterSpec {
+
+ private String mdName = "SHA-1";
+ private String mgfName = "MGF1";
+ private AlgorithmParameterSpec mgfSpec = MGF1ParameterSpec.SHA1;
+ private int saltLen = 20;
+ private int trailerField = 1;
+
+ /**
+ * The PSS parameter set with all default values.
+ * @since 1.5
+ */
+ public static final PSSParameterSpec DEFAULT = new PSSParameterSpec();
+
+ /**
+ * Constructs a new <code>PSSParameterSpec</code> as defined in
+ * the PKCS #1 standard using the default values.
+ */
+ private PSSParameterSpec() {
+ }
+
+ /**
+ * Creates a new <code>PSSParameterSpec</code> as defined in
+ * the PKCS #1 standard using the specified message digest,
+ * mask generation function, parameters for mask generation
+ * function, salt length, and trailer field values.
+ *
+ * @param mdName the algorithm name of the hash function.
+ * @param mgfName the algorithm name of the mask generation
+ * function.
+ * @param mgfSpec the parameters for the mask generation
+ * function. If null is specified, null will be returned by
+ * getMGFParameters().
+ * @param saltLen the length of salt.
+ * @param trailerField the value of the trailer field.
+ * @exception NullPointerException if <code>mdName</code>,
+ * or <code>mgfName</code> is null.
+ * @exception IllegalArgumentException if <code>saltLen</code>
+ * or <code>trailerField</code> is less than 0.
+ * @since 1.5
+ */
+ public PSSParameterSpec(String mdName, String mgfName,
+ AlgorithmParameterSpec mgfSpec,
+ int saltLen, int trailerField) {
+ if (mdName == null) {
+ throw new NullPointerException("digest algorithm is null");
+ }
+ if (mgfName == null) {
+ throw new NullPointerException("mask generation function " +
+ "algorithm is null");
+ }
+ if (saltLen < 0) {
+ throw new IllegalArgumentException("negative saltLen value: " +
+ saltLen);
+ }
+ if (trailerField < 0) {
+ throw new IllegalArgumentException("negative trailerField: " +
+ trailerField);
+ }
+ this.mdName = mdName;
+ this.mgfName = mgfName;
+ this.mgfSpec = mgfSpec;
+ this.saltLen = saltLen;
+ this.trailerField = trailerField;
+ }
+
+ /**
+ * Creates a new <code>PSSParameterSpec</code>
+ * using the specified salt length and other default values as
+ * defined in PKCS#1.
+ *
+ * @param saltLen the length of salt in bits to be used in PKCS#1
+ * PSS encoding.
+ * @exception IllegalArgumentException if <code>saltLen</code> is
+ * less than 0.
+ */
+ public PSSParameterSpec(int saltLen) {
+ if (saltLen < 0) {
+ throw new IllegalArgumentException("negative saltLen value: " +
+ saltLen);
+ }
+ this.saltLen = saltLen;
+ }
+
+ /**
+ * Returns the message digest algorithm name.
+ *
+ * @return the message digest algorithm name.
+ * @since 1.5
+ */
+ public String getDigestAlgorithm() {
+ return mdName;
+ }
+
+ /**
+ * Returns the mask generation function algorithm name.
+ *
+ * @return the mask generation function algorithm name.
+ *
+ * @since 1.5
+ */
+ public String getMGFAlgorithm() {
+ return mgfName;
+ }
+
+ /**
+ * Returns the parameters for the mask generation function.
+ *
+ * @return the parameters for the mask generation function.
+ * @since 1.5
+ */
+ public AlgorithmParameterSpec getMGFParameters() {
+ return mgfSpec;
+ }
+
+ /**
+ * Returns the salt length in bits.
+ *
+ * @return the salt length.
+ */
+ public int getSaltLength() {
+ return saltLen;
+ }
+
+ /**
+ * Returns the value for the trailer field, i.e. bc in PKCS#1 v2.1.
+ *
+ * @return the value for the trailer field, i.e. bc in PKCS#1 v2.1.
+ * @since 1.5
+ */
+ public int getTrailerField() {
+ return trailerField;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/RSAKeyGenParameterSpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/RSAKeyGenParameterSpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/RSAKeyGenParameterSpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+import java.security.spec.AlgorithmParameterSpec;
+
+/**
+ * This class specifies the set of parameters used to generate an RSA
+ * key pair.
+ *
+ * @author Jan Luehe
+ * @version 1.15 05/05/07
+ *
+ * @see java.security.KeyPairGenerator#initialize(java.security.spec.AlgorithmParameterSpec)
+ *
+ * @since 1.3
+ */
+
+public class RSAKeyGenParameterSpec implements AlgorithmParameterSpec {
+
+ private int keysize;
+ private BigInteger publicExponent;
+
+ /**
+ * The public-exponent value F0 = 3.
+ */
+ public static final BigInteger F0 = BigInteger.valueOf(3);
+
+ /**
+ * The public exponent-value F4 = 65537.
+ */
+ public static final BigInteger F4 = BigInteger.valueOf(65537);
+
+ /**
+ * Constructs a new <code>RSAParameterSpec</code> object from the
+ * given keysize and public-exponent value.
+ *
+ * @param keysize the modulus size (specified in number of bits)
+ * @param publicExponent the public exponent
+ */
+ public RSAKeyGenParameterSpec(int keysize, BigInteger publicExponent) {
+ this.keysize = keysize;
+ this.publicExponent = publicExponent;
+ }
+
+ /**
+ * Returns the keysize.
+ *
+ * @return the keysize.
+ */
+ public int getKeysize() {
+ return keysize;
+ }
+
+ /**
+ * Returns the public-exponent value.
+ *
+ * @return the public-exponent value.
+ */
+ public BigInteger getPublicExponent() {
+ return publicExponent;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,213 @@
+/*
+ * Copyright 2001-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+
+/**
+ * This class specifies an RSA multi-prime private key, as defined in the
+ * PKCS#1 v2.1, using the Chinese Remainder Theorem (CRT) information
+ * values for efficiency.
+ *
+ * @author Valerie Peng
+ *
+ * @version 1.15 07/05/05
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see PKCS8EncodedKeySpec
+ * @see RSAPrivateKeySpec
+ * @see RSAPublicKeySpec
+ * @see RSAOtherPrimeInfo
+ *
+ * @since 1.4
+ */
+
+public class RSAMultiPrimePrivateCrtKeySpec extends RSAPrivateKeySpec {
+
+ private final BigInteger publicExponent;
+ private final BigInteger primeP;
+ private final BigInteger primeQ;
+ private final BigInteger primeExponentP;
+ private final BigInteger primeExponentQ;
+ private final BigInteger crtCoefficient;
+ private final RSAOtherPrimeInfo otherPrimeInfo[];
+
+ /**
+ * 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>Note that the contents of <code>otherPrimeInfo</code>
+ * are copied to protect against subsequent modification when
+ * constructing this object.
+ *
+ * @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, null can be
+ * specified if there are only two prime factors (p and q).
+ * @exception NullPointerException if any of the parameters, i.e.
+ * <code>modulus</code>,
+ * <code>publicExponent</code>, <code>privateExponent</code>,
+ * <code>primeP</code>, <code>primeQ</code>,
+ * <code>primeExponentP</code>, <code>primeExponentQ</code>,
+ * <code>crtCoefficient</code>, is null.
+ * @exception IllegalArgumentException if an empty, i.e. 0-length,
+ * <code>otherPrimeInfo</code> 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("the modulus parameter must be " +
+ "non-null");
+ }
+ if (publicExponent == null) {
+ throw new NullPointerException("the publicExponent parameter " +
+ "must be non-null");
+ }
+ if (privateExponent == null) {
+ throw new NullPointerException("the privateExponent parameter " +
+ "must be non-null");
+ }
+ if (primeP == null) {
+ throw new NullPointerException("the primeP parameter " +
+ "must be non-null");
+ }
+ if (primeQ == null) {
+ throw new NullPointerException("the primeQ parameter " +
+ "must be non-null");
+ }
+ if (primeExponentP == null) {
+ throw new NullPointerException("the primeExponentP parameter " +
+ "must be non-null");
+ }
+ if (primeExponentQ == null) {
+ throw new NullPointerException("the primeExponentQ parameter " +
+ "must be non-null");
+ }
+ if (crtCoefficient == null) {
+ throw new NullPointerException("the crtCoefficient parameter " +
+ "must be non-null");
+ }
+ this.publicExponent = publicExponent;
+ this.primeP = primeP;
+ this.primeQ = primeQ;
+ this.primeExponentP = primeExponentP;
+ this.primeExponentQ = primeExponentQ;
+ this.crtCoefficient = crtCoefficient;
+ if (otherPrimeInfo == null) {
+ this.otherPrimeInfo = null;
+ } else if (otherPrimeInfo.length == 0) {
+ throw new IllegalArgumentException("the otherPrimeInfo " +
+ "parameter must not be empty");
+ } else {
+ this.otherPrimeInfo = (RSAOtherPrimeInfo[])otherPrimeInfo.clone();
+ }
+ }
+
+ /**
+ * 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 null if there are
+ * only two prime factors (p and q).
+ *
+ * @return the otherPrimeInfo. Returns a new array each
+ * time this method is called.
+ */
+ public RSAOtherPrimeInfo[] getOtherPrimeInfo() {
+ if (otherPrimeInfo == null) return null;
+ return (RSAOtherPrimeInfo[]) otherPrimeInfo.clone();
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/RSAOtherPrimeInfo.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/RSAOtherPrimeInfo.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/RSAOtherPrimeInfo.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2001 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+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>
+ *
+ * @author Valerie Peng
+ *
+ * @version 1.13 07/05/05
+ *
+ * @see RSAPrivateCrtKeySpec
+ * @see java.security.interfaces.RSAMultiPrimePrivateCrtKey
+ *
+ * @since 1.4
+ */
+
+public class RSAOtherPrimeInfo {
+
+ private BigInteger prime;
+ private BigInteger primeExponent;
+ private BigInteger crtCoefficient;
+
+
+ /**
+ * 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.
+ * @exception NullPointerException if any of the parameters, i.e.
+ * <code>prime</code>, <code>primeExponent</code>,
+ * <code>crtCoefficient</code>, is null.
+ *
+ */
+ public RSAOtherPrimeInfo(BigInteger prime,
+ BigInteger primeExponent,
+ BigInteger crtCoefficient) {
+ if (prime == null) {
+ throw new NullPointerException("the prime parameter must be " +
+ "non-null");
+ }
+ if (primeExponent == null) {
+ throw new NullPointerException("the primeExponent parameter " +
+ "must be non-null");
+ }
+ if (crtCoefficient == null) {
+ throw new NullPointerException("the crtCoefficient parameter " +
+ "must be non-null");
+ }
+ this.prime = prime;
+ this.primeExponent = primeExponent;
+ this.crtCoefficient = crtCoefficient;
+ }
+
+ /**
+ * 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;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/RSAPrivateCrtKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/RSAPrivateCrtKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/RSAPrivateCrtKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,144 @@
+/*
+ * Copyright 1998-2003 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this code.
+ *
+ * This code 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
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * CA 95054 USA or visit www.sun.com if you need additional information or
+ * have any questions.
+ */
+
+package java.security.spec;
+
+import java.math.BigInteger;
+
+/**
+ * This class specifies an RSA private key, as defined in the PKCS#1
+ * standard, using the Chinese Remainder Theorem (CRT) information values for
+ * efficiency.
+ *
+ * @author Jan Luehe
+ *
+ * @version 1.19 07/05/05
+ *
+ * @see java.security.Key
+ * @see java.security.KeyFactory
+ * @see KeySpec
+ * @see PKCS8EncodedKeySpec
+ * @see RSAPrivateKeySpec
+ * @see RSAPublicKeySpec
+ */
+
+public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec {
+
+ private final BigInteger publicExponent;
+ private final BigInteger primeP;
+ private final BigInteger primeQ;
+ private final BigInteger primeExponentP;
+ private final BigInteger primeExponentQ;
+ private final BigInteger crtCoefficient;
+
+
+
+ /**
+ * Creates a new <code>RSAPrivateCrtKeySpec</code>
+ * given the modulus, publicExponent, privateExponent,
+ * primeP, primeQ, primeExponentP, primeExponentQ, and
+ * crtCoefficient as defined in PKCS#1.
+ *
+ * @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
+ */
+ public RSAPrivateCrtKeySpec(BigInteger modulus,
+ BigInteger publicExponent,
+ BigInteger privateExponent,
+ BigInteger primeP,
+ BigInteger primeQ,
+ BigInteger primeExponentP,
+ BigInteger primeExponentQ,
+ BigInteger crtCoefficient) {
+ super(modulus, privateExponent);
+ this.publicExponent = publicExponent;
+ this.primeP = primeP;
+ this.primeQ = primeQ;
+ this.primeExponentP = primeExponentP;
+ this.primeExponentQ = primeExponentQ;
+ this.crtCoefficient = crtCoefficient;
+ }
+
+ /**
+ * 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;
+ }
+}
Added: trunk/core/src/openjdk/java/java/security/spec/RSAPrivateKeySpec.java
===================================================================
--- trunk/core/src/openjdk/java/java/security/spec/RSAPrivateKeySpec.java (rev 0)
+++ trunk/core/src/openjdk/java/java/security/spec/RSAPrivateKeySpec.java 2007-11-17 21:07:23 UTC (rev 3593)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 1998-2001 Sun Microsystems, Inc. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the LICENSE file that accompanied this c...
[truncated message content] |