diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/Component.java b/openjdk/icedtea/jce/gnu/classpath/debug/Component.java deleted file mode 100644 index dce25750..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/Component.java +++ /dev/null @@ -1,175 +0,0 @@ -/* Component.java -- a component log level. - Copyright (C) 2005, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.util.logging.Level; - -public final class Component extends Level -{ - - /* - * HOW TO ADD NEW COMPONENTS: - * - * If you want to add a new, simple component, that you will use in - * logging statements, simply create a new class variable that - * instantiates this class, and choose an appropriate string name - * and a integer constant not used by any other component level. - * - * For example, if my component had to do with 'frobbing', I would - * add this entry below: - * - * private static final Component FROBBING = new Component ("FROBBING", 7); - * - * Then, I would update the component 'EVERYTHING' to have and end - * index ONE GREATER THAN the index of the new component. - * - * ADDING NEW COMPONENT CLASSES: - * - * A "component class" is a run of more than one component, which can - * be enabled all at once. EVERYTHING and SSL are examples of component - * classes. To add a new class, create a new component with a start index - * equal to the index of the first member component, and with an end - * index equal to the index of the last member component plus one. - */ - - /** - * Signifies that everything should be logged. This should be used to - * enable or disable levels only; logging code should not use it. - */ - public static final Component EVERYTHING = new Component ("*", 0, 11); - - /** - * Signifies that all SSL related messages should be logged. This should - * be used to enable or disable levels only; logging code should not use - * it. - */ - public static final Component SSL = new Component ("SSL", 0, 5); - - /** - * Traces the progression of an SSL handshake. - */ - public static final Component SSL_HANDSHAKE = new Component ("SSL HANDSHAKE", 0); - - /** - * Traces record layer messages during SSL communications. - */ - public static final Component SSL_RECORD_LAYER = new Component ("SSL RECORD LAYER", 1); - - /** - * Trace details about the SSL key exchange. - */ - public static final Component SSL_KEY_EXCHANGE = new Component ("SSL KEY EXCHANGE", 2); - - /** - * Trace running of delegated tasks. - */ - public static final Component SSL_DELEGATED_TASK = new Component ("SSL DELEGATED TASK", 3); - - /* Index 4 reserved for future use by SSL components. */ - - /** - * Trace the operation of cryptographic primitives. - */ - public static final Component CRYPTO = new Component ("CRYPTO", 5); - - /** - * Trace the parsing of X.509 certificates and related objects. - */ - public static final Component X509 = new Component ("X.509", 6); - - /** - * Trace access control policies, including the parsing of - * java.policy files. - */ - public static final Component POLICY = new Component ("POLICY", 7); - - /** - * Trace ipp implementation. - */ - public static final Component IPP = new Component ("IPP", 10); - - private final int startIndex; - private final int endIndex; - - private Component (final String name, final int bitIndex) - { - this (name, bitIndex, bitIndex + 1); - } - - private Component (final String name, final int startIndex, final int endIndex) - { - super (name, Level.FINE.intValue ()); - this.startIndex = startIndex; - this.endIndex = endIndex; - } - - /** - * Return the component for the given name. - * - * @param name The name of the component to get. - * @return The named component, or null if there is no such component. - */ - public static Component forName (final String name) - { - try - { - Field f = Component.class.getField (name.toUpperCase ()); - if (!Modifier.isStatic (f.getModifiers ()) - || Component.class.isAssignableFrom (f.getClass ())) - return null; - return (Component) f.get (null); - } - catch (Throwable _) - { - return null; - } - } - - public int startIndex () - { - return startIndex; - } - - public int endIndex () - { - return endIndex; - } -} \ No newline at end of file diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/PreciseFilter.java b/openjdk/icedtea/jce/gnu/classpath/debug/PreciseFilter.java deleted file mode 100644 index 7b88b2c8..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/PreciseFilter.java +++ /dev/null @@ -1,105 +0,0 @@ -/* PreciseFilter.java -- filter log messages by precise level. - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.util.BitSet; -import java.util.logging.Filter; -import java.util.logging.LogRecord; - -public final class PreciseFilter implements Filter -{ - - /** - * The singleton filter instance. - */ - public static final PreciseFilter GLOBAL = new PreciseFilter (); - - private final BitSet enabled; - - private PreciseFilter () - { - enabled = new BitSet (); - } - - /** - * Disable logging of a component. - * - * @param component The component to disable logging for. - * @throws NullPointerException If component is null. - */ - public void disable (final Component component) - { - enabled.clear (component.startIndex (), component.endIndex ()); - } - - /** - * Enable logging of a component. - * - * @param component The component to enable logging for. - * @throws NullPointerException If component is null. - */ - public void enable (final Component component) - { - enabled.set (component.startIndex (), component.endIndex ()); - } - - /** - * Tell if a component is enabled for logging. - * - * @param component The component to test. - * @return True iff the specified component is enabled for logging. - * @throws NullPointerException If component is null. - */ - public boolean isEnabled (final Component component) - { - return (enabled.get (component.startIndex ())); - } - - public boolean isLoggable (final LogRecord record) - { - try - { - return isEnabled ((Component) record.getLevel ()); - } - catch (ClassCastException cce) - { - return true; - } - } -} \ No newline at end of file diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/Simple1LineFormatter.java b/openjdk/icedtea/jce/gnu/classpath/debug/Simple1LineFormatter.java deleted file mode 100644 index 96573193..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/Simple1LineFormatter.java +++ /dev/null @@ -1,161 +0,0 @@ -/* Simple1LineFormatter.java -- A simple 1-line logging formatter - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import gnu.java.security.action.GetPropertyAction; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.security.AccessController; -import java.text.DateFormat; -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.logging.Formatter; -import java.util.logging.LogRecord; - -/** - * A simple 1-line formatter to use instead of the 2-line SimpleFormatter used - * by default in the JDK logging handlers. - *
- * The fixed format of this formatter is as follows: - *
- *
- * Here is an example of the output generated by this formatter: - *
- *
- * 2006-02-27 21:59:12.0881 +1100 -1343151280 EncodedKeyFactory engineGeneratePublic() FINER - ENTRY java.security.spec.X509EncodedKeySpec@b00d7fc0 - * 2006-02-27 21:59:12.0887 +1100 -1343151280 EncodedKeyFactory engineGeneratePublic() FINE - Exception in DSSPublicKey.valueOf(). Ignore - * java.security.InvalidParameterException: Unexpected OID: 1.2.840.113549.1.1.1 - * at gnu.java.security.key.dss.DSSKeyPairX509Codec.decodePublicKey (DSSKeyPairX509Codec.java:205) - * at gnu.java.security.key.dss.DSSPublicKey.valueOf (DSSPublicKey.java:136) - * at gnu.java.security.jce.sig.EncodedKeyFactory.engineGeneratePublic (EncodedKeyFactory.java:218) - * at java.security.KeyFactory.generatePublic (KeyFactory.java:219) - * at gnu.java.security.x509.X509Certificate.parse (X509Certificate.java:657) - * at gnu.java.security.x509.X509Certificate.- */ -public class Simple1LineFormatter - extends Formatter -{ - private static final String DAT_PATTERN = "yyyy-MM-dd HH:mm:ss.SSSS Z "; - private static final String THREAD_PATTERN = " #########0;-#########0"; - private static final String SPACES_32 = " "; - private static final String SPACES_6 = " "; - private static final String LS = (String) AccessController.doPrivileged - (new GetPropertyAction("line.separator")); - private DateFormat dateFormat; - private NumberFormat threadFormat; - - // default 0-arguments constructor - - public String format(LogRecord record) - { - if (dateFormat == null) - dateFormat = new SimpleDateFormat(DAT_PATTERN); - - if (threadFormat == null) - threadFormat = new DecimalFormat(THREAD_PATTERN); - - StringBuilder sb = new StringBuilder(180) - .append(dateFormat.format(new Date(record.getMillis()))) - .append(threadFormat.format(record.getThreadID())) - .append(" "); - String s = record.getSourceClassName(); - if (s == null) - sb.append(SPACES_32); - else - { - s = s.trim(); - int i = s.lastIndexOf("."); - if (i != - 1) - s = s.substring(i + 1); - - s = (s + SPACES_32).substring(0, 32); - } - - sb.append(s).append(" "); - s = record.getSourceMethodName(); - if (s == null) - sb.append(SPACES_32); - else - { - s = s.trim(); - if (s.endsWith("()")) - s = (s.trim() + SPACES_32).substring(0, 32); - else - s = (s.trim() + "()" + SPACES_32).substring(0, 32); - } - - sb.append(s).append(" "); - s = String.valueOf(record.getLevel()); - if (s == null) - sb.append(SPACES_6); - else - s = (s.trim() + SPACES_6).substring(0, 6); - - sb.append(s).append(" - ").append(formatMessage(record)).append(LS); - Throwable cause = record.getThrown(); - if (cause != null) - { - StringWriter sw = new StringWriter(); - cause.printStackTrace(new PrintWriter(sw, true)); - sb.append(sw.toString()); - } - - return sb.toString(); - } -} diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/SystemLogger.java b/openjdk/icedtea/jce/gnu/classpath/debug/SystemLogger.java deleted file mode 100644 index 8919e80c..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/SystemLogger.java +++ /dev/null @@ -1,102 +0,0 @@ -/* SystemLogger.java -- Classpath's system debugging logger. - Copyright (C) 2005 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import gnu.java.security.action.GetPropertyAction; - -import java.security.AccessController; -import java.util.StringTokenizer; -import java.util.logging.Level; -import java.util.logging.Logger; - -public final class SystemLogger extends Logger -{ - public static final SystemLogger SYSTEM = new SystemLogger(); - - static - { - SYSTEM.setFilter (PreciseFilter.GLOBAL); - String defaults = (String) AccessController.doPrivileged - (new GetPropertyAction("gnu.classpath.debug.components")); - - if (defaults != null) - { - StringTokenizer tok = new StringTokenizer (defaults, ","); - while (tok.hasMoreTokens ()) - { - Component c = Component.forName (tok.nextToken ()); - if (c != null) - PreciseFilter.GLOBAL.enable (c); - SYSTEM.log (Level.INFO, "enabled: {0}", c); - } - } - } - - /** - * Fetch the system logger instance. The logger returned is meant for debug - * and diagnostic logging for Classpath internals. - * - * @return The system logger. - */ - public static SystemLogger getSystemLogger() - { - // XXX Check some permission here? - return SYSTEM; - } - - /** - * Keep only one instance of the system logger. - */ - private SystemLogger() - { - super("gnu.classpath", null); - } - - /** - * Variable-arguments log method. - * - * @param level The level to log to. - * @param format The format string. - * @param args The arguments. - */ - public void logv(Level level, String format, Object... args) - { - log(level, format, args); - } -} diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/TeeInputStream.java b/openjdk/icedtea/jce/gnu/classpath/debug/TeeInputStream.java deleted file mode 100644 index ef6b2ed3..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/TeeInputStream.java +++ /dev/null @@ -1,98 +0,0 @@ -/* TeeInputStream.java - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.io.*; - -/** - * An input stream that copies all its input to a byte sink. - * - * @author Chris Burdess - */ -public class TeeInputStream - extends InputStream -{ - - private final InputStream in; - private final OutputStream out; - - /** - * Constructs a tee input stream. - * @param in the underlying input stream - * @param out the output sink - */ - public TeeInputStream(InputStream in, OutputStream out) - { - this.in = in; - this.out = out; - } - - public int read() - throws IOException - { - int ret = in.read(); - out.write(ret); - out.flush(); - return ret; - } - - public int read(byte[] b, int off, int len) - throws IOException - { - int ret = in.read(b, off, len); - if (ret != -1) - { - out.write(b, off, ret); - out.flush(); - } - return ret; - } - - public void close() - throws IOException - { - in.close(); - out.close(); - } - - public final boolean markSupported() - { - return false; - } - -} diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/TeeOutputStream.java b/openjdk/icedtea/jce/gnu/classpath/debug/TeeOutputStream.java deleted file mode 100644 index cff60894..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/TeeOutputStream.java +++ /dev/null @@ -1,93 +0,0 @@ -/* TeeOutputStream.java - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.io.*; - -/** - * An output stream that copies all its output to an additional byte sink. - * - * @author Chris Burdess - */ -public class TeeOutputStream - extends OutputStream -{ - - private final OutputStream out; - private final OutputStream sink; - - /** - * Constructs a tee output stream. - * @param out the underlying output stream - * @param sink the output sink - */ - public TeeOutputStream(OutputStream out, OutputStream sink) - { - this.out = out; - this.sink = sink; - } - - public void write(int c) - throws IOException - { - out.write(c); - sink.write(c); - } - - public void write(byte[] b, int off, int len) - throws IOException - { - out.write(b, off, len); - sink.write(b, off, len); - } - - public void flush() - throws IOException - { - out.flush(); - sink.flush(); - } - - public void close() - throws IOException - { - out.close(); - sink.close(); - } - -} diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/TeeReader.java b/openjdk/icedtea/jce/gnu/classpath/debug/TeeReader.java deleted file mode 100644 index 8fa742e2..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/TeeReader.java +++ /dev/null @@ -1,98 +0,0 @@ -/* TeeReader.java - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.io.*; - -/** - * A reader that copies all characters read to an output sink. - * - * @author Chris Burdess - */ -public class TeeReader - extends Reader -{ - - private final Reader in; - private final Writer out; - - /** - * Constructs a tee reader. - * @param in the input - * @param out the output sink - */ - public TeeReader(Reader in, Writer out) - { - this.in = in; - this.out = out; - } - - public int read() - throws IOException - { - int ret = in.read(); - out.write(ret); - out.flush(); - return ret; - } - - public int read(char[] b, int off, int len) - throws IOException - { - int ret = in.read(b, off, len); - if (ret != -1) - { - out.write(b, off, ret); - out.flush(); - } - return ret; - } - - public void close() - throws IOException - { - in.close(); - out.close(); - } - - public final boolean markSupported() - { - return false; - } - -} diff --git a/openjdk/icedtea/jce/gnu/classpath/debug/TeeWriter.java b/openjdk/icedtea/jce/gnu/classpath/debug/TeeWriter.java deleted file mode 100644 index f226c216..00000000 --- a/openjdk/icedtea/jce/gnu/classpath/debug/TeeWriter.java +++ /dev/null @@ -1,93 +0,0 @@ -/* TeeWriter.java - Copyright (C) 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.classpath.debug; - -import java.io.*; - -/** - * A writer that copies all its output to an additional character sink. - * - * @author Chris Burdess - */ -public class TeeWriter - extends Writer -{ - - private final Writer out; - private final Writer sink; - - /** - * Constructs a tee writer. - * @param out the underlying writer - * @param sink the output sink - */ - public TeeWriter(Writer out, Writer sink) - { - this.out = out; - this.sink = sink; - } - - public void write(int c) - throws IOException - { - out.write(c); - sink.write(c); - } - - public void write(char[] b, int off, int len) - throws IOException - { - out.write(b, off, len); - sink.write(b, off, len); - } - - public void flush() - throws IOException - { - out.flush(); - sink.flush(); - } - - public void close() - throws IOException - { - out.close(); - sink.close(); - } - -} diff --git a/openjdk/icedtea/jce/gnu/java/io/Base64InputStream.java b/openjdk/icedtea/jce/gnu/java/io/Base64InputStream.java deleted file mode 100644 index 1f5d220d..00000000 --- a/openjdk/icedtea/jce/gnu/java/io/Base64InputStream.java +++ /dev/null @@ -1,220 +0,0 @@ -/* Base64InputStream.java -- base-64 input stream. - Copyright (C) 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.io; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.FilterInputStream; -import java.io.IOException; -import java.io.InputStream; - -/** - * A filter input stream that decodes data encoded in the Base-64 - * encoding scheme. - * - * @author Casey Marshall (rsdio@metastatic.org) - */ -public class Base64InputStream extends FilterInputStream -{ - - // Constants and fields. - // ------------------------------------------------------------------------ - - /** Base-64 digits. */ - private static final String BASE_64 = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - /** Base-64 padding character. */ - private static final char BASE_64_PAD = '='; - - /** Decoding state. */ - private int state; - - /** Intermediate decoded value. */ - private int temp; - - /** EOF flag. */ - private boolean eof; - - private final byte[] one = new byte[1]; - - // Constructors. - // ------------------------------------------------------------------------ - - /** - * Create a new Base-64 input stream. The input bytes must be the - * ASCII characters A-Z, a-z, 0-9, + and /, with optional whitespace, - * and will be decoded into a byte stream. - * - * @param in The source of Base-64 input. - */ - public Base64InputStream(InputStream in) - { - super(in); - state = 0; - temp = 0; - eof = false; - } - - // Class method. - // ------------------------------------------------------------------------ - - /** - * Decode a single Base-64 string to a byte array. - * - * @param base64 The Base-64 encoded data. - * @return The decoded bytes. - * @throws IOException If the given data do not compose a valid Base-64 - * sequence. - */ - public static byte[] decode(String base64) throws IOException - { - Base64InputStream in = - new Base64InputStream(new ByteArrayInputStream(base64.getBytes())); - ByteArrayOutputStream out = - new ByteArrayOutputStream((int) (base64.length() / 0.666)); - byte[] buf = new byte[1024]; - int len; - while ((len = in.read(buf)) != -1) - out.write(buf, 0, len); - return out.toByteArray(); - } - - // Instance methods. - // ------------------------------------------------------------------------ - - public int available() - { - return 0; - } - - public int read() throws IOException - { - if (read(one) == 1) - return one[0]; - return -1; - } - - public int read(byte[] buf, int off, int len) throws IOException - { - if (eof) - return -1; - int count = 0; - while (count < len) - { - int i; - while (Character.isWhitespace((char) (i = in.read()))) - ; - - int pos = BASE_64.indexOf((char) i); - if (pos >= 0) - { - switch (state) - { - case 0: - temp = pos << 2; - state = 1; - break; - case 1: - buf[count++] = (byte) (temp | (pos >>> 4)); - temp = (pos & 0x0F) << 4; - state = 2; - break; - case 2: - buf[count++] = (byte) (temp | (pos >>> 2)); - temp = (pos & 0x03) << 6; - state = 3; - break; - case 3: - buf[count++] = (byte) (temp | pos); - state = 0; - break; - } - } - else if (i == BASE_64_PAD) - { - switch (state) - { - case 0: - case 1: - throw new IOException("malformed Base-64 input"); - case 2: - while (Character.isWhitespace((char) (i = in.read()))) - ; - if (i != BASE_64_PAD) - throw new IOException("malformed Base-64 input"); - case 3: - while (Character.isWhitespace((char) (i = in.read()))) - ; - } - eof = true; - break; - } - else // First non-Base-64 character, consider it end-of-stream. - { - if (state != 0) - throw new IOException("malformed Base-64 input"); - eof = true; - break; - } - } - return count; - } - - public boolean markSupported() - { - return false; - } - - public void mark(int markLimit) { } - - public void reset() throws IOException - { - throw new IOException("reset not supported"); - } - - public long skip(long n) throws IOException - { - long skipped; - for (skipped = 0; skipped < n; skipped++) - if (read() == -1) - break; - return skipped; - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/Configuration.java b/openjdk/icedtea/jce/gnu/java/security/Configuration.java deleted file mode 100644 index bf68006c..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/Configuration.java +++ /dev/null @@ -1,56 +0,0 @@ -/* Configuration.java -- - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security; - -/** - * This file defines compile-time constants that can be accessed by - * our crypto code. All crypto code should use and define such - * constants here instead of using the gnu.classpath.Configuration class. - */ -public interface Configuration -{ - - /** - * The value of DEBUG is substituted according to whether the - * "--enable-debug" argument was passed to configure. Code - * which is made conditional based on the value of this flag - typically - * code that generates debugging output - will be removed by the optimizer - * in a non-debug build. - */ - boolean DEBUG = false; -} diff --git a/openjdk/icedtea/jce/gnu/java/security/Engine.java b/openjdk/icedtea/jce/gnu/java/security/Engine.java deleted file mode 100644 index 44318af8..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/Engine.java +++ /dev/null @@ -1,280 +0,0 @@ -/* Engine -- generic getInstance method. - Copyright (C) 2003, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; - -import java.security.NoSuchAlgorithmException; -import java.security.Provider; -import java.util.Enumeration; - -/** - * Generic implementation of the getInstance methods in the various - * engine classes in java.security. - *(X509Certificate.java:163) - * ... - * 2006-02-27 21:59:12.0895 +1100 -1343151280 RSAKeyPairX509Codec decodePublicKey() FINER - ENTRY [B@b00d7fd0 - * 2006-02-27 21:59:12.0897 +1100 -1343151280 RSAKeyPairX509Codec decodePublicKey() FINER - RETURN gnu.java.security.key.rsa.GnuRSAPublicKey@b00fb940 - *
- * 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
- */
-public 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;
-
- /** Argument list for no-argument constructors. */
- private static final Object[] NO_ARGS = new Object[0];
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /** This class cannot be instantiated. */
- private Engine() { }
-
- /**
- * Return the implementation for algorithm for service service
- * from provider. 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 InvocationTargetException If the SPI class's constructor throws an
- * exception.
- * @throws IllegalArgumentException If any of the three arguments is null.
- */
- public static Object getInstance(String service, String algorithm,
- Provider provider)
- throws InvocationTargetException, NoSuchAlgorithmException
- {
- return getInstance(service, algorithm, provider, NO_ARGS);
- }
-
- /**
- * Return the implementation for algorithm for service service
- * from provider, passing initArgs to the SPI class's
- * constructor (which cannot be null; pass a zero-length array if the SPI
- * takes no arguments). 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.
- * @param initArgs The arguments to pass to the SPI class's constructor
- * (cannot be null).
- * @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 InvocationTargetException If the SPI class's constructor throws an
- * exception.
- * @throws IllegalArgumentException If any of the four arguments is
- * null
or if either service
, or
- * algorithm
is an empty string.
- */
- public static Object getInstance(String service, String algorithm,
- Provider provider, Object[] initArgs)
- throws InvocationTargetException, NoSuchAlgorithmException
- {
- if (service == null)
- throw new IllegalArgumentException("service MUST NOT be null");
- service = service.trim();
- if (service.length() == 0)
- throw new IllegalArgumentException("service MUST NOT be empty");
- if (algorithm == null)
- throw new IllegalArgumentException("algorithm MUST NOT be null");
- algorithm = algorithm.trim();
- if (algorithm.length() == 0)
- throw new IllegalArgumentException("algorithm MUST NOT be empty");
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- if (initArgs == null)
- throw new IllegalArgumentException("Constructor's parameters MUST NOT be null");
-
- Enumeration enumer = provider.propertyNames();
- String key;
- String alias;
- int count = 0;
- boolean algorithmFound = false;
- StringBuilder sb = new StringBuilder();
- while (enumer.hasMoreElements())
- {
- key = (String) enumer.nextElement();
- if (key.equalsIgnoreCase(service + "." + algorithm))
- {
- // remove the service portion from the key
- algorithm = key.substring(service.length() + 1);
- algorithmFound = true;
- break;
- }
- else if (key.equalsIgnoreCase(ALG_ALIAS + service + "." + algorithm))
- {
- alias = (String) provider.getProperty(key);
- if (! algorithm.equalsIgnoreCase(alias)) // does not refer to itself
- {
- algorithm = alias;
- if (count++ > MAX_ALIASES)
- {
- sb.append("Algorithm [").append(algorithm)
- .append("] of type [").append(service)
- .append("] from provider [").append(provider)
- .append("] has too many aliases");
- throw new NoSuchAlgorithmException(sb.toString());
- }
- // need to reset enumeration to now look for the alias
- enumer = provider.propertyNames();
- }
- }
- }
-
- if (! algorithmFound)
- {
- sb.append("Algorithm [").append(algorithm).append("] of type [")
- .append(service).append("] from provider [")
- .append(provider).append("] is not found");
- throw new NoSuchAlgorithmException(sb.toString());
- }
-
- // Find and instantiate the implementation
- Class clazz = null;
- ClassLoader loader = provider.getClass().getClassLoader();
- Constructor constructor = null;
- String className = provider.getProperty(service + "." + algorithm);
- sb.append("Class [").append(className).append("] for algorithm [")
- .append(algorithm).append("] of type [").append(service)
- .append("] from provider [").append(provider).append("] ");
- Throwable cause = null;
- try
- {
- if (loader != null)
- clazz = loader.loadClass(className);
- else
- clazz = Class.forName(className);
- constructor = getCompatibleConstructor(clazz, initArgs);
- return constructor.newInstance(initArgs);
- }
- catch (ClassNotFoundException x)
- {
- sb.append("cannot not be found");
- cause = x;
- }
- catch (IllegalAccessException x)
- {
- sb.append("cannot be accessed");
- cause = x;
- }
- catch (InstantiationException x)
- {
- sb.append("cannot be instantiated");
- cause = x;
- }
- catch (ExceptionInInitializerError x)
- {
- sb.append("cannot be initialized");
- cause = x;
- }
- catch (SecurityException x)
- {
- sb.append("caused a security violation");
- cause = x;
- }
- catch (NoSuchMethodException x)
- {
- sb.append("does not have/expose an appropriate constructor");
- cause = x;
- }
-
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Find a constructor in the given class that can take the specified
- * argument list, allowing any of which to be null.
- *
- * @param clazz The class from which to get the constructor.
- * @param initArgs The argument list to be passed to the constructor.
- * @return The constructor.
- * @throws NoSuchMethodException If no constructor of the given class
- * can take the specified argument array.
- */
- private static Constructor getCompatibleConstructor(Class clazz,
- Object[] initArgs)
- throws NoSuchMethodException
- {
- Constructor[] c = clazz.getConstructors();
- outer:for (int i = 0; i < c.length; i++)
- {
- Class[] argTypes = c[i].getParameterTypes();
- if (argTypes.length != initArgs.length)
- continue;
- for (int j = 0; j < argTypes.length; j++)
- {
- if (initArgs[j] != null &&
- !argTypes[j].isAssignableFrom(initArgs[j].getClass()))
- continue outer;
- }
- // If we reach this point, we know this constructor (c[i]) has
- // the same number of parameters as the target parameter list,
- // and all our parameters are either (1) null, or (2) assignable
- // to the target parameter type.
- return c[i];
- }
- throw new NoSuchMethodException();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/OID.java b/openjdk/icedtea/jce/gnu/java/security/OID.java
deleted file mode 100644
index f61cf0fc..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/OID.java
+++ /dev/null
@@ -1,510 +0,0 @@
-/* OID.java -- numeric representation of an object identifier
- Copyright (C) 2003, 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security;
-
-import gnu.java.security.der.DEREncodingException;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.StringTokenizer;
-
-/**
- * This immutable class represents an object identifier, or OID.
- *
- *
OIDs are represented as a series of hierarchical tokens, each of - * which is usually represented as a single, unsigned integer. The - * hierarchy works so that later tokens are considered within the group - * of earlier tokens. Thus, the OID for the Serpent block cipher, - * 1.3.6.1.4.1.11591.13.2, is maintained by the GNU project, whose OID - * is 1.3.6.1.4.1.11591 (which is, in turn, part of bigger, more general - * bodies; the topmost, 1, stands for the OIDs assigned by the - * International Standards Organization, ISO). - * - *
OIDs can be represented in a variety of ways, including the - * dotted-decimal form we use here. - * - *
OIDs may be relative, in which case the first two elements of the - * OID are omitted. - * - * @author Casey Marshall (csm@gnu.org) - */ -public class OID implements Cloneable, Comparable, java.io.Serializable -{ - - // Fields. - // ------------------------------------------------------------------------ - - /* Serial version id for serialization. */ - static final long serialVersionUID = 5722492029044597779L; - - /** - * The numeric ID structure. - */ - private int[] components; - - /** - * The string representation of this OID, in dotted-decimal format. - */ - private transient String strRep; - - /** - * The DER encoding of this OID. - */ - private transient byte[] der; - - /** - * Whether or not this OID is relative. - */ - private boolean relative; - - // Constructors. - // ------------------------------------------------------------------------ - - /** - * Create a new OID from the given byte array. The argument (which can - * neither be null nor zero-length) is copied to prevent subsequent - * modification. - * - * @param components The numeric IDs. - * @throws IllegalArgumentException If components is null or empty. - */ - public OID(int[] components) - { - this(components, false); - } - - /** - * Create a new OID from the given byte array. The argument (which can - * neither be null nor zero-length) is copied to prevent subsequent - * modification. - * - * @param components The numeric IDs. - * @param relative The relative flag. - * @throws IllegalArgumentException If components is null or empty. - */ - public OID(int[] components, boolean relative) - { - if (components == null || components.length == 0) - throw new IllegalArgumentException(); - this.components = (int[]) components.clone(); - this.relative = relative; - } - - /** - * Create a new OID from the given dotted-decimal representation. - * - * @param strRep The string representation of the OID. - * @throws IllegalArgumentException If the string does not contain at - * least one integer. - * @throws NumberFormatException If the string does not contain only - * numbers and periods ('.'). - */ - public OID(String strRep) - { - this(strRep, false); - } - - /** - * Create a new OID from the given dotted-decimal representation. - * - * @param strRep The string representation of the OID. - * @param relative The relative flag. - * @throws IllegalArgumentException If the string does not contain at - * least one integer. - * @throws NumberFormatException If the string does not contain only - * numbers and periods ('.'). - */ - public OID(String strRep, boolean relative) - { - this.relative = relative; - this.strRep = strRep; - components = fromString(strRep); - } - - /** - * Construct a new OID from the DER bytes in an input stream. This method - * does not read the tag or the length field from the input stream, so - * the caller must supply the number of octets in this OID's encoded - * form. - * - * @param derIn The DER input stream. - * @param len The number of bytes in the encoded form. - * @throws IOException If an error occurs reading the OID. - */ - public OID(InputStream derIn, int len) throws IOException - { - this(derIn, len, false); - } - - /** - * Construct a new OID from the DER bytes in an input stream. This method - * does not read the tag or the length field from the input stream, so - * the caller must supply the number of octets in this OID's encoded - * form. - * - * @param derIn The DER input stream. - * @param len The number of bytes in the encoded form. - * @param relative The relative flag. - * @throws IOException If an error occurs reading the OID. - */ - public OID(InputStream derIn, int len, boolean relative) throws IOException - { - der = new byte[len]; - derIn.read(der); - this.relative = relative; - try - { - components = fromDER(der, relative); - } - catch (ArrayIndexOutOfBoundsException aioobe) - { - aioobe.printStackTrace(); - throw aioobe; - } - } - - /** - * Construct a new OID from the given DER bytes. - * - * @param encoded The DER encoded OID. - * @throws IOException If an error occurs reading the OID. - */ - public OID(byte[] encoded) throws IOException - { - this(encoded, false); - } - - /** - * Construct a new OID from the given DER bytes. - * - * @param encoded The encoded relative OID. - * @param relative The relative flag. - */ - public OID(byte[] encoded, boolean relative) throws IOException - { - der = (byte[]) encoded.clone(); - this.relative = relative; - try - { - components = fromDER(der, relative); - } - catch (ArrayIndexOutOfBoundsException aioobe) - { - aioobe.printStackTrace(); - throw aioobe; - } - } - - // Instance methods. - // ------------------------------------------------------------------------ - - /** - * Return the numeric IDs of this OID. The value returned is copied to - * prevent modification. - * - * @return The IDs in a new integer array. - */ - public int[] getIDs() - { - return (int[]) components.clone(); - } - - /** - * Get the DER encoding of this OID, minus the tag and length fields. - * - * @return The DER bytes. - */ - public byte[] getDER() - { - if (der == null) - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - int i = 0; - if (!relative) - { - int b = components[i++] * 40 + (components.length > 1 - ? components[i++] : 0); - encodeSubID(bout, b); - } - for ( ; i < components.length; i++) - encodeSubID(bout, components[i]); - der = bout.toByteArray(); - } - return (byte[]) der.clone(); - } - - /** - * Get the parent OID of this OID. That is, if this OID is "1.2.3.4", - * then the parent OID will be "1.2.3". If this OID is a top-level - * OID, this method returns null. - * - * @return The parent OID, or null. - */ - public OID getParent() - { - if (components.length == 1) - return null; - int[] parent = new int[components.length - 1]; - System.arraycopy(components, 0, parent, 0, parent.length); - return new OID(parent); - } - - public OID getChild(int id) - { - int[] child = new int[components.length + 1]; - System.arraycopy(components, 0, child, 0, components.length); - child[child.length - 1] = id; - return new OID(child); - } - - /** - * Get the root OID of this OID. That is, the first two components. - * - * @return The root OID. - */ - public OID getRoot() - { - if (components.length <= 2) - return this; - int[] root = new int[2]; - root[0] = components[0]; - root[1] = components[1]; - return new OID(root); - } - - public boolean isRelative() - { - return relative; - } - - /** - * Returns a copy of this OID. - * - * @return The copy. - */ - public Object clone() - { - try - { - return super.clone(); - } - catch (CloneNotSupportedException cnse) - { - InternalError ie = new InternalError(); - ie.initCause(cnse); - throw ie; - } - } - - /* Nice idea, but possibly too expensive for whatever benefit it - * provides. - - public String getShortName() - { - return OIDTable.getShortName(this); - } - - public String getLongName() - { - return OIDTable.getLongName(this); - } - - */ - - /** - * Returns the value of this OID in dotted-decimal format. - * - * @return The string representation. - */ - public String toString() - { - if (strRep != null) - return strRep; - else - { - StringBuffer buf = new StringBuffer(); - for (int i = 0; i < components.length; i++) - { - buf.append((long) components[i] & 0xFFFFFFFFL); - if (i < components.length - 1) - buf.append('.'); - } - return (strRep = buf.toString()); - } - } - - /** - * Computes a hash code for this OID. - * - * @return The hash code. - */ - public int hashCode() - { - int ret = 0; - for (int i = 0; i < components.length; i++) - ret += components[i] << (i & 31); - return ret; - } - - /** - * Tests whether or not this OID equals another. - * - * @return Whether or not this OID equals the other. - */ - public boolean equals(Object o) - { - if (!(o instanceof OID)) - return false; - return java.util.Arrays.equals(components, ((OID) o).components); - } - - /** - * Compares this OID to another. The comparison is essentially - * lexicographic, where the two OIDs are compared until their - * first difference, then that difference is returned. If one OID is - * shorter, but all elements equal between the two for the shorter - * length, then the shorter OID is lesser than the longer. - * - * @param o The object to compare. - * @return An integer less than, equal to, or greater than zero if - * this object is less than, equal to, or greater than the - * argument. - * @throws ClassCastException If o is not an OID. - */ - public int compareTo(Object o) - { - if (equals(o)) - return 0; - int[] components2 = ((OID) o).components; - int len = Math.min(components.length, components2.length); - for (int i = 0; i < len; i++) - { - if (components[i] != components2[i]) - return (components[i] < components2[i]) ? -1 : 1; - } - if (components.length == components2.length) - return 0; - return (components.length < components2.length) ? -1 : 1; - } - - // Own methods. - // ------------------------------------------------------------------------ - - private static int[] fromDER(byte[] der, boolean relative) - throws DEREncodingException - { - // cannot be longer than this. - int[] components = new int[der.length + 1]; - int count = 0; - int i = 0; - if (!relative && i < der.length) - { - // Non-relative OIDs have the first two arcs coded as: - // - // i = first_arc * 40 + second_arc; - // - int j = (der[i] & 0xFF); - components[count++] = j / 40; - components[count++] = j % 40; - i++; - } - while (i < der.length) - { - int j = 0; - do - { - j = der[i++] & 0xFF; - components[count] <<= 7; - components[count] |= j & 0x7F; - if (i >= der.length && (j & 0x80) != 0) - throw new DEREncodingException("malformed OID"); - } - while ((j & 0x80) != 0); - count++; - } - if (count == components.length) - return components; - int[] ret = new int[count]; - System.arraycopy(components, 0, ret, 0, count); - return ret; - } - - private static int[] fromString(String strRep) throws NumberFormatException - { - if (strRep.startsWith("OID.") || strRep.startsWith("oid.")) - strRep = strRep.substring(4); - StringTokenizer tok = new StringTokenizer(strRep, "."); - if (tok.countTokens() == 0) - throw new IllegalArgumentException(); - int[] components = new int[tok.countTokens()]; - int i = 0; - while (tok.hasMoreTokens()) - { - components[i++] = Integer.parseInt(tok.nextToken()); - } - return components; - } - - private static void encodeSubID(ByteArrayOutputStream out, int id) - { - if (id < 128) - { - out.write(id); - } - else if (id < 16384) - { - out.write((id >>> 7) | 0x80); - out.write(id & 0x7F); - } - else if (id < 2097152) - { - out.write((id >>> 14) | 0x80); - out.write(((id >>> 7) | 0x80) & 0xFF); - out.write(id & 0x7F); - } - else if (id < 268435456) - { - out.write( (id >>> 21) | 0x80); - out.write(((id >>> 14) | 0x80) & 0xFF); - out.write(((id >>> 7) | 0x80) & 0xFF); - out.write(id & 0x7F); - } - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/PolicyFile.java b/openjdk/icedtea/jce/gnu/java/security/PolicyFile.java deleted file mode 100644 index 8da3a7d7..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/PolicyFile.java +++ /dev/null @@ -1,685 +0,0 @@ -/* PolicyFile.java -- policy file reader - Copyright (C) 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security; - -import gnu.classpath.debug.Component; -import gnu.classpath.debug.SystemLogger; -import gnu.java.security.action.GetPropertyAction; - -import java.io.File; -import java.io.IOException; -import java.io.InputStreamReader; -import java.io.StreamTokenizer; -import java.lang.reflect.Constructor; -import java.net.MalformedURLException; -import java.net.URL; -import java.security.AccessController; -import java.security.CodeSource; -import java.security.KeyStore; -import java.security.KeyStoreException; -import java.security.Permission; -import java.security.PermissionCollection; -import java.security.Permissions; -import java.security.Policy; -import java.security.Principal; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; -import java.security.Security; -import java.security.UnresolvedPermission; -import java.security.cert.Certificate; -import java.security.cert.X509Certificate; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.logging.Logger; - -/** - * An implementation of a {@link java.security.Policy} object whose - * permissions are specified by a policy file. - * - *
The approximate syntax of policy files is:
- * - *- * policyFile ::= keystoreOrGrantEntries ; - * - * keystoreOrGrantEntries ::= keystoreOrGrantEntry | - * keystoreOrGrantEntries keystoreOrGrantEntry | - * EMPTY ; - * - * keystoreOrGrantEntry ::= keystoreEntry | grantEntry ; - * - * keystoreEntry ::= "keystore" keystoreUrl ';' | - * "keystore" keystoreUrl ',' keystoreAlgorithm ';' ; - * - * keystoreUrl ::= URL ; - * keystoreAlgorithm ::= STRING ; - * - * grantEntry ::= "grant" domainParameters '{' permissions '}' ';' - * - * domainParameters ::= domainParameter | - * domainParameter ',' domainParameters ; - * - * domainParameter ::= "signedBy" signerNames | - * "codeBase" codeBaseUrl | - * "principal" principalClassName principalName | - * "principal" principalName ; - * - * signerNames ::= quotedString ; - * codeBaseUrl ::= URL ; - * principalClassName ::= STRING ; - * principalName ::= quotedString ; - * - * quotedString ::= quoteChar STRING quoteChar ; - * quoteChar ::= '"' | '\''; - * - * permissions ::= permission | permissions permission ; - * - * permission ::= "permission" permissionClassName permissionTarget permissionAction | - * "permission" permissionClassName permissionTarget | - * "permission" permissionClassName; - *- * - *
Comments are either form of Java comments. Keystore entries only
- * affect subsequent grant entries, so if a grant entry preceeds a
- * keystore entry, that grant entry is not affected by that keystore
- * entry. Certian instances of ${property-name}
will be
- * replaced with System.getProperty("property-name")
in
- * quoted strings.
This class will load the following files when created or - * refreshed, in order:
- * - *${java.home}/lib/security/java.policy
."policy.file.n"
, for increasing n
- * starting from 1. The sequence stops at the first undefined
- * property, so you must set "policy.file.1"
if you also
- * set "policy.file.2"
, and so on."java.security.policy"
."${property-name}"
into
- * System.getProperty("property-name")
.
- */
- private static String expand(final String s)
- {
- final StringBuffer result = new StringBuffer();
- final StringBuffer prop = new StringBuffer();
- int state = 0;
- for (int i = 0; i < s.length(); i++)
- {
- switch (state)
- {
- case 0:
- if (s.charAt(i) == '$')
- state = 1;
- else
- result.append(s.charAt(i));
- break;
- case 1:
- if (s.charAt(i) == '{')
- state = 2;
- else
- {
- state = 0;
- result.append('$').append(s.charAt(i));
- }
- break;
- case 2:
- if (s.charAt(i) == '}')
- {
- String p = prop.toString();
- if (p.equals("/"))
- p = "file.separator";
- p = System.getProperty(p);
- if (p == null)
- p = "";
- result.append(p);
- prop.setLength(0);
- state = 0;
- }
- else
- prop.append(s.charAt(i));
- break;
- }
- }
- if (state != 0)
- result.append('$').append('{').append(prop);
- return result.toString();
- }
-
- /**
- * I miss macros.
- */
- private static void error(URL base, StreamTokenizer in, String msg)
- throws IOException
- {
- throw new IOException(base+":"+in.lineno()+": "+msg);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/Properties.java b/openjdk/icedtea/jce/gnu/java/security/Properties.java
deleted file mode 100644
index a515a542..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/Properties.java
+++ /dev/null
@@ -1,348 +0,0 @@
-/* Properties.java -- run-time configuration properties.
- Copyright (C) 2003, 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security;
-
-import gnu.java.security.Configuration;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.util.HashMap;
-import java.util.PropertyPermission;
-import java.util.logging.Logger;
-
-/**
- * A global object containing build-specific properties that affect the
- * behaviour of the generated binaries from this library.
- */
-public final class Properties
-{
- private static final Logger log = Logger.getLogger(Properties.class.getName());
-
- public static final String VERSION = "gnu.crypto.version";
-
- public static final String PROPERTIES_FILE = "gnu.crypto.properties.file";
-
- public static final String REPRODUCIBLE_PRNG = "gnu.crypto.with.reproducible.prng";
-
- public static final String CHECK_WEAK_KEYS = "gnu.crypto.with.check.for.weak.keys";
-
- public static final String DO_RSA_BLINDING = "gnu.crypto.with.rsa.blinding";
-
- private static final String TRUE = Boolean.TRUE.toString();
-
- private static final String FALSE = Boolean.FALSE.toString();
-
- private static final HashMap props = new HashMap();
-
- private static Properties singleton = null;
-
- private boolean reproducible = false;
-
- private boolean checkForWeakKeys = true;
-
- private boolean doRSABlinding = true;
-
- /** Trivial constructor to enforce Singleton pattern. */
- private Properties()
- {
- super();
- init();
- }
-
- /**
- * Returns the string representation of the library global configuration
- * property with the designated key
.
- *
- * @param key the case-insensitive, non-null and non-empty name of a
- * configuration property.
- * @return the string representation of the designated property, or
- * null
if such property is not yet set, or
- * key
is empty.
- */
- public static final synchronized String getProperty(String key)
- {
- if (key == null)
- return null;
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(key, "read"));
- key = key.trim().toLowerCase();
- if ("".equals(key))
- return null;
- return (String) props.get(key);
- }
-
- /**
- * Sets the value of a designated library global configuration property, to a
- * string representation of what should be a legal value.
- *
- * @param key the case-insensitive, non-null and non-empty name of a
- * configuration property.
- * @param value the non-null, non-empty string representation of a legal value
- * of the configuration property named by key
.
- */
- public static final synchronized void setProperty(String key, String value)
- {
- if (key == null || value == null)
- return;
- key = key.trim().toLowerCase();
- if ("".equals(key))
- return;
- if (key.equals(VERSION))
- return;
- value = value.trim();
- if ("".equals(value))
- return;
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(key, "write"));
- if (key.equals(REPRODUCIBLE_PRNG)
- && (value.equalsIgnoreCase(TRUE) || value.equalsIgnoreCase(FALSE)))
- setReproducible(Boolean.valueOf(value).booleanValue());
- else if (key.equals(CHECK_WEAK_KEYS)
- && (value.equalsIgnoreCase(TRUE) || value.equalsIgnoreCase(FALSE)))
- setCheckForWeakKeys(Boolean.valueOf(value).booleanValue());
- else if (key.equals(DO_RSA_BLINDING)
- && (value.equalsIgnoreCase(TRUE) || value.equalsIgnoreCase(FALSE)))
- setDoRSABlinding(Boolean.valueOf(value).booleanValue());
- else
- props.put(key, value);
- }
-
- /**
- * A convenience method that returns, as a boolean, the library global
- * configuration property indicating if the default Pseudo Random Number
- * Generator produces, or not, the same bit stream when instantiated.
- *
- * @return true
if the default PRNG produces the same bit
- * stream with every VM instance. Returns false
if the
- * default PRNG is seeded with the time of day of its first
- * invocation.
- */
- public static final synchronized boolean isReproducible()
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(REPRODUCIBLE_PRNG, "read"));
- return instance().reproducible;
- }
-
- /**
- * A convenience method that returns, as a boolean, the library global
- * configuration property indicating if the implementations of symmetric key
- * block ciphers check, or not, for possible/potential weak and semi-weak keys
- * that may be produced in the course of generating round encryption and/or
- * decryption keys.
- *
- * @return true
if the cipher implementations check for weak
- * and semi-weak keys. Returns false
if the cipher
- * implementations do not check for weak or semi-weak keys.
- */
- public static final synchronized boolean checkForWeakKeys()
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(CHECK_WEAK_KEYS, "read"));
- return instance().checkForWeakKeys;
- }
-
- /**
- * A convenience method that returns, as a boolean, the library global
- * configuration property indicating if RSA decryption (RSADP primitive),
- * does, or not, blinding against timing attacks.
- *
- * @return true
if the RSA decryption primitive includes a
- * blinding operation. Returns false
if the RSA
- * decryption primitive does not include the additional blinding
- * operation.
- */
- public static final synchronized boolean doRSABlinding()
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(DO_RSA_BLINDING, "read"));
- return instance().doRSABlinding;
- }
-
- /**
- * A convenience method to set the global property for reproducibility of the
- * default PRNG bit stream output.
- *
- * @param value if true
then the default PRNG bit stream output
- * is the same with every invocation of the VM.
- */
- public static final synchronized void setReproducible(final boolean value)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(REPRODUCIBLE_PRNG, "write"));
- instance().reproducible = value;
- props.put(REPRODUCIBLE_PRNG, String.valueOf(value));
- }
-
- /**
- * A convenience method to set the global property for checking for weak and
- * semi-weak cipher keys.
- *
- * @param value if true
then the cipher implementations will
- * invoke additional checks for weak and semi-weak key values that
- * may get generated.
- */
- public static final synchronized void setCheckForWeakKeys(final boolean value)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(CHECK_WEAK_KEYS, "write"));
- instance().checkForWeakKeys = value;
- props.put(CHECK_WEAK_KEYS, String.valueOf(value));
- }
-
- /**
- * A convenience method to set the global property fo adding a blinding
- * operation when executing the RSA decryption primitive.
- *
- * @param value if true
then the code for performing the RSA
- * decryption primitive will include a blinding operation.
- */
- public static final synchronized void setDoRSABlinding(final boolean value)
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new PropertyPermission(DO_RSA_BLINDING, "write"));
- instance().doRSABlinding = value;
- props.put(DO_RSA_BLINDING, String.valueOf(value));
- }
-
- private static final synchronized Properties instance()
- {
- if (singleton == null)
- singleton = new Properties();
- return singleton;
- }
-
- private void init()
- {
- // default values
- props.put(REPRODUCIBLE_PRNG, (reproducible ? "true" : "false"));
- props.put(CHECK_WEAK_KEYS, (checkForWeakKeys ? "true" : "false"));
- props.put(DO_RSA_BLINDING, (doRSABlinding ? "true" : "false"));
- // 1. allow site-wide override by reading a properties file
- String propFile = null;
- try
- {
- propFile = (String) AccessController.doPrivileged(new PrivilegedAction()
- {
- public Object run()
- {
- return System.getProperty(PROPERTIES_FILE);
- }
- });
- }
- catch (SecurityException se)
- {
- if (Configuration.DEBUG)
- log.fine("Reading property " + PROPERTIES_FILE + " not allowed. Ignored.");
- }
- if (propFile != null)
- {
- try
- {
- final java.util.Properties temp = new java.util.Properties();
- final FileInputStream fin = new FileInputStream(propFile);
- temp.load(fin);
- temp.list(System.out);
- props.putAll(temp);
- }
- catch (IOException ioe)
- {
- if (Configuration.DEBUG)
- log.fine("IO error reading " + propFile + ": " + ioe.getMessage());
- }
- catch (SecurityException se)
- {
- if (Configuration.DEBUG)
- log.fine("Security error reading " + propFile + ": "
- + se.getMessage());
- }
- }
- // 2. allow vm-specific override by allowing -D options in launcher
- handleBooleanProperty(REPRODUCIBLE_PRNG);
- handleBooleanProperty(CHECK_WEAK_KEYS);
- handleBooleanProperty(DO_RSA_BLINDING);
- // re-sync the 'known' properties
- reproducible = Boolean.valueOf((String) props.get(REPRODUCIBLE_PRNG)).booleanValue();
- checkForWeakKeys = Boolean.valueOf((String) props.get(CHECK_WEAK_KEYS)).booleanValue();
- doRSABlinding = Boolean.valueOf((String) props.get(DO_RSA_BLINDING)).booleanValue();
- // This does not change.
- props.put(VERSION, Registry.VERSION_STRING);
- }
-
- private void handleBooleanProperty(final String name)
- {
- String s = null;
- try
- {
- s = System.getProperty(name);
- }
- catch (SecurityException x)
- {
- if (Configuration.DEBUG)
- log.fine("SecurityManager forbids reading system properties. Ignored");
- }
- if (s != null)
- {
- s = s.trim().toLowerCase();
- // we have to test for explicit "true" or "false". anything else may
- // hide valid value set previously
- if (s.equals(TRUE) || s.equals(FALSE))
- {
- if (Configuration.DEBUG)
- log.fine("Setting " + name + " to '" + s + "'");
- props.put(name, s);
- }
- else
- {
- if (Configuration.DEBUG)
- log.fine("Invalid value for -D" + name + ": " + s + ". Ignored");
- }
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/Registry.java b/openjdk/icedtea/jce/gnu/java/security/Registry.java
deleted file mode 100644
index 053d7177..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/Registry.java
+++ /dev/null
@@ -1,465 +0,0 @@
-/* Registry.java --
- Copyright (C) 2001, 2002, 2003, 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security;
-
-/**
- * A placeholder for names and literals used throughout this
- * library.
- */
-public interface Registry
-{
- /** The name of our Providers. */
- String GNU_SECURITY = "GNU";
- String GNU_CRYPTO = "GNU-CRYPTO";
- String GNU_SASL = "GNU-SASL";
-
- /** Our version number. */
- String VERSION_STRING = "2.1.0";
-
- // Names of properties to use in Maps when initialising primitives .........
-
- // Symmetric block cipher algorithms and synonyms...........................
-
- String ANUBIS_CIPHER = "anubis";
-
- String BLOWFISH_CIPHER = "blowfish";
-
- String DES_CIPHER = "des";
-
- String KHAZAD_CIPHER = "khazad";
-
- String RIJNDAEL_CIPHER = "rijndael";
-
- String SERPENT_CIPHER = "serpent";
-
- String SQUARE_CIPHER = "square";
-
- String TRIPLEDES_CIPHER = "tripledes";
-
- String TWOFISH_CIPHER = "twofish";
-
- String CAST5_CIPHER = "cast5";
-
- String NULL_CIPHER = "null";
-
- /** AES is synonymous to Rijndael for 128-bit block size only. */
- String AES_CIPHER = "aes";
-
- /** TripleDES is also known as DESede. */
- String DESEDE_CIPHER = "desede";
-
- /** CAST5 is also known as CAST-128. */
- String CAST128_CIPHER = "cast128";
-
- String CAST_128_CIPHER = "cast-128";
-
- // Key Wrapping Algorithm names and synonyms ...............................
-
- String KWA_PREFIX = "kw-";
- String AES_KWA = KWA_PREFIX + AES_CIPHER;
- String AES128_KWA = AES_KWA + "128";
- String AES192_KWA = AES_KWA + "192";
- String AES256_KWA = AES_KWA + "256";
- String RIJNDAEL_KWA = KWA_PREFIX + RIJNDAEL_CIPHER;
-
- String TRIPLEDES_KWA = KWA_PREFIX + TRIPLEDES_CIPHER;
- String DESEDE_KWA = KWA_PREFIX + DESEDE_CIPHER;
-
- // Message digest algorithms and synonyms...................................
-
- String WHIRLPOOL_HASH = "whirlpool";
-
- String RIPEMD128_HASH = "ripemd128";
-
- String RIPEMD160_HASH = "ripemd160";
-
- String SHA160_HASH = "sha-160";
-
- String SHA256_HASH = "sha-256";
-
- String SHA384_HASH = "sha-384";
-
- String SHA512_HASH = "sha-512";
-
- String TIGER_HASH = "tiger";
-
- String HAVAL_HASH = "haval";
-
- String MD5_HASH = "md5";
-
- String MD4_HASH = "md4";
-
- String MD2_HASH = "md2";
-
- /** RIPEMD-128 is synonymous to RIPEMD128. */
- String RIPEMD_128_HASH = "ripemd-128";
-
- /** RIPEMD-160 is synonymous to RIPEMD160. */
- String RIPEMD_160_HASH = "ripemd-160";
-
- /** SHA-1 is synonymous to SHA-160. */
- String SHA_1_HASH = "sha-1";
-
- /** SHA1 is synonymous to SHA-160. */
- String SHA1_HASH = "sha1";
-
- /** SHA is synonymous to SHA-160. */
- String SHA_HASH = "sha";
-
- // Symmetric block cipher modes of operations...............................
-
- /** Electronic CodeBook mode. */
- String ECB_MODE = "ecb";
-
- /** Counter (NIST) mode. */
- String CTR_MODE = "ctr";
-
- /** Integer Counter Mode (David McGrew). */
- String ICM_MODE = "icm";
-
- /** Output Feedback Mode (NIST). */
- String OFB_MODE = "ofb";
-
- /** Cipher block chaining mode (NIST). */
- String CBC_MODE = "cbc";
-
- /** Cipher feedback mode (NIST). */
- String CFB_MODE = "cfb";
-
- /** Authenticated-Encrypted mode. */
- String EAX_MODE = "eax";
-
- // Padding scheme names and synonyms........................................
-
- /** PKCS#5 padding scheme. */
- String PKCS5_PAD = "pkcs5";
-
- /** PKCS#7 padding scheme. */
- String PKCS7_PAD = "pkcs7";
-
- /** Trailing Bit Complement padding scheme. */
- String TBC_PAD = "tbc";
-
- /** EME-PKCS1-v1_5 padding as described in section 7.2 in RFC-3447. */
- String EME_PKCS1_V1_5_PAD = "eme-pkcs1-v1.5";
-
- /** SSLv3 padding scheme. */
- String SSL3_PAD = "ssl3";
-
- /** TLSv1 padding scheme. */
- String TLS1_PAD = "tls1";
-
- /** ISO 10126-2 padding scheme. */
- String ISO10126_PAD = "iso10126";
-
- // Pseudo-random number generators..........................................
-
- /** (Apparently) RC4 keystream PRNG. */
- String ARCFOUR_PRNG = "arcfour";
-
- /** We use "rc4" as an alias for "arcfour". */
- String RC4_PRNG = "rc4";
-
- /** PRNG based on David McGrew's Integer Counter Mode. */
- String ICM_PRNG = "icm";
-
- /** PRNG based on a designated hash function. */
- String MD_PRNG = "md";
-
- /** PRNG based on UMAC's Key Derivation Function. */
- String UMAC_PRNG = "umac-kdf";
-
- /**
- * PRNG based on PBKDF2 from PKCS #5 v.2. This is suffixed with the name
- * of a MAC to be used as a PRF.
- */
- String PBKDF2_PRNG_PREFIX = "pbkdf2-";
-
- /** The continuously-seeded pseudo-random number generator. */
- String CSPRNG_PRNG = "csprng";
-
- /** The Fortuna PRNG. */
- String FORTUNA_PRNG = "fortuna";
-
- /** The Fortuna generator PRNG. */
- String FORTUNA_GENERATOR_PRNG = "fortuna-generator";
-
- // Asymmetric keypair generators............................................
-
- String DSS_KPG = "dss";
-
- String RSA_KPG = "rsa";
-
- String DH_KPG = "dh";
-
- String SRP_KPG = "srp";
-
- /** DSA is synonymous to DSS. */
- String DSA_KPG = "dsa";
-
- // Signature-with-appendix schemes..........................................
-
- String DSS_SIG = "dss";
-
- String RSA_SIG_PREFIX = "rsa-";
-
- String RSA_PSS_ENCODING = "pss";
-
- String RSA_PSS_SIG = RSA_SIG_PREFIX + RSA_PSS_ENCODING;
-
- String RSA_PKCS1_V1_5_ENCODING = "pkcs1-v1.5";
-
- String RSA_PKCS1_V1_5_SIG = RSA_SIG_PREFIX + RSA_PKCS1_V1_5_ENCODING;
-
- /** DSA is synonymous to DSS. */
- String DSA_SIG = "dsa";
-
- // Key agreement protocols .................................................
-
- String DH_KA = "dh";
-
- String ELGAMAL_KA = "elgamal";
-
- String SRP6_KA = "srp6";
-
- String SRP_SASL_KA = "srp-sasl";
-
- String SRP_TLS_KA = "srp-tls";
-
- // Keyed-Hash Message Authentication Code ..................................
-
- /** Name prefix of every HMAC implementation. */
- String HMAC_NAME_PREFIX = "hmac-";
-
- // Other MAC algorithms ....................................................
-
- /** The One-key CBC MAC. */
- String OMAC_PREFIX = "omac-";
-
- /** Message Authentication Code using Universal Hashing (Ted Krovetz). */
- String UHASH32 = "uhash32";
-
- String UMAC32 = "umac32";
-
- /** The Truncated Multi-Modular Hash Function -v1 (David McGrew). */
- String TMMH16 = "tmmh16";
-
- // String TMMH32 = "tmmh32";
-
- // Format IDs used to identify how we externalise asymmetric keys ..........
- // fully-qualified names of the supported codecs
- String RAW_ENCODING = "gnu.crypto.raw.format";
- String X509_ENCODING = "gnu.crypto.x509.format";
- String PKCS8_ENCODING = "gnu.crypto.pkcs8.format";
- String ASN1_ENCODING = "gnu.crypto.asn1.format";
-
- // short names of the same. used by JCE adapters
- String RAW_ENCODING_SHORT_NAME = "RAW";
- String X509_ENCODING_SORT_NAME = "X.509";
- String PKCS8_ENCODING_SHORT_NAME = "PKCS#8";
- String ASN1_ENCODING_SHORT_NAME = "ASN.1";
-
- // unique identifiers of the same
- int RAW_ENCODING_ID = 1;
- int X509_ENCODING_ID = 2;
- int PKCS8_ENCODING_ID = 3;
- int ASN1_ENCODING_ID = 4;
-
- // OID strings used in encoding/decoding keys
- String DSA_OID_STRING = "1.2.840.10040.4.1";
- String RSA_OID_STRING = "1.2.840.113549.1.1.1";
- String DH_OID_STRING = "1.2.840.10046.2.1";
-
- // Magic bytes we generate/expect in externalised asymmetric keys ..........
- // the four bytes represent G (0x47) for GNU, 1 (0x01) for Raw format,
- // D (0x44) for DSS, R (0x52) for RSA, H (0x48) for Diffie-Hellman, or S
- // (0x53) for SRP-6, and finally P (0x50) for Public, p (0x70) for private,
- // or S (0x53) for signature.
- byte[] MAGIC_RAW_DSS_PUBLIC_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x44, 0x50 };
-
- byte[] MAGIC_RAW_DSS_PRIVATE_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x44, 0x70 };
-
- byte[] MAGIC_RAW_DSS_SIGNATURE = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x44, 0x53 };
-
- byte[] MAGIC_RAW_RSA_PUBLIC_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x52, 0x50 };
-
- byte[] MAGIC_RAW_RSA_PRIVATE_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x52, 0x70 };
-
- byte[] MAGIC_RAW_RSA_PSS_SIGNATURE = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x52, 0x53 };
-
- byte[] MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x52, 0x54 };
-
- byte[] MAGIC_RAW_DH_PUBLIC_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x48, 0x50 };
-
- byte[] MAGIC_RAW_DH_PRIVATE_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x48, 0x70 };
-
- byte[] MAGIC_RAW_SRP_PUBLIC_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x53, 0x50 };
-
- byte[] MAGIC_RAW_SRP_PRIVATE_KEY = new byte[] {
- 0x47, RAW_ENCODING_ID, 0x53, 0x70 };
-
- // SASL Property names .....................................................
-
- String SASL_PREFIX = "gnu.crypto.sasl";
-
- /** Name of username property. */
- String SASL_USERNAME = SASL_PREFIX + ".username";
-
- /** Name of password property. */
- String SASL_PASSWORD = SASL_PREFIX + ".password";
-
- /** Name of authentication information provider packages. */
- String SASL_AUTH_INFO_PROVIDER_PKGS = SASL_PREFIX + ".auth.info.provider.pkgs";
-
- /** SASL authorization ID. */
- String SASL_AUTHORISATION_ID = SASL_PREFIX + ".authorisation.ID";
-
- /** SASL protocol. */
- String SASL_PROTOCOL = SASL_PREFIX + ".protocol";
-
- /** SASL Server name. */
- String SASL_SERVER_NAME = SASL_PREFIX + ".server.name";
-
- /** SASL Callback handler. */
- String SASL_CALLBACK_HANDLER = SASL_PREFIX + ".callback.handler";
-
- /** SASL channel binding. */
- String SASL_CHANNEL_BINDING = SASL_PREFIX + ".channel.binding";
-
- // SASL data element size limits ...........................................
-
- /** The size limit, in bytes, of a SASL OS (Octet Sequence) element. */
- int SASL_ONE_BYTE_MAX_LIMIT = 255;
-
- /**
- * The size limit, in bytes, of both a SASL MPI (Multi-Precision Integer)
- * element and a SASL Text element.
- */
- int SASL_TWO_BYTE_MAX_LIMIT = 65535;
-
- /** The size limit, in bytes, of a SASL EOS (Extended Octet Sequence) element. */
- int SASL_FOUR_BYTE_MAX_LIMIT = 2147483383;
-
- /** The size limit, in bytes, of a SASL Buffer. */
- int SASL_BUFFER_MAX_LIMIT = 2147483643;
-
- // Canonical names of SASL mechanisms ......................................
-
- String SASL_ANONYMOUS_MECHANISM = "ANONYMOUS";
-
- String SASL_CRAM_MD5_MECHANISM = "CRAM-MD5";
-
- String SASL_PLAIN_MECHANISM = "PLAIN";
-
- String SASL_SRP_MECHANISM = "SRP";
-
- // Canonical names of Integrity Protection algorithms ......................
-
- String SASL_HMAC_MD5_IALG = "HMACwithMD5";
-
- String SASL_HMAC_SHA_IALG = "HMACwithSHA";
-
- // Quality Of Protection string representations ............................
-
- /** authentication only. */
- String QOP_AUTH = "auth";
-
- /** authentication plus integrity protection. */
- String QOP_AUTH_INT = "auth-int";
-
- /** authentication plus integrity and confidentiality protection. */
- String QOP_AUTH_CONF = "auth-conf";
-
- // SASL mechanism strength string representation ...........................
-
- String STRENGTH_HIGH = "high";
-
- String STRENGTH_MEDIUM = "medium";
-
- String STRENGTH_LOW = "low";
-
- // SASL Server Authentication requirement ..................................
-
- /** Server must authenticate to the client. */
- String SERVER_AUTH_TRUE = "true";
-
- /** Server does not need to, or cannot, authenticate to the client. */
- String SERVER_AUTH_FALSE = "false";
-
- // SASL mechanism reuse capability .........................................
-
- String REUSE_TRUE = "true";
-
- String REUSE_FALSE = "false";
-
- // Keyrings ...............................................................
-
- byte[] GKR_MAGIC = new byte[] { 0x47, 0x4b, 0x52, 0x01 };
-
- // Ring usage fields.
- int GKR_PRIVATE_KEYS = 1 << 0;
-
- int GKR_PUBLIC_CREDENTIALS = 1 << 1;
-
- int GKR_CERTIFICATES = 1 << 2;
-
- // HMac types.
- int GKR_HMAC_MD5_128 = 0;
-
- int GKR_HMAC_SHA_160 = 1;
-
- int GKR_HMAC_MD5_96 = 2;
-
- int GKR_HMAC_SHA_96 = 3;
-
- // Cipher types.
- int GKR_CIPHER_AES_128_OFB = 0;
-
- int GKR_CIPHER_AES_128_CBC = 1;
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/Requires.java b/openjdk/icedtea/jce/gnu/java/security/Requires.java
deleted file mode 100644
index c820336c..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/Requires.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* Requires.java -- mark methods as requiring permission.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.Retention;
-import java.lang.annotation.Target;
-import static java.lang.annotation.ElementType.METHOD;
-import static java.lang.annotation.RetentionPolicy.CLASS;
-import java.security.Permission;
-
-/**
- *
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-@Documented @Retention(CLASS) @Target(METHOD)
-public @interface Requires
-{
- Class extends Permission> permissionClass();
- String target();
- String action();
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/BitString.java b/openjdk/icedtea/jce/gnu/java/security/der/BitString.java
deleted file mode 100644
index 02b1c037..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/BitString.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/* BitString.java -- Java representation of the BIT STRING type.
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-import java.math.BigInteger;
-import java.util.Arrays;
-
-/**
- * Immutable representation of a bit string, which is equivalent to a
- * byte array except some number of the rightmost bits are ignored. For
- * example, this could be the bit string:
- *
- * 00010101 11101101 11010xxx- * - *
Where the "xxx" represents three bits that should be ignored, and
- * can have any value.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class BitString implements Cloneable, Comparable
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The bits themselves. */
- private final byte[] bytes;
-
- /**
- * The exportable byte array. This array has the ignored bits
- * removed.
- */
- private transient byte[] externBytes;
-
- /** The number of bits ignored at the end of the byte array. */
- private final int ignoredBits;
-
- /** This bit string as a boolean array. */
- private transient boolean[] boolVal;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new bit string, shifting the given byte array if needed.
- *
- * @param bytes The byte array holding the bit string.
- * @param ignoredBits The number of bits to ignore.
- * @param doShift Pass true in this parameter if the byte array has
- * not yet been shifted left by ignoredBits.
- * @throws IllegalArgumentException If ignoredBits is negative
- * or greater than 7.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes, int ignoredBits, boolean doShift)
- {
- this(bytes, 0, bytes.length, ignoredBits, doShift);
- }
-
- /**
- * Create a new bit string, shifting the given byte array if needed.
- *
- * @param bytes The byte array holding the bit string.
- * @param offset The offset where the meaningful bytes begin.
- * @param length The number of meaningful bytes.
- * @param ignoredBits The number of bits to ignore.
- * @param doShift Pass true in this parameter if the byte array has
- * not yet been shifted left by ignoredBits.
- * @throws IllegalArgumentException If ignoredBits is negative
- * or greater than 7.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes, int offset, int length,
- int ignoredBits, boolean doShift)
- {
- if (ignoredBits < 0 || ignoredBits > 7)
- throw new IllegalArgumentException();
- if (bytes == null)
- throw new NullPointerException();
- if (doShift && ignoredBits > 0)
- {
- this.externBytes = new byte[length];
- System.arraycopy(bytes, offset, externBytes, 0, length);
- this.bytes = new BigInteger(externBytes).shiftLeft(ignoredBits)
- .toByteArray();
- }
- else
- {
- this.bytes = new byte[length];
- System.arraycopy(bytes, offset, this.bytes, 0, length);
- }
- this.ignoredBits = ignoredBits;
- }
-
- /**
- * Create a new bit string.
- *
- * @param bytes The byte array holding the bit string.
- * @param offset The offset where the meaningful bytes begin.
- * @param length The number of meaningful bytes.
- * @param ignoredBits The number of bits to ignore.
- * @throws IllegalArgumentException If ignoredBits is negative
- * or greater than 7.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes, int offset, int length, int ignoredBits)
- {
- this(bytes, offset, length, ignoredBits, false);
- }
-
- /**
- * Create a new bit string.
- *
- * @param bytes The byte array holding the bit string.
- * @param ignoredBits The number of bits to ignore.
- * @throws IllegalArgumentException If ignoredBits is negative
- * or greater than 7.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes, int ignoredBits)
- {
- this(bytes, 0, bytes.length, ignoredBits, false);
- }
-
- /**
- * Create a new bit string.
- *
- * @param bytes The byte array holding the bit string.
- * @param offset The offset where the meaningful bytes begin.
- * @param length The number of meaningful bytes.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes, int offset, int length)
- {
- this(bytes, offset, length, 0, false);
- }
-
- /**
- * Create a new bit string.
- *
- * @param bytes The byte array holding the bit string.
- * @throws NullPointerException If bytes is null.
- */
- public BitString(byte[] bytes)
- {
- this(bytes, 0, bytes.length, 0, false);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return this bit string as a byte array, with the ignored bits
- * trimmed off. The byte array is cloned every time this method is
- * called to prevent modification.
- *
- * @return The trimmed byte array.
- */
- public byte[] toByteArray()
- {
- if (ignoredBits == 0)
- return (byte[]) bytes.clone();
- if (externBytes == null)
- externBytes = new BigInteger(bytes).shiftRight(ignoredBits).toByteArray();
- return (byte[]) externBytes.clone();
- }
-
- /**
- * Returns this bit string as a byte array, with the ignored bits
- * present. The byte array is cloned every time this method is
- * called to prevent modification.
- *
- * @return The byte array.
- */
- public byte[] getShiftedByteArray()
- {
- return (byte[]) bytes.clone();
- }
-
- /**
- * Returns the number of ignored bits.
- *
- * @return The number of ignored bits.
- */
- public int getIgnoredBits()
- {
- return ignoredBits;
- }
-
- /**
- * Returns the size, in bits, of this bit string.
- *
- * @return The size of this bit string.
- */
- public int size()
- {
- return (bytes.length << 3) - ignoredBits;
- }
-
- /**
- * Return this bit string as a boolean array. The value returned is of
- * size {@link #size()}, and each true
value
- * corresponding to each "1" in this bit string. The boolean array is
- * cloned before it is returned.
- *
- * @return The boolean array.
- */
- public boolean[] toBooleanArray()
- {
- if (boolVal == null)
- {
- boolVal = new boolean[size()];
- for (int i = 0, j = 7, k = 0; i < boolVal.length; i++)
- {
- boolVal[i] = (bytes[k] & 1 << j--) != 0;
- if (j < 0)
- {
- j = 7;
- k++;
- }
- }
- }
- return (boolean[]) boolVal.clone();
- }
-
- public Object clone()
- {
- try
- {
- return super.clone();
- }
- catch (CloneNotSupportedException cce)
- {
- throw new InternalError(cce.getMessage());
- }
- }
-
- public int compareTo(Object o)
- {
- BitString that = (BitString) o;
- if (this.equals(that))
- return 0;
- if (this.bytes.length != that.bytes.length)
- return (this.bytes.length < that.bytes.length) ? -1 : 1;
- if (this.ignoredBits != that.ignoredBits)
- return (this.ignoredBits < that.ignoredBits) ? -1 : 1;
- for (int i = 0; i < this.bytes.length; i++)
- if (this.bytes[i] != that.bytes[i])
- return (this.bytes[i] < that.bytes[i]) ? -1 : 1;
- return 0; // not reached.
- }
-
- public int hashCode()
- {
- int result = 0;
- for (int i = 0; i < bytes.length - 1; ++i)
- result = result * 31 + bytes[i];
- if (bytes.length > 0)
- {
- int lastByte = bytes[bytes.length - 1] & ~ ((1 << ignoredBits) - 1);
- result = result * 31 + lastByte;
- }
- return result;
- }
-
- public boolean equals(Object o)
- {
- if (!(o instanceof BitString))
- return false;
- BitString that = (BitString) o;
- // True for cloned instances.
- if (this.bytes == that.bytes && this.ignoredBits == that.ignoredBits)
- return true;
- if (this.ignoredBits == that.ignoredBits)
- return Arrays.equals(this.bytes, that.bytes);
- return false;
- }
-
- public String toString()
- {
- StringBuffer sb = new StringBuffer();
- for (int i = 0, j = 7, k = 0; i < size(); i++)
- {
- sb.append((bytes[k] & 1 << j) != 0 ? "1" : "0");
- j--;
- if (j < 0)
- {
- j = 7;
- k++;
- }
- }
- return sb.toString();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/DER.java b/openjdk/icedtea/jce/gnu/java/security/der/DER.java
deleted file mode 100644
index a7eb4a68..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/DER.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/* DER.java -- Basic constants in DER sequences.
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-/**
- * The set of tags for DER types.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public interface DER
-{
- int UNIVERSAL = 0x00;
- int APPLICATION = 0x40;
- int CONTEXT = 0x80;
- int PRIVATE = 0xC0;
-
- int CONSTRUCTED = 0x20;
-
- int ANY = 0x00;
- int BOOLEAN = 0x01;
- int INTEGER = 0x02;
- int BIT_STRING = 0x03;
- int OCTET_STRING = 0x04;
- int NULL = 0x05;
- int OBJECT_IDENTIFIER = 0x06;
- int REAL = 0x09;
- int ENUMERATED = 0x0a;
- int RELATIVE_OID = 0x0d;
-
- int SEQUENCE = 0x10;
- int SET = 0x11;
-
- Object CONSTRUCTED_VALUE = new Object();
-
- int NUMERIC_STRING = 0x12;
- int PRINTABLE_STRING = 0x13;
- int T61_STRING = 0x14;
- int VIDEOTEX_STRING = 0x15;
- int IA5_STRING = 0x16;
- int GRAPHIC_STRING = 0x19;
- int ISO646_STRING = 0x1A;
- int GENERAL_STRING = 0x1B;
-
- int UTF8_STRING = 0x0C;
- int UNIVERSAL_STRING = 0x1C;
- int BMP_STRING = 0x1E;
-
- int UTC_TIME = 0x17;
- int GENERALIZED_TIME = 0x18;
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/DEREncodingException.java b/openjdk/icedtea/jce/gnu/java/security/der/DEREncodingException.java
deleted file mode 100644
index 90042a3f..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/DEREncodingException.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* DEREncodingException.java --- DER Encoding Exception
- Copyright (C) 1999,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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-import java.io.IOException;
-
-public class DEREncodingException extends IOException
-{
- public DEREncodingException()
- {
- super ();
- }
-
- public DEREncodingException (String msg)
- {
- super (msg);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/DERReader.java b/openjdk/icedtea/jce/gnu/java/security/der/DERReader.java
deleted file mode 100644
index 09ec1e2d..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/DERReader.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/* DERReader.java -- parses ASN.1 DER sequences
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-import gnu.java.security.OID;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.TimeZone;
-
-/**
- * This class decodes DER sequences into Java objects. The methods of
- * this class do not have knowledge of higher-levels of structure in the
- * DER stream -- such as ASN.1 constructions -- and it is therefore up
- * to the calling application to determine if the data are structured
- * properly by inspecting the {@link DERValue} that is returned.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class DERReader implements DER
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- protected InputStream in;
-
- protected final ByteArrayOutputStream encBuf;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new DER reader from a byte array.
- *
- * @param in The encoded bytes.
- */
- public DERReader(byte[] in)
- {
- this(new ByteArrayInputStream(in));
- }
-
- public DERReader (byte[] in, int off, int len)
- {
- this (new ByteArrayInputStream (in, off, len));
- }
-
- /**
- * Create a new DER readed from an input stream.
- *
- * @param in The encoded bytes.
- */
- public DERReader(InputStream in)
- {
- if (!in.markSupported())
- this.in = new BufferedInputStream(in, 16384);
- else
- this.in = in;
- encBuf = new ByteArrayOutputStream(2048);
- }
-
- // Class methods.
- // ------------------------------------------------------------------------
-
- /**
- * Convenience method for reading a single primitive value from the
- * given byte array.
- *
- * @param encoded The encoded bytes.
- * @throws IOException If the bytes do not represent an encoded
- * object.
- */
- public static DERValue read(byte[] encoded) throws IOException
- {
- return new DERReader(encoded).read();
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- public void skip (int bytes) throws IOException
- {
- in.skip (bytes);
- }
-
- /**
- * Decode a single value from the input stream, returning it in a new
- * {@link DERValue}. By "single value" we mean any single type in its
- * entirety -- including constructed types such as SEQUENCE and all
- * the values they contain. Usually it is sufficient to call this
- * method once to parse and return the top-level structure, then to
- * inspect the returned value for the proper contents.
- *
- * @return The parsed DER structure.
- * @throws IOException If an error occurs reading from the input
- * stream.
- * @throws DEREncodingException If the input does not represent a
- * valid DER stream.
- */
- public DERValue read() throws IOException
- {
- int tag = in.read();
- if (tag == -1)
- throw new EOFException();
- encBuf.write(tag);
- int len = readLength();
- DERValue value = null;
- if ((tag & CONSTRUCTED) == CONSTRUCTED)
- {
- in.mark(2048);
- byte[] encoded = new byte[len];
- in.read(encoded);
- encBuf.write(encoded);
- value = new DERValue(tag, len, CONSTRUCTED_VALUE, encBuf.toByteArray());
- in.reset();
- encBuf.reset();
- return value;
- }
- switch (tag & 0xC0)
- {
- case UNIVERSAL:
- value = new DERValue(tag, len, readUniversal(tag, len),
- encBuf.toByteArray());
- encBuf.reset();
- break;
- case CONTEXT:
- byte[] encoded = new byte[len];
- in.read(encoded);
- encBuf.write(encoded);
- value = new DERValue(tag, len, encoded, encBuf.toByteArray());
- encBuf.reset();
- break;
- case APPLICATION:
- // This should not be reached, since (I think) APPLICATION is
- // always constructed.
- throw new DEREncodingException("non-constructed APPLICATION data");
- default:
- throw new DEREncodingException("PRIVATE class not supported");
- }
- return value;
- }
-
- protected int readLength() throws IOException
- {
- int i = in.read();
- if (i == -1)
- throw new EOFException();
- encBuf.write(i);
- if ((i & ~0x7F) == 0)
- {
- return i;
- }
- else if (i < 0xFF)
- {
- byte[] octets = new byte[i & 0x7F];
- in.read(octets);
- encBuf.write(octets);
- return new BigInteger(1, octets).intValue();
- }
- throw new DEREncodingException();
- }
-
- // Own methods.
- // ------------------------------------------------------------------------
-
- private Object readUniversal(int tag, int len) throws IOException
- {
- byte[] value = new byte[len];
- in.read(value);
- encBuf.write(value);
- switch (tag & 0x1F)
- {
- case BOOLEAN:
- if (value.length != 1)
- throw new DEREncodingException();
- return Boolean.valueOf(value[0] != 0);
- case NULL:
- if (len != 0)
- throw new DEREncodingException();
- return null;
- case INTEGER:
- case ENUMERATED:
- return new BigInteger(value);
- case BIT_STRING:
- byte[] bits = new byte[len - 1];
- System.arraycopy(value, 1, bits, 0, bits.length);
- return new BitString(bits, value[0] & 0xFF);
- case OCTET_STRING:
- return value;
- case NUMERIC_STRING:
- case PRINTABLE_STRING:
- case T61_STRING:
- case VIDEOTEX_STRING:
- case IA5_STRING:
- case GRAPHIC_STRING:
- case ISO646_STRING:
- case GENERAL_STRING:
- case UNIVERSAL_STRING:
- case BMP_STRING:
- case UTF8_STRING:
- return makeString(tag, value);
- case UTC_TIME:
- case GENERALIZED_TIME:
- return makeTime(tag, value);
- case OBJECT_IDENTIFIER:
- return new OID(value);
- case RELATIVE_OID:
- return new OID(value, true);
- default:
- throw new DEREncodingException("unknown tag " + tag);
- }
- }
-
- private static String makeString(int tag, byte[] value)
- throws IOException
- {
- switch (tag & 0x1F)
- {
- case NUMERIC_STRING:
- case PRINTABLE_STRING:
- case T61_STRING:
- case VIDEOTEX_STRING:
- case IA5_STRING:
- case GRAPHIC_STRING:
- case ISO646_STRING:
- case GENERAL_STRING:
- return fromIso88591(value);
-
- case UNIVERSAL_STRING:
- // XXX The docs say UniversalString is encoded in four bytes
- // per character, but Java has no support (yet) for UTF-32.
- //return new String(buf, "UTF-32");
- case BMP_STRING:
- return fromUtf16Be(value);
-
- case UTF8_STRING:
- return fromUtf8(value);
-
- default:
- throw new DEREncodingException("unknown string tag");
- }
- }
-
- private static String fromIso88591(byte[] bytes)
- {
- StringBuffer str = new StringBuffer(bytes.length);
- for (int i = 0; i < bytes.length; i++)
- str.append((char) (bytes[i] & 0xFF));
- return str.toString();
- }
-
- private static String fromUtf16Be(byte[] bytes) throws IOException
- {
- if ((bytes.length & 0x01) != 0)
- throw new IOException("UTF-16 bytes are odd in length");
- StringBuffer str = new StringBuffer(bytes.length / 2);
- for (int i = 0; i < bytes.length; i += 2)
- {
- char c = (char) ((bytes[i] << 8) & 0xFF);
- c |= (char) (bytes[i+1] & 0xFF);
- str.append(c);
- }
- return str.toString();
- }
-
- private static String fromUtf8(byte[] bytes) throws IOException
- {
- StringBuffer str = new StringBuffer((int)(bytes.length / 1.5));
- for (int i = 0; i < bytes.length; )
- {
- char c = 0;
- if ((bytes[i] & 0xE0) == 0xE0)
- {
- if ((i + 2) >= bytes.length)
- throw new IOException("short UTF-8 input");
- c = (char) ((bytes[i++] & 0x0F) << 12);
- if ((bytes[i] & 0x80) != 0x80)
- throw new IOException("malformed UTF-8 input");
- c |= (char) ((bytes[i++] & 0x3F) << 6);
- if ((bytes[i] & 0x80) != 0x80)
- throw new IOException("malformed UTF-8 input");
- c |= (char) (bytes[i++] & 0x3F);
- }
- else if ((bytes[i] & 0xC0) == 0xC0)
- {
- if ((i + 1) >= bytes.length)
- throw new IOException("short input");
- c = (char) ((bytes[i++] & 0x1F) << 6);
- if ((bytes[i] & 0x80) != 0x80)
- throw new IOException("malformed UTF-8 input");
- c |= (char) (bytes[i++] & 0x3F);
- }
- else if ((bytes[i] & 0xFF) < 0x80)
- {
- c = (char) (bytes[i++] & 0xFF);
- }
- else
- throw new IOException("badly formed UTF-8 sequence");
- str.append(c);
- }
- return str.toString();
- }
-
- private Date makeTime(int tag, byte[] value) throws IOException
- {
- Calendar calendar = Calendar.getInstance();
- String str = makeString(PRINTABLE_STRING, value);
-
- // Classpath's SimpleDateFormat does not work for parsing these
- // types of times, so we do this by hand.
- String date = str;
- String tz = "";
- if (str.indexOf("+") > 0)
- {
- date = str.substring(0, str.indexOf("+"));
- tz = str.substring(str.indexOf("+"));
- }
- else if (str.indexOf("-") > 0)
- {
- date = str.substring(0, str.indexOf("-"));
- tz = str.substring(str.indexOf("-"));
- }
- else if (str.endsWith("Z"))
- {
- date = str.substring(0, str.length()-2);
- tz = "Z";
- }
- if (!tz.equals("Z") && tz.length() > 0)
- calendar.setTimeZone(TimeZone.getTimeZone(tz));
- else
- calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
- if ((tag & 0x1F) == UTC_TIME)
- {
- if (date.length() < 10) // must be at least 10 chars long
- throw new DEREncodingException("cannot parse date");
- // UTCTime is of the form "yyMMddHHmm[ss](Z|(+|-)hhmm)"
- try
- {
- int year = Integer.parseInt(str.substring(0, 2));
- if (year < 50)
- year += 2000;
- else
- year += 1900;
- calendar.set(year,
- Integer.parseInt(str.substring( 2, 4))-1, // month
- Integer.parseInt(str.substring( 4, 6)), // day
- Integer.parseInt(str.substring( 6, 8)), // hour
- Integer.parseInt(str.substring( 8, 10))); // minute
- if (date.length() == 12)
- calendar.set(Calendar.SECOND,
- Integer.parseInt(str.substring(10, 12)));
- }
- catch (NumberFormatException nfe)
- {
- throw new DEREncodingException("cannot parse date");
- }
- }
- else
- {
- if (date.length() < 10) // must be at least 10 chars long
- throw new DEREncodingException("cannot parse date");
- // GeneralTime is of the form "yyyyMMddHH[mm[ss[(.|,)SSSS]]]"
- // followed by "Z" or "(+|-)hh[mm]"
- try
- {
- calendar.set(
- Integer.parseInt(date.substring(0, 4)), // year
- Integer.parseInt(date.substring(4, 6))-1, // month
- Integer.parseInt(date.substring(6, 8)), // day
- Integer.parseInt(date.substring(8, 10)), 0); // hour, min
- switch (date.length())
- {
- case 19:
- case 18:
- case 17:
- case 16:
- calendar.set(Calendar.MILLISECOND,
- Integer.parseInt(date.substring(15)));
- case 14:
- calendar.set(Calendar.SECOND,
- Integer.parseInt(date.substring(12, 14)));
- case 12:
- calendar.set(Calendar.MINUTE,
- Integer.parseInt(date.substring(10, 12)));
- }
- }
- catch (NumberFormatException nfe)
- {
- throw new DEREncodingException("cannot parse date");
- }
- }
- return calendar.getTime();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/DERValue.java b/openjdk/icedtea/jce/gnu/java/security/der/DERValue.java
deleted file mode 100644
index d98ce78e..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/DERValue.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/* DERValue.java -- a value read or written to a DER encoding.
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-import gnu.java.security.x509.Util;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-
-public class DERValue implements DER
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- private final int tagClass;
- private final boolean constructed;
- private final int tag;
- private int length;
- private final Object value;
- private byte[] encoded;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- public DERValue(int tag, int length, Object value, byte[] encoded)
- {
- tagClass = tag & 0xC0;
- this.tag = tag & 0x1F;
- constructed = (tag & CONSTRUCTED) == CONSTRUCTED;
- this.length = length;
- this.value = value;
- if (encoded != null)
- this.encoded = (byte[]) encoded.clone();
- }
-
- public DERValue(int tag, Object value)
- {
- this(tag, 0, value, null);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- public int getExternalTag()
- {
- return tagClass | tag | (constructed ? 0x20 : 0x00);
- }
-
- public int getTag()
- {
- return tag;
- }
-
- public int getTagClass()
- {
- return tagClass;
- }
-
- public boolean isConstructed()
- {
- return constructed;
- }
-
- public int getLength()
- {
- if (encoded == null)
- {
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- length = DERWriter.write(out, this);
- encoded = out.toByteArray();
- }
- catch (IOException ioe)
- {
- IllegalArgumentException iae = new IllegalArgumentException ();
- iae.initCause (ioe);
- throw iae;
- }
- }
- return length;
- }
-
- public Object getValue()
- {
- return value;
- }
-
- public Object getValueAs (final int derType) throws IOException
- {
- byte[] encoded = getEncoded ();
- encoded[0] = (byte) derType;
- return DERReader.read (encoded).getValue ();
- }
-
- public byte[] getEncoded()
- {
- if (encoded == null)
- {
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- length = DERWriter.write(out, this);
- encoded = out.toByteArray();
- }
- catch (IOException ioe)
- {
- IllegalArgumentException iae = new IllegalArgumentException ();
- iae.initCause (ioe);
- throw iae;
- }
- }
- return (byte[]) encoded.clone();
- }
-
- public int getEncodedLength()
- {
- if (encoded == null)
- {
- try
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- length = DERWriter.write(out, this);
- encoded = out.toByteArray();
- }
- catch (IOException ioe)
- {
- IllegalArgumentException iae = new IllegalArgumentException ();
- iae.initCause (ioe);
- throw iae;
- }
- }
- return encoded.length;
- }
-
- public String toString()
- {
- String start = "DERValue ( [";
- if (tagClass == DER.UNIVERSAL)
- start = start + "UNIVERSAL ";
- else if (tagClass == DER.PRIVATE)
- start = start + "PRIVATE ";
- else if (tagClass == DER.APPLICATION)
- start = start + "APPLICATION ";
- start = start + tag + "] constructed=" + constructed + ", value=";
- if (constructed)
- start = start + "\n" + Util.hexDump(getEncoded(), "\t");
- else
- start = start + value;
- return start + " )";
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/der/DERWriter.java b/openjdk/icedtea/jce/gnu/java/security/der/DERWriter.java
deleted file mode 100644
index 0c263360..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/der/DERWriter.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/* DERWriter.java -- write Java types in DER format.
- Copyright (C) 2003, 2004, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.der;
-
-import gnu.java.security.OID;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.math.BigInteger;
-
-import java.text.SimpleDateFormat;
-
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-import java.util.TimeZone;
-
-/**
- * Methods that allow various Java types to be written as a DER
- * (Distinguished Encoding Rules) stream to the specified output stream.
- * DER is used to encode ASN.1 constructions, but this class provides no
- * methods for interacting with ASN.1. Rather, callers should construct
- * their output objects properly for whatever ASN.1 construct is being
- * output.
- *
- *
This class only defines static methods; there are no instance - * variables needed. - * - * @author Casey Marshall (csm@gnu.org) - */ -public class DERWriter implements DER -{ - - // Constructors. - // ------------------------------------------------------------------------ - - /** This class only has static methods. */ - private DERWriter() - { - } - - // Class methods. - // ------------------------------------------------------------------------ - - public static int write(OutputStream out, DERValue object) - throws IOException - { - if (DER.CONSTRUCTED_VALUE.equals (object.getValue ())) - { - out.write (object.getEncoded ()); - return object.getLength (); - } - - out.write(object.getExternalTag()); - Object value = object.getValue(); - if (value == null) - { - writeLength(out, 0); - return 0; - } - if (value instanceof Boolean) - return writeBoolean(out, (Boolean) value); - else if (value instanceof BigInteger) - return writeInteger(out, (BigInteger) value); - else if (value instanceof Date) - return writeDate(out, object.getExternalTag(), (Date) value); - else if (value instanceof String) - return writeString(out, object.getExternalTag(), (String) value); - else if (value instanceof List) - return writeSequence(out, (List) value); - else if (value instanceof Set) - return writeSet(out, (Set) value); - else if (value instanceof BitString) - return writeBitString(out, (BitString) value); - else if (value instanceof OID) - return writeOID(out, (OID) value); - else if (value instanceof byte[]) - { - writeLength(out, ((byte[]) value).length); - out.write((byte[]) value); - return ((byte[]) value).length; - } - else if (value instanceof DERValue) - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - write(bout, (DERValue) value); - byte[] buf = bout.toByteArray(); - writeLength(out, buf.length); - out.write(buf); - return buf.length; - } - else - throw new DEREncodingException("cannot encode " + value.getClass().getName()); - } - - public static int definiteEncodingSize(int length) - { - if (length < 128) - return 1; - else if (length < 256) - return 2; - else if (length < 65536) - return 3; - else if (length < 16777216) - return 4; - else - return 5; - } - - // Own methods. - // ------------------------------------------------------------------------ - - /** - * Write a BOOLEAN type to the given output stream. - * - * @param out The sink output stream. - * @param b The boolean value to write. - */ - private static int writeBoolean(OutputStream out, Boolean b) - throws IOException - { - writeLength(out, 1); - if (b.booleanValue()) - out.write(0xFF); - else - out.write(0); - return 1; - } - - /** - * Write an INTEGER type to the given output stream. - * - * @param out The sink output stream. - * @param integer The integer to write. - */ - private static int writeInteger(OutputStream out, BigInteger integer) - throws IOException - { - byte[] bytes = integer.toByteArray(); - writeLength(out, bytes.length); - out.write(bytes); - return bytes.length; - } - - private static int writeSequence(OutputStream out, List sequence) - throws IOException - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - for (Iterator i = sequence.iterator(); i.hasNext(); ) - { - write(bout, (DERValue) i.next()); - } - byte[] buf = bout.toByteArray(); - writeLength(out, buf.length); - out.write(buf); - return buf.length; - } - - private static int writeSet(OutputStream out, Set set) - throws IOException - { - ByteArrayOutputStream bout = new ByteArrayOutputStream(); - for (Iterator i = set.iterator(); i.hasNext(); ) - { - write(bout, (DERValue) i.next()); - } - byte[] buf = bout.toByteArray(); - writeLength(out, buf.length); - out.write(buf); - return buf.length; - } - - private static int writeOID(OutputStream out, OID oid) - throws IOException - { - byte[] der = oid.getDER(); - writeLength(out, der.length); - out.write(der); - return der.length; - } - - private static int writeBitString(OutputStream out, BitString bs) - throws IOException - { - byte[] buf = bs.getShiftedByteArray(); - writeLength(out, buf.length + 1); - out.write(bs.getIgnoredBits()); - out.write(buf); - return buf.length + 1; - } - - private static int writeString(OutputStream out, int tag, String str) - throws IOException - { - byte[] b = null; - switch (tag & 0x1F) - { - case NUMERIC_STRING: - case PRINTABLE_STRING: - case T61_STRING: - case VIDEOTEX_STRING: - case IA5_STRING: - case GRAPHIC_STRING: - case ISO646_STRING: - case GENERAL_STRING: - b = toIso88591(str); - break; - - case UNIVERSAL_STRING: - case BMP_STRING: - b = toUtf16Be(str); - break; - - case UTF8_STRING: - default: - b = toUtf8(str); - break; - } - writeLength(out, b.length); - out.write(b); - return b.length; - } - - private static byte[] toIso88591(String string) - { - byte[] result = new byte[string.length()]; - for (int i = 0; i < string.length(); i++) - result[i] = (byte) string.charAt(i); - return result; - } - - private static byte[] toUtf16Be(String string) - { - byte[] result = new byte[string.length() * 2]; - for (int i = 0; i < string.length(); i++) - { - result[i*2 ] = (byte) ((string.charAt(i) >>> 8) & 0xFF); - result[i*2+1] = (byte) (string.charAt(i) & 0xFF); - } - return result; - } - - private static byte[] toUtf8(String string) - { - ByteArrayOutputStream buf = - new ByteArrayOutputStream((int)(string.length() * 1.5)); - for (int i = 0; i < string.length(); i++) - { - char c = string.charAt(i); - if (c < 0x0080) - buf.write(c & 0xFF); - else if (c < 0x0800) - { - buf.write(0xC0 | ((c >>> 6) & 0x3F)); - buf.write(0x80 | (c & 0x3F)); - } - else - { - buf.write(0xE0 | ((c >>> 12) & 0x0F)); - buf.write(0x80 | ((c >>> 6) & 0x3F)); - buf.write(0x80 | (c & 0x3F)); - } - } - return buf.toByteArray(); - } - - private static int writeDate(OutputStream out, int tag, Date date) - throws IOException - { - SimpleDateFormat sdf = null; - if ((tag & 0x1F) == UTC_TIME) - sdf = new SimpleDateFormat("yyMMddHHmmss'Z'"); - else - sdf = new SimpleDateFormat("yyyyMMddHHmmss'.'SSS'Z'"); - sdf.setTimeZone(TimeZone.getTimeZone("UTC")); - byte[] b = sdf.format(date).getBytes("ISO-8859-1"); - writeLength(out, b.length); - out.write(b); - return b.length; - } - - // Package method. - // ------------------------------------------------------------------------ - - static void writeLength(OutputStream out, int len) throws IOException - { - if (len < 128) - out.write(len); - else if (len < 256) - { - out.write(0x81); - out.write(len); - } - else if (len < 65536) - { - out.write(0x82); - out.write(len >> 8); - out.write(len); - } - else if (len < 16777216) - { - out.write(0x83); - out.write(len >> 16); - out.write(len >> 8); - out.write(len); - } - else - { - out.write(0x84); - out.write(len >> 24); - out.write(len >> 16); - out.write(len >> 8); - out.write(len); - } - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/BaseHash.java b/openjdk/icedtea/jce/gnu/java/security/hash/BaseHash.java deleted file mode 100644 index ff1750ae..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/hash/BaseHash.java +++ /dev/null @@ -1,183 +0,0 @@ -/* BaseHash.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.hash; - -/** - * A base abstract class to facilitate hash implementations. - */ -public abstract class BaseHash - implements IMessageDigest -{ - /** The canonical name prefix of the hash. */ - protected String name; - - /** The hash (output) size in bytes. */ - protected int hashSize; - - /** The hash (inner) block size in bytes. */ - protected int blockSize; - - /** Number of bytes processed so far. */ - protected long count; - - /** Temporary input buffer. */ - protected byte[] buffer; - - /** - * Trivial constructor for use by concrete subclasses. - * - * @param name the canonical name prefix of this instance. - * @param hashSize the block size of the output in bytes. - * @param blockSize the block size of the internal transform. - */ - protected BaseHash(String name, int hashSize, int blockSize) - { - super(); - - this.name = name; - this.hashSize = hashSize; - this.blockSize = blockSize; - this.buffer = new byte[blockSize]; - - resetContext(); - } - - public String name() - { - return name; - } - - public int hashSize() - { - return hashSize; - } - - public int blockSize() - { - return blockSize; - } - - public void update(byte b) - { - // compute number of bytes still unhashed; ie. present in buffer - int i = (int) (count % blockSize); - count++; - buffer[i] = b; - if (i == (blockSize - 1)) - transform(buffer, 0); - } - - public void update(byte[] b) - { - update(b, 0, b.length); - } - - public void update(byte[] b, int offset, int len) - { - int n = (int) (count % blockSize); - count += len; - int partLen = blockSize - n; - int i = 0; - - if (len >= partLen) - { - System.arraycopy(b, offset, buffer, n, partLen); - transform(buffer, 0); - for (i = partLen; i + blockSize - 1 < len; i += blockSize) - transform(b, offset + i); - - n = 0; - } - - if (i < len) - System.arraycopy(b, offset + i, buffer, n, len - i); - } - - public byte[] digest() - { - byte[] tail = padBuffer(); // pad remaining bytes in buffer - update(tail, 0, tail.length); // last transform of a message - byte[] result = getResult(); // make a result out of context - - reset(); // reset this instance for future re-use - - return result; - } - - public void reset() - { // reset this instance for future re-use - count = 0L; - for (int i = 0; i < blockSize;) - buffer[i++] = 0; - - resetContext(); - } - - public abstract Object clone(); - - public abstract boolean selfTest(); - - /** - * Returns the byte array to use as padding before completing a hash - * operation. - * - * @return the bytes to pad the remaining bytes in the buffer before - * completing a hash operation. - */ - protected abstract byte[] padBuffer(); - - /** - * Constructs the result from the contents of the current context. - * - * @return the output of the completed hash operation. - */ - protected abstract byte[] getResult(); - - /** Resets the instance for future re-use. */ - protected abstract void resetContext(); - - /** - * The block digest transformation per se. - * - * @param in the blockSize long block, as an array of bytes to digest. - * @param offset the index where the data to digest is located within the - * input buffer. - */ - protected abstract void transform(byte[] in, int offset); -} diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/HashFactory.java b/openjdk/icedtea/jce/gnu/java/security/hash/HashFactory.java deleted file mode 100644 index 2a4e4878..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/hash/HashFactory.java +++ /dev/null @@ -1,135 +0,0 @@ -/* HashFactory.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.hash; - -import gnu.java.security.Registry; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - -/** - * A Factory to instantiate message digest algorithm instances. - */ -public class HashFactory -{ - /** Trivial constructor to enforce Singleton pattern. */ - private HashFactory() - { - super(); - } - - /** - * Return an instance of a hash algorithm given its name. - * - * @param name the name of the hash algorithm. - * @return an instance of the hash algorithm, or null if none found. - * @exception InternalError if the implementation does not pass its self- - * test. - */ - public static IMessageDigest getInstance(String name) - { - if (name == null) - return null; - - name = name.trim(); - IMessageDigest result = null; - if (name.equalsIgnoreCase(Registry.WHIRLPOOL_HASH)) - result = new Whirlpool(); - else if (name.equalsIgnoreCase(Registry.RIPEMD128_HASH) - || name.equalsIgnoreCase(Registry.RIPEMD_128_HASH)) - result = new RipeMD128(); - else if (name.equalsIgnoreCase(Registry.RIPEMD160_HASH) - || name.equalsIgnoreCase(Registry.RIPEMD_160_HASH)) - result = new RipeMD160(); - else if (name.equalsIgnoreCase(Registry.SHA160_HASH) - || name.equalsIgnoreCase(Registry.SHA_1_HASH) - || name.equalsIgnoreCase(Registry.SHA1_HASH) - || name.equalsIgnoreCase(Registry.SHA_HASH)) - result = new Sha160(); - else if (name.equalsIgnoreCase(Registry.SHA256_HASH)) - result = new Sha256(); - else if (name.equalsIgnoreCase(Registry.SHA384_HASH)) - result = new Sha384(); - else if (name.equalsIgnoreCase(Registry.SHA512_HASH)) - result = new Sha512(); - else if (name.equalsIgnoreCase(Registry.TIGER_HASH)) - result = new Tiger(); - else if (name.equalsIgnoreCase(Registry.HAVAL_HASH)) - result = new Haval(); - else if (name.equalsIgnoreCase(Registry.MD5_HASH)) - result = new MD5(); - else if (name.equalsIgnoreCase(Registry.MD4_HASH)) - result = new MD4(); - else if (name.equalsIgnoreCase(Registry.MD2_HASH)) - result = new MD2(); - else if (name.equalsIgnoreCase(Registry.HAVAL_HASH)) - result = new Haval(); - - if (result != null && ! result.selfTest()) - throw new InternalError(result.name()); - - return result; - } - - /** - * Returns a {@link Set} of names of hash algorithms supported by this - * Factory. - * - * @return a {@link Set} of hash names (Strings). - */ - public static final Set getNames() - { - HashSet hs = new HashSet(); - hs.add(Registry.WHIRLPOOL_HASH); - hs.add(Registry.RIPEMD128_HASH); - hs.add(Registry.RIPEMD160_HASH); - hs.add(Registry.SHA160_HASH); - hs.add(Registry.SHA256_HASH); - hs.add(Registry.SHA384_HASH); - hs.add(Registry.SHA512_HASH); - hs.add(Registry.TIGER_HASH); - hs.add(Registry.HAVAL_HASH); - hs.add(Registry.MD5_HASH); - hs.add(Registry.MD4_HASH); - hs.add(Registry.MD2_HASH); - - return Collections.unmodifiableSet(hs); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/Haval.java b/openjdk/icedtea/jce/gnu/java/security/hash/Haval.java deleted file mode 100644 index 662934f3..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/hash/Haval.java +++ /dev/null @@ -1,807 +0,0 @@ -/* Haval.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.hash; - -import gnu.java.security.Registry; -import gnu.java.security.util.Util; - -/** - * The HAVAL message-digest algorithm is a variable output length, with - * variable number of rounds. By default, this implementation allows HAVAL - * to be used as a drop-in replacement for MD5. - *
- * References: - *
3
- * .. 5
.
- * The default is 3
.
- */
- private int rounds = HAVAL_3_ROUND;
-
- /** 128-bit interim result. */
- private int h0, h1, h2, h3, h4, h5, h6, h7;
-
- /**
- * Calls the constructor with two argument using {@link #HAVAL_128_BIT} as the
- * value for the output size (i.e. 128
bits, and
- * {@link #HAVAL_3_ROUND} for the value of number of rounds.
- */
- public Haval()
- {
- this(HAVAL_128_BIT, HAVAL_3_ROUND);
- }
-
- /**
- * Calls the constructor with two arguments using the designated output size,
- * and {@link #HAVAL_3_ROUND} for the value of number of rounds.
- *
- * @param size the output size in bytes of this instance.
- * @throws IllegalArgumentException if the designated output size is invalid.
- * @see #HAVAL_128_BIT
- * @see #HAVAL_160_BIT
- * @see #HAVAL_192_BIT
- * @see #HAVAL_224_BIT
- * @see #HAVAL_256_BIT
- */
- public Haval(int size)
- {
- this(size, HAVAL_3_ROUND);
- }
-
- /**
- * Constructs a Haval
instance with the designated output size
- * (in bytes). Valid output size
values are 16
,
- * 20
, 24
, 28
and
- * 32
. Valid values for rounds
are in the range
- * 3..5
inclusive.
- *
- * @param size the output size in bytes of this instance.
- * @param rounds the number of rounds to apply when transforming data.
- * @throws IllegalArgumentException if the designated output size is invalid,
- * or if the number of rounds is invalid.
- * @see #HAVAL_128_BIT
- * @see #HAVAL_160_BIT
- * @see #HAVAL_192_BIT
- * @see #HAVAL_224_BIT
- * @see #HAVAL_256_BIT
- * @see #HAVAL_3_ROUND
- * @see #HAVAL_4_ROUND
- * @see #HAVAL_5_ROUND
- */
- public Haval(int size, int rounds)
- {
- super(Registry.HAVAL_HASH, size, BLOCK_SIZE);
-
- if (size != HAVAL_128_BIT
- && size != HAVAL_160_BIT
- && size != HAVAL_192_BIT
- && size != HAVAL_224_BIT
- && size != HAVAL_256_BIT)
- throw new IllegalArgumentException("Invalid HAVAL output size");
-
- if (rounds != HAVAL_3_ROUND
- && rounds != HAVAL_4_ROUND
- && rounds != HAVAL_5_ROUND)
- throw new IllegalArgumentException("Invalid HAVAL number of rounds");
-
- this.rounds = rounds;
- }
-
- /**
- * Private constructor for cloning purposes.
- *
- * @param md the instance to clone.
- */
- private Haval(Haval md)
- {
- this(md.hashSize, md.rounds);
-
- this.h0 = md.h0;
- this.h1 = md.h1;
- this.h2 = md.h2;
- this.h3 = md.h3;
- this.h4 = md.h4;
- this.h5 = md.h5;
- this.h6 = md.h6;
- this.h7 = md.h7;
- this.count = md.count;
- this.buffer = (byte[]) md.buffer.clone();
- }
-
- public Object clone()
- {
- return new Haval(this);
- }
-
- protected synchronized void transform(byte[] in, int i)
- {
- int X0 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X1 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X2 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X3 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X4 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X5 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X6 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X7 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X8 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X9 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X10 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X11 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X12 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X13 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X14 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X15 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X16 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X17 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X18 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X19 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X20 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X21 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X22 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X23 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X24 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X25 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X26 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X27 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X28 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X29 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X30 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int X31 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | (in[i++] & 0xFF) << 24;
- int t0 = h0, t1 = h1, t2 = h2, t3 = h3, t4 = h4, t5 = h5, t6 = h6, t7 = h7;
- // Pass 1
- t7 = FF1(t7, t6, t5, t4, t3, t2, t1, t0, X0);
- t6 = FF1(t6, t5, t4, t3, t2, t1, t0, t7, X1);
- t5 = FF1(t5, t4, t3, t2, t1, t0, t7, t6, X2);
- t4 = FF1(t4, t3, t2, t1, t0, t7, t6, t5, X3);
- t3 = FF1(t3, t2, t1, t0, t7, t6, t5, t4, X4);
- t2 = FF1(t2, t1, t0, t7, t6, t5, t4, t3, X5);
- t1 = FF1(t1, t0, t7, t6, t5, t4, t3, t2, X6);
- t0 = FF1(t0, t7, t6, t5, t4, t3, t2, t1, X7);
-
- t7 = FF1(t7, t6, t5, t4, t3, t2, t1, t0, X8);
- t6 = FF1(t6, t5, t4, t3, t2, t1, t0, t7, X9);
- t5 = FF1(t5, t4, t3, t2, t1, t0, t7, t6, X10);
- t4 = FF1(t4, t3, t2, t1, t0, t7, t6, t5, X11);
- t3 = FF1(t3, t2, t1, t0, t7, t6, t5, t4, X12);
- t2 = FF1(t2, t1, t0, t7, t6, t5, t4, t3, X13);
- t1 = FF1(t1, t0, t7, t6, t5, t4, t3, t2, X14);
- t0 = FF1(t0, t7, t6, t5, t4, t3, t2, t1, X15);
-
- t7 = FF1(t7, t6, t5, t4, t3, t2, t1, t0, X16);
- t6 = FF1(t6, t5, t4, t3, t2, t1, t0, t7, X17);
- t5 = FF1(t5, t4, t3, t2, t1, t0, t7, t6, X18);
- t4 = FF1(t4, t3, t2, t1, t0, t7, t6, t5, X19);
- t3 = FF1(t3, t2, t1, t0, t7, t6, t5, t4, X20);
- t2 = FF1(t2, t1, t0, t7, t6, t5, t4, t3, X21);
- t1 = FF1(t1, t0, t7, t6, t5, t4, t3, t2, X22);
- t0 = FF1(t0, t7, t6, t5, t4, t3, t2, t1, X23);
-
- t7 = FF1(t7, t6, t5, t4, t3, t2, t1, t0, X24);
- t6 = FF1(t6, t5, t4, t3, t2, t1, t0, t7, X25);
- t5 = FF1(t5, t4, t3, t2, t1, t0, t7, t6, X26);
- t4 = FF1(t4, t3, t2, t1, t0, t7, t6, t5, X27);
- t3 = FF1(t3, t2, t1, t0, t7, t6, t5, t4, X28);
- t2 = FF1(t2, t1, t0, t7, t6, t5, t4, t3, X29);
- t1 = FF1(t1, t0, t7, t6, t5, t4, t3, t2, X30);
- t0 = FF1(t0, t7, t6, t5, t4, t3, t2, t1, X31);
-
- // Pass 2
- t7 = FF2(t7, t6, t5, t4, t3, t2, t1, t0, X5, 0x452821E6);
- t6 = FF2(t6, t5, t4, t3, t2, t1, t0, t7, X14, 0x38D01377);
- t5 = FF2(t5, t4, t3, t2, t1, t0, t7, t6, X26, 0xBE5466CF);
- t4 = FF2(t4, t3, t2, t1, t0, t7, t6, t5, X18, 0x34E90C6C);
- t3 = FF2(t3, t2, t1, t0, t7, t6, t5, t4, X11, 0xC0AC29B7);
- t2 = FF2(t2, t1, t0, t7, t6, t5, t4, t3, X28, 0xC97C50DD);
- t1 = FF2(t1, t0, t7, t6, t5, t4, t3, t2, X7, 0x3F84D5B5);
- t0 = FF2(t0, t7, t6, t5, t4, t3, t2, t1, X16, 0xB5470917);
-
- t7 = FF2(t7, t6, t5, t4, t3, t2, t1, t0, X0, 0x9216D5D9);
- t6 = FF2(t6, t5, t4, t3, t2, t1, t0, t7, X23, 0x8979FB1B);
- t5 = FF2(t5, t4, t3, t2, t1, t0, t7, t6, X20, 0xD1310BA6);
- t4 = FF2(t4, t3, t2, t1, t0, t7, t6, t5, X22, 0x98DFB5AC);
- t3 = FF2(t3, t2, t1, t0, t7, t6, t5, t4, X1, 0x2FFD72DB);
- t2 = FF2(t2, t1, t0, t7, t6, t5, t4, t3, X10, 0xD01ADFB7);
- t1 = FF2(t1, t0, t7, t6, t5, t4, t3, t2, X4, 0xB8E1AFED);
- t0 = FF2(t0, t7, t6, t5, t4, t3, t2, t1, X8, 0x6A267E96);
-
- t7 = FF2(t7, t6, t5, t4, t3, t2, t1, t0, X30, 0xBA7C9045);
- t6 = FF2(t6, t5, t4, t3, t2, t1, t0, t7, X3, 0xF12C7F99);
- t5 = FF2(t5, t4, t3, t2, t1, t0, t7, t6, X21, 0x24A19947);
- t4 = FF2(t4, t3, t2, t1, t0, t7, t6, t5, X9, 0xB3916CF7);
- t3 = FF2(t3, t2, t1, t0, t7, t6, t5, t4, X17, 0x0801F2E2);
- t2 = FF2(t2, t1, t0, t7, t6, t5, t4, t3, X24, 0x858EFC16);
- t1 = FF2(t1, t0, t7, t6, t5, t4, t3, t2, X29, 0x636920D8);
- t0 = FF2(t0, t7, t6, t5, t4, t3, t2, t1, X6, 0x71574E69);
-
- t7 = FF2(t7, t6, t5, t4, t3, t2, t1, t0, X19, 0xA458FEA3);
- t6 = FF2(t6, t5, t4, t3, t2, t1, t0, t7, X12, 0xF4933D7E);
- t5 = FF2(t5, t4, t3, t2, t1, t0, t7, t6, X15, 0x0D95748F);
- t4 = FF2(t4, t3, t2, t1, t0, t7, t6, t5, X13, 0x728EB658);
- t3 = FF2(t3, t2, t1, t0, t7, t6, t5, t4, X2, 0x718BCD58);
- t2 = FF2(t2, t1, t0, t7, t6, t5, t4, t3, X25, 0x82154AEE);
- t1 = FF2(t1, t0, t7, t6, t5, t4, t3, t2, X31, 0x7B54A41D);
- t0 = FF2(t0, t7, t6, t5, t4, t3, t2, t1, X27, 0xC25A59B5);
-
- // Pass 3
- t7 = FF3(t7, t6, t5, t4, t3, t2, t1, t0, X19, 0x9C30D539);
- t6 = FF3(t6, t5, t4, t3, t2, t1, t0, t7, X9, 0x2AF26013);
- t5 = FF3(t5, t4, t3, t2, t1, t0, t7, t6, X4, 0xC5D1B023);
- t4 = FF3(t4, t3, t2, t1, t0, t7, t6, t5, X20, 0x286085F0);
- t3 = FF3(t3, t2, t1, t0, t7, t6, t5, t4, X28, 0xCA417918);
- t2 = FF3(t2, t1, t0, t7, t6, t5, t4, t3, X17, 0xB8DB38EF);
- t1 = FF3(t1, t0, t7, t6, t5, t4, t3, t2, X8, 0x8E79DCB0);
- t0 = FF3(t0, t7, t6, t5, t4, t3, t2, t1, X22, 0x603A180E);
-
- t7 = FF3(t7, t6, t5, t4, t3, t2, t1, t0, X29, 0x6C9E0E8B);
- t6 = FF3(t6, t5, t4, t3, t2, t1, t0, t7, X14, 0xB01E8A3E);
- t5 = FF3(t5, t4, t3, t2, t1, t0, t7, t6, X25, 0xD71577C1);
- t4 = FF3(t4, t3, t2, t1, t0, t7, t6, t5, X12, 0xBD314B27);
- t3 = FF3(t3, t2, t1, t0, t7, t6, t5, t4, X24, 0x78AF2FDA);
- t2 = FF3(t2, t1, t0, t7, t6, t5, t4, t3, X30, 0x55605C60);
- t1 = FF3(t1, t0, t7, t6, t5, t4, t3, t2, X16, 0xE65525F3);
- t0 = FF3(t0, t7, t6, t5, t4, t3, t2, t1, X26, 0xAA55AB94);
-
- t7 = FF3(t7, t6, t5, t4, t3, t2, t1, t0, X31, 0x57489862);
- t6 = FF3(t6, t5, t4, t3, t2, t1, t0, t7, X15, 0x63E81440);
- t5 = FF3(t5, t4, t3, t2, t1, t0, t7, t6, X7, 0x55CA396A);
- t4 = FF3(t4, t3, t2, t1, t0, t7, t6, t5, X3, 0x2AAB10B6);
- t3 = FF3(t3, t2, t1, t0, t7, t6, t5, t4, X1, 0xB4CC5C34);
- t2 = FF3(t2, t1, t0, t7, t6, t5, t4, t3, X0, 0x1141E8CE);
- t1 = FF3(t1, t0, t7, t6, t5, t4, t3, t2, X18, 0xA15486AF);
- t0 = FF3(t0, t7, t6, t5, t4, t3, t2, t1, X27, 0x7C72E993);
-
- t7 = FF3(t7, t6, t5, t4, t3, t2, t1, t0, X13, 0xB3EE1411);
- t6 = FF3(t6, t5, t4, t3, t2, t1, t0, t7, X6, 0x636FBC2A);
- t5 = FF3(t5, t4, t3, t2, t1, t0, t7, t6, X21, 0x2BA9C55D);
- t4 = FF3(t4, t3, t2, t1, t0, t7, t6, t5, X10, 0x741831F6);
- t3 = FF3(t3, t2, t1, t0, t7, t6, t5, t4, X23, 0xCE5C3E16);
- t2 = FF3(t2, t1, t0, t7, t6, t5, t4, t3, X11, 0x9B87931E);
- t1 = FF3(t1, t0, t7, t6, t5, t4, t3, t2, X5, 0xAFD6BA33);
- t0 = FF3(t0, t7, t6, t5, t4, t3, t2, t1, X2, 0x6C24CF5C);
-
- if (rounds >= 4)
- {
- t7 = FF4(t7, t6, t5, t4, t3, t2, t1, t0, X24, 0x7A325381);
- t6 = FF4(t6, t5, t4, t3, t2, t1, t0, t7, X4, 0x28958677);
- t5 = FF4(t5, t4, t3, t2, t1, t0, t7, t6, X0, 0x3B8F4898);
- t4 = FF4(t4, t3, t2, t1, t0, t7, t6, t5, X14, 0x6B4BB9AF);
- t3 = FF4(t3, t2, t1, t0, t7, t6, t5, t4, X2, 0xC4BFE81B);
- t2 = FF4(t2, t1, t0, t7, t6, t5, t4, t3, X7, 0x66282193);
- t1 = FF4(t1, t0, t7, t6, t5, t4, t3, t2, X28, 0x61D809CC);
- t0 = FF4(t0, t7, t6, t5, t4, t3, t2, t1, X23, 0xFB21A991);
- t7 = FF4(t7, t6, t5, t4, t3, t2, t1, t0, X26, 0x487CAC60);
- t6 = FF4(t6, t5, t4, t3, t2, t1, t0, t7, X6, 0x5DEC8032);
- t5 = FF4(t5, t4, t3, t2, t1, t0, t7, t6, X30, 0xEF845D5D);
- t4 = FF4(t4, t3, t2, t1, t0, t7, t6, t5, X20, 0xE98575B1);
- t3 = FF4(t3, t2, t1, t0, t7, t6, t5, t4, X18, 0xDC262302);
- t2 = FF4(t2, t1, t0, t7, t6, t5, t4, t3, X25, 0xEB651B88);
- t1 = FF4(t1, t0, t7, t6, t5, t4, t3, t2, X19, 0x23893E81);
- t0 = FF4(t0, t7, t6, t5, t4, t3, t2, t1, X3, 0xD396ACC5);
-
- t7 = FF4(t7, t6, t5, t4, t3, t2, t1, t0, X22, 0x0F6D6FF3);
- t6 = FF4(t6, t5, t4, t3, t2, t1, t0, t7, X11, 0x83F44239);
- t5 = FF4(t5, t4, t3, t2, t1, t0, t7, t6, X31, 0x2E0B4482);
- t4 = FF4(t4, t3, t2, t1, t0, t7, t6, t5, X21, 0xA4842004);
- t3 = FF4(t3, t2, t1, t0, t7, t6, t5, t4, X8, 0x69C8F04A);
- t2 = FF4(t2, t1, t0, t7, t6, t5, t4, t3, X27, 0x9E1F9B5E);
- t1 = FF4(t1, t0, t7, t6, t5, t4, t3, t2, X12, 0x21C66842);
- t0 = FF4(t0, t7, t6, t5, t4, t3, t2, t1, X9, 0xF6E96C9A);
- t7 = FF4(t7, t6, t5, t4, t3, t2, t1, t0, X1, 0x670C9C61);
- t6 = FF4(t6, t5, t4, t3, t2, t1, t0, t7, X29, 0xABD388F0);
- t5 = FF4(t5, t4, t3, t2, t1, t0, t7, t6, X5, 0x6A51A0D2);
- t4 = FF4(t4, t3, t2, t1, t0, t7, t6, t5, X15, 0xD8542F68);
- t3 = FF4(t3, t2, t1, t0, t7, t6, t5, t4, X17, 0x960FA728);
- t2 = FF4(t2, t1, t0, t7, t6, t5, t4, t3, X10, 0xAB5133A3);
- t1 = FF4(t1, t0, t7, t6, t5, t4, t3, t2, X16, 0x6EEF0B6C);
- t0 = FF4(t0, t7, t6, t5, t4, t3, t2, t1, X13, 0x137A3BE4);
-
- if (rounds == 5)
- {
- t7 = FF5(t7, t6, t5, t4, t3, t2, t1, t0, X27, 0xBA3BF050);
- t6 = FF5(t6, t5, t4, t3, t2, t1, t0, t7, X3, 0x7EFB2A98);
- t5 = FF5(t5, t4, t3, t2, t1, t0, t7, t6, X21, 0xA1F1651D);
- t4 = FF5(t4, t3, t2, t1, t0, t7, t6, t5, X26, 0x39AF0176);
- t3 = FF5(t3, t2, t1, t0, t7, t6, t5, t4, X17, 0x66CA593E);
- t2 = FF5(t2, t1, t0, t7, t6, t5, t4, t3, X11, 0x82430E88);
- t1 = FF5(t1, t0, t7, t6, t5, t4, t3, t2, X20, 0x8CEE8619);
- t0 = FF5(t0, t7, t6, t5, t4, t3, t2, t1, X29, 0x456F9FB4);
-
- t7 = FF5(t7, t6, t5, t4, t3, t2, t1, t0, X19, 0x7D84A5C3);
- t6 = FF5(t6, t5, t4, t3, t2, t1, t0, t7, X0, 0x3B8B5EBE);
- t5 = FF5(t5, t4, t3, t2, t1, t0, t7, t6, X12, 0xE06F75D8);
- t4 = FF5(t4, t3, t2, t1, t0, t7, t6, t5, X7, 0x85C12073);
- t3 = FF5(t3, t2, t1, t0, t7, t6, t5, t4, X13, 0x401A449F);
- t2 = FF5(t2, t1, t0, t7, t6, t5, t4, t3, X8, 0x56C16AA6);
- t1 = FF5(t1, t0, t7, t6, t5, t4, t3, t2, X31, 0x4ED3AA62);
- t0 = FF5(t0, t7, t6, t5, t4, t3, t2, t1, X10, 0x363F7706);
-
- t7 = FF5(t7, t6, t5, t4, t3, t2, t1, t0, X5, 0x1BFEDF72);
- t6 = FF5(t6, t5, t4, t3, t2, t1, t0, t7, X9, 0x429B023D);
- t5 = FF5(t5, t4, t3, t2, t1, t0, t7, t6, X14, 0x37D0D724);
- t4 = FF5(t4, t3, t2, t1, t0, t7, t6, t5, X30, 0xD00A1248);
- t3 = FF5(t3, t2, t1, t0, t7, t6, t5, t4, X18, 0xDB0FEAD3);
- t2 = FF5(t2, t1, t0, t7, t6, t5, t4, t3, X6, 0x49F1C09B);
- t1 = FF5(t1, t0, t7, t6, t5, t4, t3, t2, X28, 0x075372C9);
- t0 = FF5(t0, t7, t6, t5, t4, t3, t2, t1, X24, 0x80991B7B);
-
- t7 = FF5(t7, t6, t5, t4, t3, t2, t1, t0, X2, 0x25D479D8);
- t6 = FF5(t6, t5, t4, t3, t2, t1, t0, t7, X23, 0xF6E8DEF7);
- t5 = FF5(t5, t4, t3, t2, t1, t0, t7, t6, X16, 0xE3FE501A);
- t4 = FF5(t4, t3, t2, t1, t0, t7, t6, t5, X22, 0xB6794C3B);
- t3 = FF5(t3, t2, t1, t0, t7, t6, t5, t4, X4, 0x976CE0BD);
- t2 = FF5(t2, t1, t0, t7, t6, t5, t4, t3, X1, 0x04C006BA);
- t1 = FF5(t1, t0, t7, t6, t5, t4, t3, t2, X25, 0xC1A94FB6);
- t0 = FF5(t0, t7, t6, t5, t4, t3, t2, t1, X15, 0x409F60C4);
- }
- }
- h7 += t7;
- h6 += t6;
- h5 += t5;
- h4 += t4;
- h3 += t3;
- h2 += t2;
- h1 += t1;
- h0 += t0;
- }
-
- protected byte[] padBuffer()
- {
- // pad out to 118 mod 128. other 10 bytes have special use.
- int n = (int)(count % BLOCK_SIZE);
- int padding = (n < 118) ? (118 - n) : (246 - n);
- byte[] result = new byte[padding + 10];
- result[0] = (byte) 0x01;
- // save the version number (LSB 3), the number of rounds (3 bits in the
- // middle), the fingerprint length (MSB 2 bits and next byte) and the
- // number of bits in the unpadded message.
- int bl = hashSize * 8;
- int sigByte = (bl & 0x03) << 6;
- sigByte |= (rounds & 0x07) << 3;
- sigByte |= HAVAL_VERSION & 0x07;
- result[padding++] = (byte) sigByte;
- result[padding++] = (byte)(bl >>> 2);
- // save number of bits, casting the long to an array of 8 bytes
- long bits = count << 3;
- result[padding++] = (byte) bits;
- result[padding++] = (byte)(bits >>> 8);
- result[padding++] = (byte)(bits >>> 16);
- result[padding++] = (byte)(bits >>> 24);
- result[padding++] = (byte)(bits >>> 32);
- result[padding++] = (byte)(bits >>> 40);
- result[padding++] = (byte)(bits >>> 48);
- result[padding ] = (byte)(bits >>> 56);
- return result;
- }
-
- protected byte[] getResult()
- {
- tailorDigestBits(); // tailor context for the designated output size
- // cast enough top context values into an array of hashSize bytes
- byte[] result = new byte[hashSize];
- if (hashSize >= HAVAL_256_BIT)
- {
- result[31] = (byte)(h7 >>> 24);
- result[30] = (byte)(h7 >>> 16);
- result[29] = (byte)(h7 >>> 8);
- result[28] = (byte) h7;
- }
- if (hashSize >= HAVAL_224_BIT)
- {
- result[27] = (byte)(h6 >>> 24);
- result[26] = (byte)(h6 >>> 16);
- result[25] = (byte)(h6 >>> 8);
- result[24] = (byte) h6;
- }
- if (hashSize >= HAVAL_192_BIT)
- {
- result[23] = (byte)(h5 >>> 24);
- result[22] = (byte)(h5 >>> 16);
- result[21] = (byte)(h5 >>> 8);
- result[20] = (byte) h5;
- }
- if (hashSize >= HAVAL_160_BIT)
- {
- result[19] = (byte)(h4 >>> 24);
- result[18] = (byte)(h4 >>> 16);
- result[17] = (byte)(h4 >>> 8);
- result[16] = (byte) h4;
- }
- result[15] = (byte)(h3 >>> 24);
- result[14] = (byte)(h3 >>> 16);
- result[13] = (byte)(h3 >>> 8);
- result[12] = (byte) h3;
- result[11] = (byte)(h2 >>> 24);
- result[10] = (byte)(h2 >>> 16);
- result[ 9] = (byte)(h2 >>> 8);
- result[ 8] = (byte) h2;
- result[ 7] = (byte)(h1 >>> 24);
- result[ 6] = (byte)(h1 >>> 16);
- result[ 5] = (byte)(h1 >>> 8);
- result[ 4] = (byte) h1;
- result[ 3] = (byte)(h0 >>> 24);
- result[ 2] = (byte)(h0 >>> 16);
- result[ 1] = (byte)(h0 >>> 8);
- result[ 0] = (byte) h0;
- return result;
- }
-
- protected void resetContext()
- {
- h0 = 0x243F6A88;
- h1 = 0x85A308D3;
- h2 = 0x13198A2E;
- h3 = 0x03707344;
- h4 = 0xA4093822;
- h5 = 0x299F31D0;
- h6 = 0x082EFA98;
- h7 = 0xEC4E6C89;
- }
-
- public boolean selfTest()
- {
- if (valid == null)
- {
- String d = Util.toString(new Haval().digest());
- valid = Boolean.valueOf(DIGEST0.equals(d));
- }
- return valid.booleanValue();
- }
-
- /** Tailors the last output. */
- private void tailorDigestBits()
- {
- int t;
- switch (hashSize)
- {
- case HAVAL_128_BIT:
- t = (h7 & 0x000000FF)
- | (h6 & 0xFF000000)
- | (h5 & 0x00FF0000)
- | (h4 & 0x0000FF00);
- h0 += t >>> 8 | t << 24;
- t = (h7 & 0x0000FF00)
- | (h6 & 0x000000FF)
- | (h5 & 0xFF000000)
- | (h4 & 0x00FF0000);
- h1 += t >>> 16 | t << 16;
- t = (h7 & 0x00FF0000)
- | (h6 & 0x0000FF00)
- | (h5 & 0x000000FF)
- | (h4 & 0xFF000000);
- h2 += t >>> 24 | t << 8;
- t = (h7 & 0xFF000000)
- | (h6 & 0x00FF0000)
- | (h5 & 0x0000FF00)
- | (h4 & 0x000000FF);
- h3 += t;
- break;
- case HAVAL_160_BIT:
- t = (h7 & 0x3F) | (h6 & (0x7F << 25)) | (h5 & (0x3F << 19));
- h0 += t >>> 19 | t << 13;
- t = (h7 & (0x3F << 6)) | (h6 & 0x3F) | (h5 & (0x7F << 25));
- h1 += t >>> 25 | t << 7;
- t = (h7 & (0x7F << 12)) | (h6 & (0x3F << 6)) | (h5 & 0x3F);
- h2 += t;
- t = (h7 & (0x3F << 19)) | (h6 & (0x7F << 12)) | (h5 & (0x3F << 6));
- h3 += (t >>> 6);
- t = (h7 & (0x7F << 25)) | (h6 & (0x3F << 19)) | (h5 & (0x7F << 12));
- h4 += (t >>> 12);
- break;
- case HAVAL_192_BIT:
- t = (h7 & 0x1F) | (h6 & (0x3F << 26));
- h0 += t >>> 26 | t << 6;
- t = (h7 & (0x1F << 5)) | (h6 & 0x1F);
- h1 += t;
- t = (h7 & (0x3F << 10)) | (h6 & (0x1F << 5));
- h2 += (t >>> 5);
- t = (h7 & (0x1F << 16)) | (h6 & (0x3F << 10));
- h3 += (t >>> 10);
- t = (h7 & (0x1F << 21)) | (h6 & (0x1F << 16));
- h4 += (t >>> 16);
- t = (h7 & (0x3F << 26)) | (h6 & (0x1F << 21));
- h5 += (t >>> 21);
- break;
- case HAVAL_224_BIT:
- h0 += ((h7 >>> 27) & 0x1F);
- h1 += ((h7 >>> 22) & 0x1F);
- h2 += ((h7 >>> 18) & 0x0F);
- h3 += ((h7 >>> 13) & 0x1F);
- h4 += ((h7 >>> 9) & 0x0F);
- h5 += ((h7 >>> 4) & 0x1F);
- h6 += (h7 & 0x0F);
- }
- }
-
- /**
- * Permutations phi_{i,j}, i=3,4,5, j=1,...,i.
- *
- * rounds = 3: 6 5 4 3 2 1 0
- * | | | | | | | (replaced by)
- * phi_{3,1}: 1 0 3 5 6 2 4
- * phi_{3,2}: 4 2 1 0 5 3 6
- * phi_{3,3}: 6 1 2 3 4 5 0
- *
- * rounds = 4: 6 5 4 3 2 1 0
- * | | | | | | | (replaced by)
- * phi_{4,1}: 2 6 1 4 5 3 0
- * phi_{4,2}: 3 5 2 0 1 6 4
- * phi_{4,3}: 1 4 3 6 0 2 5
- * phi_{4,4}: 6 4 0 5 2 1 3
- *
- * rounds = 5: 6 5 4 3 2 1 0
- * | | | | | | | (replaced by)
- * phi_{5,1}: 3 4 1 0 5 2 6
- * phi_{5,2}: 6 2 1 0 3 4 5
- * phi_{5,3}: 2 6 0 4 3 1 5
- * phi_{5,4}: 1 5 3 2 0 4 6
- * phi_{5,5}: 2 5 0 6 4 3 1
- */
- private int FF1(int x7, int x6, int x5, int x4, int x3, int x2, int x1,
- int x0, int w)
- {
- int t;
- switch (rounds)
- {
- case 3:
- t = f1(x1, x0, x3, x5, x6, x2, x4);
- break;
- case 4:
- t = f1(x2, x6, x1, x4, x5, x3, x0);
- break;
- default:
- t = f1(x3, x4, x1, x0, x5, x2, x6);
- }
- return (t >>> 7 | t << 25) + (x7 >>> 11 | x7 << 21) + w;
- }
-
- private int FF2(int x7, int x6, int x5, int x4, int x3, int x2, int x1,
- int x0, int w, int c)
- {
- int t;
- switch (rounds)
- {
- case 3:
- t = f2(x4, x2, x1, x0, x5, x3, x6);
- break;
- case 4:
- t = f2(x3, x5, x2, x0, x1, x6, x4);
- break;
- default:
- t = f2(x6, x2, x1, x0, x3, x4, x5);
- }
- return (t >>> 7 | t << 25) + (x7 >>> 11 | x7 << 21) + w + c;
- }
-
- private int FF3(int x7, int x6, int x5, int x4, int x3, int x2, int x1,
- int x0, int w, int c)
- {
- int t;
- switch (rounds)
- {
- case 3:
- t = f3(x6, x1, x2, x3, x4, x5, x0);
- break;
- case 4:
- t = f3(x1, x4, x3, x6, x0, x2, x5);
- break;
- default:
- t = f3(x2, x6, x0, x4, x3, x1, x5);
- }
- return (t >>> 7 | t << 25) + (x7 >>> 11 | x7 << 21) + w + c;
- }
-
- private int FF4(int x7, int x6, int x5, int x4, int x3, int x2, int x1,
- int x0, int w, int c)
- {
- int t;
- switch (rounds)
- {
- case 4:
- t = f4(x6, x4, x0, x5, x2, x1, x3);
- break;
- default:
- t = f4(x1, x5, x3, x2, x0, x4, x6);
- }
- return (t >>> 7 | t << 25) + (x7 >>> 11 | x7 << 21) + w + c;
- }
-
- private int FF5(int x7, int x6, int x5, int x4, int x3, int x2, int x1,
- int x0, int w, int c)
- {
- int t = f5(x2, x5, x0, x6, x4, x3, x1);
- return (t >>> 7 | t << 25) + (x7 >>> 11 | x7 << 21) + w + c;
- }
-
- private int f1(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
- {
- return x1 & (x0 ^ x4) ^ x2 & x5 ^ x3 & x6 ^ x0;
- }
-
- private int f2(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
- {
- return x2 & (x1 & ~x3 ^ x4 & x5 ^ x6 ^ x0) ^ x4 & (x1 ^ x5) ^ x3 & x5 ^ x0;
- }
-
- private int f3(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
- {
- return x3 & (x1 & x2 ^ x6 ^ x0) ^ x1 & x4 ^ x2 & x5 ^ x0;
- }
-
- private int f4(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
- {
- return x4 & (x5 & ~x2 ^ x3 & ~x6 ^ x1 ^ x6 ^ x0) ^ x3
- & (x1 & x2 ^ x5 ^ x6) ^ x2 & x6 ^ x0;
- }
-
- private int f5(int x6, int x5, int x4, int x3, int x2, int x1, int x0)
- {
- return x0 & (x1 & x2 & x3 ^ ~x5) ^ x1 & x4 ^ x2 & x5 ^ x3 & x6;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/IMessageDigest.java b/openjdk/icedtea/jce/gnu/java/security/hash/IMessageDigest.java
deleted file mode 100644
index 2c5bdd41..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/hash/IMessageDigest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/* IMessageDigest.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.hash;
-
-/**
- * The basic visible methods of any hash algorithm.
- *
- * A hash (or message digest) algorithm produces its output by iterating a basic
- * compression function on blocks of data.
- */
-public interface IMessageDigest
- extends Cloneable
-{
- /**
- * Returns the canonical name of this algorithm.
- *
- * @return the canonical name of this instance.
- */
- String name();
-
- /**
- * Returns the output length in bytes of this message digest algorithm.
- *
- * @return the output length in bytes of this message digest algorithm.
- */
- int hashSize();
-
- /**
- * Returns the algorithm's (inner) block size in bytes.
- *
- * @return the algorithm's inner block size in bytes.
- */
- int blockSize();
-
- /**
- * Continues a message digest operation using the input byte.
- *
- * @param b the input byte to digest.
- */
- void update(byte b);
-
- /**
- * Continues a message digest operation, by filling the buffer, processing
- * data in the algorithm's HASH_SIZE-bit block(s), updating the context and
- * count, and buffering the remaining bytes in buffer for the next operation.
- *
- * @param in the input block.
- */
- void update(byte[] in);
-
- /**
- * Continues a message digest operation, by filling the buffer, processing
- * data in the algorithm's HASH_SIZE-bit block(s), updating the context and
- * count, and buffering the remaining bytes in buffer for the next operation.
- *
- * @param in the input block.
- * @param offset start of meaningful bytes in input block.
- * @param length number of bytes, in input block, to consider.
- */
- void update(byte[] in, int offset, int length);
-
- /**
- * Completes the message digest by performing final operations such as padding
- * and resetting the instance.
- *
- * @return the array of bytes representing the hash value.
- */
- byte[] digest();
-
- /**
- * Resets the current context of this instance clearing any eventually cached
- * intermediary values.
- */
- void reset();
-
- /**
- * A basic test. Ensures that the digest of a pre-determined message is equal
- * to a known pre-computed value.
- *
- * @return true
if the implementation passes a basic self-test.
- * Returns false
otherwise.
- */
- boolean selfTest();
-
- /**
- * Returns a clone copy of this instance.
- *
- * @return a clone copy of this instance.
- */
- Object clone();
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/MD2.java b/openjdk/icedtea/jce/gnu/java/security/hash/MD2.java
deleted file mode 100644
index 8f6b265b..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/hash/MD2.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/* MD2.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.hash;
-
-import gnu.java.security.Registry;
-import gnu.java.security.util.Util;
-
-/**
- * An implementation of the MD2 message digest algorithm.
- *
- * MD2 is not widely used. Unless it is needed for compatibility with - * existing systems, it is not recommended for use in new applications. - *
- * References: - *
BLOCK_LENGTH
bytes
- * are also used to store the running digest.
- */
- private byte[] work;
-
- /** Creates a new MD2 digest ready for use. */
- public MD2()
- {
- super(Registry.MD2_HASH, DIGEST_LENGTH, BLOCK_LENGTH);
- }
-
- /**
- * Private constructor used for cloning.
- *
- * @param md2 the instance to clone.
- */
- private MD2(MD2 md2)
- {
- this();
-
- // superclass field
- this.count = md2.count;
- this.buffer = (byte[]) md2.buffer.clone();
- // private field
- this.checksum = (byte[]) md2.checksum.clone();
- this.work = (byte[]) md2.work.clone();
- }
-
- public Object clone()
- {
- return new MD2(this);
- }
-
- protected byte[] getResult()
- {
- byte[] result = new byte[DIGEST_LENGTH];
- // Encrypt checksum as last block.
- encryptBlock(checksum, 0);
- for (int i = 0; i < BLOCK_LENGTH; i++)
- result[i] = work[i];
-
- return result;
- }
-
- protected void resetContext()
- {
- checksum = new byte[BLOCK_LENGTH];
- work = new byte[BLOCK_LENGTH * 3];
- }
-
- public boolean selfTest()
- {
- if (valid == null)
- {
- String d = Util.toString(new MD2().digest());
- valid = Boolean.valueOf(DIGEST0.equals(d));
- }
- return valid.booleanValue();
- }
-
- /**
- * Generates an array of padding bytes. The padding is defined as
- * i
bytes of value i
, where i
is the
- * number of bytes to fill the last block of the message to
- * BLOCK_LENGTH
bytes (or BLOCK_LENGTH
bytes when
- * the last block was completely full).
- *
- * @return the bytes to pad the remaining bytes in the buffer before
- * completing a hash operation.
- */
- protected byte[] padBuffer()
- {
- int length = BLOCK_LENGTH - (int) (count % BLOCK_LENGTH);
- if (length == 0)
- length = BLOCK_LENGTH;
-
- byte[] pad = new byte[length];
- for (int i = 0; i < length; i++)
- pad[i] = (byte) length;
-
- return pad;
- }
-
- /**
- * Adds BLOCK_LENGTH
bytes to the running digest.
- *
- * @param in the byte array to take the BLOCK_LENGTH
bytes from.
- * @param off the offset to start from in the given byte array.
- */
- protected void transform(byte[] in, int off)
- {
- updateCheckSumAndEncryptBlock(in, off);
- }
-
- /**
- * Adds a new block (BLOCK_LENGTH
bytes) to the running digest
- * from the given byte array starting from the given offset.
- */
- private void encryptBlock(byte[] in, int off)
- {
- for (int i = 0; i < BLOCK_LENGTH; i++)
- {
- byte b = in[off + i];
- work[BLOCK_LENGTH + i] = b;
- work[BLOCK_LENGTH * 2 + i] = (byte)(work[i] ^ b);
- }
- byte t = 0;
- for (int i = 0; i < 18; i++)
- {
- for (int j = 0; j < 3 * BLOCK_LENGTH; j++)
- {
- t = (byte)(work[j] ^ PI[t & 0xFF]);
- work[j] = t;
- }
- t = (byte)(t + i);
- }
- }
-
- /**
- * Optimized method that combines a checksum update and encrypt of a block.
- */
- private void updateCheckSumAndEncryptBlock(byte[] in, int off)
- {
- byte l = checksum[BLOCK_LENGTH - 1];
- for (int i = 0; i < BLOCK_LENGTH; i++)
- {
- byte b = in[off + i];
- work[BLOCK_LENGTH + i] = b;
- work[BLOCK_LENGTH * 2 + i] = (byte)(work[i] ^ b);
- l = (byte)(checksum[i] ^ PI[(b ^ l) & 0xFF]);
- checksum[i] = l;
- }
- byte t = 0;
- for (int i = 0; i < 18; i++)
- {
- for (int j = 0; j < 3 * BLOCK_LENGTH; j++)
- {
- t = (byte)(work[j] ^ PI[t & 0xFF]);
- work[j] = t;
- }
- t = (byte)(t + i);
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/MD4.java b/openjdk/icedtea/jce/gnu/java/security/hash/MD4.java
deleted file mode 100644
index dfc1c6bd..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/hash/MD4.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/* MD4.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.hash;
-
-import gnu.java.security.Registry;
-import gnu.java.security.util.Util;
-
-/**
- * An implementation of Ron Rivest's MD4 message digest algorithm.
- * - * MD4 was the precursor to the stronger {@link gnu.java.security.hash.MD5} - * algorithm, and while not considered cryptograpically secure itself, MD4 is - * in use in various applications. It is slightly faster than MD5. - *
- * References: - *
0
, and creates a new block of 512
bits.
- */
- public MD4()
- {
- super(Registry.MD4_HASH, DIGEST_LENGTH, BLOCK_LENGTH);
- }
-
- /**
- * Trivial private constructor for cloning purposes.
- *
- * @param that the instance to clone.
- */
- private MD4(MD4 that)
- {
- this();
-
- this.a = that.a;
- this.b = that.b;
- this.c = that.c;
- this.d = that.d;
- this.count = that.count;
- this.buffer = (byte[]) that.buffer.clone();
- }
-
- public Object clone()
- {
- return new MD4(this);
- }
-
- protected byte[] getResult()
- {
- return new byte[] {
- (byte) a, (byte)(a >>> 8), (byte)(a >>> 16), (byte)(a >>> 24),
- (byte) b, (byte)(b >>> 8), (byte)(b >>> 16), (byte)(b >>> 24),
- (byte) c, (byte)(c >>> 8), (byte)(c >>> 16), (byte)(c >>> 24),
- (byte) d, (byte)(d >>> 8), (byte)(d >>> 16), (byte)(d >>> 24) };
- }
-
- protected void resetContext()
- {
- a = A;
- b = B;
- c = C;
- d = D;
- }
-
- public boolean selfTest()
- {
- if (valid == null)
- {
- String d = Util.toString(new MD4().digest());
- valid = Boolean.valueOf(DIGEST0.equals(d));
- }
- return valid.booleanValue();
- }
-
- protected byte[] padBuffer()
- {
- int n = (int)(count % BLOCK_LENGTH);
- int padding = (n < 56) ? (56 - n) : (120 - n);
- byte[] pad = new byte[padding + 8];
- pad[0] = (byte) 0x80;
- long bits = count << 3;
- pad[padding++] = (byte) bits;
- pad[padding++] = (byte)(bits >>> 8);
- pad[padding++] = (byte)(bits >>> 16);
- pad[padding++] = (byte)(bits >>> 24);
- pad[padding++] = (byte)(bits >>> 32);
- pad[padding++] = (byte)(bits >>> 40);
- pad[padding++] = (byte)(bits >>> 48);
- pad[padding ] = (byte)(bits >>> 56);
- return pad;
- }
-
- protected void transform(byte[] in, int i)
- {
- int X0 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X1 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X2 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X3 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X4 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X5 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X6 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X7 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X8 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X9 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X10 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X11 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X12 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X13 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X14 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i++] << 24;
- int X15 = (in[i++] & 0xFF)
- | (in[i++] & 0xFF) << 8
- | (in[i++] & 0xFF) << 16
- | in[i] << 24;
- int aa, bb, cc, dd;
- aa = a;
- bb = b;
- cc = c;
- dd = d;
-
- aa += ((bb & cc) | ((~bb) & dd)) + X0;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & bb) | ((~aa) & cc)) + X1;
- dd = dd << 7 | dd >>> -7;
- cc += ((dd & aa) | ((~dd) & bb)) + X2;
- cc = cc << 11 | cc >>> -11;
- bb += ((cc & dd) | ((~cc) & aa)) + X3;
- bb = bb << 19 | bb >>> -19;
- aa += ((bb & cc) | ((~bb) & dd)) + X4;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & bb) | ((~aa) & cc)) + X5;
- dd = dd << 7 | dd >>> -7;
- cc += ((dd & aa) | ((~dd) & bb)) + X6;
- cc = cc << 11 | cc >>> -11;
- bb += ((cc & dd) | ((~cc) & aa)) + X7;
- bb = bb << 19 | bb >>> -19;
- aa += ((bb & cc) | ((~bb) & dd)) + X8;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & bb) | ((~aa) & cc)) + X9;
- dd = dd << 7 | dd >>> -7;
- cc += ((dd & aa) | ((~dd) & bb)) + X10;
- cc = cc << 11 | cc >>> -11;
- bb += ((cc & dd) | ((~cc) & aa)) + X11;
- bb = bb << 19 | bb >>> -19;
- aa += ((bb & cc) | ((~bb) & dd)) + X12;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & bb) | ((~aa) & cc)) + X13;
- dd = dd << 7 | dd >>> -7;
- cc += ((dd & aa) | ((~dd) & bb)) + X14;
- cc = cc << 11 | cc >>> -11;
- bb += ((cc & dd) | ((~cc) & aa)) + X15;
- bb = bb << 19 | bb >>> -19;
-
- aa += ((bb & (cc | dd)) | (cc & dd)) + X0 + 0x5a827999;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & (bb | cc)) | (bb & cc)) + X4 + 0x5a827999;
- dd = dd << 5 | dd >>> -5;
- cc += ((dd & (aa | bb)) | (aa & bb)) + X8 + 0x5a827999;
- cc = cc << 9 | cc >>> -9;
- bb += ((cc & (dd | aa)) | (dd & aa)) + X12 + 0x5a827999;
- bb = bb << 13 | bb >>> -13;
- aa += ((bb & (cc | dd)) | (cc & dd)) + X1 + 0x5a827999;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & (bb | cc)) | (bb & cc)) + X5 + 0x5a827999;
- dd = dd << 5 | dd >>> -5;
- cc += ((dd & (aa | bb)) | (aa & bb)) + X9 + 0x5a827999;
- cc = cc << 9 | cc >>> -9;
- bb += ((cc & (dd | aa)) | (dd & aa)) + X13 + 0x5a827999;
- bb = bb << 13 | bb >>> -13;
- aa += ((bb & (cc | dd)) | (cc & dd)) + X2 + 0x5a827999;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & (bb | cc)) | (bb & cc)) + X6 + 0x5a827999;
- dd = dd << 5 | dd >>> -5;
- cc += ((dd & (aa | bb)) | (aa & bb)) + X10 + 0x5a827999;
- cc = cc << 9 | cc >>> -9;
- bb += ((cc & (dd | aa)) | (dd & aa)) + X14 + 0x5a827999;
- bb = bb << 13 | bb >>> -13;
- aa += ((bb & (cc | dd)) | (cc & dd)) + X3 + 0x5a827999;
- aa = aa << 3 | aa >>> -3;
- dd += ((aa & (bb | cc)) | (bb & cc)) + X7 + 0x5a827999;
- dd = dd << 5 | dd >>> -5;
- cc += ((dd & (aa | bb)) | (aa & bb)) + X11 + 0x5a827999;
- cc = cc << 9 | cc >>> -9;
- bb += ((cc & (dd | aa)) | (dd & aa)) + X15 + 0x5a827999;
- bb = bb << 13 | bb >>> -13;
-
- aa += (bb ^ cc ^ dd) + X0 + 0x6ed9eba1;
- aa = aa << 3 | aa >>> -3;
- dd += (aa ^ bb ^ cc) + X8 + 0x6ed9eba1;
- dd = dd << 9 | dd >>> -9;
- cc += (dd ^ aa ^ bb) + X4 + 0x6ed9eba1;
- cc = cc << 11 | cc >>> -11;
- bb += (cc ^ dd ^ aa) + X12 + 0x6ed9eba1;
- bb = bb << 15 | bb >>> -15;
- aa += (bb ^ cc ^ dd) + X2 + 0x6ed9eba1;
- aa = aa << 3 | aa >>> -3;
- dd += (aa ^ bb ^ cc) + X10 + 0x6ed9eba1;
- dd = dd << 9 | dd >>> -9;
- cc += (dd ^ aa ^ bb) + X6 + 0x6ed9eba1;
- cc = cc << 11 | cc >>> -11;
- bb += (cc ^ dd ^ aa) + X14 + 0x6ed9eba1;
- bb = bb << 15 | bb >>> -15;
- aa += (bb ^ cc ^ dd) + X1 + 0x6ed9eba1;
- aa = aa << 3 | aa >>> -3;
- dd += (aa ^ bb ^ cc) + X9 + 0x6ed9eba1;
- dd = dd << 9 | dd >>> -9;
- cc += (dd ^ aa ^ bb) + X5 + 0x6ed9eba1;
- cc = cc << 11 | cc >>> -11;
- bb += (cc ^ dd ^ aa) + X13 + 0x6ed9eba1;
- bb = bb << 15 | bb >>> -15;
- aa += (bb ^ cc ^ dd) + X3 + 0x6ed9eba1;
- aa = aa << 3 | aa >>> -3;
- dd += (aa ^ bb ^ cc) + X11 + 0x6ed9eba1;
- dd = dd << 9 | dd >>> -9;
- cc += (dd ^ aa ^ bb) + X7 + 0x6ed9eba1;
- cc = cc << 11 | cc >>> -11;
- bb += (cc ^ dd ^ aa) + X15 + 0x6ed9eba1;
- bb = bb << 15 | bb >>> -15;
-
- a += aa;
- b += bb;
- c += cc;
- d += dd;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/hash/MD5.java b/openjdk/icedtea/jce/gnu/java/security/hash/MD5.java
deleted file mode 100644
index 65307851..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/hash/MD5.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/* MD5.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.hash;
-
-import gnu.java.security.Registry;
-import gnu.java.security.util.Util;
-
-/**
- * The MD5 message-digest algorithm takes as input a message of arbitrary
- * length and produces as output a 128-bit "fingerprint" or "message digest" of
- * the input. It is conjectured that it is computationally infeasible to
- * produce two messages having the same message digest, or to produce any
- * message having a given prespecified target message digest.
- * - * References: - *
- * References: - *
- * References: - *
- * The SHA-1 is designed to have the following properties: it is - * computationally infeasible to find a message which corresponds to a given - * message digest, or to find two different messages which produce the same - * message digest. - *
- * References: - *
- * References: - *
- * References: - *
- * References: - *
- * Tiger processes data in 512-bit blocks and produces a 192-bit - * digest. - *
- * References: - *
- * This implementation is of Whirlpool Version 3, described in [1] last revised - * on May 24th, 2003. - *
- * IMPORTANT: This implementation is not thread-safe. - *
- * References: - *
- * This class defines the Service Provider Interface (SPI) for - * the {@link java.security.MessageDigest} class, which provides the - * functionality of a message digest algorithm, such as MD5 or SHA. Message - * digests are secure one-way hash functions that take arbitrary-sized data and - * output a fixed-length hash value. - *
- * All the abstract methods in the {@link MessageDigestSpi} class are - * implemented by this class and all its sub-classes. - *
- * All the implementations which subclass this object, and which are serviced by - * the GNU provider implement the {@link Cloneable} interface. - */ -class MessageDigestAdapter - extends MessageDigestSpi - implements Cloneable -{ - /** Our underlying hash instance. */ - private IMessageDigest adaptee; - - /** - * Trivial protected constructor. - * - * @param mdName the canonical name of the hash algorithm. - */ - protected MessageDigestAdapter(String mdName) - { - this(HashFactory.getInstance(mdName)); - } - - /** - * Private constructor for cloning purposes. - * - * @param adaptee a clone of the underlying hash algorithm instance. - */ - private MessageDigestAdapter(IMessageDigest adaptee) - { - super(); - - this.adaptee = adaptee; - } - - public Object clone() - { - return new MessageDigestAdapter((IMessageDigest) adaptee.clone()); - } - - public int engineGetDigestLength() - { - return adaptee.hashSize(); - } - - public void engineUpdate(byte input) - { - adaptee.update(input); - } - - public void engineUpdate(byte[] input, int offset, int len) - { - adaptee.update(input, offset, len); - } - - public byte[] engineDigest() - { - return adaptee.digest(); - } - - public int engineDigest(byte[] buf, int offset, int len) - throws DigestException - { - int result = adaptee.hashSize(); - if (len < result) - throw new DigestException(); - - byte[] md = adaptee.digest(); - System.arraycopy(md, 0, buf, offset, result); - return result; - } - - public void engineReset() - { - adaptee.reset(); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD128Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD128Spi.java deleted file mode 100644 index 159a1173..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD128Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* RipeMD128Spi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the RIPEMD-128 Service Provider Interface - * (SPI) adapter. - */ -public class RipeMD128Spi - extends MessageDigestAdapter -{ - public RipeMD128Spi() - { - super(Registry.RIPEMD128_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD160Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD160Spi.java deleted file mode 100644 index 579ccb26..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/RipeMD160Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* RipeMD160Spi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the RIPEMD-160 Service Provider Interface - * (SPI) adapter. - */ -public class RipeMD160Spi - extends MessageDigestAdapter -{ - public RipeMD160Spi() - { - super(Registry.RIPEMD160_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha160Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha160Spi.java deleted file mode 100644 index 901cac19..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha160Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha160Spi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-1 (160-bit) Service Provider Interface - * (SPI) adapter. - */ -public class Sha160Spi - extends MessageDigestAdapter -{ - public Sha160Spi() - { - super(Registry.SHA160_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha256Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha256Spi.java deleted file mode 100644 index 9d471e65..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha256Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha256Spi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-2-1 (256-bit) Service Provider Interface - * (SPI) adapter. - */ -public class Sha256Spi - extends MessageDigestAdapter -{ - public Sha256Spi() - { - super(Registry.SHA256_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha384Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha384Spi.java deleted file mode 100644 index 30d5fce0..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha384Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha384Spi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-2-2 (384-bit) Service Provider Interface - * (SPI) adapter. - */ -public class Sha384Spi - extends MessageDigestAdapter -{ - public Sha384Spi() - { - super(Registry.SHA384_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha512Spi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha512Spi.java deleted file mode 100644 index a2d44ab2..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/Sha512Spi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha512Spi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-2-3 (512-bit) Service Provider Interface - * (SPI) adapter. - */ -public class Sha512Spi - extends MessageDigestAdapter -{ - public Sha512Spi() - { - super(Registry.SHA512_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/TigerSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/TigerSpi.java deleted file mode 100644 index a21e5fe1..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/TigerSpi.java +++ /dev/null @@ -1,55 +0,0 @@ -/* TigerSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the Tiger Service Provider Interface - * (SPI) adapter. - */ -public class TigerSpi - extends MessageDigestAdapter -{ - /** Trivial 0-arguments constructor. */ - public TigerSpi() - { - super(Registry.TIGER_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/hash/WhirlpoolSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/hash/WhirlpoolSpi.java deleted file mode 100644 index d7a7a450..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/hash/WhirlpoolSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* WhirlpoolSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.hash; - -import gnu.java.security.Registry; - -/** - * The implementation of the Whirlpool Service Provider Interface - * (SPI) adapter. - */ -public class WhirlpoolSpi - extends MessageDigestAdapter -{ - public WhirlpoolSpi() - { - super(Registry.WHIRLPOOL_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/HavalRandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/HavalRandomSpi.java deleted file mode 100644 index c3d4b941..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/HavalRandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* HavalRandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the HAVAL-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class HavalRandomSpi - extends SecureRandomAdapter -{ - public HavalRandomSpi() - { - super(Registry.HAVAL_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD2RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD2RandomSpi.java deleted file mode 100644 index 8ba28680..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD2RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* MD2RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the MD2-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class MD2RandomSpi - extends SecureRandomAdapter -{ - public MD2RandomSpi() - { - super(Registry.MD2_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD4RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD4RandomSpi.java deleted file mode 100644 index d4d18297..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD4RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* MD4RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the MD4-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class MD4RandomSpi - extends SecureRandomAdapter -{ - public MD4RandomSpi() - { - super(Registry.MD4_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD5RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD5RandomSpi.java deleted file mode 100644 index be38add0..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/MD5RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* MD5RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the MD5-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class MD5RandomSpi - extends SecureRandomAdapter -{ - public MD5RandomSpi() - { - super(Registry.MD5_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD128RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD128RandomSpi.java deleted file mode 100644 index 530c3ec2..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD128RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* RipeMD128RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the RIPEMD128-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class RipeMD128RandomSpi - extends SecureRandomAdapter -{ - public RipeMD128RandomSpi() - { - super(Registry.RIPEMD128_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD160RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD160RandomSpi.java deleted file mode 100644 index 6875cdfa..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/RipeMD160RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* RipeMD160RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the RIPEMD160-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class RipeMD160RandomSpi - extends SecureRandomAdapter -{ - public RipeMD160RandomSpi() - { - super(Registry.RIPEMD160_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/SecureRandomAdapter.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/SecureRandomAdapter.java deleted file mode 100644 index 5be402ff..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/SecureRandomAdapter.java +++ /dev/null @@ -1,107 +0,0 @@ -/* SecureRandomAdapter.java -- - Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.prng.LimitReachedException; -import gnu.java.security.prng.MDGenerator; - -import java.security.SecureRandomSpi; -import java.util.Collections; - -/** - * The implementation of a generic {@link java.security.SecureRandom} adapter - * class to wrap GNU PRNG instances based on Message Digest algorithms. - *
- * This class defines the Service Provider Interface (SPI) for - * the {@link java.security.SecureRandom} class, which provides the - * functionality of a cryptographically strong pseudo-random number generator. - *
- * All the abstract methods in the {@link SecureRandomSpi} class are implemented - * by this class and all its sub-classes. - */ -abstract class SecureRandomAdapter - extends SecureRandomSpi -{ - /** Our underlying prng instance. */ - private MDGenerator adaptee = new MDGenerator(); - - /** The name of the message digest algorithm used by the adaptee. */ - private String mdName; - - /** - * Trivial protected constructor. - * - * @param mdName the canonical name of the underlying hash algorithm. - */ - protected SecureRandomAdapter(String mdName) - { - super(); - - this.mdName = mdName; - adaptee.init(Collections.singletonMap(MDGenerator.MD_NAME, mdName)); - } - - public byte[] engineGenerateSeed(int numBytes) - { - if (numBytes < 1) - return new byte[0]; - - byte[] result = new byte[numBytes]; - this.engineNextBytes(result); - return result; - } - - public void engineNextBytes(byte[] bytes) - { - if (! adaptee.isInitialised()) - this.engineSetSeed(new byte[0]); - try - { - adaptee.nextBytes(bytes, 0, bytes.length); - } - catch (LimitReachedException ignored) - { - } - } - - public void engineSetSeed(byte[] seed) - { - adaptee.addRandomBytes(seed); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha160RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha160RandomSpi.java deleted file mode 100644 index 9fded67e..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha160RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha160RandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA1-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class Sha160RandomSpi - extends SecureRandomAdapter -{ - public Sha160RandomSpi() - { - super(Registry.SHA160_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha256RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha256RandomSpi.java deleted file mode 100644 index e3999ffe..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha256RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha256RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-256 based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class Sha256RandomSpi - extends SecureRandomAdapter -{ - public Sha256RandomSpi() - { - super(Registry.SHA256_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha384RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha384RandomSpi.java deleted file mode 100644 index 978c8fe3..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha384RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha384RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-384 based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class Sha384RandomSpi - extends SecureRandomAdapter -{ - public Sha384RandomSpi() - { - super(Registry.SHA384_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha512RandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha512RandomSpi.java deleted file mode 100644 index a89e26f0..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/Sha512RandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* Sha512RandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the SHA-512 based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class Sha512RandomSpi - extends SecureRandomAdapter -{ - public Sha512RandomSpi() - { - super(Registry.SHA512_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/TigerRandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/TigerRandomSpi.java deleted file mode 100644 index ba4b22fb..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/TigerRandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* TigerRandomSpi.java -- - Copyright (C) 2003, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the Tiger based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class TigerRandomSpi - extends SecureRandomAdapter -{ - public TigerRandomSpi() - { - super(Registry.TIGER_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java deleted file mode 100644 index 9d937e65..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/prng/WhirlpoolRandomSpi.java +++ /dev/null @@ -1,54 +0,0 @@ -/* WhirlpoolRandomSpi.java -- - Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.prng; - -import gnu.java.security.Registry; - -/** - * The implementation of the Whirlpool-based SecureRandom Service Provider - * Interface (SPI) adapter. - */ -public class WhirlpoolRandomSpi - extends SecureRandomAdapter -{ - public WhirlpoolRandomSpi() - { - super(Registry.WHIRLPOOL_HASH); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyFactory.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyFactory.java deleted file mode 100644 index 7b57dba7..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyFactory.java +++ /dev/null @@ -1,221 +0,0 @@ -/* DSSKeyFactory.java -- JCE DSA key factory Adapter - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security.jce.sig; - -import gnu.java.security.Registry; -import gnu.java.security.key.dss.DSSKeyPairPKCS8Codec; -import gnu.java.security.key.dss.DSSKeyPairX509Codec; -import gnu.java.security.key.dss.DSSPrivateKey; -import gnu.java.security.key.dss.DSSPublicKey; - -import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.Key; -import java.security.KeyFactorySpi; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.interfaces.DSAPrivateKey; -import java.security.interfaces.DSAPublicKey; -import java.security.spec.DSAPrivateKeySpec; -import java.security.spec.DSAPublicKeySpec; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.X509EncodedKeySpec; - -/** - * DSA key factory. - * - * @author Casey Marshall (rsdio@metastatic.org) - */ -public class DSSKeyFactory - extends KeyFactorySpi -{ - // implicit 0-arguments constructor - - protected PublicKey engineGeneratePublic(KeySpec keySpec) - throws InvalidKeySpecException - { - if (keySpec instanceof DSAPublicKeySpec) - { - DSAPublicKeySpec spec = (DSAPublicKeySpec) keySpec; - BigInteger p = spec.getP(); - BigInteger q = spec.getQ(); - BigInteger g = spec.getG(); - BigInteger y = spec.getY(); - return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); - } - if (keySpec instanceof X509EncodedKeySpec) - { - X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec; - byte[] encoded = spec.getEncoded(); - PublicKey result; - try - { - result = new DSSKeyPairX509Codec().decodePublicKey(encoded); - return result; - } - catch (RuntimeException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - throw new InvalidKeySpecException("Unsupported (public) key specification"); - } - - protected PrivateKey engineGeneratePrivate(KeySpec keySpec) - throws InvalidKeySpecException - { - if (keySpec instanceof DSAPrivateKeySpec) - { - DSAPrivateKeySpec spec = (DSAPrivateKeySpec) keySpec; - BigInteger p = spec.getP(); - BigInteger q = spec.getQ(); - BigInteger g = spec.getG(); - BigInteger x = spec.getX(); - return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x); - } - if (keySpec instanceof PKCS8EncodedKeySpec) - { - PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec; - byte[] encoded = spec.getEncoded(); - PrivateKey result; - try - { - result = new DSSKeyPairPKCS8Codec().decodePrivateKey(encoded); - return result; - } - catch (RuntimeException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - throw new InvalidKeySpecException("Unsupported (private) key specification"); - } - - protected KeySpec engineGetKeySpec(Key key, Class keySpec) - throws InvalidKeySpecException - { - if (key instanceof DSAPublicKey) - { - if (keySpec.isAssignableFrom(DSAPublicKeySpec.class)) - { - DSAPublicKey dsaKey = (DSAPublicKey) key; - BigInteger p = dsaKey.getParams().getP(); - BigInteger q = dsaKey.getParams().getQ(); - BigInteger g = dsaKey.getParams().getG(); - BigInteger y = dsaKey.getY(); - return new DSAPublicKeySpec(y, p, q, g); - } - if (keySpec.isAssignableFrom(X509EncodedKeySpec.class)) - { - if (key instanceof DSSPublicKey) - { - DSSPublicKey dssKey = (DSSPublicKey) key; - byte[] encoded = dssKey.getEncoded(Registry.X509_ENCODING_ID); - return new X509EncodedKeySpec(encoded); - } - if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat())) - { - byte[] encoded = key.getEncoded(); - return new X509EncodedKeySpec(encoded); - } - throw new InvalidKeySpecException( - "Wrong key type or unsupported (public) key specification"); - } - throw new InvalidKeySpecException("Unsupported (public) key specification"); - } - if (key instanceof DSAPrivateKey) - { - if (keySpec.isAssignableFrom(DSAPrivateKeySpec.class)) - { - DSAPrivateKey dsaKey = (DSAPrivateKey) key; - BigInteger p = dsaKey.getParams().getP(); - BigInteger q = dsaKey.getParams().getQ(); - BigInteger g = dsaKey.getParams().getG(); - BigInteger x = dsaKey.getX(); - return new DSAPrivateKeySpec(x, p, q, g); - } - if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) - { - if (key instanceof DSSPrivateKey) - { - DSSPrivateKey dssKey = (DSSPrivateKey) key; - byte[] encoded = dssKey.getEncoded(Registry.PKCS8_ENCODING_ID); - return new PKCS8EncodedKeySpec(encoded); - } - if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat())) - { - byte[] encoded = key.getEncoded(); - return new PKCS8EncodedKeySpec(encoded); - } - throw new InvalidKeySpecException( - "Wrong key type or unsupported (private) key specification"); - } - throw new InvalidKeySpecException("Unsupported (private) key specification"); - } - throw new InvalidKeySpecException("Wrong key type or unsupported key specification"); - } - - protected Key engineTranslateKey(Key key) throws InvalidKeyException - { - if ((key instanceof DSSPublicKey) || (key instanceof DSSPrivateKey)) - return key; - - if (key instanceof DSAPublicKey) - { - DSAPublicKey dsaKey = (DSAPublicKey) key; - BigInteger p = dsaKey.getParams().getP(); - BigInteger q = dsaKey.getParams().getQ(); - BigInteger g = dsaKey.getParams().getG(); - BigInteger y = dsaKey.getY(); - return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); - } - if (key instanceof DSAPrivateKey) - { - DSAPrivateKey dsaKey = (DSAPrivateKey) key; - BigInteger p = dsaKey.getParams().getP(); - BigInteger q = dsaKey.getParams().getQ(); - BigInteger g = dsaKey.getParams().getG(); - BigInteger x = dsaKey.getX(); - return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x); - } - throw new InvalidKeyException("Wrong key type"); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java deleted file mode 100644 index c4453810..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSKeyPairGeneratorSpi.java +++ /dev/null @@ -1,146 +0,0 @@ -/* DSSKeyPairGeneratorSpi.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.sig; - -import gnu.java.security.Registry; -import gnu.java.security.key.dss.DSSKeyPairGenerator; - -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidParameterException; -import java.security.SecureRandom; -import java.security.interfaces.DSAKeyPairGenerator; -import java.security.interfaces.DSAParams; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.DSAParameterSpec; -import java.util.HashMap; - -/** - * The implementation of a {@link java.security.KeyPairGenerator} adapter class - * to wrap GNU DSS keypair generator instances. - *
- * In case the client does not explicitly initialize the KeyPairGenerator (via a
- * call to an initialize()
method), the GNU provider uses a
- * default modulus size (keysize) of 1024 bits.
- */
-public class DSSKeyPairGeneratorSpi
- extends KeyPairGeneratorAdapter
- implements DSAKeyPairGenerator
-{
- public DSSKeyPairGeneratorSpi()
- {
- super(Registry.DSS_KPG);
- }
-
- public void initialize(int keysize, SecureRandom random)
- {
- this.initialize(keysize, false, random);
- }
-
- public void initialize(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException
- {
- HashMap attributes = new HashMap();
- if (params != null)
- {
- if (! (params instanceof DSAParameterSpec))
- throw new InvalidAlgorithmParameterException(
- "Parameters argument is not a non-null instance, or "
- + "sub-instance, of java.security.spec.DSAParameterSpec");
- attributes.put(DSSKeyPairGenerator.DSS_PARAMETERS, params);
- }
- if (random != null)
- attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
-
- attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- Integer.valueOf(Registry.ASN1_ENCODING_ID));
- try
- {
- adaptee.setup(attributes);
- }
- catch (IllegalArgumentException x)
- {
- throw new InvalidAlgorithmParameterException(x.getMessage(), x);
- }
- }
-
- public void initialize(DSAParams params, SecureRandom random)
- throws InvalidParameterException
- {
- if (params == null || !(params instanceof DSAParameterSpec))
- throw new InvalidParameterException(
- "Parameters argument is either null or is not an instance, or "
- + "sub-instance, of java.security.spec.DSAParameterSpec");
- DSAParameterSpec spec = (DSAParameterSpec) params;
- try
- {
- this.initialize((AlgorithmParameterSpec) spec, random);
- }
- catch (InvalidAlgorithmParameterException x)
- {
- InvalidParameterException y = new InvalidParameterException(x.getMessage());
- y.initCause(x);
- throw y;
- }
- }
-
- public void initialize(int modlen, boolean genParams, SecureRandom random)
- throws InvalidParameterException
- {
- HashMap attributes = new HashMap();
- attributes.put(DSSKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(modlen));
- if (random != null)
- attributes.put(DSSKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
-
- attributes.put(DSSKeyPairGenerator.USE_DEFAULTS,
- Boolean.valueOf(! genParams));
- attributes.put(DSSKeyPairGenerator.STRICT_DEFAULTS, Boolean.TRUE);
- attributes.put(DSSKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- Integer.valueOf(Registry.ASN1_ENCODING_ID));
- try
- {
- adaptee.setup(attributes);
- }
- catch (IllegalArgumentException x)
- {
- InvalidParameterException y = new InvalidParameterException(x.getMessage());
- y.initCause(x);
- throw y;
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParameters.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParameters.java
deleted file mode 100644
index eaccb009..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParameters.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/* DSSParameters.java -- DSS parameters DAO
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.der.DERWriter;
-import gnu.java.security.util.DerUtil;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.AlgorithmParametersSpi;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.DSAParameterSpec;
-import java.security.spec.InvalidParameterSpecException;
-import java.util.ArrayList;
-
-/**
- * A JCE-specific Data Access Object (DAO) for DSS parameters.
- */
-public class DSSParameters
- extends AlgorithmParametersSpi
-{
- /**
- * A prime modulus, where 2L-1 < p < 2L
- * for 512 <= L <= 1024
and L
a multiple of
- * 64
.
- */
- private BigInteger p;
-
- /**
- * A prime divisor of p - 1
, where 2159 < q
- * < 2160
.
- */
- private BigInteger q;
-
- /**
- * g = h(p-1)/q mod p
, where h
is any
- * integer with 1 < h < p - 1
such that h
- * (p-1)/q mod p > 1
(g
has order q mod p
- *
).
- */
- private BigInteger g;
-
- // default 0-arguments constructor
-
- protected void engineInit(AlgorithmParameterSpec spec)
- throws InvalidParameterSpecException
- {
- if (! (spec instanceof DSAParameterSpec))
- throw new InvalidParameterSpecException("Wrong AlgorithmParameterSpec type: "
- + spec.getClass().getName());
- DSAParameterSpec dsaSpec = (DSAParameterSpec) spec;
- p = dsaSpec.getP();
- q = dsaSpec.getQ();
- g = dsaSpec.getG();
- }
-
- /**
- * Decodes the set of DSS parameters as per RFC-2459; i.e. the DER-encoded
- * form of the following ASN.1 construct:
- *
- *
- * DssParams ::= SEQUENCE { - * p INTEGER, - * q INTEGER, - * g INTEGER - * } - *- */ - protected void engineInit(byte[] params) throws IOException - { - DERReader der = new DERReader(params); - - DERValue derParams = der.read(); - DerUtil.checkIsConstructed(derParams, "Wrong DSS Parameters field"); - - DERValue val = der.read(); - DerUtil.checkIsBigInteger(val, "Wrong P field"); - p = (BigInteger) val.getValue(); - val = der.read(); - DerUtil.checkIsBigInteger(val, "Wrong Q field"); - q = (BigInteger) val.getValue(); - val = der.read(); - DerUtil.checkIsBigInteger(val, "Wrong G field"); - g = (BigInteger) val.getValue(); - } - - protected void engineInit(byte[] params, String format) throws IOException - { - if (format != null) - { - format = format.trim(); - if (format.length() == 0) - throw new IOException("Format MUST NOT be an empty string"); - - if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME)) - throw new IOException("Unknown or unsupported format: " + format); - } - engineInit(params); - } - - protected AlgorithmParameterSpec engineGetParameterSpec(Class paramSpec) - throws InvalidParameterSpecException - { - if (! paramSpec.isAssignableFrom(DSAParameterSpec.class)) - throw new InvalidParameterSpecException("Wrong AlgorithmParameterSpec type: " - + paramSpec.getName()); - return new DSAParameterSpec(p, q, g); - } - - /** - * Encodes the set of DSS parameters as per RFC-2459; i.e. as the DER-encoded - * form of the following ASN.1 construct: - * - *
- * DssParams ::= SEQUENCE { - * p INTEGER, - * q INTEGER, - * g INTEGER - * } - *- */ - protected byte[] engineGetEncoded() throws IOException - { - DERValue derP = new DERValue(DER.INTEGER, p); - DERValue derQ = new DERValue(DER.INTEGER, q); - DERValue derG = new DERValue(DER.INTEGER, g); - - ArrayList params = new ArrayList(3); - params.add(derP); - params.add(derQ); - params.add(derG); - DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - DERWriter.write(baos, derParams); - byte[] result = baos.toByteArray(); - - return result; - } - - protected byte[] engineGetEncoded(String format) throws IOException - { - if (format != null) - { - format = format.trim(); - if (format.length() == 0) - throw new IOException("Format MUST NOT be an empty string"); - - if (! format.equalsIgnoreCase(Registry.ASN1_ENCODING_SHORT_NAME)) - throw new IOException("Unknown or unsupported format: " + format); - } - return engineGetEncoded(); - } - - protected String engineToString() - { - StringBuffer sb = new StringBuffer("p="); - if (p == null) - sb.append("???"); - else - sb.append("0x").append(p.toString(16)); - - sb.append(", q="); - if (q == null) - sb.append("???"); - else - sb.append("0x").append(q.toString(16)); - - sb.append(", g="); - if (g == null) - sb.append("???"); - else - sb.append("0x").append(g.toString(16)); - - return sb.toString(); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParametersGenerator.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParametersGenerator.java deleted file mode 100644 index 09c13861..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSParametersGenerator.java +++ /dev/null @@ -1,125 +0,0 @@ -/* DSSParametersGenerator.java -- JCE Adapter for a generator of DSS parameters - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security.jce.sig; - -import gnu.java.security.Registry; -import gnu.java.security.key.dss.DSSKeyPairGenerator; -import gnu.java.security.key.dss.FIPS186; -import gnu.java.security.provider.Gnu; - -import java.math.BigInteger; -import java.security.AlgorithmParameterGeneratorSpi; -import java.security.AlgorithmParameters; -import java.security.InvalidAlgorithmParameterException; -import java.security.InvalidParameterException; -import java.security.NoSuchAlgorithmException; -import java.security.Provider; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; -import java.security.spec.DSAParameterSpec; -import java.security.spec.InvalidParameterSpecException; - -/** - * A JCE Adapter for a generator of DSS parameters. - */ -public class DSSParametersGenerator - extends AlgorithmParameterGeneratorSpi -{ - private static final Provider GNU = new Gnu(); - - /** Size of the public modulus in bits. */ - private int modulusLength = -1; - - /** User specified source of randomness. */ - private SecureRandom rnd; - - /** Our concrete DSS parameters generator. */ - private FIPS186 fips; - - // default 0-arguments constructor - - protected void engineInit(int size, SecureRandom random) - { - if ((size % 64) != 0 || size < 512 || size > 1024) - throw new InvalidParameterException("Modulus size/length (in bits) MUST " - + "be a multiple of 64, greater than " - + "or equal to 512, and less than or " - + "equal to 1024"); - this.modulusLength = size; - this.rnd = random; - } - - protected void engineInit(AlgorithmParameterSpec spec, SecureRandom random) - throws InvalidAlgorithmParameterException - { - if (! (spec instanceof DSAParameterSpec)) - throw new InvalidAlgorithmParameterException("Wrong AlgorithmParameterSpec type: " - + spec.getClass().getName()); - DSAParameterSpec dsaSpec = (DSAParameterSpec) spec; - BigInteger p = dsaSpec.getP(); - int size = p.bitLength(); - this.engineInit(size, random); - } - - protected AlgorithmParameters engineGenerateParameters() - { - if (modulusLength < 1) - modulusLength = DSSKeyPairGenerator.DEFAULT_MODULUS_LENGTH; - - fips = new FIPS186(modulusLength, rnd); - BigInteger[] params = fips.generateParameters(); - BigInteger p = params[3]; - BigInteger q = params[2]; - BigInteger g = params[5]; - DSAParameterSpec spec = new DSAParameterSpec(p, q, g); - AlgorithmParameters result = null; - try - { - result = AlgorithmParameters.getInstance(Registry.DSS_KPG, GNU); - result.init(spec); - } - catch (NoSuchAlgorithmException ignore) - { - } - catch (InvalidParameterSpecException ignore) - { - } - return result; - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSRawSignatureSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSRawSignatureSpi.java deleted file mode 100644 index 9b20c03b..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/DSSRawSignatureSpi.java +++ /dev/null @@ -1,56 +0,0 @@ -/* DSSRawSignatureSpi.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.sig; - -import gnu.java.security.Registry; -import gnu.java.security.sig.dss.DSSSignatureRawCodec; - -/** - * The implementation of Service Provider Interface (SPI) - * adapter for the DSS (Digital Signature Standard) signature scheme, encoded - * and/or decoded in RAW format. - */ -public class DSSRawSignatureSpi - extends SignatureAdapter -{ - public DSSRawSignatureSpi() - { - super(Registry.DSS_SIG, new DSSSignatureRawCodec()); - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/EncodedKeyFactory.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/EncodedKeyFactory.java deleted file mode 100644 index 19ec088c..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/EncodedKeyFactory.java +++ /dev/null @@ -1,430 +0,0 @@ -/* EncodedKeyFactory.java -- JCE Encoded key factory Adapter - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security.jce.sig; - -import gnu.java.security.Configuration; -import gnu.java.security.Registry; -import gnu.java.security.key.dss.DSSPrivateKey; -import gnu.java.security.key.dss.DSSPublicKey; -import gnu.java.security.key.rsa.GnuRSAPrivateKey; -import gnu.java.security.key.rsa.GnuRSAPublicKey; - -import java.lang.reflect.Constructor; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.math.BigInteger; -import java.security.InvalidKeyException; -import java.security.InvalidParameterException; -import java.security.Key; -import java.security.KeyFactorySpi; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.security.spec.DSAPrivateKeySpec; -import java.security.spec.DSAPublicKeySpec; -import java.security.spec.InvalidKeySpecException; -import java.security.spec.KeySpec; -import java.security.spec.PKCS8EncodedKeySpec; -import java.security.spec.RSAPrivateCrtKeySpec; -import java.security.spec.RSAPublicKeySpec; -import java.security.spec.X509EncodedKeySpec; -import java.util.logging.Level; -import java.util.logging.Logger; - -import javax.crypto.interfaces.DHPrivateKey; -import javax.crypto.interfaces.DHPublicKey; -import javax.crypto.spec.DHPrivateKeySpec; -import javax.crypto.spec.DHPublicKeySpec; - -/** - * A factory for keys encoded in either the X.509 format (for public keys) or - * the PKCS#8 format (for private keys). - */ -public class EncodedKeyFactory - extends KeyFactorySpi -{ - private static final Logger log = Logger.getLogger(EncodedKeyFactory.class.getName()); - - private static Object invokeConstructor(String className, Object[] params) - throws InvalidKeySpecException - { - Class clazz = getConcreteClass(className); - try - { - Constructor ctor = getConcreteCtor(clazz); - Object result = ctor.newInstance(params); - return result; - } - catch (InstantiationException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - catch (IllegalAccessException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - catch (InvocationTargetException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - - private static Class getConcreteClass(String className) - throws InvalidKeySpecException - { - try - { - Class result = Class.forName(className); - return result; - } - catch (ClassNotFoundException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - - private static Constructor getConcreteCtor(Class clazz) - throws InvalidKeySpecException - { - try - { - Constructor result = clazz.getConstructor(new Class[] {int.class, - BigInteger.class, - BigInteger.class, - BigInteger.class, - BigInteger.class}); - return result; - } - catch (NoSuchMethodException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - - private static Object invokeValueOf(String className, byte[] encoded) - throws InvalidKeySpecException - { - Class clazz = getConcreteClass(className); - try - { - Method valueOf = getValueOfMethod(clazz); - Object result = valueOf.invoke(null, new Object[] { encoded }); - return result; - } - catch (IllegalAccessException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - catch (InvocationTargetException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - - private static Method getValueOfMethod(Class clazz) - throws InvalidKeySpecException - { - try - { - Method result = clazz.getMethod("valueOf", new Class[] {byte[].class}); - return result; - } - catch (NoSuchMethodException x) - { - throw new InvalidKeySpecException(x.getMessage(), x); - } - } - - protected PublicKey engineGeneratePublic(KeySpec keySpec) - throws InvalidKeySpecException - { - if (Configuration.DEBUG) - log.entering(this.getClass().getName(), "engineGeneratePublic()", keySpec); - PublicKey result = null; - if (keySpec instanceof DSAPublicKeySpec) - result = decodeDSSPublicKey((DSAPublicKeySpec) keySpec); - else if (keySpec instanceof RSAPublicKeySpec) - result = decodeRSAPublicKey((RSAPublicKeySpec) keySpec); - else if (keySpec instanceof DHPublicKeySpec) - result = decodeDHPublicKey((DHPublicKeySpec) keySpec); - else - { - if (! (keySpec instanceof X509EncodedKeySpec)) - throw new InvalidKeySpecException("Unsupported key specification"); - - byte[] input = ((X509EncodedKeySpec) keySpec).getEncoded(); - boolean ok = false; - // try DSS - try - { - result = DSSPublicKey.valueOf(input); - ok = true; - } - catch (InvalidParameterException ignored) - { - if (Configuration.DEBUG) - log.log(Level.FINE, "Exception in DSSPublicKey.valueOf(). Ignore", - ignored); - } - if (! ok) // try RSA - try - { - result = GnuRSAPublicKey.valueOf(input); - ok = true; - } - catch (InvalidParameterException ignored) - { - if (Configuration.DEBUG) - log.log(Level.FINE, - "Exception in GnuRSAPublicKey.valueOf(). Ignore", - ignored); - } - if (! ok) // try DH - result = decodeDHPublicKey(input); - } - if (Configuration.DEBUG) - log.exiting(this.getClass().getName(), "engineGeneratePublic()", result); - return result; - } - - protected PrivateKey engineGeneratePrivate(KeySpec keySpec) - throws InvalidKeySpecException - { - if (Configuration.DEBUG) - log.entering(this.getClass().getName(), "engineGeneratePrivate()", keySpec); - PrivateKey result = null; - if (keySpec instanceof DSAPrivateKeySpec) - result = decodeDSSPrivateKey((DSAPrivateKeySpec) keySpec); - else if (keySpec instanceof RSAPrivateCrtKeySpec) - result = decodeRSAPrivateKey((RSAPrivateCrtKeySpec) keySpec); - else if (keySpec instanceof DHPrivateKeySpec) - result = decodeDHPrivateKey((DHPrivateKeySpec) keySpec); - else - { - if (! (keySpec instanceof PKCS8EncodedKeySpec)) - throw new InvalidKeySpecException("Unsupported key specification"); - - byte[] input = ((PKCS8EncodedKeySpec) keySpec).getEncoded(); - boolean ok = false; - // try DSS - try - { - result = DSSPrivateKey.valueOf(input); - ok = true; - } - catch (InvalidParameterException ignored) - { - if (Configuration.DEBUG) - log.log(Level.FINE, "Exception in DSSPrivateKey.valueOf(). Ignore", - ignored); - } - if (! ok) // try RSA - try - { - result = GnuRSAPrivateKey.valueOf(input); - ok = true; - } - catch (InvalidParameterException ignored) - { - if (Configuration.DEBUG) - log.log(Level.FINE, - "Exception in GnuRSAPrivateKey.valueOf(). Ignore", - ignored); - } - if (! ok) // try DH - result = decodeDHPrivateKey(input); - } - if (Configuration.DEBUG) - log.exiting(this.getClass().getName(), "engineGeneratePrivate()", result); - return result; - } - - protected KeySpec engineGetKeySpec(Key key, Class keySpec) - throws InvalidKeySpecException - { - if (key instanceof PublicKey - && Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()) - && keySpec.isAssignableFrom(X509EncodedKeySpec.class)) - return new X509EncodedKeySpec(key.getEncoded()); - - if (key instanceof PrivateKey - && Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()) - && keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class)) - return new PKCS8EncodedKeySpec(key.getEncoded()); - - throw new InvalidKeySpecException("Unsupported format or invalid key spec class"); - } - - protected Key engineTranslateKey(Key key) throws InvalidKeyException - { - throw new InvalidKeyException("Key translation not supported"); - } - - /** - * @param spec an instance of {@link DSAPublicKeySpec} to decode. - * @return an instance of {@link DSSPublicKey} constructed from the - * information in the designated key-specification. - */ - private DSSPublicKey decodeDSSPublicKey(DSAPublicKeySpec spec) - { - BigInteger p = spec.getP(); - BigInteger q = spec.getQ(); - BigInteger g = spec.getG(); - BigInteger y = spec.getY(); - return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y); - } - - /** - * @param spec an instance of {@link RSAPublicKeySpec} to decode. - * @return an instance of {@link GnuRSAPublicKey} constructed from the - * information in the designated key-specification. - */ - private GnuRSAPublicKey decodeRSAPublicKey(RSAPublicKeySpec spec) - { - BigInteger n = spec.getModulus(); - BigInteger e = spec.getPublicExponent(); - return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e); - } - - /** - * @param spec an instance of {@link DHPublicKeySpec} to decode. - * @return an instance of a {@link DHPublicKey} constructed from the - * information in the designated key-specification. - * @throws InvalidKeySpecException if no concrete implementation of the - * {@link DHPublicKey} interface exists at run-time, or if an - * exception occurs during its instantiation. - */ - private DHPublicKey decodeDHPublicKey(DHPublicKeySpec spec) - throws InvalidKeySpecException - { - BigInteger p = spec.getP(); - BigInteger g = spec.getG(); - BigInteger y = spec.getY(); - Object[] params = new Object[] {Integer.valueOf(Registry.X509_ENCODING_ID), - null, p, g, y}; - Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPublicKey", - params); - return (DHPublicKey) obj; - } - - /** - * @param encoded the bytes to decode. - * @return an instance of a {@link DHPublicKey} constructed from the - * information in the designated key-specification. - * @throws InvalidKeySpecException if no concrete implementation of the - * {@link DHPublicKey} interface exists at run-time, or if an - * exception occurs during its instantiation. - */ - private DHPublicKey decodeDHPublicKey(byte[] encoded) - throws InvalidKeySpecException - { - Object obj = invokeValueOf("gnu.javax.crypto.key.dh.GnuDHPublicKey", - encoded); - return (DHPublicKey) obj; - } - - /** - * @param spec an instance of {@link DSAPrivateKeySpec} to decode. - * @return an instance of {@link DSSPrivateKey} constructed from the - * information in the designated key-specification. - */ - private PrivateKey decodeDSSPrivateKey(DSAPrivateKeySpec spec) - { - BigInteger p = spec.getP(); - BigInteger q = spec.getQ(); - BigInteger g = spec.getG(); - BigInteger x = spec.getX(); - return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x); - } - - /** - * @param spec an instance of {@link RSAPrivateCrtKeySpec} to decode. - * @return an instance of {@link GnuRSAPrivateKey} constructed from the - * information in the designated key-specification. - */ - private PrivateKey decodeRSAPrivateKey(RSAPrivateCrtKeySpec spec) - { - BigInteger n = spec.getModulus(); - BigInteger e = spec.getPublicExponent(); - BigInteger d = spec.getPrivateExponent(); - BigInteger p = spec.getPrimeP(); - BigInteger q = spec.getPrimeQ(); - BigInteger dP = spec.getPrimeExponentP(); - BigInteger dQ = spec.getPrimeExponentQ(); - BigInteger qInv = spec.getCrtCoefficient(); - return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID, - n, e, d, p, q, dP, dQ, qInv); - } - - /** - * @param spec an instance of {@link DHPrivateKeySpec} to decode. - * @return an instance of a {@link DHPrivateKey} constructed from the - * information in the designated key-specification. - * @throws InvalidKeySpecException if no concrete implementation of the - * {@link DHPrivateKey} interface exists at run-time, or if an - * exception occurs during its instantiation. - */ - private DHPrivateKey decodeDHPrivateKey(DHPrivateKeySpec spec) - throws InvalidKeySpecException - { - BigInteger p = spec.getP(); - BigInteger g = spec.getG(); - BigInteger x = spec.getX(); - Object[] params = new Object[] {Integer.valueOf(Registry.PKCS8_ENCODING_ID), - null, p, g, x}; - Object obj = invokeConstructor("gnu.javax.crypto.key.dh.GnuDHPrivateKey", - params); - return (DHPrivateKey) obj; - } - - /** - * @param encoded the bytes to decode. - * @return an instance of a {@link DHPrivateKey} constructed from the - * information in the designated key-specification. - * @throws InvalidKeySpecException if no concrete implementation of the - * {@link DHPrivateKey} interface exists at run-time, or if an - * exception occurs during its instantiation. - */ - private DHPrivateKey decodeDHPrivateKey(byte[] encoded) - throws InvalidKeySpecException - { - Object obj = invokeValueOf("gnu.javax.crypto.key.dh.GnuDHPrivateKey", - encoded); - return (DHPrivateKey) obj; - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java deleted file mode 100644 index bcbbe477..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/KeyPairGeneratorAdapter.java +++ /dev/null @@ -1,95 +0,0 @@ -/* KeyPairGeneratorAdapter.java -- - Copyright 2001, 2002, 2006 Free Software Foundation, Inc. - -This file is a 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 of the License, 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; if not, write to the Free Software -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 -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 gnu.java.security.jce.sig; - -import gnu.java.security.key.IKeyPairGenerator; -import gnu.java.security.key.KeyPairGeneratorFactory; - -import java.security.InvalidAlgorithmParameterException; -import java.security.KeyPair; -import java.security.KeyPairGenerator; -import java.security.SecureRandom; -import java.security.spec.AlgorithmParameterSpec; - -/** - * The implementation of a generic {@link java.security.KeyPairGenerator} - * adapter class to wrap GNU keypair generator instances. - *
- * This class defines the Service Provider Interface (SPI) for - * the {@link java.security.KeyPairGenerator} class, which is used to generate - * pairs of public and private keys. - *
- * All the abstract methods in the {@link java.security.KeyPairGeneratorSpi} - * class are implemented by this class and all its sub-classes. - *
- * In case the client does not explicitly initialize the KeyPairGenerator (via a
- * call to an initialize()
method), the GNU provider supplies
- * (and document) default values to be used. For example, the GNU provider uses
- * a default modulus size (keysize) of 1024 bits for the DSS (Digital
- * Signature Standard) a.k.a DSA.
- */
-public abstract class KeyPairGeneratorAdapter
- extends KeyPairGenerator
-{
- /** Our underlying keypair instance. */
- protected IKeyPairGenerator adaptee;
-
- /**
- * Trivial protected constructor.
- *
- * @param kpgName the canonical name of the keypair generator algorithm.
- */
- protected KeyPairGeneratorAdapter(String kpgName)
- {
- super(kpgName);
-
- this.adaptee = KeyPairGeneratorFactory.getInstance(kpgName);
- }
-
- public abstract void initialize(int keysize, SecureRandom random);
-
- public abstract void initialize(AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException;
-
- public KeyPair generateKeyPair()
- {
- return adaptee.generate();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD2withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD2withRSA.java
deleted file mode 100644
index 353be218..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD2withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* MD2WithRSA.java -- RSA PKCS1 with MD2 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with MD2 hash and X.509
- * encoding format.
- */
-public class MD2withRSA
- extends SignatureAdapter
-{
- public MD2withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.MD2_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD5withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD5withRSA.java
deleted file mode 100644
index 42c481b0..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/MD5withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* MD5withRSA.java -- RSA PKCS1 with MD5 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with MD5 hash and X.509
- * encoding format.
- */
-public class MD5withRSA
- extends SignatureAdapter
-{
- public MD5withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.MD5_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyFactory.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyFactory.java
deleted file mode 100644
index 3ba49edc..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyFactory.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/* RSAKeyFactory.java -- RSA key-factory JCE Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.rsa.GnuRSAPrivateKey;
-import gnu.java.security.key.rsa.GnuRSAPublicKey;
-import gnu.java.security.key.rsa.RSAKeyPairPKCS8Codec;
-import gnu.java.security.key.rsa.RSAKeyPairX509Codec;
-
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.KeyFactorySpi;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPrivateCrtKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.security.spec.RSAPrivateCrtKeySpec;
-import java.security.spec.RSAPrivateKeySpec;
-import java.security.spec.RSAPublicKeySpec;
-import java.security.spec.X509EncodedKeySpec;
-
-public class RSAKeyFactory
- extends KeyFactorySpi
-{
- // implicit 0-arguments constructor
-
- protected PublicKey engineGeneratePublic(KeySpec keySpec)
- throws InvalidKeySpecException
- {
- if (keySpec instanceof RSAPublicKeySpec)
- {
- RSAPublicKeySpec spec = (RSAPublicKeySpec) keySpec;
- BigInteger n = spec.getModulus();
- BigInteger e = spec.getPublicExponent();
- return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
- }
- if (keySpec instanceof X509EncodedKeySpec)
- {
- X509EncodedKeySpec spec = (X509EncodedKeySpec) keySpec;
- byte[] encoded = spec.getEncoded();
- PublicKey result;
- try
- {
- return new RSAKeyPairX509Codec().decodePublicKey(encoded);
- }
- catch (RuntimeException x)
- {
- throw new InvalidKeySpecException(x.getMessage(), x);
- }
- }
- throw new InvalidKeySpecException("Unsupported (public) key specification");
- }
-
- protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
- throws InvalidKeySpecException
- {
- if (keySpec instanceof RSAPrivateCrtKeySpec)
- {
- RSAPrivateCrtKeySpec spec = (RSAPrivateCrtKeySpec) keySpec;
- BigInteger n = spec.getModulus();
- BigInteger e = spec.getPublicExponent();
- BigInteger d = spec.getPrivateExponent();
- BigInteger p = spec.getPrimeP();
- BigInteger q = spec.getPrimeQ();
- BigInteger dP = spec.getPrimeExponentP();
- BigInteger dQ = spec.getPrimeExponentQ();
- BigInteger qInv = spec.getCrtCoefficient();
- return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
- n, e, d, p, q, dP, dQ, qInv);
- }
- if (keySpec instanceof PKCS8EncodedKeySpec)
- {
- PKCS8EncodedKeySpec spec = (PKCS8EncodedKeySpec) keySpec;
- byte[] encoded = spec.getEncoded();
- PrivateKey result;
- try
- {
- return new RSAKeyPairPKCS8Codec().decodePrivateKey(encoded);
- }
- catch (RuntimeException x)
- {
- throw new InvalidKeySpecException(x.getMessage(), x);
- }
- }
- throw new InvalidKeySpecException("Unsupported (private) key specification");
- }
-
- protected KeySpec engineGetKeySpec(Key key, Class keySpec)
- throws InvalidKeySpecException
- {
- if (key instanceof RSAPublicKey)
- {
- if (keySpec.isAssignableFrom(RSAPublicKeySpec.class))
- {
- RSAPublicKey rsaKey = (RSAPublicKey) key;
- BigInteger n = rsaKey.getModulus();
- BigInteger e = rsaKey.getPublicExponent();
- return new RSAPublicKeySpec(n, e);
- }
- if (keySpec.isAssignableFrom(X509EncodedKeySpec.class))
- {
- if (key instanceof GnuRSAPublicKey)
- {
- GnuRSAPublicKey rsaKey = (GnuRSAPublicKey) key;
- byte[] encoded = rsaKey.getEncoded(Registry.X509_ENCODING_ID);
- return new X509EncodedKeySpec(encoded);
- }
-
- if (Registry.X509_ENCODING_SORT_NAME.equalsIgnoreCase(key.getFormat()))
- {
- byte[] encoded = key.getEncoded();
- return new X509EncodedKeySpec(encoded);
- }
- throw new InvalidKeySpecException(
- "Wrong key type or unsupported (public) key specification");
- }
- throw new InvalidKeySpecException("Unsupported (public) key specification");
- }
- if ((key instanceof RSAPrivateCrtKey)
- && keySpec.isAssignableFrom(RSAPrivateCrtKeySpec.class))
- {
- RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
- BigInteger n = rsaKey.getModulus();
- BigInteger e = rsaKey.getPublicExponent();
- BigInteger d = rsaKey.getPrivateExponent();
- BigInteger p = rsaKey.getPrimeP();
- BigInteger q = rsaKey.getPrimeQ();
- BigInteger dP = rsaKey.getPrimeExponentP();
- BigInteger dQ = rsaKey.getPrimeExponentQ();
- BigInteger qInv = rsaKey.getCrtCoefficient();
- return new RSAPrivateCrtKeySpec(n, e, d, p, q, dP, dQ, qInv);
- }
- if ((key instanceof RSAPrivateKey)
- && keySpec.isAssignableFrom(RSAPrivateKeySpec.class))
- {
- RSAPrivateKey rsaKey = (RSAPrivateKey) key;
- BigInteger n = rsaKey.getModulus();
- BigInteger d = rsaKey.getPrivateExponent();
- return new RSAPrivateKeySpec(n, d);
- }
- if (keySpec.isAssignableFrom(PKCS8EncodedKeySpec.class))
- {
- if (key instanceof GnuRSAPrivateKey)
- {
- GnuRSAPrivateKey rsaKey = (GnuRSAPrivateKey) key;
- byte[] encoded = rsaKey.getEncoded(Registry.PKCS8_ENCODING_ID);
- return new PKCS8EncodedKeySpec(encoded);
- }
- if (Registry.PKCS8_ENCODING_SHORT_NAME.equalsIgnoreCase(key.getFormat()))
- {
- byte[] encoded = key.getEncoded();
- return new PKCS8EncodedKeySpec(encoded);
- }
- throw new InvalidKeySpecException(
- "Wrong key type or unsupported (private) key specification");
- }
- throw new InvalidKeySpecException(
- "Wrong key type or unsupported key specification");
- }
-
- protected Key engineTranslateKey(Key key) throws InvalidKeyException
- {
- if ((key instanceof GnuRSAPublicKey) || (key instanceof GnuRSAPrivateKey))
- return key;
-
- if (key instanceof RSAPublicKey)
- {
- RSAPublicKey rsaKey = (RSAPublicKey) key;
- BigInteger n = rsaKey.getModulus();
- BigInteger e = rsaKey.getPublicExponent();
- return new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
- }
- if (key instanceof RSAPrivateCrtKey)
- {
- RSAPrivateCrtKey rsaKey = (RSAPrivateCrtKey) key;
- BigInteger n = rsaKey.getModulus();
- BigInteger e = rsaKey.getPublicExponent();
- BigInteger d = rsaKey.getPrivateExponent();
- BigInteger p = rsaKey.getPrimeP();
- BigInteger q = rsaKey.getPrimeQ();
- BigInteger dP = rsaKey.getPrimeExponentP();
- BigInteger dQ = rsaKey.getPrimeExponentQ();
- BigInteger qInv = rsaKey.getCrtCoefficient();
- return new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
- n, e, d, p, q, dP, dQ, qInv);
- }
- throw new InvalidKeyException("Unsupported key type");
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java
deleted file mode 100644
index ef53b811..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAKeyPairGeneratorSpi.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/* RSAKeyPairGeneratorSpi.java -- JCE RSA KeyPairGenerator Adapter
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.rsa.RSAKeyPairGenerator;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-import java.security.spec.RSAKeyGenParameterSpec;
-import java.util.HashMap;
-
-/**
- * The implementation of a {@link java.security.KeyPairGenerator} adapter class
- * to wrap GNU RSA keypair generator instances.
- *
- * In case the client does not explicitly initialize the KeyPairGenerator (via a
- * call to an initialize()
method), the GNU provider uses a
- * default modulus size (keysize) of 1024 bits.
- */
-public class RSAKeyPairGeneratorSpi
- extends KeyPairGeneratorAdapter
-{
- public RSAKeyPairGeneratorSpi()
- {
- super(Registry.RSA_KPG);
- }
-
- public void initialize(int keysize, SecureRandom random)
- {
- HashMap attributes = new HashMap();
- attributes.put(RSAKeyPairGenerator.MODULUS_LENGTH, Integer.valueOf(keysize));
- if (random != null)
- attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
-
- attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- Integer.valueOf(Registry.ASN1_ENCODING_ID));
- adaptee.setup(attributes);
- }
-
- public void initialize(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException
- {
- HashMap attributes = new HashMap();
- if (params != null)
- {
- if (! (params instanceof RSAKeyGenParameterSpec))
- throw new InvalidAlgorithmParameterException("params");
-
- attributes.put(RSAKeyPairGenerator.RSA_PARAMETERS, params);
- }
- if (random != null)
- attributes.put(RSAKeyPairGenerator.SOURCE_OF_RANDOMNESS, random);
-
- attributes.put(RSAKeyPairGenerator.PREFERRED_ENCODING_FORMAT,
- Integer.valueOf(Registry.ASN1_ENCODING_ID));
- adaptee.setup(attributes);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java
deleted file mode 100644
index f1ccbde4..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/RSAPSSRawSignatureSpi.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* RSAPSSRawSignatureSpi.java --
- Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPSSSignatureRawCodec;
-
-/**
- * The implementation of Service Provider Interface (SPI)
- * adapter for the RSA-PSS signature scheme, encoded and/or decoded in RAW
- * format.
- */
-public class RSAPSSRawSignatureSpi
- extends SignatureAdapter
-{
- public RSAPSSRawSignatureSpi()
- {
- super(Registry.RSA_PSS_SIG, new RSAPSSSignatureRawCodec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withDSS.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withDSS.java
deleted file mode 100644
index c55139f4..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withDSS.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/* SHA160withDSS.java -- JCE Adapter for DSS with SHA1 signatures
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.dss.DSSSignatureX509Codec;
-
-/**
- * A JCE Adapter for providing X.509 formatted DSS with SHA1 signatures.
- */
-public class SHA160withDSS
- extends SignatureAdapter
-{
- public SHA160withDSS()
- {
- super(Registry.DSS_SIG, new DSSSignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withRSA.java
deleted file mode 100644
index d3b2054e..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA160withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* SHA160withRSA.java -- RSA PKCS1 with SHA160 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with SHA160 hash and X.509
- * encoding format.
- */
-public class SHA160withRSA
- extends SignatureAdapter
-{
- public SHA160withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA160_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA256withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA256withRSA.java
deleted file mode 100644
index d21888b5..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA256withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* SHA256withRSA.java -- RSA PKCS1 with SHA256 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with SHA256 hash and X.509
- * encoding format.
- */
-public class SHA256withRSA
- extends SignatureAdapter
-{
- public SHA256withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA256_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA384withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA384withRSA.java
deleted file mode 100644
index 5495ec1c..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA384withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* SHA384withRSA.java -- RSA PKCS1 with SHA384 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with SHA384 hash and X.509
- * encoding format.
- */
-public class SHA384withRSA
- extends SignatureAdapter
-{
- public SHA384withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA384_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA512withRSA.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA512withRSA.java
deleted file mode 100644
index f7632290..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SHA512withRSA.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/* SHA512withRSA.java -- RSA PKCS1 with SHA512 JCE signature Adapter
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-
-/**
- * A JCE Adapter for the RSA PKCS1 (v1.5) signature with SHA512 hash and X.509
- * encoding format.
- */
-public class SHA512withRSA
- extends SignatureAdapter
-{
- public SHA512withRSA()
- {
- super(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA512_HASH,
- new RSAPKCS1V1_5SignatureX509Codec());
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SignatureAdapter.java b/openjdk/icedtea/jce/gnu/java/security/jce/sig/SignatureAdapter.java
deleted file mode 100644
index a65d727e..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/jce/sig/SignatureAdapter.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/* SignatureAdapter.java --
- Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.jce.sig;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.sig.BaseSignature;
-import gnu.java.security.sig.ISignature;
-import gnu.java.security.sig.ISignatureCodec;
-import gnu.java.security.sig.SignatureFactory;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.SignatureException;
-import java.security.SignatureSpi;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.HashMap;
-import java.util.logging.Logger;
-
-/**
- * The implementation of a generic {@link java.security.Signature} adapter class
- * to wrap GNU signature instances.
- *
- * This class defines the Service Provider Interface (SPI) for - * the {@link java.security.Signature} class, which provides the functionality - * of a digital signature algorithm. Digital signatures are used for - * authentication and integrity assurance of digital data. - *
- * All the abstract methods in the {@link SignatureSpi} class are implemented by - * this class and all its sub-classes. - *
- * All the implementations which subclass this object, and which are serviced by
- * the GNU provider implement the {@link Cloneable} interface.
- */
-class SignatureAdapter
- extends SignatureSpi
- implements Cloneable
-{
- private static final Logger log = Logger.getLogger(SignatureAdapter.class.getName());
-
- /** Our underlying signature instance. */
- private ISignature adaptee;
-
- /** Our underlying signature encoder/decoder engine. */
- private ISignatureCodec codec;
-
- /**
- * Trivial protected constructor.
- *
- * @param sigName the canonical name of the signature scheme.
- * @param codec the signature codec engine to use with this scheme.
- */
- protected SignatureAdapter(String sigName, ISignatureCodec codec)
- {
- this(SignatureFactory.getInstance(sigName), codec);
- }
-
- /**
- * Private constructor for cloning purposes.
- *
- * @param adaptee a clone of the underlying signature scheme instance.
- * @param codec the signature codec engine to use with this scheme.
- */
- private SignatureAdapter(ISignature adaptee, ISignatureCodec codec)
- {
- super();
-
- this.adaptee = adaptee;
- this.codec = codec;
- }
-
- public Object clone()
- {
- return new SignatureAdapter((ISignature) adaptee.clone(), codec);
- }
-
- public void engineInitVerify(PublicKey publicKey) throws InvalidKeyException
- {
- HashMap attributes = new HashMap();
- attributes.put(BaseSignature.VERIFIER_KEY, publicKey);
- try
- {
- adaptee.setupVerify(attributes);
- }
- catch (IllegalArgumentException x)
- {
- throw new InvalidKeyException(x.getMessage(), x);
- }
- }
-
- public void engineInitSign(PrivateKey privateKey) throws InvalidKeyException
- {
- HashMap attributes = new HashMap();
- attributes.put(BaseSignature.SIGNER_KEY, privateKey);
- try
- {
- adaptee.setupSign(attributes);
- }
- catch (IllegalArgumentException x)
- {
- throw new InvalidKeyException(x.getMessage(), x);
- }
- }
-
- public void engineInitSign(PrivateKey privateKey, SecureRandom random)
- throws InvalidKeyException
- {
- HashMap attributes = new HashMap();
- attributes.put(BaseSignature.SIGNER_KEY, privateKey);
- attributes.put(BaseSignature.SOURCE_OF_RANDOMNESS, random);
- try
- {
- adaptee.setupSign(attributes);
- }
- catch (IllegalArgumentException x)
- {
- throw new InvalidKeyException(x.getMessage(), x);
- }
- }
-
- public void engineUpdate(byte b) throws SignatureException
- {
- try
- {
- adaptee.update(b);
- }
- catch (IllegalStateException x)
- {
- throw new SignatureException(x.getMessage(), x);
- }
- }
-
- public void engineUpdate(byte[] b, int off, int len)
- throws SignatureException
- {
- try
- {
- adaptee.update(b, off, len);
- }
- catch (IllegalStateException x)
- {
- throw new SignatureException(x.getMessage(), x);
- }
- }
-
- public byte[] engineSign() throws SignatureException
- {
- Object signature = null;
- try
- {
- signature = adaptee.sign();
- }
- catch (IllegalStateException x)
- {
- throw new SignatureException(x.getMessage(), x);
- }
- byte[] result = codec.encodeSignature(signature);
- return result;
- }
-
- public int engineSign(byte[] outbuf, int offset, int len)
- throws SignatureException
- {
- byte[] signature = this.engineSign();
- int result = signature.length;
- if (result > len)
- throw new SignatureException("Not enough room to store signature");
-
- System.arraycopy(signature, 0, outbuf, offset, result);
- return result;
- }
-
- public boolean engineVerify(byte[] sigBytes) throws SignatureException
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "engineVerify");
- Object signature = codec.decodeSignature(sigBytes);
- boolean result = false;
- try
- {
- result = adaptee.verify(signature);
- }
- catch (IllegalStateException x)
- {
- throw new SignatureException(x.getMessage(), x);
- }
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "engineVerify",
- Boolean.valueOf(result));
- return result;
- }
-
- // Deprecated. Replaced by engineSetParameter.
- public void engineSetParameter(String param, Object value)
- throws InvalidParameterException
- {
- throw new InvalidParameterException("deprecated");
- }
-
- public void engineSetParameter(AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException
- {
- }
-
- // Deprecated
- public Object engineGetParameter(String param)
- throws InvalidParameterException
- {
- throw new InvalidParameterException("deprecated");
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairCodec.java b/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairCodec.java
deleted file mode 100644
index f09743d2..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairCodec.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/* IKeyPairCodec.java --
- Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key;
-
-import gnu.java.security.Registry;
-
-import java.security.PrivateKey;
-import java.security.PublicKey;
-
-/**
- * The visible methods of an object that knows how to encode and decode
- * cryptographic asymmetric keypairs. Codecs are useful for (a) externalising
- * public and private keys for storage and on-the-wire transmission, as well as
- * (b) re-creating their internal Java representation from external sources.
- */
-public interface IKeyPairCodec
-{
- /** Constant identifying the Raw encoding format. */
- int RAW_FORMAT = Registry.RAW_ENCODING_ID;
-
- /** Constant identifying the X.509 encoding format. */
- int X509_FORMAT = Registry.X509_ENCODING_ID;
-
- /** Constant identifying the PKCS#8 encoding format. */
- int PKCS8_FORMAT = Registry.PKCS8_ENCODING_ID;
-
- /**
- * Constant identifying the ASN.1 encoding format: a combined encoding
- * of X.509 for public keys, and PKCS#8 for private ones.
- */
- int ASN1_FORMAT = Registry.ASN1_ENCODING_ID;
-
- /**
- * Returns the unique identifier (within this library) of the format used to
- * externalise public and private keys.
- *
- * @return the identifier of the format, the object supports.
- */
- int getFormatID();
-
- /**
- * Encodes an instance of a public key for storage or transmission purposes.
- *
- * @param key the non-null key to encode.
- * @return a byte sequence representing the encoding of the designated key
- * according to the format supported by this codec.
- * @exception IllegalArgumentException if the designated key is not supported
- * by this codec.
- */
- byte[] encodePublicKey(PublicKey key);
-
- /**
- * Encodes an instance of a private key for storage or transmission purposes.
- *
- * @param key the non-null key to encode.
- * @return a byte sequence representing the encoding of the designated key
- * according to the format supported by this codec.
- * @exception IllegalArgumentException if the designated key is not supported
- * by this codec.
- */
- byte[] encodePrivateKey(PrivateKey key);
-
- /**
- * Decodes an instance of an external public key into its native Java
- * representation.
- *
- * @param input the source of the externalised key to decode.
- * @return a concrete instance of a public key, reconstructed from the
- * designated input.
- * @exception IllegalArgumentException if the designated input does not
- * contain a known representation of a public key for the format
- * supported by the concrete codec.
- */
- PublicKey decodePublicKey(byte[] input);
-
- /**
- * Decodes an instance of an external private key into its native Java
- * representation.
- *
- * @param input the source of the externalised key to decode.
- * @return a concrete instance of a private key, reconstructed from the
- * designated input.
- * @exception IllegalArgumentException if the designated input does not
- * contain a known representation of a private key for the format
- * supported by the concrete codec.
- */
- PrivateKey decodePrivateKey(byte[] input);
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairGenerator.java b/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairGenerator.java
deleted file mode 100644
index 8d7842e9..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/IKeyPairGenerator.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/* IKeyPairGenerator.java --
- Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key;
-
-import java.security.KeyPair;
-import java.util.Map;
-
-/**
- * The visible methods of every asymmetric keypair generator.
- */
-public interface IKeyPairGenerator
-{
- /**
- * Returns the canonical name of this keypair generator.
- *
- * @return the canonical name of this instance.
- */
- String name();
-
- /**
- * [Re]-initialises this instance for use with a given set of attributes.
- *
- * @param attributes a map of name/value pairs to use for setting up the
- * instance.
- * @exception IllegalArgumentException if at least one of the mandatory
- * attributes is missing or an invalid value was specified.
- */
- void setup(Map attributes);
-
- /**
- * Generates a new keypair based on the attributes used to configure the
- * instance.
- *
- * @return a new keypair.
- */
- KeyPair generate();
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/KeyPairCodecFactory.java b/openjdk/icedtea/jce/gnu/java/security/key/KeyPairCodecFactory.java
deleted file mode 100644
index e68a7d65..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/KeyPairCodecFactory.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/* KeyPairCodecFactory.java --
- Copyright 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.dss.DSSKeyPairPKCS8Codec;
-import gnu.java.security.key.dss.DSSKeyPairRawCodec;
-import gnu.java.security.key.dss.DSSKeyPairX509Codec;
-import gnu.java.security.key.dss.DSSPrivateKey;
-import gnu.java.security.key.dss.DSSPublicKey;
-import gnu.java.security.key.rsa.GnuRSAPrivateKey;
-import gnu.java.security.key.rsa.GnuRSAPublicKey;
-import gnu.java.security.key.rsa.RSAKeyPairPKCS8Codec;
-import gnu.java.security.key.rsa.RSAKeyPairRawCodec;
-import gnu.java.security.key.rsa.RSAKeyPairX509Codec;
-import gnu.java.security.util.FormatUtil;
-
-import java.lang.reflect.Constructor;
-import java.security.Key;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A Factory class to instantiate key encoder/decoder instances.
- */
-public class KeyPairCodecFactory
-{
- private static Set names;
-
- /** Trivial constructor to enforce Singleton pattern. */
- private KeyPairCodecFactory()
- {
- super();
- }
-
- /**
- * Returns the appropriate codec given a composed key-pair generator algorithm
- * and an encoding format. A composed name is formed by the concatenation of
- * the canonical key-pair algorithm name, the forward slash character
- * /
and the canonical name of the encoding format.
- *
- * IMPORTANT: For backward compatibility, when the encoding format
- * name is missing, the Raw encoding format is assumed. When this is the case
- * the trailing forward slash is discarded from the name.
- *
- * @param name the case-insensitive key codec name.
- * @return an instance of the keypair codec, or null
if none
- * found.
- */
- public static IKeyPairCodec getInstance(String name)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- if (name.length() == 0)
- return null;
-
- if (name.startsWith("/"))
- return null;
-
- if (name.endsWith("/"))
- return getInstance(name.substring(0, name.length() - 1),
- Registry.RAW_ENCODING_ID);
-
- int i = name.indexOf("/");
- if (i == -1)
- return getInstance(name, Registry.RAW_ENCODING_ID);
-
- String kpgName = name.substring(0, i);
- String formatName = name.substring(i + 1);
- return getInstance(kpgName, formatName);
- }
-
- /**
- * Returns an instance of a keypair codec given the canonical name of the
- * key-pair algorithm, and the name of the encoding format to use when
- * externalizing the keys.
- *
- * @param name the case-insensitive key-pair algorithm name.
- * @param format the name of the encoding format to use when externalizing the
- * keys generated by the key-pair algorithm.
- * @return an instance of the key-pair codec, or null
if none
- * found.
- */
- public static IKeyPairCodec getInstance(String name, String format)
- {
- int formatID = FormatUtil.getFormatID(format);
- if (formatID == 0)
- return null;
-
- return getInstance(name, formatID);
- }
-
- /**
- * Returns an instance of a keypair codec given the canonical name of the
- * key-pair algorithm, and the identifier of the format to use when
- * externalizing the keys.
- *
- * @param name the case-insensitive key-pair algorithm name.
- * @param formatID the identifier of the format to use when externalizing the
- * keys generated by the key-pair algorithm.
- * @return an instance of the key-pair codec, or null
if none
- * found.
- */
- public static IKeyPairCodec getInstance(String name, int formatID)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- switch (formatID)
- {
- case Registry.RAW_ENCODING_ID:
- return getRawCodec(name);
- case Registry.X509_ENCODING_ID:
- return getX509Codec(name);
- case Registry.PKCS8_ENCODING_ID:
- return getPKCS8Codec(name);
- }
-
- return null;
- }
-
- /**
- * Returns an instance of a keypair codec given a key.
- *
- * @param key the key to encode.
- * @return an instance of the keypair codec, or null
if none
- * found.
- */
- public static IKeyPairCodec getInstance(Key key)
- {
- if (key == null)
- return null;
-
- String format = key.getFormat();
- int formatID = FormatUtil.getFormatID(format);
- if (formatID == 0)
- return null;
-
- switch (formatID)
- {
- case Registry.RAW_ENCODING_ID:
- return getRawCodec(key);
- case Registry.X509_ENCODING_ID:
- return getX509Codec(key);
- case Registry.PKCS8_ENCODING_ID:
- return getPKCS8Codec(key);
- }
-
- return null;
- }
-
- /**
- * Returns a {@link Set} of supported key-pair codec names.
- *
- * @return a {@link Set} of the names of supported key-pair codec (Strings).
- */
- public static synchronized final Set getNames()
- {
- if (names == null)
- {
- HashSet hs = new HashSet();
- hs.add(Registry.DSS_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- hs.add(Registry.DSS_KPG + "/" + Registry.X509_ENCODING_SORT_NAME);
- hs.add(Registry.DSS_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME);
- hs.add(Registry.RSA_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- hs.add(Registry.RSA_KPG + "/" + Registry.X509_ENCODING_SORT_NAME);
- hs.add(Registry.RSA_KPG + "/" + Registry.PKCS8_ENCODING_SHORT_NAME);
- hs.add(Registry.DH_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- hs.add(Registry.SRP_KPG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- names = Collections.unmodifiableSet(hs);
- }
- return names;
- }
-
- private static IKeyPairCodec makeInstance (String clazz)
- {
- try
- {
- Class c = Class.forName (clazz);
- Constructor ctor = c.getConstructor (new Class[0]);
- return (IKeyPairCodec) ctor.newInstance (new Object[0]);
- }
- catch (Exception x)
- {
- IllegalArgumentException iae =
- new IllegalArgumentException ("strong crypto key codec not available: "
- + clazz);
- iae.initCause (x);
- throw iae;
- }
- }
-
- private static boolean matches (Object o, String clazz)
- {
- try
- {
- Class c = Class.forName (clazz);
- return c.isAssignableFrom (o.getClass ());
- }
- catch (Exception x)
- {
- // Can't match.
- return false;
- }
- }
-
- /**
- * @param name the trimmed name of a key-pair algorithm.
- * @return a Raw format codec for the designated key-pair algorithm, or
- * null
if none exists.
- */
- private static IKeyPairCodec getRawCodec(String name)
- {
- IKeyPairCodec result = null;
- if (name.equalsIgnoreCase(Registry.DSA_KPG)
- || name.equals(Registry.DSS_KPG))
- result = new DSSKeyPairRawCodec();
- else if (name.equalsIgnoreCase(Registry.RSA_KPG))
- result = new RSAKeyPairRawCodec();
- else if (name.equalsIgnoreCase(Registry.DH_KPG))
- result = makeInstance("gnu.javax.crypto.key.dh.DHKeyPairRawCodec");
- else if (name.equalsIgnoreCase(Registry.SRP_KPG))
- result = makeInstance("gnu.javax.crypto.key.srp6.SRPKeyPairRawCodec");
-
- return result;
- }
-
- /**
- * @param name the trimmed name of a key-pair algorithm.
- * @return a X.509 format codec for the designated key-pair algorithm, or
- * null
if none exists.
- */
- private static IKeyPairCodec getX509Codec(String name)
- {
- IKeyPairCodec result = null;
- if (name.equalsIgnoreCase(Registry.DSA_KPG)
- || name.equals(Registry.DSS_KPG))
- result = new DSSKeyPairX509Codec();
- else if (name.equalsIgnoreCase(Registry.RSA_KPG))
- result = new RSAKeyPairX509Codec();
- else if (name.equalsIgnoreCase(Registry.DH_KPG))
- result = makeInstance("gnu.javax.crypto.key.dh.DHKeyPairX509Codec");
-
- return result;
- }
-
- /**
- * @param name the trimmed name of a key-pair algorithm.
- * @return a PKCS#8 format codec for the designated key-pair algorithm, or
- * null
if none exists.
- */
- private static IKeyPairCodec getPKCS8Codec(String name)
- {
- IKeyPairCodec result = null;
- if (name.equalsIgnoreCase(Registry.DSA_KPG)
- || name.equals(Registry.DSS_KPG))
- result = new DSSKeyPairPKCS8Codec();
- else if (name.equalsIgnoreCase(Registry.RSA_KPG))
- result = new RSAKeyPairPKCS8Codec();
- else if (name.equalsIgnoreCase(Registry.DH_KPG))
- result = makeInstance("gnu.javax.crypto.key.dh.DHKeyPairPKCS8Codec");
-
- return result;
- }
-
- /**
- * @param key a {@link Key} for which we want to return a Raw codec.
- * @return the Raw codec corresponding to the key, or null
if
- * none exists for this key.
- */
- private static IKeyPairCodec getRawCodec(Key key)
- {
- IKeyPairCodec result = null;
- if ((key instanceof DSSPublicKey) || (key instanceof DSSPrivateKey))
- result = new DSSKeyPairRawCodec();
- else if ((key instanceof GnuRSAPublicKey)
- || (key instanceof GnuRSAPrivateKey))
- result = new RSAKeyPairRawCodec();
- else if (matches(key, "gnu.javax.crypto.key.dh.GnuDHPublicKey")
- || matches(key, "gnu.javax.crypto.key.dh.GnuDHPrivateKey"))
- result = makeInstance("gnu.javax.crypto.key.dh.DHKeyPairRawCodec");
- else if (matches(key, "gnu.javax.crypto.key.srp6.SRPPublicKey")
- || matches(key, "gnu.javax.crypto.key.srp6.SRPPrivateKey"))
- result = makeInstance("gnu.javax.crypto.key.srp6.SRPKeyPairRawCodec");
-
- return result;
- }
-
- /**
- * @param key a {@link Key} for which we want to return an X.509 codec.
- * @return the X.509 codec corresponding to the key, or null
if
- * none exists for this key.
- */
- private static IKeyPairCodec getX509Codec(Key key)
- {
- IKeyPairCodec result = null;
- if (key instanceof DSSPublicKey)
- result = new DSSKeyPairX509Codec();
- else if (key instanceof GnuRSAPublicKey)
- result = new RSAKeyPairX509Codec();
-
- return result;
- }
-
- /**
- * @param key a {@link Key} for which we want to return a PKCS#8 codec.
- * @return the PKCS#8 codec corresponding to the key, or null
if
- * none exists for this key.
- */
- private static IKeyPairCodec getPKCS8Codec(Key key)
- {
- IKeyPairCodec result = null;
- if (key instanceof DSSPrivateKey)
- result = new DSSKeyPairPKCS8Codec();
- else if (key instanceof GnuRSAPrivateKey)
- result = new RSAKeyPairPKCS8Codec();
-
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/KeyPairGeneratorFactory.java b/openjdk/icedtea/jce/gnu/java/security/key/KeyPairGeneratorFactory.java
deleted file mode 100644
index 4872fc3d..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/KeyPairGeneratorFactory.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/* KeyPairGeneratorFactory.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.dss.DSSKeyPairGenerator;
-import gnu.java.security.key.rsa.RSAKeyPairGenerator;
-
-import java.lang.reflect.Constructor;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A Factory to instantiate asymmetric keypair generators.
- */
-public class KeyPairGeneratorFactory
-{
- /** Trivial constructor to enforce Singleton pattern. */
- private KeyPairGeneratorFactory()
- {
- super();
- }
-
- /**
- * Returns an instance of a keypair generator given its name.
- *
- * @param name the case-insensitive key generator name.
- * @return an instance of the keypair generator, or null
if
- * none found.
- */
- public static IKeyPairGenerator getInstance(String name)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- IKeyPairGenerator result = null;
- if (name.equalsIgnoreCase(Registry.DSA_KPG)
- || name.equalsIgnoreCase(Registry.DSS_KPG))
- result = new DSSKeyPairGenerator();
- else if (name.equalsIgnoreCase(Registry.RSA_KPG))
- result = new RSAKeyPairGenerator();
- else if (name.equalsIgnoreCase(Registry.DH_KPG))
- result = makeInstance("gnu.javax.crypto.key.dh.GnuDHKeyPairGenerator");
- else if (name.equalsIgnoreCase(Registry.SRP_KPG))
- result = makeInstance("gnu.javax.crypto.key.srp6.SRPKeyPairGenerator");
-
- return result;
- }
-
- /**
- * Returns a {@link Set} of keypair generator names supported by this
- * Factory. Those keypair generators may be used in conjunction with
- * the digital signature schemes with appendix supported by this library.
- *
- * @return a {@link Set} of keypair generator names (Strings).
- */
- public static final Set getNames()
- {
- HashSet hs = new HashSet();
- hs.add(Registry.DSS_KPG);
- hs.add(Registry.DSA_KPG);
- hs.add(Registry.RSA_KPG);
- hs.add(Registry.DH_KPG);
- hs.add(Registry.SRP_KPG);
- return Collections.unmodifiableSet(hs);
- }
-
- private static IKeyPairGenerator makeInstance(String clazz)
- {
- try
- {
- Class c = Class.forName(clazz);
- Constructor ctor = c.getConstructor(new Class[0]);
- return (IKeyPairGenerator) ctor.newInstance(new Object[0]);
- }
- catch (Exception x)
- {
- throw new IllegalArgumentException(
- "strong crypto key pair generator not available: " + clazz, x);
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKey.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKey.java
deleted file mode 100644
index 657de8dd..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKey.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/* DSSKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.util.FormatUtil;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.Key;
-import java.security.interfaces.DSAKey;
-import java.security.interfaces.DSAParams;
-import java.security.spec.DSAParameterSpec;
-
-/**
- * A base asbtract class for both public and private DSS (Digital Signature
- * Standard) keys. It encapsulates the three DSS numbers: p
,
- * q
and g
.
- *
- * According to the JDK, cryptographic Keys all have a format.
- * The format used in this implementation is called Raw, and basically
- * consists of the raw byte sequences of algorithm parameters. The exact order
- * of the byte sequences and the implementation details are given in each of the
- * relevant getEncoded()
methods of each of the private and
- * public keys.
- *
- * IMPORTANT: Under certain circumstances (e.g. in an X.509 certificate
- * with inherited AlgorithmIdentifier's parameters of a SubjectPublicKeyInfo
- * element) these three MPIs may be null
.
- *
- * @see DSSPrivateKey#getEncoded
- * @see DSSPublicKey#getEncoded
- */
-public abstract class DSSKey
- implements Key, DSAKey
-{
- /**
- * A prime modulus, where
- * 2L-1 < p < 2L
for
- * 512 <= L <= 1024
and L
a multiple of
- * 64
.
- */
- protected final BigInteger p;
-
- /**
- * A prime divisor of p - 1
, where
- * 2159 < q
- * < 2160
.
- */
- protected final BigInteger q;
-
- /**
- * g = h(p-1)/q mod p
, where h
is
- * any integer with 1 < h < p - 1
such that h
- * (p-1)/q mod p > 1
(g
- * has order q mod p
- *
).
- */
- protected final BigInteger g;
-
- /**
- * Identifier of the default encoding format to use when externalizing the key
- * material.
- */
- protected final int defaultFormat;
-
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Trivial protected constructor.
- *
- * @param defaultFormat the identifier of the encoding format to use by
- * default when externalizing the key.
- * @param p the DSS parameter p
.
- * @param q the DSS parameter q
.
- * @param g the DSS parameter g
.
- */
- protected DSSKey(int defaultFormat, BigInteger p, BigInteger q, BigInteger g)
- {
- super();
-
- this.defaultFormat = defaultFormat <= 0 ? Registry.RAW_ENCODING_ID
- : defaultFormat;
- this.p = p;
- this.q = q;
- this.g = g;
- }
-
- public DSAParams getParams()
- {
- return new DSAParameterSpec(p, q, g);
- }
-
- public String getAlgorithm()
- {
- return Registry.DSS_KPG;
- }
-
- /** @deprecated see getEncoded(int). */
- public byte[] getEncoded()
- {
- return getEncoded(defaultFormat);
- }
-
- public String getFormat()
- {
- return FormatUtil.getEncodingShortName(defaultFormat);
- }
-
- /**
- * Returns true
if the designated object is an instance of
- * {@link DSAKey} and has the same DSS (Digital Signature Standard) parameter
- * values as this one.
- *
- * Always returns false
if the MPIs of this key are
- * inherited. This may be the case when the key is re-constructed from
- * an X.509 certificate with absent or NULL AlgorithmIdentifier's parameters
- * field.
- *
- * @param obj the other non-null DSS key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(Object obj)
- {
- if (hasInheritedParameters())
- return false;
-
- if (obj == null)
- return false;
-
- if (! (obj instanceof DSAKey))
- return false;
-
- DSAKey that = (DSAKey) obj;
- return p.equals(that.getParams().getP())
- && q.equals(that.getParams().getQ())
- && g.equals(that.getParams().getG());
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged(new GetPropertyAction("line.separator"));
- StringBuilder sb = new StringBuilder(ls)
- .append("defaultFormat=").append(defaultFormat).append(",")
- .append(ls);
- if (hasInheritedParameters())
- sb.append("p=inherited,").append(ls)
- .append("q=inherited,").append(ls)
- .append("g=inherited");
- else
- sb.append("p=0x").append(p.toString(16)).append(",").append(ls)
- .append("q=0x").append(q.toString(16)).append(",").append(ls)
- .append("g=0x").append(g.toString(16));
- str = sb.toString();
- }
- return str;
- }
-
- public abstract byte[] getEncoded(int format);
-
- /**
- * @return true
if p
, q
and
- * g
are all null
. Returns
- * false
otherwise.
- */
- public boolean hasInheritedParameters()
- {
- return p == null && q == null && g == null;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairGenerator.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairGenerator.java
deleted file mode 100644
index 1bad0b62..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairGenerator.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/* DSSKeyPairGenerator.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.Registry;
-import gnu.java.security.hash.Sha160;
-import gnu.java.security.key.IKeyPairGenerator;
-import gnu.java.security.util.PRNG;
-
-import java.math.BigInteger;
-import java.security.KeyPair;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.spec.DSAParameterSpec;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * A key-pair generator for asymetric keys to use in conjunction with the DSS
- * (Digital Signature Standard).
- *
- * References: - *
- * Digital Signature
- * Standard (DSS), Federal Information Processing Standards Publication
- * 186. National Institute of Standards and Technology.
- */
-public class DSSKeyPairGenerator
- implements IKeyPairGenerator
-{
- private static final Logger log = Logger.getLogger(DSSKeyPairGenerator.class.getName());
-
- /** The BigInteger constant 2. */
- private static final BigInteger TWO = BigInteger.valueOf(2L);
-
- /** Property name of the length (Integer) of the modulus (p) of a DSS key. */
- public static final String MODULUS_LENGTH = "gnu.crypto.dss.L";
-
- /**
- * Property name of the Boolean indicating wether or not to use default pre-
- * computed values of p
, q
and g
- * for a given modulus length. The ultimate behaviour of this generator with
- * regard to using pre-computed parameter sets will depend on the value of
- * this property and of the following one {@link #STRICT_DEFAULTS}:
- *
512
and
- * 1024
, and is of the form 512 + 64 * n
. In
- * addition, a new paramter set will always be generated; i.e. no pre-
- * computed values are used.512
, 768
and 1024
. Any
- * other value, of the modulus length, even if between 512
and
- * 1024
, and of the form 512 + 64 * n
, will
- * cause an {@link IllegalArgumentException} to be thrown. When those modulus
- * length (512
, 768
, and 1024
)
- * are specified, the paramter set is always the same.512
,
- * 768
, or 1024
.p
, q
, and g
- * values. The default is to generate these values or use pre-computed ones,
- * depending on the value of the USE_DEFAULTS
attribute.
- */
- public static final String DSS_PARAMETERS = "gnu.crypto.dss.params";
-
- /**
- * Property name of the preferred encoding format to use when externalizing
- * generated instance of key-pairs from this generator. The property is taken
- * to be an {@link Integer} that encapsulates an encoding format identifier.
- */
- public static final String PREFERRED_ENCODING_FORMAT = "gnu.crypto.dss.encoding";
-
- /** Default value for the modulus length. */
- public static final int DEFAULT_MODULUS_LENGTH = 1024;
-
- /** Default encoding format to use when none was specified. */
- private static final int DEFAULT_ENCODING_FORMAT = Registry.RAW_ENCODING_ID;
-
- /** Initial SHS context. */
- private static final int[] T_SHS = new int[] {
- 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0
- };
-
- // from jdk1.3.1/docs/guide/security/CryptoSpec.html#AppB
- public static final DSAParameterSpec KEY_PARAMS_512 = new DSAParameterSpec(
- new BigInteger(
- "fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae"
- + "01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17", 16),
- new BigInteger("962eddcc369cba8ebb260ee6b6a126d9346e38c5", 16),
- new BigInteger(
- "678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e"
- + "35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4", 16));
- public static final DSAParameterSpec KEY_PARAMS_768 = new DSAParameterSpec(
- new BigInteger(
- "e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d8901419"
- + "22d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d77"
- + "7d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf", 16),
- new BigInteger("9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511", 16),
- new BigInteger(
- "30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4"
- + "dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d8"
- + "3c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252", 16));
- public static final DSAParameterSpec KEY_PARAMS_1024 = new DSAParameterSpec(
- new BigInteger(
- "fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669"
- + "455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b7"
- + "6b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb"
- + "83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7", 16),
- new BigInteger("9760508f15230bccb292b982a2eb840bf0581cf5", 16),
- new BigInteger(
- "f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d078267"
- + "5159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e1"
- + "3c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243b"
- + "cca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a", 16));
-
- private static final BigInteger TWO_POW_160 = TWO.pow(160);
-
- /** The length of the modulus of DSS keys generated by this instance. */
- private int L;
-
- /** The optional {@link SecureRandom} instance to use. */
- private SecureRandom rnd = null;
-
- private BigInteger seed;
-
- private BigInteger counter;
-
- private BigInteger p;
-
- private BigInteger q;
-
- private BigInteger e;
-
- private BigInteger g;
-
- private BigInteger XKEY;
-
- /** Our default source of randomness. */
- private PRNG prng = null;
-
- /** Preferred encoding format of generated keys. */
- private int preferredFormat;
-
- public String name()
- {
- return Registry.DSS_KPG;
- }
-
- /**
- * Configures this instance.
- *
- * @param attributes the map of name/value pairs to use.
- * @exception IllegalArgumentException if the designated MODULUS_LENGTH value
- * is not greater than 512, less than 1024 and not of the form
- * 512 + 64j
.
- */
- public void setup(Map attributes)
- {
- // find out the modulus length
- Integer l = (Integer) attributes.get(MODULUS_LENGTH);
- L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue());
- if ((L % 64) != 0 || L < 512 || L > 1024)
- throw new IllegalArgumentException(MODULUS_LENGTH);
-
- // should we use the default pre-computed params?
- Boolean useDefaults = (Boolean) attributes.get(USE_DEFAULTS);
- if (useDefaults == null)
- useDefaults = Boolean.TRUE;
-
- Boolean strictDefaults = (Boolean) attributes.get(STRICT_DEFAULTS);
- if (strictDefaults == null)
- strictDefaults = Boolean.FALSE;
-
- // are we given a set of DSA params or we shall use/generate our own?
- DSAParameterSpec params = (DSAParameterSpec) attributes.get(DSS_PARAMETERS);
- if (params != null)
- {
- p = params.getP();
- q = params.getQ();
- g = params.getG();
- }
- else if (useDefaults.equals(Boolean.TRUE))
- {
- switch (L)
- {
- case 512:
- p = KEY_PARAMS_512.getP();
- q = KEY_PARAMS_512.getQ();
- g = KEY_PARAMS_512.getG();
- break;
- case 768:
- p = KEY_PARAMS_768.getP();
- q = KEY_PARAMS_768.getQ();
- g = KEY_PARAMS_768.getG();
- break;
- case 1024:
- p = KEY_PARAMS_1024.getP();
- q = KEY_PARAMS_1024.getQ();
- g = KEY_PARAMS_1024.getG();
- break;
- default:
- if (strictDefaults.equals(Boolean.TRUE))
- throw new IllegalArgumentException(
- "Does not provide default parameters for " + L
- + "-bit modulus length");
- else
- {
- p = null;
- q = null;
- g = null;
- }
- }
- }
- else
- {
- p = null;
- q = null;
- g = null;
- }
- // do we have a SecureRandom, or should we use our own?
- rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
- // what is the preferred encoding format
- Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
- preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
- : formatID.intValue();
- // set the seed-key
- byte[] kb = new byte[20]; // we need 160 bits of randomness
- nextRandomBytes(kb);
- XKEY = new BigInteger(1, kb).setBit(159).setBit(0);
- }
-
- public KeyPair generate()
- {
- if (p == null)
- {
- BigInteger[] params = new FIPS186(L, rnd).generateParameters();
- seed = params[FIPS186.DSA_PARAMS_SEED];
- counter = params[FIPS186.DSA_PARAMS_COUNTER];
- q = params[FIPS186.DSA_PARAMS_Q];
- p = params[FIPS186.DSA_PARAMS_P];
- e = params[FIPS186.DSA_PARAMS_E];
- g = params[FIPS186.DSA_PARAMS_G];
- if (Configuration.DEBUG)
- {
- log.fine("seed: " + seed.toString(16));
- log.fine("counter: " + counter.intValue());
- log.fine("q: " + q.toString(16));
- log.fine("p: " + p.toString(16));
- log.fine("e: " + e.toString(16));
- log.fine("g: " + g.toString(16));
- }
- }
- BigInteger x = nextX();
- BigInteger y = g.modPow(x, p);
- PublicKey pubK = new DSSPublicKey(preferredFormat, p, q, g, y);
- PrivateKey secK = new DSSPrivateKey(preferredFormat, p, q, g, x);
- return new KeyPair(pubK, secK);
- }
-
- /**
- * This method applies the following algorithm described in 3.1 of FIPS-186:
- *
- * Where b
is the length of a secret b-bit seed-key (XKEY).
- *
- * Note that in this implementation, XSEED, the optional user input, is always - * zero. - */ - private synchronized BigInteger nextX() - { - byte[] xk = XKEY.toByteArray(); - byte[] in = new byte[64]; // 512-bit block for SHS - System.arraycopy(xk, 0, in, 0, xk.length); - int[] H = Sha160.G(T_SHS[0], T_SHS[1], T_SHS[2], T_SHS[3], T_SHS[4], in, 0); - byte[] h = new byte[20]; - for (int i = 0, j = 0; i < 5; i++) - { - h[j++] = (byte)(H[i] >>> 24); - h[j++] = (byte)(H[i] >>> 16); - h[j++] = (byte)(H[i] >>> 8); - h[j++] = (byte) H[i]; - } - BigInteger result = new BigInteger(1, h).mod(q); - XKEY = XKEY.add(result).add(BigInteger.ONE).mod(TWO_POW_160); - return result; - } - - /** - * Fills the designated byte array with random data. - * - * @param buffer the byte array to fill with random data. - */ - private void nextRandomBytes(byte[] buffer) - { - if (rnd != null) - rnd.nextBytes(buffer); - else - getDefaultPRNG().nextBytes(buffer); - } - - private PRNG getDefaultPRNG() - { - if (prng == null) - prng = PRNG.getInstance(); - - return prng; - } -} diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java deleted file mode 100644 index 06b8e849..00000000 --- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairPKCS8Codec.java +++ /dev/null @@ -1,249 +0,0 @@ -/* DSSKeyPairPKCS8Codec.java -- PKCS#8 Encoding/Decoding handler - Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA -02110-1301 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 gnu.java.security.key.dss; - -import gnu.java.security.Configuration; -import gnu.java.security.OID; -import gnu.java.security.Registry; -import gnu.java.security.der.DER; -import gnu.java.security.der.DERReader; -import gnu.java.security.der.DERValue; -import gnu.java.security.der.DERWriter; -import gnu.java.security.key.IKeyPairCodec; -import gnu.java.security.util.DerUtil; -import gnu.java.security.util.Util; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.math.BigInteger; -import java.security.InvalidParameterException; -import java.security.PrivateKey; -import java.security.PublicKey; -import java.util.ArrayList; -import java.util.logging.Logger; - -/** - * An implementation of an {@link IKeyPairCodec} that knows how to encode / - * decode PKCS#8 ASN.1 external representation of DSS private keys. - * - * @author Casey Marshall (rsdio@metastatic.org) - */ -public class DSSKeyPairPKCS8Codec - implements IKeyPairCodec -{ - private static final Logger log = Logger.getLogger(DSSKeyPairPKCS8Codec.class.getName()); - private static final OID DSA_ALG_OID = new OID(Registry.DSA_OID_STRING); - - // implicit 0-arguments constructor - - public int getFormatID() - { - return PKCS8_FORMAT; - } - - /** - * @throws InvalidParameterException ALWAYS. - */ - public byte[] encodePublicKey(PublicKey key) - { - throw new InvalidParameterException("Wrong format for public keys"); - } - - /** - * Returns the PKCS#8 ASN.1 PrivateKeyInfo representation of a DSA - * private key. The ASN.1 specification is as follows: - * - *
- * PrivateKeyInfo ::= SEQUENCE { - * version INTEGER, -- MUST be 0 - * privateKeyAlgorithm AlgorithmIdentifier, - * privateKey OCTET STRING - * } - * - * AlgorithmIdentifier ::= SEQUENCE { - * algorithm OBJECT IDENTIFIER, - * parameters ANY DEFINED BY algorithm OPTIONAL - * } - * - * DssParams ::= SEQUENCE { - * p INTEGER, - * q INTEGER, - * g INTEGER - * } - *- * - * @return the DER encoded form of the ASN.1 representation of the - * PrivateKeyInfo field in an X.509 certificate. - * @throw InvalidParameterException if an error occurs during the marshalling - * process. - */ - public byte[] encodePrivateKey(PrivateKey key) - { - if (! (key instanceof DSSPrivateKey)) - throw new InvalidParameterException("Wrong key type"); - - DERValue derVersion = new DERValue(DER.INTEGER, BigInteger.ZERO); - - DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, DSA_ALG_OID); - - DSSPrivateKey pk = (DSSPrivateKey) key; - BigInteger p = pk.getParams().getP(); - BigInteger q = pk.getParams().getQ(); - BigInteger g = pk.getParams().getG(); - BigInteger x = pk.getX(); - - ArrayList params = new ArrayList(3); - params.add(new DERValue(DER.INTEGER, p)); - params.add(new DERValue(DER.INTEGER, q)); - params.add(new DERValue(DER.INTEGER, g)); - DERValue derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params); - - ArrayList algorithmID = new ArrayList(2); - algorithmID.add(derOID); - algorithmID.add(derParams); - DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, - algorithmID); - - // The OCTET STRING is the DER encoding of an INTEGER. - DERValue derX = new DERValue(DER.INTEGER, x); - DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, derX.getEncoded()); - - ArrayList pki = new ArrayList(3); - pki.add(derVersion); - pki.add(derAlgorithmID); - pki.add(derPrivateKey); - DERValue derPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, pki); - - byte[] result; - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try - { - DERWriter.write(baos, derPKI); - result = baos.toByteArray(); - } - catch (IOException e) - { - InvalidParameterException y = new InvalidParameterException(e.getMessage()); - y.initCause(e); - throw y; - } - return result; - } - - /** - * @throws InvalidParameterException ALWAYS. - */ - public PublicKey decodePublicKey(byte[] input) - { - throw new InvalidParameterException("Wrong format for public keys"); - } - - /** - * @param input the byte array to unmarshall into a valid DSS - * {@link PrivateKey} instance. MUST NOT be null. - * @return a new instance of a {@link DSSPrivateKey} decoded from the - * PrivateKeyInfo material fed as
input
.
- * @throw InvalidParameterException if an exception occurs during the
- * unmarshalling process.
- */
- public PrivateKey decodePrivateKey(byte[] input)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "decodePrivateKey");
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- BigInteger version, p, q, g, x;
- DERReader der = new DERReader(input);
- try
- {
- DERValue derPKI = der.read();
- DerUtil.checkIsConstructed(derPKI, "Wrong PrivateKeyInfo field");
-
- DERValue derVersion = der.read();
- if (! (derVersion.getValue() instanceof BigInteger))
- throw new InvalidParameterException("Wrong Version field");
-
- version = (BigInteger) derVersion.getValue();
- if (version.compareTo(BigInteger.ZERO) != 0)
- throw new InvalidParameterException("Unexpected Version: " + version);
-
- DERValue derAlgoritmID = der.read();
- DerUtil.checkIsConstructed(derAlgoritmID, "Wrong AlgorithmIdentifier field");
-
- DERValue derOID = der.read();
- OID algOID = (OID) derOID.getValue();
- if (! algOID.equals(DSA_ALG_OID))
- throw new InvalidParameterException("Unexpected OID: " + algOID);
-
- DERValue derParams = der.read();
- DerUtil.checkIsConstructed(derParams, "Wrong DSS Parameters field");
-
- DERValue val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong P field");
- p = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong Q field");
- q = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong G field");
- g = (BigInteger) val.getValue();
-
- val = der.read();
- if (Configuration.DEBUG)
- log.fine("val = " + val);
- byte[] xBytes = (byte[]) val.getValue();
- if (Configuration.DEBUG)
- log.fine(Util.dumpString(xBytes, "xBytes: "));
- DERReader der2 = new DERReader(xBytes);
- val = der2.read();
- DerUtil.checkIsBigInteger(val, "Wrong X field");
- x = (BigInteger) val.getValue();
- }
- catch (IOException e)
- {
- InvalidParameterException y = new InvalidParameterException(e.getMessage());
- y.initCause(e);
- throw y;
- }
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "decodePrivateKey");
- return new DSSPrivateKey(Registry.PKCS8_ENCODING_ID, p, q, g, x);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairRawCodec.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairRawCodec.java
deleted file mode 100644
index b1135b75..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSKeyPairRawCodec.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/* DSSKeyPairRawCodec.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-
-/**
- * An object that implements the {@link IKeyPairCodec} operations for the
- * Raw format to use with DSS keypairs.
- */
-public class DSSKeyPairRawCodec
- implements IKeyPairCodec
-{
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return RAW_FORMAT;
- }
-
- /**
- * Returns the encoded form of the designated DSS (Digital Signature Standard)
- * public key according to the Raw format supported by this library.
- * - * The Raw format for a DSA public key, in this implementation, is a - * byte sequence consisting of the following: - *
p
in internet order,toByteArray()
method on the DSA parameter p
,
- * q
,toByteArray()
method on the DSA parameter q
,
- * g
,toByteArray()
method on the DSA parameter g
,
- * y
,toByteArray()
method on the DSA parameter y
,
- * - * The Raw format for a DSA private key, in this implementation, is a - * byte sequence consisting of the following: - *
p
in internet order,toByteArray()
method on the DSA parameter p
,
- * q
,toByteArray()
method on the DSA parameter q
,
- * g
,toByteArray()
method on the DSA parameter g
,
- * x
,toByteArray()
method on the DSA parameter x
,
- * - * SubjectPublicKeyInfo ::= SEQUENCE { - * algorithm AlgorithmIdentifier, - * subjectPublicKey BIT STRING - * } - * - * AlgorithmIdentifier ::= SEQUENCE { - * algorithm OBJECT IDENTIFIER, - * parameters ANY DEFINED BY algorithm OPTIONAL - * } - * - * DssParams ::= SEQUENCE { - * p INTEGER, - * q INTEGER, - * g INTEGER - * } - *- *
- * Note that RFC-3280 (page 79) implies that some certificates MAY have an - * absent, or NULL, parameters field in their AlgorithmIdentifier element, - * implying that those parameters MUST be inherited from another - * certificate. This implementation, encodes a NULL element as the DER - * value of the parameters field when such is the case. - *
- * The subjectPublicKey field, which is a BIT STRING, contains the - * DER-encoded form of the DSA public key as an INTEGER. - * - *
- * DSAPublicKey ::= INTEGER -- public key, Y - *- * - * @param key the {@link PublicKey} instance to encode. MUST be an instance of - * {@link DSSPublicKey}. - * @return the ASN.1 representation of the SubjectPublicKeyInfo in an - * X.509 certificate. - * @throw InvalidParameterException if
key
is not an instance
- * of {@link DSSPublicKey} or if an exception occurs during the
- * marshalling process.
- */
- public byte[] encodePublicKey(PublicKey key)
- {
- if (! (key instanceof DSSPublicKey))
- throw new InvalidParameterException("key");
-
- DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, DSA_ALG_OID);
-
- DSSPublicKey dssKey = (DSSPublicKey) key;
- DERValue derParams;
- if (dssKey.hasInheritedParameters())
- derParams = new DERValue(DER.NULL, null);
- else
- {
- BigInteger p = dssKey.getParams().getP();
- BigInteger q = dssKey.getParams().getQ();
- BigInteger g = dssKey.getParams().getG();
-
- DERValue derP = new DERValue(DER.INTEGER, p);
- DERValue derQ = new DERValue(DER.INTEGER, q);
- DERValue derG = new DERValue(DER.INTEGER, g);
-
- ArrayList params = new ArrayList(3);
- params.add(derP);
- params.add(derQ);
- params.add(derG);
- derParams = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, params);
- }
-
- ArrayList algorithmID = new ArrayList(2);
- algorithmID.add(derOID);
- algorithmID.add(derParams);
- DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- algorithmID);
-
- BigInteger y = dssKey.getY();
- DERValue derDSAPublicKey = new DERValue(DER.INTEGER, y);
- byte[] yBytes = derDSAPublicKey.getEncoded();
- DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(yBytes));
-
- ArrayList spki = new ArrayList(2);
- spki.add(derAlgorithmID);
- spki.add(derSPK);
- DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki);
-
- byte[] result;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try
- {
- DERWriter.write(baos, derSPKI);
- result = baos.toByteArray();
- }
- catch (IOException x)
- {
- InvalidParameterException e = new InvalidParameterException(x.getMessage());
- e.initCause(x);
- throw e;
- }
- return result;
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public byte[] encodePrivateKey(PrivateKey key)
- {
- throw new InvalidParameterException("Wrong format for private keys");
- }
-
- /**
- * @param input the byte array to unmarshall into a valid DSS
- * {@link PublicKey} instance. MUST NOT be null.
- * @return a new instance of a {@link DSSPublicKey} decoded from the
- * SubjectPublicKeyInfo material in an X.509 certificate.
- * @throw InvalidParameterException if an exception occurs during the
- * unmarshalling process.
- */
- public PublicKey decodePublicKey(byte[] input)
- {
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- BigInteger p = null;
- BigInteger g = null;
- BigInteger q = null;
- BigInteger y;
- DERReader der = new DERReader(input);
- try
- {
- DERValue derSPKI = der.read();
- DerUtil.checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field");
-
- DERValue derAlgorithmID = der.read();
- DerUtil.checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field");
-
- DERValue derOID = der.read();
- if (! (derOID.getValue() instanceof OID))
- throw new InvalidParameterException("Wrong Algorithm field");
-
- OID algOID = (OID) derOID.getValue();
- if (! algOID.equals(DSA_ALG_OID))
- throw new InvalidParameterException("Unexpected OID: " + algOID);
-
- DERValue val = der.read();
- // RFC-3280, page 79 states: "If the subjectPublicKeyInfo field of the
- // certificate contains an algorithm field with null parameters or
- // parameters are omitted, compare the certificate subjectPublicKey
- // algorithm to the working_public_key_algorithm. If the certificate
- // subjectPublicKey algorithm and the working_public_key_algorithm are
- // different, set the working_public_key_parameters to null."
- // in other words, the parameters field of an AlgorithmIdentifier
- // element MAY NOT be present at all, or if present MAY be NULL!
- // the Mauve test ValidDSAParameterInheritenceTest5, in
- // gnu.testlet.java.security.cert.pkix.pkits, is/was failing because
- // of this.
- if (val.getTag() == DER.NULL)
- val = der.read();
- else if (val.isConstructed())
- {
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong P field");
- p = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong Q field");
- q = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong G field");
- g = (BigInteger) val.getValue();
-
- val = der.read();
- }
-
- if (! (val.getValue() instanceof BitString))
- throw new InvalidParameterException("Wrong SubjectPublicKey field");
-
- byte[] yBytes = ((BitString) val.getValue()).toByteArray();
-
- DERReader dsaPub = new DERReader(yBytes);
- val = dsaPub.read();
- DerUtil.checkIsBigInteger(val, "Wrong Y field");
- y = (BigInteger) val.getValue();
- }
- catch (IOException x)
- {
- InvalidParameterException e = new InvalidParameterException(x.getMessage());
- e.initCause(x);
- throw e;
- }
- return new DSSPublicKey(Registry.X509_ENCODING_ID, p, q, g, y);
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public PrivateKey decodePrivateKey(byte[] input)
- {
- throw new InvalidParameterException("Wrong format for private keys");
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPrivateKey.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPrivateKey.java
deleted file mode 100644
index 6ed8de84..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPrivateKey.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/* DSSPrivateKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.Registry;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.PrivateKey;
-import java.security.interfaces.DSAPrivateKey;
-
-/**
- * An object that embodies a DSS (Digital Signature Standard) private key.
- *
- * @see #getEncoded
- */
-public class DSSPrivateKey
- extends DSSKey
- implements PrivateKey, DSAPrivateKey
-{
- /**
- * A randomly or pseudorandomly generated integer with 0 < x <
- * q
.
- */
- private final BigInteger x;
-
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Convenience constructor. Calls the constructor with 5 arguments passing
- * {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
- * encoding format.
- *
- * @param p the public modulus.
- * @param q the public prime divisor of p-1
.
- * @param g a generator of the unique cyclic group Z*
- * p
.
- * @param x the private key part.
- */
- public DSSPrivateKey(BigInteger p, BigInteger q, BigInteger g, BigInteger x)
- {
- this(Registry.RAW_ENCODING_ID, p, q, g, x);
- }
-
- /**
- * Constructs a new instance of a DSSPrivateKey
given the
- * designated arguments.
- *
- * @param preferredFormat the indetifier of the preferred encoding format to
- * use when externalizing this key.
- * @param p the public modulus.
- * @param q the public prime divisor of p-1
.
- * @param g a generator of the unique cyclic group Z*
- * p
.
- * @param x the private key part.
- */
- public DSSPrivateKey(int preferredFormat, BigInteger p, BigInteger q,
- BigInteger g, BigInteger x)
- {
- super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
- : preferredFormat,
- p, q, g);
- this.x = x;
- }
-
- /**
- * A class method that takes the output of the encodePrivateKey()
- * method of a DSS keypair codec object (an instance implementing
- * {@link gnu.java.security.key.IKeyPairCodec} for DSS keys, and re-constructs
- * an instance of this object.
- *
- * @param k the contents of a previously encoded instance of this object.
- * @exception ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * k
, to represent a valid encoding of an
- * instance of this object.
- * @exception IllegalArgumentException if the byte sequence does not represent
- * a valid encoding of an instance of this object.
- */
- public static DSSPrivateKey valueOf(byte[] k)
- {
- // try RAW codec
- if (k[0] == Registry.MAGIC_RAW_DSS_PRIVATE_KEY[0])
- try
- {
- return (DSSPrivateKey) new DSSKeyPairRawCodec().decodePrivateKey(k);
- }
- catch (IllegalArgumentException ignored)
- {
- }
- // try PKCS#8 codec
- return (DSSPrivateKey) new DSSKeyPairPKCS8Codec().decodePrivateKey(k);
- }
-
- public BigInteger getX()
- {
- return x;
- }
-
- /**
- * Returns the encoded form of this private key according to the designated
- * format.
- *
- * @param format the desired format identifier of the resulting encoding.
- * @return the byte sequence encoding this key according to the designated
- * format.
- * @exception IllegalArgumentException if the format is not supported.
- * @see DSSKeyPairRawCodec
- */
- public byte[] getEncoded(int format)
- {
- byte[] result;
- switch (format)
- {
- case IKeyPairCodec.RAW_FORMAT:
- result = new DSSKeyPairRawCodec().encodePrivateKey(this);
- break;
- case IKeyPairCodec.PKCS8_FORMAT:
- result = new DSSKeyPairPKCS8Codec().encodePrivateKey(this);
- break;
- default:
- throw new IllegalArgumentException("Unsupported encoding format: "
- + format);
- }
- return result;
- }
-
- /**
- * Returns true
if the designated object is an instance of
- * {@link DSAPrivateKey} and has the same DSS (Digital Signature Standard)
- * parameter values as this one.
- *
- * @param obj the other non-null DSS key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(Object obj)
- {
- if (obj == null)
- return false;
-
- if (! (obj instanceof DSAPrivateKey))
- return false;
-
- DSAPrivateKey that = (DSAPrivateKey) obj;
- return super.equals(that) && x.equals(that.getX());
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged
- (new GetPropertyAction("line.separator"));
- str = new StringBuilder(this.getClass().getName()).append("(")
- .append(super.toString()).append(",").append(ls)
- .append("x=0x").append(Configuration.DEBUG ? x.toString(16)
- : "**...*").append(ls)
- .append(")")
- .toString();
- }
- return str;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPublicKey.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPublicKey.java
deleted file mode 100644
index 9e1c4cf0..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/DSSPublicKey.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/* DSSPublicKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.PublicKey;
-import java.security.interfaces.DSAPublicKey;
-
-/**
- * An object that embodies a DSS (Digital Signature Standard) public key.
- *
- * @see #getEncoded
- */
-public class DSSPublicKey
- extends DSSKey
- implements PublicKey, DSAPublicKey
-{
- /**
- * y = gx mod p
where x
is the
- * private part of the DSA key.
- */
- private final BigInteger y;
-
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Conveience constructor. Calls the constructor with 5 arguments passing
- * {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
- * encoding format.
- *
- * @param p the public modulus.
- * @param q the public prime divisor of p-1
.
- * @param g a generator of the unique cyclic group Z*
- * p
.
- * @param y the public key part.
- */
- public DSSPublicKey(BigInteger p, BigInteger q, BigInteger g, BigInteger y)
- {
- this(Registry.RAW_ENCODING_ID, p, q, g, y);
- }
-
- /**
- * Constructs a new instance of DSSPublicKey
given the
- * designated arguments.
- *
- * @param preferredFormat the identifier of the preferred encoding format to
- * use when externalizing this key.
- * @param p the public modulus.
- * @param q the public prime divisor of p-1
.
- * @param g a generator of the unique cyclic group Z*
- * p
.
- * @param y the public key part.
- */
- public DSSPublicKey(int preferredFormat, BigInteger p, BigInteger q,
- BigInteger g, BigInteger y)
- {
- super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.X509_ENCODING_ID
- : preferredFormat,
- p, q, g);
- this.y = y;
- }
-
- /**
- * A class method that takes the output of the encodePublicKey()
- * method of a DSS keypair codec object (an instance implementing
- * {@link gnu.java.security.key.IKeyPairCodec} for DSS keys, and re-constructs
- * an instance of this object.
- *
- * @param k the contents of a previously encoded instance of this object.
- * @exception ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * k
, to represent a valid encoding of an
- * instance of this object.
- * @exception IllegalArgumentException if the byte sequence does not represent
- * a valid encoding of an instance of this object.
- */
- public static DSSPublicKey valueOf(byte[] k)
- {
- // try RAW codec
- if (k[0] == Registry.MAGIC_RAW_DSS_PUBLIC_KEY[0])
- try
- {
- return (DSSPublicKey) new DSSKeyPairRawCodec().decodePublicKey(k);
- }
- catch (IllegalArgumentException ignored)
- {
- }
- // try X.509 codec
- return (DSSPublicKey) new DSSKeyPairX509Codec().decodePublicKey(k);
- }
-
- public BigInteger getY()
- {
- return y;
- }
-
- /**
- * Returns the encoded form of this public key according to the designated
- * format.
- *
- * @param format the desired format identifier of the resulting encoding.
- * @return the byte sequence encoding this key according to the designated
- * format.
- * @exception IllegalArgumentException if the format is not supported.
- * @see DSSKeyPairRawCodec
- */
- public byte[] getEncoded(int format)
- {
- byte[] result;
- switch (format)
- {
- case IKeyPairCodec.RAW_FORMAT:
- result = new DSSKeyPairRawCodec().encodePublicKey(this);
- break;
- case IKeyPairCodec.X509_FORMAT:
- result = new DSSKeyPairX509Codec().encodePublicKey(this);
- break;
- default:
- throw new IllegalArgumentException("Unsupported encoding format: "
- + format);
- }
- return result;
- }
-
- /**
- * Returns true
if the designated object is an instance of
- * {@link DSAPublicKey} and has the same DSS (Digital Signature Standard)
- * parameter values as this one.
- *
- * @param obj the other non-null DSS key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(Object obj)
- {
- if (obj == null)
- return false;
-
- if (! (obj instanceof DSAPublicKey))
- return false;
-
- DSAPublicKey that = (DSAPublicKey) obj;
- return super.equals(that) && y.equals(that.getY());
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged
- (new GetPropertyAction("line.separator"));
- str = new StringBuilder(this.getClass().getName()).append("(")
- .append(super.toString()).append(",").append(ls)
- .append("y=0x").append(y.toString(16)).append(ls)
- .append(")")
- .toString();
- }
- return str;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/dss/FIPS186.java b/openjdk/icedtea/jce/gnu/java/security/key/dss/FIPS186.java
deleted file mode 100644
index 7277599b..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/dss/FIPS186.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/* FIPS186.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.dss;
-
-import gnu.java.security.hash.Sha160;
-import gnu.java.security.util.PRNG;
-
-import java.math.BigInteger;
-import java.security.SecureRandom;
-
-/**
- * An implementation of the DSA parameters generation as described in FIPS-186.
- * - * References: - *
- * Digital Signature
- * Standard (DSS), Federal Information Processing Standards Publication
- * 186. National Institute of Standards and Technology.
- */
-public class FIPS186
-{
- public static final int DSA_PARAMS_SEED = 0;
-
- public static final int DSA_PARAMS_COUNTER = 1;
-
- public static final int DSA_PARAMS_Q = 2;
-
- public static final int DSA_PARAMS_P = 3;
-
- public static final int DSA_PARAMS_E = 4;
-
- public static final int DSA_PARAMS_G = 5;
-
- /** The BigInteger constant 2. */
- private static final BigInteger TWO = BigInteger.valueOf(2L);
-
- private static final BigInteger TWO_POW_160 = TWO.pow(160);
-
- /** The SHA instance to use. */
- private Sha160 sha = new Sha160();
-
- /** The length of the modulus of DSS keys generated by this instance. */
- private int L;
-
- /** The optional {@link SecureRandom} instance to use. */
- private SecureRandom rnd = null;
-
- /** Our default source of randomness. */
- private PRNG prng = null;
-
- public FIPS186(int L, SecureRandom rnd)
- {
- super();
-
- this.L = L;
- this.rnd = rnd;
- }
-
- /**
- * This method generates the DSS p
, q
, and
- * g
parameters only when L
(the modulus length)
- * is not one of the following: 512
, 768
and
- * 1024
. For those values of L
, this
- * implementation uses pre-computed values of p
,
- * q
, and g
given in the document CryptoSpec
- * included in the security guide documentation of the standard JDK
- * distribution.
- *
- * The DSS requires two primes , p
and q
,
- * satisfying the following three conditions:
- *
2159 < q < 2160
2L-1 < p < 2L
for a
- * specified L
, where L = 512 + 64j
for some
- * 0 <= j <= 8
q
, in the range 2159 < q < 2160.
- * Once this is accomplished, the same SEED value is used to construct
- * an X
in the range 2L-1
- * < X < 2L. The prime, p
, is then
- * formed by rounding X
to a number congruent to 1 mod
- * 2q
. In this implementation we use the same SEED value given
- * in FIPS-186, Appendix 5.
- */
- public BigInteger[] generateParameters()
- {
- int counter, offset;
- BigInteger SEED, alpha, U, q, OFFSET, SEED_PLUS_OFFSET, W, X, p, c, g;
- byte[] a, u;
- byte[] kb = new byte[20]; // to hold 160 bits of randomness
-
- // Let L-1 = n*160 + b, where b and n are integers and 0 <= b < 160.
- int b = (L - 1) % 160;
- int n = (L - 1 - b) / 160;
- BigInteger[] V = new BigInteger[n + 1];
- algorithm: while (true)
- {
- step1: while (true)
- {
- // 1. Choose an arbitrary sequence of at least 160 bits and
- // call it SEED.
- nextRandomBytes(kb);
- SEED = new BigInteger(1, kb).setBit(159).setBit(0);
- // Let g be the length of SEED in bits. here always 160
- // 2. Compute: U = SHA[SEED] XOR SHA[(SEED+1) mod 2**g]
- alpha = SEED.add(BigInteger.ONE).mod(TWO_POW_160);
- synchronized (sha)
- {
- a = SEED.toByteArray();
- sha.update(a, 0, a.length);
- a = sha.digest();
- u = alpha.toByteArray();
- sha.update(u, 0, u.length);
- u = sha.digest();
- }
- for (int i = 0; i < a.length; i++)
- a[i] ^= u[i];
-
- U = new BigInteger(1, a);
- // 3. Form q from U by setting the most significant bit (the
- // 2**159 bit) and the least significant bit to 1. In terms of
- // boolean operations, q = U OR 2**159 OR 1. Note that
- // 2**159 < q < 2**160.
- q = U.setBit(159).setBit(0);
- // 4. Use a robust primality testing algorithm to test whether
- // q is prime(1). A robust primality test is one where the
- // probability of a non-prime number passing the test is at
- // most 1/2**80.
- // 5. If q is not prime, go to step 1.
- if (q.isProbablePrime(80))
- break step1;
- } // step1
- // 6. Let counter = 0 and offset = 2.
- counter = 0;
- offset = 2;
- step7: while (true)
- {
- OFFSET = BigInteger.valueOf(offset & 0xFFFFFFFFL);
- SEED_PLUS_OFFSET = SEED.add(OFFSET);
- // 7. For k = 0,...,n let V[k] = SHA[(SEED + offset + k) mod 2**g].
- synchronized (sha)
- {
- for (int k = 0; k <= n; k++)
- {
- a = SEED_PLUS_OFFSET
- .add(BigInteger.valueOf(k & 0xFFFFFFFFL))
- .mod(TWO_POW_160).toByteArray();
- sha.update(a, 0, a.length);
- V[k] = new BigInteger(1, sha.digest());
- }
- }
- // 8. Let W be the integer:
- // V[0]+V[1]*2**160+...+V[n-1]*2**((n-1)*160)+(V[n]mod2**b)*2**(n*160)
- // and let : X = W + 2**(L-1).
- // Note that 0 <= W < 2**(L-1) and hence 2**(L-1) <= X < 2**L.
- W = V[0];
- for (int k = 1; k < n; k++)
- W = W.add(V[k].multiply(TWO.pow(k * 160)));
-
- W = W.add(V[n].mod(TWO.pow(b)).multiply(TWO.pow(n * 160)));
- X = W.add(TWO.pow(L - 1));
- // 9. Let c = X mod 2q and set p = X - (c - 1).
- // Note that p is congruent to 1 mod 2q.
- c = X.mod(TWO.multiply(q));
- p = X.subtract(c.subtract(BigInteger.ONE));
- // 10. If p < 2**(L-1), then go to step 13.
- if (p.compareTo(TWO.pow(L - 1)) >= 0)
- {
- // 11. Perform a robust primality test on p.
- // 12. If p passes the test performed in step 11, go to step 15.
- if (p.isProbablePrime(80))
- break algorithm;
- }
- // 13. Let counter = counter + 1 and offset = offset + n + 1.
- counter++;
- offset += n + 1;
- // 14. If counter >= 4096 go to step 1, otherwise go to step 7.
- if (counter >= 4096)
- continue algorithm;
- } // step7
- } // algorithm
- // compute g. from FIPS-186, Appendix 4:
- // 1. Generate p and q as specified in Appendix 2.
- // 2. Let e = (p - 1) / q
- BigInteger e = p.subtract(BigInteger.ONE).divide(q);
- BigInteger h = TWO;
- BigInteger p_minus_1 = p.subtract(BigInteger.ONE);
- g = TWO;
- // 3. Set h = any integer, where 1 < h < p - 1 and
- // h differs from any value previously tried
- for (; h.compareTo(p_minus_1) < 0; h = h.add(BigInteger.ONE))
- {
- // 4. Set g = h**e mod p
- g = h.modPow(e, p);
- // 5. If g = 1, go to step 3
- if (! g.equals(BigInteger.ONE))
- break;
- }
- return new BigInteger[] { SEED, BigInteger.valueOf(counter), q, p, e, g };
- }
-
- /**
- * Fills the designated byte array with random data.
- *
- * @param buffer the byte array to fill with random data.
- */
- private void nextRandomBytes(byte[] buffer)
- {
- if (rnd != null)
- rnd.nextBytes(buffer);
- else
- getDefaultPRNG().nextBytes(buffer);
- }
-
- private PRNG getDefaultPRNG()
- {
- if (prng == null)
- prng = PRNG.getInstance();
-
- return prng;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAKey.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAKey.java
deleted file mode 100644
index 4bdce401..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAKey.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/* GnuRSAKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.util.FormatUtil;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.Key;
-import java.security.interfaces.RSAKey;
-
-/**
- * A base asbtract class for both public and private RSA keys.
- */
-public abstract class GnuRSAKey
- implements Key, RSAKey
-{
- /** The public modulus of an RSA key pair. */
- private final BigInteger n;
-
- /** The public exponent of an RSA key pair. */
- private final BigInteger e;
-
- /**
- * Identifier of the default encoding format to use when externalizing the key
- * material.
- */
- protected final int defaultFormat;
-
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Trivial protected constructor.
- *
- * @param defaultFormat the identifier of the encoding format to use by
- * default when externalizing the key.
- * @param n the public modulus n
.
- * @param e the public exponent e
.
- */
- protected GnuRSAKey(int defaultFormat, BigInteger n, BigInteger e)
- {
- super();
-
- this.defaultFormat = defaultFormat <= 0 ? Registry.RAW_ENCODING_ID
- : defaultFormat;
- this.n = n;
- this.e = e;
- }
-
- public BigInteger getModulus()
- {
- return getN();
- }
-
- public String getAlgorithm()
- {
- return Registry.RSA_KPG;
- }
-
- /** @deprecated see getEncoded(int). */
- public byte[] getEncoded()
- {
- return getEncoded(defaultFormat);
- }
-
- public String getFormat()
- {
- return FormatUtil.getEncodingShortName(defaultFormat);
- }
-
- /**
- * Returns the modulus n
.
- *
- * @return the modulus n
.
- */
- public BigInteger getN()
- {
- return n;
- }
-
- /**
- * Returns the public exponent e
.
- *
- * @return the public exponent e
.
- */
- public BigInteger getPublicExponent()
- {
- return getE();
- }
-
- /**
- * Same as {@link #getPublicExponent()}.
- *
- * @return the public exponent e
.
- */
- public BigInteger getE()
- {
- return e;
- }
-
- /**
- * Returns true
if the designated object is an instance of
- * {@link RSAKey} and has the same RSA parameter values as this one.
- *
- * @param obj the other non-null RSA key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(final Object obj)
- {
- if (obj == null)
- return false;
-
- if (! (obj instanceof RSAKey))
- return false;
-
- final RSAKey that = (RSAKey) obj;
- return n.equals(that.getModulus());
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged
- (new GetPropertyAction("line.separator"));
- str = new StringBuilder(ls)
- .append("defaultFormat=").append(defaultFormat).append(",").append(ls)
- .append("n=0x").append(n.toString(16)).append(",").append(ls)
- .append("e=0x").append(e.toString(16))
- .toString();
- }
- return str;
- }
-
- public abstract byte[] getEncoded(int format);
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPrivateKey.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
deleted file mode 100644
index 00a1b822..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPrivateKey.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/* GnuRSAPrivateKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.Registry;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.PrivateKey;
-import java.security.interfaces.RSAPrivateCrtKey;
-import java.security.interfaces.RSAPrivateKey;
-
-/**
- * An object that embodies an RSA private key.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class GnuRSAPrivateKey
- extends GnuRSAKey
- implements PrivateKey, RSAPrivateCrtKey
-{
- /** The first prime divisor of the modulus. */
- private final BigInteger p;
-
- /** The second prime divisor of the modulus. */
- private final BigInteger q;
-
- /** The private exponent of an RSA private key. */
- private final BigInteger d;
-
- /** The first factor's exponent. */
- private final BigInteger dP;
-
- /** The second factor's exponent. */
- private final BigInteger dQ;
-
- /** The CRT (Chinese Remainder Theorem) coefficient. */
- private final BigInteger qInv;
-
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Convenience constructor. Calls the constructor with 5 arguments passing
- * {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
- * encoding format.
- *
- * @param p the modulus first prime divisor.
- * @param q the modulus second prime divisor.
- * @param e the public exponent.
- * @param d the private exponent.
- */
- public GnuRSAPrivateKey(BigInteger p, BigInteger q, BigInteger e, BigInteger d)
- {
- this(Registry.RAW_ENCODING_ID, p, q, e, d);
- }
-
- /**
- * Constructs a new instance of a GnuRSAPrivateKey
given the
- * designated arguments.
- *
- * @param preferredFormat the indetifier of the preferred encoding format to
- * use when externalizing this key.
- * @param p the modulus first prime divisor.
- * @param q the modulus second prime divisor.
- * @param e the public exponent.
- * @param d the private exponent.
- */
- public GnuRSAPrivateKey(int preferredFormat, BigInteger p, BigInteger q,
- BigInteger e, BigInteger d)
- {
- this(preferredFormat,
- p.multiply(q),
- e, d, p, q,
- e.modInverse(p.subtract(BigInteger.ONE)),
- e.modInverse(q.subtract(BigInteger.ONE)),
- q.modInverse(p));
- }
-
- /**
- * Constructs a new instance of a GnuRSAPrivateKey
given the
- * designated arguments.
- *
- * @param preferredFormat the indetifier of the preferred encoding format to
- * use when externalizing this key.
- * @param n the public modulus, which is also the product of p
- * and q
.
- * @param e the public exponent.
- * @param d the private exponent.
- * @param p the modulus first prime divisor.
- * @param q the modulus second prime divisor.
- * @param dP the first prime's exponen. A positive integer less than
- * p
and q
, satisfying
- * e * dP = 1 (mod p-1)
.
- * @param dQ the second prime's exponent. A positive integer less than
- * p
and q
, satisfying
- * e * dQ = 1 (mod p-1)
.
- * @param qInv the Chinese Remainder Theorem coefiicient. A positive integer
- * less than p
, satisfying
- * q * qInv = 1 (mod p)
.
- */
- public GnuRSAPrivateKey(int preferredFormat, BigInteger n, BigInteger e,
- BigInteger d, BigInteger p, BigInteger q,
- BigInteger dP, BigInteger dQ, BigInteger qInv)
- {
- super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.PKCS8_ENCODING_ID
- : preferredFormat,
- n, e);
- this.d = d;
- this.p = p;
- this.q = q;
- // the exponents dP and dQ are positive integers less than p and q
- // respectively satisfying
- // e * dP = 1 (mod p-1);
- // e * dQ = 1 (mod q-1),
- this.dP = dP;
- this.dQ = dQ;
- // the CRT coefficient qInv is a positive integer less than p satisfying
- // q * qInv = 1 (mod p).
- this.qInv = qInv;
- }
-
- /**
- * A class method that takes the output of the encodePrivateKey()
- * method of an RSA keypair codec object (an instance implementing
- * {@link IKeyPairCodec} for RSA keys, and re-constructs an instance of this
- * object.
- *
- * @param k the contents of a previously encoded instance of this object.
- * @throws ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * k
, to represent a valid encoding of an instance
- * of this object.
- * @throws IllegalArgumentException if the byte sequence does not represent a
- * valid encoding of an instance of this object.
- */
- public static GnuRSAPrivateKey valueOf(final byte[] k)
- {
- // try RAW codec
- if (k[0] == Registry.MAGIC_RAW_RSA_PRIVATE_KEY[0])
- try
- {
- return (GnuRSAPrivateKey) new RSAKeyPairRawCodec().decodePrivateKey(k);
- }
- catch (IllegalArgumentException ignored)
- {
- }
- // try PKCS#8 codec
- return (GnuRSAPrivateKey) new RSAKeyPairPKCS8Codec().decodePrivateKey(k);
- }
-
- public BigInteger getPrimeP()
- {
- return p;
- }
-
- public BigInteger getPrimeQ()
- {
- return q;
- }
-
- public BigInteger getPrimeExponentP()
- {
- return dP;
- }
-
- public BigInteger getPrimeExponentQ()
- {
- return dQ;
- }
-
- public BigInteger getCrtCoefficient()
- {
- return qInv;
- }
-
- public BigInteger getPrivateExponent()
- {
- return d;
- }
-
- /**
- * Returns the encoded form of this private key according to the designated
- * format.
- *
- * @param format the desired format identifier of the resulting encoding.
- * @return the byte sequence encoding this key according to the designated
- * format.
- * @throws IllegalArgumentException if the format is not supported.
- * @see RSAKeyPairRawCodec
- * @see RSAKeyPairPKCS8Codec
- */
- public byte[] getEncoded(int format)
- {
- final byte[] result;
- switch (format)
- {
- case IKeyPairCodec.RAW_FORMAT:
- result = new RSAKeyPairRawCodec().encodePrivateKey(this);
- break;
- case IKeyPairCodec.PKCS8_FORMAT:
- result = new RSAKeyPairPKCS8Codec().encodePrivateKey(this);
- break;
- default:
- throw new IllegalArgumentException("Unsupported encoding format: "
- + format);
- }
- return result;
- }
-
- /**
- * Returns true
if the designated object is an instance of this
- * class and has the same RSA parameter values as this one.
- *
- * @param obj the other non-null RSA key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(final Object obj)
- {
- if (obj == null)
- return false;
-
- if (obj instanceof RSAPrivateKey)
- {
- final RSAPrivateKey that = (RSAPrivateKey) obj;
- return super.equals(that) && d.equals(that.getPrivateExponent());
- }
- if (obj instanceof RSAPrivateCrtKey)
- {
- final RSAPrivateCrtKey that = (RSAPrivateCrtKey) obj;
- return super.equals(that) && p.equals(that.getPrimeP())
- && q.equals(that.getPrimeQ())
- && dP.equals(that.getPrimeExponentP())
- && dQ.equals(that.getPrimeExponentQ())
- && qInv.equals(that.getCrtCoefficient());
- }
- return false;
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged
- (new GetPropertyAction("line.separator"));
- str = new StringBuilder(this.getClass().getName()).append("(")
- .append(super.toString()).append(",").append(ls)
- .append("d=0x").append(Configuration.DEBUG ? d.toString(16)
- : "**...*").append(ls)
- .append("p=0x").append(Configuration.DEBUG ? p.toString(16)
- : "**...*").append(ls)
- .append("q=0x").append(Configuration.DEBUG ? q.toString(16)
- : "**...*").append(ls)
- .append("dP=0x").append(Configuration.DEBUG ? dP.toString(16)
- : "**...*").append(ls)
- .append("dQ=0x").append(Configuration.DEBUG ? dQ.toString(16)
- : "**...*").append(ls)
- .append("qInv=0x").append(Configuration.DEBUG ? qInv.toString(16)
- : "**...*").append(ls)
- .append(")")
- .toString();
- }
- return str;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPublicKey.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPublicKey.java
deleted file mode 100644
index fe28d0ba..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/GnuRSAPublicKey.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/* GnuRSAPublicKey.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.action.GetPropertyAction;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.math.BigInteger;
-import java.security.AccessController;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPublicKey;
-
-/**
- * An object that encapsulates an RSA public key.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class GnuRSAPublicKey
- extends GnuRSAKey
- implements PublicKey, RSAPublicKey
-{
- /** String representation of this key. Cached for speed. */
- private transient String str;
-
- /**
- * Conveience constructor. Calls the constructor with 3 arguments passing
- * {@link Registry#RAW_ENCODING_ID} as the identifier of the preferred
- * encoding format.
- *
- * @param n the modulus.
- * @param e the public exponent.
- */
- public GnuRSAPublicKey(final BigInteger n, final BigInteger e)
- {
- this(Registry.RAW_ENCODING_ID, n, e);
- }
-
- /**
- * Constructs a new instance of GnuRSAPublicKey
given the
- * designated arguments.
- *
- * @param preferredFormat the identifier of the preferred encoding format to
- * use when externalizing this key.
- * @param n the modulus.
- * @param e the public exponent.
- */
- public GnuRSAPublicKey(int preferredFormat, BigInteger n, BigInteger e)
- {
- super(preferredFormat == Registry.ASN1_ENCODING_ID ? Registry.X509_ENCODING_ID
- : preferredFormat,
- n, e);
- }
-
- /**
- * A class method that takes the output of the encodePublicKey()
- * method of an RSA keypair codec object (an instance implementing
- * {@link IKeyPairCodec} for RSA keys, and re-constructs an instance of this
- * object.
- *
- * @param k the contents of a previously encoded instance of this object.
- * @throws ArrayIndexOutOfBoundsException if there is not enough bytes, in
- * k
, to represent a valid encoding of an instance
- * of this object.
- * @throws IllegalArgumentException if the byte sequence does not represent a
- * valid encoding of an instance of this object.
- */
- public static GnuRSAPublicKey valueOf(final byte[] k)
- {
- // try RAW codec
- if (k[0] == Registry.MAGIC_RAW_RSA_PUBLIC_KEY[0])
- try
- {
- return (GnuRSAPublicKey) new RSAKeyPairRawCodec().decodePublicKey(k);
- }
- catch (IllegalArgumentException ignored)
- {
- }
- // try X.509 codec
- return (GnuRSAPublicKey) new RSAKeyPairX509Codec().decodePublicKey(k);
- }
-
- /**
- * Returns the encoded form of this public key according to the designated
- * format.
- *
- * @param format the desired format identifier of the resulting encoding.
- * @return the byte sequence encoding this key according to the designated
- * format.
- * @throws IllegalArgumentException if the format is not supported.
- * @see RSAKeyPairRawCodec
- */
- public byte[] getEncoded(final int format)
- {
- final byte[] result;
- switch (format)
- {
- case IKeyPairCodec.RAW_FORMAT:
- result = new RSAKeyPairRawCodec().encodePublicKey(this);
- break;
- case IKeyPairCodec.X509_FORMAT:
- result = new RSAKeyPairX509Codec().encodePublicKey(this);
- break;
- default:
- throw new IllegalArgumentException("Unsupported encoding format: "
- + format);
- }
- return result;
- }
-
- /**
- * Returns true
if the designated object is an instance of this
- * class and has the same RSA parameter values as this one.
- *
- * @param obj the other non-null RSA key to compare to.
- * @return true
if the designated object is of the same type
- * and value as this one.
- */
- public boolean equals(final Object obj)
- {
- if (obj == null)
- return false;
-
- if (! (obj instanceof RSAPublicKey))
- return false;
-
- final RSAPublicKey that = (RSAPublicKey) obj;
- return super.equals(that)
- && getPublicExponent().equals(that.getPublicExponent());
- }
-
- public String toString()
- {
- if (str == null)
- {
- String ls = (String) AccessController.doPrivileged
- (new GetPropertyAction("line.separator"));
- str = new StringBuilder(this.getClass().getName()).append("(")
- .append(super.toString()).append(",").append(ls)
- .append(")")
- .toString();
- }
- return str;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairGenerator.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairGenerator.java
deleted file mode 100644
index c31cc4cc..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairGenerator.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/* RSAKeyPairGenerator.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.Registry;
-import gnu.java.security.key.IKeyPairGenerator;
-import gnu.java.security.util.PRNG;
-
-import java.math.BigInteger;
-import java.security.KeyPair;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.SecureRandom;
-import java.security.spec.RSAKeyGenParameterSpec;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/**
- * A key-pair generator for asymetric keys to use in conjunction with the RSA
- * scheme.
- *
- * Reference:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B. Primitive specification
- * and supporting documentation. Jakob Jonsson and Burt Kaliski.
- * - Handbook of Applied
- * Cryptography, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
- * Vanstone. Section 11.3 RSA and related signature schemes.
- *
- */
-public class RSAKeyPairGenerator
- implements IKeyPairGenerator
-{
- private static final Logger log = Logger.getLogger(RSAKeyPairGenerator.class.getName());
-
- /** The BigInteger constant 1. */
- private static final BigInteger ONE = BigInteger.ONE;
-
- /** The BigInteger constant 2. */
- private static final BigInteger TWO = BigInteger.valueOf(2L);
-
- /** Property name of the length (Integer) of the modulus of an RSA key. */
- public static final String MODULUS_LENGTH = "gnu.crypto.rsa.L";
-
- /**
- * Property name of an optional {@link SecureRandom} instance to use. The
- * default is to use a classloader singleton from {@link PRNG}.
- */
- public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.rsa.prng";
-
- /**
- * Property name of an optional {@link RSAKeyGenParameterSpec} instance to use
- * for this generator's n
, and e
values. The
- * default is to generate n
and use a fixed value for
- * e (Fermat's F4 number).
- */
- public static final String RSA_PARAMETERS = "gnu.crypto.rsa.params";
-
- /**
- * Property name of the preferred encoding format to use when externalizing
- * generated instance of key-pairs from this generator. The property is taken
- * to be an {@link Integer} that encapsulates an encoding format identifier.
- */
- public static final String PREFERRED_ENCODING_FORMAT = "gnu.crypto.rsa.encoding";
-
- /** Default value for the modulus length. */
- private static final int DEFAULT_MODULUS_LENGTH = 1024;
-
- /** Default encoding format to use when none was specified. */
- private static final int DEFAULT_ENCODING_FORMAT = Registry.RAW_ENCODING_ID;
-
- /** The desired bit length of the modulus. */
- private int L;
-
- /**
- * This implementation uses, by default, Fermat's F4 number as the public
- * exponent.
- */
- private BigInteger e = BigInteger.valueOf(65537L);
-
- /** The optional {@link SecureRandom} instance to use. */
- private SecureRandom rnd = null;
-
- /** Our default source of randomness. */
- private PRNG prng = null;
-
- /** Preferred encoding format of generated keys. */
- private int preferredFormat;
-
- // implicit 0-arguments constructor
-
- public String name()
- {
- return Registry.RSA_KPG;
- }
-
- /**
- * Configures this instance.
- *
- * @param attributes the map of name/value pairs to use.
- * @exception IllegalArgumentException if the designated MODULUS_LENGTH value
- * is less than 1024.
- */
- public void setup(Map attributes)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "setup", attributes);
- // do we have a SecureRandom, or should we use our own?
- rnd = (SecureRandom) attributes.get(SOURCE_OF_RANDOMNESS);
- // are we given a set of RSA params or we shall use our own?
- RSAKeyGenParameterSpec params = (RSAKeyGenParameterSpec) attributes.get(RSA_PARAMETERS);
- // find out the modulus length
- if (params != null)
- {
- L = params.getKeysize();
- e = params.getPublicExponent();
- }
- else
- {
- Integer l = (Integer) attributes.get(MODULUS_LENGTH);
- L = (l == null ? DEFAULT_MODULUS_LENGTH : l.intValue());
- }
- if (L < 1024)
- throw new IllegalArgumentException(MODULUS_LENGTH);
-
- // what is the preferred encoding format
- Integer formatID = (Integer) attributes.get(PREFERRED_ENCODING_FORMAT);
- preferredFormat = formatID == null ? DEFAULT_ENCODING_FORMAT
- : formatID.intValue();
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "setup");
- }
-
- /**
- *
- * The algorithm used here is described in nessie-pss-B.pdf document
- * which is part of the RSA-PSS submission to NESSIE.
- *
- *
- * @return an RSA keypair.
- */
- public KeyPair generate()
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "generate");
- BigInteger p, q, n, d;
- // 1. Generate a prime p in the interval [2**(M-1), 2**M - 1], where
- // M = CEILING(L/2), and such that GCD(p, e) = 1
- int M = (L + 1) / 2;
- BigInteger lower = TWO.pow(M - 1);
- BigInteger upper = TWO.pow(M).subtract(ONE);
- byte[] kb = new byte[(M + 7) / 8]; // enough bytes to frame M bits
- step1: while (true)
- {
- nextRandomBytes(kb);
- p = new BigInteger(1, kb).setBit(0);
- if (p.compareTo(lower) >= 0 && p.compareTo(upper) <= 0
- && p.isProbablePrime(80) && p.gcd(e).equals(ONE))
- break step1;
- }
- // 2. Generate a prime q such that the product of p and q is an L-bit
- // number, and such that GCD(q, e) = 1
- step2: while (true)
- {
- nextRandomBytes(kb);
- q = new BigInteger(1, kb).setBit(0);
- n = p.multiply(q);
- if (n.bitLength() == L && q.isProbablePrime(80) && q.gcd(e).equals(ONE))
- break step2;
- // TODO: test for p != q
- }
- // TODO: ensure p < q
- // 3. Put n = pq. The public key is (n, e).
- // 4. Compute the parameters necessary for the private key K (see
- // Section 2.2).
- BigInteger phi = p.subtract(ONE).multiply(q.subtract(ONE));
- d = e.modInverse(phi);
- // 5. Output the public key and the private key.
- PublicKey pubK = new GnuRSAPublicKey(preferredFormat, n, e);
- PrivateKey secK = new GnuRSAPrivateKey(preferredFormat, p, q, e, d);
- KeyPair result = new KeyPair(pubK, secK);
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "generate", result);
- return result;
- }
-
- /**
- * Fills the designated byte array with random data.
- *
- * @param buffer the byte array to fill with random data.
- */
- private void nextRandomBytes(byte[] buffer)
- {
- if (rnd != null)
- rnd.nextBytes(buffer);
- else
- getDefaultPRNG().nextBytes(buffer);
- }
-
- private PRNG getDefaultPRNG()
- {
- if (prng == null)
- prng = PRNG.getInstance();
-
- return prng;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
deleted file mode 100644
index 7a51d0a0..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairPKCS8Codec.java
+++ /dev/null
@@ -1,299 +0,0 @@
-/* RSAKeyPairPKCS8Codec.java -- PKCS#8 Encoding/Decoding handler
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.OID;
-import gnu.java.security.Registry;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.der.DERWriter;
-import gnu.java.security.key.IKeyPairCodec;
-import gnu.java.security.util.DerUtil;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.ArrayList;
-import java.util.logging.Logger;
-
-/**
- * An implementation of an {@link IKeyPairCodec} that knows how to encode /
- * decode PKCS#8 ASN.1 external representation of RSA private keys.
- */
-public class RSAKeyPairPKCS8Codec
- implements IKeyPairCodec
-{
- private static final Logger log = Logger.getLogger(RSAKeyPairPKCS8Codec.class.getName());
- private static final OID RSA_ALG_OID = new OID(Registry.RSA_OID_STRING);
-
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return PKCS8_FORMAT;
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public byte[] encodePublicKey(PublicKey key)
- {
- throw new InvalidParameterException("Wrong format for public keys");
- }
-
- /**
- * Returns the PKCS#8 ASN.1 PrivateKeyInfo representation of an RSA
- * private key. The ASN.1 specification is as follows:
- *
- * PrivateKeyInfo ::= SEQUENCE {
- * version INTEGER, -- MUST be 0
- * privateKeyAlgorithm AlgorithmIdentifier,
- * privateKey OCTET STRING
- * }
- *
- * AlgorithmIdentifier ::= SEQUENCE {
- * algorithm OBJECT IDENTIFIER,
- * parameters ANY DEFINED BY algorithm OPTIONAL
- * }
- *
- *
- * As indicated in RFC-2459: "The parameters field shall have ASN.1 type NULL
- * for this algorithm identifier.".
- *
- * The privateKey field, which is an OCTET STRING, contains the
- * DER-encoded form of the RSA private key defined as:
- *
- * RSAPrivateKey ::= SEQUENCE {
- * version INTEGER, -- MUST be 0
- * modulus INTEGER, -- n
- * publicExponent INTEGER, -- e
- * privateExponent INTEGER, -- d
- * prime1 INTEGER, -- p
- * prime2 INTEGER, -- q
- * exponent1 INTEGER, -- d mod (p-1)
- * exponent2 INTEGER, -- d mod (q-1)
- * coefficient INTEGER, -- (inverse of q) mod p
- * }
- *
- *
- * @return the DER encoded form of the ASN.1 representation of the
- * PrivateKeyInfo field for an RSA {@link PrivateKey}..
- * @throw InvalidParameterException if an error occurs during the marshalling
- * process.
- */
- public byte[] encodePrivateKey(PrivateKey key)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "encodePrivateKey()", key);
- if (! (key instanceof GnuRSAPrivateKey))
- throw new InvalidParameterException("Wrong key type");
-
- GnuRSAPrivateKey pk = (GnuRSAPrivateKey) key;
- BigInteger n = pk.getN();
- BigInteger e = pk.getE();
- BigInteger d = pk.getPrivateExponent();
- BigInteger p = pk.getPrimeP();
- BigInteger q = pk.getPrimeQ();
- BigInteger dP = pk.getPrimeExponentP();
- BigInteger dQ = pk.getPrimeExponentQ();
- BigInteger qInv = pk.getCrtCoefficient();
-
- DERValue derVersion = new DERValue(DER.INTEGER, BigInteger.ZERO);
-
- DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, RSA_ALG_OID);
-
- ArrayList algorithmID = new ArrayList(2);
- algorithmID.add(derOID);
- algorithmID.add(new DERValue(DER.NULL, null));
- DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- algorithmID);
-
- DERValue derRSAVersion = new DERValue(DER.INTEGER, BigInteger.ZERO);
- DERValue derN = new DERValue(DER.INTEGER, n);
- DERValue derE = new DERValue(DER.INTEGER, e);
- DERValue derD = new DERValue(DER.INTEGER, d);
- DERValue derP = new DERValue(DER.INTEGER, p);
- DERValue derQ = new DERValue(DER.INTEGER, q);
- DERValue derDP = new DERValue(DER.INTEGER, dP);
- DERValue derDQ = new DERValue(DER.INTEGER, dQ);
- DERValue derQInv = new DERValue(DER.INTEGER, qInv);
-
- ArrayList rsaPrivateKey = new ArrayList();
- rsaPrivateKey.add(derRSAVersion);
- rsaPrivateKey.add(derN);
- rsaPrivateKey.add(derE);
- rsaPrivateKey.add(derD);
- rsaPrivateKey.add(derP);
- rsaPrivateKey.add(derQ);
- rsaPrivateKey.add(derDP);
- rsaPrivateKey.add(derDQ);
- rsaPrivateKey.add(derQInv);
- DERValue derRSAPrivateKey = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- rsaPrivateKey);
- byte[] pkBytes = derRSAPrivateKey.getEncoded();
- DERValue derPrivateKey = new DERValue(DER.OCTET_STRING, pkBytes);
-
- ArrayList pki = new ArrayList(3);
- pki.add(derVersion);
- pki.add(derAlgorithmID);
- pki.add(derPrivateKey);
- DERValue derPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, pki);
-
- byte[] result;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try
- {
- DERWriter.write(baos, derPKI);
- result = baos.toByteArray();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException();
- y.initCause(x);
- throw y;
- }
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "encodePrivateKey()", result);
- return result;
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public PublicKey decodePublicKey(byte[] input)
- {
- throw new InvalidParameterException("Wrong format for public keys");
- }
-
- /**
- * @param input the byte array to unmarshall into a valid RSA
- * {@link PrivateKey} instance. MUST NOT be null.
- * @return a new instance of a {@link GnuRSAPrivateKey} decoded from the
- * PrivateKeyInfo material fed as input
.
- * @throw InvalidParameterException if an exception occurs during the
- * unmarshalling process.
- */
- public PrivateKey decodePrivateKey(byte[] input)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "decodePrivateKey()", input);
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- BigInteger version, n, e, d, p, q, dP, dQ, qInv;
- DERReader der = new DERReader(input);
- try
- {
- DERValue derPKI = der.read();
- DerUtil.checkIsConstructed(derPKI, "Wrong PrivateKeyInfo field");
-
- DERValue derVersion = der.read();
- DerUtil.checkIsBigInteger(derVersion, "Wrong Version field");
- version = (BigInteger) derVersion.getValue();
- if (version.compareTo(BigInteger.ZERO) != 0)
- throw new InvalidParameterException("Unexpected Version: " + version);
-
- DERValue derAlgoritmID = der.read();
- DerUtil.checkIsConstructed(derAlgoritmID, "Wrong AlgorithmIdentifier field");
-
- DERValue derOID = der.read();
- OID algOID = (OID) derOID.getValue();
- if (! algOID.equals(RSA_ALG_OID))
- throw new InvalidParameterException("Unexpected OID: " + algOID);
-
- // rfc-2459 states that this field is OPTIONAL but NULL if/when present
- DERValue val = der.read();
- if (val.getTag() == DER.NULL)
- val = der.read();
-
- byte[] pkBytes = (byte[]) val.getValue();
- der = new DERReader(pkBytes);
- DERValue derRSAPrivateKey = der.read();
- DerUtil.checkIsConstructed(derRSAPrivateKey, "Wrong RSAPrivateKey field");
-
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong RSAPrivateKey Version field");
- version = (BigInteger) val.getValue();
- if (version.compareTo(BigInteger.ZERO) != 0)
- throw new InvalidParameterException("Unexpected RSAPrivateKey Version: "
- + version);
-
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong modulus field");
- n = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong publicExponent field");
- e = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong privateExponent field");
- d = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong prime1 field");
- p = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong prime2 field");
- q = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong exponent1 field");
- dP = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong exponent2 field");
- dQ = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong coefficient field");
- qInv = (BigInteger) val.getValue();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException();
- y.initCause(x);
- throw y;
- }
- PrivateKey result = new GnuRSAPrivateKey(Registry.PKCS8_ENCODING_ID,
- n, e, d, p, q, dP, dQ, qInv);
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "decodePrivateKey()", result);
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java
deleted file mode 100644
index 95220236..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairRawCodec.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/* RSAKeyPairRawCodec.java --
- Copyright 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.key.IKeyPairCodec;
-
-import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-
-/**
- * An object that implements the {@link IKeyPairCodec} interface for the Raw
- * format to use with RSA keypairs.
- */
-public class RSAKeyPairRawCodec
- implements IKeyPairCodec
-{
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return RAW_FORMAT;
- }
-
- /**
- * Returns the encoded form of the designated RSA public key according to the
- * Raw format supported by this library.
- *
- * The Raw format for an RSA public key, in this implementation, is a
- * byte sequence consisting of the following:
- *
- * - 4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PUBLIC_KEY},
- * - 1-byte version consisting of the constant: 0x01,
- * - 4-byte count of following bytes representing the RSA parameter
- *
n
(the modulus) in internet order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter n
,
- *
- * - 4-byte count of following bytes representing the RSA parameter
- *
e
(the public exponent) in internet order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter e
.
- *
- *
- *
- * @param key the key to encode.
- * @return the Raw format encoding of the designated key.
- * @exception IllegalArgumentException if the designated key is not an RSA
- * one.
- */
- public byte[] encodePublicKey(PublicKey key)
- {
- if (! (key instanceof GnuRSAPublicKey))
- throw new IllegalArgumentException("key");
-
- GnuRSAPublicKey rsaKey = (GnuRSAPublicKey) key;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // magic
- baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[0]);
- baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[1]);
- baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[2]);
- baos.write(Registry.MAGIC_RAW_RSA_PUBLIC_KEY[3]);
- // version
- baos.write(0x01);
- // n
- byte[] buffer = rsaKey.getModulus().toByteArray();
- int length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- // e
- buffer = rsaKey.getPublicExponent().toByteArray();
- length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- return baos.toByteArray();
- }
-
- public PublicKey decodePublicKey(byte[] k)
- {
- // magic
- if (k[0] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[0]
- || k[1] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[1]
- || k[2] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[2]
- || k[3] != Registry.MAGIC_RAW_RSA_PUBLIC_KEY[3])
- throw new IllegalArgumentException("magic");
-
- // version
- if (k[4] != 0x01)
- throw new IllegalArgumentException("version");
-
- int i = 5;
- int l;
- byte[] buffer;
- // n
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger n = new BigInteger(1, buffer);
- // e
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger e = new BigInteger(1, buffer);
- return new GnuRSAPublicKey(n, e);
- }
-
- /**
- * Returns the encoded form of the designated RSA private key according to the
- * Raw format supported by this library.
- *
- * The Raw format for an RSA private key, in this implementation, is a
- * byte sequence consisting of the following:
- *
- * - 4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PRIVATE_KEY},
- * - 1-byte version consisting of the constant: 0x01,
- * - 4-byte count of following bytes representing the RSA parameter
- *
p
(the first prime factor of the modulus) in internet order,
- *
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter p
,
- *
- * - 4-byte count of following bytes representing the RSA parameter
- *
q
(the second prime factor of the modulus) in internet
- * order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter q
,
- *
- * - 4-byte count of following bytes representing the RSA parameter
- *
e
(the public exponent) in internet order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter e
,
- *
- * - 4-byte count of following bytes representing the RSA parameter
- *
d
(the private exponent) in internet order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the RSA parameter d
,
- *
- *
- *
- * @param key the key to encode.
- * @return the Raw format encoding of the designated key.
- */
- public byte[] encodePrivateKey(PrivateKey key)
- {
- if (! (key instanceof GnuRSAPrivateKey))
- throw new IllegalArgumentException("key");
-
- GnuRSAPrivateKey rsaKey = (GnuRSAPrivateKey) key;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // magic
- baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[0]);
- baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[1]);
- baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[2]);
- baos.write(Registry.MAGIC_RAW_RSA_PRIVATE_KEY[3]);
- // version
- baos.write(0x01);
- // p
- byte[] buffer = rsaKey.getPrimeP().toByteArray();
- int length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- // q
- buffer = rsaKey.getPrimeQ().toByteArray();
- length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- // e
- buffer = rsaKey.getPublicExponent().toByteArray();
- length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- // d
- buffer = rsaKey.getPrivateExponent().toByteArray();
- length = buffer.length;
- baos.write(length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- return baos.toByteArray();
- }
-
- public PrivateKey decodePrivateKey(byte[] k)
- {
- // magic
- if (k[0] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[0]
- || k[1] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[1]
- || k[2] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[2]
- || k[3] != Registry.MAGIC_RAW_RSA_PRIVATE_KEY[3])
- throw new IllegalArgumentException("magic");
-
- // version
- if (k[4] != 0x01)
- throw new IllegalArgumentException("version");
-
- int i = 5;
- int l;
- byte[] buffer;
- // p
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger p = new BigInteger(1, buffer);
- // q
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger q = new BigInteger(1, buffer);
- // e
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger e = new BigInteger(1, buffer);
- // d
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger d = new BigInteger(1, buffer);
- return new GnuRSAPrivateKey(p, q, e, d);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java b/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java
deleted file mode 100644
index b11e1c01..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/key/rsa/RSAKeyPairX509Codec.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/* RSAKeyPairX509Codec.java -- X.509 Encoding/Decoding handler
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.key.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.OID;
-import gnu.java.security.Registry;
-import gnu.java.security.der.BitString;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.der.DERWriter;
-import gnu.java.security.key.IKeyPairCodec;
-import gnu.java.security.util.DerUtil;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidParameterException;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.ArrayList;
-import java.util.logging.Logger;
-
-/**
- * An implementation of an {@link IKeyPairCodec} that knows how to encode /
- * decode X.509 ASN.1 external representation of RSA public keys.
- */
-public class RSAKeyPairX509Codec
- implements IKeyPairCodec
-{
- private static final Logger log = Logger.getLogger(RSAKeyPairX509Codec.class.getName());
- private static final OID RSA_ALG_OID = new OID(Registry.RSA_OID_STRING);
-
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return X509_FORMAT;
- }
-
- /**
- * Returns the X.509 ASN.1 SubjectPublicKeyInfo representation of an
- * RSA public key. The ASN.1 specification, as defined in RFC-3280, and
- * RFC-2459, is as follows:
- *
- *
- * SubjectPublicKeyInfo ::= SEQUENCE {
- * algorithm AlgorithmIdentifier,
- * subjectPublicKey BIT STRING
- * }
- *
- * AlgorithmIdentifier ::= SEQUENCE {
- * algorithm OBJECT IDENTIFIER,
- * parameters ANY DEFINED BY algorithm OPTIONAL
- * }
- *
- *
- * As indicated in RFC-2459: "The parameters field shall have ASN.1 type NULL
- * for this algorithm identifier.".
- *
- * The subjectPublicKey field, which is a BIT STRING, contains the
- * DER-encoded form of the RSA public key defined as:
- *
- *
- * RSAPublicKey ::= SEQUENCE {
- * modulus INTEGER, -- n
- * publicExponent INTEGER -- e
- * }
- *
- *
- * @param key the {@link PublicKey} instance to encode. MUST be an instance of
- * {@link GnuRSAPublicKey}.
- * @return the ASN.1 representation of the SubjectPublicKeyInfo in an
- * X.509 certificate.
- * @throw InvalidParameterException if key
is not an instance
- * of {@link GnuRSAPublicKey} or if an exception occurs during the
- * marshalling process.
- */
- public byte[] encodePublicKey(PublicKey key)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "encodePublicKey()", key);
- if (! (key instanceof GnuRSAPublicKey))
- throw new InvalidParameterException("key");
-
- DERValue derOID = new DERValue(DER.OBJECT_IDENTIFIER, RSA_ALG_OID);
-
- GnuRSAPublicKey rsaKey = (GnuRSAPublicKey) key;
- BigInteger n = rsaKey.getN();
- BigInteger e = rsaKey.getE();
-
- DERValue derN = new DERValue(DER.INTEGER, n);
- DERValue derE = new DERValue(DER.INTEGER, e);
-
- ArrayList algorithmID = new ArrayList(2);
- algorithmID.add(derOID);
- algorithmID.add(new DERValue(DER.NULL, null));
- DERValue derAlgorithmID = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- algorithmID);
-
- ArrayList publicKey = new ArrayList(2);
- publicKey.add(derN);
- publicKey.add(derE);
- DERValue derPublicKey = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- publicKey);
- byte[] spkBytes = derPublicKey.getEncoded();
- DERValue derSPK = new DERValue(DER.BIT_STRING, new BitString(spkBytes));
-
- ArrayList spki = new ArrayList(2);
- spki.add(derAlgorithmID);
- spki.add(derSPK);
- DERValue derSPKI = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE, spki);
-
- byte[] result;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try
- {
- DERWriter.write(baos, derSPKI);
- result = baos.toByteArray();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException(x.getMessage());
- y.initCause(x);
- throw y;
- }
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "encodePublicKey()", result);
- return result;
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public byte[] encodePrivateKey(PrivateKey key)
- {
- throw new InvalidParameterException("Wrong format for private keys");
- }
-
- /**
- * @param input the byte array to unmarshall into a valid RSA
- * {@link PublicKey} instance. MUST NOT be null.
- * @return a new instance of a {@link GnuRSAPublicKey} decoded from the
- * SubjectPublicKeyInfo material in an X.509 certificate.
- * @throw InvalidParameterException if an exception occurs during the
- * unmarshalling process.
- */
- public PublicKey decodePublicKey(byte[] input)
- {
- if (Configuration.DEBUG)
- log.entering(this.getClass().getName(), "decodePublicKey()", input);
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- BigInteger n, e;
- DERReader der = new DERReader(input);
- try
- {
- DERValue derSPKI = der.read();
- DerUtil.checkIsConstructed(derSPKI, "Wrong SubjectPublicKeyInfo field");
-
- DERValue derAlgorithmID = der.read();
- DerUtil.checkIsConstructed(derAlgorithmID, "Wrong AlgorithmIdentifier field");
-
- DERValue derOID = der.read();
- if (! (derOID.getValue() instanceof OID))
- throw new InvalidParameterException("Wrong Algorithm field");
-
- OID algOID = (OID) derOID.getValue();
- if (! algOID.equals(RSA_ALG_OID))
- throw new InvalidParameterException("Unexpected OID: " + algOID);
-
- // rfc-2459 states that this field is OPTIONAL but NULL if/when present
- DERValue val = der.read();
- if (val.getTag() == DER.NULL)
- val = der.read();
-
- if (! (val.getValue() instanceof BitString))
- throw new InvalidParameterException("Wrong SubjectPublicKey field");
-
- byte[] spkBytes = ((BitString) val.getValue()).toByteArray();
-
- der = new DERReader(spkBytes);
- val = der.read();
- DerUtil.checkIsConstructed(derAlgorithmID, "Wrong subjectPublicKey field");
-
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong modulus field");
- n = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong publicExponent field");
- e = (BigInteger) val.getValue();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException(x.getMessage());
- y.initCause(x);
- throw y;
- }
- PublicKey result = new GnuRSAPublicKey(Registry.X509_ENCODING_ID, n, e);
- if (Configuration.DEBUG)
- log.exiting(this.getClass().getName(), "decodePublicKey()", result);
- return result;
- }
-
- /**
- * @throws InvalidParameterException ALWAYS.
- */
- public PrivateKey decodePrivateKey(byte[] input)
- {
- throw new InvalidParameterException("Wrong format for private keys");
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/BasePRNG.java b/openjdk/icedtea/jce/gnu/java/security/prng/BasePRNG.java
deleted file mode 100644
index 3b7c8cf0..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/BasePRNG.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/* BasePRNG.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import java.util.Map;
-
-/**
- * An abstract class to facilitate implementing PRNG algorithms.
- */
-public abstract class BasePRNG
- implements IRandom
-{
- /** The canonical name prefix of the PRNG algorithm. */
- protected String name;
-
- /** Indicate if this instance has already been initialised or not. */
- protected boolean initialised;
-
- /** A temporary buffer to serve random bytes. */
- protected byte[] buffer;
-
- /** The index into buffer of where the next byte will come from. */
- protected int ndx;
-
- /**
- * Trivial constructor for use by concrete subclasses.
- *
- * @param name the canonical name of this instance.
- */
- protected BasePRNG(String name)
- {
- super();
-
- this.name = name;
- initialised = false;
- buffer = new byte[0];
- }
-
- public String name()
- {
- return name;
- }
-
- public void init(Map attributes)
- {
- this.setup(attributes);
-
- ndx = 0;
- initialised = true;
- }
-
- public byte nextByte() throws IllegalStateException, LimitReachedException
- {
- if (! initialised)
- throw new IllegalStateException();
-
- return nextByteInternal();
- }
-
- public void nextBytes(byte[] out) throws IllegalStateException,
- LimitReachedException
- {
- nextBytes(out, 0, out.length);
- }
-
- public void nextBytes(byte[] out, int offset, int length)
- throws IllegalStateException, LimitReachedException
- {
- if (! initialised)
- throw new IllegalStateException("not initialized");
-
- if (length == 0)
- return;
-
- if (offset < 0 || length < 0 || offset + length > out.length)
- throw new ArrayIndexOutOfBoundsException("offset=" + offset + " length="
- + length + " limit="
- + out.length);
- if (ndx >= buffer.length)
- {
- fillBlock();
- ndx = 0;
- }
- int count = 0;
- while (count < length)
- {
- int amount = Math.min(buffer.length - ndx, length - count);
- System.arraycopy(buffer, ndx, out, offset + count, amount);
- count += amount;
- ndx += amount;
- if (ndx >= buffer.length)
- {
- fillBlock();
- ndx = 0;
- }
- }
- }
-
- public void addRandomByte(byte b)
- {
- throw new UnsupportedOperationException("random state is non-modifiable");
- }
-
- public void addRandomBytes(byte[] buffer)
- {
- addRandomBytes(buffer, 0, buffer.length);
- }
-
- public void addRandomBytes(byte[] buffer, int offset, int length)
- {
- throw new UnsupportedOperationException("random state is non-modifiable");
- }
-
- public boolean isInitialised()
- {
- return initialised;
- }
-
- private byte nextByteInternal() throws LimitReachedException
- {
- if (ndx >= buffer.length)
- {
- this.fillBlock();
- ndx = 0;
- }
-
- return buffer[ndx++];
- }
-
- public Object clone() throws CloneNotSupportedException
- {
- BasePRNG result = (BasePRNG) super.clone();
- if (this.buffer != null)
- result.buffer = (byte[]) this.buffer.clone();
-
- return result;
- }
-
- public abstract void setup(Map attributes);
-
- public abstract void fillBlock() throws LimitReachedException;
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/EntropySource.java b/openjdk/icedtea/jce/gnu/java/security/prng/EntropySource.java
deleted file mode 100644
index 95f68f04..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/EntropySource.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* EntropySource.java --
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-/**
- * A generic interface for adding random bytes to an entropy pool.
- */
-public interface EntropySource
-{
- /**
- * Returns the estimated quality of this source. This value should be
- * between 0 and 100 (the running quality is computed as a percentage,
- * 100 percent being perfect-quality).
- *
- * @return The quality.
- */
- double quality();
-
- /**
- * Returns a new buffer with the next random bytes to add.
- *
- * @return The next random bytes.
- */
- byte[] nextBytes();
-}
\ No newline at end of file
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/IRandom.java b/openjdk/icedtea/jce/gnu/java/security/prng/IRandom.java
deleted file mode 100644
index 66ad6d22..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/IRandom.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/* IRandom.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import java.util.Map;
-
-/**
- * The basic visible methods of any pseudo-random number generator.
- *
- * The [HAC] defines a PRNG (as implemented in this library) as follows:
- *
- * - "5.6 Definition: A pseudorandom bit generator (PRBG) is said to pass the
- * next-bit test if there is no polynomial-time algorithm which, on
- * input of the first
L
bits of an output sequence S
,
- * can predict the (L+1)
st bit of S
with a
- * probability significantly greater than 1/2
."
- * - "5.8 Definition: A PRBG that passes the next-bit test
- * (possibly under some plausible but unproved mathematical assumption such as
- * the intractability of factoring integers) is called a cryptographically
- * secure pseudorandom bit generator (CSPRBG)."
- *
- *
- * IMPLEMENTATION NOTE: Although all the concrete classes in this
- * package implement the {@link Cloneable} interface, it is important to note
- * here that such an operation, for those algorithms that use an underlying
- * symmetric key block cipher, DOES NOT clone any session key material
- * that may have been used in initialising the source PRNG (the instance to be
- * cloned). Instead a clone of an already initialised PRNG, that uses an
- * underlying symmetric key block cipher, is another instance with a clone of
- * the same cipher that operates with the same block size but without
- * any knowledge of neither key material nor key size.
- *
- * References:
- *
- * - [HAC]: Handbook of
- * Applied Cryptography.
- * CRC Press, Inc. ISBN 0-8493-8523-7, 1997
- * Menezes, A., van Oorschot, P. and S. Vanstone.
- *
- */
-public interface IRandom
- extends Cloneable
-{
- /**
- * Returns the canonical name of this instance.
- *
- * @return the canonical name of this instance.
- */
- String name();
-
- /**
- * Initialises the pseudo-random number generator scheme with the appropriate
- * attributes.
- *
- * @param attributes a set of name-value pairs that describe the desired
- * future instance behaviour.
- * @exception IllegalArgumentException if at least one of the defined name/
- * value pairs contains invalid data.
- */
- void init(Map attributes);
-
- /**
- * Returns the next 8 bits of random data generated from this instance.
- *
- * @return the next 8 bits of random data generated from this instance.
- * @exception IllegalStateException if the instance is not yet initialised.
- * @exception LimitReachedException if this instance has reached its
- * theoretical limit for generating non-repetitive pseudo-random
- * data.
- */
- byte nextByte() throws IllegalStateException, LimitReachedException;
-
- /**
- * Fills the designated byte array, starting from byte at index
- * offset
, for a maximum of length
bytes with
- * the output of this generator instance.
- *
- * @param out the placeholder to contain the generated random bytes.
- * @param offset the starting index in out to consider. This method
- * does nothing if this parameter is not within 0
and
- * out.length
.
- * @param length the maximum number of required random bytes. This method does
- * nothing if this parameter is less than 1
.
- * @exception IllegalStateException if the instance is not yet initialised.
- * @exception LimitReachedException if this instance has reached its
- * theoretical limit for generating non-repetitive pseudo-random
- * data.
- */
- void nextBytes(byte[] out, int offset, int length)
- throws IllegalStateException, LimitReachedException;
-
- /**
- * Supplement, or possibly replace, the random state of this PRNG with a
- * random byte.
- *
- * Implementations are not required to implement this method in any meaningful
- * way; this may be a no-operation, and implementations may throw an
- * {@link UnsupportedOperationException}.
- *
- * @param b The byte to add.
- */
- void addRandomByte(byte b);
-
- /**
- * Supplement, or possibly replace, the random state of this PRNG with a
- * sequence of new random bytes.
- *
- * Implementations are not required to implement this method in any meaningful
- * way; this may be a no-operation, and implementations may throw an
- * {@link UnsupportedOperationException}.
- *
- * @param in The buffer of new random bytes to add.
- */
- void addRandomBytes(byte[] in);
-
- /**
- * Supplement, or possibly replace, the random state of this PRNG with a
- * sequence of new random bytes.
- *
- * Implementations are not required to implement this method in any meaningful
- * way; this may be a no-operation, and implementations may throw an
- * {@link UnsupportedOperationException}.
- *
- * @param in The buffer of new random bytes to add.
- * @param offset The offset from whence to begin reading random bytes.
- * @param length The number of random bytes to add.
- * @exception IndexOutOfBoundsException If offset, length, or
- * offset+length is out of bounds.
- */
- void addRandomBytes(byte[] in, int offset, int length);
-
- /**
- * Returns a clone copy of this instance.
- *
- * @return a clone copy of this instance.
- */
- Object clone() throws CloneNotSupportedException;
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/LimitReachedException.java b/openjdk/icedtea/jce/gnu/java/security/prng/LimitReachedException.java
deleted file mode 100644
index 8d5b30ba..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/LimitReachedException.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/* LimitReachedException.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-/**
- * A checked exception that indicates that a pseudo random number generated has
- * reached its theoretical limit in generating random bytes.
- */
-public class LimitReachedException
- extends Exception
-{
- public LimitReachedException()
- {
- super();
- }
-
- public LimitReachedException(String msg)
- {
- super(msg);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/MDGenerator.java b/openjdk/icedtea/jce/gnu/java/security/prng/MDGenerator.java
deleted file mode 100644
index 574a2f9d..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/MDGenerator.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/* MDGenerator.java --
- Copyright (C) 2001, 2002, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-
-import java.util.Map;
-
-/**
- * A simple pseudo-random number generator that relies on a hash algorithm, that
- * (a) starts its operation by hashing a seed
, and then (b)
- * continuously re-hashing its output. If no hash algorithm name is specified in
- * the {@link Map} of attributes used to initialise the instance then the
- * SHA-160 algorithm is used as the underlying hash function. Also, if no
- * seed
is given, an empty octet sequence is used.
- */
-public class MDGenerator
- extends BasePRNG
- implements Cloneable
-{
- /** Property name of underlying hash algorithm for this generator. */
- public static final String MD_NAME = "gnu.crypto.prng.md.hash.name";
-
- /** Property name of seed material. */
- public static final String SEEED = "gnu.crypto.prng.md.seed";
-
- /** The underlying hash instance. */
- private IMessageDigest md;
-
- /** Trivial 0-arguments constructor. */
- public MDGenerator()
- {
- super(Registry.MD_PRNG);
- }
-
- public void setup(Map attributes)
- {
- // find out which hash to use
- String underlyingMD = (String) attributes.get(MD_NAME);
- if (underlyingMD == null)
- {
- if (md == null)
- { // happy birthday
- // ensure we have a reliable implementation of this hash
- md = HashFactory.getInstance(Registry.SHA160_HASH);
- }
- else // a clone. reset it for reuse
- md.reset();
- }
- else // ensure we have a reliable implementation of this hash
- md = HashFactory.getInstance(underlyingMD);
- // get the seeed
- byte[] seed = (byte[]) attributes.get(SEEED);
- if (seed == null)
- seed = new byte[0];
-
- md.update(seed, 0, seed.length);
- }
-
- public void fillBlock() throws LimitReachedException
- {
- IMessageDigest mdc = (IMessageDigest) md.clone();
- buffer = mdc.digest();
- md.update(buffer, 0, buffer.length);
- }
-
- public void addRandomByte(final byte b)
- {
- if (md == null)
- throw new IllegalStateException("not initialized");
- md.update(b);
- }
-
- public void addRandomBytes(final byte[] buf, final int off, final int len)
- {
- if (md == null)
- throw new IllegalStateException("not initialized");
- md.update(buf, off, len);
- }
-
- public Object clone() throws CloneNotSupportedException
- {
- MDGenerator result = (MDGenerator) super.clone();
- if (this.md != null)
- result.md = (IMessageDigest) this.md.clone();
-
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/PRNGFactory.java b/openjdk/icedtea/jce/gnu/java/security/prng/PRNGFactory.java
deleted file mode 100644
index ae15d053..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/PRNGFactory.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/* PRNGFactory.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import gnu.java.security.Registry;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A Factory to instantiate pseudo random number generators.
- */
-public class PRNGFactory
- implements Registry
-{
- /** Trivial constructor to enforce Singleton pattern. */
- protected PRNGFactory()
- {
- }
-
- /**
- * Returns an instance of a padding algorithm given its name.
- *
- * @param prng the case-insensitive name of the PRNG.
- * @return an instance of the pseudo-random number generator.
- * @exception InternalError if the implementation does not pass its self-
- * test.
- */
- public static final IRandom getInstance(String prng)
- {
- if (prng == null)
- return null;
-
- prng = prng.trim();
- IRandom result = null;
- if (prng.equalsIgnoreCase(MD_PRNG))
- result = new MDGenerator();
-
- return result;
- }
-
- /**
- * Returns a {@link Set} of names of padding algorithms supported by this
- * Factory.
- *
- * @return a {@link Set} of pseudo-random number generator algorithm names
- * (Strings).
- */
- public static final Set getNames()
- {
- HashSet hs = new HashSet();
- hs.add(MD_PRNG);
- return Collections.unmodifiableSet(hs);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/RandomEvent.java b/openjdk/icedtea/jce/gnu/java/security/prng/RandomEvent.java
deleted file mode 100644
index fc4607a8..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/RandomEvent.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/* RandomEvent.java -- an event with random data.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import java.util.EventObject;
-
-/**
- * A type for entropy accumulators that will be notified of random events.
- */
-public class RandomEvent
- extends EventObject
-{
- private final byte sourceNumber;
-
- private final byte poolNumber;
-
- private final byte[] data;
-
- public RandomEvent(Object source, byte sourceNumber, byte poolNumber,
- byte[] data)
- {
- super(source);
- this.sourceNumber = sourceNumber;
- this.poolNumber = poolNumber;
- if (data.length == 0 || data.length > 32)
- throw new IllegalArgumentException(
- "random events take between 1 and 32 bytes of data");
- this.data = (byte[]) data.clone();
- }
-
- public byte getSourceNumber()
- {
- return sourceNumber;
- }
-
- public byte getPoolNumber()
- {
- return poolNumber;
- }
-
- public byte[] getData()
- {
- return data;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/prng/RandomEventListener.java b/openjdk/icedtea/jce/gnu/java/security/prng/RandomEventListener.java
deleted file mode 100644
index beb9087f..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/prng/RandomEventListener.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/* RandomEventListener.java --
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.prng;
-
-import java.util.EventListener;
-
-/**
- * An interface for entropy accumulators that will be notified of random events.
- */
-public interface RandomEventListener
- extends EventListener
-{
- void addRandomEvent(RandomEvent event);
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/CollectionCertStoreImpl.java b/openjdk/icedtea/jce/gnu/java/security/provider/CollectionCertStoreImpl.java
deleted file mode 100644
index 4bf3d543..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/CollectionCertStoreImpl.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/* CollectionCertStore.java -- Collection-based cert store.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.provider;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.cert.CRL;
-import java.security.cert.CRLSelector;
-import java.security.cert.CertSelector;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertStoreParameters;
-import java.security.cert.CertStoreSpi;
-import java.security.cert.Certificate;
-import java.security.cert.CollectionCertStoreParameters;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-
-public final class CollectionCertStoreImpl extends CertStoreSpi
-{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private final Collection store;
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public CollectionCertStoreImpl(CertStoreParameters params)
- throws InvalidAlgorithmParameterException
- {
- super(params);
- if (! (params instanceof CollectionCertStoreParameters))
- throw new InvalidAlgorithmParameterException("not a CollectionCertStoreParameters object");
- store = ((CollectionCertStoreParameters) params).getCollection();
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public Collection engineGetCertificates(CertSelector selector)
- throws CertStoreException
- {
- LinkedList result = new LinkedList();
- for (Iterator it = store.iterator(); it.hasNext(); )
- {
- Object o = it.next();
- if ((o instanceof Certificate) && selector.match((Certificate) o))
- result.add(o);
- }
- return result;
- }
-
- public Collection engineGetCRLs(CRLSelector selector)
- throws CertStoreException
- {
- LinkedList result = new LinkedList();
- for (Iterator it = store.iterator(); it.hasNext(); )
- {
- Object o = it.next();
- if ((o instanceof CRL) && selector.match((CRL) o))
- result.add(o);
- }
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/DefaultPolicy.java b/openjdk/icedtea/jce/gnu/java/security/provider/DefaultPolicy.java
deleted file mode 100644
index d42be6c9..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/DefaultPolicy.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* DefaultPolicy.java --
- Copyright (C) 2001, 2002 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.provider;
-
-import java.security.AllPermission;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.security.Policy;
-
-/**
- * This is just a stub policy implementation which grants all permissions
- * to any code source. FIXME: This should be replaced with a real
- * implementation that reads the policy configuration from a file, like
- * $JAVA_HOME/jre/lib/security/java.security.
- */
-public class DefaultPolicy extends Policy
-{
- static Permission allPermission = new AllPermission();
-
- public PermissionCollection getPermissions(CodeSource codesource)
- {
- Permissions perms = new Permissions();
- perms.add(allPermission);
- return perms;
- }
-
- public void refresh()
- {
- // Nothing.
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/Gnu.java b/openjdk/icedtea/jce/gnu/java/security/provider/Gnu.java
deleted file mode 100644
index 62bb0a29..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/Gnu.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/* Gnu.java --- Gnu provider main class
- Copyright (C) 1999, 2002, 2003, 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.provider;
-
-import java.security.AccessController;
-import java.security.PrivilegedAction;
-import java.security.Provider;
-
-public final class Gnu
- extends Provider
-{
- public Gnu()
- {
- super("GNU", 1.0,
- "GNU provider v1.0 implementing SHA-1, MD5, DSA, RSA, X.509 "
- + "Certificates and CRLs, PKIX certificate path validators, "
- + "Collection cert stores, Diffie-Hellman key agreement and "
- + "key pair generator");
- AccessController.doPrivileged (new PrivilegedAction()
- {
- public Object run()
- {
- // Note that all implementation class names are referenced by using
- // Class.getName(). That way when we staticly link the Gnu provider
- // we automatically get all the implementation classes.
-
- // Signature
- put("Signature.SHA160withDSS",
- gnu.java.security.jce.sig.SHA160withDSS.class.getName());
- put("Alg.Alias.Signature.SHA1withDSA", "SHA160withDSS");
- put("Alg.Alias.Signature.DSS", "SHA160withDSS");
- put("Alg.Alias.Signature.DSA", "SHA160withDSS");
- put("Alg.Alias.Signature.SHAwithDSA", "SHA160withDSS");
- put("Alg.Alias.Signature.DSAwithSHA", "SHA160withDSS");
- put("Alg.Alias.Signature.DSAwithSHA1", "SHA160withDSS");
- put("Alg.Alias.Signature.SHA/DSA", "SHA160withDSS");
- put("Alg.Alias.Signature.SHA-1/DSA", "SHA160withDSS");
- put("Alg.Alias.Signature.SHA1/DSA", "SHA160withDSS");
- put("Alg.Alias.Signature.OID.1.2.840.10040.4.3", "SHA160withDSS");
- put("Alg.Alias.Signature.1.2.840.10040.4.3", "SHA160withDSS");
- put("Alg.Alias.Signature.1.3.14.3.2.13", "SHA160withDSS");
- put("Alg.Alias.Signature.1.3.14.3.2.27", "SHA160withDSS");
-
- put("Signature.MD2withRSA",
- gnu.java.security.jce.sig.MD2withRSA.class.getName());
- put("Signature.MD2withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.md2WithRSAEncryption", "MD2withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.2", "MD2withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.2", "MD2withRSA");
-
- put("Signature.MD5withRSA",
- gnu.java.security.jce.sig.MD5withRSA.class.getName());
- put("Signature.MD5withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.md5WithRSAEncryption", "MD5withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.4", "MD5withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.4", "MD5withRSA");
- put("Alg.Alias.Signature.RSA", "MD5withRSA");
-
- put("Signature.SHA160withRSA",
- gnu.java.security.jce.sig.SHA160withRSA.class.getName());
- put("Signature.SHA160withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.sha-1WithRSAEncryption", "SHA160withRSA");
- put("Alg.Alias.Signature.sha-160WithRSAEncryption", "SHA160withRSA");
- put("Alg.Alias.Signature.sha1WithRSAEncryption", "SHA160withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.5", "SHA160withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.5", "SHA160withRSA");
- put("Alg.Alias.Signature.SHA1withRSA", "SHA160withRSA");
-
- put("Signature.SHA256withRSA",
- gnu.java.security.jce.sig.SHA256withRSA.class.getName());
- put("Signature.SHA160withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.sha256WithRSAEncryption", "SHA256withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.11", "SHA256withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.11", "SHA256withRSA");
-
- put("Signature.SHA384withRSA",
- gnu.java.security.jce.sig.SHA384withRSA.class.getName());
- put("Signature.SHA160withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.sha384WithRSAEncryption", "SHA384withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.12", "SHA384withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.12", "SHA384withRSA");
-
- put("Signature.SHA512withRSA",
- gnu.java.security.jce.sig.SHA512withRSA.class.getName());
- put("Signature.SHA160withRSA ImplementedIn", "Software");
- put("Alg.Alias.Signature.sha512WithRSAEncryption", "SHA512withRSA");
- put("Alg.Alias.Signature.OID.1.2.840.113549.1.1.13", "SHA512withRSA");
- put("Alg.Alias.Signature.1.2.840.113549.1.1.13", "SHA512withRSA");
-
- put("Signature.DSS/RAW",
- gnu.java.security.jce.sig.DSSRawSignatureSpi.class.getName());
- put("Signature.DSS/RAW KeySize", "1024");
- put("Signature.DSS/RAW ImplementedIn", "Software");
-
- put("Signature.RSA-PSS/RAW",
- gnu.java.security.jce.sig.RSAPSSRawSignatureSpi.class.getName());
- put("Signature.RSA-PSS/RAW KeySize", "1024");
- put("Signature.RSA-PSS/RAW ImplementedIn", "Software");
-
- // Key Pair Generator
- put("KeyPairGenerator.DSS",
- gnu.java.security.jce.sig.DSSKeyPairGeneratorSpi.class.getName());
- put("KeyPairGenerator.DSS KeySize", "1024");
- put("KeyPairGenerator.DSS ImplementedIn", "Software");
- put("Alg.Alias.KeyPairGenerator.DSA", "DSS");
- put("Alg.Alias.KeyPairGenerator.OID.1.2.840.10040.4.1", "DSS");
- put("Alg.Alias.KeyPairGenerator.1.2.840.10040.4.1", "DSS");
- put("Alg.Alias.KeyPairGenerator.1.3.14.3.2.12", "DSS");
-
- put("KeyPairGenerator.RSA",
- gnu.java.security.jce.sig.RSAKeyPairGeneratorSpi.class.getName());
- put("KeyPairGenerator.RSA KeySize", "1024");
- put("KeyPairGenerator.RSA ImplementedIn", "Software");
-
- // Key Factory
- put("KeyFactory.DSS",
- gnu.java.security.jce.sig.DSSKeyFactory.class.getName());
- put("Alg.Alias.KeyFactory.DSA", "DSS");
- put("Alg.Alias.KeyFactory.OID.1.2.840.10040.4.1", "DSS");
- put("Alg.Alias.KeyFactory.1.2.840.10040.4.1", "DSS");
- put("Alg.Alias.KeyFactory.1.3.14.3.2.12", "DSS");
-
- put("KeyFactory.RSA",
- gnu.java.security.jce.sig.RSAKeyFactory.class.getName());
-
- put("KeyFactory.Encoded",
- gnu.java.security.jce.sig.EncodedKeyFactory.class.getName());
- put("KeyFactory.Encoded ImplementedIn", "Software");
- put("Alg.Alias.KeyFactory.X.509", "Encoded");
- put("Alg.Alias.KeyFactory.X509", "Encoded");
- put("Alg.Alias.KeyFactory.PKCS#8", "Encoded");
- put("Alg.Alias.KeyFactory.PKCS8", "Encoded");
-
- put("MessageDigest.HAVAL",
- gnu.java.security.jce.hash.HavalSpi.class.getName());
- put("MessageDigest.HAVAL ImplementedIn", "Software");
- put("MessageDigest.MD2",
- gnu.java.security.jce.hash.MD2Spi.class.getName());
- put("MessageDigest.MD2 ImplementedIn", "Software");
- put("MessageDigest.MD4",
- gnu.java.security.jce.hash.MD4Spi.class.getName());
- put("MessageDigest.MD4 ImplementedIn", "Software");
- put("MessageDigest.MD5",
- gnu.java.security.jce.hash.MD5Spi.class.getName());
- put("MessageDigest.MD5 ImplementedIn", "Software");
- put("MessageDigest.RIPEMD128",
- gnu.java.security.jce.hash.RipeMD128Spi.class.getName());
- put("MessageDigest.RIPEMD128 ImplementedIn", "Software");
- put("MessageDigest.RIPEMD160",
- gnu.java.security.jce.hash.RipeMD160Spi.class.getName());
- put("MessageDigest.RIPEMD160 ImplementedIn", "Software");
- put("MessageDigest.SHA-160",
- gnu.java.security.jce.hash.Sha160Spi.class.getName());
- put("MessageDigest.SHA-160 ImplementedIn", "Software");
- put("MessageDigest.SHA-256",
- gnu.java.security.jce.hash.Sha256Spi.class.getName());
- put("MessageDigest.SHA-256 ImplementedIn", "Software");
- put("MessageDigest.SHA-384",
- gnu.java.security.jce.hash.Sha384Spi.class.getName());
- put("MessageDigest.SHA-384 ImplementedIn", "Software");
- put("MessageDigest.SHA-512",
- gnu.java.security.jce.hash.Sha512Spi.class.getName());
- put("MessageDigest.SHA-512 ImplementedIn", "Software");
- put("MessageDigest.TIGER",
- gnu.java.security.jce.hash.TigerSpi.class.getName());
- put("MessageDigest.TIGER ImplementedIn", "Software");
- put("MessageDigest.WHIRLPOOL",
- gnu.java.security.jce.hash.WhirlpoolSpi.class.getName());
- put("MessageDigest.WHIRLPOOL ImplementedIn", "Software");
-
- put("Alg.Alias.MessageDigest.SHS", "SHA-160");
- put("Alg.Alias.MessageDigest.SHA", "SHA-160");
- put("Alg.Alias.MessageDigest.SHA1", "SHA-160");
- put("Alg.Alias.MessageDigest.SHA-1", "SHA-160");
- put("Alg.Alias.MessageDigest.SHA2-256", "SHA-256");
- put("Alg.Alias.MessageDigest.SHA2-384", "SHA-384");
- put("Alg.Alias.MessageDigest.SHA2-512", "SHA-512");
- put("Alg.Alias.MessageDigest.SHA256", "SHA-256");
- put("Alg.Alias.MessageDigest.SHA384", "SHA-384");
- put("Alg.Alias.MessageDigest.SHA512", "SHA-512");
- put("Alg.Alias.MessageDigest.RIPEMD-160", "RIPEMD160");
- put("Alg.Alias.MessageDigest.RIPEMD-128", "RIPEMD128");
- put("Alg.Alias.MessageDigest.OID.1.2.840.11359.2.2", "MD2");
- put("Alg.Alias.MessageDigest.1.2.840.11359.2.2", "MD2");
- put("Alg.Alias.MessageDigest.OID.1.2.840.11359.2.5", "MD5");
- put("Alg.Alias.MessageDigest.1.2.840.11359.2.5", "MD5");
- put("Alg.Alias.MessageDigest.OID.1.3.14.3.2.26", "SHA1");
- put("Alg.Alias.MessageDigest.1.3.14.3.2.26", "SHA1");
-
- // Algorithm Parameters
- put("AlgorithmParameters.DSS",
- gnu.java.security.jce.sig.DSSParameters.class.getName());
- put("Alg.Alias.AlgorithmParameters.DSA", "DSS");
- put("Alg.Alias.AlgorithmParameters.SHAwithDSA", "DSS");
- put("Alg.Alias.AlgorithmParameters.OID.1.2.840.10040.4.3", "DSS");
- put("Alg.Alias.AlgorithmParameters.1.2.840.10040.4.3", "DSS");
-
- // Algorithm Parameter Generator
- put("AlgorithmParameterGenerator.DSA",
- gnu.java.security.jce.sig.DSSParametersGenerator.class.getName());
- put("Alg.Alias.AlgorithmParameterGenerator.DSA", "DSS");
-
- // SecureRandom
- put("SecureRandom.SHA1PRNG",
- gnu.java.security.jce.prng.Sha160RandomSpi.class.getName());
-
- put("SecureRandom.MD2PRNG",
- gnu.java.security.jce.prng.MD2RandomSpi.class.getName());
- put("SecureRandom.MD2PRNG ImplementedIn", "Software");
- put("SecureRandom.MD4PRNG",
- gnu.java.security.jce.prng.MD4RandomSpi.class.getName());
- put("SecureRandom.MD4PRNG ImplementedIn", "Software");
- put("SecureRandom.MD5PRNG",
- gnu.java.security.jce.prng.MD5RandomSpi.class.getName());
- put("SecureRandom.MD5PRNG ImplementedIn", "Software");
- put("SecureRandom.RIPEMD128PRNG",
- gnu.java.security.jce.prng.RipeMD128RandomSpi.class.getName());
- put("SecureRandom.RIPEMD128PRNG ImplementedIn", "Software");
- put("SecureRandom.RIPEMD160PRNG",
- gnu.java.security.jce.prng.RipeMD160RandomSpi.class.getName());
- put("SecureRandom.RIPEMD160PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-160PRNG",
- gnu.java.security.jce.prng.Sha160RandomSpi.class.getName());
- put("SecureRandom.SHA-160PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-256PRNG",
- gnu.java.security.jce.prng.Sha256RandomSpi.class.getName());
- put("SecureRandom.SHA-256PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-384PRNG",
- gnu.java.security.jce.prng.Sha384RandomSpi.class.getName());
- put("SecureRandom.SHA-384PRNG ImplementedIn", "Software");
- put("SecureRandom.SHA-512PRNG",
- gnu.java.security.jce.prng.Sha512RandomSpi.class.getName());
- put("SecureRandom.SHA-512PRNG ImplementedIn", "Software");
- put("SecureRandom.TIGERPRNG",
- gnu.java.security.jce.prng.TigerRandomSpi.class.getName());
- put("SecureRandom.TIGERPRNG ImplementedIn", "Software");
- put("SecureRandom.HAVALPRNG",
- gnu.java.security.jce.prng.HavalRandomSpi.class.getName());
- put("SecureRandom.HAVALPRNG ImplementedIn", "Software");
- put("SecureRandom.WHIRLPOOLPRNG",
- gnu.java.security.jce.prng.WhirlpoolRandomSpi.class.getName());
- put("SecureRandom.WHIRLPOOLPRNG ImplementedIn", "Software");
-
- put("Alg.Alias.SecureRandom.SHA-1PRNG", "SHA-160PRNG");
- put("Alg.Alias.SecureRandom.SHA1PRNG", "SHA-160PRNG");
- put("Alg.Alias.SecureRandom.SHAPRNG", "SHA-160PRNG");
- put("Alg.Alias.SecureRandom.SHA-256PRNG", "SHA-256PRNG");
- put("Alg.Alias.SecureRandom.SHA-2-1PRNG", "SHA-256PRNG");
- put("Alg.Alias.SecureRandom.SHA-384PRNG", "SHA-384PRNG");
- put("Alg.Alias.SecureRandom.SHA-2-2PRNG", "SHA-384PRNG");
- put("Alg.Alias.SecureRandom.SHA-512PRNG", "SHA-512PRNG");
- put("Alg.Alias.SecureRandom.SHA-2-3PRNG", "SHA-512PRNG");
-
- // CertificateFactory
- put("CertificateFactory.X509", X509CertificateFactory.class.getName());
- put("CertificateFactory.X509 ImplementedIn", "Software");
- put("Alg.Alias.CertificateFactory.X.509", "X509");
-
- // CertPathValidator
- put("CertPathValidator.PKIX", PKIXCertPathValidatorImpl.class.getName());
- put("CertPathValidator.PKIX ImplementedIn", "Software");
-
- // CertStore
- put("CertStore.Collection", CollectionCertStoreImpl.class.getName());
-
- return null;
- }
- });
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/PKIXCertPathValidatorImpl.java b/openjdk/icedtea/jce/gnu/java/security/provider/PKIXCertPathValidatorImpl.java
deleted file mode 100644
index cdfad3f6..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/PKIXCertPathValidatorImpl.java
+++ /dev/null
@@ -1,693 +0,0 @@
-/* PKIXCertPathValidatorImpl.java -- PKIX certificate path validator.
- Copyright (C) 2004, 2005, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.provider;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.OID;
-import gnu.java.security.Registry;
-import gnu.java.security.key.dss.DSSPublicKey;
-import gnu.java.security.x509.GnuPKIExtension;
-import gnu.java.security.x509.PolicyNodeImpl;
-import gnu.java.security.x509.X509CRLSelectorImpl;
-import gnu.java.security.x509.X509CertSelectorImpl;
-import gnu.java.security.x509.ext.BasicConstraints;
-import gnu.java.security.x509.ext.CertificatePolicies;
-import gnu.java.security.x509.ext.Extension;
-import gnu.java.security.x509.ext.KeyUsage;
-import gnu.java.security.x509.ext.PolicyConstraint;
-
-import java.io.IOException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.PublicKey;
-import java.security.cert.CRL;
-import java.security.cert.CertPath;
-import java.security.cert.CertPathParameters;
-import java.security.cert.CertPathValidatorException;
-import java.security.cert.CertPathValidatorResult;
-import java.security.cert.CertPathValidatorSpi;
-import java.security.cert.CertStore;
-import java.security.cert.CertStoreException;
-import java.security.cert.CertificateException;
-import java.security.cert.PKIXCertPathChecker;
-import java.security.cert.PKIXCertPathValidatorResult;
-import java.security.cert.PKIXParameters;
-import java.security.cert.TrustAnchor;
-import java.security.cert.X509CRL;
-import java.security.cert.X509Certificate;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPublicKey;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-
-/**
- * An implementation of the Public Key Infrastructure's X.509 certificate path
- * validation algorithm.
- *
- * See RFC 3280: Internet X.509
- * Public Key Infrastructure Certificate and Certificate Revocation List (CRL)
- * Profile.
- *
- * @author Casey Marshall (rsdio@metastatic.org)
- */
-public class PKIXCertPathValidatorImpl
- extends CertPathValidatorSpi
-{
- private static final Logger log = Logger.getLogger(PKIXCertPathValidatorImpl.class.getName());
-
- public static final String ANY_POLICY = "2.5.29.32.0";
-
- public PKIXCertPathValidatorImpl()
- {
- super();
- }
-
- public CertPathValidatorResult engineValidate(CertPath path,
- CertPathParameters params)
- throws CertPathValidatorException, InvalidAlgorithmParameterException
- {
- if (! (params instanceof PKIXParameters))
- throw new InvalidAlgorithmParameterException("not a PKIXParameters object");
- // First check if the certificate path is valid.
- //
- // This means that:
- //
- // (a) for all x in {1, ..., n-1}, the subject of certificate x is
- // the issuer of certificate x+1;
- //
- // (b) for all x in {1, ..., n}, the certificate was valid at the
- // time in question.
- //
- // Because this is the X.509 algorithm, we also check if all
- // cerificates are of type X509Certificate.
- PolicyNodeImpl rootNode = new PolicyNodeImpl();
- Set initPolicies = ((PKIXParameters) params).getInitialPolicies();
- rootNode.setValidPolicy(ANY_POLICY);
- rootNode.setCritical(false);
- rootNode.setDepth(0);
- if (initPolicies != null)
- rootNode.addAllExpectedPolicies(initPolicies);
- else
- rootNode.addExpectedPolicy(ANY_POLICY);
- List checks = ((PKIXParameters) params).getCertPathCheckers();
- List l = path.getCertificates();
- if (l == null || l.size() == 0)
- throw new CertPathValidatorException();
- X509Certificate[] p = null;
- try
- {
- p = (X509Certificate[]) l.toArray(new X509Certificate[l.size()]);
- }
- catch (ClassCastException cce)
- {
- throw new CertPathValidatorException("invalid certificate path");
- }
- String sigProvider = ((PKIXParameters) params).getSigProvider();
- PublicKey prevKey = null;
- Date now = ((PKIXParameters) params).getDate();
- if (now == null)
- now = new Date();
- LinkedList policyConstraints = new LinkedList();
- for (int i = p.length - 1; i >= 0; i--)
- {
- try
- {
- p[i].checkValidity(now);
- }
- catch (CertificateException ce)
- {
- throw new CertPathValidatorException(ce.toString());
- }
- Set uce = getCritExts(p[i]);
- for (Iterator check = checks.iterator(); check.hasNext();)
- {
- try
- {
- ((PKIXCertPathChecker) check.next()).check(p[i], uce);
- }
- catch (Exception x)
- {
- }
- }
- PolicyConstraint constr = null;
- if (p[i] instanceof GnuPKIExtension)
- {
- Extension pcx = ((GnuPKIExtension) p[i]).getExtension(PolicyConstraint.ID);
- if (pcx != null)
- constr = (PolicyConstraint) pcx.getValue();
- }
- else
- {
- byte[] pcx = p[i].getExtensionValue(PolicyConstraint.ID.toString());
- if (pcx != null)
- {
- try
- {
- constr = new PolicyConstraint(pcx);
- }
- catch (Exception x)
- {
- }
- }
- }
- if (constr != null && constr.getRequireExplicitPolicy() >= 0)
- policyConstraints.add(new int[] { p.length - i,
- constr.getRequireExplicitPolicy() });
- updatePolicyTree(p[i], rootNode, p.length - i, (PKIXParameters) params,
- checkExplicitPolicy(p.length - i, policyConstraints));
- // The rest of the tests involve this cert's relationship with the
- // next in the path. If this cert is the end entity, we can stop.
- if (i == 0)
- break;
-
- basicSanity(p, i);
- PublicKey pubKey = null;
- try
- {
- pubKey = p[i].getPublicKey();
- if (pubKey instanceof DSAPublicKey)
- {
- DSAParams dsa = ((DSAPublicKey) pubKey).getParams();
- // If the DSA public key is missing its parameters, use those
- // from the previous cert's key.
- if (dsa == null || dsa.getP() == null || dsa.getG() == null
- || dsa.getQ() == null)
- {
- if (prevKey == null)
- throw new InvalidKeyException("DSA keys not chainable");
- if (! (prevKey instanceof DSAPublicKey))
- throw new InvalidKeyException("DSA keys not chainable");
- dsa = ((DSAPublicKey) prevKey).getParams();
- pubKey = new DSSPublicKey(Registry.X509_ENCODING_ID,
- dsa.getP(), dsa.getQ(),
- dsa.getG(),
- ((DSAPublicKey) pubKey).getY());
- }
- }
- if (sigProvider == null)
- p[i - 1].verify(pubKey);
- else
- p[i - 1].verify(pubKey, sigProvider);
- prevKey = pubKey;
- }
- catch (Exception e)
- {
- throw new CertPathValidatorException(e.toString());
- }
- if (! p[i].getSubjectDN().equals(p[i - 1].getIssuerDN()))
- throw new CertPathValidatorException("issuer DN mismatch");
- boolean[] issuerUid = p[i - 1].getIssuerUniqueID();
- boolean[] subjectUid = p[i].getSubjectUniqueID();
- if (issuerUid != null && subjectUid != null)
- if (! Arrays.equals(issuerUid, subjectUid))
- throw new CertPathValidatorException("UID mismatch");
-
- // Check the certificate against the revocation lists.
- if (((PKIXParameters) params).isRevocationEnabled())
- {
- X509CRLSelectorImpl selector = new X509CRLSelectorImpl();
- try
- {
- selector.addIssuerName(p[i].getSubjectDN());
- }
- catch (IOException ioe)
- {
- throw new CertPathValidatorException("error selecting CRLs");
- }
- List certStores = ((PKIXParameters) params).getCertStores();
- List crls = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext();)
- {
- CertStore cs = (CertStore) it.next();
- try
- {
- Collection c = cs.getCRLs(selector);
- crls.addAll(c);
- }
- catch (CertStoreException cse)
- {
- }
- }
- if (crls.isEmpty())
- throw new CertPathValidatorException("no CRLs for issuer");
- boolean certOk = false;
- for (Iterator it = crls.iterator(); it.hasNext();)
- {
- CRL crl = (CRL) it.next();
- if (! (crl instanceof X509CRL))
- continue;
- X509CRL xcrl = (X509CRL) crl;
- if (! checkCRL(xcrl, p, now, p[i], pubKey, certStores))
- continue;
- if (xcrl.isRevoked(p[i - 1]))
- throw new CertPathValidatorException("certificate is revoked");
- else
- certOk = true;
- }
- if (! certOk)
- throw new CertPathValidatorException(
- "certificate's validity could not be determined");
- }
- }
- rootNode.setReadOnly();
- // Now ensure that the first certificate in the chain was issued
- // by a trust anchor.
- Exception cause = null;
- Set anchors = ((PKIXParameters) params).getTrustAnchors();
- for (Iterator i = anchors.iterator(); i.hasNext();)
- {
- TrustAnchor anchor = (TrustAnchor) i.next();
- X509Certificate anchorCert = null;
- PublicKey anchorKey = null;
- if (anchor.getTrustedCert() != null)
- {
- anchorCert = anchor.getTrustedCert();
- anchorKey = anchorCert.getPublicKey();
- }
- else
- anchorKey = anchor.getCAPublicKey();
- if (anchorKey == null)
- continue;
- try
- {
- if (anchorCert != null)
- anchorCert.checkValidity(now);
- p[p.length - 1].verify(anchorKey);
- if (anchorCert != null && anchorCert.getBasicConstraints() >= 0
- && anchorCert.getBasicConstraints() < p.length)
- continue;
-
- if (((PKIXParameters) params).isRevocationEnabled())
- {
- X509CRLSelectorImpl selector = new X509CRLSelectorImpl();
- if (anchorCert != null)
- try
- {
- selector.addIssuerName(anchorCert.getSubjectDN());
- }
- catch (IOException ioe)
- {
- }
- else
- selector.addIssuerName(anchor.getCAName());
- List certStores = ((PKIXParameters) params).getCertStores();
- List crls = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext();)
- {
- CertStore cs = (CertStore) it.next();
- try
- {
- Collection c = cs.getCRLs(selector);
- crls.addAll(c);
- }
- catch (CertStoreException cse)
- {
- }
- }
- if (crls.isEmpty())
- continue;
- for (Iterator it = crls.iterator(); it.hasNext();)
- {
- CRL crl = (CRL) it.next();
- if (! (crl instanceof X509CRL))
- continue;
- X509CRL xcrl = (X509CRL) crl;
- try
- {
- xcrl.verify(anchorKey);
- }
- catch (Exception x)
- {
- continue;
- }
- Date nextUpdate = xcrl.getNextUpdate();
- if (nextUpdate != null && nextUpdate.compareTo(now) < 0)
- continue;
- if (xcrl.isRevoked(p[p.length - 1]))
- throw new CertPathValidatorException("certificate is revoked");
- }
- }
- // The chain is valid; return the result.
- return new PKIXCertPathValidatorResult(anchor, rootNode,
- p[0].getPublicKey());
- }
- catch (Exception ignored)
- {
- cause = ignored;
- continue;
- }
- }
- // The path is not valid.
- CertPathValidatorException cpve =
- new CertPathValidatorException("path validation failed");
- if (cause != null)
- cpve.initCause(cause);
- throw cpve;
- }
-
- /**
- * Check if a given CRL is acceptable for checking the revocation status of
- * certificates in the path being checked.
- *
- * The CRL is accepted iff:
- *
- * - The nextUpdate field (if present) is in the future.
- * - The CRL does not contain any unsupported critical extensions.
- * - The CRL is signed by one of the certificates in the path, or,
- * - The CRL is signed by the given public key and was issued by the public
- * key's subject, or,
- * - The CRL is signed by a certificate in the given cert stores, and that
- * cert is signed by one of the certificates in the path.
- *
- *
- * @param crl The CRL being checked.
- * @param path The path this CRL is being checked against.
- * @param now The value to use as 'now'.
- * @param pubKeyCert The certificate authenticating the public key.
- * @param pubKey The public key to check.
- * @return True if the CRL is acceptable.
- */
- private static boolean checkCRL(X509CRL crl, X509Certificate[] path,
- Date now, X509Certificate pubKeyCert,
- PublicKey pubKey, List certStores)
- {
- Date nextUpdate = crl.getNextUpdate();
- if (nextUpdate != null && nextUpdate.compareTo(now) < 0)
- return false;
- if (crl.hasUnsupportedCriticalExtension())
- return false;
- for (int i = 0; i < path.length; i++)
- {
- if (! path[i].getSubjectDN().equals(crl.getIssuerDN()))
- continue;
- boolean[] keyUsage = path[i].getKeyUsage();
- if (keyUsage != null)
- {
- if (! keyUsage[KeyUsage.CRL_SIGN])
- continue;
- }
- try
- {
- crl.verify(path[i].getPublicKey());
- return true;
- }
- catch (Exception x)
- {
- }
- }
- if (crl.getIssuerDN().equals(pubKeyCert.getSubjectDN()))
- {
- try
- {
- boolean[] keyUsage = pubKeyCert.getKeyUsage();
- if (keyUsage != null)
- {
- if (! keyUsage[KeyUsage.CRL_SIGN])
- throw new Exception();
- }
- crl.verify(pubKey);
- return true;
- }
- catch (Exception x)
- {
- }
- }
- try
- {
- X509CertSelectorImpl select = new X509CertSelectorImpl();
- select.addSubjectName(crl.getIssuerDN());
- List certs = new LinkedList();
- for (Iterator it = certStores.iterator(); it.hasNext();)
- {
- CertStore cs = (CertStore) it.next();
- try
- {
- certs.addAll(cs.getCertificates(select));
- }
- catch (CertStoreException cse)
- {
- }
- }
- for (Iterator it = certs.iterator(); it.hasNext();)
- {
- X509Certificate c = (X509Certificate) it.next();
- for (int i = 0; i < path.length; i++)
- {
- if (! c.getIssuerDN().equals(path[i].getSubjectDN()))
- continue;
- boolean[] keyUsage = c.getKeyUsage();
- if (keyUsage != null)
- {
- if (! keyUsage[KeyUsage.CRL_SIGN])
- continue;
- }
- try
- {
- c.verify(path[i].getPublicKey());
- crl.verify(c.getPublicKey());
- return true;
- }
- catch (Exception x)
- {
- }
- }
- if (c.getIssuerDN().equals(pubKeyCert.getSubjectDN()))
- {
- c.verify(pubKey);
- crl.verify(c.getPublicKey());
- }
- }
- }
- catch (Exception x)
- {
- }
- return false;
- }
-
- private static Set getCritExts(X509Certificate cert)
- {
- HashSet s = new HashSet();
- if (cert instanceof GnuPKIExtension)
- {
- Collection exts = ((GnuPKIExtension) cert).getExtensions();
- for (Iterator it = exts.iterator(); it.hasNext();)
- {
- Extension ext = (Extension) it.next();
- if (ext.isCritical() && ! ext.isSupported())
- s.add(ext.getOid().toString());
- }
- }
- else
- s.addAll(cert.getCriticalExtensionOIDs());
- return s;
- }
-
- /**
- * Perform a basic sanity check on the CA certificate at index
.
- */
- private static void basicSanity(X509Certificate[] path, int index)
- throws CertPathValidatorException
- {
- X509Certificate cert = path[index];
- int pathLen = 0;
- for (int i = index - 1; i > 0; i--)
- {
- if (! path[i].getIssuerDN().equals(path[i].getSubjectDN()))
- pathLen++;
- }
- Extension e = null;
- if (cert instanceof GnuPKIExtension)
- {
- e = ((GnuPKIExtension) cert).getExtension(BasicConstraints.ID);
- }
- else
- {
- try
- {
- e = new Extension(cert.getExtensionValue(BasicConstraints.ID.toString()));
- }
- catch (Exception x)
- {
- }
- }
- if (e == null)
- throw new CertPathValidatorException("no basicConstraints");
- BasicConstraints bc = (BasicConstraints) e.getValue();
- if (! bc.isCA())
- throw new CertPathValidatorException(
- "certificate cannot be used to verify signatures");
- if (bc.getPathLengthConstraint() >= 0
- && bc.getPathLengthConstraint() < pathLen)
- throw new CertPathValidatorException("path is too long");
-
- boolean[] keyUsage = cert.getKeyUsage();
- if (keyUsage != null)
- {
- if (! keyUsage[KeyUsage.KEY_CERT_SIGN])
- throw new CertPathValidatorException(
- "certificate cannot be used to sign certificates");
- }
- }
-
- private static void updatePolicyTree(X509Certificate cert,
- PolicyNodeImpl root, int depth,
- PKIXParameters params,
- boolean explicitPolicy)
- throws CertPathValidatorException
- {
- if (Configuration.DEBUG)
- log.fine("updatePolicyTree depth == " + depth);
- Set nodes = new HashSet();
- LinkedList stack = new LinkedList();
- Iterator current = null;
- stack.addLast(Collections.singleton(root).iterator());
- do
- {
- current = (Iterator) stack.removeLast();
- while (current.hasNext())
- {
- PolicyNodeImpl p = (PolicyNodeImpl) current.next();
- if (Configuration.DEBUG)
- log.fine("visiting node == " + p);
- if (p.getDepth() == depth - 1)
- {
- if (Configuration.DEBUG)
- log.fine("added node");
- nodes.add(p);
- }
- else
- {
- if (Configuration.DEBUG)
- log.fine("skipped node");
- stack.addLast(current);
- current = p.getChildren();
- }
- }
- }
- while (! stack.isEmpty());
-
- Extension e = null;
- CertificatePolicies policies = null;
- List qualifierInfos = null;
- if (cert instanceof GnuPKIExtension)
- {
- e = ((GnuPKIExtension) cert).getExtension(CertificatePolicies.ID);
- if (e != null)
- policies = (CertificatePolicies) e.getValue();
- }
-
- List cp = null;
- if (policies != null)
- cp = policies.getPolicies();
- else
- cp = Collections.EMPTY_LIST;
- boolean match = false;
- if (Configuration.DEBUG)
- {
- log.fine("nodes are == " + nodes);
- log.fine("cert policies are == " + cp);
- }
- for (Iterator it = nodes.iterator(); it.hasNext();)
- {
- PolicyNodeImpl parent = (PolicyNodeImpl) it.next();
- if (Configuration.DEBUG)
- log.fine("adding policies to " + parent);
- for (Iterator it2 = cp.iterator(); it2.hasNext();)
- {
- OID policy = (OID) it2.next();
- if (Configuration.DEBUG)
- log.fine("trying to add policy == " + policy);
- if (policy.toString().equals(ANY_POLICY)
- && params.isAnyPolicyInhibited())
- continue;
- PolicyNodeImpl child = new PolicyNodeImpl();
- child.setValidPolicy(policy.toString());
- child.addExpectedPolicy(policy.toString());
- if (parent.getExpectedPolicies().contains(policy.toString()))
- {
- parent.addChild(child);
- match = true;
- }
- else if (parent.getExpectedPolicies().contains(ANY_POLICY))
- {
- parent.addChild(child);
- match = true;
- }
- else if (ANY_POLICY.equals(policy.toString()))
- {
- parent.addChild(child);
- match = true;
- }
- if (match && policies != null)
- {
- List qualifiers = policies.getPolicyQualifierInfos(policy);
- if (qualifiers != null)
- child.addAllPolicyQualifiers(qualifiers);
- }
- }
- }
- if (! match && (params.isExplicitPolicyRequired() || explicitPolicy))
- throw new CertPathValidatorException("policy tree building failed");
- }
-
- private boolean checkExplicitPolicy(int depth, List explicitPolicies)
- {
- if (Configuration.DEBUG)
- log.fine("checkExplicitPolicy depth=" + depth);
- for (Iterator it = explicitPolicies.iterator(); it.hasNext();)
- {
- int[] i = (int[]) it.next();
- int caDepth = i[0];
- int limit = i[1];
- if (Configuration.DEBUG)
- log.fine(" caDepth=" + caDepth + " limit=" + limit);
- if (depth - caDepth >= limit)
- return true;
- }
- return false;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/X509CertificateFactory.java b/openjdk/icedtea/jce/gnu/java/security/provider/X509CertificateFactory.java
deleted file mode 100644
index 7d61779f..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/X509CertificateFactory.java
+++ /dev/null
@@ -1,294 +0,0 @@
-/* X509CertificateFactory.java -- generates X.509 certificates.
- 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.provider;
-
-import gnu.java.io.Base64InputStream;
-import gnu.java.security.x509.X509CRL;
-import gnu.java.security.x509.X509CertPath;
-import gnu.java.security.x509.X509Certificate;
-
-import java.io.BufferedInputStream;
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.security.cert.CRL;
-import java.security.cert.CRLException;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateFactorySpi;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-public class X509CertificateFactory
- extends CertificateFactorySpi
-{
- public static final String BEGIN_CERTIFICATE = "-----BEGIN CERTIFICATE-----";
-
- public static final String END_CERTIFICATE = "-----END CERTIFICATE-----";
-
- public static final String BEGIN_X509_CRL = "-----BEGIN X509 CRL-----";
-
- public static final String END_X509_CRL = "-----END X509 CRL-----";
-
- public X509CertificateFactory()
- {
- super();
- }
-
- public Certificate engineGenerateCertificate(InputStream inStream)
- throws CertificateException
- {
- try
- {
- return generateCert(inStream);
- }
- catch (IOException ioe)
- {
- CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause(ioe);
- throw ce;
- }
- }
-
- public Collection engineGenerateCertificates(InputStream inStream)
- throws CertificateException
- {
- LinkedList certs = new LinkedList();
- while (true)
- {
- try
- {
- certs.add(generateCert(inStream));
- }
- catch (EOFException eof)
- {
- break;
- }
- catch (IOException ioe)
- {
- CertificateException ce = new CertificateException(ioe.getMessage());
- ce.initCause(ioe);
- throw ce;
- }
- }
- return certs;
- }
-
- public CRL engineGenerateCRL(InputStream inStream) throws CRLException
- {
- try
- {
- return generateCRL(inStream);
- }
- catch (IOException ioe)
- {
- CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause(ioe);
- throw crle;
- }
- }
-
- public Collection engineGenerateCRLs(InputStream inStream)
- throws CRLException
- {
- LinkedList crls = new LinkedList();
- while (true)
- {
- try
- {
- crls.add(generateCRL(inStream));
- }
- catch (EOFException eof)
- {
- break;
- }
- catch (IOException ioe)
- {
- CRLException crle = new CRLException(ioe.getMessage());
- crle.initCause(ioe);
- throw crle;
- }
- }
- return crls;
- }
-
- public CertPath engineGenerateCertPath(List certs)
- {
- return new X509CertPath(certs);
- }
-
- public CertPath engineGenerateCertPath(InputStream in)
- throws CertificateEncodingException
- {
- return new X509CertPath(in);
- }
-
- public CertPath engineGenerateCertPath(InputStream in, String encoding)
- throws CertificateEncodingException
- {
- return new X509CertPath(in, encoding);
- }
-
- public Iterator engineGetCertPathEncodings()
- {
- return X509CertPath.ENCODINGS.iterator();
- }
-
- private X509Certificate generateCert(InputStream inStream)
- throws IOException, CertificateException
- {
- if (inStream == null)
- throw new CertificateException("missing input stream");
- if (! inStream.markSupported())
- inStream = new BufferedInputStream(inStream, 8192);
- inStream.mark(20);
- int i = inStream.read();
- if (i == -1)
- throw new EOFException();
- // If the input is in binary DER format, the first byte MUST be
- // 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
- // UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
- //
- // So if we do not see 0x30 here we will assume it is in Base-64.
- if (i != 0x30)
- {
- inStream.reset();
- StringBuffer line = new StringBuffer(80);
- do
- {
- line.setLength(0);
- do
- {
- i = inStream.read();
- if (i == -1)
- throw new EOFException();
- if (i != '\n' && i != '\r')
- line.append((char) i);
- }
- while (i != '\n' && i != '\r');
- }
- while (! line.toString().equals(BEGIN_CERTIFICATE));
- X509Certificate ret = new X509Certificate(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
- line.setLength(0);
- line.append('-'); // Base64InputStream will eat this.
- do
- {
- i = inStream.read();
- if (i == -1)
- throw new EOFException();
- if (i != '\n' && i != '\r')
- line.append((char) i);
- }
- while (i != '\n' && i != '\r');
- // XXX ???
- if (! line.toString().equals(END_CERTIFICATE))
- throw new CertificateException("no end-of-certificate marker");
- return ret;
- }
- else
- {
- inStream.reset();
- return new X509Certificate(inStream);
- }
- }
-
- private X509CRL generateCRL(InputStream inStream) throws IOException,
- CRLException
- {
- if (inStream == null)
- throw new CRLException("missing input stream");
- if (! inStream.markSupported())
- inStream = new BufferedInputStream(inStream, 8192);
- inStream.mark(20);
- int i = inStream.read();
- if (i == -1)
- throw new EOFException();
- // If the input is in binary DER format, the first byte MUST be
- // 0x30, which stands for the ASN.1 [UNIVERSAL 16], which is the
- // UNIVERSAL SEQUENCE, with the CONSTRUCTED bit (0x20) set.
- //
- // So if we do not see 0x30 here we will assume it is in Base-64.
- if (i != 0x30)
- {
- inStream.reset();
- StringBuffer line = new StringBuffer(80);
- do
- {
- line.setLength(0);
- do
- {
- i = inStream.read();
- if (i == -1)
- throw new EOFException();
- if (i != '\n' && i != '\r')
- line.append((char) i);
- }
- while (i != '\n' && i != '\r');
- }
- while (! line.toString().startsWith(BEGIN_X509_CRL));
- X509CRL ret = new X509CRL(
- new BufferedInputStream(new Base64InputStream(inStream), 8192));
- line.setLength(0);
- line.append('-'); // Base64InputStream will eat this.
- do
- {
- i = inStream.read();
- if (i == -1)
- throw new EOFException();
- if (i != '\n' && i != '\r')
- line.append((char) i);
- }
- while (i != '\n' && i != '\r');
- // XXX ???
- if (! line.toString().startsWith(END_X509_CRL))
- throw new CRLException("no end-of-CRL marker");
- return ret;
- }
- else
- {
- inStream.reset();
- return new X509CRL(inStream);
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/provider/package.html b/openjdk/icedtea/jce/gnu/java/security/provider/package.html
deleted file mode 100644
index 641a22af..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/provider/package.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-GNU Classpath - gnu.java.security.provider
-
-
-
-
-
-
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/BaseSignature.java b/openjdk/icedtea/jce/gnu/java/security/sig/BaseSignature.java
deleted file mode 100644
index 9c76cacb..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/BaseSignature.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/* BaseSignature.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig;
-
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.prng.IRandom;
-import gnu.java.security.prng.LimitReachedException;
-import gnu.java.security.util.PRNG;
-
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.util.Map;
-import java.util.Random;
-
-/**
- * A base abstract class to facilitate implementations of concrete Signatures.
- */
-public abstract class BaseSignature
- implements ISignature
-{
- /** The canonical name of this signature scheme. */
- protected String schemeName;
-
- /** The underlying message digest instance for this signature scheme. */
- protected IMessageDigest md;
-
- /** The public key to use when verifying signatures. */
- protected PublicKey publicKey;
-
- /** The private key to use when generating signatures (signing). */
- protected PrivateKey privateKey;
-
- /** The optional {@link Random} instance to use. */
- private Random rnd;
-
- /** The optional {@link IRandom} instance to use. */
- private IRandom irnd;
-
- /** Our default source of randomness. */
- private PRNG prng = null;
-
- /**
- * Trivial constructor.
- *
- * @param schemeName the name of this signature scheme.
- * @param md the underlying instance of the message digest algorithm.
- * @throws IllegalArgumentException if the designated hash instance is
- * null
.
- */
- protected BaseSignature(String schemeName, IMessageDigest md)
- {
- super();
-
- this.schemeName = schemeName;
- if (md == null)
- throw new IllegalArgumentException("Message digest MUST NOT be null");
-
- this.md = md;
- }
-
- public String name()
- {
- return schemeName + "-" + md.name();
- }
-
- public void setupVerify(Map attributes) throws IllegalArgumentException
- {
- setup(attributes);
- // do we have a public key?
- PublicKey key = (PublicKey) attributes.get(VERIFIER_KEY);
- if (key != null)
- setupForVerification(key);
- }
-
- public void setupSign(Map attributes) throws IllegalArgumentException
- {
- setup(attributes);
- // do we have a private key?
- PrivateKey key = (PrivateKey) attributes.get(SIGNER_KEY);
- if (key != null)
- setupForSigning(key);
- }
-
- public void update(byte b)
- {
- if (md == null)
- throw new IllegalStateException();
-
- md.update(b);
- }
-
- public void update(byte[] b, int off, int len)
- {
- if (md == null)
- throw new IllegalStateException();
-
- md.update(b, off, len);
- }
-
- public Object sign()
- {
- if (md == null || privateKey == null)
- throw new IllegalStateException();
-
- return generateSignature();
- }
-
- public boolean verify(Object sig)
- {
- if (md == null || publicKey == null)
- throw new IllegalStateException();
-
- return verifySignature(sig);
- }
-
- public abstract Object clone();
-
- protected abstract void setupForVerification(PublicKey key)
- throws IllegalArgumentException;
-
- protected abstract void setupForSigning(PrivateKey key)
- throws IllegalArgumentException;
-
- protected abstract Object generateSignature() throws IllegalStateException;
-
- protected abstract boolean verifySignature(Object signature)
- throws IllegalStateException;
-
- /** Initialises the internal fields of this instance. */
- protected void init()
- {
- md.reset();
- rnd = null;
- irnd = null;
- publicKey = null;
- privateKey = null;
- }
-
- /**
- * Fills the designated byte array with random data.
- *
- * @param buffer the byte array to fill with random data.
- */
- protected void nextRandomBytes(byte[] buffer)
- {
- if (rnd != null)
- rnd.nextBytes(buffer);
- else if (irnd != null)
- try
- {
- irnd.nextBytes(buffer, 0, buffer.length);
- }
- catch (IllegalStateException x)
- {
- throw new RuntimeException("nextRandomBytes(): " + x);
- }
- catch (LimitReachedException x)
- {
- throw new RuntimeException("nextRandomBytes(): " + x);
- }
- else
- getDefaultPRNG().nextBytes(buffer);
- }
-
- private void setup(Map attributes)
- {
- init();
- // do we have a Random or SecureRandom, or should we use our own?
- Object obj = attributes.get(SOURCE_OF_RANDOMNESS);
- if (obj instanceof Random)
- rnd = (Random) obj;
- else if (obj instanceof IRandom)
- irnd = (IRandom) obj;
- }
-
- private PRNG getDefaultPRNG()
- {
- if (prng == null)
- prng = PRNG.getInstance();
-
- return prng;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/ISignature.java b/openjdk/icedtea/jce/gnu/java/security/sig/ISignature.java
deleted file mode 100644
index ff25f29d..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/ISignature.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* ISignature.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig;
-
-import java.util.Map;
-
-/**
- * The visible methods of every signature-with-appendix scheme.
- *
- * The Handbook of Applied Cryptography (HAC), by A. Menezes & al. states:
- * "Digital signature schemes which require the message as input to the
- * verification algorithm are called digital signature schemes with appendix.
- * ... They rely on cryptographic hash functions rather than customised
- * redundancy functions, and are less prone to existential forgery attacks."
- *
- * References:
- *
- * - Handbook of Applied
- * Cryptography, Alfred J. Menezes, Paul C. van Oorschot and Scott A.
- * Vanstone. Section 11.2.2 Digital signature schemes with appendix.
- *
- */
-public interface ISignature
- extends Cloneable
-{
- /** Property name of the verifier's public key. */
- public static final String VERIFIER_KEY = "gnu.crypto.sig.public.key";
-
- /** Property name of the signer's private key. */
- public static final String SIGNER_KEY = "gnu.crypto.sig.private.key";
-
- /**
- * Property name of an optional {@link java.security.SecureRandom},
- * {@link java.util.Random}, or {@link gnu.java.security.prng.IRandom}
- * instance to use. The default is to use a classloader singleton from
- * {@link gnu.java.security.util.PRNG}.
- */
- public static final String SOURCE_OF_RANDOMNESS = "gnu.crypto.sig.prng";
-
- /**
- * Returns the canonical name of this signature scheme.
- *
- * @return the canonical name of this instance.
- */
- String name();
-
- /**
- * Initialises this instance for signature verification.
- *
- * @param attributes the attributes to use for setting up this instance.
- * @throws IllegalArgumentException if the designated public key is not
- * appropriate for this signature scheme.
- * @see #SOURCE_OF_RANDOMNESS
- * @see #VERIFIER_KEY
- */
- void setupVerify(Map attributes) throws IllegalArgumentException;
-
- /**
- * Initialises this instance for signature generation.
- *
- * @param attributes the attributes to use for setting up this instance.
- * @throws IllegalArgumentException if the designated private key is not
- * appropriate for this signature scheme.
- * @see #SOURCE_OF_RANDOMNESS
- * @see #SIGNER_KEY
- */
- void setupSign(Map attributes) throws IllegalArgumentException;
-
- /**
- * Digests one byte of a message for signing or verification purposes.
- *
- * @param b the message byte to digest.
- * @throws IllegalStateException if this instance was not setup for signature
- * generation/verification.
- */
- void update(byte b) throws IllegalStateException;
-
- /**
- * Digests a sequence of bytes from a message for signing or verification
- * purposes.
- *
- * @param buffer the byte sequence to consider.
- * @param offset the byte poisition in buffer
of the first byte
- * to consider.
- * @param length the number of bytes in buffer
starting from
- * the byte at index offset
to digest.
- * @throws IllegalStateException if this instance was not setup for signature
- * generation/verification.
- */
- void update(byte[] buffer, int offset, int length)
- throws IllegalStateException;
-
- /**
- * Terminates a signature generation phase by digesting and processing the
- * context of the underlying message digest algorithm instance.
- *
- * @return a {@link Object} representing the native output of the signature
- * scheme implementation.
- * @throws IllegalStateException if this instance was not setup for signature
- * generation.
- */
- Object sign() throws IllegalStateException;
-
- /**
- * Terminates a signature verification phase by digesting and processing the
- * context of the underlying message digest algorithm instance.
- *
- * @param signature a native signature object previously generated by an
- * invocation of the sign()
method.
- * @return true
iff the outpout of the verification phase
- * confirms that the designated signature object has been generated
- * using the corresponding public key of the recepient.
- * @throws IllegalStateException if this instance was not setup for signature
- * verification.
- */
- boolean verify(Object signature) throws IllegalStateException;
-
- /**
- * Returns a clone copy of this instance.
- *
- * @return a clone copy of this instance.
- */
- Object clone();
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/ISignatureCodec.java b/openjdk/icedtea/jce/gnu/java/security/sig/ISignatureCodec.java
deleted file mode 100644
index aaae6ccb..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/ISignatureCodec.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ISignatureCodec.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig;
-
-import gnu.java.security.Registry;
-
-/**
- * The visible methods of an object that knows how to encode and decode
- * cryptographic signatures. Codecs are useful for (a) externalising signature
- * output data for storage and on-the-wire transmission, as well as (b) re-
- * creating their internal Java representation from external sources.
- */
-public interface ISignatureCodec
-{
- /** Constant identifying the Raw encoding format. */
- int RAW_FORMAT = Registry.RAW_ENCODING_ID;
-
- int getFormatID();
-
- byte[] encodeSignature(Object signature);
-
- Object decodeSignature(byte[] input);
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/SignatureCodecFactory.java b/openjdk/icedtea/jce/gnu/java/security/sig/SignatureCodecFactory.java
deleted file mode 100644
index c5b2ccd4..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/SignatureCodecFactory.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/* SignatureCodecFactory.java -- Factory to instantiate Signature codecs
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.sig.dss.DSSSignatureRawCodec;
-import gnu.java.security.sig.dss.DSSSignatureX509Codec;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureRawCodec;
-import gnu.java.security.sig.rsa.RSAPKCS1V1_5SignatureX509Codec;
-import gnu.java.security.sig.rsa.RSAPSSSignatureRawCodec;
-import gnu.java.security.util.FormatUtil;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * A Factory class to instantiate Signature codecs.
- */
-public class SignatureCodecFactory
-{
- private static Set names;
-
- /** Trivial constructor to enforce Singleton pattern. */
- private SignatureCodecFactory()
- {
- super();
- }
-
- /**
- * Returns the appropriate codec given a composed signature algorithm and an
- * encoding format. A composed name is formed by the concatenation of the
- * canonical signature algorithm name, the forward slash character
- * /
and the canonical name of the encoding format.
- *
- * When the encoding format name is missing, the Raw encoding format is
- * assumed. When this is the case the trailing forward slash is discarded from
- * the name.
- *
- * @param name the case-insensitive, possibly composed, signature codec name.
- * @return an instance of the signaturecodec, or null
if none
- * found.
- */
- public static ISignatureCodec getInstance(String name)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- if (name.length() == 0)
- return null;
-
- if (name.startsWith("/"))
- return null;
-
- if (name.endsWith("/"))
- return getInstance(name.substring(0, name.length() - 1),
- Registry.RAW_ENCODING_ID);
-
- int i = name.indexOf("/");
- if (i == - 1)
- return getInstance(name, Registry.RAW_ENCODING_ID);
-
- String sigName = name.substring(0, i);
- String formatName = name.substring(i + 1);
- return getInstance(sigName, formatName);
- }
-
- /**
- * Returns an instance of a signature codec given the canonical name of the
- * signature algorithm, and that of the encoding format.
- *
- * @param name the case-insensitive signature algorithm name.
- * @param format the name of the format to use when encodigng/decoding
- * signatures generated by the named algorithm.
- * @return an instance of the signature codec, or null
if none
- * found.
- */
- public static ISignatureCodec getInstance(String name, String format)
- {
- int formatID = FormatUtil.getFormatID(format);
- if (formatID == 0)
- return null;
-
- return getInstance(name, formatID);
- }
-
- /**
- * Returns an instance of a signature codec given the canonical name of the
- * signature algorithm, and the identifier of the format to use when
- * encoding/decoding signatures generated by that algorithm.
- *
- * @param name the case-insensitive signature algorithm name.
- * @param formatID the identifier of the format to use when encoding /
- * decoding signatures generated by the designated algorithm.
- * @return an instance of the signature codec, or null
if none
- * found.
- */
- public static ISignatureCodec getInstance(String name, int formatID)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- switch (formatID)
- {
- case Registry.RAW_ENCODING_ID:
- return getRawCodec(name);
- case Registry.X509_ENCODING_ID:
- return getX509Codec(name);
- }
-
- return null;
- }
-
- /**
- * Returns a {@link Set} of supported signature codec names.
- *
- * @return a {@link Set} of the names of supported signature codec (Strings).
- */
- public static synchronized final Set getNames()
- {
- if (names == null)
- {
- HashSet hs = new HashSet();
- hs.add(Registry.DSS_SIG + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- hs.add(Registry.DSS_SIG + "/" + Registry.X509_ENCODING_SORT_NAME);
- Set hashNames = HashFactory.getNames();
- for (Iterator it = hashNames.iterator(); it.hasNext();)
- {
- String mdName = (String) it.next();
- String name = Registry.RSA_PKCS1_V1_5_SIG + "-" + mdName;
- hs.add(name + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- hs.add(name + "/" + Registry.X509_ENCODING_SORT_NAME);
- name = Registry.RSA_PSS_SIG + "-" + mdName;
- hs.add(name + "/" + Registry.RAW_ENCODING_SHORT_NAME);
- }
-
- names = Collections.unmodifiableSet(hs);
- }
-
- return names;
- }
-
- /**
- * @param name the trimmed name of a signature algorithm.
- * @return a Raw format codec for the designated signature algorithm, or
- * null
if none exists.
- */
- private static ISignatureCodec getRawCodec(String name)
- {
- ISignatureCodec result = null;
- if (name.equalsIgnoreCase(Registry.DSA_SIG)
- || name.equalsIgnoreCase(Registry.DSS_SIG))
- result = new DSSSignatureRawCodec();
- else
- {
- name = name.toLowerCase();
- if (name.startsWith(Registry.RSA_PKCS1_V1_5_SIG))
- result = new RSAPKCS1V1_5SignatureRawCodec();
- else if (name.startsWith(Registry.RSA_PSS_SIG))
- result = new RSAPSSSignatureRawCodec();
- }
-
- return result;
- }
-
- /**
- * @param name the trimmed name of a signature algorithm.
- * @return a X.509 format codec for the designated signature algorithm, or
- * null
if none exists.
- */
- private static ISignatureCodec getX509Codec(String name)
- {
- ISignatureCodec result = null;
- if (name.equalsIgnoreCase(Registry.DSA_SIG)
- || name.equalsIgnoreCase(Registry.DSS_SIG))
- result = new DSSSignatureX509Codec();
- else
- {
- name = name.toLowerCase();
- if (name.startsWith(Registry.RSA_PKCS1_V1_5_SIG))
- result = new RSAPKCS1V1_5SignatureX509Codec();
- }
-
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/SignatureFactory.java b/openjdk/icedtea/jce/gnu/java/security/sig/SignatureFactory.java
deleted file mode 100644
index 28b68925..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/SignatureFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/* SignatureFactory.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.dss.DSSSignature;
-import gnu.java.security.sig.rsa.RSASignatureFactory;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * A Factory to instantiate signature-with-appendix handlers.
- */
-public class SignatureFactory
-{
- private static Set names;
-
- /** Trivial constructor to enforce Singleton pattern. */
- private SignatureFactory()
- {
- super();
- }
-
- /**
- * Returns an instance of a signature-with-appendix scheme given its name.
- *
- * @param ssa the case-insensitive signature-with-appendix scheme name.
- * @return an instance of the scheme, or null
if none found.
- */
- public static final ISignature getInstance(String ssa)
- {
- if (ssa == null)
- return null;
-
- ssa = ssa.trim();
- ssa = ssa.toLowerCase();
- ISignature result = null;
- if (ssa.equalsIgnoreCase(Registry.DSA_SIG) || ssa.equals(Registry.DSS_SIG))
- result = new DSSSignature();
- else if (ssa.startsWith(Registry.RSA_SIG_PREFIX))
- result = RSASignatureFactory.getInstance(ssa);
-
- return result;
- }
-
- /**
- * Returns a {@link Set} of signature-with-appendix scheme names supported by
- * this Factory.
- *
- * @return a {@link Set} of signature-with-appendix scheme names (Strings).
- */
- public static synchronized final Set getNames()
- {
- if (names == null)
- {
- HashSet hs = new HashSet();
- hs.add(Registry.DSS_SIG);
- hs.addAll(RSASignatureFactory.getNames());
- names = Collections.unmodifiableSet(hs);
- }
- return names;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignature.java b/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignature.java
deleted file mode 100644
index 1ef1bea1..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignature.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/* DSSSignature.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.hash.Sha160;
-import gnu.java.security.prng.IRandom;
-import gnu.java.security.sig.BaseSignature;
-import gnu.java.security.sig.ISignature;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.DSAPrivateKey;
-import java.security.interfaces.DSAPublicKey;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Random;
-
-/**
- * The DSS (Digital Signature Standard) algorithm makes use of the following
- * parameters:
- *
- * - p: A prime modulus, where
- *
2L-1 < p < 2L
for 512 <= L
- * <= 1024
and L
a multiple of 64
.
- * - q: A prime divisor of
p - 1
, where 2159
- * < q < 2160
.
- * - g: Where
g = h(p-1)/q mod p
, where
- * h
is any integer with 1 < h < p - 1
such
- * that h (p-1)/q mod p > 1
(g
has order
- * q mod p
).
- * - x: A randomly or pseudorandomly generated integer with
0 < x
- * < q
.
- * - y:
y = gx mod p
.
- * - k: A randomly or pseudorandomly generated integer with
0 < k
- * < q
.
- *
- *
- * The integers p
, q
, and g
can be
- * public and can be common to a group of users. A user's private and public
- * keys are x
and y
, respectively. They are
- * normally fixed for a period of time. Parameters x
and
- * k
are used for signature generation only, and must be kept
- * secret. Parameter k
must be regenerated for each signature.
- *
- * The signature of a message M
is the pair of numbers
- * r
and s
computed according to the equations below:
- *
- * r = (gk mod p) mod q
and
- * s = (k-1(SHA(M) + xr)) mod q
.
- *
- *
- * In the above, k-1
is the multiplicative inverse of
- * k
, mod q
; i.e., (k-1 k) mod q =
- * 1
and 0 < k-1 < q
. The value of SHA(M)
- * is a 160-bit string output by the Secure Hash Algorithm specified in FIPS
- * 180. For use in computing s
, this string must be converted to
- * an integer.
- *
- * As an option, one may wish to check if r == 0
or s == 0
- *
.
- * If either r == 0
or s == 0
, a new value of
- * k
should be generated and the signature should be recalculated
- * (it is extremely unlikely that r == 0
or s == 0
if
- * signatures are generated properly).
- *
- * The signature is transmitted along with the message to the verifier.
- *
- * References:
- *
- * - Digital Signature
- * Standard (DSS), Federal Information Processing Standards Publication
- * 186. National Institute of Standards and Technology.
- *
- */
-public class DSSSignature
- extends BaseSignature
-{
- /** Trivial 0-arguments constructor. */
- public DSSSignature()
- {
- super(Registry.DSS_SIG, new Sha160());
- }
-
- /** Private constructor for cloning purposes. */
- private DSSSignature(DSSSignature that)
- {
- this();
-
- this.publicKey = that.publicKey;
- this.privateKey = that.privateKey;
- this.md = (IMessageDigest) that.md.clone();
- }
-
- public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h)
- {
- final DSSSignature sig = new DSSSignature();
- final Map attributes = new HashMap();
- attributes.put(ISignature.SIGNER_KEY, k);
- sig.setupSign(attributes);
- return sig.computeRS(h);
- }
-
- public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h,
- Random rnd)
- {
- final DSSSignature sig = new DSSSignature();
- final Map attributes = new HashMap();
- attributes.put(ISignature.SIGNER_KEY, k);
- if (rnd != null)
- attributes.put(ISignature.SOURCE_OF_RANDOMNESS, rnd);
-
- sig.setupSign(attributes);
- return sig.computeRS(h);
- }
-
- public static final BigInteger[] sign(final DSAPrivateKey k, final byte[] h,
- IRandom irnd)
- {
- final DSSSignature sig = new DSSSignature();
- final Map attributes = new HashMap();
- attributes.put(ISignature.SIGNER_KEY, k);
- if (irnd != null)
- attributes.put(ISignature.SOURCE_OF_RANDOMNESS, irnd);
-
- sig.setupSign(attributes);
- return sig.computeRS(h);
- }
-
- public static final boolean verify(final DSAPublicKey k, final byte[] h,
- final BigInteger[] rs)
- {
- final DSSSignature sig = new DSSSignature();
- final Map attributes = new HashMap();
- attributes.put(ISignature.VERIFIER_KEY, k);
- sig.setupVerify(attributes);
- return sig.checkRS(rs, h);
- }
-
- public Object clone()
- {
- return new DSSSignature(this);
- }
-
- protected void setupForVerification(PublicKey k)
- throws IllegalArgumentException
- {
- if (! (k instanceof DSAPublicKey))
- throw new IllegalArgumentException();
-
- this.publicKey = k;
- }
-
- protected void setupForSigning(PrivateKey k) throws IllegalArgumentException
- {
- if (! (k instanceof DSAPrivateKey))
- throw new IllegalArgumentException();
-
- this.privateKey = k;
- }
-
- protected Object generateSignature() throws IllegalStateException
- {
- final BigInteger[] rs = computeRS(md.digest());
- return encodeSignature(rs[0], rs[1]);
- }
-
- protected boolean verifySignature(Object sig) throws IllegalStateException
- {
- final BigInteger[] rs = decodeSignature(sig);
- return checkRS(rs, md.digest());
- }
-
- /**
- * Returns the output of a signature generation phase.
- *
- * @return an object encapsulating the DSS signature pair r
and
- * s
.
- */
- private Object encodeSignature(BigInteger r, BigInteger s)
- {
- return new BigInteger[] { r, s };
- }
-
- /**
- * Returns the output of a previously generated signature object as a pair of
- * {@link java.math.BigInteger}.
- *
- * @return the DSS signature pair r
and s
.
- */
- private BigInteger[] decodeSignature(Object signature)
- {
- return (BigInteger[]) signature;
- }
-
- private BigInteger[] computeRS(final byte[] digestBytes)
- {
- final BigInteger p = ((DSAPrivateKey) privateKey).getParams().getP();
- final BigInteger q = ((DSAPrivateKey) privateKey).getParams().getQ();
- final BigInteger g = ((DSAPrivateKey) privateKey).getParams().getG();
- final BigInteger x = ((DSAPrivateKey) privateKey).getX();
- final BigInteger m = new BigInteger(1, digestBytes);
- BigInteger k, r, s;
- final byte[] kb = new byte[20]; // we'll use 159 bits only
- while (true)
- {
- this.nextRandomBytes(kb);
- k = new BigInteger(1, kb);
- k.clearBit(159);
- r = g.modPow(k, p).mod(q);
- if (r.equals(BigInteger.ZERO))
- continue;
-
- s = m.add(x.multiply(r)).multiply(k.modInverse(q)).mod(q);
- if (s.equals(BigInteger.ZERO))
- continue;
-
- break;
- }
- return new BigInteger[] { r, s };
- }
-
- private boolean checkRS(final BigInteger[] rs, final byte[] digestBytes)
- {
- final BigInteger r = rs[0];
- final BigInteger s = rs[1];
- final BigInteger g = ((DSAPublicKey) publicKey).getParams().getG();
- final BigInteger p = ((DSAPublicKey) publicKey).getParams().getP();
- final BigInteger q = ((DSAPublicKey) publicKey).getParams().getQ();
- final BigInteger y = ((DSAPublicKey) publicKey).getY();
- final BigInteger w = s.modInverse(q);
- final BigInteger u1 = w.multiply(new BigInteger(1, digestBytes)).mod(q);
- final BigInteger u2 = r.multiply(w).mod(q);
- final BigInteger v = g.modPow(u1, p).multiply(y.modPow(u2, p)).mod(p).mod(q);
- return v.equals(r);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureRawCodec.java b/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureRawCodec.java
deleted file mode 100644
index 903d7aad..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureRawCodec.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/* DSSSignatureRawCodec.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.ISignatureCodec;
-
-import java.io.ByteArrayOutputStream;
-import java.math.BigInteger;
-
-/**
- * An object that implements the {@link ISignatureCodec} operations for the
- * Raw format to use with DSS signatures.
- */
-public class DSSSignatureRawCodec
- implements ISignatureCodec
-{
- public int getFormatID()
- {
- return RAW_FORMAT;
- }
-
- /**
- * Returns the encoded form of the designated DSS (Digital Signature Standard)
- * signature object according to the Raw format supported by this
- * library.
- *
- * The Raw format for a DSA signature, in this implementation, is a
- * byte sequence consisting of the following:
- *
- * - 4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_DSS_SIGNATURE},
- * - 1-byte version consisting of the constant: 0x01,
- * - 4-byte count of following bytes representing the DSS parameter
- *
r
in internet order,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the DSS parameter r
,
- *
- * - 4-byte count of following bytes representing the DSS parameter
- *
s
,
- * - n-bytes representation of a {@link BigInteger} obtained by invoking
- * the
toByteArray()
method on the DSS parameter s
.
- *
- *
- *
- * @param signature the signature to encode, consisting of the two DSS
- * parameters r
and s
as a
- * {@link BigInteger} array.
- * @return the Raw format encoding of the designated signature.
- * @exception IllegalArgumentException if the designated signature is not a
- * DSS (Digital Signature Standard) one.
- */
- public byte[] encodeSignature(Object signature)
- {
- BigInteger r, s;
- try
- {
- BigInteger[] sig = (BigInteger[]) signature;
- r = sig[0];
- s = sig[1];
- }
- catch (Exception x)
- {
- throw new IllegalArgumentException("signature");
- }
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // magic
- baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[0]);
- baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[1]);
- baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[2]);
- baos.write(Registry.MAGIC_RAW_DSS_SIGNATURE[3]);
- // version
- baos.write(0x01);
- // r
- byte[] buffer = r.toByteArray();
- int length = buffer.length;
- baos.write( length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- // s
- buffer = s.toByteArray();
- length = buffer.length;
- baos.write( length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- return baos.toByteArray();
- }
-
- public Object decodeSignature(byte[] k)
- {
- // magic
- if (k[0] != Registry.MAGIC_RAW_DSS_SIGNATURE[0]
- || k[1] != Registry.MAGIC_RAW_DSS_SIGNATURE[1]
- || k[2] != Registry.MAGIC_RAW_DSS_SIGNATURE[2]
- || k[3] != Registry.MAGIC_RAW_DSS_SIGNATURE[3])
- throw new IllegalArgumentException("magic");
- // version
- if (k[4] != 0x01)
- throw new IllegalArgumentException("version");
-
- int i = 5;
- int l;
- byte[] buffer;
- // r
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger r = new BigInteger(1, buffer);
- // s
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- buffer = new byte[l];
- System.arraycopy(k, i, buffer, 0, l);
- i += l;
- BigInteger s = new BigInteger(1, buffer);
- return new BigInteger[] { r, s };
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureX509Codec.java b/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureX509Codec.java
deleted file mode 100644
index 0fdb754a..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/dss/DSSSignatureX509Codec.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/* DSSSignatureX509Codec.java -- X.509 encoder/decoder for DSS signatures
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.sig.dss;
-
-import gnu.java.security.Registry;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.der.DERWriter;
-import gnu.java.security.sig.ISignatureCodec;
-import gnu.java.security.util.DerUtil;
-
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-
-/**
- * An implementation of an {@link ISignatureCodec} that knows to encode and
- * decode DSS signatures into the raw bytes which would constitute a DER-encoded
- * form of the ASN.1 structure defined in RFC-2459, and RFC-2313 as described in
- * the next paragraphs.
- *
- * Digital signatures when transmitted in an X.509 certificates are encoded
- * in DER (Distinguished Encoding Rules) as a BIT STRING; i.e.
- *
- *
- * Certificate ::= SEQUENCE {
- * tbsCertificate TBSCertificate,
- * signatureAlgorithm AlgorithmIdentifier,
- * signature BIT STRING
- * }
- *
- *
- * The output of the encoder, and the input of the decoder, of this codec are
- * then the raw bytes of such a BIT STRING; i.e. not the DER-encoded
- * form itself.
- *
- * RFC-2459 states that, for the Digital Signature Standard (DSS), which
- * generates two MPIs, commonly called r
and s
, as the
- * result of digitally signing a message, these two numbers will be transferred
- * as the following ASN.1 structure:
- *
- *
- * Dss-Sig-Value ::= SEQUENCE {
- * r INTEGER,
- * s INTEGER
- * }
- *
- *
- * Client code that needs to build a DER BIT STRING MUST construct such
- * an ASN.1 value. The following is an example of how to do this:
- *
- *
- * ...
- * import gnu.java.security.der.BitString;
- * import gnu.java.security.der.DER;
- * import gnu.java.security.der.DERValue;
- * ...
- * DERValue bitString = new DERValue(DER.BIT_STRING, new BitString(sigBytes));
- * ...
- *
- */
-public class DSSSignatureX509Codec
- implements ISignatureCodec
-{
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return Registry.X509_ENCODING_ID;
- }
-
- /**
- * Encodes a DSS Signature output as the signature raw bytes which can
- * be used to construct an ASN.1 DER-encoded BIT STRING as defined in the
- * documentation of this class.
- *
- * @param signature the output of the DSS signature algorithm; i.e. the value
- * returned by the invocation of
- * {@link gnu.java.security.sig.ISignature#sign()} method. In the
- * case of a DSS signature this is an array of two MPIs called
- * r
and s
.
- * @return the raw bytes of a DSS signature which could be then used as the
- * contents of a BIT STRING as per rfc-2459.
- * @throws InvalidParameterException if an exception occurs during the
- * marshalling process.
- */
- public byte[] encodeSignature(Object signature)
- {
- BigInteger[] rs = (BigInteger[]) signature;
-
- DERValue derR = new DERValue(DER.INTEGER, rs[0]);
- DERValue derS = new DERValue(DER.INTEGER, rs[1]);
-
- ArrayList dssSigValue = new ArrayList(2);
- dssSigValue.add(derR);
- dssSigValue.add(derS);
- DERValue derDssSigValue = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- dssSigValue);
- byte[] result;
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- try
- {
- DERWriter.write(baos, derDssSigValue);
- result = baos.toByteArray();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException();
- y.initCause(x);
- throw y;
- }
-
- return result;
- }
-
- /**
- * Decodes a signature as defined in the documentation of this class.
- *
- * @param input the byte array to unmarshall into a valid DSS signature
- * instance; i.e. an array of two MPIs. MUST NOT be null.
- * @return an array of two MPIs, r
and s
in this
- * order, decoded from the designated input
.
- * @throw InvalidParameterException if an exception occurs during the
- * unmarshalling process.
- */
- public Object decodeSignature(byte[] input)
- {
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- BigInteger r, s;
- DERReader der = new DERReader(input);
- try
- {
- DERValue derDssSigValue = der.read();
- DerUtil.checkIsConstructed(derDssSigValue, "Wrong Dss-Sig-Value field");
-
- DERValue val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong R field");
- r = (BigInteger) val.getValue();
- val = der.read();
- DerUtil.checkIsBigInteger(val, "Wrong S field");
- s = (BigInteger) val.getValue();
- }
- catch (IOException x)
- {
- InvalidParameterException y = new InvalidParameterException();
- y.initCause(x);
- throw y;
- }
-
- return new BigInteger[] { r, s };
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java
deleted file mode 100644
index 39de01f0..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EME_PKCS1_V1_5.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/* EME_PKCS1_V1_5.java --
- Copyright (C) 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.prng.IRandom;
-import gnu.java.security.prng.LimitReachedException;
-import gnu.java.security.util.PRNG;
-
-import java.io.ByteArrayOutputStream;
-import java.security.interfaces.RSAKey;
-import java.util.Random;
-
-/**
- * An implementation of the EME-PKCS1-V1.5 encoding and decoding methods.
- *
- * EME-PKCS1-V1.5 is parameterised by the entity k
which is the
- * byte count of an RSA public shared modulus.
- *
- * References:
- *
- * - Public-Key Cryptography
- * Standards (PKCS) #1:
- * RSA Cryptography Specifications Version 2.1.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class EME_PKCS1_V1_5
-{
- private int k;
-
- private ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- /** Our default source of randomness. */
- private PRNG prng = PRNG.getInstance();
-
- private EME_PKCS1_V1_5(final int k)
- {
- super();
-
- this.k = k;
- }
-
- public static final EME_PKCS1_V1_5 getInstance(final int k)
- {
- if (k < 0)
- throw new IllegalArgumentException("k must be a positive integer");
-
- return new EME_PKCS1_V1_5(k);
- }
-
- public static final EME_PKCS1_V1_5 getInstance(final RSAKey key)
- {
- final int modBits = key.getModulus().bitLength();
- final int k = (modBits + 7) / 8;
- return EME_PKCS1_V1_5.getInstance(k);
- }
-
- /**
- * Generates an octet string PS
of length k - mLen -
- * 3
consisting of pseudo-randomly generated nonzero octets. The length
- * of PS
will be at least eight octets.
- *
- * The method then concatenates PS
, the message M
,
- * and other padding to form an encoded message EM
of length
- * k
octets as:
- *
- * EM = 0x00 || 0x02 || PS || 0x00 || M.
- *
- *
- * This method uses a default PRNG to obtain the padding bytes.
- *
- * @param M the message to encode.
- * @return the encoded message EM
.
- */
- public byte[] encode(final byte[] M)
- {
- // a. Generate an octet string PS of length k - mLen - 3 consisting
- // of pseudo-randomly generated nonzero octets. The length of PS
- // will be at least eight octets.
- final byte[] PS = new byte[k - M.length - 3];
- // FIXME. This should be configurable, somehow.
- prng.nextBytes(PS);
- int i = 0;
- for (; i < PS.length; i++)
- {
- if (PS[i] == 0)
- PS[i] = 1;
- }
- // b. Concatenate PS, the message M, and other padding to form an
- // encoded message EM of length k octets as
- //
- // EM = 0x00 || 0x02 || PS || 0x00 || M.
- return assembleEM(PS, M);
- }
-
- /**
- * Similar to {@link #encode(byte[])} method, except that the source of
- * randomness to use for obtaining the padding bytes (an instance of
- * {@link IRandom}) is given as a parameter.
- *
- * @param M the message to encode.
- * @param irnd the {@link IRandom} instance to use as a source of randomness.
- * @return the encoded message EM
.
- */
- public byte[] encode(final byte[] M, final IRandom irnd)
- {
- final byte[] PS = new byte[k - M.length - 3];
- try
- {
- irnd.nextBytes(PS, 0, PS.length);
- int i = 0;
- outer: while (true)
- {
- for (; i < PS.length; i++)
- {
- if (PS[i] == 0x00)
- {
- System.arraycopy(PS, i + 1, PS, i, PS.length - i - 1);
- irnd.nextBytes(PS, PS.length - 1, 1);
- continue outer;
- }
- }
- break;
- }
- }
- catch (IllegalStateException x)
- {
- throw new RuntimeException("encode(): " + String.valueOf(x));
- }
- catch (LimitReachedException x)
- {
- throw new RuntimeException("encode(): " + String.valueOf(x));
- }
- return assembleEM(PS, M);
- }
-
- /**
- * Similar to the {@link #encode(byte[], IRandom)} method, except that the
- * source of randmoness is an instance of {@link Random}.
- *
- * @param M the message to encode.
- * @param rnd the {@link Random} instance to use as a source of randomness.
- * @return the encoded message EM
.
- */
- public byte[] encode(final byte[] M, final Random rnd)
- {
- final byte[] PS = new byte[k - M.length - 3];
- rnd.nextBytes(PS);
- int i = 0;
- outer: while (true)
- {
- for (; i < PS.length; i++)
- {
- if (PS[i] == 0x00)
- {
- System.arraycopy(PS, i + 1, PS, i, PS.length - i - 1);
- PS[PS.length - 1] = (byte) rnd.nextInt();
- continue outer;
- }
- }
- break;
- }
- return assembleEM(PS, M);
- }
-
- /**
- * Separate the encoded message EM
into an octet string
- * PS
consisting of nonzero octets and a message M
- * as:
- *
- * EM = 0x00 || 0x02 || PS || 0x00 || M.
- *
- *
- * If the first octet of EM
does not have hexadecimal value
- * 0x00
, if the second octet of EM
does not
- * have hexadecimal value 0x02
, if there is no octet with
- * hexadecimal value 0x00
to separate PS
from
- * M
, or if the length of PS
is less than
- * 8
octets, output "decryption error" and stop.
- *
- * @param EM the designated encoded message.
- * @return the decoded message M
framed in the designated
- * EM
value.
- * @throws IllegalArgumentException if the length of the designated entity
- * EM
is different than k
(the length
- * in bytes of the public shared modulus), or if any of the
- * conditions described above is detected.
- */
- public byte[] decode(final byte[] EM)
- {
- // Separate the encoded message EM into an
- // octet string PS consisting of nonzero octets and a message M as
- //
- // EM = 0x00 || 0x02 || PS || 0x00 || M.
- //
- // If the first octet of EM does not have hexadecimal value 0x00, if
- // the second octet of EM does not have hexadecimal value 0x02, if
- // there is no octet with hexadecimal value 0x00 to separate PS from
- // M, or if the length of PS is less than 8 octets, output
- // "decryption error" and stop. (See the note below.)
- final int emLen = EM.length;
- if (emLen != k)
- throw new IllegalArgumentException("decryption error");
- if (EM[0] != 0x00)
- throw new IllegalArgumentException("decryption error");
- if (EM[1] != 0x02)
- throw new IllegalArgumentException("decryption error");
- int i = 2;
- for (; i < emLen; i++)
- {
- if (EM[i] == 0x00)
- break;
- }
- if (i >= emLen || i < 11)
- throw new IllegalArgumentException("decryption error");
- i++;
- final byte[] result = new byte[emLen - i];
- System.arraycopy(EM, i, result, 0, result.length);
- return result;
- }
-
- private byte[] assembleEM(final byte[] PS, final byte[] M)
- {
- // b. Concatenate PS, the message M, and other padding to form an
- // encoded message EM of length k octets as
- //
- // EM = 0x00 || 0x02 || PS || 0x00 || M.
- baos.reset();
- baos.write(0x00);
- baos.write(0x02);
- baos.write(PS, 0, PS.length);
- baos.write(0x00);
- baos.write(M, 0, M.length);
- final byte[] result = baos.toByteArray();
- baos.reset();
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java
deleted file mode 100644
index a0c4de17..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PKCS1_V1_5.java
+++ /dev/null
@@ -1,243 +0,0 @@
-/* EMSA_PKCS1_V1_5.java --
- Copyright (C) 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-
-import java.io.ByteArrayOutputStream;
-
-/**
- * An implementation of the EMSA-PKCS1-V1.5 encoding scheme.
- *
- * EMSA-PKCS1-V1.5 is parameterised by the choice of hash function Hash and
- * hLen which denotes the length in octets of the hash function output.
- *
- * References:
- *
- * - Public-Key Cryptography
- * Standards (PKCS) #1:
- * RSA Cryptography Specifications Version 2.1.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class EMSA_PKCS1_V1_5
- implements Cloneable
-{
- /* Notes.
- 1. For the six hash functions mentioned in Appendix B.1, the DER encoding
- T of the DigestInfo value is equal to the following:
-
- MD2: (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 02 05 00 04 10 || H
- MD5: (0x)30 20 30 0c 06 08 2a 86 48 86 f7 0d 02 05 05 00 04 10 || H
- SHA-1: (0x)30 21 30 09 06 05 2b 0e 03 02 1a 05 00 04 14 || H
- SHA-256: (0x)30 31 30 0d 06 09 60 86 48 01 65 03 04 02 01 05 00 04 20 || H
- SHA-384: (0x)30 41 30 0d 06 09 60 86 48 01 65 03 04 02 02 05 00 04 30 || H
- SHA-512: (0x)30 51 30 0d 06 09 60 86 48 01 65 03 04 02 03 05 00 04 40 || H
- */
- private static final byte[] MD2_PREFIX = {
- (byte) 0x30, (byte) 0x20, (byte) 0x30, (byte) 0x0c, (byte) 0x06,
- (byte) 0x08, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86,
- (byte) 0xf7, (byte) 0x0d, (byte) 0x02, (byte) 0x02, (byte) 0x05,
- (byte) 0x00, (byte) 0x04, (byte) 0x10
- };
-
- private static final byte[] MD5_PREFIX = {
- (byte) 0x30, (byte) 0x20, (byte) 0x30, (byte) 0x0c, (byte) 0x06,
- (byte) 0x08, (byte) 0x2a, (byte) 0x86, (byte) 0x48, (byte) 0x86,
- (byte) 0xf7, (byte) 0x0d, (byte) 0x02, (byte) 0x05, (byte) 0x05,
- (byte) 0x00, (byte) 0x04, (byte) 0x10
- };
-
- private static final byte[] SHA160_PREFIX = {
- (byte) 0x30, (byte) 0x21, (byte) 0x30, (byte) 0x09, (byte) 0x06,
- (byte) 0x05, (byte) 0x2b, (byte) 0x0e, (byte) 0x03, (byte) 0x02,
- (byte) 0x1a, (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x14
- };
-
- private static final byte[] SHA256_PREFIX = {
- (byte) 0x30, (byte) 0x31, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
- (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x01,
- (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x20
- };
-
- private static final byte[] SHA384_PREFIX = {
- (byte) 0x30, (byte) 0x41, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
- (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x02,
- (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x30
- };
-
- private static final byte[] SHA512_PREFIX = {
- (byte) 0x30, (byte) 0x51, (byte) 0x30, (byte) 0x0d, (byte) 0x06,
- (byte) 0x09, (byte) 0x60, (byte) 0x86, (byte) 0x48, (byte) 0x01,
- (byte) 0x65, (byte) 0x03, (byte) 0x04, (byte) 0x02, (byte) 0x03,
- (byte) 0x05, (byte) 0x00, (byte) 0x04, (byte) 0x40
- };
-
- /** The underlying hash function to use with this instance. */
- private IMessageDigest hash;
-
- /** The output size of the hash function in octets. */
- private int hLen; // TODO: field not used!!! investigate
-
- /** The DER part of DigestInfo not containing the hash value itself. */
- private byte[] prefix;
-
- /**
- * Trivial private constructor to enforce use through Factory method.
- *
- * @param hash the message digest instance to use with this scheme instance.
- */
- private EMSA_PKCS1_V1_5(final IMessageDigest hash)
- {
- super();
-
- this.hash = hash;
- hLen = hash.hashSize();
- final String name = hash.name();
- if (name.equals(Registry.MD2_HASH))
- prefix = MD2_PREFIX;
- else if (name.equals(Registry.MD5_HASH))
- prefix = MD5_PREFIX;
- else if (name.equals(Registry.SHA160_HASH))
- prefix = SHA160_PREFIX;
- else if (name.equals(Registry.SHA256_HASH))
- prefix = SHA256_PREFIX;
- else if (name.equals(Registry.SHA384_HASH))
- prefix = SHA384_PREFIX;
- else if (name.equals(Registry.SHA512_HASH))
- prefix = SHA512_PREFIX;
- else
- throw new UnsupportedOperationException(); // should not happen
- }
-
- /**
- * Returns an instance of this object given a designated name of a hash
- * function.
- *
- * @param mdName the canonical name of a hash function.
- * @return an instance of this object configured for use with the designated
- * options.
- * @throws UnsupportedOperationException if the hash function is not
- * implemented or does not have an ID listed in RFC-3447.
- */
- public static final EMSA_PKCS1_V1_5 getInstance(final String mdName)
- {
- final IMessageDigest hash = HashFactory.getInstance(mdName);
- final String name = hash.name();
- if (! (name.equals(Registry.MD2_HASH)
- || name.equals(Registry.MD5_HASH)
- || name.equals(Registry.SHA160_HASH)
- || name.equals(Registry.SHA256_HASH)
- || name.equals(Registry.SHA384_HASH)
- || name.equals(Registry.SHA512_HASH)))
- throw new UnsupportedOperationException("hash with no OID: " + name);
-
- return new EMSA_PKCS1_V1_5(hash);
- }
-
- public Object clone()
- {
- return getInstance(hash.name());
- }
-
- /**
- * Frames the hash of a message, along with an ID of the hash function in
- * a DER sequence according to the specifications of EMSA-PKCS1-V1.5 as
- * described in RFC-3447 (see class documentation).
- *
- * @param mHash the byte sequence resulting from applying the message digest
- * algorithm Hash to the message M.
- * @param emLen intended length in octets of the encoded message, at least
- * tLen + 11
, where tLen
is the octet length of the
- * DER encoding T
of a certain value computed during the
- * encoding operation.
- * @return encoded message, an octet string of length emLen
.
- * @throws IllegalArgumentException if the message is too long, or if the
- * intended encoded message length is too short.
- */
- public byte[] encode(final byte[] mHash, final int emLen)
- {
- // 1. Apply the hash function to the message M to produce a hash value
- // H: H = Hash(M).
- // If the hash function outputs "message too long," output "message
- // too long" and stop.
- // 2. Encode the algorithm ID for the hash function and the hash value
- // into an ASN.1 value of type DigestInfo (see Appendix A.2.4) with
- // the Distinguished Encoding Rules (DER), where the type DigestInfo
- // has the syntax
- // DigestInfo ::= SEQUENCE {
- // digestAlgorithm AlgorithmIdentifier,
- // digest OCTET STRING
- // }
- // The first field identifies the hash function and the second contains
- // the hash value. Let T be the DER encoding of the DigestInfo value
- // (see the notes below) and let tLen be the length in octets of T.
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- baos.write(prefix, 0, prefix.length);
- baos.write(mHash, 0, mHash.length);
- final byte[] T = baos.toByteArray();
- final int tLen = T.length;
- // 3. If emLen < tLen + 11, output "intended encoded message length too
- // short" and stop.
- if (emLen < tLen + 11)
- throw new IllegalArgumentException("emLen too short");
- // 4. Generate an octet string PS consisting of emLen - tLen - 3 octets
- // with hexadecimal value 0xff. The length of PS will be at least 8
- // octets.
- final byte[] PS = new byte[emLen - tLen - 3];
- for (int i = 0; i < PS.length; i++)
- PS[i] = (byte) 0xFF;
- // 5. Concatenate PS, the DER encoding T, and other padding to form the
- // encoded message EM as: EM = 0x00 || 0x01 || PS || 0x00 || T.
- baos.reset();
- baos.write(0x00);
- baos.write(0x01);
- baos.write(PS, 0, PS.length);
- baos.write(0x00);
- baos.write(T, 0, tLen);
- final byte[] result = baos.toByteArray();
- baos.reset();
- // 6. Output EM.
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PSS.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PSS.java
deleted file mode 100644
index 97b3afcf..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/EMSA_PSS.java
+++ /dev/null
@@ -1,371 +0,0 @@
-/* EMSA_PSS.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.util.Util;
-
-import java.util.Arrays;
-import java.util.logging.Logger;
-
-/**
- * An implementation of the EMSA-PSS encoding/decoding scheme.
- *
- * EMSA-PSS coincides with EMSA4 in IEEE P1363a D5 except that EMSA-PSS acts on
- * octet strings and not on bit strings. In particular, the bit lengths of the
- * hash and the salt must be multiples of 8 in EMSA-PSS. Moreover, EMSA4 outputs
- * an integer of a desired bit length rather than an octet string.
- *
- * EMSA-PSS is parameterized by the choice of hash function Hash and mask
- * generation function MGF. In this submission, MGF is based on a Hash
- * definition that coincides with the corresponding definitions in IEEE Std
- * 1363-2000, PKCS #1 v2.0, and the draft ANSI X9.44. In PKCS #1 v2.0 and the
- * draft ANSI X9.44, the recommended hash function is SHA-1, while IEEE Std
- * 1363-2000 recommends SHA-1 and RIPEMD-160.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class EMSA_PSS
- implements Cloneable
-{
- private static final Logger log = Logger.getLogger(EMSA_PSS.class.getName());
-
- /** The underlying hash function to use with this instance. */
- private IMessageDigest hash;
-
- /** The output size of the hash function in octets. */
- private int hLen;
-
- /**
- * Trivial private constructor to enforce use through Factory method.
- *
- * @param hash the message digest instance to use with this scheme instance.
- */
- private EMSA_PSS(IMessageDigest hash)
- {
- super();
-
- this.hash = hash;
- hLen = hash.hashSize();
- }
-
- /**
- * Returns an instance of this object given a designated name of a hash
- * function.
- *
- * @param mdName the canonical name of a hash function.
- * @return an instance of this object configured for use with the designated
- * options.
- */
- public static EMSA_PSS getInstance(String mdName)
- {
- IMessageDigest hash = HashFactory.getInstance(mdName);
- return new EMSA_PSS(hash);
- }
-
- public Object clone()
- {
- return getInstance(hash.name());
- }
-
- /**
- * The encoding operation EMSA-PSS-Encode computes the hash of a message
- * M
using a hash function and maps the result to an encoded
- * message EM
of a specified length using a mask generation
- * function.
- *
- * @param mHash the byte sequence resulting from applying the message digest
- * algorithm Hash to the message M.
- * @param emBits the maximal bit length of the integer OS2IP(EM), at least
- * 8.hLen + 8.sLen + 9
.
- * @param salt the salt to use when encoding the output.
- * @return the encoded message EM
, an octet string of length
- * emLen = CEILING(emBits / 8)
.
- * @exception IllegalArgumentException if an exception occurs.
- */
- public byte[] encode(byte[] mHash, int emBits, byte[] salt)
- {
- int sLen = salt.length;
- // 1. If the length of M is greater than the input limitation for the hash
- // function (2**61 - 1 octets for SHA-1) then output "message too long"
- // and stop.
- // 2. Let mHash = Hash(M), an octet string of length hLen.
- if (hLen != mHash.length)
- throw new IllegalArgumentException("wrong hash");
- // 3. If emBits < 8.hLen + 8.sLen + 9, output 'encoding error' and stop.
- if (emBits < (8 * hLen + 8 * sLen + 9))
- throw new IllegalArgumentException("encoding error");
- int emLen = (emBits + 7) / 8;
- // 4. Generate a random octet string salt of length sLen; if sLen = 0,
- // then salt is the empty string.
- // ...passed as argument to accomodate JCE
- // 5. Let M0 = 00 00 00 00 00 00 00 00 || mHash || salt;
- // M0 is an octet string of length 8 + hLen + sLen with eight initial zero
- // octets.
- // 6. Let H = Hash(M0), an octet string of length hLen.
- byte[] H;
- int i;
- synchronized (hash)
- {
- for (i = 0; i < 8; i++)
- hash.update((byte) 0x00);
-
- hash.update(mHash, 0, hLen);
- hash.update(salt, 0, sLen);
- H = hash.digest();
- }
- // 7. Generate an octet string PS consisting of emLen - sLen - hLen - 2
- // zero octets. The length of PS may be 0.
- // 8. Let DB = PS || 01 || salt.
- byte[] DB = new byte[emLen - sLen - hLen - 2 + 1 + sLen];
- DB[emLen - sLen - hLen - 2] = 0x01;
- System.arraycopy(salt, 0, DB, emLen - sLen - hLen - 1, sLen);
- // 9. Let dbMask = MGF(H, emLen - hLen - 1).
- byte[] dbMask = MGF(H, emLen - hLen - 1);
- if (Configuration.DEBUG)
- {
- log.fine("dbMask (encode): " + Util.toString(dbMask));
- log.fine("DB (encode): " + Util.toString(DB));
- }
- // 10. Let maskedDB = DB XOR dbMask.
- for (i = 0; i < DB.length; i++)
- DB[i] = (byte)(DB[i] ^ dbMask[i]);
- // 11. Set the leftmost 8emLen - emBits bits of the leftmost octet in
- // maskedDB to zero.
- DB[0] &= (0xFF >>> (8 * emLen - emBits));
- // 12. Let EM = maskedDB || H || bc, where bc is the single octet with
- // hexadecimal value 0xBC.
- byte[] result = new byte[emLen];
- System.arraycopy(DB, 0, result, 0, emLen - hLen - 1);
- System.arraycopy(H, 0, result, emLen - hLen - 1, hLen);
- result[emLen - 1] = (byte) 0xBC;
- // 13. Output EM.
- return result;
- }
-
- /**
- * The decoding operation EMSA-PSS-Decode recovers the message hash from an
- * encoded message EM
and compares it to the hash of
- * M
.
- *
- * @param mHash the byte sequence resulting from applying the message digest
- * algorithm Hash to the message M.
- * @param EM the encoded message, an octet string of length
- * emLen = CEILING(emBits/8).
- * @param emBits the maximal bit length of the integer OS2IP(EM), at least
- * 8.hLen + 8.sLen + 9
.
- * @param sLen the length, in octets, of the expected salt.
- * @return true
if the result of the verification was
- * consistent with the expected reseult; and false
if the
- * result was inconsistent.
- * @exception IllegalArgumentException if an exception occurs.
- */
- public boolean decode(byte[] mHash, byte[] EM, int emBits, int sLen)
- {
- if (Configuration.DEBUG)
- {
- log.fine("mHash: " + Util.toString(mHash));
- log.fine("EM: " + Util.toString(EM));
- log.fine("emBits: " + String.valueOf(emBits));
- log.fine("sLen: " + String.valueOf(sLen));
- }
- if (sLen < 0)
- throw new IllegalArgumentException("sLen");
- // 1. If the length of M is greater than the input limitation for the hash
- // function (2**61 ? 1 octets for SHA-1) then output 'inconsistent' and
- // stop.
- // 2. Let mHash = Hash(M), an octet string of length hLen.
- if (hLen != mHash.length)
- {
- if (Configuration.DEBUG)
- log.fine("hLen != mHash.length; hLen: " + String.valueOf(hLen));
- throw new IllegalArgumentException("wrong hash");
- }
- // 3. If emBits < 8.hLen + 8.sLen + 9, output 'decoding error' and stop.
- if (emBits < (8 * hLen + 8 * sLen + 9))
- {
- if (Configuration.DEBUG)
- log.fine("emBits < (8hLen + 8sLen + 9); sLen: "
- + String.valueOf(sLen));
- throw new IllegalArgumentException("decoding error");
- }
- int emLen = (emBits + 7) / 8;
- // 4. If the rightmost octet of EM does not have hexadecimal value bc,
- // output 'inconsistent' and stop.
- if ((EM[EM.length - 1] & 0xFF) != 0xBC)
- {
- if (Configuration.DEBUG)
- log.fine("EM does not end with 0xBC");
- return false;
- }
- // 5. Let maskedDB be the leftmost emLen ? hLen ? 1 octets of EM, and let
- // H be the next hLen octets.
- // 6. If the leftmost 8.emLen ? emBits bits of the leftmost octet in
- // maskedDB are not all equal to zero, output 'inconsistent' and stop.
- if ((EM[0] & (0xFF << (8 - (8 * emLen - emBits)))) != 0)
- {
- if (Configuration.DEBUG)
- log.fine("Leftmost 8emLen - emBits bits of EM are not 0s");
- return false;
- }
- byte[] DB = new byte[emLen - hLen - 1];
- byte[] H = new byte[hLen];
- System.arraycopy(EM, 0, DB, 0, emLen - hLen - 1);
- System.arraycopy(EM, emLen - hLen - 1, H, 0, hLen);
- // 7. Let dbMask = MGF(H, emLen ? hLen ? 1).
- byte[] dbMask = MGF(H, emLen - hLen - 1);
- // 8. Let DB = maskedDB XOR dbMask.
- int i;
- for (i = 0; i < DB.length; i++)
- DB[i] = (byte)(DB[i] ^ dbMask[i]);
- // 9. Set the leftmost 8.emLen ? emBits bits of DB to zero.
- DB[0] &= (0xFF >>> (8 * emLen - emBits));
- if (Configuration.DEBUG)
- {
- log.fine("dbMask (decode): " + Util.toString(dbMask));
- log.fine("DB (decode): " + Util.toString(DB));
- }
- // 10. If the emLen -hLen -sLen -2 leftmost octets of DB are not zero or
- // if the octet at position emLen -hLen -sLen -1 is not equal to 0x01,
- // output 'inconsistent' and stop.
- // IMPORTANT (rsn): this is an error in the specs, the index of the 0x01
- // byte should be emLen -hLen -sLen -2 and not -1! authors have been advised
- for (i = 0; i < (emLen - hLen - sLen - 2); i++)
- {
- if (DB[i] != 0)
- {
- if (Configuration.DEBUG)
- log.fine("DB[" + String.valueOf(i) + "] != 0x00");
- return false;
- }
- }
- if (DB[i] != 0x01)
- { // i == emLen -hLen -sLen -2
- if (Configuration.DEBUG)
- log.fine("DB's byte at position (emLen -hLen -sLen -2); i.e. "
- + String.valueOf(i) + " is not 0x01");
- return false;
- }
- // 11. Let salt be the last sLen octets of DB.
- byte[] salt = new byte[sLen];
- System.arraycopy(DB, DB.length - sLen, salt, 0, sLen);
- // 12. Let M0 = 00 00 00 00 00 00 00 00 || mHash || salt;
- // M0 is an octet string of length 8 + hLen + sLen with eight initial
- // zero octets.
- // 13. Let H0 = Hash(M0), an octet string of length hLen.
- byte[] H0;
- synchronized (hash)
- {
- for (i = 0; i < 8; i++)
- hash.update((byte) 0x00);
-
- hash.update(mHash, 0, hLen);
- hash.update(salt, 0, sLen);
- H0 = hash.digest();
- }
- // 14. If H = H0, output 'consistent.' Otherwise, output 'inconsistent.'
- return Arrays.equals(H, H0);
- }
-
- /**
- * A mask generation function takes an octet string of variable length and a
- * desired output length as input, and outputs an octet string of the desired
- * length. There may be restrictions on the length of the input and output
- * octet strings, but such bounds are generally very large. Mask generation
- * functions are deterministic; the octet string output is completely
- * determined by the input octet string. The output of a mask generation
- * function should be pseudorandom, that is, it should be infeasible to
- * predict, given one part of the output but not the input, another part of
- * the output. The provable security of RSA-PSS relies on the random nature of
- * the output of the mask generation function, which in turn relies on the
- * random nature of the underlying hash function.
- *
- * @param Z a seed.
- * @param l the desired output length in octets.
- * @return the mask.
- * @exception IllegalArgumentException if the desired output length is too
- * long.
- */
- private byte[] MGF(byte[] Z, int l)
- {
- // 1. If l > (2**32).hLen, output 'mask too long' and stop.
- if (l < 1 || (l & 0xFFFFFFFFL) > ((hLen & 0xFFFFFFFFL) << 32L))
- throw new IllegalArgumentException("mask too long");
- // 2. Let T be the empty octet string.
- byte[] result = new byte[l];
- // 3. For i = 0 to CEILING(l/hLen) ? 1, do
- int limit = ((l + hLen - 1) / hLen) - 1;
- IMessageDigest hashZ = null;
- hashZ = (IMessageDigest) hash.clone();
- hashZ.digest();
- hashZ.update(Z, 0, Z.length);
- IMessageDigest hashZC = null;
- byte[] t;
- int sofar = 0;
- int length;
- for (int i = 0; i < limit; i++)
- {
- // 3.1 Convert i to an octet string C of length 4 with the primitive
- // I2OSP: C = I2OSP(i, 4).
- // 3.2 Concatenate the hash of the seed Z and C to the octet string T:
- // T = T || Hash(Z || C)
- hashZC = (IMessageDigest) hashZ.clone();
- hashZC.update((byte)(i >>> 24));
- hashZC.update((byte)(i >>> 16));
- hashZC.update((byte)(i >>> 8));
- hashZC.update((byte) i);
- t = hashZC.digest();
- length = l - sofar;
- length = (length > hLen ? hLen : length);
- System.arraycopy(t, 0, result, sofar, length);
- sofar += length;
- }
- // 4. Output the leading l octets of T as the octet string mask.
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSA.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSA.java
deleted file mode 100644
index cdd9eaa5..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSA.java
+++ /dev/null
@@ -1,324 +0,0 @@
-/* RSA.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Properties;
-import gnu.java.security.util.PRNG;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPrivateCrtKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-
-/**
- * Utility methods related to the RSA algorithm.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- * - Public-Key Cryptography
- * Standards (PKCS) #1:
- * RSA Cryptography Specifications Version 2.1.
- * Jakob Jonsson and Burt Kaliski.
- * -
- * Remote timing attacks are practical
- * D. Boneh and D. Brumley.
- *
- */
-public class RSA
-{
- private static final BigInteger ZERO = BigInteger.ZERO;
-
- private static final BigInteger ONE = BigInteger.ONE;
-
- /** Our default source of randomness. */
- private static final PRNG prng = PRNG.getInstance();
-
- /** Trivial private constructor to enforce Singleton pattern. */
- private RSA()
- {
- super();
- }
-
- /**
- * An implementation of the RSASP method: Assuming that the designated
- * RSA private key is a valid one, this method computes a signature
- * representative for a designated message representative signed
- * by the holder of the designated RSA private key.
- *
- * @param K the RSA private key.
- * @param m the message representative: an integer between
- * 0
and n - 1
, where n
- * is the RSA modulus.
- * @return the signature representative, an integer between
- * 0
and n - 1
, where n
- * is the RSA modulus.
- * @throws ClassCastException if K
is not an RSA one.
- * @throws IllegalArgumentException if m
(the message
- * representative) is out of range.
- */
- public static final BigInteger sign(final PrivateKey K, final BigInteger m)
- {
- try
- {
- return RSADP((RSAPrivateKey) K, m);
- }
- catch (IllegalArgumentException x)
- {
- throw new IllegalArgumentException("message representative out of range");
- }
- }
-
- /**
- * An implementation of the RSAVP method: Assuming that the designated
- * RSA public key is a valid one, this method computes a message
- * representative for the designated signature representative
- * generated by an RSA private key, for a message intended for the holder of
- * the designated RSA public key.
- *
- * @param K the RSA public key.
- * @param s the signature representative, an integer between
- * 0
and n - 1
, where n
- * is the RSA modulus.
- * @return a message representative: an integer between 0
- * and n - 1
, where n
is the RSA
- * modulus.
- * @throws ClassCastException if K
is not an RSA one.
- * @throws IllegalArgumentException if s
(the signature
- * representative) is out of range.
- */
- public static final BigInteger verify(final PublicKey K, final BigInteger s)
- {
- try
- {
- return RSAEP((RSAPublicKey) K, s);
- }
- catch (IllegalArgumentException x)
- {
- throw new IllegalArgumentException("signature representative out of range");
- }
- }
-
- /**
- * An implementation of the RSAEP
algorithm.
- *
- * @param K the recipient's RSA public key.
- * @param m the message representative as an MPI.
- * @return the resulting MPI --an MPI between 0
and
- * n - 1
(n
being the public shared
- * modulus)-- that will eventually be padded with an appropriate
- * framing/padding scheme.
- * @throws ClassCastException if K
is not an RSA one.
- * @throws IllegalArgumentException if m
, the message
- * representative is not between 0
and
- * n - 1
(n
being the public shared
- * modulus).
- */
- public static final BigInteger encrypt(final PublicKey K, final BigInteger m)
- {
- try
- {
- return RSAEP((RSAPublicKey) K, m);
- }
- catch (IllegalArgumentException x)
- {
- throw new IllegalArgumentException("message representative out of range");
- }
- }
-
- /**
- * An implementation of the RSADP
algorithm.
- *
- * @param K the recipient's RSA private key.
- * @param c the ciphertext representative as an MPI.
- * @return the message representative, an MPI between 0
and
- * n - 1
(n
being the shared public
- * modulus).
- * @throws ClassCastException if K
is not an RSA one.
- * @throws IllegalArgumentException if c
, the ciphertext
- * representative is not between 0
and
- * n - 1
(n
being the shared public
- * modulus).
- */
- public static final BigInteger decrypt(final PrivateKey K, final BigInteger c)
- {
- try
- {
- return RSADP((RSAPrivateKey) K, c);
- }
- catch (IllegalArgumentException x)
- {
- throw new IllegalArgumentException("ciphertext representative out of range");
- }
- }
-
- /**
- * Converts a multi-precision integer (MPI) s
into an
- * octet sequence of length k
.
- *
- * @param s the multi-precision integer to convert.
- * @param k the length of the output.
- * @return the result of the transform.
- * @exception IllegalArgumentException if the length in octets of meaningful
- * bytes of s
is greater than k
.
- */
- public static final byte[] I2OSP(final BigInteger s, final int k)
- {
- byte[] result = s.toByteArray();
- if (result.length < k)
- {
- final byte[] newResult = new byte[k];
- System.arraycopy(result, 0, newResult, k - result.length, result.length);
- result = newResult;
- }
- else if (result.length > k)
- { // leftmost extra bytes should all be 0
- final int limit = result.length - k;
- for (int i = 0; i < limit; i++)
- {
- if (result[i] != 0x00)
- throw new IllegalArgumentException("integer too large");
- }
- final byte[] newResult = new byte[k];
- System.arraycopy(result, limit, newResult, 0, k);
- result = newResult;
- }
- return result;
- }
-
- private static final BigInteger RSAEP(final RSAPublicKey K, final BigInteger m)
- {
- // 1. If the representative m is not between 0 and n - 1, output
- // "representative out of range" and stop.
- final BigInteger n = K.getModulus();
- if (m.compareTo(ZERO) < 0 || m.compareTo(n.subtract(ONE)) > 0)
- throw new IllegalArgumentException();
- // 2. Let c = m^e mod n.
- final BigInteger e = K.getPublicExponent();
- final BigInteger result = m.modPow(e, n);
- // 3. Output c.
- return result;
- }
-
- private static final BigInteger RSADP(final RSAPrivateKey K, BigInteger c)
- {
- // 1. If the representative c is not between 0 and n - 1, output
- // "representative out of range" and stop.
- final BigInteger n = K.getModulus();
- if (c.compareTo(ZERO) < 0 || c.compareTo(n.subtract(ONE)) > 0)
- throw new IllegalArgumentException();
- // 2. The representative m is computed as follows.
- BigInteger result;
- if (! (K instanceof RSAPrivateCrtKey))
- {
- // a. If the first form (n, d) of K is used, let m = c^d mod n.
- final BigInteger d = K.getPrivateExponent();
- result = c.modPow(d, n);
- }
- else
- {
- // from [3] p.13 --see class docs:
- // The RSA blinding operation calculates x = (r^e) * g mod n before
- // decryption, where r is random, e is the RSA encryption exponent, and
- // g is the ciphertext to be decrypted. x is then decrypted as normal,
- // followed by division by r, i.e. (x^e) / r mod n. Since r is random,
- // x is random and timing the decryption should not reveal information
- // about the key. Note that r should be a new random number for every
- // decryption.
- final boolean rsaBlinding = Properties.doRSABlinding();
- BigInteger r = null;
- BigInteger e = null;
- if (rsaBlinding)
- { // pre-decryption
- r = newR(n);
- e = ((RSAPrivateCrtKey) K).getPublicExponent();
- final BigInteger x = r.modPow(e, n).multiply(c).mod(n);
- c = x;
- }
- // b. If the second form (p, q, dP, dQ, qInv) and (r_i, d_i, t_i)
- // of K is used, proceed as follows:
- final BigInteger p = ((RSAPrivateCrtKey) K).getPrimeP();
- final BigInteger q = ((RSAPrivateCrtKey) K).getPrimeQ();
- final BigInteger dP = ((RSAPrivateCrtKey) K).getPrimeExponentP();
- final BigInteger dQ = ((RSAPrivateCrtKey) K).getPrimeExponentQ();
- final BigInteger qInv = ((RSAPrivateCrtKey) K).getCrtCoefficient();
- // i. Let m_1 = c^dP mod p and m_2 = c^dQ mod q.
- final BigInteger m_1 = c.modPow(dP, p);
- final BigInteger m_2 = c.modPow(dQ, q);
- // ii. If u > 2, let m_i = c^(d_i) mod r_i, i = 3, ..., u.
- // iii. Let h = (m_1 - m_2) * qInv mod p.
- final BigInteger h = m_1.subtract(m_2).multiply(qInv).mod(p);
- // iv. Let m = m_2 + q * h.
- result = m_2.add(q.multiply(h));
- if (rsaBlinding) // post-decryption
- result = result.multiply(r.modInverse(n)).mod(n);
- }
- // 3. Output m
- return result;
- }
-
- /**
- * Returns a random MPI with a random bit-length of the form 8b
,
- * where b
is in the range [32..64]
.
- *
- * @return a random MPI whose length in bytes is between 32 and 64 inclusive.
- */
- private static final BigInteger newR(final BigInteger N)
- {
- final int upper = (N.bitLength() + 7) / 8;
- final int lower = upper / 2;
- final byte[] bl = new byte[1];
- int b;
- do
- {
- prng.nextBytes(bl);
- b = bl[0] & 0xFF;
- }
- while (b < lower || b > upper);
- final byte[] buffer = new byte[b]; // 256-bit MPI
- prng.nextBytes(buffer);
- return new BigInteger(1, buffer);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java
deleted file mode 100644
index 76460c0c..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5Signature.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/* RSAPKCS1V1_5Signature.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.sig.BaseSignature;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.util.Arrays;
-
-/**
- * The RSA-PKCS1-V1.5 signature scheme is a digital signature scheme with
- * appendix (SSA) combining the RSA algorithm with the EMSA-PKCS1-v1_5 encoding
- * method.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- * - Public-Key Cryptography
- * Standards (PKCS) #1:
- * RSA Cryptography Specifications Version 2.1.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class RSAPKCS1V1_5Signature
- extends BaseSignature
-{
- /** The underlying EMSA-PKCS1-v1.5 instance for this object. */
- private EMSA_PKCS1_V1_5 pkcs1;
-
- /**
- * Default 0-arguments constructor. Uses SHA-1 as the default hash.
- */
- public RSAPKCS1V1_5Signature()
- {
- this(Registry.SHA160_HASH);
- }
-
- /**
- * Constructs an instance of this object using the designated message digest
- * algorithm as its underlying hash function.
- *
- * @param mdName the canonical name of the underlying hash function.
- */
- public RSAPKCS1V1_5Signature(final String mdName)
- {
- this(HashFactory.getInstance(mdName));
- }
-
- public RSAPKCS1V1_5Signature(IMessageDigest md)
- {
- super(Registry.RSA_PKCS1_V1_5_SIG, md);
-
- pkcs1 = EMSA_PKCS1_V1_5.getInstance(md.name());
- }
-
- /** Private constructor for cloning purposes. */
- private RSAPKCS1V1_5Signature(final RSAPKCS1V1_5Signature that)
- {
- this(that.md.name());
-
- this.publicKey = that.publicKey;
- this.privateKey = that.privateKey;
- this.md = (IMessageDigest) that.md.clone();
- this.pkcs1 = (EMSA_PKCS1_V1_5) that.pkcs1.clone();
- }
-
- public Object clone()
- {
- return new RSAPKCS1V1_5Signature(this);
- }
-
- protected void setupForVerification(final PublicKey k)
- throws IllegalArgumentException
- {
- if (! (k instanceof RSAPublicKey))
- throw new IllegalArgumentException();
-
- publicKey = k;
- }
-
- protected void setupForSigning(final PrivateKey k)
- throws IllegalArgumentException
- {
- if (! (k instanceof RSAPrivateKey))
- throw new IllegalArgumentException();
-
- privateKey = k;
- }
-
- protected Object generateSignature() throws IllegalStateException
- {
- // 1. EMSA-PKCS1-v1_5 encoding: Apply the EMSA-PKCS1-v1_5 encoding
- // operation (Section 9.2) to the message M to produce an encoded
- // message EM of length k octets:
- //
- // EM = EMSA-PKCS1-V1_5-ENCODE (M, k).
- //
- // If the encoding operation outputs "message too long," output
- // "message too long" and stop. If the encoding operation outputs
- // "intended encoded message length too short," output "RSA modulus
- // too short" and stop.
- final int modBits = ((RSAPrivateKey) privateKey).getModulus().bitLength();
- final int k = (modBits + 7) / 8;
- final byte[] EM = pkcs1.encode(md.digest(), k);
- // 2. RSA signature:
- // a. Convert the encoded message EM to an integer message epresentative
- // m (see Section 4.2): m = OS2IP (EM).
- final BigInteger m = new BigInteger(1, EM);
- // b. Apply the RSASP1 signature primitive (Section 5.2.1) to the RSA
- // private key K and the message representative m to produce an
- // integer signature representative s: s = RSASP1 (K, m).
- final BigInteger s = RSA.sign(privateKey, m);
- // c. Convert the signature representative s to a signature S of length
- // k octets (see Section 4.1): S = I2OSP (s, k).
- // 3. Output the signature S.
- return RSA.I2OSP(s, k);
- }
-
- protected boolean verifySignature(final Object sig)
- throws IllegalStateException
- {
- if (publicKey == null)
- throw new IllegalStateException();
- final byte[] S = (byte[]) sig;
- // 1. Length checking: If the length of the signature S is not k octets,
- // output "invalid signature" and stop.
- final int modBits = ((RSAPublicKey) publicKey).getModulus().bitLength();
- final int k = (modBits + 7) / 8;
- if (S.length != k)
- return false;
- // 2. RSA verification:
- // a. Convert the signature S to an integer signature representative
- // s (see Section 4.2): s = OS2IP (S).
- final BigInteger s = new BigInteger(1, S);
- // b. Apply the RSAVP1 verification primitive (Section 5.2.2) to the
- // RSA public key (n, e) and the signature representative s to
- // produce an integer message representative m:
- // m = RSAVP1 ((n, e), s).
- // If RSAVP1 outputs "signature representative out of range,"
- // output "invalid signature" and stop.
- final BigInteger m;
- try
- {
- m = RSA.verify(publicKey, s);
- }
- catch (IllegalArgumentException x)
- {
- return false;
- }
- // c. Convert the message representative m to an encoded message EM
- // of length k octets (see Section 4.1): EM = I2OSP (m, k).
- // If I2OSP outputs "integer too large," output "invalid signature"
- // and stop.
- final byte[] EM;
- try
- {
- EM = RSA.I2OSP(m, k);
- }
- catch (IllegalArgumentException x)
- {
- return false;
- }
- // 3. EMSA-PKCS1-v1_5 encoding: Apply the EMSA-PKCS1-v1_5 encoding
- // operation (Section 9.2) to the message M to produce a second
- // encoded message EM' of length k octets:
- // EM' = EMSA-PKCS1-V1_5-ENCODE (M, k).
- // If the encoding operation outputs "message too long," output
- // "message too long" and stop. If the encoding operation outputs
- // "intended encoded message length too short," output "RSA modulus
- // too short" and stop.
- final byte[] EMp = pkcs1.encode(md.digest(), k);
- // 4. Compare the encoded message EM and the second encoded message EM'.
- // If they are the same, output "valid signature"; otherwise, output
- // "invalid signature."
- return Arrays.equals(EM, EMp);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureRawCodec.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureRawCodec.java
deleted file mode 100644
index 68c1edaa..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureRawCodec.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/* RSAPKCS1V1_5SignatureRawCodec.java -- Raw RSA PKCS1 v1.5 signature codeec
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.sig.rsa;
-
-import java.io.ByteArrayOutputStream;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.ISignatureCodec;
-
-/**
- * An object that implements the {@link ISignatureCodec} operations for the
- * Raw format to use with RSA-PKCS#1 v1.5 signatures.
- */
-public class RSAPKCS1V1_5SignatureRawCodec
- implements ISignatureCodec
-{
- public int getFormatID()
- {
- return RAW_FORMAT;
- }
-
- /**
- * Returns the encoded form of the designated RSA-PKCS#1 (v1.5) signature
- * object according to the Raw format supported by this library.
- *
- * The Raw format for such a signature, in this implementation, is a
- * byte sequence consisting of the following:
- *
- *
- * - 4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE},
- *
-
- *
- 1-byte version consisting of the constant: 0x01,
- * - 4-byte count of following bytes representing the RSA-PKCS#1 (v1.5)
- * signature bytes in internet order,
- * - the RSA-PKCS#1 (v1.5) signature bytes in internet order.
- *
- *
- * @param signature the signature to encode, consisting of the output of the
- * sign()
method of a {@link RSAPKCS1V1_5Signature}
- * instance --a byte array.
- * @return the Raw format encoding of the designated signature.
- * @exception IllegalArgumentException if the designated signature is not an
- * RSA-PKCS#1 (v1.5) one.
- */
- public byte[] encodeSignature(Object signature)
- {
- byte[] buffer;
- try
- {
- buffer = (byte[]) signature;
- }
- catch (Exception x)
- {
- throw new IllegalArgumentException("Signature/codec mismatch");
- }
-
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
-
- // magic
- baos.write(Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[0]);
- baos.write(Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[1]);
- baos.write(Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[2]);
- baos.write(Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[3]);
-
- // version
- baos.write(0x01);
-
- // signature bytes
- int length = buffer.length;
- baos.write( length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write( length & 0xFF);
- baos.write(buffer, 0, length);
-
- return baos.toByteArray();
- }
-
- /**
- * Returns the decoded object from a designated input assumed to have been
- * generated by the {@link #encodeSignature(Object)} method.
- *
- * @param input the input bytes of a previously Raw-encoded RSA PKCS1 (v1.5)
- * signature.
- * @return the signature object.
- * @throws IllegalArgumentException if the designated input does not start
- * with the right magic characters, or if the version
- * is not supported.
- */
- public Object decodeSignature(byte[] input)
- {
- // magic
- if (input[0] != Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[0]
- || input[1] != Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[1]
- || input[2] != Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[2]
- || input[3] != Registry.MAGIC_RAW_RSA_PKCS1V1_5_SIGNATURE[3])
- throw new IllegalArgumentException("Signature/codec mismatch");
-
- // version
- if (input[4] != 0x01)
- throw new IllegalArgumentException("Wrong or unsupported format version");
-
- int i = 5;
- int l;
-
- // signature bytes
- l = input[i++] << 24
- | (input[i++] & 0xFF) << 16
- | (input[i++] & 0xFF) << 8
- | (input[i++] & 0xFF);
- byte[] result = new byte[l];
- System.arraycopy(input, i, result, 0, l);
-
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureX509Codec.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureX509Codec.java
deleted file mode 100644
index 3cb37560..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPKCS1V1_5SignatureX509Codec.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/* RSAPSSSignatureX509Codec.java -- X.509 encoder/decoder for RSA signatures
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.ISignatureCodec;
-
-import java.security.InvalidParameterException;
-
-/**
- * An implementation of an {@link ISignatureCodec} that knows to encode and
- * decode RSA PKCS1 (v1.5) signatures into the raw bytes which would constitute
- * a DER-encoded form of the ASN.1 structure defined in RFC-2459, and RFC-2313
- * as described in the next paragraphs.
- *
- * Digital signatures when transmitted in an X.509 certificates are encoded
- * in DER (Distinguished Encoding Rules) as a BIT STRING; i.e.
- *
- *
- * Certificate ::= SEQUENCE {
- * tbsCertificate TBSCertificate,
- * signatureAlgorithm AlgorithmIdentifier,
- * signature BIT STRING
- * }
- *
- *
- * The output of the encoder, and the input of the decoder, of this codec are
- * then the raw bytes of such a BIT STRING; i.e. not the DER-encoded
- * form itself.
- *
- * Our implementation of the RSA PKCS1 signature algorithm outputs a byte array
- * as the result of generating a digital signature, in accordance with RFC-2313.
- * As a consequence, the encoder and decoder of this codec, simply pass through
- * such a byte array.
- *
- * Client code that needs to build a DER BIT STRING MUST construct such
- * an ASN.1 value. The following is an example of how to do this:
- *
- *
- * ...
- * import gnu.java.security.der.BitString;
- * import gnu.java.security.der.DER;
- * import gnu.java.security.der.DERValue;
- * ...
- * DERValue bitString = new DERValue(DER.BIT_STRING, new BitString(sigBytes));
- * ...
- *
- */
-public class RSAPKCS1V1_5SignatureX509Codec
- implements ISignatureCodec
-{
- // default 0-arguments constructor
-
- public int getFormatID()
- {
- return Registry.X509_ENCODING_ID;
- }
-
- /**
- * Encodes an RSA Signature output as a signature BIT STRING as
- * defined in the documentation of this class.
- *
- * @param signature the output of the RSA PKCS1 (v1.5) signature algorithm;
- * i.e. the value returned by the invocation of
- * {@link gnu.java.security.sig.ISignature#sign()} method. In the
- * case of the RSA PKCS1 (v1.5) signature this is an array of bytes.
- * @return the raw bytes of an RSA signature which could be then used as the
- * contents of a BIT STRING as per rfc-2459.
- */
- public byte[] encodeSignature(Object signature)
- {
- byte[] result = (byte[]) signature;
- return result;
- }
-
- /**
- * Decodes a signature as defined in the documentation of this class.
- *
- * @param input the byte array to unmarshall into a valid RSA PKCS1 (v1.5)
- * signature instance; i.e. a byte array. MUST NOT be null.
- * @return an array of raw bytes decoded from the designated input. In the
- * case of RSA PKCS1 (v1.5) this is the same as the input.
- * @throw InvalidParameterException if the input
array is null.
- */
- public Object decodeSignature(byte[] input)
- {
- if (input == null)
- throw new InvalidParameterException("Input bytes MUST NOT be null");
-
- return input;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignature.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignature.java
deleted file mode 100644
index 27c7fe62..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignature.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/* RSAPSSSignature.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.sig.BaseSignature;
-import gnu.java.security.util.Util;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-import java.security.PublicKey;
-import java.security.interfaces.RSAPrivateKey;
-import java.security.interfaces.RSAPublicKey;
-import java.util.logging.Logger;
-
-/**
- * The RSA-PSS signature scheme is a public-key encryption scheme combining the
- * RSA algorithm with the Probabilistic Signature Scheme (PSS) encoding method.
- *
- * The inventors of RSA are Ronald L. Rivest, Adi Shamir, and Leonard Adleman,
- * while the inventors of the PSS encoding method are Mihir Bellare and Phillip
- * Rogaway. During efforts to adopt RSA-PSS into the P1363a standards effort,
- * certain adaptations to the original version of RSA-PSS were made by Mihir
- * Bellare and Phillip Rogaway and also by Burt Kaliski (the editor of IEEE
- * P1363a) to facilitate implementation and integration into existing protocols.
- *
- * References:
- *
- * -
- * RSA-PSS Signature Scheme with Appendix, part B.
- * Primitive specification and supporting documentation.
- * Jakob Jonsson and Burt Kaliski.
- *
- */
-public class RSAPSSSignature
- extends BaseSignature
-{
- private static final Logger log = Logger.getLogger(RSAPSSSignature.class.getName());
-
- /** The underlying EMSA-PSS instance for this object. */
- private EMSA_PSS pss;
-
- /** The desired length in octets of the EMSA-PSS salt. */
- private int sLen;
-
- /**
- * Default 0-arguments constructor. Uses SHA-1 as the default hash and a
- * 0-octet salt.
- */
- public RSAPSSSignature()
- {
- this(Registry.SHA160_HASH, 0);
- }
-
- /**
- * Constructs an instance of this object using the designated message digest
- * algorithm as its underlying hash function, and having 0-octet salt.
- *
- * @param mdName the canonical name of the underlying hash function.
- */
- public RSAPSSSignature(String mdName)
- {
- this(mdName, 0);
- }
-
- /**
- * Constructs an instance of this object using the designated message digest
- * algorithm as its underlying hash function.
- *
- * @param mdName the canonical name of the underlying hash function.
- * @param sLen the desired length in octets of the salt to use for encoding /
- * decoding signatures.
- */
- public RSAPSSSignature(String mdName, int sLen)
- {
- this(HashFactory.getInstance(mdName), sLen);
- }
-
- public RSAPSSSignature(IMessageDigest md, int sLen)
- {
- super(Registry.RSA_PSS_SIG, md);
-
- pss = EMSA_PSS.getInstance(md.name());
- this.sLen = sLen;
- }
-
- /** Private constructor for cloning purposes. */
- private RSAPSSSignature(RSAPSSSignature that)
- {
- this(that.md.name(), that.sLen);
-
- this.publicKey = that.publicKey;
- this.privateKey = that.privateKey;
- this.md = (IMessageDigest) that.md.clone();
- this.pss = (EMSA_PSS) that.pss.clone();
- }
-
- public Object clone()
- {
- return new RSAPSSSignature(this);
- }
-
- protected void setupForVerification(PublicKey k)
- throws IllegalArgumentException
- {
- if (! (k instanceof RSAPublicKey))
- throw new IllegalArgumentException();
-
- publicKey = (RSAPublicKey) k;
- }
-
- protected void setupForSigning(PrivateKey k) throws IllegalArgumentException
- {
- if (! (k instanceof RSAPrivateKey))
- throw new IllegalArgumentException();
-
- privateKey = (RSAPrivateKey) k;
- }
-
- protected Object generateSignature() throws IllegalStateException
- {
- // 1. Apply the EMSA-PSS encoding operation to the message M to produce an
- // encoded message EM of length CEILING((modBits ? 1)/8) octets such
- // that the bit length of the integer OS2IP(EM) is at most modBits ? 1:
- // EM = EMSA-PSS-Encode(M,modBits ? 1).
- // Note that the octet length of EM will be one less than k if
- // modBits ? 1 is divisible by 8. If the encoding operation outputs
- // 'message too long' or 'encoding error,' then output 'message too
- // long' or 'encoding error' and stop.
- int modBits = ((RSAPrivateKey) privateKey).getModulus().bitLength();
- byte[] salt = new byte[sLen];
- this.nextRandomBytes(salt);
- byte[] EM = pss.encode(md.digest(), modBits - 1, salt);
- if (Configuration.DEBUG)
- log.fine("EM (sign): " + Util.toString(EM));
- // 2. Convert the encoded message EM to an integer message representative
- // m (see Section 1.2.2): m = OS2IP(EM).
- BigInteger m = new BigInteger(1, EM);
- // 3. Apply the RSASP signature primitive to the public key K and the
- // message representative m to produce an integer signature
- // representative s: s = RSASP(K,m).
- BigInteger s = RSA.sign(privateKey, m);
- // 4. Convert the signature representative s to a signature S of length k
- // octets (see Section 1.2.1): S = I2OSP(s, k).
- // 5. Output the signature S.
- int k = (modBits + 7) / 8;
- // return encodeSignature(s, k);
- return RSA.I2OSP(s, k);
- }
-
- protected boolean verifySignature(Object sig) throws IllegalStateException
- {
- if (publicKey == null)
- throw new IllegalStateException();
- // byte[] S = decodeSignature(sig);
- byte[] S = (byte[]) sig;
- // 1. If the length of the signature S is not k octets, output 'signature
- // invalid' and stop.
- int modBits = ((RSAPublicKey) publicKey).getModulus().bitLength();
- int k = (modBits + 7) / 8;
- if (S.length != k)
- return false;
- // 2. Convert the signature S to an integer signature representative s:
- // s = OS2IP(S).
- BigInteger s = new BigInteger(1, S);
- // 3. Apply the RSAVP verification primitive to the public key (n, e) and
- // the signature representative s to produce an integer message
- // representative m: m = RSAVP((n, e), s).
- // If RSAVP outputs 'signature representative out of range,' then
- // output 'signature invalid' and stop.
- BigInteger m = null;
- try
- {
- m = RSA.verify(publicKey, s);
- }
- catch (IllegalArgumentException x)
- {
- return false;
- }
- // 4. Convert the message representative m to an encoded message EM of
- // length emLen = CEILING((modBits - 1)/8) octets, where modBits is
- // equal to the bit length of the modulus: EM = I2OSP(m, emLen).
- // Note that emLen will be one less than k if modBits - 1 is divisible
- // by 8. If I2OSP outputs 'integer too large,' then output 'signature
- // invalid' and stop.
- int emBits = modBits - 1;
- int emLen = (emBits + 7) / 8;
- byte[] EM = m.toByteArray();
- if (Configuration.DEBUG)
- log.fine("EM (verify): " + Util.toString(EM));
- if (EM.length > emLen)
- return false;
- else if (EM.length < emLen)
- {
- byte[] newEM = new byte[emLen];
- System.arraycopy(EM, 0, newEM, emLen - EM.length, EM.length);
- EM = newEM;
- }
- // 5. Apply the EMSA-PSS decoding operation to the message M and the
- // encoded message EM: Result = EMSA-PSS-Decode(M, EM, emBits). If
- // Result = 'consistent,' output 'signature verified.' Otherwise,
- // output 'signature invalid.'
- byte[] mHash = md.digest();
- boolean result = false;
- try
- {
- result = pss.decode(mHash, EM, emBits, sLen);
- }
- catch (IllegalArgumentException x)
- {
- result = false;
- }
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java
deleted file mode 100644
index b5e059c2..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSAPSSSignatureRawCodec.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/* RSAPSSSignatureRawCodec.java --
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.sig.rsa;
-
-import gnu.java.security.Registry;
-import gnu.java.security.sig.ISignatureCodec;
-
-import java.io.ByteArrayOutputStream;
-
-/**
- * An object that implements the {@link ISignatureCodec} operations for the
- * Raw format to use with RSA-PSS signatures.
- */
-public class RSAPSSSignatureRawCodec
- implements ISignatureCodec
-{
- // implicit 0-arguments constructor
-
- public int getFormatID()
- {
- return RAW_FORMAT;
- }
-
- /**
- * Returns the encoded form of the designated RSA-PSS signature object
- * according to the Raw format supported by this library.
- *
- * The Raw format for an RSA-PSS signature, in this implementation, is
- * a byte sequence consisting of the following:
- *
- * - 4-byte magic consisting of the value of the literal
- * {@link Registry#MAGIC_RAW_RSA_PSS_SIGNATURE},
- *
-
- *
- 1-byte version consisting of the constant: 0x01,
- * - 4-byte count of following bytes representing the RSA-PSS signature
- * bytes in internet order,
- * - the RSA-PSS signature bytes in internet order.
- *
- *
- * @param signature the signature to encode, consisting of the output of the
- * sign()
method of a {@link RSAPSSSignature} instance
- * --a byte array.
- * @return the Raw format encoding of the designated signature.
- * @exception IllegalArgumentException if the designated signature is not an
- * RSA-PSS one.
- */
- public byte[] encodeSignature(Object signature)
- {
- byte[] buffer;
- try
- {
- buffer = (byte[]) signature;
- }
- catch (Exception x)
- {
- throw new IllegalArgumentException("signature");
- }
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- // magic
- baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[0]);
- baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[1]);
- baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[2]);
- baos.write(Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[3]);
- // version
- baos.write(0x01);
- // signature bytes
- int length = buffer.length;
- baos.write( length >>> 24);
- baos.write((length >>> 16) & 0xFF);
- baos.write((length >>> 8) & 0xFF);
- baos.write(length & 0xFF);
- baos.write(buffer, 0, length);
- return baos.toByteArray();
- }
-
- public Object decodeSignature(byte[] k)
- {
- // magic
- if (k[0] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[0]
- || k[1] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[1]
- || k[2] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[2]
- || k[3] != Registry.MAGIC_RAW_RSA_PSS_SIGNATURE[3])
- throw new IllegalArgumentException("magic");
- // version
- if (k[4] != 0x01)
- throw new IllegalArgumentException("version");
- int i = 5;
- int l;
- // signature bytes
- l = k[i++] << 24
- | (k[i++] & 0xFF) << 16
- | (k[i++] & 0xFF) << 8
- | (k[i++] & 0xFF);
- byte[] result = new byte[l];
- System.arraycopy(k, i, result, 0, l);
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSASignatureFactory.java b/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSASignatureFactory.java
deleted file mode 100644
index b8e12caf..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/sig/rsa/RSASignatureFactory.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/* RSASignatureFactory.java -- A Factory class to instantiate RSA Signatures
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.sig.rsa;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import gnu.java.security.Registry;
-import gnu.java.security.hash.HashFactory;
-import gnu.java.security.hash.IMessageDigest;
-import gnu.java.security.sig.ISignature;
-
-/**
- * A Factory class to instantiate RSA Signature classes.
- */
-public class RSASignatureFactory
-{
- private static Set names;
-
- /**
- * Private constructor to enforce usage through Factory (class) methods.
- */
- private RSASignatureFactory()
- {
- super();
- }
-
- /**
- * Returns a new instance of an RSA Signature given its name. The name of an
- * RSA Signature always starts with rsa-
, followed by either
- * pss
or pkcs1_v1.5
. An optional message digest
- * name, to be used with the RSA signature may be specified by appending the
- * hyphen chanaracter -
followed by the canonical message digest
- * algorithm name. When no message digest algorithm name is given, SHA-160 is
- * used.
- *
- * @param name the composite RSA signature name.
- * @return a new instance of an RSA Signature algorithm implementation.
- * Returns null
if the given name does not correspond to any
- * supported RSA Signature encoding and message digest combination.
- */
- public static final ISignature getInstance(String name)
- {
- if (name == null)
- return null;
-
- name = name.trim();
- if (name.length() == 0)
- return null;
-
- name = name.toLowerCase();
- if (! name.startsWith(Registry.RSA_SIG_PREFIX))
- return null;
-
- name = name.substring(Registry.RSA_SIG_PREFIX.length()).trim();
- if (name.startsWith(Registry.RSA_PSS_ENCODING))
- return getPSSSignature(name);
- else if (name.startsWith(Registry.RSA_PKCS1_V1_5_ENCODING))
- return getPKCS1Signature(name);
- else
- return null;
- }
-
- /**
- * Returns a {@link Set} of names of RSA signatures supported by this
- * Factory.
- *
- * @return a {@link Set} of RSA Signature algorithm names (Strings).
- */
- public static synchronized final Set getNames()
- {
- if (names == null)
- {
- Set hashNames = HashFactory.getNames();
- HashSet hs = new HashSet();
- for (Iterator it = hashNames.iterator(); it.hasNext();)
- {
- String mdName = (String) it.next();
- hs.add(Registry.RSA_PSS_SIG + "-" + mdName);
- }
-
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.MD2_HASH);
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.MD5_HASH);
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA160_HASH);
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA256_HASH);
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA384_HASH);
- hs.add(Registry.RSA_PKCS1_V1_5_SIG + "-" + Registry.SHA512_HASH);
-
- names = Collections.unmodifiableSet(hs);
- }
-
- return names;
- }
-
- private static final ISignature getPSSSignature(String name)
- {
- name = name.substring(Registry.RSA_PSS_ENCODING.length()).trim();
- // remove the hyphen if found at the beginning
- if (name.startsWith("-"))
- name = name.substring(1).trim();
-
- IMessageDigest md;
- if (name.length() == 0)
- md = HashFactory.getInstance(Registry.SHA160_HASH);
- else
- {
- // check if there is such a hash
- md = HashFactory.getInstance(name);
- if (md == null)
- return null;
- }
-
- ISignature result = new RSAPSSSignature(md, 0);
- return result;
- }
-
- private static final ISignature getPKCS1Signature(String name)
- {
- name = name.substring(Registry.RSA_PKCS1_V1_5_ENCODING.length()).trim();
- // remove the hyphen if found at the beginning
- if (name.startsWith("-"))
- name = name.substring(1).trim();
-
- IMessageDigest md;
- if (name.length() == 0)
- md = HashFactory.getInstance(Registry.SHA160_HASH);
- else
- {
- // check if there is such a hash
- md = HashFactory.getInstance(name);
- if (md == null)
- return null;
- }
-
- ISignature result = new RSAPKCS1V1_5Signature(md);
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/ByteArray.java b/openjdk/icedtea/jce/gnu/java/security/util/ByteArray.java
deleted file mode 100644
index 0d04d912..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/ByteArray.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* ByteArray.java -- wrapper around a byte array, with nice toString output.
- Copyright (C) 2005 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-
-public final class ByteArray
-{
- private final byte[] value;
-
- public ByteArray (final byte[] value)
- {
- this.value = value;
- }
-
- public byte[] getValue ()
- {
- return value;
- }
-
- public String toString ()
- {
- StringWriter str = new StringWriter ();
- PrintWriter out = new PrintWriter (str);
- int i = 0;
- int len = value.length;
- while (i < len)
- {
- out.print (formatInt (i, 16, 8));
- out.print (" ");
- int l = Math.min (16, len - i);
- String s = toHexString (value, i, l, ' ');
- out.print (s);
- for (int j = 56 - (56 - s.length ()); j < 56; j++)
- out.print (" ");
- for (int j = 0; j < l; j++)
- {
- byte b = value[i+j];
- if ((b & 0xFF) < 0x20 || (b & 0xFF) > 0x7E)
- out.print (".");
- else
- out.print ((char) (b & 0xFF));
- }
- out.println ();
- i += 16;
- }
- return str.toString ();
- }
-
- public static String toHexString (byte[] buf, int off, int len, char sep)
- {
- StringBuffer str = new StringBuffer();
- for (int i = 0; i < len; i++)
- {
- str.append (Character.forDigit (buf[i+off] >>> 4 & 0x0F, 16));
- str.append (Character.forDigit (buf[i+off] & 0x0F, 16));
- if (i < len - 1)
- str.append(sep);
- }
- return str.toString();
- }
-
- public static String formatInt (int value, int radix, int len)
- {
- String s = Integer.toString (value, radix);
- StringBuffer buf = new StringBuffer ();
- for (int j = 0; j < len - s.length(); j++)
- buf.append ("0");
- buf.append (s);
- return buf.toString();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/ByteBufferOutputStream.java b/openjdk/icedtea/jce/gnu/java/security/util/ByteBufferOutputStream.java
deleted file mode 100644
index be4d0a98..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/ByteBufferOutputStream.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* ByteBufferOutputStream.java -- output stream with a growable underlying
- byte buffer.
- Copyright (C) 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.util;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-import java.nio.ByteBuffer;
-
-/**
- * An output stream that writes bytes to a ByteBuffer, which will be resized
- * if more space is needed.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class ByteBufferOutputStream extends OutputStream
-{
- private ByteBuffer buffer;
-
- public ByteBufferOutputStream()
- {
- this(256);
- }
-
- public ByteBufferOutputStream(int initialCapacity)
- {
- buffer = ByteBuffer.allocate(initialCapacity);
- }
-
- /* (non-Javadoc)
- * @see java.io.OutputStream#write(int)
- */
- public @Override synchronized void write(int b) throws IOException
- {
- if (!buffer.hasRemaining())
- growBuffer();
- buffer.put((byte) b);
- }
-
- public @Override synchronized void write(byte[] b, int offset, int length)
- {
- if (buffer.remaining() < length)
- growBuffer();
- buffer.put(b, offset, length);
- }
-
- public @Override void write(byte[] b)
- {
- write(b, 0, b.length);
- }
-
- /**
- * Get the current state of the buffer. The returned buffer will have
- * its position set to zero, its capacity set to the current limit,
- * and its limit set to its capacity.
- *
- * @return The buffer.
- */
- public ByteBuffer buffer()
- {
- return ((ByteBuffer) buffer.duplicate().flip()).slice();
- }
-
- public String toString()
- {
- return super.toString() + " [ buffer: " + buffer + " ]";
- }
-
- private void growBuffer()
- {
- int newCapacity = buffer.capacity();
- if (newCapacity < 16384) // If the buffer isn't huge yet, double its size
- newCapacity = newCapacity << 1;
- else // Otherwize, increment by a bit.
- newCapacity += 4096;
- ByteBuffer newBuffer = ByteBuffer.allocate(newCapacity);
- buffer.flip();
- newBuffer.put(buffer);
- buffer = newBuffer;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/DerUtil.java b/openjdk/icedtea/jce/gnu/java/security/util/DerUtil.java
deleted file mode 100644
index 26232ba9..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/DerUtil.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/* DerUtil.java -- Utility methods for DER read/write operations
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-
-import gnu.java.security.der.DEREncodingException;
-import gnu.java.security.der.DERValue;
-
-import java.math.BigInteger;
-
-/**
- * Utility methods for DER encoding handling.
- */
-public abstract class DerUtil
-{
- public static final void checkIsConstructed(DERValue v, String msg)
- throws DEREncodingException
- {
- if (! v.isConstructed())
- throw new DEREncodingException(msg);
- }
-
- public static final void checkIsBigInteger(DERValue v, String msg)
- throws DEREncodingException
- {
- if (! (v.getValue() instanceof BigInteger))
- throw new DEREncodingException(msg);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/ExpirableObject.java b/openjdk/icedtea/jce/gnu/java/security/util/ExpirableObject.java
deleted file mode 100644
index e0c4e6b5..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/ExpirableObject.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/* ExpirableObject.java -- an object that is automatically destroyed.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.util;
-
-import java.util.Timer;
-import java.util.TimerTask;
-
-import javax.security.auth.DestroyFailedException;
-import javax.security.auth.Destroyable;
-
-/**
- * The base class for objects with sensitive data that are automatically
- * destroyed after a timeout elapses. On creation, an object that extends this
- * class will automatically be added to a {@link Timer} object that, once a
- * timeout elapses, will automatically call the {@link Destroyable#destroy()}
- * method.
- *
- * Concrete subclasses must implement the {@link #doDestroy()} method instead of
- * {@link Destroyable#destroy()}; the behavior of that method should match
- * exactly the behavior desired of destroy()
.
- *
- * Note that if a {@link DestroyFailedException} occurs when the timeout
- * expires, it will not be reported.
- *
- * @see Destroyable
- */
-public abstract class ExpirableObject
- implements Destroyable
-{
- /**
- * The default timeout, used in the default constructor.
- */
- public static final long DEFAULT_TIMEOUT = 3600000L;
-
- /**
- * The timer that expires instances.
- */
- private static final Timer EXPIRER = new Timer(true);
-
- /**
- * A reference to the task that will destroy this object when the timeout
- * expires.
- */
- private final Destroyer destroyer;
-
- /**
- * Create a new expirable object that will expire after one hour.
- */
- protected ExpirableObject()
- {
- this(DEFAULT_TIMEOUT);
- }
-
- /**
- * Create a new expirable object that will expire after the specified timeout.
- *
- * @param delay The delay before expiration.
- * @throws IllegalArgumentException If delay is negative, or if
- * delay + System.currentTimeMillis()
is negative.
- */
- protected ExpirableObject(final long delay)
- {
- destroyer = new Destroyer(this);
- EXPIRER.schedule(destroyer, delay);
- }
-
- /**
- * Destroys this object. This method calls {@link #doDestroy}, then, if no
- * exception is thrown, cancels the task that would destroy this object when
- * the timeout is reached.
- *
- * @throws DestroyFailedException If this operation fails.
- */
- public final void destroy() throws DestroyFailedException
- {
- doDestroy();
- destroyer.cancel();
- }
-
- /**
- * Subclasses must implement this method instead of the {@link
- * Destroyable#destroy()} method.
- *
- * @throws DestroyFailedException If this operation fails.
- */
- protected abstract void doDestroy() throws DestroyFailedException;
-
- /**
- * The task that destroys the target when the timeout elapses.
- */
- private final class Destroyer
- extends TimerTask
- {
- private final ExpirableObject target;
-
- Destroyer(final ExpirableObject target)
- {
- super();
- this.target = target;
- }
-
- public void run()
- {
- try
- {
- if (! target.isDestroyed())
- target.doDestroy();
- }
- catch (DestroyFailedException dfe)
- {
- }
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/FormatUtil.java b/openjdk/icedtea/jce/gnu/java/security/util/FormatUtil.java
deleted file mode 100644
index eed669cc..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/FormatUtil.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/* FormatUtil.java -- Encoding and decoding format utility methods
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-
-import gnu.java.security.Registry;
-
-/**
- * Encoding and decoding format utility methods.
- */
-public class FormatUtil
-{
- /** Trivial constructor to enforce Singleton pattern. */
- private FormatUtil()
- {
- super();
- }
-
- /**
- * Returns the fully qualified name of the designated encoding ID.
- *
- * @param formatID the unique identifier of the encoding format.
- * @return the fully qualified name of the designated format. Returns
- * null
if no such encoding format is known.
- */
- public static final String getEncodingName(int formatID)
- {
- String result = null;
- switch (formatID)
- {
- case Registry.RAW_ENCODING_ID:
- result = Registry.RAW_ENCODING;
- break;
- case Registry.X509_ENCODING_ID:
- result = Registry.X509_ENCODING;
- break;
- case Registry.PKCS8_ENCODING_ID:
- result = Registry.PKCS8_ENCODING;
- break;
- case Registry.ASN1_ENCODING_ID:
- result = Registry.ASN1_ENCODING;
- break;
- }
-
- return result;
- }
-
- /**
- * Returns the short name of the designated encoding ID. This is used by the
- * JCE Adapters.
- *
- * @param formatID the unique identifier of the encoding format.
- * @return the short name of the designated format. Returns null
- * if no such encoding format is known.
- */
- public static final String getEncodingShortName(int formatID)
- {
- String result = null;
- switch (formatID)
- {
- case Registry.RAW_ENCODING_ID:
- result = Registry.RAW_ENCODING_SHORT_NAME;
- break;
- case Registry.X509_ENCODING_ID:
- result = Registry.X509_ENCODING_SORT_NAME;
- break;
- case Registry.PKCS8_ENCODING_ID:
- result = Registry.PKCS8_ENCODING_SHORT_NAME;
- break;
- case Registry.ASN1_ENCODING_ID:
- result = Registry.ASN1_ENCODING_SHORT_NAME;
- break;
- }
-
- return result;
- }
-
- /**
- * Returns the identifier of the encoding format given its short name.
- *
- * @param name the case-insensitive canonical short name of an encoding
- * format.
- * @return the identifier of the designated encoding format, or 0
- * if the name does not correspond to any known format.
- */
- public static final int getFormatID(String name)
- {
- if (name == null)
- return 0;
-
- name = name.trim();
- if (name.length() == 0)
- return 0;
-
- int result = 0;
- if (name.equalsIgnoreCase(Registry.RAW_ENCODING_SHORT_NAME))
- result = Registry.RAW_ENCODING_ID;
- else if (name.equalsIgnoreCase(Registry.X509_ENCODING_SORT_NAME))
- result = Registry.X509_ENCODING_ID;
- else if (name.equalsIgnoreCase(Registry.PKCS8_ENCODING_SHORT_NAME))
- result = Registry.PKCS8_ENCODING_ID;
-
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/IntegerUtil.java b/openjdk/icedtea/jce/gnu/java/security/util/IntegerUtil.java
deleted file mode 100644
index f0713080..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/IntegerUtil.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/* IntegerUtil.java -- JDK 5 Integer methods with 1.4 API
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-/**
- * Utility class which offers Integer related methods found in RI's version 5
- * but written with RI's 1.4 API.
- */
-public abstract class IntegerUtil
-{
- /** Maximum size of our cache of constructed Integers. */
- private static final int CACHE_SIZE = 100;
- /** LRU (Least Recently Used) cache, of the last accessed 100 Integers. */
- private static final Map cache = new LinkedHashMap(CACHE_SIZE + 1, 0.75F, true)
- {
- public boolean removeEldestEntry(Map.Entry entry)
- {
- return size() > CACHE_SIZE;
- }
- };
-
- /** Trivial private constructor to enforce Singleton usage. */
- private IntegerUtil()
- {
- super();
- }
-
- /**
- * Similar to {@link Integer#valueOf(String)} except it caches the result in
- * a local LRU cache of 100 elements, organized by access order.
- *
- * This method MUST be used in the gnu.java.security and gnu.javax.crypto
- * packages to ensure they would work with a version 1.4 only of the Java
- * class library API.
- *
- * @param aString a string representation of an integer.
- * @return the {@link Integer} object representing the designated string.
- */
- public static final Integer valueOf(String aString)
- {
- Integer result;
- synchronized (cache)
- {
- result = (Integer) cache.get(aString);
- if (result == null)
- {
- result = Integer.valueOf(aString);
- cache.put(aString, result);
- }
- }
- return result;
- }
-
- /**
- * Simulates the valueOf(int)
method found in {@link Integer} of
- * the RI's version 1.5 using a local LRU cache of 100 elements, organized by
- * access order.
- *
- * This method MUST be used in the gnu.java.security and gnu.javax.crypto
- * packages to ensure they would work with a version 1.4 only of the Java
- * class library API.
- *
- * @param anInt a decimal integer.
- * @return the {@link Integer} object representing the designated primitive.
- */
- public static final Integer valueOf(int anInt)
- {
- return valueOf(Integer.toString(anInt, 10));
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/PRNG.java b/openjdk/icedtea/jce/gnu/java/security/util/PRNG.java
deleted file mode 100644
index 7bb27cbf..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/PRNG.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/* PRNG.java -- A Utility methods for default source of randomness
- Copyright (C) 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-
-import java.util.HashMap;
-
-import gnu.java.security.prng.IRandom;
-import gnu.java.security.prng.LimitReachedException;
-import gnu.java.security.prng.MDGenerator;
-
-/**
- * A useful hash-based (SHA) pseudo-random number generator used throughout this
- * library.
- *
- * @see MDGenerator
- */
-public class PRNG
-{
- /** The underlying {@link IRandom}. */
- private IRandom delegate;
-
- /**
- * Private constructor to enforce using the Factory method.
- *
- * @param delegate the undelying {@link IRandom} object used.
- */
- private PRNG(IRandom delegate)
- {
- super();
-
- this.delegate = delegate;
- }
-
- public static final PRNG getInstance()
- {
- IRandom delegate = new MDGenerator();
- try
- {
- HashMap map = new HashMap();
- // initialise it with a seed
- long t = System.currentTimeMillis();
- byte[] seed = new byte[] {
- (byte)(t >>> 56), (byte)(t >>> 48),
- (byte)(t >>> 40), (byte)(t >>> 32),
- (byte)(t >>> 24), (byte)(t >>> 16),
- (byte)(t >>> 8), (byte) t };
- map.put(MDGenerator.SEEED, seed);
- delegate.init(map); // default is to use SHA-1 hash
- }
- catch (Exception x)
- {
- throw new ExceptionInInitializerError(x);
- }
- return new PRNG(delegate);
- }
-
- /**
- * Completely fills the designated buffer
with random data
- * generated by the underlying delegate.
- *
- * @param buffer the place holder of random bytes generated by the underlying
- * delegate. On output, the contents of buffer
are
- * replaced with pseudo-random data, iff the buffer
- * size is not zero.
- */
- public void nextBytes(byte[] buffer)
- {
- nextBytes(buffer, 0, buffer.length);
- }
-
- /**
- * Fills the designated buffer
, starting from byte at position
- * offset
with, at most, length
bytes of random
- * data generated by the underlying delegate.
- *
- * @see IRandom#nextBytes
- */
- public void nextBytes(byte[] buffer, int offset, int length)
- {
- try
- {
- delegate.nextBytes(buffer, offset, length);
- }
- catch (LimitReachedException x) // re-initialise with a seed
- {
- try
- {
- HashMap map = new HashMap();
- long t = System.currentTimeMillis();
- byte[] seed = new byte[] {
- (byte)(t >>> 56), (byte)(t >>> 48),
- (byte)(t >>> 40), (byte)(t >>> 32),
- (byte)(t >>> 24), (byte)(t >>> 16),
- (byte)(t >>> 8), (byte) t };
- map.put(MDGenerator.SEEED, seed);
- delegate.init(map); // default is to use SHA-1 hash
- delegate.nextBytes(buffer, offset, length);
- }
- catch (Exception y)
- {
- throw new ExceptionInInitializerError(y);
- }
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/Prime.java b/openjdk/icedtea/jce/gnu/java/security/util/Prime.java
deleted file mode 100644
index e493ce67..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/Prime.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/* Prime.java --- Prime number generation utilities
- Copyright (C) 1999, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.util;
-import java.math.BigInteger;
-import java.util.Random;
-//import java.security.SecureRandom;
-
-public final class Prime
-{
-
- /*
- See IEEE P1363 A.15.4 (10/05/98 Draft)
- */
- public static BigInteger generateRandomPrime( int pmin, int pmax, BigInteger f )
- {
- BigInteger d;
-
- //Step 1 - generate prime
- BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() );
- if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmin ) ) <= 0 )
- {
- p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin ).subtract( p ) );
- }
-
- //Step 2 - test for even
- if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
- p = p.add( BigInteger.valueOf( 1 ) );
-
- for(;;)
- {
- //Step 3
- if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0)
- {
- //Step 3.1
- p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) );
- p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) );
- p = p.subtract( BigInteger.valueOf( 1 ) );
-
- //Step 3.2
- // put step 2 code here so looping code is cleaner
- //Step 2 - test for even
- if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
- p = p.add( BigInteger.valueOf( 1 ) );
- continue;
- }
-
- //Step 4 - compute GCD
- d = p.subtract( BigInteger.valueOf(1) );
- d = d.gcd( f );
-
- //Step 5 - test d
- if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0)
- {
- //Step 5.1 - test primality
- if( p.isProbablePrime( 1 ) == true )
- {
- //Step 5.2;
- return p;
- }
- }
- //Step 6
- p = p.add( BigInteger.valueOf( 2 ) );
-
- //Step 7
- }
- }
-
-
- /*
- See IEEE P1363 A.15.5 (10/05/98 Draft)
- */
- public static BigInteger generateRandomPrime( BigInteger r, BigInteger a, int pmin, int pmax, BigInteger f )
- {
- BigInteger d, w;
-
- //Step 1 - generate prime
- BigInteger p = new BigInteger( (pmax + pmin)/2, new Random() );
-
- steptwo:{ //Step 2
- w = p.mod( r.multiply( BigInteger.valueOf(2) ));
-
- //Step 3
- p = p.add( r.multiply( BigInteger.valueOf(2) ) );
- p = p.subtract( w );
- p = p.add(a);
-
- //Step 4 - test for even
- if( p.mod( BigInteger.valueOf(2) ).compareTo( BigInteger.valueOf( 0 )) == 0)
- p = p.add( r );
-
- for(;;)
- {
- //Step 5
- if( p.compareTo( BigInteger.valueOf( 1 ).shiftLeft( pmax)) > 0)
- {
- //Step 5.1
- p = p.subtract( BigInteger.valueOf( 1 ).shiftLeft( pmax) );
- p = p.add( BigInteger.valueOf( 1 ).shiftLeft( pmin) );
- p = p.subtract( BigInteger.valueOf( 1 ) );
-
- //Step 5.2 - goto to Step 2
- break steptwo;
- }
-
- //Step 6
- d = p.subtract( BigInteger.valueOf(1) );
- d = d.gcd( f );
-
- //Step 7 - test d
- if( d.compareTo( BigInteger.valueOf( 1 ) ) == 0)
- {
- //Step 7.1 - test primality
- if( p.isProbablePrime( 1 ) == true )
- {
- //Step 7.2;
- return p;
- }
- }
- //Step 8
- p = p.add( r.multiply( BigInteger.valueOf(2) ) );
-
- //Step 9
- }
- }
- //Should never reach here but makes the compiler happy
- return BigInteger.valueOf(0);
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/Sequence.java b/openjdk/icedtea/jce/gnu/java/security/util/Sequence.java
deleted file mode 100644
index 5e3a64ea..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/Sequence.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/* Sequence.java -- a sequence of integers.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.util;
-
-import java.util.AbstractList;
-import java.util.LinkedList;
-
-/**
- * A monotonic sequence of integers in the finite field 232.
- */
-public final class Sequence
- extends AbstractList
-{
- private final Integer[] sequence;
-
- /**
- * Create a sequence of integers from 0 to end, with an increment of
- * 1. If end is less than 0, then the sequence will wrap around
- * through all positive integers then negative integers until the end value is
- * reached. Naturally, this will result in an enormous object, so don't do
- * this.
- *
- * @param end The ending value.
- */
- public Sequence(int end)
- {
- this(0, end, 1);
- }
-
- /**
- * Create a sequence of integers from start to end, with an
- * increment of 1. If end is less than start, then the
- * sequence will wrap around until the end value is reached. Naturally, this
- * will result in an enormous object, so don't do this.
- *
- * @param start The starting value.
- * @param end The ending value.
- */
- public Sequence(int start, int end)
- {
- this(start, end, 1);
- }
-
- /**
- * Create a sequence of integers from start to end, with an
- * increment of span. If end is less than start, then
- * the sequence will wrap around until the end value is reached. Naturally,
- * this will result in an enormous object, so don't do this.
- *
- * span can be negative, resulting in a decresing sequence.
- *
- * If span is 0, then the sequence will contain {start,
- * end} if start != end, or just the singleton
- * start if start == end.
- *
- * @param start The starting value.
- * @param end The ending value.
- * @param span The increment value.
- */
- public Sequence(int start, int end, int span)
- {
- if (span == 0)
- {
- if (start != end)
- sequence = new Integer[] { Integer.valueOf(start),
- Integer.valueOf(end) };
- else
- sequence = new Integer[] { Integer.valueOf(start) };
- }
- else
- {
- LinkedList l = new LinkedList();
- for (int i = start; i != end; i += span)
- l.add(Integer.valueOf(i));
-
- l.add(Integer.valueOf(end));
- sequence = (Integer[]) l.toArray(new Integer[l.size()]);
- }
- }
-
- public Object get(int index)
- {
- if (index < 0 || index >= size())
- throw new IndexOutOfBoundsException("index=" + index + ", size=" + size());
- return sequence[index];
- }
-
- public int size()
- {
- return sequence.length;
- }
-
- public Object[] toArray()
- {
- return (Object[]) sequence.clone();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/SimpleList.java b/openjdk/icedtea/jce/gnu/java/security/util/SimpleList.java
deleted file mode 100644
index 74f3bafc..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/SimpleList.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/* SimpleList.java -- simple way to make tuples.
- Copyright (C) 2004, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.util;
-
-import java.util.AbstractList;
-import java.util.Collection;
-import java.util.Iterator;
-
-/**
- * A simple way to create immutable n-tuples. This class can be created with up
- * to four elements specified via one of the constructors, or with a collection
- * of arbitrary size.
- */
-public final class SimpleList
- extends AbstractList
-{
- private final Object[] elements;
-
- /**
- * Create a singleton list.
- *
- * @param element The first element.
- */
- public SimpleList(final Object element)
- {
- elements = new Object[1];
- elements[0] = element;
- }
-
- /**
- * Create an ordered pair (2-tuple).
- *
- * @param e1 The first element.
- * @param e2 The second element.
- */
- public SimpleList(final Object e1, final Object e2)
- {
- elements = new Object[2];
- elements[0] = e1;
- elements[1] = e2;
- }
-
- /**
- * Create a 3-tuple.
- *
- * @param e1 The first element.
- * @param e2 The second element.
- * @param e3 The third element.
- */
- public SimpleList(final Object e1, final Object e2, final Object e3)
- {
- elements = new Object[3];
- elements[0] = e1;
- elements[1] = e2;
- elements[2] = e3;
- }
-
- /**
- * Create a 4-tuple.
- *
- * @param e1 The first element.
- * @param e2 The second element.
- * @param e3 The third element.
- * @param e4 The fourth element.
- */
- public SimpleList(final Object e1, final Object e2, final Object e3,
- final Object e4)
- {
- elements = new Object[4];
- elements[0] = e1;
- elements[1] = e2;
- elements[2] = e3;
- elements[3] = e4;
- }
-
- /**
- * Create the empty list.
- */
- public SimpleList()
- {
- elements = null;
- }
-
- /**
- * Create an n-tuple of arbitrary size. Even if the supplied collection has no
- * natural order, the created n-tuple will have the order that the elements
- * are returned by the collection's iterator.
- *
- * @param c The collection.
- */
- public SimpleList(Collection c)
- {
- elements = new Object[c.size()];
- int i = 0;
- for (Iterator it = c.iterator(); it.hasNext() && i < elements.length;)
- elements[i++] = it.next();
- }
-
- public int size()
- {
- if (elements == null)
- return 0;
- return elements.length;
- }
-
- public Object get(int index)
- {
- if (elements == null)
- throw new IndexOutOfBoundsException("list is empty");
- if (index < 0 || index >= elements.length)
- throw new IndexOutOfBoundsException("index=" + index + ", size=" + size());
- return elements[index];
- }
-
- public String toString()
- {
- return SimpleList.class.getName() + "(" + size() + ") " + super.toString();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/Util.java b/openjdk/icedtea/jce/gnu/java/security/util/Util.java
deleted file mode 100644
index c7a6810f..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/Util.java
+++ /dev/null
@@ -1,627 +0,0 @@
-/* Util.java -- various utility routines.
- Copyright (C) 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
-
-This file is a 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 of the License, 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; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
-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 gnu.java.security.util;
-
-import java.math.BigInteger;
-
-/**
- * A collection of utility methods used throughout this project.
- */
-public class Util
-{
- // Hex charset
- private static final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
-
- // Base-64 charset
- private static final String BASE64_CHARS =
- "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz./";
-
- private static final char[] BASE64_CHARSET = BASE64_CHARS.toCharArray();
-
- /** Trivial constructor to enforce Singleton pattern. */
- private Util()
- {
- super();
- }
-
- /**
- * Returns a string of hexadecimal digits from a byte array. Each byte is
- * converted to 2 hex symbols; zero(es) included.
- *
- * This method calls the method with same name and three arguments as:
- *
- * toString(ba, 0, ba.length);
- *
- *
- * @param ba the byte array to convert.
- * @return a string of hexadecimal characters (two for each byte) representing
- * the designated input byte array.
- */
- public static String toString(byte[] ba)
- {
- return toString(ba, 0, ba.length);
- }
-
- /**
- * Returns a string of hexadecimal digits from a byte array, starting at
- * offset
and consisting of length
bytes. Each
- * byte is converted to 2 hex symbols; zero(es) included.
- *
- * @param ba the byte array to convert.
- * @param offset the index from which to start considering the bytes to
- * convert.
- * @param length the count of bytes, starting from the designated offset to
- * convert.
- * @return a string of hexadecimal characters (two for each byte) representing
- * the designated input byte sub-array.
- */
- public static final String toString(byte[] ba, int offset, int length)
- {
- char[] buf = new char[length * 2];
- for (int i = 0, j = 0, k; i < length;)
- {
- k = ba[offset + i++];
- buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[ k & 0x0F];
- }
- return new String(buf);
- }
-
- /**
- * Returns a string of hexadecimal digits from a byte array. Each byte is
- * converted to 2 hex symbols; zero(es) included. The argument is treated as a
- * large little-endian integer and is returned as a large big-endian integer.
- *
- * This method calls the method with same name and three arguments as:
- *
- * toReversedString(ba, 0, ba.length);
- *
- *
- * @param ba the byte array to convert.
- * @return a string of hexadecimal characters (two for each byte) representing
- * the designated input byte array.
- */
- public static String toReversedString(byte[] ba)
- {
- return toReversedString(ba, 0, ba.length);
- }
-
- /**
- * Returns a string of hexadecimal digits from a byte array, starting at
- * offset
and consisting of length
bytes. Each
- * byte is converted to 2 hex symbols; zero(es) included.
- *
- * The byte array is treated as a large little-endian integer, and is returned
- * as a large big-endian integer.
- *
- * @param ba the byte array to convert.
- * @param offset the index from which to start considering the bytes to
- * convert.
- * @param length the count of bytes, starting from the designated offset to
- * convert.
- * @return a string of hexadecimal characters (two for each byte) representing
- * the designated input byte sub-array.
- */
- public static final String toReversedString(byte[] ba, int offset, int length)
- {
- char[] buf = new char[length * 2];
- for (int i = offset + length - 1, j = 0, k; i >= offset;)
- {
- k = ba[offset + i--];
- buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[ k & 0x0F];
- }
- return new String(buf);
- }
-
- /**
- *
- * Returns a byte array from a string of hexadecimal digits.
- *
- *
- * @param s a string of hexadecimal ASCII characters
- * @return the decoded byte array from the input hexadecimal string.
- */
- public static byte[] toBytesFromString(String s)
- {
- int limit = s.length();
- byte[] result = new byte[((limit + 1) / 2)];
- int i = 0, j = 0;
- if ((limit % 2) == 1)
- result[j++] = (byte) fromDigit(s.charAt(i++));
- while (i < limit)
- {
- result[j ] = (byte) (fromDigit(s.charAt(i++)) << 4);
- result[j++] |= (byte) fromDigit(s.charAt(i++));
- }
- return result;
- }
-
- /**
- * Returns a byte array from a string of hexadecimal digits, interpreting them
- * as a large big-endian integer and returning it as a large little-endian
- * integer.
- *
- * @param s a string of hexadecimal ASCII characters
- * @return the decoded byte array from the input hexadecimal string.
- */
- public static byte[] toReversedBytesFromString(String s)
- {
- int limit = s.length();
- byte[] result = new byte[((limit + 1) / 2)];
- int i = 0;
- if ((limit % 2) == 1)
- result[i++] = (byte) fromDigit(s.charAt(--limit));
- while (limit > 0)
- {
- result[i ] = (byte) fromDigit(s.charAt(--limit));
- result[i++] |= (byte) (fromDigit(s.charAt(--limit)) << 4);
- }
- return result;
- }
-
- /**
- * Returns a number from 0
to 15
corresponding
- * to the designated hexadecimal digit.
- *
- * @param c a hexadecimal ASCII symbol.
- */
- public static int fromDigit(char c)
- {
- if (c >= '0' && c <= '9')
- return c - '0';
- else if (c >= 'A' && c <= 'F')
- return c - 'A' + 10;
- else if (c >= 'a' && c <= 'f')
- return c - 'a' + 10;
- else
- throw new IllegalArgumentException("Invalid hexadecimal digit: " + c);
- }
-
- /**
- * Returns a string of 8 hexadecimal digits (most significant digit first)
- * corresponding to the unsigned integer n
.
- *
- * @param n the unsigned integer to convert.
- * @return a hexadecimal string 8-character long.
- */
- public static String toString(int n)
- {
- char[] buf = new char[8];
- for (int i = 7; i >= 0; i--)
- {
- buf[i] = HEX_DIGITS[n & 0x0F];
- n >>>= 4;
- }
- return new String(buf);
- }
-
- /**
- * Returns a string of hexadecimal digits from an integer array. Each int is
- * converted to 4 hex symbols.
- */
- public static String toString(int[] ia)
- {
- int length = ia.length;
- char[] buf = new char[length * 8];
- for (int i = 0, j = 0, k; i < length; i++)
- {
- k = ia[i];
- buf[j++] = HEX_DIGITS[(k >>> 28) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 24) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 20) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 16) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 12) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 8) & 0x0F];
- buf[j++] = HEX_DIGITS[(k >>> 4) & 0x0F];
- buf[j++] = HEX_DIGITS[ k & 0x0F];
- }
- return new String(buf);
- }
-
- /**
- * Returns a string of 16 hexadecimal digits (most significant digit first)
- * corresponding to the unsigned long n
.
- *
- * @param n the unsigned long to convert.
- * @return a hexadecimal string 16-character long.
- */
- public static String toString(long n)
- {
- char[] b = new char[16];
- for (int i = 15; i >= 0; i--)
- {
- b[i] = HEX_DIGITS[(int)(n & 0x0FL)];
- n >>>= 4;
- }
- return new String(b);
- }
-
- /**
- * Similar to the toString()
method except that the Unicode
- * escape character is inserted before every pair of bytes. Useful to
- * externalise byte arrays that will be constructed later from such strings;
- * eg. s-box values.
- *
- * @throws ArrayIndexOutOfBoundsException if the length is odd.
- */
- public static String toUnicodeString(byte[] ba)
- {
- return toUnicodeString(ba, 0, ba.length);
- }
-
- /**
- * Similar to the toString()
method except that the Unicode
- * escape character is inserted before every pair of bytes. Useful to
- * externalise byte arrays that will be constructed later from such strings;
- * eg. s-box values.
- *
- * @throws ArrayIndexOutOfBoundsException if the length is odd.
- */
- public static final String toUnicodeString(byte[] ba, int offset, int length)
- {
- StringBuffer sb = new StringBuffer();
- int i = 0;
- int j = 0;
- int k;
- sb.append('\n').append("\"");
- while (i < length)
- {
- sb.append("\\u");
- k = ba[offset + i++];
- sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[ k & 0x0F]);
- k = ba[offset + i++];
- sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[ k & 0x0F]);
- if ((++j % 8) == 0)
- sb.append("\"+").append('\n').append("\"");
- }
- sb.append("\"").append('\n');
- return sb.toString();
- }
-
- /**
- * Similar to the toString()
method except that the Unicode
- * escape character is inserted before every pair of bytes. Useful to
- * externalise integer arrays that will be constructed later from such
- * strings; eg. s-box values.
- *
- * @throws ArrayIndexOutOfBoundsException if the length is not a multiple of
- * 4.
- */
- public static String toUnicodeString(int[] ia)
- {
- StringBuffer sb = new StringBuffer();
- int i = 0;
- int j = 0;
- int k;
- sb.append('\n').append("\"");
- while (i < ia.length)
- {
- k = ia[i++];
- sb.append("\\u");
- sb.append(HEX_DIGITS[(k >>> 28) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 24) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 20) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 16) & 0x0F]);
- sb.append("\\u");
- sb.append(HEX_DIGITS[(k >>> 12) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 8) & 0x0F]);
- sb.append(HEX_DIGITS[(k >>> 4) & 0x0F]);
- sb.append(HEX_DIGITS[ k & 0x0F]);
- if ((++j % 4) == 0)
- sb.append("\"+").append('\n').append("\"");
- }
- sb.append("\"").append('\n');
- return sb.toString();
- }
-
- public static byte[] toBytesFromUnicode(String s)
- {
- int limit = s.length() * 2;
- byte[] result = new byte[limit];
- char c;
- for (int i = 0; i < limit; i++)
- {
- c = s.charAt(i >>> 1);
- result[i] = (byte)(((i & 1) == 0) ? c >>> 8 : c);
- }
- return result;
- }
-
- /**
- * Dumps a byte array as a string, in a format that is easy to read for
- * debugging. The string m
is prepended to the start of each
- * line.
- *
- * If offset
and length
are omitted, the whole
- * array is used. If m
is omitted, nothing is prepended to each
- * line.
- *
- * @param data the byte array to be dumped.
- * @param offset the offset within data to start from.
- * @param length the number of bytes to dump.
- * @param m a string to be prepended to each line.
- * @return a string containing the result.
- */
- public static String dumpString(byte[] data, int offset, int length, String m)
- {
- if (data == null)
- return m + "null\n";
- StringBuffer sb = new StringBuffer(length * 3);
- if (length > 32)
- sb.append(m).append("Hexadecimal dump of ")
- .append(length).append(" bytes...\n");
- // each line will list 32 bytes in 4 groups of 8 each
- int end = offset + length;
- String s;
- int l = Integer.toString(length).length();
- if (l < 4)
- l = 4;
- for (; offset < end; offset += 32)
- {
- if (length > 32)
- {
- s = " " + offset;
- sb.append(m).append(s.substring(s.length() - l)).append(": ");
- }
- int i = 0;
- for (; i < 32 && offset + i + 7 < end; i += 8)
- sb.append(toString(data, offset + i, 8)).append(' ');
- if (i < 32)
- for (; i < 32 && offset + i < end; i++)
- sb.append(byteToString(data[offset + i]));
- sb.append('\n');
- }
- return sb.toString();
- }
-
- public static String dumpString(byte[] data)
- {
- return (data == null) ? "null\n" : dumpString(data, 0, data.length, "");
- }
-
- public static String dumpString(byte[] data, String m)
- {
- return (data == null) ? "null\n" : dumpString(data, 0, data.length, m);
- }
-
- public static String dumpString(byte[] data, int offset, int length)
- {
- return dumpString(data, offset, length, "");
- }
-
- /**
- * Returns a string of 2 hexadecimal digits (most significant digit first)
- * corresponding to the lowest 8 bits of n
.
- *
- * @param n the byte value to convert.
- * @return a string of 2 hex characters representing the input.
- */
- public static String byteToString(int n)
- {
- char[] buf = { HEX_DIGITS[(n >>> 4) & 0x0F], HEX_DIGITS[n & 0x0F] };
- return new String(buf);
- }
-
- /**
- * Converts a designated byte array to a Base-64 representation, with the
- * exceptions that (a) leading 0-byte(s) are ignored, and (b) the character
- * '.' (dot) shall be used instead of "+' (plus).
- *
- * Used by SASL password file manipulation primitives.
- *
- * @param buffer an arbitrary sequence of bytes to represent in Base-64.
- * @return unpadded (without the '=' character(s)) Base-64 representation of
- * the input.
- */
- public static final String toBase64(byte[] buffer)
- {
- int len = buffer.length, pos = len % 3;
- byte b0 = 0, b1 = 0, b2 = 0;
- switch (pos)
- {
- case 1:
- b2 = buffer[0];
- break;
- case 2:
- b1 = buffer[0];
- b2 = buffer[1];
- break;
- }
- StringBuffer sb = new StringBuffer();
- int c;
- boolean notleading = false;
- do
- {
- c = (b0 & 0xFC) >>> 2;
- if (notleading || c != 0)
- {
- sb.append(BASE64_CHARSET[c]);
- notleading = true;
- }
- c = ((b0 & 0x03) << 4) | ((b1 & 0xF0) >>> 4);
- if (notleading || c != 0)
- {
- sb.append(BASE64_CHARSET[c]);
- notleading = true;
- }
- c = ((b1 & 0x0F) << 2) | ((b2 & 0xC0) >>> 6);
- if (notleading || c != 0)
- {
- sb.append(BASE64_CHARSET[c]);
- notleading = true;
- }
- c = b2 & 0x3F;
- if (notleading || c != 0)
- {
- sb.append(BASE64_CHARSET[c]);
- notleading = true;
- }
- if (pos >= len)
- break;
- else
- {
- try
- {
- b0 = buffer[pos++];
- b1 = buffer[pos++];
- b2 = buffer[pos++];
- }
- catch (ArrayIndexOutOfBoundsException x)
- {
- break;
- }
- }
- }
- while (true);
-
- if (notleading)
- return sb.toString();
- return "0";
- }
-
- /**
- * The inverse function of the above.
- *
- * Converts a string representing the encoding of some bytes in Base-64 to
- * their original form.
- *
- * @param str the Base-64 encoded representation of some byte(s).
- * @return the bytes represented by the str
.
- * @throws NumberFormatException if str
is null
,
- * or str
contains an illegal Base-64 character.
- * @see #toBase64(byte[])
- */
- public static final byte[] fromBase64(String str)
- {
- int len = str.length();
- if (len == 0)
- throw new NumberFormatException("Empty string");
- byte[] a = new byte[len + 1];
- int i, j;
- for (i = 0; i < len; i++)
- try
- {
- a[i] = (byte) BASE64_CHARS.indexOf(str.charAt(i));
- }
- catch (ArrayIndexOutOfBoundsException x)
- {
- throw new NumberFormatException("Illegal character at #" + i);
- }
- i = len - 1;
- j = len;
- try
- {
- while (true)
- {
- a[j] = a[i];
- if (--i < 0)
- break;
- a[j] |= (a[i] & 0x03) << 6;
- j--;
- a[j] = (byte)((a[i] & 0x3C) >>> 2);
- if (--i < 0)
- break;
- a[j] |= (a[i] & 0x0F) << 4;
- j--;
- a[j] = (byte)((a[i] & 0x30) >>> 4);
- if (--i < 0)
- break;
- a[j] |= (a[i] << 2);
- j--;
- a[j] = 0;
- if (--i < 0)
- break;
- }
- }
- catch (Exception ignored)
- {
- }
- try
- { // ignore leading 0-bytes
- while (a[j] == 0)
- j++;
- }
- catch (Exception x)
- {
- return new byte[1]; // one 0-byte
- }
- byte[] result = new byte[len - j + 1];
- System.arraycopy(a, j, result, 0, len - j + 1);
- return result;
- }
-
- // BigInteger utilities ----------------------------------------------------
-
- /**
- * Treats the input as the MSB representation of a number, and discards
- * leading zero elements. For efficiency, the input is simply returned if no
- * leading zeroes are found.
- *
- * @param n the {@link BigInteger} to trim.
- * @return the byte array representation of the designated {@link BigInteger}
- * with no leading 0-bytes.
- */
- public static final byte[] trim(BigInteger n)
- {
- byte[] in = n.toByteArray();
- if (in.length == 0 || in[0] != 0)
- return in;
- int len = in.length;
- int i = 1;
- while (in[i] == 0 && i < len)
- ++i;
- byte[] result = new byte[len - i];
- System.arraycopy(in, i, result, 0, len - i);
- return result;
- }
-
- /**
- * Returns a hexadecimal dump of the trimmed bytes of a {@link BigInteger}.
- *
- * @param x the {@link BigInteger} to display.
- * @return the string representation of the designated {@link BigInteger}.
- */
- public static final String dump(BigInteger x)
- {
- return dumpString(trim(x));
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/util/package.html b/openjdk/icedtea/jce/gnu/java/security/util/package.html
deleted file mode 100644
index 36dd33b7..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/util/package.html
+++ /dev/null
@@ -1,46 +0,0 @@
-
-
-
-
-
GNU Classpath - gnu.java.security.util
-
-
-
-
-
-
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/GnuPKIExtension.java b/openjdk/icedtea/jce/gnu/java/security/x509/GnuPKIExtension.java
deleted file mode 100644
index 8e74b8b2..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/GnuPKIExtension.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/* GnuPKIExtension.java -- interface for GNU PKI extensions.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.java.security.OID;
-import gnu.java.security.x509.ext.Extension;
-
-import java.security.cert.X509Extension;
-import java.util.Collection;
-
-public interface GnuPKIExtension extends X509Extension
-{
-
- /**
- * Returns the extension object for the given object identifier.
- *
- * @param oid The OID of the extension to get.
- * @return The extension, or null if there is no such extension.
- */
- Extension getExtension(OID oid);
-
- Collection getExtensions();
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/PolicyNodeImpl.java b/openjdk/icedtea/jce/gnu/java/security/x509/PolicyNodeImpl.java
deleted file mode 100644
index 72cb4a9e..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/PolicyNodeImpl.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/* PolicyNodeImpl.java -- An implementation of a policy tree node.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import java.security.cert.PolicyNode;
-import java.security.cert.PolicyQualifierInfo;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-public final class PolicyNodeImpl implements PolicyNode
-{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private String policy;
- private final Set expectedPolicies;
- private final Set qualifiers;
- private final Set children;
- private PolicyNodeImpl parent;
- private int depth;
- private boolean critical;
- private boolean readOnly;
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public PolicyNodeImpl()
- {
- expectedPolicies = new HashSet();
- qualifiers = new HashSet();
- children = new HashSet();
- readOnly = false;
- critical = false;
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public void addChild(PolicyNodeImpl node)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- if (node.getParent() != null)
- throw new IllegalStateException("already a child node");
- node.parent = this;
- node.setDepth(depth + 1);
- children.add(node);
- }
-
- public Iterator getChildren()
- {
- return Collections.unmodifiableSet(children).iterator();
- }
-
- public int getDepth()
- {
- return depth;
- }
-
- public void setDepth(int depth)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- this.depth = depth;
- }
-
- public void addAllExpectedPolicies(Set policies)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- expectedPolicies.addAll(policies);
- }
-
- public void addExpectedPolicy(String policy)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- expectedPolicies.add(policy);
- }
-
- public Set getExpectedPolicies()
- {
- return Collections.unmodifiableSet(expectedPolicies);
- }
-
- public PolicyNode getParent()
- {
- return parent;
- }
-
- public void addAllPolicyQualifiers (Collection qualifiers)
- {
- for (Iterator it = qualifiers.iterator(); it.hasNext(); )
- {
- if (!(it.next() instanceof PolicyQualifierInfo))
- throw new IllegalArgumentException ("can only add PolicyQualifierInfos");
- }
- qualifiers.addAll (qualifiers);
- }
-
- public void addPolicyQualifier (PolicyQualifierInfo qualifier)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- qualifiers.add(qualifier);
- }
-
- public Set getPolicyQualifiers()
- {
- return Collections.unmodifiableSet(qualifiers);
- }
-
- public String getValidPolicy()
- {
- return policy;
- }
-
- public void setValidPolicy(String policy)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- this.policy = policy;
- }
-
- public boolean isCritical()
- {
- return critical;
- }
-
- public void setCritical(boolean critical)
- {
- if (readOnly)
- throw new IllegalStateException("read only");
- this.critical = critical;
- }
-
- public void setReadOnly()
- {
- if (readOnly)
- return;
- readOnly = true;
- for (Iterator it = getChildren(); it.hasNext(); )
- ((PolicyNodeImpl) it.next()).setReadOnly();
- }
-
- public String toString()
- {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < depth; i++)
- buf.append(" ");
- buf.append("(");
- buf.append(PolicyNodeImpl.class.getName());
- buf.append(" (oid ");
- buf.append(policy);
- buf.append(") (depth ");
- buf.append(depth);
- buf.append(") (qualifiers ");
- buf.append(qualifiers);
- buf.append(") (critical ");
- buf.append(critical);
- buf.append(") (expectedPolicies ");
- buf.append(expectedPolicies);
- buf.append(") (children (");
- final String nl = System.getProperty("line.separator");
- for (Iterator it = getChildren(); it.hasNext(); )
- {
- buf.append(nl);
- buf.append(it.next().toString());
- }
- buf.append(")))");
- return buf.toString();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/Util.java b/openjdk/icedtea/jce/gnu/java/security/x509/Util.java
deleted file mode 100644
index 1bd268a5..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/Util.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/* Util.java -- Miscellaneous utility methods.
- Copyright (C) 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-/**
- * A collection of useful class methods.
- *
- * @author Casey Marshall (rsdio@metastatic.org)
- */
-public final class Util
-{
-
- // Constants.
- // -------------------------------------------------------------------------
-
- public static final String HEX = "0123456789abcdef";
-
- // Class methods.
- // -------------------------------------------------------------------------
-
- /**
- * Convert a byte array to a hexadecimal string, as though it were a
- * big-endian arbitrarily-sized integer.
- *
- * @param buf The bytes to format.
- * @param off The offset to start at.
- * @param len The number of bytes to format.
- * @return A hexadecimal representation of the specified bytes.
- */
- public static String toHexString(byte[] buf, int off, int len)
- {
- StringBuffer str = new StringBuffer();
- for (int i = 0; i < len; i++)
- {
- str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
- str.append(HEX.charAt(buf[i+off] & 0x0F));
- }
- return str.toString();
- }
-
- /**
- * See {@link #toHexString(byte[],int,int)}.
- */
- public static String toHexString(byte[] buf)
- {
- return Util.toHexString(buf, 0, buf.length);
- }
-
- /**
- * Convert a byte array to a hexadecimal string, separating octets
- * with the given character.
- *
- * @param buf The bytes to format.
- * @param off The offset to start at.
- * @param len The number of bytes to format.
- * @param sep The character to insert between octets.
- * @return A hexadecimal representation of the specified bytes.
- */
- public static String toHexString(byte[] buf, int off, int len, char sep)
- {
- StringBuffer str = new StringBuffer();
- for (int i = 0; i < len; i++)
- {
- str.append(HEX.charAt(buf[i+off] >>> 4 & 0x0F));
- str.append(HEX.charAt(buf[i+off] & 0x0F));
- if (i < len - 1)
- str.append(sep);
- }
- return str.toString();
- }
-
- /**
- * See {@link #toHexString(byte[],int,int,char)}.
- */
- public static String toHexString(byte[] buf, char sep)
- {
- return Util.toHexString(buf, 0, buf.length, sep);
- }
-
- /**
- * Create a representation of the given byte array similar to the
- * output of `hexdump -C', which is
- *
- * OFFSET SIXTEEN-BYTES-IN-HEX PRINTABLE-BYTES
- *
- * The printable bytes show up as-is if they are printable and
- * not a newline character, otherwise showing as '.'.
- *
- * @param buf The bytes to format.
- * @param off The offset to start at.
- * @param len The number of bytes to encode.
- * @return The formatted string.
- */
- public static String hexDump(byte[] buf, int off, int len, String prefix)
- {
- String nl = System.getProperty("line.separator");
- StringBuffer str = new StringBuffer();
- int i = 0;
- while (i < len)
- {
- str.append(prefix);
- str.append(Util.formatInt(i+off, 16, 8));
- str.append(" ");
- String s = Util.toHexString(buf, i+off, Math.min(16, len-i), ' ');
- str.append(s);
- for (int j = 56 - (56 - s.length()); j < 56; j++)
- str.append(" ");
- for (int j = 0; j < Math.min(16, len - i); j++)
- {
- if ((buf[i+off+j] & 0xFF) < 0x20 || (buf[i+off+j] & 0xFF) > 0x7E)
- str.append('.');
- else
- str.append((char) (buf[i+off+j] & 0xFF));
- }
- str.append(nl);
- i += 16;
- }
- return str.toString();
- }
-
- /**
- * See {@link #hexDump(byte[],int,int,String)}.
- */
- public static String hexDump(byte[] buf, String prefix)
- {
- return hexDump(buf, 0, buf.length, prefix);
- }
-
- /**
- * Format an integer into the specified radix, zero-filled.
- *
- * @param i The integer to format.
- * @param radix The radix to encode to.
- * @param len The target length of the string. The string is
- * zero-padded to this length, but may be longer.
- * @return The formatted integer.
- */
- public static String formatInt(int i, int radix, int len)
- {
- String s = Integer.toString(i, radix);
- StringBuffer buf = new StringBuffer();
- for (int j = 0; j < len - s.length(); j++)
- buf.append("0");
- buf.append(s);
- return buf.toString();
- }
-
- /**
- * Convert a hexadecimal string into its byte representation.
- *
- * @param hex The hexadecimal string.
- * @return The converted bytes.
- */
- public static byte[] toByteArray(String hex)
- {
- hex = hex.toLowerCase();
- byte[] buf = new byte[hex.length() / 2];
- int j = 0;
- for (int i = 0; i < buf.length; i++)
- {
- buf[i] = (byte) ((Character.digit(hex.charAt(j++), 16) << 4) |
- Character.digit(hex.charAt(j++), 16));
- }
- return buf;
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X500DistinguishedName.java b/openjdk/icedtea/jce/gnu/java/security/x509/X500DistinguishedName.java
deleted file mode 100644
index 02adad7d..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X500DistinguishedName.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/* X500DistinguishedName.java -- X.500 distinguished name.
- Copyright (C) 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.java.security.OID;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.security.Principal;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class X500DistinguishedName implements Principal
-{
- // Constants and fields.
- // -------------------------------------------------------------------------
-
- public static final OID CN = new OID("2.5.4.3");
- public static final OID C = new OID("2.5.4.6");
- public static final OID L = new OID("2.5.4.7");
- public static final OID ST = new OID("2.5.4.8");
- public static final OID STREET = new OID("2.5.4.9");
- public static final OID O = new OID("2.5.4.10");
- public static final OID OU = new OID("2.5.4.11");
- public static final OID T = new OID("2.5.4.12");
- public static final OID DNQ = new OID("2.5.4.46");
- public static final OID NAME = new OID("2.5.4.41");
- public static final OID GIVENNAME = new OID("2.5.4.42");
- public static final OID INITIALS = new OID("2.5.4.43");
- public static final OID GENERATION = new OID("2.5.4.44");
- public static final OID EMAIL = new OID("1.2.840.113549.1.9.1");
- public static final OID DC = new OID("0.9.2342.19200300.100.1.25");
- public static final OID UID = new OID("0.9.2342.19200300.100.1.1");
-
- private List components;
- private Map currentRdn;
- private boolean fixed;
- private String stringRep;
- private byte[] encoded;
-
- // Constructors.
- // -------------------------------------------------------------------------
-
- public X500DistinguishedName()
- {
- components = new LinkedList();
- currentRdn = new LinkedHashMap();
- components.add(currentRdn);
- }
-
- public X500DistinguishedName(String name)
- {
- this();
- try
- {
- parseString(name);
- }
- catch (IOException ioe)
- {
- throw new IllegalArgumentException(ioe.toString());
- }
- }
-
- public X500DistinguishedName(byte[] encoded) throws IOException
- {
- this();
- parseDer(new DERReader(encoded));
- }
-
- public X500DistinguishedName(InputStream encoded) throws IOException
- {
- this();
- parseDer(new DERReader(encoded));
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public String getName()
- {
- return toString();
- }
-
- public void newRelativeDistinguishedName()
- {
- if (fixed || currentRdn.isEmpty()) return;
- currentRdn = new LinkedHashMap();
- components.add(currentRdn);
- }
-
- public int size()
- {
- return components.size();
- }
-
- public int countComponents()
- {
- int count = 0;
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- count += ((Map) it.next()).size();
- }
- return count;
- }
-
- public boolean containsComponent(OID oid, String value)
- {
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map rdn = (Map) it.next();
- String s = (String) rdn.get(oid);
- if (s == null)
- continue;
- if (compressWS(value).equalsIgnoreCase(compressWS(s)))
- return true;
- }
- return false;
- }
-
- public String getComponent(OID oid)
- {
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map rdn = (Map) it.next();
- if (rdn.containsKey(oid))
- return (String) rdn.get(oid);
- }
- return null;
- }
-
- public String getComponent(OID oid, int rdn)
- {
- if (rdn >= size())
- return null;
- return (String) ((Map) components.get(rdn)).get(oid);
- }
-
- public void putComponent(OID oid, String value)
- {
- currentRdn.put(oid, value);
- }
-
- public void putComponent(String name, String value)
- {
- name = name.trim().toLowerCase();
- if (name.equals("cn"))
- putComponent(CN, value);
- else if (name.equals("c"))
- putComponent(C, value);
- else if (name.equals("l"))
- putComponent(L, value);
- else if (name.equals("street"))
- putComponent(STREET, value);
- else if (name.equals("st"))
- putComponent(ST, value);
- else if (name.equals("t"))
- putComponent(T, value);
- else if (name.equals("dnq"))
- putComponent(DNQ, value);
- else if (name.equals("name"))
- putComponent(NAME, value);
- else if (name.equals("givenname"))
- putComponent(GIVENNAME, value);
- else if (name.equals("initials"))
- putComponent(INITIALS, value);
- else if (name.equals("generation"))
- putComponent(GENERATION, value);
- else if (name.equals("email"))
- putComponent(EMAIL, value);
- else if (name.equals("dc"))
- putComponent(DC, value);
- else if (name.equals("uid"))
- putComponent(UID, value);
- else if (name.equals("o"))
- putComponent(O, value);
- else if (name.equals("ou"))
- putComponent(OU, value);
- else
- putComponent(new OID(name), value);
- }
-
- public void setUnmodifiable()
- {
- if (fixed) return;
- fixed = true;
- List newComps = new ArrayList(components.size());
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map rdn = (Map) it.next();
- rdn = Collections.unmodifiableMap(rdn);
- newComps.add(rdn);
- }
- components = Collections.unmodifiableList(newComps);
- currentRdn = Collections.EMPTY_MAP;
- }
-
- public int hashCode()
- {
- int sum = 0;
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map m = (Map) it.next();
- for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
- {
- Map.Entry e = (Map.Entry) it2.next();
- sum += e.getKey().hashCode();
- sum += e.getValue().hashCode();
- }
- }
- return sum;
- }
-
- public boolean equals(Object o)
- {
- if (!(o instanceof X500DistinguishedName))
- return false;
- if (size() != ((X500DistinguishedName) o).size())
- return false;
- for (int i = 0; i < size(); i++)
- {
- Map m = (Map) components.get(i);
- for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
- {
- Map.Entry e = (Map.Entry) it2.next();
- OID oid = (OID) e.getKey();
- String v1 = (String) e.getValue();
- String v2 = ((X500DistinguishedName) o).getComponent(oid, i);
- if (!compressWS(v1).equalsIgnoreCase(compressWS(v2)))
- return false;
- }
- }
- return true;
- }
-
- public String toString()
- {
- if (fixed && stringRep != null)
- return stringRep;
- StringBuffer str = new StringBuffer();
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map m = (Map) it.next();
- for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) it2.next();
- OID oid = (OID) entry.getKey();
- String value = (String) entry.getValue();
- if (oid.equals(CN))
- str.append("CN");
- else if (oid.equals(C))
- str.append("C");
- else if (oid.equals(L))
- str.append("L");
- else if (oid.equals(ST))
- str.append("ST");
- else if (oid.equals(STREET))
- str.append("STREET");
- else if (oid.equals(O))
- str.append("O");
- else if (oid.equals(OU))
- str.append("OU");
- else if (oid.equals(T))
- str.append("T");
- else if (oid.equals(DNQ))
- str.append("DNQ");
- else if (oid.equals(NAME))
- str.append("NAME");
- else
- str.append(oid.toString());
- str.append('=');
- str.append(value);
- if (it2.hasNext())
- str.append("+");
- }
- if (it.hasNext())
- str.append(',');
- }
- return (stringRep = str.toString());
- }
-
- public byte[] getDer()
- {
- if (fixed && encoded != null)
- return (byte[]) encoded.clone();
-
- ArrayList name = new ArrayList(components.size());
- for (Iterator it = components.iterator(); it.hasNext(); )
- {
- Map m = (Map) it.next();
- if (m.isEmpty())
- continue;
-
- Set rdn = new HashSet();
- for (Iterator it2 = m.entrySet().iterator(); it2.hasNext(); )
- {
- Map.Entry e = (Map.Entry) it2.next();
- ArrayList atav = new ArrayList(2);
- atav.add(new DERValue(DER.OBJECT_IDENTIFIER, e.getKey()));
- atav.add(new DERValue(DER.UTF8_STRING, e.getValue()));
- rdn.add(new DERValue(DER.SEQUENCE|DER.CONSTRUCTED, atav));
- }
- name.add(new DERValue(DER.SET|DER.CONSTRUCTED, rdn));
- }
- DERValue val = new DERValue(DER.SEQUENCE|DER.CONSTRUCTED, name);
- return (byte[]) (encoded = val.getEncoded()).clone();
- }
-
- // Own methods.
- // -------------------------------------------------------------------------
-
- private int sep;
-
- private void parseString(String str) throws IOException
- {
- Reader in = new StringReader(str);
- while (true)
- {
- String key = readAttributeType(in);
- if (key == null)
- break;
- String value = readAttributeValue(in);
- putComponent(key, value);
- if (sep == ',')
- newRelativeDistinguishedName();
- }
- setUnmodifiable();
- }
-
- private String readAttributeType(Reader in) throws IOException
- {
- StringBuffer buf = new StringBuffer();
- int ch;
- while ((ch = in.read()) != '=')
- {
- if (ch == -1)
- {
- if (buf.length() > 0)
- throw new EOFException();
- return null;
- }
- if (ch > 127)
- throw new IOException("Invalid char: " + (char) ch);
- if (Character.isLetterOrDigit((char) ch) || ch == '-' || ch == '.')
- buf.append((char) ch);
- else
- throw new IOException("Invalid char: " + (char) ch);
- }
- return buf.toString();
- }
-
- private String readAttributeValue(Reader in) throws IOException
- {
- StringBuffer buf = new StringBuffer();
- int ch = in.read();
- if (ch == '#')
- {
- while (true)
- {
- ch = in.read();
- if (('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F')
- || Character.isDigit((char) ch))
- buf.append((char) ch);
- else if (ch == '+' || ch == ',')
- {
- sep = ch;
- String hex = buf.toString();
- return new String(Util.toByteArray(hex));
- }
- else
- throw new IOException("illegal character: " + (char) ch);
- }
- }
- else if (ch == '"')
- {
- while (true)
- {
- ch = in.read();
- if (ch == '"')
- break;
- else if (ch == '\\')
- {
- ch = in.read();
- if (ch == -1)
- throw new EOFException();
- if (('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F')
- || Character.isDigit((char) ch))
- {
- int i = Character.digit((char) ch, 16) << 4;
- ch = in.read();
- if (!(('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F')
- || Character.isDigit((char) ch)))
- throw new IOException("illegal hex char");
- i |= Character.digit((char) ch, 16);
- buf.append((char) i);
- }
- else
- buf.append((char) ch);
- }
- else
- buf.append((char) ch);
- }
- sep = in.read();
- if (sep != '+' || sep != ',')
- throw new IOException("illegal character: " + (char) ch);
- return buf.toString();
- }
- else
- {
- while (true)
- {
- switch (ch)
- {
- case '+':
- case ',':
- sep = ch;
- return buf.toString();
- case '\\':
- ch = in.read();
- if (ch == -1)
- throw new EOFException();
- if (('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F')
- || Character.isDigit((char) ch))
- {
- int i = Character.digit((char) ch, 16) << 4;
- ch = in.read();
- if (!(('a' <= ch && ch <= 'f') || ('A' <= ch && ch <= 'F')
- || Character.isDigit((char) ch)))
- throw new IOException("illegal hex char");
- i |= Character.digit((char) ch, 16);
- buf.append((char) i);
- }
- else
- buf.append((char) ch);
- break;
- case '=':
- case '<':
- case '>':
- case '#':
- case ';':
- throw new IOException("illegal character: " + (char) ch);
- case -1:
- throw new EOFException();
- default:
- buf.append((char) ch);
- ch = in.read();
- if (ch == -1)
- return buf.toString();
- }
- }
- }
- }
-
- private void parseDer(DERReader der) throws IOException
- {
- DERValue name = der.read();
- if (!name.isConstructed())
- throw new IOException("malformed Name");
- encoded = name.getEncoded();
- int len = 0;
- while (len < name.getLength())
- {
- DERValue rdn = der.read();
- if (!rdn.isConstructed())
- throw new IOException("badly formed RDNSequence");
- int len2 = 0;
- while (len2 < rdn.getLength())
- {
- DERValue atav = der.read();
- if (!atav.isConstructed())
- throw new IOException("badly formed AttributeTypeAndValue");
- DERValue val = der.read();
- if (val.getTag() != DER.OBJECT_IDENTIFIER)
- throw new IOException("badly formed AttributeTypeAndValue");
- OID oid = (OID) val.getValue();
- val = der.read();
- if (!(val.getValue() instanceof String))
- throw new IOException("badly formed AttributeTypeAndValue");
- String value = (String) val.getValue();
- putComponent(oid, value);
- len2 += atav.getEncodedLength();
- }
- len += rdn.getEncodedLength();
- if (len < name.getLength())
- newRelativeDistinguishedName();
- }
- setUnmodifiable();
- }
-
- private static String compressWS(String str)
- {
- StringBuffer buf = new StringBuffer();
- char lastChar = 0;
- for (int i = 0; i < str.length(); i++)
- {
- char c = str.charAt(i);
- if (Character.isWhitespace(c))
- {
- if (!Character.isWhitespace(lastChar))
- buf.append(' ');
- }
- else
- buf.append(c);
- lastChar = c;
- }
- return buf.toString().trim();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRL.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509CRL.java
deleted file mode 100644
index 7c471c97..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRL.java
+++ /dev/null
@@ -1,485 +0,0 @@
-/* X509CRL.java -- X.509 certificate revocation list.
- Copyright (C) 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.OID;
-import gnu.java.security.der.BitString;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.x509.ext.Extension;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.cert.CRLException;
-import java.security.cert.Certificate;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * X.509 certificate revocation lists.
- *
- * @author Casey Marshall (rsdio@metastatic.org)
- */
-public class X509CRL extends java.security.cert.X509CRL
- implements GnuPKIExtension
-{
- private static final Logger log = Logger.getLogger(X509CRL.class.getName());
- private static final OID ID_DSA = new OID("1.2.840.10040.4.1");
- private static final OID ID_DSA_WITH_SHA1 = new OID("1.2.840.10040.4.3");
- private static final OID ID_RSA = new OID("1.2.840.113549.1.1.1");
- private static final OID ID_RSA_WITH_MD2 = new OID("1.2.840.113549.1.1.2");
- private static final OID ID_RSA_WITH_MD5 = new OID("1.2.840.113549.1.1.4");
- private static final OID ID_RSA_WITH_SHA1 = new OID("1.2.840.113549.1.1.5");
-
- private byte[] encoded;
-
- private byte[] tbsCRLBytes;
- private int version;
- private OID algId;
- private byte[] algParams;
- private Date thisUpdate;
- private Date nextUpdate;
- private X500DistinguishedName issuerDN;
- private HashMap revokedCerts;
- private HashMap extensions;
-
- private OID sigAlg;
- private byte[] sigAlgParams;
- private byte[] rawSig;
- private byte[] signature;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new X.509 CRL.
- *
- * @param encoded The DER encoded CRL.
- * @throws CRLException If the input bytes are incorrect.
- * @throws IOException If the input bytes cannot be read.
- */
- public X509CRL(InputStream encoded) throws CRLException, IOException
- {
- super();
- revokedCerts = new HashMap();
- extensions = new HashMap();
- try
- {
- parse(encoded);
- }
- catch (IOException ioe)
- {
- ioe.printStackTrace();
- throw ioe;
- }
- catch (Exception x)
- {
- x.printStackTrace();
- throw new CRLException(x.toString());
- }
- }
-
- // X509CRL methods.
- // ------------------------------------------------------------------------
-
- public boolean equals(Object o)
- {
- if (!(o instanceof X509CRL))
- return false;
- return ((X509CRL) o).getRevokedCertificates().equals(revokedCerts.values());
- }
-
- public int hashCode()
- {
- return revokedCerts.hashCode();
- }
-
- public byte[] getEncoded() throws CRLException
- {
- return (byte[]) encoded.clone();
- }
-
- public void verify(PublicKey key)
- throws CRLException, NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException
- {
- Signature sig = Signature.getInstance(sigAlg.toString());
- doVerify(sig, key);
- }
-
- public void verify(PublicKey key, String provider)
- throws CRLException, NoSuchAlgorithmException, InvalidKeyException,
- NoSuchProviderException, SignatureException
- {
- Signature sig = Signature.getInstance(sigAlg.toString(), provider);
- doVerify(sig, key);
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public Principal getIssuerDN()
- {
- return issuerDN;
- }
-
- public X500Principal getIssuerX500Principal()
- {
- return new X500Principal(issuerDN.getDer());
- }
-
- public Date getThisUpdate()
- {
- return (Date) thisUpdate.clone();
- }
-
- public Date getNextUpdate()
- {
- if (nextUpdate != null)
- return (Date) nextUpdate.clone();
- return null;
- }
-
- public java.security.cert.X509CRLEntry getRevokedCertificate(BigInteger serialNo)
- {
- return (java.security.cert.X509CRLEntry) revokedCerts.get(serialNo);
- }
-
- public Set getRevokedCertificates()
- {
- return Collections.unmodifiableSet(new HashSet(revokedCerts.values()));
- }
-
- public byte[] getTBSCertList() throws CRLException
- {
- return (byte[]) tbsCRLBytes.clone();
- }
-
- public byte[] getSignature()
- {
- return (byte[]) rawSig.clone();
- }
-
- public String getSigAlgName()
- {
- if (sigAlg.equals(ID_DSA_WITH_SHA1))
- return "SHA1withDSA";
- if (sigAlg.equals(ID_RSA_WITH_MD2))
- return "MD2withRSA";
- if (sigAlg.equals(ID_RSA_WITH_MD5))
- return "MD5withRSA";
- if (sigAlg.equals(ID_RSA_WITH_SHA1))
- return "SHA1withRSA";
- return "unknown";
- }
-
- public String getSigAlgOID()
- {
- return sigAlg.toString();
- }
-
- public byte[] getSigAlgParams()
- {
- if (sigAlgParams != null)
- return (byte[]) sigAlgParams.clone();
- return null;
- }
-
- // X509Extension methods.
- // ------------------------------------------------------------------------
-
- public boolean hasUnsupportedCriticalExtension()
- {
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (e.isCritical() && !e.isSupported())
- return true;
- }
- return false;
- }
-
- public Set getCriticalExtensionOIDs()
- {
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (e.isCritical())
- s.add(e.getOid().toString());
- }
- return Collections.unmodifiableSet(s);
- }
-
- public Set getNonCriticalExtensionOIDs()
- {
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (!e.isCritical())
- s.add(e.getOid().toString());
- }
- return Collections.unmodifiableSet(s);
- }
-
- public byte[] getExtensionValue(String oid)
- {
- Extension e = getExtension(new OID(oid));
- if (e != null)
- {
- return e.getValue().getEncoded();
- }
- return null;
- }
-
- // GnuPKIExtension method.
- // -------------------------------------------------------------------------
-
- public Extension getExtension(OID oid)
- {
- return (Extension) extensions.get(oid);
- }
-
- public Collection getExtensions()
- {
- return extensions.values();
- }
-
- // CRL methods.
- // -------------------------------------------------------------------------
-
- public String toString()
- {
- return X509CRL.class.getName();
- }
-
- public boolean isRevoked(Certificate cert)
- {
- if (!(cert instanceof java.security.cert.X509Certificate))
- throw new IllegalArgumentException("not a X.509 certificate");
- BigInteger certSerial =
- ((java.security.cert.X509Certificate) cert).getSerialNumber();
- X509CRLEntry ent = (X509CRLEntry) revokedCerts.get(certSerial);
- if (ent == null)
- return false;
- return ent.getRevocationDate().compareTo(new Date()) < 0;
- }
-
- // Own methods.
- // ------------------------------------------------------------------------
-
- private void doVerify(Signature sig, PublicKey key)
- throws CRLException, InvalidKeyException, SignatureException
- {
- sig.initVerify(key);
- sig.update(tbsCRLBytes);
- if (!sig.verify(signature))
- throw new CRLException("signature not verified");
- }
-
- private void parse(InputStream in) throws Exception
- {
- // CertificateList ::= SEQUENCE {
- DERReader der = new DERReader(in);
- DERValue val = der.read();
- if (Configuration.DEBUG)
- log.fine("start CertificateList len == " + val.getLength());
- if (!val.isConstructed())
- throw new IOException("malformed CertificateList");
- encoded = val.getEncoded();
-
- // tbsCertList ::= SEQUENCE { -- TBSCertList
- val = der.read();
- if (!val.isConstructed())
- throw new IOException("malformed TBSCertList");
- if (Configuration.DEBUG)
- log.fine("start tbsCertList len == " + val.getLength());
- tbsCRLBytes = val.getEncoded();
-
- // version Version OPTIONAL,
- // -- If present must be v2
- val = der.read();
- if (val.getValue() instanceof BigInteger)
- {
- version = ((BigInteger) val.getValue()).intValue() + 1;
- val = der.read();
- }
- else
- version = 1;
- if (Configuration.DEBUG)
- log.fine("read version == " + version);
-
- // signature AlgorithmIdentifier,
- if (Configuration.DEBUG)
- log.fine("start AlgorithmIdentifier len == " + val.getLength());
- if (!val.isConstructed())
- throw new IOException("malformed AlgorithmIdentifier");
- DERValue algIdVal = der.read();
- algId = (OID) algIdVal.getValue();
- if (Configuration.DEBUG)
- log.fine("read object identifier == " + algId);
- if (val.getLength() > algIdVal.getEncodedLength())
- {
- val = der.read();
- if (Configuration.DEBUG)
- log.fine("read parameters len == " + val.getEncodedLength());
- algParams = val.getEncoded();
- if (val.isConstructed())
- in.skip(val.getLength());
- }
-
- // issuer Name,
- val = der.read();
- issuerDN = new X500DistinguishedName(val.getEncoded());
- der.skip(val.getLength());
- if (Configuration.DEBUG)
- log.fine("read issuer == " + issuerDN);
-
- // thisUpdate Time,
- thisUpdate = (Date) der.read().getValue();
- if (Configuration.DEBUG)
- log.fine("read thisUpdate == " + thisUpdate);
-
- // nextUpdate Time OPTIONAL,
- val = der.read();
- if (val.getValue() instanceof Date)
- {
- nextUpdate = (Date) val.getValue();
- if (Configuration.DEBUG)
- log.fine("read nextUpdate == " + nextUpdate);
- val = der.read();
- }
-
- // revokedCertificates SEQUENCE OF SEQUENCE {
- // -- X509CRLEntry objects...
- // } OPTIONAL,
- if (val.getTag() != 0)
- {
- int len = 0;
- while (len < val.getLength())
- {
- X509CRLEntry entry = new X509CRLEntry(version, der);
- revokedCerts.put(entry.getSerialNumber(), entry);
- len += entry.getEncoded().length;
- }
- val = der.read();
- }
-
- // crlExtensions [0] EXPLICIT Extensions OPTIONAL
- // -- if present MUST be v2
- if (val.getTagClass() != DER.UNIVERSAL && val.getTag() == 0)
- {
- if (version < 2)
- throw new IOException("extra data in CRL");
- DERValue exts = der.read();
- if (!exts.isConstructed())
- throw new IOException("malformed Extensions");
- if (Configuration.DEBUG)
- log.fine("start Extensions len == " + exts.getLength());
- int len = 0;
- while (len < exts.getLength())
- {
- DERValue ext = der.read();
- if (!ext.isConstructed())
- throw new IOException("malformed Extension");
- Extension e = new Extension(ext.getEncoded());
- extensions.put(e.getOid(), e);
- der.skip(ext.getLength());
- len += ext.getEncodedLength();
- if (Configuration.DEBUG)
- log.fine("current count == " + len);
- }
- val = der.read();
- }
-
- if (Configuration.DEBUG)
- log.fine("read tag == " + val.getTag());
- if (!val.isConstructed())
- throw new IOException("malformed AlgorithmIdentifier");
- if (Configuration.DEBUG)
- log.fine("start AlgorithmIdentifier len == " + val.getLength());
- DERValue sigAlgVal = der.read();
- if (Configuration.DEBUG)
- log.fine("read tag == " + sigAlgVal.getTag());
- if (sigAlgVal.getTag() != DER.OBJECT_IDENTIFIER)
- throw new IOException("malformed AlgorithmIdentifier");
- sigAlg = (OID) sigAlgVal.getValue();
- if (Configuration.DEBUG)
- {
- log.fine("signature id == " + sigAlg);
- log.fine("sigAlgVal length == " + sigAlgVal.getEncodedLength());
- }
- if (val.getLength() > sigAlgVal.getEncodedLength())
- {
- val = der.read();
- if (Configuration.DEBUG)
- log.fine("sig params tag = " + val.getTag() + " len == "
- + val.getEncodedLength());
- sigAlgParams = (byte[]) val.getEncoded();
- if (val.isConstructed())
- in.skip(val.getLength());
- }
- val = der.read();
- if (Configuration.DEBUG)
- log.fine("read tag = " + val.getTag());
- rawSig = val.getEncoded();
- signature = ((BitString) val.getValue()).toByteArray();
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLEntry.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLEntry.java
deleted file mode 100644
index 26b40363..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLEntry.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/* X509CRLEntry.java -- an entry in a X.509 CRL.
- Copyright (C) 2003, 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.java.security.Configuration;
-import gnu.java.security.OID;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.x509.ext.Extension;
-
-import java.io.IOException;
-import java.math.BigInteger;
-import java.security.cert.CRLException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.logging.Logger;
-
-/**
- * A single entry in a X.509 certificate revocation list.
- *
- * @see X509CRL
- * @author Casey Marshall
- */
-class X509CRLEntry extends java.security.cert.X509CRLEntry
- implements GnuPKIExtension
-{
- private static final Logger log = Logger.getLogger(X509CRLEntry.class.getName());
- /** The DER encoded form of this CRL entry. */
- private byte[] encoded;
-
- /** The revoked certificate's serial number. */
- private BigInteger serialNo;
-
- /** The date the certificate was revoked. */
- private Date revocationDate;
-
- /** The CRL entry extensions. */
- private HashMap extensions;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new X.509 certificate revocation list entry from the given
- * input stream and CRL version number.
- *
- * @param version The CRL version.
- * @param encoded The stream of DER bytes.
- * @throws CRLException If the ASN.1 structure is invalid.
- * @throws IOException If the bytes cannot be read.
- */
- X509CRLEntry(int version, DERReader encoded)
- throws CRLException, IOException
- {
- super();
- extensions = new HashMap();
- try
- {
- parse(version, encoded);
- }
- catch (IOException ioe)
- {
- throw ioe;
- }
- catch (Exception x)
- {
- throw new CRLException(x.toString());
- }
- }
-
- // X509CRLEntry methods.
- // ------------------------------------------------------------------------
-
- public boolean equals(Object o)
- {
- if (!(o instanceof X509CRLEntry))
- return false;
- return ((X509CRLEntry) o).getSerialNumber().equals(serialNo) &&
- ((X509CRLEntry) o).getRevocationDate().equals(revocationDate);
- }
-
- public int hashCode()
- {
- return serialNo.hashCode();
- }
-
- public byte[] getEncoded() throws CRLException
- {
- return (byte[]) encoded.clone();
- }
-
- public BigInteger getSerialNumber()
- {
- return serialNo;
- }
-
- public Date getRevocationDate()
- {
- return (Date) revocationDate.clone();
- }
-
- public boolean hasExtensions()
- {
- return ! extensions.isEmpty();
- }
-
- public String toString()
- {
- return "X509CRLEntry serial=" + serialNo + " revocation date="
- + revocationDate + " ext=" + extensions;
- }
-
- // X509Extension methods.
- // -------------------------------------------------------------------------
-
- public boolean hasUnsupportedCriticalExtension()
- {
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (e.isCritical() && !e.isSupported())
- return true;
- }
- return false;
- }
-
- public Set getCriticalExtensionOIDs()
- {
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (e.isCritical())
- s.add(e.getOid().toString());
- }
- return Collections.unmodifiableSet(s);
- }
-
- public Set getNonCriticalExtensionOIDs()
- {
- HashSet s = new HashSet();
- for (Iterator it = extensions.values().iterator(); it.hasNext(); )
- {
- Extension e = (Extension) it.next();
- if (!e.isCritical())
- s.add(e.getOid().toString());
- }
- return Collections.unmodifiableSet(s);
- }
-
- public byte[] getExtensionValue(String oid)
- {
- Extension e = getExtension(new OID(oid));
- if (e != null)
- {
- return e.getValue().getEncoded();
- }
- return null;
- }
-
- // GnuPKIExtension method.
- // -------------------------------------------------------------------------
-
- public Extension getExtension(OID oid)
- {
- return (Extension) extensions.get(oid);
- }
-
- public Collection getExtensions()
- {
- return extensions.values();
- }
-
- // Own methods.
- // -------------------------------------------------------------------------
-
- private void parse(int version, DERReader der) throws Exception
- {
- // RevokedCertificate ::= SEQUENCE {
- DERValue entry = der.read();
- if (Configuration.DEBUG)
- log.fine("start CRL entry len == " + entry.getLength());
- if (!entry.isConstructed())
- throw new IOException("malformed revokedCertificate");
- encoded = entry.getEncoded();
- int len = 0;
- if (Configuration.DEBUG)
- log.fine("encoded entry:\n" + Util.hexDump(encoded, ">>>> "));
-
- // userCertificate CertificateSerialNumber,
- DERValue val = der.read();
- serialNo = (BigInteger) val.getValue();
- len += val.getEncodedLength();
- if (Configuration.DEBUG)
- log.fine("userCertificate == " + serialNo + " current count == " + len);
-
- // revocationDate Time,
- val = der.read();
- revocationDate = (Date) val.getValue();
- len += val.getEncodedLength();
- if (Configuration.DEBUG)
- log.fine("revocationDate == " + revocationDate + " current count == "
- + len);
- // crlEntryExtensions Extensions OPTIONAL
- // -- if present MUST be v2
- if (len < entry.getLength())
- {
- if (version < 2)
- throw new IOException("extra data in CRL entry");
- DERValue exts = der.read();
- if (!exts.isConstructed())
- throw new IOException("malformed Extensions");
- if (Configuration.DEBUG)
- log.fine("start Extensions len == " + exts.getLength());
- len = 0;
- while (len < exts.getLength())
- {
- val = der.read();
- if (!val.isConstructed())
- throw new IOException("malformed Extension");
- if (Configuration.DEBUG)
- log.fine("start Extension len == " + val.getLength());
- Extension e = new Extension(val.getEncoded());
- extensions.put(e.getOid(), e);
- der.skip(val.getLength());
- len += val.getEncodedLength();
- if (Configuration.DEBUG)
- log.fine("current count == " + len);
- }
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLSelectorImpl.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLSelectorImpl.java
deleted file mode 100644
index 0ada5501..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509CRLSelectorImpl.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/* X509CRLSelectorImpl.java -- implementation of an X509CRLSelector.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import java.io.IOException;
-
-import java.security.Principal;
-import java.security.cert.CRL;
-import java.security.cert.CRLSelector;
-import java.security.cert.X509CRL;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * Sun's implementation of X509CRLSelector sucks. This one tries to work
- * better.
- */
-public class X509CRLSelectorImpl implements CRLSelector
-{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private Set issuerNames;
-
- // Constructor.
- // -------------------------------------------------------------------------
-
- public X509CRLSelectorImpl()
- {
- issuerNames = new HashSet();
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public void addIssuerName(byte[] issuerName) throws IOException
- {
- issuerNames.add(new X500DistinguishedName(issuerName));
- }
-
- public void addIssuerName(String issuerName)
- {
- issuerNames.add(new X500DistinguishedName(issuerName));
- }
-
- public void addIssuerName(Principal issuerName) throws IOException
- {
- if (issuerName instanceof X500DistinguishedName)
- issuerNames.add(issuerName);
- else if (issuerName instanceof X500Principal)
- issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded()));
- else
- issuerNames.add(new X500DistinguishedName(issuerName.getName()));
- }
-
- public Collection getIssuerNames()
- {
- return Collections.unmodifiableSet(issuerNames);
- }
-
- public Object clone()
- {
- X509CRLSelectorImpl copy = new X509CRLSelectorImpl();
- copy.issuerNames.addAll(issuerNames);
- return copy;
- }
-
- public boolean match(CRL crl)
- {
- if (!(crl instanceof X509CRL))
- return false;
- try
- {
- Principal p = ((X509CRL) crl).getIssuerDN();
- X500DistinguishedName thisName = null;
- if (p instanceof X500DistinguishedName)
- thisName = (X500DistinguishedName) p;
- else if (p instanceof X500Principal)
- thisName = new X500DistinguishedName(((X500Principal) p).getEncoded());
- else
- thisName = new X500DistinguishedName(p.getName());
- for (Iterator it = issuerNames.iterator(); it.hasNext(); )
- {
- X500DistinguishedName name = (X500DistinguishedName) it.next();
- if (thisName.equals(name))
- return true;
- }
- }
- catch (Exception x)
- {
- }
- return false;
- }
-}
-
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509CertPath.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509CertPath.java
deleted file mode 100644
index e8ed6bf3..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509CertPath.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/* X509CertPath.java -- an X.509 certificate path.
- Copyright (C) 2004 Free Software Fonudation, 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.java.security.OID;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DEREncodingException;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.math.BigInteger;
-import java.security.cert.CertPath;
-import java.security.cert.Certificate;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-/**
- * A certificate path (or certificate chain) of X509Certificates.
- *
- * @author Casey Marshall (rsdio@metastatic.org)
- */
-public class X509CertPath extends CertPath
-{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- public static final List ENCODINGS = Collections.unmodifiableList(
- Arrays.asList(new String[] { "PkiPath", "PKCS7" }));
-
- private static final OID PKCS7_SIGNED_DATA = new OID("1.2.840.113549.1.7.2");
- private static final OID PKCS7_DATA = new OID("1.2.840.113549.1.7.1");
-
- /** The certificate path. */
- private List path;
-
- /** The cached PKCS #7 encoded bytes. */
- private byte[] pkcs_encoded;
-
- /** The cached PkiPath encoded bytes. */
- private byte[] pki_encoded;
-
- // Constructor.
- // -------------------------------------------------------------------------
-
- public X509CertPath(List path)
- {
- super("X.509");
- this.path = Collections.unmodifiableList(path);
- }
-
- public X509CertPath(InputStream in) throws CertificateEncodingException
- {
- this(in, (String) ENCODINGS.get(0));
- }
-
- public X509CertPath(InputStream in, String encoding)
- throws CertificateEncodingException
- {
- super("X.509");
- try
- {
- parse(in, encoding);
- }
- catch (IOException ioe)
- {
- throw new CertificateEncodingException();
- }
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public List getCertificates()
- {
- return path; // already unmodifiable
- }
-
- public byte[] getEncoded() throws CertificateEncodingException
- {
- return getEncoded((String) ENCODINGS.get(0));
- }
-
- public byte[] getEncoded(String encoding) throws CertificateEncodingException
- {
- if (encoding.equalsIgnoreCase("PkiPath"))
- {
- if (pki_encoded == null)
- {
- try
- {
- pki_encoded = encodePki();
- }
- catch (IOException ioe)
- {
- throw new CertificateEncodingException();
- }
- }
- return (byte[]) pki_encoded.clone();
- }
- else if (encoding.equalsIgnoreCase("PKCS7"))
- {
- if (pkcs_encoded == null)
- {
- try
- {
- pkcs_encoded = encodePKCS();
- }
- catch (IOException ioe)
- {
- throw new CertificateEncodingException();
- }
- }
- return (byte[]) pkcs_encoded.clone();
- }
- else
- throw new CertificateEncodingException("unknown encoding: " + encoding);
- }
-
- public Iterator getEncodings()
- {
- return ENCODINGS.iterator(); // already unmodifiable
- }
-
- // Own methods.
- // -------------------------------------------------------------------------
-
- private void parse(InputStream in, String encoding)
- throws CertificateEncodingException, IOException
- {
- DERReader der = new DERReader(in);
- DERValue path = null;
- if (encoding.equalsIgnoreCase("PkiPath"))
- {
- // PKI encoding is just a SEQUENCE of X.509 certificates.
- path = der.read();
- if (!path.isConstructed())
- throw new DEREncodingException("malformed PkiPath");
- }
- else if (encoding.equalsIgnoreCase("PKCS7"))
- {
- // PKCS #7 encoding means that the certificates are contained in a
- // SignedData PKCS #7 type.
- //
- // ContentInfo ::= SEQUENCE {
- // contentType ::= ContentType,
- // content [0] EXPLICIT ANY DEFINED BY contentType OPTIONAL }
- //
- // ContentType ::= OBJECT IDENTIFIER
- //
- // SignedData ::= SEQUENCE {
- // version Version,
- // digestAlgorithms DigestAlgorithmIdentifiers,
- // contentInfo ContentInfo,
- // certificates [0] IMPLICIT ExtendedCertificatesAndCertificates
- // OPTIONAL,
- // crls [1] IMPLICIT CertificateRevocationLists OPTIONAL,
- // signerInfos SignerInfos }
- //
- // Version ::= INTEGER
- //
- DERValue value = der.read();
- if (!value.isConstructed())
- throw new DEREncodingException("malformed ContentInfo");
- value = der.read();
- if (!(value.getValue() instanceof OID) ||
- ((OID) value.getValue()).equals(PKCS7_SIGNED_DATA))
- throw new DEREncodingException("not a SignedData");
- value = der.read();
- if (!value.isConstructed() || value.getTag() != 0)
- throw new DEREncodingException("malformed content");
- value = der.read();
- if (value.getTag() != DER.INTEGER)
- throw new DEREncodingException("malformed Version");
- value = der.read();
- if (!value.isConstructed() || value.getTag() != DER.SET)
- throw new DEREncodingException("malformed DigestAlgorithmIdentifiers");
- der.skip(value.getLength());
- value = der.read();
- if (!value.isConstructed())
- throw new DEREncodingException("malformed ContentInfo");
- der.skip(value.getLength());
- path = der.read();
- if (!path.isConstructed() || path.getTag() != 0)
- throw new DEREncodingException("no certificates");
- }
- else
- throw new CertificateEncodingException("unknown encoding: " + encoding);
-
- LinkedList certs = new LinkedList();
- int len = 0;
- while (len < path.getLength())
- {
- DERValue cert = der.read();
- try
- {
- certs.add(new X509Certificate(new ByteArrayInputStream(cert.getEncoded())));
- }
- catch (CertificateException ce)
- {
- throw new CertificateEncodingException(ce.getMessage());
- }
- len += cert.getEncodedLength();
- der.skip(cert.getLength());
- }
-
- this.path = Collections.unmodifiableList(certs);
- }
-
- private byte[] encodePki()
- throws CertificateEncodingException, IOException
- {
- synchronized (path)
- {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (Iterator i = path.iterator(); i.hasNext(); )
- {
- out.write(((Certificate) i.next()).getEncoded());
- }
- byte[] b = out.toByteArray();
- DERValue val = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- b.length, b, null);
- return val.getEncoded();
- }
- }
-
- private byte[] encodePKCS()
- throws CertificateEncodingException, IOException
- {
- synchronized (path)
- {
- ArrayList signedData = new ArrayList(5);
- signedData.add(new DERValue(DER.INTEGER, BigInteger.ONE));
- signedData.add(new DERValue(DER.CONSTRUCTED | DER.SET,
- Collections.EMPTY_SET));
- signedData.add(new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- Collections.singletonList(
- new DERValue(DER.OBJECT_IDENTIFIER, PKCS7_DATA))));
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- for (Iterator i = path.iterator(); i.hasNext(); )
- {
- out.write(((Certificate) i.next()).getEncoded());
- }
- byte[] b = out.toByteArray();
- signedData.add(new DERValue(DER.CONSTRUCTED | DER.CONTEXT,
- b.length, b, null));
- DERValue sdValue = new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- signedData);
-
- ArrayList contentInfo = new ArrayList(2);
- contentInfo.add(new DERValue(DER.OBJECT_IDENTIFIER, PKCS7_SIGNED_DATA));
- contentInfo.add(new DERValue(DER.CONSTRUCTED | DER.CONTEXT, sdValue));
- return new DERValue(DER.CONSTRUCTED | DER.SEQUENCE,
- contentInfo).getEncoded();
- }
- }
-}
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509CertSelectorImpl.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509CertSelectorImpl.java
deleted file mode 100644
index 36187ad8..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509CertSelectorImpl.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/* X509CertSelectorImpl.java -- implementation of an X509CertSelector.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import java.io.IOException;
-import java.security.Principal;
-import java.security.cert.CertSelector;
-import java.security.cert.Certificate;
-import java.security.cert.X509Certificate;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * Sun's implementation of X509CertSelector sucks. This one tries to work
- * better.
- */
-public class X509CertSelectorImpl implements CertSelector
-{
-
- // Fields.
- // -------------------------------------------------------------------------
-
- private Set issuerNames;
- private Set subjectNames;
-
- // Constructor.
- // -------------------------------------------------------------------------
-
- public X509CertSelectorImpl()
- {
- issuerNames = new HashSet();
- subjectNames = new HashSet();
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- public void addIssuerName(byte[] issuerName) throws IOException
- {
- issuerNames.add(new X500DistinguishedName(issuerName));
- }
-
- public void addIssuerName(String issuerName)
- {
- issuerNames.add(new X500DistinguishedName(issuerName));
- }
-
- public void addIssuerName(Principal issuerName) throws IOException
- {
- if (issuerName instanceof X500DistinguishedName)
- issuerNames.add(issuerName);
- else if (issuerName instanceof X500Principal)
- issuerNames.add(new X500DistinguishedName(((X500Principal) issuerName).getEncoded()));
- else
- issuerNames.add(new X500DistinguishedName(issuerName.getName()));
- }
-
- public Collection getIssuerNames()
- {
- return Collections.unmodifiableSet(issuerNames);
- }
-
- public void addSubjectName(byte[] subjectName) throws IOException
- {
- subjectNames.add(new X500DistinguishedName(subjectName));
- }
-
- public void addSubjectName(String subjectName) throws IOException
- {
- subjectNames.add(new X500DistinguishedName(subjectName));
- }
-
- public void addSubjectName(Principal subjectName) throws IOException
- {
- if (subjectName instanceof X500DistinguishedName)
- subjectNames.add(subjectName);
- else if (subjectName instanceof X500Principal)
- subjectNames.add(new X500DistinguishedName(((X500Principal) subjectName).getEncoded()));
- else
- subjectNames.add(new X500DistinguishedName(subjectName.getName()));
- }
-
- public Collection getSubjectNames()
- {
- return Collections.unmodifiableSet(subjectNames);
- }
-
- public Object clone()
- {
- X509CertSelectorImpl copy = new X509CertSelectorImpl();
- copy.issuerNames.addAll(issuerNames);
- copy.subjectNames.addAll(subjectNames);
- return copy;
- }
-
- public boolean match(Certificate cert)
- {
- if (!(cert instanceof X509Certificate))
- return false;
- boolean matchIssuer = false;
- boolean matchSubject = false;
- try
- {
- Principal p = ((X509Certificate) cert).getIssuerDN();
- X500DistinguishedName thisName = null;
- if (p instanceof X500DistinguishedName)
- thisName = (X500DistinguishedName) p;
- else if (p instanceof X500Principal)
- thisName = new X500DistinguishedName(((X500Principal) p).getEncoded());
- else
- thisName = new X500DistinguishedName(p.getName());
- if (issuerNames.isEmpty())
- matchIssuer = true;
- else
- {
- for (Iterator it = issuerNames.iterator(); it.hasNext(); )
- {
- X500DistinguishedName name = (X500DistinguishedName) it.next();
- if (thisName.equals(name))
- {
- matchIssuer = true;
- break;
- }
- }
- }
-
- p = ((X509Certificate) cert).getSubjectDN();
- thisName = null;
- if (p instanceof X500DistinguishedName)
- thisName = (X500DistinguishedName) p;
- else if (p instanceof X500Principal)
- thisName = new X500DistinguishedName(((X500Principal) p).getEncoded());
- else
- thisName = new X500DistinguishedName(p.getName());
- if (subjectNames.isEmpty())
- matchSubject = true;
- else
- {
- for (Iterator it = subjectNames.iterator(); it.hasNext(); )
- {
- X500DistinguishedName name = (X500DistinguishedName) it.next();
- if (thisName.equals(name))
- {
- matchSubject = true;
- break;
- }
- }
- }
- }
- catch (Exception x)
- {
- }
- return matchIssuer && matchSubject;
- }
-}
-
diff --git a/openjdk/icedtea/jce/gnu/java/security/x509/X509Certificate.java b/openjdk/icedtea/jce/gnu/java/security/x509/X509Certificate.java
deleted file mode 100644
index 14c56526..00000000
--- a/openjdk/icedtea/jce/gnu/java/security/x509/X509Certificate.java
+++ /dev/null
@@ -1,757 +0,0 @@
-/* X509Certificate.java -- X.509 certificate.
- Copyright (C) 2003, 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 gnu.java.security.x509;
-
-import gnu.classpath.debug.Component;
-import gnu.classpath.debug.SystemLogger;
-import gnu.java.security.OID;
-import gnu.java.security.der.BitString;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-import gnu.java.security.x509.ext.BasicConstraints;
-import gnu.java.security.x509.ext.ExtendedKeyUsage;
-import gnu.java.security.x509.ext.Extension;
-import gnu.java.security.x509.ext.GeneralName;
-import gnu.java.security.x509.ext.IssuerAlternativeNames;
-import gnu.java.security.x509.ext.KeyUsage;
-import gnu.java.security.x509.ext.SubjectAlternativeNames;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.PrintWriter;
-import java.io.Serializable;
-import java.io.StringWriter;
-import java.math.BigInteger;
-import java.security.AlgorithmParameters;
-import java.security.InvalidKeyException;
-import java.security.KeyFactory;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Principal;
-import java.security.PublicKey;
-import java.security.Signature;
-import java.security.SignatureException;
-import java.security.cert.CertificateEncodingException;
-import java.security.cert.CertificateException;
-import java.security.cert.CertificateExpiredException;
-import java.security.cert.CertificateNotYetValidException;
-import java.security.cert.CertificateParsingException;
-import java.security.interfaces.DSAParams;
-import java.security.interfaces.DSAPublicKey;
-import java.security.spec.DSAParameterSpec;
-import java.security.spec.X509EncodedKeySpec;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import javax.security.auth.x500.X500Principal;
-
-/**
- * An implementation of X.509 certificates.
- *
- * @author Casey Marshall (rsdio@metastatic.org)
- */
-public class X509Certificate extends java.security.cert.X509Certificate
- implements Serializable, GnuPKIExtension
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final long serialVersionUID = -2491127588187038216L;
- private static final Logger logger = SystemLogger.SYSTEM;
-
- protected static final OID ID_DSA = new OID ("1.2.840.10040.4.1");
- protected static final OID ID_DSA_WITH_SHA1 = new OID ("1.2.840.10040.4.3");
- protected static final OID ID_RSA = new OID ("1.2.840.113549.1.1.1");
- protected static final OID ID_RSA_WITH_MD2 = new OID ("1.2.840.113549.1.1.2");
- protected static final OID ID_RSA_WITH_MD5 = new OID ("1.2.840.113549.1.1.4");
- protected static final OID ID_RSA_WITH_SHA1 = new OID ("1.2.840.113549.1.1.5");
- protected static final OID ID_ECDSA_WITH_SHA1 = new OID ("1.2.840.10045.4.1");
-
- // This object SHOULD be serialized with an instance of
- // java.security.cert.Certificate.CertificateRep, thus all fields are
- // transient.
-
- // The encoded certificate.
- protected transient byte[] encoded;
-
- // TBSCertificate part.
- protected transient byte[] tbsCertBytes;
- protected transient int version;
- protected transient BigInteger serialNo;
- protected transient OID algId;
- protected transient byte[] algVal;
- protected transient X500DistinguishedName issuer;
- protected transient Date notBefore;
- protected transient Date notAfter;
- protected transient X500DistinguishedName subject;
- protected transient PublicKey subjectKey;
- protected transient BitString issuerUniqueId;
- protected transient BitString subjectUniqueId;
- protected transient Map extensions;
-
- // Signature.
- protected transient OID sigAlgId;
- protected transient byte[] sigAlgVal;
- protected transient byte[] signature;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new X.509 certificate from the encoded data. The input
- * data are expected to be the ASN.1 DER encoding of the certificate.
- *
- * @param encoded The encoded certificate data.
- * @throws IOException If the certificate cannot be read, possibly
- * from a formatting error.
- * @throws CertificateException If the data read is not an X.509
- * certificate.
- */
- public X509Certificate(InputStream encoded)
- throws CertificateException, IOException
- {
- super();
- extensions = new HashMap();
- try
- {
- parse(encoded);
- }
- catch (IOException ioe)
- {
- logger.log (Component.X509, "", ioe);
- throw ioe;
- }
- catch (Exception e)
- {
- logger.log (Component.X509, "", e);
- CertificateException ce = new CertificateException(e.getMessage());
- ce.initCause (e);
- throw ce;
- }
- }
-
- protected X509Certificate()
- {
- extensions = new HashMap();
- }
-
- // X509Certificate methods.
- // ------------------------------------------------------------------------
-
- public void checkValidity()
- throws CertificateExpiredException, CertificateNotYetValidException
- {
- checkValidity(new Date());
- }
-
- public void checkValidity(Date date)
- throws CertificateExpiredException, CertificateNotYetValidException
- {
- if (date.compareTo(notBefore) < 0)
- {
- throw new CertificateNotYetValidException();
- }
- if (date.compareTo(notAfter) > 0)
- {
- throw new CertificateExpiredException();
- }
- }
-
- public int getVersion()
- {
- return version;
- }
-
- public BigInteger getSerialNumber()
- {
- return serialNo;
- }
-
- public Principal getIssuerDN()
- {
- return issuer;
- }
-
- public X500Principal getIssuerX500Principal()
- {
- return new X500Principal(issuer.getDer());
- }
-
- public Principal getSubjectDN()
- {
- return subject;
- }
-
- public X500Principal getSubjectX500Principal()
- {
- return new X500Principal(subject.getDer());
- }
-
- public Date getNotBefore()
- {
- return (Date) notBefore.clone();
- }
-
- public Date getNotAfter()
- {
- return (Date) notAfter.clone();
- }
-
- public byte[] getTBSCertificate() throws CertificateEncodingException
- {
- return (byte[]) tbsCertBytes.clone();
- }
-
- public byte[] getSignature()
- {
- return (byte[]) signature.clone();
- }
-
- public String getSigAlgName()
- {
- if (sigAlgId.equals(ID_DSA_WITH_SHA1))
- {
- return "SHA1withDSA";
- }
- if (sigAlgId.equals(ID_RSA_WITH_MD2))
- {
- return "MD2withRSA";
- }
- if (sigAlgId.equals(ID_RSA_WITH_MD5))
- {
- return "MD5withRSA";
- }
- if (sigAlgId.equals(ID_RSA_WITH_SHA1))
- {
- return "SHA1withRSA";
- }
- return "unknown";
- }
-
- public String getSigAlgOID()
- {
- return sigAlgId.toString();
- }
-
- public byte[] getSigAlgParams()
- {
- return (byte[]) sigAlgVal.clone();
- }
-
- public boolean[] getIssuerUniqueID()
- {
- if (issuerUniqueId != null)
- {
- return issuerUniqueId.toBooleanArray();
- }
- return null;
- }
-
- public boolean[] getSubjectUniqueID()
- {
- if (subjectUniqueId != null)
- {
- return subjectUniqueId.toBooleanArray();
- }
- return null;
- }
-
- public boolean[] getKeyUsage()
- {
- Extension e = getExtension(KeyUsage.ID);
- if (e != null)
- {
- KeyUsage ku = (KeyUsage) e.getValue();
- boolean[] result = new boolean[9];
- boolean[] b = ku.getKeyUsage().toBooleanArray();
- System.arraycopy(b, 0, result, 0, b.length);
- return result;
- }
- return null;
- }
-
- public List getExtendedKeyUsage() throws CertificateParsingException
- {
- Extension e = getExtension(ExtendedKeyUsage.ID);
- if (e != null)
- {
- List a = ((ExtendedKeyUsage) e.getValue()).getPurposeIds();
- List b = new ArrayList(a.size());
- for (OID oid : a)
- b.add(oid.toString());
- return Collections.unmodifiableList(b);
- }
- return null;
- }
-
- public int getBasicConstraints()
- {
- Extension e = getExtension(BasicConstraints.ID);
- if (e != null)
- {
- return ((BasicConstraints) e.getValue()).getPathLengthConstraint();
- }
- return -1;
- }
-
- public Collection> getSubjectAlternativeNames()
- throws CertificateParsingException
- {
- Extension e = getExtension(SubjectAlternativeNames.ID);
- if (e != null)
- {
- List names
- = ((SubjectAlternativeNames) e.getValue()).getNames();
- List> list = new ArrayList>(names.size());
- for (GeneralName name : names)
- {
- List
- *
- * If at least one of the designated Configuration files was found, and
- * was parsed correctly, then no other location will be inspected.
- *
- * If the System property named java.security.auth.login.config
- * is not null or empty, its contents are then interpreted as a URL to a
- * JAAS Login Configuration file written in the default syntax.
- *
- * If this System property is defined, and the file it refers to was
- * parsed correctly, then no other location will be inspected.
- *
- * If a file named .java.login.config or java.login.config
- * (in that order) is found in the location referenced by the value of the
- * System property user.home, then that file is parsed as a JAAS Login
- * Configuration written in the default syntax.
- *
- * If none of the above resulted in a correctly parsed JAAS Login
- * Configuration file, then this implementation will install a Null
- * Configuration which basically does not recognize any Application.
- *
- */
-public final class GnuConfiguration extends Configuration
-{
- private static final Logger log = Logger.getLogger(GnuConfiguration.class.getName());
- /**
- * The internal map of login modules keyed by application name. Each entry in
- * this map is a {@link List} of {@link AppConfigurationEntry}s for that
- * application name.
- */
- private Map loginModulesMap;
- /** Our reference to our default syntax parser. */
- private ConfigFileParser cp;
-
- // Constructor(s)
- // --------------------------------------------------------------------------
-
- /** Trivial 0-arguments Constructor. */
- public GnuConfiguration()
- {
- super();
-
- loginModulesMap = new HashMap();
- cp = new ConfigFileParser();
- init();
- }
-
- // Class methods
- // --------------------------------------------------------------------------
-
- // Instance methods
- // --------------------------------------------------------------------------
-
- // Configuration abstract methods implementation ----------------------------
-
- /* (non-Javadoc)
- * @see javax.security.auth.login.Configuration#getAppConfigurationEntry(java.lang.String)
- */
- public AppConfigurationEntry[] getAppConfigurationEntry(String appName)
- {
- if (appName == null)
- return null;
-
- appName = appName.trim();
- if (appName.length() == 0)
- return null;
-
- List loginModules = (List) loginModulesMap.get(appName);
- if (loginModules == null || loginModules.size() == 0)
- return null;
-
- if (gnu.java.security.Configuration.DEBUG)
- log.fine(appName + " -> " + loginModules.size() + " entry(ies)");
- return (AppConfigurationEntry[]) loginModules.toArray(new AppConfigurationEntry[0]);
- }
-
- /**
- * Refreshes and reloads this Configuration
.
- *
- * This method causes this Configuration
object to refresh /
- * reload its contents following the locations and logic described above in
- * the class documentation section.
- *
- * @throws SecurityException if the caller does not have an
- * {@link AuthPermission} for the action named
- * refreshLoginConfiguration
.
- * @see AuthPermission
- */
- public void refresh()
- {
- SecurityManager sm = System.getSecurityManager();
- if (sm != null)
- sm.checkPermission(new AuthPermission("refreshLoginConfiguration"));
-
- loginModulesMap.clear();
- init();
- }
-
- // helper methods -----------------------------------------------------------
-
- /**
- * Attempts to find and parse JAAS Login Configuration file(s) written in
- * the default syntax. The locations searched are as descibed in the class
- * documentation.
- */
- private void init()
- {
- if (processSecurityProperties())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Using login configuration defined by Security property(ies)");
- }
- else if (processSystemProperty())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Using login configuration defined by System property");
- }
- else if (processUserHome())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Using login configuration defined in ${user.home}");
- }
- else
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("No login configuration file found");
- }
- }
-
- /**
- * Attempts to locate and parse one or more JAAS Login Configuration files
- * defined as the values of the Security properties
- * java.security.auth.login.config.url.N.
- *
- * @return true
if it succeeds, and false
- * otherwsie.
- */
- private boolean processSecurityProperties()
- {
- boolean result = false;
- int counter = 0;
- String s;
- while (true)
- try
- {
- counter++;
- s = Security.getProperty("java.security.auth.login.config.url."
- + counter);
- if (s == null)
- break;
-
- s = s.trim();
- if (s.length() != 0)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("java.security.auth.login.config.url." + counter
- + " = " + s);
- parseConfig(getInputStreamFromURL(s));
- result = true;
- }
- }
- catch (Throwable t)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Exception while handling Security property at #"
- + counter + ". Continue: " + t);
- }
- return result;
- }
-
- /**
- * Attempts to open a designated string as a well-formed {@link URL}. If a
- * {@link MalformedURLException} occurs, this method then tries to open that
- * string as a {@link File} (with the same name). If it succeeds, an
- * {@link InputStream} is constructed and returned.
- *
- * @param s
- * the designated name of either a {@link URL} or a {@link File}
- * assumed to contain a JAAS Login Configuration in the default
- * syntax.
- * @return an {@link InputStream} around the data source.
- * @throws IOException
- * if an exception occurs during the operation.
- */
- private InputStream getInputStreamFromURL(String s) throws IOException
- {
- InputStream result = null;
- try
- {
- URL url = new URL(s);
- result = url.openStream();
- }
- catch (MalformedURLException x)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Failed opening as URL: " + s + ". Will try as File");
- result = new FileInputStream(s);
- }
- return result;
- }
-
- /**
- * Attempts to locate and parse a JAAS Login Configuration file defined as the
- * value of the System property java.security.auth.login.config.
- *
- * @return true
if it succeeds, and false
- * otherwsie.
- */
- private boolean processSystemProperty()
- {
- boolean result = false;
- try
- {
- String s = System.getProperty("java.security.auth.login.config");
- if (s != null)
- {
- s = s.trim();
- if (s.length() != 0)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("java.security.auth.login.config = " + s);
- parseConfig(getInputStreamFromURL(s));
- result = true;
- }
- }
- }
- catch (Throwable t)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Exception while handling System property. Continue: " + t);
- }
- return result;
- }
-
- /**
- * Attempts to locate and parse a JAAS Login Configuration file named either
- * as .java.login.config or java.login.config (without the
- * leading dot) in the folder referenced by the System property
- * user.home
.
- *
- * @return true
if it succeeds, and false
- * otherwsie.
- */
- private boolean processUserHome()
- {
- boolean result = false;
- try
- {
- File userHome = getUserHome();
- if (userHome == null)
- return result;
-
- File jaasFile;
- jaasFile = getConfigFromUserHome(userHome, ".java.login.config");
- if (jaasFile == null)
- jaasFile = getConfigFromUserHome(userHome, "java.login.config");
-
- if (jaasFile == null)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Login Configuration file, in " + userHome
- + ", does not exist or is inaccessible");
- return result;
- }
-
- FileInputStream fis = new FileInputStream(jaasFile);
- parseConfig(fis);
- result = true;
- }
- catch (Throwable t)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("Exception (ignored) while handling ${user.home}: " + t);
- }
- return result;
- }
-
- private void parseConfig(InputStream configStream) throws IOException
- {
- cp.parse(new InputStreamReader(configStream, "UTF-8"));
- Map loginModulesMap = cp.getLoginModulesMap();
- mergeLoginModules(loginModulesMap);
- }
-
- private void mergeLoginModules(Map otherLoginModules)
- {
- if (otherLoginModules == null || otherLoginModules.size() < 1)
- return;
-
- for (Iterator it = otherLoginModules.keySet().iterator(); it.hasNext();)
- {
- String appName = (String) it.next();
- List thatListOfACEs = (List) otherLoginModules.get(appName);
- if (thatListOfACEs == null || thatListOfACEs.size() < 1)
- continue;
-
- List thisListsOfACEs = (List) loginModulesMap.get(appName);
- if (thisListsOfACEs == null)
- loginModulesMap.put(appName, thatListOfACEs);
- else
- thisListsOfACEs.addAll(thatListOfACEs);
- }
- }
-
- private File getUserHome()
- {
- String uh = System.getProperty("user.home");
- if (uh == null || uh.trim().length() == 0)
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("User home path is not set or is empty");
- return null;
- }
- uh = uh.trim();
- File result = new File(uh);
- if (! result.exists())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("User home '" + uh + "' does not exist");
- return null;
- }
- if (! result.isDirectory())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("User home '" + uh + "' is not a directory");
- return null;
- }
- if (! result.canRead())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("User home '" + uh + "' is not readable");
- return null;
- }
- return result;
- }
-
- private File getConfigFromUserHome(File userHome, String fileName)
- {
- File result = new File(userHome, fileName);
- if (! result.exists())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("File '" + fileName + "' does not exist in user's home");
- return null;
- }
- if (! result.isFile())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("File '" + fileName + "' in user's home is not a file");
- return null;
- }
- if (! result.canRead())
- {
- if (gnu.java.security.Configuration.DEBUG)
- log.fine("File '" + fileName + "' in user's home is not readable");
- return null;
- }
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/BadPaddingException.java b/openjdk/icedtea/jce/javax/crypto/BadPaddingException.java
deleted file mode 100644
index a1d6dd59..00000000
--- a/openjdk/icedtea/jce/javax/crypto/BadPaddingException.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/* BadPaddingException -- Signals bad padding bytes on decryption.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.GeneralSecurityException;
-
-/**
- * This exception is thrown during decryption when the decrypted input
- * does not have the proper padding bytes that are expected by the padding
- * mechanism.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class BadPaddingException extends GeneralSecurityException
-{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /** Serialization constant. */
- private static final long serialVersionUID = -5315033893984728443L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Creates a new bad padding exception with no detail message.
- */
- public BadPaddingException()
- {
- super();
- }
-
- /**
- * Creates a new bad padding exception with a detail message.
- *
- * @param message The detail message.
- */
- public BadPaddingException(String message)
- {
- super(message);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/Cipher.java b/openjdk/icedtea/jce/javax/crypto/Cipher.java
deleted file mode 100644
index b21bc921..00000000
--- a/openjdk/icedtea/jce/javax/crypto/Cipher.java
+++ /dev/null
@@ -1,1154 +0,0 @@
-/* Cipher.java -- Interface to a cryptographic cipher.
- Copyright (C) 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.nio.ByteBuffer;
-import java.nio.ReadOnlyBufferException;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.cert.Certificate;
-import java.security.cert.X509Certificate;
-import java.security.spec.AlgorithmParameterSpec;
-import java.util.StringTokenizer;
-
-/**
- * This class implements a cryptographic cipher for transforming
- * data.
- *
- * Ciphers cannot be instantiated directly; rather one of the
- * getInstance
must be used to instantiate a given
- * transformation, optionally with a specific provider.
- *
- * A transformation is of the form:
- *
- *
- * - algorithm/mode/padding, or
- * - algorithm
- *
- *
- * where algorithm is the base name of a cryptographic cipher
- * (such as "AES"), mode is the abbreviated name of a block
- * cipher mode (such as "CBC" for cipher block chaining mode), and
- * padding is the name of a padding scheme (such as
- * "PKCS5Padding"). If only the algorithm name is supplied, then the
- * provider-specific default mode and padding will be used.
- *
- * An example transformation is:
- *
- * Cipher c =
- * Cipher.getInstance("AES/CBC/PKCS5Padding");
- *
- * Finally, when requesting a block cipher in stream cipher mode
- * (such as AES
- * in OFB or CFB mode) the number of bits to be processed
- * at a time may be specified by appending it to the name of the mode;
- * e.g. "AES/OFB8/NoPadding"
. If no such number is
- * specified a provider-specific default value is used.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @see java.security.KeyGenerator
- * @see javax.crypto.SecretKey
- */
-public class Cipher
-{
-
- // Constants and variables.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "Cipher";
-
- /**
- * The decryption operation mode.
- */
- public static final int DECRYPT_MODE = 2;
-
- /**
- * The encryption operation mode.
- */
- public static final int ENCRYPT_MODE = 1;
-
- /**
- * Constant for when the key to be unwrapped is a private key.
- */
- public static final int PRIVATE_KEY = 2;
-
- /**
- * Constant for when the key to be unwrapped is a public key.
- */
- public static final int PUBLIC_KEY = 1;
-
- /**
- * Constant for when the key to be unwrapped is a secret key.
- */
- public static final int SECRET_KEY = 3;
-
- /**
- * The key unwrapping operation mode.
- */
- public static final int UNWRAP_MODE = 4;
-
- /**
- * The key wrapping operation mode.
- */
- public static final int WRAP_MODE = 3;
-
- /**
- * The uninitialized state. This state signals that any of the
- * init
methods have not been called, and therefore no
- * transformations can be done.
- */
- private static final int INITIAL_STATE = 0;
-
- /** The underlying cipher service provider interface. */
- private CipherSpi cipherSpi;
-
- /** The provider from which this instance came. */
- private Provider provider;
-
- /** The transformation requested. */
- private String transformation;
-
- /** Our current state (encrypting, wrapping, etc.) */
- private int state;
-
- /**
- * Creates a new cipher instance for the given transformation.
- *
- * The installed providers are tried in order for an implementation, and the
- * first appropriate instance is returned. If no installed provider can
- * provide the implementation, an appropriate exception is thrown.
- *
- * @param transformation The transformation to create.
- * @return An appropriate cipher for this transformation.
- * @throws NoSuchAlgorithmException If no installed provider can supply the
- * appropriate cipher or mode.
- * @throws NoSuchPaddingException If no installed provider can supply the
- * appropriate padding.
- */
- public static final Cipher getInstance(String transformation)
- throws NoSuchAlgorithmException, NoSuchPaddingException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- NoSuchPaddingException lastPaddingException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(transformation, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- lastPaddingException = null;
- }
- catch (NoSuchPaddingException x)
- {
- lastPaddingException = x;
- }
- if (lastPaddingException != null)
- throw lastPaddingException;
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(transformation);
- }
-
- /**
- * Creates a new cipher instance for the given transformation and the named
- * provider.
- *
- * @param transformation The transformation to create.
- * @param provider The name of the provider to use.
- * @return An appropriate cipher for this transformation.
- * @throws NoSuchAlgorithmException If the provider cannot supply the
- * appropriate cipher or mode.
- * @throws NoSuchProviderException If the named provider is not installed.
- * @throws NoSuchPaddingException If the provider cannot supply the
- * appropriate padding.
- * @throws IllegalArgumentException if either transformation
or
- * provider
is null
.
- */
- public static final Cipher getInstance(String transformation, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException,
- NoSuchPaddingException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(transformation, p);
- }
-
- /**
- * Creates a new cipher instance for a given transformation from a given
- * provider.
- *
- * @param transformation The transformation to create.
- * @param provider The provider to use.
- * @return An appropriate cipher for this transformation.
- * @throws NoSuchAlgorithmException If the given provider cannot supply the
- * appropriate cipher or mode.
- * @throws NoSuchPaddingException If the given provider cannot supply the
- * appropriate padding scheme.
- */
- public static final Cipher getInstance(String transformation,
- Provider provider)
- throws NoSuchAlgorithmException, NoSuchPaddingException
- {
- StringBuilder sb = new StringBuilder().append("Cipher transformation [")
- .append(transformation).append("] from provider [")
- .append(provider).append("] ");
- Throwable cause;
- Object spi;
- CipherSpi result;
- if (transformation.indexOf('/') < 0)
- {
- try
- {
- spi = Engine.getInstance(SERVICE, transformation, provider);
- return new Cipher((CipherSpi) spi, provider, transformation);
- }
- catch (Exception e)
- {
- if (e instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) e;
- cause = e;
- }
- }
- else
- {
- StringTokenizer tok = new StringTokenizer(transformation, "/");
- if (tok.countTokens() != 3)
- throw new NoSuchAlgorithmException(sb.append("is malformed").toString());
-
- String alg = tok.nextToken();
- String mode = tok.nextToken();
- String pad = tok.nextToken();
- try
- {
- spi = Engine.getInstance(SERVICE, transformation, provider);
- return new Cipher((CipherSpi) spi, provider, transformation);
- }
- catch (Exception e)
- {
- cause = e;
- }
-
- try
- {
- spi = Engine.getInstance(SERVICE, alg + '/' + mode, provider);
- result = (CipherSpi) spi;
- result.engineSetPadding(pad);
- return new Cipher(result, provider, transformation);
- }
- catch (Exception e)
- {
- if (e instanceof NoSuchPaddingException)
- throw (NoSuchPaddingException) e;
- cause = e;
- }
-
- try
- {
- spi = Engine.getInstance(SERVICE, alg + "//" + pad, provider);
- result = (CipherSpi) spi;
- result.engineSetMode(mode);
- return new Cipher(result, provider, transformation);
- }
- catch (Exception e)
- {
- cause = e;
- }
-
- try
- {
- spi = Engine.getInstance(SERVICE, alg, provider);
- result = (CipherSpi) spi;
- result.engineSetMode(mode);
- result.engineSetPadding(pad);
- return new Cipher(result, provider, transformation);
- }
- catch (Exception e)
- {
- if (e instanceof NoSuchPaddingException)
- throw (NoSuchPaddingException) e;
- cause = e;
- }
- }
- sb.append("could not be created");
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Create a cipher.
- *
- * @param cipherSpi The underlying implementation of the cipher.
- * @param provider The provider of this cipher implementation.
- * @param transformation The transformation this cipher performs.
- */
- protected
- Cipher(CipherSpi cipherSpi, Provider provider, String transformation)
- {
- this.cipherSpi = cipherSpi;
- this.provider = provider;
- this.transformation = transformation;
- state = INITIAL_STATE;
- }
-
- /**
- * Get the name that this cipher instance was created with; this is
- * equivalent to the "transformation" argument given to any of the
- * {@link #getInstance()} methods.
- *
- * @return The cipher name.
- */
- public final String getAlgorithm()
- {
- return transformation;
- }
-
- /**
- * Return the size of blocks, in bytes, that this cipher processes.
- *
- * @return The block size.
- */
- public final int getBlockSize()
- {
- if (cipherSpi != null)
- {
- return cipherSpi.engineGetBlockSize();
- }
- return 1;
- }
-
- /**
- * Return the currently-operating {@link ExemptionMechanism}.
- *
- * @return null, currently.
- */
- public final ExemptionMechanism getExemptionMechanism()
- {
- return null;
- }
-
- /**
- * Return the initialization vector that this instance was
- * initialized with.
- *
- * @return The IV.
- */
- public final byte[] getIV()
- {
- if (cipherSpi != null)
- {
- return cipherSpi.engineGetIV();
- }
- return null;
- }
-
- /**
- * Return the {@link java.security.AlgorithmParameters} that this
- * instance was initialized with.
- *
- * @return The parameters.
- */
- public final AlgorithmParameters getParameters()
- {
- if (cipherSpi != null) {
- return cipherSpi.engineGetParameters();
- }
- return null;
- }
-
- /**
- * Return this cipher's provider.
- *
- * @return The provider.
- */
- public final Provider getProvider()
- {
- return provider;
- }
-
- /**
- * Finishes a multi-part transformation, and returns the final
- * transformed bytes.
- *
- * @return The final transformed bytes.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input is not a multiple of this cipher's
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is
- * decrypting and the padding bytes do not match this
- * instance's padding scheme.
- */
- public final byte[] doFinal()
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
- {
- return doFinal(new byte[0], 0, 0);
- }
-
- /**
- * Finishes a multi-part transformation or does an entire
- * transformation on the input, and returns the transformed bytes.
- *
- * @param input The final input bytes.
- * @return The final transformed bytes.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input is not a multiple of this cipher's
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is
- * decrypting and the padding bytes do not match this
- * instance's padding scheme.
- */
- public final byte[] doFinal(byte[] input)
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
- {
- return doFinal(input, 0, input.length);
- }
-
- /**
- * Finishes a multi-part transformation or does an entire
- * transformation on the input, and returns the transformed bytes.
- *
- * @param input The final input bytes.
- * @param inputOffset The index in the input bytes to start.
- * @param inputLength The number of bytes to read from the input.
- * @return The final transformed bytes.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input is not a multiple of this cipher's
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is
- * decrypting and the padding bytes do not match this
- * instance's padding scheme.
- */
- public final byte[] doFinal(byte[] input, int inputOffset, int inputLength)
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException
- {
- if (cipherSpi == null)
- {
- byte[] b = new byte[inputLength];
- System.arraycopy(input, inputOffset, b, 0, inputLength);
- return b;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException("neither encrypting nor decrypting");
- }
- return cipherSpi.engineDoFinal(input, inputOffset, inputLength);
- }
-
- /**
- * Finishes a multi-part transformation and stores the transformed
- * bytes into the given array.
- *
- * @param output The destination for the transformed bytes.
- * @param outputOffset The offset in output to start storing
- * bytes.
- * @return The number of bytes placed into the output array.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input is not a multiple of this cipher's
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is
- * decrypting and the padding bytes do not match this
- * instance's padding scheme.
- * @throws javax.crypto.ShortBufferException If the output array is
- * not large enough to hold the transformed bytes.
- */
- public final int doFinal(byte[] output, int outputOffset)
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
- ShortBufferException
- {
- if (cipherSpi == null)
- {
- return 0;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException("neither encrypting nor decrypting");
- }
- return cipherSpi.engineDoFinal(new byte[0], 0, 0, output, outputOffset);
- }
-
- /**
- * Finishes a multi-part transformation or transforms a portion of a
- * byte array, and stores the result in the given byte array.
- *
- * @param input The input bytes.
- * @param inputOffset The index in input to start.
- * @param inputLength The number of bytes to transform.
- * @param output The output buffer.
- * @param outputOffset The index in output to start.
- * @return The number of bytes placed into the output array.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input is not a multiple of this cipher's
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is
- * decrypting and the padding bytes do not match this
- * instance's padding scheme.
- * @throws javax.crypto.ShortBufferException If the output array is
- * not large enough to hold the transformed bytes.
- */
- public final int doFinal(byte[] input, int inputOffset, int inputLength,
- byte[] output, int outputOffset)
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
- ShortBufferException
- {
- if (cipherSpi == null)
- {
- if (inputLength > output.length - outputOffset)
- {
- throw new ShortBufferException();
- }
- System.arraycopy(input, inputOffset, output, outputOffset, inputLength);
- return inputLength;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException("neither encrypting nor decrypting");
- }
- return cipherSpi.engineDoFinal(input, inputOffset, inputLength,
- output, outputOffset);
- }
-
- public final int doFinal(byte[] input, int inputOffset, int inputLength,
- byte[] output)
- throws IllegalStateException, IllegalBlockSizeException, BadPaddingException,
- ShortBufferException
- {
- return doFinal(input, inputOffset, inputLength, output, 0);
- }
-
- /**
- * Finishes a multi-part transformation with, or completely
- * transforms, a byte buffer, and stores the result into the output
- * buffer.
- *
- * @param input The input buffer.
- * @param output The output buffer.
- * @return The number of bytes stored into the output buffer.
- * @throws IllegalArgumentException If the input and output buffers
- * are the same object.
- * @throws IllegalStateException If this cipher was not initialized
- * for encryption or decryption.
- * @throws ReadOnlyBufferException If the output buffer is not
- * writable.
- * @throws IllegalBlockSizeException If this cipher requires a total
- * input that is a multiple of its block size to complete this
- * transformation.
- * @throws ShortBufferException If the output buffer is not large
- * enough to hold the transformed bytes.
- * @throws BadPaddingException If the cipher is a block cipher with
- * a padding scheme, and the decrypted bytes do not end with a
- * valid padding.
- * @since 1.5
- */
- public final int doFinal (ByteBuffer input, ByteBuffer output)
- throws ReadOnlyBufferException, ShortBufferException,
- BadPaddingException, IllegalBlockSizeException
- {
- if (input == output)
- throw new IllegalArgumentException
- ("input and output buffers cannot be the same");
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- throw new IllegalStateException
- ("not initialized for encrypting or decrypting");
- return cipherSpi.engineDoFinal (input, output);
- }
-
- /**
- * Returns the size an output buffer needs to be if this cipher is
- * updated with a number of bytes.
- *
- * @param inputLength The input length.
- * @return The output length given this input length.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized, or if a doFinal call has already
- * been made.
- */
- public final int getOutputSize(int inputLength) throws IllegalStateException
- {
- if (cipherSpi == null)
- return inputLength;
- return cipherSpi.engineGetOutputSize(inputLength);
- }
-
- /**
- *
Initialize this cipher with the public key from the given
- * certificate.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * As per the Java 1.4 specification, if cert
is an
- * instance of an {@link java.security.cert.X509Certificate} and its
- * key usage extension field is incompatible with
- * opmode
then an {@link
- * java.security.InvalidKeyException} is thrown.
- *
- * If this cipher requires any random bytes (for example for an
- * initilization vector) than the {@link java.security.SecureRandom}
- * with the highest priority is used as the source of these bytes.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param certificate The certificate.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the certificate's public key, or if the
- * public key cannot be used as described above.
- */
- public final void init(int opmode, Certificate certificate)
- throws InvalidKeyException
- {
- init(opmode, certificate, new SecureRandom());
- }
-
- /**
- * Initialize this cipher with the supplied key.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * If this cipher requires any random bytes (for example for an
- * initilization vector) than the {@link java.security.SecureRandom}
- * with the highest priority is used as the source of these bytes.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- */
- public final void init(int opmode, Key key) throws InvalidKeyException
- {
- if (cipherSpi != null)
- {
- cipherSpi.engineInit(opmode, key, new SecureRandom());
- }
- state = opmode;
- }
-
- /**
- * Initialize this cipher with the public key from the given
- * certificate and the specified source of randomness.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * As per the Java 1.4 specification, if cert
is an
- * instance of an {@link java.security.cert.X509Certificate} and its
- * key usage extension field is incompatible with
- * opmode
then an {@link
- * java.security.InvalidKeyException} is thrown.
- *
- * If this cipher requires any random bytes (for example for an
- * initilization vector) than the {@link java.security.SecureRandom}
- * with the highest priority is used as the source of these bytes.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param certificate The certificate.
- * @param random The source of randomness.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the certificate's public key, or if the
- * public key cannot be used as described above.
- */
- public final void
- init(int opmode, Certificate certificate, SecureRandom random)
- throws InvalidKeyException
- {
- if (certificate instanceof X509Certificate)
- {
- boolean[] keyInfo = ((X509Certificate) certificate).getKeyUsage();
- if (keyInfo != null)
- {
- switch (opmode)
- {
- case DECRYPT_MODE:
- if (!keyInfo[3])
- {
- throw new InvalidKeyException(
- "the certificate's key cannot be used for transforming data");
- }
- if (keyInfo[7])
- {
- throw new InvalidKeyException(
- "the certificate's key can only be used for encryption");
- }
- break;
-
- case ENCRYPT_MODE:
- if (!keyInfo[3])
- {
- throw new InvalidKeyException(
- "the certificate's key cannot be used for transforming data");
- }
- if (keyInfo[8])
- {
- throw new InvalidKeyException(
- "the certificate's key can only be used for decryption");
- }
- break;
-
- case UNWRAP_MODE:
- if (!keyInfo[2] || keyInfo[7])
- {
- throw new InvalidKeyException(
- "the certificate's key cannot be used for key unwrapping");
- }
- break;
-
- case WRAP_MODE:
- if (!keyInfo[2] || keyInfo[8])
- {
- throw new InvalidKeyException(
- "the certificate's key cannot be used for key wrapping");
- }
- break;
- }
- }
- }
- init(opmode, certificate.getPublicKey(), random);
- }
-
- /**
- * Initialize this cipher with the supplied key and source of
- * randomness.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @param random The source of randomness to use.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- */
- public final void init(int opmode, Key key, SecureRandom random)
- throws InvalidKeyException
- {
- if (cipherSpi != null)
- {
- cipherSpi.engineInit(opmode, key, random);
- }
- state = opmode;
- }
-
- /**
- * Initialize this cipher with the supplied key and parameters.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * If this cipher requires any random bytes (for example for an
- * initilization vector) then the {@link java.security.SecureRandom}
- * with the highest priority is used as the source of these bytes.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @param params The algorithm parameters to initialize this instance
- * with.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inappropriate for this cipher.
- */
- public final void init(int opmode, Key key, AlgorithmParameters params)
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- init(opmode, key, params, new SecureRandom());
- }
-
- /**
- * Initialize this cipher with the supplied key and parameters.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * If this cipher requires any random bytes (for example for an
- * initilization vector) then the {@link java.security.SecureRandom}
- * with the highest priority is used as the source of these bytes.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @param params The algorithm parameters to initialize this instance
- * with.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inappropriate for this cipher.
- */
- public final void init(int opmode, Key key, AlgorithmParameterSpec params)
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- init(opmode, key, params, new SecureRandom());
- }
-
- /**
- * Initialize this cipher with the supplied key, parameters, and
- * source of randomness.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @param params The algorithm parameters to initialize this instance
- * with.
- * @param random The source of randomness to use.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inappropriate for this cipher.
- */
- public final void init(int opmode, Key key, AlgorithmParameters params,
- SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- if (cipherSpi != null)
- {
- cipherSpi.engineInit(opmode, key, params, random);
- }
- state = opmode;
- }
-
- /**
- * Initialize this cipher with the supplied key, parameters, and
- * source of randomness.
- *
- * The cipher will be initialized for encryption, decryption, key
- * wrapping, or key unwrapping, depending upon whether the
- * opmode
argument is {@link #ENCRYPT_MODE}, {@link
- * #DECRYPT_MODE}, {@link #WRAP_MODE}, or {@link #UNWRAP_MODE},
- * respectively.
- *
- * A call to any of the init
methods overrides the
- * state of the instance, and is equivalent to creating a new instance
- * and calling its init
method.
- *
- * @param opmode The operation mode to use.
- * @param key The key.
- * @param params The algorithm parameters to initialize this instance
- * with.
- * @param random The source of randomness to use.
- * @throws java.security.InvalidKeyException If the underlying cipher
- * instance rejects the given key.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inappropriate for this cipher.
- */
- public final void init(int opmode, Key key, AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidKeyException, InvalidAlgorithmParameterException
- {
- if (cipherSpi != null)
- {
- cipherSpi.engineInit(opmode, key, params, random);
- }
- state = opmode;
- }
-
- /**
- * Unwrap a previously-wrapped key.
- *
- * @param wrappedKey The wrapped key.
- * @param wrappedKeyAlgorithm The algorithm with which the key was
- * wrapped.
- * @param wrappedKeyType The type of key (public, private, or
- * secret) that this wrapped key respresents.
- * @return The unwrapped key.
- * @throws java.lang.IllegalStateException If this instance has not be
- * initialized for unwrapping.
- * @throws java.security.InvalidKeyException If wrappedKey
- * is not a wrapped key, if the algorithm cannot unwrap this
- * key, or if the unwrapped key's type differs from the
- * specified type.
- * @throws java.security.NoSuchAlgorithmException If
- * wrappedKeyAlgorithm
is not a valid algorithm
- * name.
- */
- public final Key unwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
- int wrappedKeyType)
- throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException
- {
- if (cipherSpi == null)
- {
- return null;
- }
- if (state != UNWRAP_MODE)
- {
- throw new IllegalStateException("instance is not for unwrapping");
- }
- return cipherSpi.engineUnwrap(wrappedKey, wrappedKeyAlgorithm,
- wrappedKeyType);
- }
-
- /**
- * Continue a multi-part transformation on an entire byte array,
- * returning the transformed bytes.
- *
- * @param input The input bytes.
- * @return The transformed bytes.
- * @throws java.lang.IllegalStateException If this cipher was not
- * initialized for encryption or decryption.
- */
- public final byte[] update(byte[] input) throws IllegalStateException
- {
- return update(input, 0, input.length);
- }
-
- /**
- * Continue a multi-part transformation on part of a byte array,
- * returning the transformed bytes.
- *
- * @param input The input bytes.
- * @param inputOffset The index in the input to start.
- * @param inputLength The number of bytes to transform.
- * @return The transformed bytes.
- * @throws java.lang.IllegalStateException If this cipher was not
- * initialized for encryption or decryption.
- */
- public final byte[] update(byte[] input, int inputOffset, int inputLength)
- throws IllegalStateException
- {
- if (cipherSpi == null)
- {
- byte[] b = new byte[inputLength];
- System.arraycopy(input, inputOffset, b, 0, inputLength);
- return b;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException(
- "cipher is not for encrypting or decrypting");
- }
- return cipherSpi.engineUpdate(input, inputOffset, inputLength);
- }
-
- /**
- * Continue a multi-part transformation on part of a byte array,
- * placing the transformed bytes into the given array.
- *
- * @param input The input bytes.
- * @param inputOffset The index in the input to start.
- * @param inputLength The number of bytes to transform.
- * @param output The output byte array.
- * @return The number of transformed bytes.
- * @throws java.lang.IllegalStateException If this cipher was not
- * initialized for encryption or decryption.
- * @throws javax.security.ShortBufferException If there is not enough
- * room in the output array to hold the transformed bytes.
- */
- public final int update(byte[] input, int inputOffset, int inputLength,
- byte[] output)
- throws IllegalStateException, ShortBufferException
- {
- return update(input, inputOffset, inputLength, output, 0);
- }
-
- /**
- * Continue a multi-part transformation on part of a byte array,
- * placing the transformed bytes into the given array.
- *
- * @param input The input bytes.
- * @param inputOffset The index in the input to start.
- * @param inputLength The number of bytes to transform.
- * @param output The output byte array.
- * @param outputOffset The index in the output array to start.
- * @return The number of transformed bytes.
- * @throws java.lang.IllegalStateException If this cipher was not
- * initialized for encryption or decryption.
- * @throws javax.security.ShortBufferException If there is not enough
- * room in the output array to hold the transformed bytes.
- */
- public final int update(byte[] input, int inputOffset, int inputLength,
- byte[] output, int outputOffset)
- throws IllegalStateException, ShortBufferException
- {
- if (cipherSpi == null)
- {
- if (inputLength > output.length - outputOffset)
- {
- throw new ShortBufferException();
- }
- System.arraycopy(input, inputOffset, output, outputOffset, inputLength);
- return inputLength;
- }
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- {
- throw new IllegalStateException(
- "cipher is not for encrypting or decrypting");
- }
- return cipherSpi.engineUpdate(input, inputOffset, inputLength,
- output, outputOffset);
- }
-
- /**
- * Continue a multi-part transformation on a byte buffer, storing
- * the transformed bytes into another buffer.
- *
- * @param input The input buffer.
- * @param output The output buffer.
- * @return The number of bytes stored in output.
- * @throws IllegalArgumentException If the two buffers are the same
- * object.
- * @throws IllegalStateException If this cipher was not initialized
- * for encrypting or decrypting.
- * @throws ReadOnlyBufferException If the output buffer is not
- * writable.
- * @throws ShortBufferException If the output buffer does not have
- * enough available space for the transformed bytes.
- * @since 1.5
- */
- public final int update (ByteBuffer input, ByteBuffer output)
- throws ReadOnlyBufferException, ShortBufferException
- {
- if (input == output)
- throw new IllegalArgumentException
- ("input and output buffers must be different");
- if (state != ENCRYPT_MODE && state != DECRYPT_MODE)
- throw new IllegalStateException
- ("not initialized for encryption or decryption");
- return cipherSpi.engineUpdate (input, output);
- }
-
- /**
- * Wrap a key.
- *
- * @param key The key to wrap.
- * @return The wrapped key.
- * @throws java.lang.IllegalStateException If this instance was not
- * initialized for key wrapping.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the key is not a multiple of the block size.
- * @throws java.security.InvalidKeyException If this instance cannot
- * wrap this key.
- */
- public final byte[] wrap(Key key)
- throws IllegalStateException, IllegalBlockSizeException, InvalidKeyException
- {
- if (cipherSpi == null)
- {
- return null;
- }
- if (state != WRAP_MODE)
- {
- throw new IllegalStateException("instance is not for key wrapping");
- }
- return cipherSpi.engineWrap(key);
- }
-
- public static final int getMaxAllowedKeyLength(String transformation)
- throws NoSuchAlgorithmException
- {
- return 0;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/CipherInputStream.java b/openjdk/icedtea/jce/javax/crypto/CipherInputStream.java
deleted file mode 100644
index aa6ebc9d..00000000
--- a/openjdk/icedtea/jce/javax/crypto/CipherInputStream.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/* CipherInputStream.java -- Filters input through a cipher.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Configuration;
-import gnu.classpath.debug.Component;
-import gnu.classpath.debug.SystemLogger;
-
-import java.io.FilterInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-
-import java.util.logging.Logger;
-
-/**
- * This is an {@link java.io.InputStream} that filters its data
- * through a {@link Cipher} before returning it. The Cipher
- * argument must have been initialized before it is passed to the
- * constructor.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class CipherInputStream extends FilterInputStream
-{
-
- // Constants and variables.
- // ------------------------------------------------------------------------
-
- private static final Logger logger = SystemLogger.SYSTEM;
-
- /**
- * The underlying {@link Cipher} instance.
- */
- private final Cipher cipher;
-
- /**
- * Data that has been transformed but not read.
- */
- private byte[] outBuffer;
-
- /**
- * The offset into {@link #outBuffer} where valid data starts.
- */
- private int outOffset;
-
- /**
- * We set this when the cipher block size is 1, meaning that we can
- * transform any amount of data.
- */
- private final boolean isStream;
-
- /**
- * Whether or not we've reached the end of the stream.
- */
- private boolean eof;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Creates a new input stream with a source input stream and cipher.
- *
- * @param in The underlying input stream.
- * @param cipher The cipher to filter data through.
- */
- public CipherInputStream(InputStream in, Cipher cipher)
- {
- super (in);
- this.cipher = cipher;
- isStream = cipher.getBlockSize () == 1;
- eof = false;
- if (Configuration.DEBUG)
- logger.log (Component.CRYPTO, "I am born; cipher: {0}, stream? {1}",
- new Object[] { cipher.getAlgorithm (),
- Boolean.valueOf (isStream) });
- }
-
- /**
- * Creates a new input stream without a cipher. This constructor is
- * protected
because this class does not work without an
- * underlying cipher.
- *
- * @param in The underlying input stream.
- */
- protected CipherInputStream(InputStream in)
- {
- this (in, new NullCipher ());
- }
-
- // Instance methods overriding java.io.FilterInputStream.
- // ------------------------------------------------------------------------
-
- /**
- * Returns the number of bytes available without blocking. The value
- * returned is the number of bytes that have been processed by the
- * cipher, and which are currently buffered by this class.
- *
- * @return The number of bytes immediately available.
- * @throws java.io.IOException If an I/O exception occurs.
- */
- public int available() throws IOException
- {
- if (isStream)
- return super.available();
- if (outBuffer == null || outOffset >= outBuffer.length)
- nextBlock ();
- return outBuffer.length - outOffset;
- }
-
- /**
- * Close this input stream. This method merely calls the {@link
- * java.io.InputStream#close()} method of the underlying input stream.
- *
- * @throws java.io.IOException If an I/O exception occurs.
- */
- public synchronized void close() throws IOException
- {
- super.close();
- }
-
- /**
- * Read a single byte from this input stream; returns -1 on the
- * end-of-file.
- *
- * @return The byte read, or -1 if there are no more bytes.
- * @throws java.io.IOExcpetion If an I/O exception occurs.
- */
- public synchronized int read() throws IOException
- {
- if (isStream)
- {
- byte[] buf = new byte[1];
- int in = super.read();
- if (in == -1)
- return -1;
- buf[0] = (byte) in;
- try
- {
- cipher.update(buf, 0, 1, buf, 0);
- }
- catch (ShortBufferException shouldNotHappen)
- {
- throw new IOException(shouldNotHappen.getMessage());
- }
- return buf[0] & 0xFF;
- }
-
- if (outBuffer == null || outOffset == outBuffer.length)
- {
- if (eof)
- return -1;
- nextBlock ();
- }
- return outBuffer [outOffset++] & 0xFF;
- }
-
- /**
- * Read bytes into an array, returning the number of bytes read or -1
- * on the end-of-file.
- *
- * @param buf The byte array to read into.
- * @param off The offset in buf
to start.
- * @param len The maximum number of bytes to read.
- * @return The number of bytes read, or -1 on the end-of-file.
- * @throws java.io.IOException If an I/O exception occurs.
- */
- public synchronized int read(byte[] buf, int off, int len)
- throws IOException
- {
- // CipherInputStream has this wierd implementation where if
- // the buffer is null, this call is the same as `skip'.
- if (buf == null)
- return (int) skip (len);
-
- if (isStream)
- {
- len = super.read(buf, off, len);
- if (len > 0)
- {
- try
- {
- cipher.update(buf, off, len, buf, off);
- }
- catch (ShortBufferException shouldNotHappen)
- {
- IOException ioe = new IOException ("Short buffer for stream cipher -- this should not happen");
- ioe.initCause (shouldNotHappen);
- throw ioe;
- }
- }
- return len;
- }
-
- int count = 0;
- while (count < len)
- {
- if (outBuffer == null || outOffset >= outBuffer.length)
- {
- if (eof)
- {
- if (count == 0)
- count = -1;
- break;
- }
- nextBlock();
- }
- int l = Math.min (outBuffer.length - outOffset, len - count);
- System.arraycopy (outBuffer, outOffset, buf, count+off, l);
- count += l;
- outOffset += l;
- }
- return count;
- }
-
- /**
- * Read bytes into an array, returning the number of bytes read or -1
- * on the end-of-file.
- *
- * @param buf The byte arry to read into.
- * @return The number of bytes read, or -1 on the end-of-file.
- * @throws java.io.IOException If an I/O exception occurs.
- */
- public int read(byte[] buf) throws IOException
- {
- return read(buf, 0, buf.length);
- }
-
- /**
- * Skip a number of bytes. This class only supports skipping as many
- * bytes as are returned by {@link #available()}, which is the number
- * of transformed bytes currently in this class's internal buffer.
- *
- * @param bytes The number of bytes to skip.
- * @return The number of bytes skipped.
- */
- public long skip(long bytes) throws IOException
- {
- if (isStream)
- {
- return super.skip(bytes);
- }
- long ret = 0;
- if (bytes > 0 && outBuffer != null && outOffset >= outBuffer.length)
- {
- ret = outBuffer.length - outOffset;
- outOffset = outBuffer.length;
- }
- return ret;
- }
-
- /**
- * Returns whether or not this input stream supports the {@link
- * #mark(long)} and {@link #reset()} methods; this input stream does
- * not, however, and invariably returns false
.
- *
- * @return false
- */
- public boolean markSupported()
- {
- return false;
- }
-
- /**
- * Set the mark. This method is unsupported and is empty.
- *
- * @param mark Is ignored.
- */
- public void mark(int mark)
- {
- }
-
- /**
- * Reset to the mark. This method is unsupported and is empty.
- */
- public void reset() throws IOException
- {
- throw new IOException("reset not supported");
- }
-
- // Own methods.
- // -------------------------------------------------------------------------
-
- // FIXME: I don't fully understand how this class is supposed to work.
-
- private void nextBlock() throws IOException
- {
- byte[] buf = new byte[cipher.getBlockSize ()];
- if (Configuration.DEBUG)
- logger.log (Component.CRYPTO, "getting a new data block");
-
- try
- {
- outBuffer = null;
- outOffset = 0;
- while (outBuffer == null)
- {
- int l = in.read (buf);
- if (Configuration.DEBUG)
- logger.log (Component.CRYPTO, "we read {0} bytes",
- Integer.valueOf (l));
- if (l == -1)
- {
- outBuffer = cipher.doFinal ();
- eof = true;
- return;
- }
-
- outOffset = 0;
- outBuffer = cipher.update (buf, 0, l);
- }
- }
- catch (BadPaddingException bpe)
- {
- IOException ioe = new IOException ("bad padding");
- ioe.initCause (bpe);
- throw ioe;
- }
- catch (IllegalBlockSizeException ibse)
- {
- IOException ioe = new IOException ("illegal block size");
- ioe.initCause (ibse);
- throw ioe;
- }
- finally
- {
- if (Configuration.DEBUG)
- logger.log (Component.CRYPTO,
- "decrypted {0} bytes for reading",
- Integer.valueOf (outBuffer.length));
- }
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/CipherOutputStream.java b/openjdk/icedtea/jce/javax/crypto/CipherOutputStream.java
deleted file mode 100644
index 960f6fb6..00000000
--- a/openjdk/icedtea/jce/javax/crypto/CipherOutputStream.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/* CipherOutputStream.java -- Filters output through a cipher.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.io.FilterOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * A filtered output stream that transforms data written to it with a
- * {@link Cipher} before sending it to the underlying output stream.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class CipherOutputStream extends FilterOutputStream
-{
- /** The underlying cipher. */
- private Cipher cipher;
-
- /**
- * Create a new cipher output stream. The cipher argument must have already
- * been initialized.
- *
- * @param out The sink for transformed data.
- * @param cipher The cipher to transform data with.
- */
- public CipherOutputStream(OutputStream out, Cipher cipher)
- {
- super(out);
- this.cipher = (cipher != null) ? cipher : new NullCipher();
- }
-
- /**
- * Create a cipher output stream with no cipher.
- *
- * @param out The sink for transformed data.
- */
- protected CipherOutputStream(OutputStream out)
- {
- super(out);
- }
-
- /**
- * Close this output stream, and the sink output stream.
- *
- * This method will first invoke the {@link Cipher#doFinal()} method of the
- * underlying {@link Cipher}, and writes the output of that method to the
- * sink output stream.
- *
- * @throws IOException If an I/O error occurs, or if an error is caused by
- * finalizing the transformation.
- */
- public void close() throws IOException
- {
- try
- {
- out.write(cipher.doFinal());
- out.flush();
- out.close();
- }
- catch (Exception cause)
- {
- IOException ioex = new IOException(String.valueOf(cause));
- ioex.initCause(cause);
- throw ioex;
- }
- }
-
- /**
- * Flush any pending output.
- *
- * @throws IOException If an I/O error occurs.
- */
- public void flush() throws IOException
- {
- out.flush();
- }
-
- /**
- * Write a single byte to the output stream.
- *
- * @param b The next byte.
- * @throws IOException If an I/O error occurs, or if the underlying cipher is
- * not in the correct state to transform data.
- */
- public void write(int b) throws IOException
- {
- write(new byte[] { (byte) b }, 0, 1);
- }
-
- /**
- * Write a byte array to the output stream.
- *
- * @param buf The next bytes.
- * @throws IOException If an I/O error occurs, or if the underlying cipher is
- * not in the correct state to transform data.
- */
- public void write(byte[] buf) throws IOException
- {
- write(buf, 0, buf.length);
- }
-
- /**
- * Write a portion of a byte array to the output stream.
- *
- * @param buf The next bytes.
- * @param off The offset in the byte array to start.
- * @param len The number of bytes to write.
- * @throws IOException If an I/O error occurs, or if the underlying cipher is
- * not in the correct state to transform data.
- */
- public void write(byte[] buf, int off, int len) throws IOException
- {
- byte[] b = cipher.update(buf, off, len);
- if (b != null)
- out.write(b);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/CipherSpi.java b/openjdk/icedtea/jce/javax/crypto/CipherSpi.java
deleted file mode 100644
index 194c1dab..00000000
--- a/openjdk/icedtea/jce/javax/crypto/CipherSpi.java
+++ /dev/null
@@ -1,445 +0,0 @@
-/* CipherSpi.java -- The cipher service provider interface.
- Copyright (C) 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.nio.ByteBuffer;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- *
This class represents the Service Provider Interface
- * (SPI) for cryptographic ciphers.
- *
- * Providers of cryptographic ciphers must subclass this for every
- * cipher they implement, implementing the abstract methods as
- * appropriate, then provide an entry that points to the subclass in
- * their implementation of {@link java.security.Provider}.
- *
- * CipherSpi objects are instantiated along with {@link Cipher}s when
- * the {@link Cipher#getInstance(java.lang.String)} methods are invoked.
- * Particular ciphers are referenced by a transformation, which
- * is a String consisting of the cipher's name or the ciper's name
- * followed by a mode and a padding. Transformations all follow the
- * general form:
- *
- *
- * - algorithm, or
- * - algorithm/mode/padding
- *
- *
- * Cipher names in the master {@link java.security.Provider} class
- * may be:
- *
- *
- * - The algorithm's name, which uses a pluggable mode and padding:
- *
Cipher.algorithm
- * - The algorithm's name and the mode, which uses pluggable padding:
- *
Cipher.algorithm/mode
- * - The algorithm's name and the padding, which uses a pluggable
- * mode:
Cipher.algorithm//padding
- * - The algorihtm's name, the mode, and the padding:
- *
Cipher.algorithm/mode/padding
- *
- *
- * When any {@link Cipher#getInstance(java.lang.String)} method is
- * invoked, the following happens if the transformation is simply
- * algorithm:
- *
- *
- * - If the provider defines a
CipherSpi
implementation
- * for "algorithm", return it. Otherwise throw a {@link
- * java.security.NoSuchAlgorithmException}.
- *
- *
- * If the transformation is of the form
- * algorithm/mode/padding:
- *
- *
- * - If the provider defines a
CipherSpi
subclass for
- * "algorithm/mode/padding", return it. Otherwise
- * go to step 2.
- *
- * - If the provider defines a
CipherSpi
subclass for
- * "algorithm/mode", instatiate it, call {@link
- * #engineSetPadding(java.lang.String)} for the padding name, and return
- * it. Otherwise go to step 3.
- *
- * - If the provider defines a
CipherSpi
subclass for
- * "algorithm//padding", instatiate it, call {@link
- * #engineSetMode(java.lang.String)} for the mode name, and return
- * it. Otherwise go to step 4.
- *
- * - If the provider defines a
CipherSpi
subclass for
- * "algorithm", instatiate it, call {@link
- * #engineSetMode(java.lang.String)} for the mode name, call {@link
- * #engineSetPadding(java.lang.String)} for the padding name, and return
- * it. Otherwise throw a {@link java.security.NoSuchAlgorithmException}.
- *
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public abstract class CipherSpi
-{
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new CipherSpi.
- */
- public CipherSpi()
- {
- }
-
- // Abstract methods to be implemented by providers.
- // ------------------------------------------------------------------------
-
- /**
- * Finishes a multi-part transformation or transforms a portion of a
- * byte array, and returns the transformed bytes.
- *
- * @param input The input bytes.
- * @param inputOffset The index in the input at which to start.
- * @param inputLength The number of bytes to transform.
- * @return The transformed bytes in a new array.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input size is not a multiple of the
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is being
- * used for decryption and the padding is not appropriate for
- * this instance's padding scheme.
- */
- protected abstract byte[]
- engineDoFinal(byte[] input, int inputOffset, int inputLength)
- throws IllegalBlockSizeException, BadPaddingException;
-
- /**
- * Finishes a multi-part transformation or transforms a portion of a
- * byte array, and stores the transformed bytes in the supplied array.
- *
- * @param input The input bytes.
- * @param inputOffset The index in the input at which to start.
- * @param inputLength The number of bytes to transform.
- * @param output The output byte array.
- * @param outputOffset The index in the output array at which to start.
- * @return The number of transformed bytes stored in the output array.
- * @throws javax.crypto.IllegalBlockSizeException If this instance has
- * no padding and the input size is not a multiple of the
- * block size.
- * @throws javax.crypto.BadPaddingException If this instance is being
- * used for decryption and the padding is not appropriate for
- * this instance's padding scheme.
- * @throws javax.crypto.ShortBufferException If there is not enough
- * space in the output array for the transformed bytes.
- */
- protected abstract int
- engineDoFinal(byte[] input, int inputOffset, int inputLength,
- byte[] output, int outputOffset)
- throws IllegalBlockSizeException, BadPaddingException, ShortBufferException;
-
- /**
- * @since 1.5
- */
- protected int engineDoFinal (ByteBuffer input, ByteBuffer output)
- throws BadPaddingException, IllegalBlockSizeException,
- ShortBufferException
- {
- int total = 0;
- byte[] inbuf = new byte[256];
- while (input.hasRemaining ())
- {
- int in = Math.min (inbuf.length, input.remaining ());
- input.get (inbuf, 0, in);
- byte[] outbuf = new byte[engineGetOutputSize (in)];
- int out = 0;
- if (input.hasRemaining ()) // i.e., we have more 'update' calls
- out = engineUpdate (inbuf, 0, in, outbuf, 0);
- else
- out = engineDoFinal (inbuf, 0, in, outbuf, 0);
- output.put (outbuf, 0, out);
- total += out;
- }
- return total;
- }
-
- /**
- * Returns the block size of the underlying cipher.
- *
- * @return The block size.
- */
- protected abstract int engineGetBlockSize();
-
- /**
- * Returns the initializaiton vector this cipher was initialized with,
- * if any.
- *
- * @return The IV, or null if this cipher uses no IV or if this
- * instance has not been initialized yet.
- */
- protected abstract byte[] engineGetIV();
-
- /**
- * Return the length of the given key in bits.
- *
- * For compatibility this method is not declared
- * abstract
, and the default implementation will throw an
- * {@link java.lang.UnsupportedOperationException}. Concrete
- * subclasses should override this method to return the correct
- * value.
- *
- * @param key The key to get the size for.
- * @return The size of the key, in bits.
- * @throws java.security.InvalidKeyException If the key's length
- * cannot be determined by this implementation.
- */
- protected int engineGetKeySize(Key key) throws InvalidKeyException
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Returns the size, in bytes, an output buffer must be for a call
- * to {@link #engineUpdate(byte[],int,int,byte[],int)} or {@link
- * #engineDoFinal(byte[],int,int,byte[],int)} to succeed.
- *
- * The actual output length may be smaller than the value returned
- * by this method, as it considers the padding length as well. The
- * length considered is the argument plus the length of any buffered,
- * unprocessed bytes.
- *
- * @param inputLength The input length, in bytes.
- * @return The size an output buffer must be.
- */
- protected abstract int engineGetOutputSize(int inputLength);
-
- /**
- * Returns the parameters that this cipher is using. This may be the
- * parameters used to initialize this cipher, or it may be parameters
- * that have been initialized with random values.
- *
- * @return This cipher's parameters, or null
if this
- * cipher does not use parameters.
- */
- protected abstract AlgorithmParameters engineGetParameters();
-
- /**
- * Initializes this cipher with an operation mode, key, and source of
- * randomness. If this cipher requires any other initializing data,
- * for example an initialization vector, then it should generate it
- * from the provided source of randomness.
- *
- * @param opmode The operation mode, one of {@link
- * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
- * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
- * @param key The key to initialize this cipher with.
- * @param random The source of random bytes to use.
- * @throws java.security.InvalidKeyException If the given key is not
- * acceptable for this implementation.
- */
- protected abstract void engineInit(int opmode, Key key, SecureRandom random)
- throws InvalidKeyException;
-
- /**
- * Initializes this cipher with an operation mode, key, parameters,
- * and source of randomness. If this cipher requires any other
- * initializing data, for example an initialization vector, then it should
- * generate it from the provided source of randomness.
- *
- * @param opmode The operation mode, one of {@link
- * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
- * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
- * @param key The key to initialize this cipher with.
- * @param params The algorithm parameters to initialize with.
- * @param random The source of random bytes to use.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * given parameters are not appropriate for this
- * implementation.
- * @throws java.security.InvalidKeyException If the given key is not
- * acceptable for this implementation.
- */
- protected abstract void
- engineInit(int opmode, Key key, AlgorithmParameters params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException, InvalidKeyException;
-
- /**
- * Initializes this cipher with an operation mode, key, parameters,
- * and source of randomness. If this cipher requires any other
- * initializing data, for example an initialization vector, then it should
- * generate it from the provided source of randomness.
- *
- * @param opmode The operation mode, one of {@link
- * Cipher#DECRYPT_MODE}, {@link Cipher#ENCRYPT_MODE}, {@link
- * Cipher#UNWRAP_MODE}, or {@link Cipher#WRAP_MODE}.
- * @param key The key to initialize this cipher with.
- * @param params The algorithm parameters to initialize with.
- * @param random The source of random bytes to use.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * given parameters are not appropriate for this
- * implementation.
- * @throws java.security.InvalidKeyException If the given key is not
- * acceptable for this implementation.
- */
- protected abstract void
- engineInit(int opmode, Key key, AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException, InvalidKeyException;
-
- /**
- * Set the mode in which this cipher is to run.
- *
- * @param mode The name of the mode to use.
- * @throws java.security.NoSuchAlgorithmException If the mode is
- * not supported by this cipher's provider.
- */
- protected abstract void engineSetMode(String mode)
- throws NoSuchAlgorithmException;
-
- /**
- * Set the method with which the input is to be padded.
- *
- * @param padding The name of the padding to use.
- * @throws javax.crypto.NoSuchPaddingException If the padding is not
- * supported by this cipher's provider.
- */
- protected abstract void engineSetPadding(String padding)
- throws NoSuchPaddingException;
-
- /**
- * Unwraps a previously-wrapped key.
- *
- * For compatibility this method is not declared
- * abstract
, and the default implementation will throw an
- * {@link java.lang.UnsupportedOperationException}.
- *
- * @param wrappedKey The wrapped key.
- * @param wrappedKeyAlgorithm The name of the algorithm used to wrap
- * this key.
- * @param wrappedKeyType The type of wrapped key; one of
- * {@link Cipher#PRIVATE_KEY},
- * {@link Cipher#PUBLIC_KEY}, or
- * {@link Cipher#SECRET_KEY}.
- * @return The unwrapped key.
- * @throws java.security.InvalidKeyException If the key cannot be
- * unwrapped, or if wrappedKeyType
is an
- * inappropriate type for the unwrapped key.
- * @throws java.security.NoSuchAlgorithmException If the
- * wrappedKeyAlgorithm
is unknown.
- */
- protected Key engineUnwrap(byte[] wrappedKey, String wrappedKeyAlgorithm,
- int wrappedKeyType)
- throws InvalidKeyException, NoSuchAlgorithmException
- {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Continue with a multi-part transformation, returning a new array of
- * the transformed bytes.
- *
- * @param input The next input bytes.
- * @param inputOffset The index in the input array from which to start.
- * @param inputLength The number of bytes to input.
- * @return The transformed bytes.
- */
- protected abstract byte[]
- engineUpdate(byte[] input, int inputOffset, int inputLength);
-
- /**
- * Continue with a multi-part transformation, storing the transformed
- * bytes into the specified array.
- *
- * @param input The next input bytes.
- * @param inputOffset The index in the input from which to start.
- * @param inputLength The number of bytes to input.
- * @param output The output buffer.
- * @param outputOffset The index in the output array from which to start.
- * @return The transformed bytes.
- * @throws javax.crypto.ShortBufferException If there is not enough
- * space in the output array to store the transformed bytes.
- */
- protected abstract int
- engineUpdate(byte[] input, int inputOffset, int inputLength,
- byte[] output, int outputOffset)
- throws ShortBufferException;
-
- /**
- * @since 1.5
- */
- protected int engineUpdate (ByteBuffer input, ByteBuffer output)
- throws ShortBufferException
- {
- int total = 0;
- byte[] inbuf = new byte[256];
- while (input.hasRemaining ())
- {
- int in = Math.min (inbuf.length, input.remaining ());
- input.get (inbuf, 0, in);
- byte[] outbuf = new byte[engineGetOutputSize (in)];
- int out = engineUpdate (inbuf, 0, in, outbuf, 0);
- output.put (outbuf, 0, out);
- total += out;
- }
- return total;
- }
-
- /**
- * Wrap a key.
- *
- * For compatibility this method is not declared
- * abstract
, and the default implementation will throw an
- * {@link java.lang.UnsupportedOperationException}.
- *
- * @param key The key to wrap.
- * @return The wrapped key.
- * @throws java.security.InvalidKeyException If the key cannot be
- * wrapped.
- */
- protected byte[] engineWrap(Key key) throws InvalidKeyException, IllegalBlockSizeException
- {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/EncryptedPrivateKeyInfo.java b/openjdk/icedtea/jce/javax/crypto/EncryptedPrivateKeyInfo.java
deleted file mode 100644
index 0fddd54b..00000000
--- a/openjdk/icedtea/jce/javax/crypto/EncryptedPrivateKeyInfo.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/* EncryptedPrivateKeyInfo.java -- As in PKCS #8.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.OID;
-import gnu.java.security.der.DER;
-import gnu.java.security.der.DERReader;
-import gnu.java.security.der.DERValue;
-
-import java.io.IOException;
-import java.security.AlgorithmParameters;
-import java.security.NoSuchAlgorithmException;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.PKCS8EncodedKeySpec;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * An implementation of the EncryptedPrivateKeyInfo
ASN.1
- * type as specified in PKCS #8 -
- * Private-Key Information Syntax Standard.
- *
- * The ASN.1 type EncryptedPrivateKeyInfo
is:
- *
- *
- * EncryptedPrivateKeyInfo ::= SEQUENCE {
- * encryptionAlgorithm EncryptionAlgorithmIdentifier,
- * encryptedData EncryptedData }
- *
- * EncryptionAlgorithmIdentifier ::= AlgorithmIdentifier
- *
- * EncrytpedData ::= OCTET STRING
- *
- * AlgorithmIdentifier ::= SEQUENCE {
- * algorithm OBJECT IDENTIFIER,
- * parameters ANY DEFINED BY algorithm OPTIONAL }
- *
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see java.security.spec.PKCS8EncodedKeySpec
- */
-public class EncryptedPrivateKeyInfo
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The encrypted data. */
- private byte[] encryptedData;
-
- /** The encoded, encrypted key. */
- private byte[] encoded;
-
- /** The OID of the encryption algorithm. */
- private OID algOid;
-
- /** The encryption algorithm name. */
- private String algName;
-
- /** The encryption algorithm's parameters. */
- private AlgorithmParameters params;
-
- /** The encoded ASN.1 algorithm parameters. */
- private byte[] encodedParams;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new EncryptedPrivateKeyInfo
object from raw
- * encrypted data and the parameters used for encryption.
- *
- * The encryptedData
array is cloned.
- *
- * @param params The encryption algorithm parameters.
- * @param encryptedData The encrypted key data.
- * @throws java.lang.IllegalArgumentException If the
- * encryptedData
array is empty (zero-length).
- * @throws java.security.NoSuchAlgorithmException If the algorithm
- * specified in the parameters is not supported.
- * @throws java.lang.NullPointerException If encryptedData
- * is null.
- */
- public EncryptedPrivateKeyInfo(AlgorithmParameters params,
- byte[] encryptedData)
- throws IllegalArgumentException, NoSuchAlgorithmException
- {
- if (encryptedData.length == 0)
- {
- throw new IllegalArgumentException("0-length encryptedData");
- }
- this.params = params;
- algName = params.getAlgorithm ();
- algOid = getOid (algName);
- this.encryptedData = (byte[]) encryptedData.clone();
- }
-
- /**
- * Create a new EncryptedPrivateKeyInfo
from an encoded
- * representation, parsing the ASN.1 sequence.
- *
- * @param encoded The encoded info.
- * @throws java.io.IOException If parsing the encoded data fails.
- * @throws java.lang.NullPointerException If encoded
is
- * null.
- */
- public EncryptedPrivateKeyInfo(byte[] encoded)
- throws IOException
- {
- this.encoded = (byte[]) encoded.clone();
- decode();
- }
-
- /**
- * Create a new EncryptedPrivateKeyInfo
from the cipher
- * name and the encrytpedData.
- *
- *
The encryptedData
array is cloned.
- *
- * @param algName The name of the algorithm (as an object identifier).
- * @param encryptedData The encrypted key data.
- * @throws java.lang.IllegalArgumentException If the
- * encryptedData
array is empty (zero-length).
- * @throws java.security.NoSuchAlgorithmException If algName is not
- * the name of a supported algorithm.
- * @throws java.lang.NullPointerException If encryptedData
- * is null.
- */
- public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData)
- throws IllegalArgumentException, NoSuchAlgorithmException,
- NullPointerException
- {
- if (encryptedData.length == 0)
- {
- throw new IllegalArgumentException("0-length encryptedData");
- }
- this.algName = algName.toString (); // do NP check
- this.algOid = getOid (algName);
- this.encryptedData = (byte[]) encryptedData.clone();
- }
-
- /**
- * Return the OID for the given cipher name.
- *
- * @param str The string.
- * @throws NoSuchAlgorithmException If the OID is not known.
- */
- private static OID getOid (final String str)
- throws NoSuchAlgorithmException
- {
- if (str.equalsIgnoreCase ("DSA"))
- {
- return new OID ("1.2.840.10040.4.3");
- }
- // FIXME add more
-
- try
- {
- return new OID (str);
- }
- catch (Throwable t)
- {
- }
- throw new NoSuchAlgorithmException ("cannot determine OID for '" + str + "'");
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return the name of the cipher used to encrypt this key.
- *
- * @return The algorithm name.
- */
- public String getAlgName()
- {
- return algOid.toString();
- }
-
- public AlgorithmParameters getAlgParameters()
- {
- if (params == null && encodedParams != null)
- {
- try
- {
- params = AlgorithmParameters.getInstance(getAlgName());
- params.init(encodedParams);
- }
- catch (NoSuchAlgorithmException ignore)
- {
- // FIXME throw exception?
- }
- catch (IOException ignore)
- {
- }
- }
- return params;
- }
-
- public synchronized byte[] getEncoded() throws IOException
- {
- if (encoded == null) encode();
- return (byte[]) encoded.clone();
- }
-
- public byte[] getEncryptedData()
- {
- return encryptedData;
- }
-
- public PKCS8EncodedKeySpec getKeySpec(Cipher cipher)
- throws InvalidKeySpecException
- {
- try
- {
- return new PKCS8EncodedKeySpec(cipher.doFinal(encryptedData));
- }
- catch (Exception x)
- {
- throw new InvalidKeySpecException(x.toString());
- }
- }
-
- // Own methods.
- // -------------------------------------------------------------------------
-
- private void decode() throws IOException
- {
- DERReader der = new DERReader(encoded);
- DERValue val = der.read();
- if (val.getTag() != DER.SEQUENCE)
- throw new IOException("malformed EncryptedPrivateKeyInfo");
- val = der.read();
- if (val.getTag() != DER.SEQUENCE)
- throw new IOException("malformed AlgorithmIdentifier");
- int algpLen = val.getLength();
- DERValue oid = der.read();
- if (oid.getTag() != DER.OBJECT_IDENTIFIER)
- throw new IOException("malformed AlgorithmIdentifier");
- algOid = (OID) oid.getValue();
- if (algpLen == 0)
- {
- val = der.read();
- if (val.getTag() != 0)
- {
- encodedParams = val.getEncoded();
- der.read();
- }
- }
- else if (oid.getEncodedLength() < val.getLength())
- {
- val = der.read();
- encodedParams = val.getEncoded();
- }
- val = der.read();
- if (val.getTag() != DER.OCTET_STRING)
- throw new IOException("malformed AlgorithmIdentifier");
- encryptedData = (byte[]) val.getValue();
- }
-
- private void encode() throws IOException
- {
- List algId = new ArrayList(2);
- algId.add(new DERValue(DER.OBJECT_IDENTIFIER, algOid));
- getAlgParameters();
- if (params != null)
- {
- algId.add (DERReader.read (params.getEncoded()));
- }
- else
- {
- algId.add (new DERValue (DER.NULL, null));
- }
- List epki = new ArrayList(2);
- epki.add(new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, algId));
- epki.add(new DERValue(DER.OCTET_STRING, encryptedData));
- encoded = new DERValue(DER.CONSTRUCTED|DER.SEQUENCE, epki).getEncoded();
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanism.java b/openjdk/icedtea/jce/javax/crypto/ExemptionMechanism.java
deleted file mode 100644
index baf6bad9..00000000
--- a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanism.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/* ExemptionMechanism.java -- Generic crypto-weakening mechanism.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.lang.reflect.InvocationTargetException;
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * An exemption mechanism, which will conditionally allow cryptography
- * where it is not normally allowed, implements things such as key
- * recovery, key weakening, or key escrow.
- *
- *
Implementation note: this class is present for
- * API-compatibility only; it is not actually used anywhere in this library
- * and this library does not, in general, support crypto weakening.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class ExemptionMechanism
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "ExemptionMechanism";
- private ExemptionMechanismSpi emSpi;
- private Provider provider;
- private String mechanism;
- private boolean virgin;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- protected ExemptionMechanism(ExemptionMechanismSpi emSpi, Provider provider,
- String mechanism)
- {
- this.emSpi = emSpi;
- this.provider = provider;
- this.mechanism = mechanism;
- virgin = true;
- }
-
- /**
- * Create an instance of ExemptionMechanism
for a designated
- * mechanism
from the first Security Provider offering it.
- *
- * @param mechanism the name of the exemption mechanism to create.
- * @return a newly created instance of ExemptionMechanism
.
- * @throws IllegalArgumentException if the provider is null.
- * @throws NoSuchAlgorithmException if no such exemption mechanism is
- * available from any known Security Provider.
- * @throws IllegalArgumentException if mechanism
is
- * null
or is an empty string.
- */
- public static final ExemptionMechanism getInstance(String mechanism)
- throws NoSuchAlgorithmException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(mechanism, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- }
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(mechanism);
- }
-
- /**
- * Create an instance of ExemptionMechanism
for a designated
- * mechanism
from a named provider
.
- *
- * @param mechanism the name of the exemption mechanism to create.
- * @param provider the security provider to provide the exemption
- * mechanism
.
- * @return a newly created instance of ExemptionMechanism
.
- * @throws NoSuchAlgorithmException if no such exemption mechanism is
- * available from the named provider
.
- * @throws NoSuchProviderException if no Security Provider with the designated
- * name is known to the underlying JVM.
- * @throws IllegalArgumentException if either mechanism
or
- * provider
is null
, or if
- * mechanism
is an empty string.
- */
- public static final ExemptionMechanism getInstance(String mechanism,
- String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(mechanism, p);
- }
-
- /**
- * Create an instance of ExemptionMechanism
for a designated
- * mechanism
from a designated provider
.
- *
- * @param mechanism the name of the exemption mechanism to create.
- * @param provider the security provider to provide the exemption
- * mechanism
.
- * @return a newly created instance of ExemptionMechanism
.
- * @throws NoSuchAlgorithmException if an exemption mechanism could not be
- * created.
- * @throws IllegalArgumentException if either mechanism
or
- * provider
is null
, or if
- * mechanism
is an empty string.
- */
- public static final ExemptionMechanism getInstance(String mechanism,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- StringBuilder sb = new StringBuilder("ExemptionMechanism [")
- .append(mechanism).append("] from provider[")
- .append(provider).append("] could not be created");
- Throwable cause;
- try
- {
- Object spi = Engine.getInstance(SERVICE, mechanism, provider);
- return new ExemptionMechanism((ExemptionMechanismSpi) spi,
- provider,
- mechanism);
- }
- catch (InvocationTargetException x)
- {
- cause = x.getCause();
- if (cause instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) cause;
- if (cause == null)
- cause = x;
- }
- catch (ClassCastException x)
- {
- cause = x;
- }
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- public final byte[] genExemptionBlob()
- throws IllegalStateException, ExemptionMechanismException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return emSpi.engineGenExemptionBlob();
- }
-
- public final int genExemptionBlob(byte[] output)
- throws IllegalStateException, ExemptionMechanismException,
- ShortBufferException
- {
- return genExemptionBlob(output, 0);
- }
-
- public final int genExemptionBlob(byte[] output, int outputOffset)
- throws IllegalStateException, ExemptionMechanismException,
- ShortBufferException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return emSpi.engineGenExemptionBlob(output, outputOffset);
- }
-
- public final String getName()
- {
- return mechanism;
- }
-
- public final int getOutputSize(int inputLength) throws IllegalStateException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return emSpi.engineGetOutputSize(inputLength);
- }
-
- public final Provider getProvider()
- {
- return provider;
- }
-
- public final void init(Key key)
- throws ExemptionMechanismException, InvalidKeyException
- {
- emSpi.engineInit(key);
- virgin = false;
- }
-
- public final void init(Key key, AlgorithmParameters params)
- throws ExemptionMechanismException, InvalidAlgorithmParameterException,
- InvalidKeyException
- {
- emSpi.engineInit(key, params);
- virgin = false;
- }
-
- public final void init(Key key, AlgorithmParameterSpec params)
- throws ExemptionMechanismException, InvalidAlgorithmParameterException,
- InvalidKeyException
- {
- emSpi.engineInit(key, params);
- virgin = false;
- }
-
- public final boolean isCryptoAllowed(Key key)
- throws ExemptionMechanismException
- {
- return true;
- }
-
- protected void finalize()
- {
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismException.java b/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismException.java
deleted file mode 100644
index 6cc44c70..00000000
--- a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismException.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* ExemptionMechanismException -- An error in an exemption mechanism.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.GeneralSecurityException;
-
-/**
- * Signals a general exception in an {@link ExemptionMechanism}.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class ExemptionMechanismException extends GeneralSecurityException
-{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /** Compatible with JDK1.4. */
- private static final long serialVersionUID = 1572699429277957109L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new exception with no detail message.
- */
- public ExemptionMechanismException()
- {
- super();
- }
-
- /**
- * Create a new exception with a detail message.
- *
- * @param message The detail message.
- */
- public ExemptionMechanismException(String message)
- {
- super(message);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismSpi.java b/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismSpi.java
deleted file mode 100644
index 00406095..00000000
--- a/openjdk/icedtea/jce/javax/crypto/ExemptionMechanismSpi.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/* ExemptionMechanismSpi.java -- Exemption mechanism service provider interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * The Service Provider Interface (SPI) for the {@link
- * ExemptionMechanism} class.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public abstract class ExemptionMechanismSpi
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new exemption mechanism SPI.
- */
- public ExemptionMechanismSpi()
- {
- }
-
- // Abstract instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return a key blob for the key that this mechanism was initialized
- * with.
- *
- * @return The key blob.
- * @throws javax.crypto.ExemptionMechanismException If generating the
- * blob fails.
- */
- protected abstract byte[] engineGenExemptionBlob()
- throws ExemptionMechanismException;
-
- /**
- * Generate a key blob for the key that this mechanism was initialized
- * with, storing it into the given byte array.
- *
- * @param output The destination for the key blob.
- * @param outputOffset The index in the output array to start.
- * @return The size of the key blob.
- * @throws javax.crypto.ExemptionMechanismException If generating the
- * blob fails.
- * @throws javax.crypto.ShortBufferException If the output array is
- * not large enough for the key blob.
- */
- protected abstract int engineGenExemptionBlob(byte[] output, int outputOffset)
- throws ExemptionMechanismException, ShortBufferException;
-
- /**
- * Get the size of the output blob given an input key size. The actual
- * blob may be shorter than the value returned by this method. Both
- * values are in bytes.
- *
- * @param inputLength The input size.
- * @return The output size.
- */
- protected abstract int engineGetOutputSize(int inputLength);
-
- /**
- * Initialize this mechanism with a key.
- *
- * @param key The key.
- * @throws javax.crypto.ExemptionMechanismException If generating the
- * blob fails.
- * @throws java.security.InvalidKeyException If the supplied key
- * cannot be used.
- */
- protected abstract void engineInit(Key key)
- throws ExemptionMechanismException, InvalidKeyException;
-
- /**
- * Initialize this mechanism with a key and parameters.
- *
- * @param key The key.
- * @param params The parameters.
- * @throws javax.crypto.ExemptionMechanismException If generating the
- * blob fails.
- * @throws java.security.InvalidAlgorithmParameterExceptin If the
- * supplied parameters are inappropriate.
- * @throws java.security.InvalidKeyException If the supplied key
- * cannot be used.
- */
- protected abstract void engineInit(Key key, AlgorithmParameters params)
- throws ExemptionMechanismException, InvalidAlgorithmParameterException,
- InvalidKeyException;
-
- /**
- * Initialize this mechanism with a key and parameters.
- *
- * @param key The key.
- * @param params The parameters.
- * @throws javax.crypto.ExemptionMechanismException If generating the
- * blob fails.
- * @throws java.security.InvalidAlgorithmParameterExceptin If the
- * supplied parameters are inappropriate.
- * @throws java.security.InvalidKeyException If the supplied key
- * cannot be used.
- */
- protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
- throws ExemptionMechanismException, InvalidAlgorithmParameterException,
- InvalidKeyException;
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/IllegalBlockSizeException.java b/openjdk/icedtea/jce/javax/crypto/IllegalBlockSizeException.java
deleted file mode 100644
index c08752aa..00000000
--- a/openjdk/icedtea/jce/javax/crypto/IllegalBlockSizeException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/* IllegalBlockSizeException.java -- Signals illegal block sizes.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.GeneralSecurityException;
-
-/**
- * This exception is thrown when finishing encryption without padding or
- * decryption and the input is not a multiple of the cipher's block
- * size.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class IllegalBlockSizeException extends GeneralSecurityException
-{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /** Serialization constant. */
- private static final long serialVersionUID = -1965144811953540392L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- public IllegalBlockSizeException()
- {
- super();
- }
-
- public IllegalBlockSizeException(String message)
- {
- super(message);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/KeyAgreement.java b/openjdk/icedtea/jce/javax/crypto/KeyAgreement.java
deleted file mode 100644
index 49003109..00000000
--- a/openjdk/icedtea/jce/javax/crypto/KeyAgreement.java
+++ /dev/null
@@ -1,378 +0,0 @@
-/* KeyAgreement.java -- Engine for key agreement methods.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.lang.reflect.InvocationTargetException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * Key agreement is a method in which two or more parties may agree on a
- * secret key for symmetric cryptography or message authentication
- * without transmitting any secrets in the clear. Key agreement
- * algorithms typically use a public/private key pair, and the
- * public key (along with some additional information) is sent across
- * untrusted networks.
- *
- *
The most common form of key agreement used today is the
- * Diffie-Hellman key exchange algorithm, described in PKCS #3 -
- * Diffie Hellman Key Agreement Standard.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see KeyGenerator
- * @see SecretKey
- */
-public class KeyAgreement
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "KeyAgreement";
-
- /** The underlying key agreement implementation. */
- private KeyAgreementSpi kaSpi;
-
- /** The provider of this implementation. */
- private Provider provider;
-
- /** The name of this instance's algorithm. */
- private String algorithm;
-
- /** Singnals whether or not this instance has been initialized. */
- private boolean virgin;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- protected KeyAgreement(KeyAgreementSpi kaSpi, Provider provider,
- String algorithm)
- {
- this.kaSpi = kaSpi;
- this.provider = provider;
- this.algorithm = algorithm;
- virgin = true;
- }
-
- /**
- * Get an implementation of an algorithm from the first provider that
- * implements it.
- *
- * @param algorithm The name of the algorithm to get.
- * @return The proper KeyAgreement instacne, if found.
- * @throws NoSuchAlgorithmException If the specified algorithm is not
- * implemented by any installed provider.
- * @throws IllegalArgumentException if algorithm
is
- * null
or is an empty string.
- */
- public static final KeyAgreement getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- }
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- /**
- * Return an implementation of an algorithm from a named provider.
- *
- * @param algorithm The name of the algorithm to create.
- * @param provider The name of the provider from which to get the
- * implementation.
- * @return The proper KeyAgreement instance, if found.
- * @throws NoSuchAlgorithmException If the named provider does not implement
- * the algorithm.
- * @throws NoSuchProviderException If the named provider does not exist.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final KeyAgreement getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(algorithm, p);
- }
-
- /**
- * Return an implementation of an algorithm from a specific provider.
- *
- * @param algorithm The name of the algorithm to get.
- * @param provider The provider from which to get the implementation.
- * @return The proper KeyAgreement instance, if found.
- * @throws NoSuchAlgorithmException If this provider does not implement the
- * algorithm.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final KeyAgreement getInstance(String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- StringBuilder sb = new StringBuilder("KeyAgreement algorithm [")
- .append(algorithm).append("] from provider[")
- .append(provider).append("] could not be created");
- Throwable cause;
- try
- {
- Object spi = Engine.getInstance(SERVICE, algorithm, provider);
- return new KeyAgreement((KeyAgreementSpi) spi, provider, algorithm);
- }
- catch (InvocationTargetException x)
- {
- cause = x.getCause();
- if (cause instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) cause;
- if (cause == null)
- cause = x;
- }
- catch (ClassCastException x)
- {
- cause = x;
- }
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Do a phase in the key agreement. The number of times this method is
- * called depends upon the algorithm and the number of parties
- * involved, but must be called at least once with the
- * lastPhase
flag set to true
.
- *
- * @param key The key for this phase.
- * @param lastPhase Should be true
if this will be the
- * last phase before generating the shared secret.
- * @return The intermediate result, or null
if there is
- * no intermediate result.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized.
- * @throws java.security.InvalidKeyException If the key is
- * inappropriate for this algorithm.
- */
- public final Key doPhase(Key key, boolean lastPhase)
- throws IllegalStateException, InvalidKeyException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return kaSpi.engineDoPhase(key, lastPhase);
- }
-
- /**
- * Generate the shared secret in a new byte array.
- *
- * @return The shared secret.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized, or if not enough calls to
- * doPhase
have been made.
- */
- public final byte[] generateSecret() throws IllegalStateException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return kaSpi.engineGenerateSecret();
- }
-
- /**
- * Generate the shared secret and store it into the supplied array.
- *
- * @param sharedSecret The array in which to store the secret.
- * @param offset The index in sharedSecret
to start
- * storing data.
- * @return The length of the shared secret, in bytes.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized, or if not enough calls to
- * doPhase
have been made.
- * @throws javax.crypto.ShortBufferException If the supplied array is
- * not large enough to store the result.
- */
- public final int generateSecret(byte[] sharedSecret, int offset)
- throws IllegalStateException, ShortBufferException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return kaSpi.engineGenerateSecret(sharedSecret, offset);
- }
-
- /**
- * Generate the shared secret and return it as an appropriate {@link
- * SecretKey}.
- *
- * @param algorithm The secret key's algorithm.
- * @return The shared secret as a secret key.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized, or if not enough calls to
- * doPhase
have been made.
- * @throws java.security.InvalidKeyException If the shared secret
- * cannot be used to make a {@link SecretKey}.
- * @throws java.security.NoSuchAlgorithmException If the specified
- * algorithm does not exist.
- */
- public final SecretKey generateSecret(String algorithm)
- throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- return kaSpi.engineGenerateSecret(algorithm);
- }
-
- /**
- * Return the name of this key-agreement algorithm.
- *
- * @return The algorithm name.
- */
- public final String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Return the provider of the underlying implementation.
- *
- * @return The provider.
- */
- public final Provider getProvider()
- {
- return provider;
- }
-
- /**
- * Initialize this key agreement with a key. This method will use the
- * highest-priority {@link java.security.SecureRandom} as its source
- * of randomness.
- *
- * @param key The key, usually the user's private key.
- * @throws java.security.InvalidKeyException If the supplied key is
- * not appropriate.
- */
- public final void init(Key key) throws InvalidKeyException
- {
- init(key, new SecureRandom());
- }
-
- /**
- * Initialize this key agreement with a key and a source of
- * randomness.
- *
- * @param key The key, usually the user's private key.
- * @param random The source of randomness.
- * @throws java.security.InvalidKeyException If the supplied key is
- * not appropriate.
- */
- public final void init(Key key, SecureRandom random)
- throws InvalidKeyException
- {
- kaSpi.engineInit(key, random);
- virgin = false; // w00t!
- }
-
- /**
- * Initialize this key agreement with a key and parameters. This
- * method will use the highest-priority {@link
- * java.security.SecureRandom} as its source of randomness.
- *
- * @param key The key, usually the user's private key.
- * @param params The algorithm parameters.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are not appropriate.
- * @throws java.security.InvalidKeyException If the supplied key is
- * not appropriate.
- */
- public final void init(Key key, AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException, InvalidKeyException
- {
- init(key, params, new SecureRandom());
- }
-
- /**
- * Initialize this key agreement with a key, parameters, and source of
- * randomness.
- *
- * @param key The key, usually the user's private key.
- * @param params The algorithm parameters.
- * @param random The source of randomness.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are not appropriate.
- * @throws java.security.InvalidKeyException If the supplied key is
- * not appropriate.
- */
- public final void init(Key key, AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException, InvalidKeyException
- {
- kaSpi.engineInit(key, params, random);
- virgin = false; // w00t!
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/KeyAgreementSpi.java b/openjdk/icedtea/jce/javax/crypto/KeyAgreementSpi.java
deleted file mode 100644
index d71c89c1..00000000
--- a/openjdk/icedtea/jce/javax/crypto/KeyAgreementSpi.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/* KeyAgreementSpi.java -- The key agreement service provider interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * This is the Service Provider Interface (SPI) for the
- * {@link javax.crypto.KeyAgreement} class.
- *
- *
Providers wishing to implement a key agreement algorithm must
- * subclass this and provide an appropriate implementation for all the
- * abstract methods below, and provide an appropriate entry in the
- * master {@link java.security.Provider} class (the service name for key
- * agreement algorithms is "KeyAgreement"
).
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see KeyAgreement
- * @see SecretKey
- */
-public abstract class KeyAgreementSpi
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new KeyAgreementSpi instance.
- */
- public KeyAgreementSpi()
- {
- }
-
- // Abstract instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Do a phase in the key agreement.
- *
- * @param key The key to use for this phase.
- * @param lastPhase true
if this call should be the last
- * phase.
- * @return The intermediate result, or null
if there is
- * no intermediate result.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized.
- * @throws java.security.InvalidKeyException If the supplied key is
- * not appropriate.
- */
- protected abstract Key engineDoPhase(Key key, boolean lastPhase)
- throws IllegalStateException, InvalidKeyException;
-
- /**
- * Generate the shared secret in a new byte array.
- *
- * @return The shared secret in a new byte array.
- * @throws java.lang.IllegalStateException If this key agreement is
- * not ready to generate the secret.
- */
- protected abstract byte[] engineGenerateSecret()
- throws IllegalStateException;
-
- /**
- * Generate the shared secret, storing it into the specified array.
- *
- * @param sharedSecret The byte array in which to store the secret.
- * @param offset The offset into the byte array to start.
- * @return The size of the shared secret.
- * @throws java.lang.IllegalStateException If this key agreement is
- * not ready to generate the secret.
- * @throws javax.crypto.ShortBufferException If there is not enough
- * space in the supplied array for the shared secret.
- */
- protected abstract int engineGenerateSecret(byte[] sharedSecret, int offset)
- throws IllegalStateException, ShortBufferException;
-
- /**
- * Generate the shared secret and return it as a {@link SecretKey}.
- *
- * @param algorithm The algorithm with which to generate the secret key.
- * @return The shared secret as a secret key.
- * @throws java.lang.IllegalStateException If this key agreement is
- * not ready to generate the secret.
- * @throws java.security.InvalidKeyException If the shared secret
- * cannot be made into a {@link SecretKey}.
- * @throws java.security.NoSuchAlgorithmException If
- * algorithm
cannot be found.
- */
- protected abstract SecretKey engineGenerateSecret(String algorithm)
- throws IllegalStateException, InvalidKeyException, NoSuchAlgorithmException;
-
- /**
- * Initialize this key agreement with a key, parameters, and source of
- * randomness.
- *
- * @param key The key to initialize with, usually a private key.
- * @param params The parameters to initialize with.
- * @param random The source of randomness to use.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inappropriate.
- * @throws java.security.InvalidKeyException If the supplied key is
- * inappropriate.
- */
- protected abstract void engineInit(Key key, AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException, InvalidKeyException;
-
- /**
- * Initialize this key agreement with a key and source of randomness.
- *
- * @param key The key to initialize with, usually a private key.
- * @param random The source of randomness to use.
- * @throws java.security.InvalidKeyException If the supplied key is
- * inappropriate.
- */
- protected abstract void engineInit(Key key, SecureRandom random)
- throws InvalidKeyException;
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/KeyGenerator.java b/openjdk/icedtea/jce/javax/crypto/KeyGenerator.java
deleted file mode 100644
index 02098c32..00000000
--- a/openjdk/icedtea/jce/javax/crypto/KeyGenerator.java
+++ /dev/null
@@ -1,298 +0,0 @@
-/* KeyGenerator.java -- Interface to a symmetric key generator.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.lang.reflect.InvocationTargetException;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.SecureRandom;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-import sun.security.internal.spec.TlsKeyMaterialParameterSpec;
-import sun.security.internal.spec.TlsMasterSecretParameterSpec;
-import sun.security.internal.spec.TlsPrfParameterSpec;
-import sun.security.internal.spec.TlsRsaPremasterSecretParameterSpec;
-
-/**
- * A generic producer of keys for symmetric cryptography. The keys
- * returned may be simple wrappers around byte arrays, or, if the
- * target cipher requires them, more complex objects.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see Cipher
- * @see Mac
- */
-public class KeyGenerator
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "KeyGenerator";
-
- /** The underlying generator implementation. */
- private KeyGeneratorSpi kgSpi;
-
- /** The provider of the implementation. */
- private Provider provider;
-
- /** The name of the algorithm. */
- private String algorithm;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new key generator.
- *
- * @param kgSpi The underlying generator.
- * @param provider The provider of this implementation.
- * @param algorithm The algorithm's name.
- */
- protected KeyGenerator(KeyGeneratorSpi kgSpi, Provider provider,
- String algorithm)
- {
- this.kgSpi = kgSpi;
- this.provider = provider;
- this.algorithm = algorithm;
- }
-
- /**
- * Create a new key generator, returning the first available implementation.
- *
- * @param algorithm The generator algorithm name.
- * @throws NoSuchAlgorithmException If the specified algorithm does not exist.
- * @throws IllegalArgumentException if algorithm
is
- * null
or is an empty string.
- */
- public static final KeyGenerator getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- }
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- /**
- * Create a new key generator from the named provider.
- *
- * @param algorithm The generator algorithm name.
- * @param provider The name of the provider to use.
- * @return An appropriate key generator, if found.
- * @throws NoSuchAlgorithmException If the specified algorithm is not
- * implemented by the named provider.
- * @throws NoSuchProviderException If the named provider does not exist.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final KeyGenerator getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(algorithm, p);
- }
-
- /**
- * Create a new key generator from the supplied provider.
- *
- * @param algorithm The generator algorithm name.
- * @param provider The provider to use.
- * @return An appropriate key generator, if found.
- * @throws NoSuchAlgorithmException If the specified algorithm is not
- * implemented by the provider.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final KeyGenerator getInstance(String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- StringBuilder sb = new StringBuilder("KeyGenerator algorithm [")
- .append(algorithm).append("] from provider[")
- .append(provider).append("] could not be created");
- Throwable cause;
- try
- {
- Object spi = Engine.getInstance(SERVICE, algorithm, provider);
- KeyGenerator instance = new KeyGenerator((KeyGeneratorSpi) spi,
- provider,
- algorithm);
- instance.init(new SecureRandom());
- return instance;
- }
- catch (InvocationTargetException x)
- {
- cause = x.getCause();
- if (cause instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) cause;
- if (cause == null)
- cause = x;
- }
- catch (ClassCastException x)
- {
- cause = x;
- }
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Generate a key.
- *
- * @return The new key.
- */
- public final SecretKey generateKey()
- {
- return kgSpi.engineGenerateKey();
- }
-
- /**
- * Return the name of this key generator.
- *
- * @return The algorithm name.
- */
- public final String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Return the provider of the underlying implementation.
- *
- * @return The provider.
- */
- public final Provider getProvider()
- {
- return provider;
- }
-
- /**
- * Initialize this key generator with a set of parameters; the
- * highest-priority {@link java.security.SecureRandom} implementation
- * will be used.
- *
- * @param params The algorithm parameters.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inapproprate.
- */
- public final void init(AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException
- {
- init(params, new SecureRandom());
- }
-
- /**
- * Initialize this key generator with a set of parameters and a source
- * of randomness.
- *
- * @param params The algorithm parameters.
- * @param random The source of randomness.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * supplied parameters are inapproprate.
- */
- public final void init(AlgorithmParameterSpec params, SecureRandom random)
- throws InvalidAlgorithmParameterException
- {
- kgSpi.engineInit(params, random);
- }
-
- /**
- * Initialize this key generator with a key size (in bits); the
- * highest-priority {@link java.security.SecureRandom} implementation
- * will be used.
- *
- * @param keySize The target key size, in bits.
- * @throws java.security.InvalidParameterException If the
- * key size is unsupported.
- */
- public final void init(int keySize)
- {
- init(keySize, new SecureRandom());
- }
-
- /**
- * Initialize this key generator with a key size (in bits) and a
- * source of randomness.
- *
- * @param keySize The target key size, in bits.
- * @param random The source of randomness.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * key size is unsupported.
- */
- public final void init(int keySize, SecureRandom random)
- {
- kgSpi.engineInit(keySize, random);
- }
-
- /**
- * Initialize this key generator with a source of randomness. The
- * implementation-specific default parameters (such as key size) will
- * be used.
- *
- * @param random The source of randomness.
- */
- public final void init(SecureRandom random)
- {
- kgSpi.engineInit(random);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/KeyGeneratorSpi.java b/openjdk/icedtea/jce/javax/crypto/KeyGeneratorSpi.java
deleted file mode 100644
index 1c481890..00000000
--- a/openjdk/icedtea/jce/javax/crypto/KeyGeneratorSpi.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/* KeyGeneratorSpi.java -- The key generator service provider interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.InvalidAlgorithmParameterException;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * The Service Provider Interface (SPI) for the {@link
- * KeyGenerator} class.
- *
- *
Providers wishing to implement a key generator must subclass this
- * and provide an appropriate implementation for all the abstract
- * methods below, and provide an appropriate entry in the master {@link
- * java.security.Provider} class (the service name for key generators is
- * "KeyGenerator"
).
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see KeyGenerator
- */
-public abstract class KeyGeneratorSpi
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /** Create a new key generator SPI. */
- public KeyGeneratorSpi()
- {
- }
-
- // Abstract instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Generate a key, returning it as a {@link SecretKey}.
- *
- * @return The generated key.
- */
- protected abstract SecretKey engineGenerateKey();
-
- /**
- * Initialize this key generator with parameters and a source of
- * randomness.
- *
- * @param params The parameters.
- * @param random The source of randomness.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * parameters are inappropriate for this instance.
- */
- protected abstract void engineInit(AlgorithmParameterSpec params,
- SecureRandom random)
- throws InvalidAlgorithmParameterException;
-
- /**
- * Initialize this key generator with a key size (in bits) and a
- * source of randomness.
- *
- * @param keySize The target key size, in bits.
- * @param random The source of randomness.
- * @throws java.security.InvalidParameterException If the
- * key size is illogical or unsupported.
- */
- protected abstract void engineInit(int keySize, SecureRandom random);
-
- /**
- * Initialize this key generator with a source of randomness; the
- * implementation should use reasonable default parameters (such as
- * generated key size).
- *
- * @param random The source of randomness.
- */
- protected abstract void engineInit(SecureRandom random);
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/Mac.java b/openjdk/icedtea/jce/javax/crypto/Mac.java
deleted file mode 100644
index 2a269ab8..00000000
--- a/openjdk/icedtea/jce/javax/crypto/Mac.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/* Mac.java -- The message authentication code interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.lang.reflect.InvocationTargetException;
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * This class implements a "message authentication code" (MAC), a method
- * to ensure the integrity of data transmitted between two parties who
- * share a common secret key.
- *
- *
The best way to describe a MAC is as a keyed one-way hash
- * function, which looks like:
- *
- *
D = MAC(K, M)
- *
- * where K
is the key, M
is the message,
- * and D
is the resulting digest. One party will usually
- * send the concatenation M || D
to the other party, who
- * will then verify D
by computing D'
in a
- * similar fashion. If D == D'
, then the message is assumed
- * to be authentic.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class Mac implements Cloneable
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "Mac";
-
- /** The underlying MAC implementation. */
- private MacSpi macSpi;
-
- /** The provider we got our implementation from. */
- private Provider provider;
-
- /** The name of the algorithm. */
- private String algorithm;
-
- /** Whether or not we've been initialized. */
- private boolean virgin;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Creates a new Mac instance.
- *
- * @param macSpi The underlying MAC implementation.
- * @param provider The provider of this implementation.
- * @param algorithm The name of this MAC algorithm.
- */
- protected Mac(MacSpi macSpi, Provider provider, String algorithm)
- {
- this.macSpi = macSpi;
- this.provider = provider;
- this.algorithm = algorithm;
- virgin = true;
- }
-
- /**
- * Create an instance of the named algorithm from the first provider with an
- * appropriate implementation.
- *
- * @param algorithm The name of the algorithm.
- * @return An appropriate Mac instance, if the specified algorithm is
- * implemented by a provider.
- * @throws NoSuchAlgorithmException If no implementation of the named
- * algorithm is installed.
- * @throws IllegalArgumentException if algorithm
is
- * null
or is an empty string.
- */
- public static final Mac getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- }
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- /**
- * Create an instance of the named algorithm from the named provider.
- *
- * @param algorithm The name of the algorithm.
- * @param provider The name of the provider.
- * @return An appropriate Mac instance, if the specified algorithm is
- * implemented by the named provider.
- * @throws NoSuchAlgorithmException If the named provider has no
- * implementation of the algorithm.
- * @throws NoSuchProviderException If the named provider does not exist.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final Mac getInstance(String algorithm, String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(algorithm, p);
- }
-
- /**
- * Create an instance of the named algorithm from a provider.
- *
- * @param algorithm The name of the algorithm.
- * @param provider The provider.
- * @return An appropriate Mac instance, if the specified algorithm is
- * implemented by the provider.
- * @throws NoSuchAlgorithmException If the provider has no implementation of
- * the algorithm.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final Mac getInstance(String algorithm, Provider provider)
- throws NoSuchAlgorithmException
- {
- StringBuilder sb = new StringBuilder("Mac algorithm [")
- .append(algorithm).append("] from provider[")
- .append(provider).append("] could not be created");
- Throwable cause;
- try
- {
- Object spi = Engine.getInstance(SERVICE, algorithm, provider);
- return new Mac((MacSpi) spi, provider, algorithm);
- }
- catch (InvocationTargetException x)
- {
- cause = x.getCause();
- if (cause instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) cause;
- if (cause == null)
- cause = x;
- }
- catch (ClassCastException x)
- {
- cause = x;
- }
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Finishes the computation of a MAC and returns the digest.
- *
- *
After this method succeeds, it may be used again as just after a
- * call to init
, and can compute another MAC using the
- * same key and parameters.
- *
- * @return The message authentication code.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized.
- */
- public final byte[] doFinal() throws IllegalStateException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- byte[] digest = macSpi.engineDoFinal();
- reset();
- return digest;
- }
-
- /**
- * Finishes the computation of a MAC with a final byte array (or
- * computes a MAC over those bytes only) and returns the digest.
- *
- *
After this method succeeds, it may be used again as just after a
- * call to init
, and can compute another MAC using the
- * same key and parameters.
- *
- * @param input The bytes to add.
- * @return The message authentication code.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized.
- */
- public final byte[] doFinal(byte[] input) throws IllegalStateException
- {
- update(input);
- byte[] digest = macSpi.engineDoFinal();
- reset();
- return digest;
- }
-
- /**
- * Finishes the computation of a MAC and places the result into the
- * given array.
- *
- *
After this method succeeds, it may be used again as just after a
- * call to init
, and can compute another MAC using the
- * same key and parameters.
- *
- * @param output The destination for the result.
- * @param outOffset The index in the output array to start.
- * @return The message authentication code.
- * @throws java.lang.IllegalStateException If this instnace has not
- * been initialized.
- * @throws javax.crypto.ShortBufferException If output
is
- * not large enough to hold the result.
- */
- public final void doFinal(byte[] output, int outOffset)
- throws IllegalStateException, ShortBufferException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- if (output.length - outOffset < getMacLength())
- {
- throw new ShortBufferException();
- }
- byte[] mac = macSpi.engineDoFinal();
- System.arraycopy(mac, 0, output, outOffset, getMacLength());
- reset();
- }
-
- /**
- * Returns the name of this MAC algorithm.
- *
- * @return The MAC name.
- */
- public final String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Get the size of the MAC. This is the size of the array returned by
- * {@link #doFinal()} and {@link #doFinal(byte[])}, and the minimum
- * number of bytes that must be available in the byte array passed to
- * {@link #doFinal(byte[],int)}.
- *
- * @return The MAC length.
- */
- public final int getMacLength()
- {
- return macSpi.engineGetMacLength();
- }
-
- /**
- * Get the provider of the underlying implementation.
- *
- * @return The provider.
- */
- public final Provider getProvider()
- {
- return provider;
- }
-
- /**
- * Initialize this MAC with a key and no parameters.
- *
- * @param key The key to initialize this instance with.
- * @throws java.security.InvalidKeyException If the key is
- * unacceptable.
- */
- public final void init(Key key) throws InvalidKeyException
- {
- try
- {
- init(key, null);
- }
- catch (InvalidAlgorithmParameterException iape)
- {
- throw new IllegalArgumentException(algorithm + " needs parameters");
- }
- }
-
- /**
- * Initialize this MAC with a key and parameters.
- *
- * @param key The key to initialize this instance with.
- * @param params The algorithm-specific parameters.
- * @throws java.security.InvalidAlgorithmParameterException If the
- * algorithm parameters are unacceptable.
- * @throws java.security.InvalidKeyException If the key is
- * unacceptable.
- */
- public final void init(Key key, AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException, InvalidKeyException
- {
- macSpi.engineInit(key, params);
- virgin = false; // w00t!
- }
-
- /**
- * Reset this instance. A call to this method returns this instance
- * back to the state it was in just after it was initialized.
- */
- public final void reset()
- {
- macSpi.engineReset();
- }
-
- /**
- * Update the computation with a single byte.
- *
- * @param input The next byte.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized.
- */
- public final void update(byte input) throws IllegalStateException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- macSpi.engineUpdate(input);
- }
-
- /**
- * Update the computation with a byte array.
- *
- * @param input The next bytes.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized.
- */
- public final void update(byte[] input) throws IllegalStateException
- {
- update(input, 0, input.length);
- }
-
- /**
- * Update the computation with a portion of a byte array.
- *
- * @param input The next bytes.
- * @param offset The index in input
to start.
- * @param length The number of bytes to update.
- * @throws java.lang.IllegalStateException If this instance has not
- * been initialized.
- */
- public final void update(byte[] input, int offset, int length)
- throws IllegalStateException
- {
- if (virgin)
- {
- throw new IllegalStateException("not initialized");
- }
- macSpi.engineUpdate(input, offset, length);
- }
-
- /**
- * Update this MAC with the remaining bytes in the given buffer
- * @param buffer The input buffer.
- * @since 1.5
- */
- public final void update (final ByteBuffer buffer)
- {
- if (virgin)
- throw new IllegalStateException ("not initialized");
- macSpi.engineUpdate(buffer);
- }
-
- /**
- * Clone this instance, if the underlying implementation supports it.
- *
- * @return A clone of this instance.
- * @throws java.lang.CloneNotSupportedException If the underlying
- * implementation is not cloneable.
- */
- public final Object clone() throws CloneNotSupportedException
- {
- Mac result = new Mac((MacSpi) macSpi.clone(), provider, algorithm);
- result.virgin = virgin;
- return result;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/MacSpi.java b/openjdk/icedtea/jce/javax/crypto/MacSpi.java
deleted file mode 100644
index 853bd66a..00000000
--- a/openjdk/icedtea/jce/javax/crypto/MacSpi.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/* MacSpi.java -- The MAC service provider interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.nio.ByteBuffer;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * This is the Service Provider Interface (SPI) for the
- * {@link Mac} class.
- *
- *
Providers wishing to implement a Mac must subclass this class and
- * provide appropriate implementations of all its abstract methods,
- * then provide an entry pointing to this implementation in the master
- * {@link java.security.Provider} class.
- *
- *
Implementations may optionally implement the {@link
- * java.lang.Cloneable} interface.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public abstract class MacSpi
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new MacSpi instance.
- */
- public MacSpi()
- {
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Returns a clone of this instance if cloning is supported.
- *
- * @return A clone of this instance.
- * @throws java.lang.CloneNotSupportedException If this instance does
- * not support cloneing.
- */
- public Object clone() throws CloneNotSupportedException
- {
- return super.clone();
- }
-
- // Abstract instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Finalize the computation of this MAC and return the result as a
- * byte array.
- *
- * @return The MAC.
- */
- protected abstract byte[] engineDoFinal();
-
- /**
- * Return the total length, in bytes, of the computed MAC (the length
- * of the byte array returned by {@link #doFinal()}.
- *
- * @return The MAC length.
- */
- protected abstract int engineGetMacLength();
-
- /**
- * Initialize (or re-initialize) this instance.
- *
- * @param key The key to use.
- * @param params The parameters to use.
- * @throws java.security.InvalidAlgorithmParameterException If this
- * instance rejects the specified parameters.
- * @throws java.security.InvalidKeyException If this instance rejects
- * the specified key.
- */
- protected abstract void engineInit(Key key, AlgorithmParameterSpec params)
- throws InvalidAlgorithmParameterException, InvalidKeyException;
-
- /**
- * Reset this instance. After this method succeeds, the state of this
- * instance should be the same as it was before any data was input
- * (possibly after a call to {@link
- * #init(java.security.Key,java.security.spec.AlgorithmParameterSpec)},
- * possibly not).
- */
- protected abstract void engineReset();
-
- /**
- * Update this MAC with a single byte.
- *
- * @param input The next byte.
- */
- protected abstract void engineUpdate(byte input);
-
- /**
- * Update this MAC with a portion of a byte array.
- *
- * @param input The next bytes.
- * @param offset The index in input
at which to start.
- * @param length The number of bytes to update.
- */
- protected abstract void engineUpdate(byte[] input, int offset, int length);
-
- /**
- * Update this MAC with the remaining bytes of a buffer.
- *
- * @param buffer The input buffer.
- * @since 1.5
- */
- protected void engineUpdate (final ByteBuffer buffer)
- {
- byte[] buf = new byte[1024];
- while (buffer.hasRemaining ())
- {
- int n = Math.min (buffer.remaining (), buf.length);
- buffer.get (buf, 0, n);
- engineUpdate (buf, 0, n);
- }
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/NoSuchPaddingException.java b/openjdk/icedtea/jce/javax/crypto/NoSuchPaddingException.java
deleted file mode 100644
index 57ada3c5..00000000
--- a/openjdk/icedtea/jce/javax/crypto/NoSuchPaddingException.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/* NoSuchPaddingException.java -- Signals an unknown padding scheme.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.GeneralSecurityException;
-
-/**
- * This exception is thrown when a particular padding scheme is
- * requested but is not available.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class NoSuchPaddingException extends GeneralSecurityException
-{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /** Serialization constant. */
- private static final long serialVersionUID = -4572885201200175466L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- public NoSuchPaddingException()
- {
- super();
- }
-
- public NoSuchPaddingException(String message)
- {
- super(message);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/NullCipher.java b/openjdk/icedtea/jce/javax/crypto/NullCipher.java
deleted file mode 100644
index 1913afb3..00000000
--- a/openjdk/icedtea/jce/javax/crypto/NullCipher.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/* NullCipher.java -- The identity cipher.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-/**
- * Trivial subclass of Cipher that implements the identity
- * transformation, where the input is always copied to the output
- * unchanged. Null ciphers can be instantiated with the public
- * constructor.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class NullCipher extends Cipher
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new identity cipher.
- */
- public NullCipher()
- {
- super(new NullCipherImpl(), null, "NULL");
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/NullCipherImpl.java b/openjdk/icedtea/jce/javax/crypto/NullCipherImpl.java
deleted file mode 100644
index 2ff5e0e7..00000000
--- a/openjdk/icedtea/jce/javax/crypto/NullCipherImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/* NullCipherImpl.java -- implementation of NullCipher.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.AlgorithmParameters;
-import java.security.Key;
-import java.security.SecureRandom;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * Implementation of the identity cipher.
- */
-final class NullCipherImpl extends CipherSpi
-{
-
- // Constructor.
- // -------------------------------------------------------------------------
-
- NullCipherImpl()
- {
- super();
- }
-
- // Instance methods.
- // -------------------------------------------------------------------------
-
- protected void engineSetMode(String mode) { }
- protected void engineSetPadding(String padding) { }
-
- protected int engineGetBlockSize()
- {
- return 1;
- }
-
- protected int engineGetOutputSize(int inputLen)
- {
- return inputLen;
- }
-
- protected byte[] engineGetIV()
- {
- return null;
- }
-
- protected AlgorithmParameters engineGetParameters()
- {
- return null;
- }
-
- protected void engineInit(int mode, Key key, SecureRandom random) { }
- protected void engineInit(int mode, Key key, AlgorithmParameterSpec spec, SecureRandom random) { }
- protected void engineInit(int mode, Key key, AlgorithmParameters params, SecureRandom random) { }
-
- protected byte[] engineUpdate(byte[] input, int inputOffset, int inputLen)
- {
- if (input == null)
- return new byte[0];
- if (inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length)
- throw new ArrayIndexOutOfBoundsException();
- byte[] output = new byte[inputLen];
- System.arraycopy(input, inputOffset, output, 0, inputLen);
- return output;
- }
-
- protected int engineUpdate(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset)
- throws ShortBufferException
- {
- if (input == null)
- return 0;
- if (inputOffset < 0 || inputLen < 0 || inputOffset + inputLen > input.length
- || outputOffset < 0)
- throw new ArrayIndexOutOfBoundsException();
- if (output.length - outputOffset < inputLen)
- throw new ShortBufferException();
- System.arraycopy(input, inputOffset, output, outputOffset, inputLen);
- return inputLen;
- }
-
- protected byte[] engineDoFinal(byte[] input, int inputOffset, int inputLen)
- {
- return engineUpdate(input, inputOffset, inputLen);
- }
-
- protected int engineDoFinal(byte[] input, int inputOffset, int inputLen,
- byte[] output, int outputOffset)
- throws ShortBufferException
- {
- return engineUpdate(input, inputOffset, inputLen, output, outputOffset);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/SealedObject.java b/openjdk/icedtea/jce/javax/crypto/SealedObject.java
deleted file mode 100644
index 0f28f333..00000000
--- a/openjdk/icedtea/jce/javax/crypto/SealedObject.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/* SealedObject.java -- An encrypted Serializable object.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-import java.security.AlgorithmParameters;
-import java.security.InvalidAlgorithmParameterException;
-import java.security.InvalidKeyException;
-import java.security.Key;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-
-/**
- * This class allows any {@link java.io.Serializable} object to be
- * stored in an encrypted form.
- *
- *
When the sealed object is ready to be unsealed (and deserialized)
- * the caller may use either
- *
- *
- * - {@link #getObject(javax.crypto.Cipher)}, which uses an
- * already-initialized {@link javax.crypto.Cipher}.
- *
- * or,
- *
- * - {@link #getObject(java.security.Key)} or {@link
- * #getObject(java.security.Key,java.lang.String)}, which will
- * initialize a new cipher instance with the {@link #encodedParams} that
- * were stored with this sealed object (this is so parameters, such as
- * the IV, don't need to be known by the one unsealing the object).
- *
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class SealedObject implements Serializable
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- /** The encoded algorithm parameters. */
- protected byte[] encodedParams;
-
- /** The serialized, encrypted object. */
- private byte[] encryptedContent;
-
- /** The algorithm used to seal the object. */
- private String sealAlg;
-
- /** The parameter type. */
- private String paramsAlg;
-
- /** The cipher that decrypts when this object is unsealed. */
- private transient Cipher sealCipher;
-
- /** Compatible with JDK1.4. */
- private static final long serialVersionUID = 4482838265551344752L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new sealed object from a {@link java.io.Serializable}
- * object and a cipher.
- *
- * @param object The object to seal.
- * @param cipher The cipher to encrypt with.
- * @throws java.io.IOException If serializing the object fails.
- * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
- * padding and the size of the serialized representation of the
- * object is not a multiple of the cipher's block size.
- */
- public SealedObject(Serializable object, Cipher cipher)
- throws IOException, IllegalBlockSizeException
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ObjectOutputStream oos = new ObjectOutputStream(baos);
- oos.writeObject(object);
- oos.flush();
- try
- {
- encryptedContent = cipher.doFinal(baos.toByteArray());
- }
- catch (IllegalStateException ise)
- {
- throw new IOException("cipher not in proper state");
- }
- catch (BadPaddingException bpe)
- {
- throw new IOException(
- "encrypting but got javax.crypto.BadPaddingException");
- }
- sealAlg = cipher.getAlgorithm();
- encodedParams = cipher.getParameters().getEncoded();
- paramsAlg = cipher.getParameters().getAlgorithm();
- }
-
- /**
- * Create a new sealed object from another sealed object.
- *
- * @param so The other sealed object.
- */
- protected SealedObject(SealedObject so)
- {
- this.encodedParams = (byte[]) so.encodedParams.clone();
- this.encryptedContent = (byte[]) so.encryptedContent.clone();
- this.sealAlg = so.sealAlg;
- this.paramsAlg = so.paramsAlg;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the name of the algorithm used to seal this object.
- *
- * @return The algorithm's name.
- */
- public final String getAlgorithm()
- {
- return sealAlg;
- }
-
- /**
- * Unseal and deserialize this sealed object with a specified (already
- * initialized) cipher.
- *
- * @param cipher The cipher to decrypt with.
- * @return The original object.
- * @throws java.io.IOException If reading fails.
- * @throws java.lang.ClassNotFoundException If deserialization fails.
- * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
- * padding and the encrypted data is not a multiple of the
- * cipher's block size.
- * @throws javax.crypto.BadPaddingException If the padding bytes are
- * incorrect.
- */
- public final Object getObject(Cipher cipher)
- throws IOException, ClassNotFoundException, IllegalBlockSizeException,
- BadPaddingException
- {
- sealCipher = cipher;
- return unseal();
- }
-
- /**
- * Unseal and deserialize this sealed object with the specified key.
- *
- * @param key The key to decrypt with.
- * @return The original object.
- * @throws java.io.IOException If reading fails.
- * @throws java.lang.ClassNotFoundException If deserialization fails.
- * @throws java.security.InvalidKeyException If the supplied key
- * cannot be used to unseal this object.
- * @throws java.security.NoSuchAlgorithmException If the algorithm
- * used to originally seal this object is not available.
- */
- public final Object getObject(Key key)
- throws IOException, ClassNotFoundException, InvalidKeyException,
- NoSuchAlgorithmException
- {
- try
- {
- if (sealCipher == null)
- sealCipher = Cipher.getInstance(sealAlg);
- }
- catch (NoSuchPaddingException nspe)
- {
- throw new NoSuchAlgorithmException(nspe.getMessage());
- }
- AlgorithmParameters params = null;
- if (encodedParams != null)
- {
- params = AlgorithmParameters.getInstance(paramsAlg);
- params.init(encodedParams);
- }
- try
- {
- sealCipher.init(Cipher.DECRYPT_MODE, key, params);
- return unseal();
- }
- catch (InvalidAlgorithmParameterException iape)
- {
- throw new IOException("bad parameters");
- }
- catch (IllegalBlockSizeException ibse)
- {
- throw new IOException("illegal block size");
- }
- catch (BadPaddingException bpe)
- {
- throw new IOException("bad padding");
- }
- }
-
- /**
- * Unseal and deserialize this sealed object with the specified key,
- * using a cipher from the named provider.
- *
- * @param key The key to decrypt with.
- * @param provider The name of the provider to use.
- * @return The original object.
- * @throws java.io.IOException If reading fails.
- * @throws java.lang.ClassNotFoundException If deserialization fails.
- * @throws java.security.InvalidKeyException If the supplied key
- * cannot be used to unseal this object.
- * @throws java.security.NoSuchAlgorithmException If the algorithm
- * used to originally seal this object is not available from
- * the named provider.
- * @throws java.security.NoSuchProviderException If the named provider
- * does not exist.
- */
- public final Object getObject(Key key, String provider)
- throws IOException, ClassNotFoundException, InvalidKeyException,
- NoSuchAlgorithmException, NoSuchProviderException
- {
- try
- {
- sealCipher = Cipher.getInstance(sealAlg, provider);
- }
- catch (NoSuchPaddingException nspe)
- {
- throw new NoSuchAlgorithmException(nspe.getMessage());
- }
- AlgorithmParameters params = null;
- if (encodedParams != null)
- {
- params = AlgorithmParameters.getInstance(paramsAlg, provider);
- params.init(encodedParams);
- }
- try
- {
- sealCipher.init(Cipher.DECRYPT_MODE, key, params);
- return unseal();
- }
- catch (InvalidAlgorithmParameterException iape)
- {
- throw new IOException("bad parameters");
- }
- catch (IllegalBlockSizeException ibse)
- {
- throw new IOException("illegal block size");
- }
- catch (BadPaddingException bpe)
- {
- throw new IOException("bad padding");
- }
- }
-
- // Own methods.
- // ------------------------------------------------------------------------
-
- /**
- * Deserialize this object.
- *
- * @param ois The input stream.
- * @throws java.io.IOException If reading fails.
- * @throws java.lang.ClassNotFoundException If reading fails.
- */
- private void readObject(ObjectInputStream ois)
- throws IOException, ClassNotFoundException
- {
- encodedParams = (byte[]) ois.readObject();
- encryptedContent = (byte[]) ois.readObject();
- sealAlg = (String) ois.readObject();
- paramsAlg = (String) ois.readObject();
- }
-
- /**
- * Serialize this object.
- *
- * @param oos The output stream.
- * @throws java.io.IOException If writing fails.
- */
- private void writeObject(ObjectOutputStream oos)
- throws IOException
- {
- oos.writeObject(encodedParams);
- oos.writeObject(encryptedContent);
- oos.writeObject(sealAlg);
- oos.writeObject(paramsAlg);
- }
-
- /**
- * Unseal this object, returning it.
- *
- * @return The unsealed, deserialized Object.
- * @throws java.io.IOException If reading fails.
- * @throws java.io.ClassNotFoundException If reading fails.
- * @throws javax.crypto.IllegalBlockSizeException If the cipher has no
- * padding and the encrypted data is not a multiple of the
- * cipher's block size.
- * @throws javax.crypto.BadPaddingException If the padding bytes are
- * incorrect.
- */
- private Object unseal()
- throws IOException, ClassNotFoundException, IllegalBlockSizeException,
- BadPaddingException
- {
- ByteArrayInputStream bais = null;
- try
- {
- bais = new ByteArrayInputStream(sealCipher.doFinal(encryptedContent));
- }
- catch (IllegalStateException ise)
- {
- throw new IOException("cipher not initialized");
- }
- ObjectInputStream ois = new ObjectInputStream(bais);
- return ois.readObject();
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/SecretKey.java b/openjdk/icedtea/jce/javax/crypto/SecretKey.java
deleted file mode 100644
index 5f95a1a0..00000000
--- a/openjdk/icedtea/jce/javax/crypto/SecretKey.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/* SecretKey.java -- A key for symmetric cryptography.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.Key;
-
-/**
- * A secret key for symmetric cryptography.
- *
- * This interface defines no new methods over {@link
- * java.security.Key}, but rather is intended to be a marker
- * interface and to provide type safety for secret keys.
- *
- * The format of secret keys should be RAW
, as returned
- * by {@link java.security.Key#getFormat()}.
- *
- * Concrete implementations of this interface should override the
- * {@link java.lang.Object#equals} and {@link java.lang.Object#hashCode}
- * methods of {@link java.lang.Object} to use the actual key data rather
- * than the identity-based default methods.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @see javax.crypto.SecretKeyFactory
- * @see javax.crypto.Cipher
- */
-public interface SecretKey extends Key
-{
- long serialVersionUID = -4795878709595146952L;
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/SecretKeyFactory.java b/openjdk/icedtea/jce/javax/crypto/SecretKeyFactory.java
deleted file mode 100644
index 1c857d27..00000000
--- a/openjdk/icedtea/jce/javax/crypto/SecretKeyFactory.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/* SecretKeyFactory.java -- Factory for creating secret keys.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import gnu.java.security.Engine;
-
-import java.lang.reflect.InvocationTargetException;
-import java.security.InvalidKeyException;
-import java.security.NoSuchAlgorithmException;
-import java.security.NoSuchProviderException;
-import java.security.Provider;
-import java.security.Security;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-/**
- * A secret key factory translates {@link SecretKey} objects to and from
- * {@link java.security.spec.KeySpec} objects, and can translate between
- * different vendors' representations of {@link SecretKey} objects (for
- * security or semantics; whichever applies).
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see SecretKey
- */
-public class SecretKeyFactory
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- private static final String SERVICE = "SecretKeyFactory";
-
- /** The underlying factory implementation. */
- private SecretKeyFactorySpi skfSpi;
-
- /** The provider of the implementation. */
- private Provider provider;
-
- /** The name of the algorithm. */
- private String algorithm;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new secret key factory.
- *
- * @param skfSpi The underlying factory implementation.
- * @param provider The provider.
- * @param algorithm The algorithm name.
- */
- protected SecretKeyFactory(SecretKeyFactorySpi skfSpi, Provider provider,
- String algorithm)
- {
- this.skfSpi = skfSpi;
- this.provider = provider;
- this.algorithm = algorithm;
- }
-
- /**
- * Create a new secret key factory from the first appropriate instance.
- *
- * @param algorithm The algorithm name.
- * @return The appropriate key factory, if found.
- * @throws NoSuchAlgorithmException If no provider implements the specified
- * algorithm.
- * @throws IllegalArgumentException if algorithm
is
- * null
or is an empty string.
- */
- public static final SecretKeyFactory getInstance(String algorithm)
- throws NoSuchAlgorithmException
- {
- Provider[] p = Security.getProviders();
- NoSuchAlgorithmException lastException = null;
- for (int i = 0; i < p.length; i++)
- try
- {
- return getInstance(algorithm, p[i]);
- }
- catch (NoSuchAlgorithmException x)
- {
- lastException = x;
- }
- if (lastException != null)
- throw lastException;
- throw new NoSuchAlgorithmException(algorithm);
- }
-
- /**
- * Create a new secret key factory from the named provider.
- *
- * @param algorithm The algorithm name.
- * @param provider The provider name.
- * @return The appropriate key factory, if found.
- * @throws NoSuchAlgorithmException If the named provider does not implement
- * the algorithm.
- * @throws NoSuchProviderException If the named provider does not exist.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final SecretKeyFactory getInstance(String algorithm,
- String provider)
- throws NoSuchAlgorithmException, NoSuchProviderException
- {
- if (provider == null)
- throw new IllegalArgumentException("provider MUST NOT be null");
- Provider p = Security.getProvider(provider);
- if (p == null)
- throw new NoSuchProviderException(provider);
- return getInstance(algorithm, p);
- }
-
- /**
- * Create a new secret key factory from the specified provider.
- *
- * @param algorithm The algorithm name.
- * @param provider The provider.
- * @return The appropriate key factory, if found.
- * @throws NoSuchAlgorithmException If the provider does not implement the
- * algorithm.
- * @throws IllegalArgumentException if either algorithm
or
- * provider
is null
, or if
- * algorithm
is an empty string.
- */
- public static final SecretKeyFactory getInstance(String algorithm,
- Provider provider)
- throws NoSuchAlgorithmException
- {
- StringBuilder sb = new StringBuilder("SecretKeyFactory algorithm [")
- .append(algorithm).append("] from provider[")
- .append(provider).append("] could not be created");
- Throwable cause;
- try
- {
- Object spi = Engine.getInstance(SERVICE, algorithm, provider);
- return new SecretKeyFactory((SecretKeyFactorySpi) spi, provider, algorithm);
- }
- catch (InvocationTargetException x)
- {
- cause = x.getCause();
- if (cause instanceof NoSuchAlgorithmException)
- throw (NoSuchAlgorithmException) cause;
- if (cause == null)
- cause = x;
- }
- catch (ClassCastException x)
- {
- cause = x;
- }
- NoSuchAlgorithmException x = new NoSuchAlgorithmException(sb.toString());
- x.initCause(cause);
- throw x;
- }
-
- /**
- * Generate a secret key from a key specification, if possible.
- *
- * @param keySpec The key specification.
- * @return The secret key.
- * @throws java.security.InvalidKeySpecException If the key specification
- * cannot be transformed into a secret key.
- */
- public final SecretKey generateSecret(KeySpec keySpec)
- throws InvalidKeySpecException
- {
- return skfSpi.engineGenerateSecret(keySpec);
- }
-
- /**
- * Get the algorithm name.
- *
- * @return The algorithm name.
- */
- public final String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Get the key specification from a secret key.
- *
- * @param key The secret key.
- * @param keySpec The target key specification class.
- * @return The key specification.
- * @throws java.security.spec.InvalidKeySpecException If the secret key cannot
- * be transformed into the specified key specification.
- */
- public final KeySpec getKeySpec(SecretKey key, Class keySpec)
- throws InvalidKeySpecException
- {
- return skfSpi.engineGetKeySpec(key, keySpec);
- }
-
- /**
- * Get the provider of this implementation.
- *
- * @return The provider.
- */
- public final Provider getProvider()
- {
- return provider;
- }
-
- /**
- * Translate a secret key into another form.
- *
- * @param key The key to translate.
- * @return The translated key.
- * @throws java.security.InvalidKeyException If the argument cannot be
- * translated.
- */
- public final SecretKey translateKey(SecretKey key)
- throws InvalidKeyException
- {
- return skfSpi.engineTranslateKey(key);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/SecretKeyFactorySpi.java b/openjdk/icedtea/jce/javax/crypto/SecretKeyFactorySpi.java
deleted file mode 100644
index 6c9a3ca2..00000000
--- a/openjdk/icedtea/jce/javax/crypto/SecretKeyFactorySpi.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/* SecretKeyFactorySpi.java -- Secret key factory service provider interface.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.InvalidKeyException;
-import java.security.spec.InvalidKeySpecException;
-import java.security.spec.KeySpec;
-
-/**
- * The Service Provider Interface (SPI) for the {@link
- * SecretKeyFactory} class.
- *
- * Providers wishing to implement a secret key factory must
- * subclass this and provide an appropriate implementation for all the
- * abstract methods below, and provide an appropriate entry in the
- * master {@link java.security.Provider} class (the service name for
- * secret key factories is "SecretKeyFactory"
).
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see SecretKeyFactory
- */
-public abstract class SecretKeyFactorySpi
-{
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new secret key factory SPI.
- */
- public SecretKeyFactorySpi()
- {
- }
-
- // Abstract instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Translate a {@link java.security.KeySpec} into a {@link SecretKey}.
- *
- * @param keySpec The key specification.
- * @return The secret key.
- * @throws java.security.spec.InvalidKeySpecException If the key specification
- * cannot be translated into a secret key.
- */
- protected abstract SecretKey engineGenerateSecret(KeySpec keySpec)
- throws InvalidKeySpecException;
-
- /**
- * Translate a {@link SecretKey} into a {@link java.security.KeySpec}.
- *
- * @param key The secret key.
- * @param keySpec The desired key specification class.
- * @return The key specification.
- * @throws java.security.spec.InvalidKeySpecException If the secret key cannot
- * be translated into the desired key specification.
- */
- protected abstract KeySpec engineGetKeySpec(SecretKey key, Class keySpec)
- throws InvalidKeySpecException;
-
- /**
- * Translate a secret key into a different representation.
- *
- * @param key The secret key to translate.
- * @return The translated key.
- * @throws java.security.InvalidKeyException If the specified secret
- * key cannot be translated.
- */
- protected abstract SecretKey engineTranslateKey(SecretKey key)
- throws InvalidKeyException;
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/ShortBufferException.java b/openjdk/icedtea/jce/javax/crypto/ShortBufferException.java
deleted file mode 100644
index 98d2101c..00000000
--- a/openjdk/icedtea/jce/javax/crypto/ShortBufferException.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/* ShortBufferException.java -- Signals a short output buffer.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto;
-
-import java.security.GeneralSecurityException;
-
-/**
- * This exception is thrown on an attempt to transform bytes into a
- * buffer that is too short to contain the data.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class ShortBufferException extends GeneralSecurityException
-{
-
- // Constant.
- // ------------------------------------------------------------------------
-
- /** Serialization constant. */
- private static final long serialVersionUID = 8427718640832943747L;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- public ShortBufferException()
- {
- super();
- }
-
- public ShortBufferException(String message)
- {
- super(message);
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/interfaces/DHKey.java b/openjdk/icedtea/jce/javax/crypto/interfaces/DHKey.java
deleted file mode 100644
index 0c3ec97e..00000000
--- a/openjdk/icedtea/jce/javax/crypto/interfaces/DHKey.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/* DHKey.java -- General interface for a Diffie-Hellman key.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.interfaces;
-
-import javax.crypto.spec.DHParameterSpec;
-
-/**
- * This interface marks public/private keys in the Diffie-Hellman key
- * exchange algorithm. Implementations of Diffie-Hellman keys should
- * implement this interface, and applications can safely cast keys that
- * are known to be Diffie-Hellman keys to this interface.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public interface DHKey
-{
- /**
- * Returns the Diffie-Hellman parameters for this key, which includes
- * the generator and the prime.
- *
- * @return The Diffie-Hellman parameters.
- */
- DHParameterSpec getParams();
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/interfaces/DHPrivateKey.java b/openjdk/icedtea/jce/javax/crypto/interfaces/DHPrivateKey.java
deleted file mode 100644
index 12077bad..00000000
--- a/openjdk/icedtea/jce/javax/crypto/interfaces/DHPrivateKey.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* DHPrivateKey.java -- A Diffie-Hellman private key.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.interfaces;
-
-import java.math.BigInteger;
-import java.security.PrivateKey;
-
-/**
- * This interface marks a private key in the Diffie-Hellman key exchange
- * algorithm. It should be treated with as much care as any {@link
- * java.security.PrivateKey}.
- *
- *
Implementations of Diffie-Hellman private keys should implement
- * this interface. Applications that know a particular key is a
- * Diffie-Hellman private key can safely cast it to this interface.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see DHKey
- * @see DHPublicKey
- */
-public interface DHPrivateKey extends DHKey, PrivateKey
-{
- /** Compatible with JDK1.4. */
- long serialVersionUID = 2211791113380396553L;
-
- /**
- * Returns the private value x.
- *
- * @return The private value x.
- */
- BigInteger getX();
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/interfaces/DHPublicKey.java b/openjdk/icedtea/jce/javax/crypto/interfaces/DHPublicKey.java
deleted file mode 100644
index d0519d4d..00000000
--- a/openjdk/icedtea/jce/javax/crypto/interfaces/DHPublicKey.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/* DHPublicKey.java -- A Diffie-Hellman public key.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.interfaces;
-
-import java.math.BigInteger;
-import java.security.PublicKey;
-
-/**
- * This interface marks a public key in the Diffie-Hellman key-exchange
- * algorithm.
- *
- *
Implementations of Diffie-Hellman public keys should implement
- * this interface. Applications that know that a particular key is a
- * Diffie-Hellman public key it can be safely cast to this interface.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see DHKey
- * @see DHPrivateKey
- */
-public interface DHPublicKey extends DHKey, PublicKey
-{
- /** Compatible with JDK1.4. */
- long serialVersionUID = -6628103563352519193L;
-
- /**
- * Get the public value y.
- *
- * @return The public value y.
- */
- BigInteger getY();
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/interfaces/PBEKey.java b/openjdk/icedtea/jce/javax/crypto/interfaces/PBEKey.java
deleted file mode 100644
index df7f2e2b..00000000
--- a/openjdk/icedtea/jce/javax/crypto/interfaces/PBEKey.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/* PBEKey.java -- A key derived from a password.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.interfaces;
-
-import javax.crypto.SecretKey;
-
-/**
- * Interface to a password-derived key for password-based encryption
- * (PBE). Applications working with a {@link javax.crypto.SecretKey}
- * that is known to be a password-based key can safely cast such keys to
- * this interface.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public interface PBEKey extends SecretKey
-{
- /** Compatible with JDK1.4. */
- long serialVersionUID = -1430015993304333921L;
-
- /**
- * Retruns the iteration count, or 0 if not specified.
- *
- * @return The iteration count.
- */
- int getIterationCount();
-
- /**
- * Returns a copy of the password as a character array. It is the
- * caller's responsibility to zero-out the password when it is no
- * longer in use.
- *
- *
Although it is not specified in the documentation,
- * implementations should not copy or clone the password array, but
- * rather return the reference to the array itself, so the caller has
- * the ability to erase the password.
- *
- * @return The password.
- */
- char[] getPassword();
-
- /**
- * Returns a copy of the salt. It is the caller's responsibility to
- * zero-out the salt when it is no longer in use.
- *
- *
Although it is not specified in the documentation,
- * implementations should not copy or clone the salt array, but
- * rather return the reference to the array itself, so the caller has
- * the ability to erase the salt.
- *
- * @return The salt.
- */
- byte[] getSalt();
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DESKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DESKeySpec.java
deleted file mode 100644
index 9075a77d..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DESKeySpec.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/* DESKeySpec -- Keys for DES.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.InvalidKeyException;
-import java.security.spec.KeySpec;
-
-/**
- * This class is a transparent wrapper for DES keys, which are arrays
- * of 8 bytes.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class DESKeySpec implements KeySpec
-{
-
- // Constants.
- // ------------------------------------------------------------------------
-
- /**
- * The length of a DES key, in bytes.
- */
- public static final int DES_KEY_LEN = 8;
-
- /**
- * The key bytes.
- */
- private byte[] key;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new DES key spec, copying the first 8 bytes from the
- * byte array.
- *
- * @param key The key bytes.
- * @throws java.security.InvalidKeyException If there are less than 8
- * bytes in the array.
- */
- public DESKeySpec(byte[] key) throws InvalidKeyException
- {
- this(key, 0);
- }
-
- /**
- * Create a new DES key spec, starting at offset
in
- * the byte array. The first 8 bytes starting at offset
- * are copied.
- *
- * @param key The key bytes.
- * @param offset The offset into the byte array at which to begin.
- * @throws java.security.InvalidKeyException If there are less than 8
- * bytes starting at offset
.
- */
- public DESKeySpec(byte[] key, int offset) throws InvalidKeyException
- {
- if (key.length - offset < DES_KEY_LEN)
- {
- throw new InvalidKeyException("DES keys must be 8 bytes long");
- }
- this.key = new byte[DES_KEY_LEN];
- System.arraycopy(key, offset, this.key, 0, DES_KEY_LEN);
- }
-
- // Class methods.
- // ------------------------------------------------------------------------
-
- /**
- * Returns whether or not the given key is parity adjusted;
- * i.e. every byte in the key has an odd number of "1" bits.
- *
- * @param key The key bytes, considered between [offset,
- * offset+7]
- * @param offset The offset into the byte array at which to begin.
- * @return True if all bytes have an odd number of "1" bits.
- * @throws java.security.InvalidKeyException If there are not enough
- * bytes in the array.
- */
- public static boolean isParityAdjusted(byte[] key, int offset)
- throws InvalidKeyException
- {
- if (key.length - offset < DES_KEY_LEN)
- {
- throw new InvalidKeyException("DES keys must be 8 bytes long");
- }
- boolean parity = false;
- boolean oddbits = false;
- for (int i = 0; i < DES_KEY_LEN; i++)
- {
- oddbits = false;
- for (int j = 0; j < 8; j++)
- {
- oddbits ^= (key[i+offset] & 1 << j) != 0;
- }
- parity &= oddbits;
- }
- return parity;
- }
-
- /**
- * One-half of the weak and semiweak DES keys (the other half are the
- * complements of these).
- */
- private static final byte[][] WEAK_KEYS = new byte[][] {
- { 0, 0, 0, 0, 0, 0, 0, 0 }, // 0000 0000 0000 0000
- { -1, -1, -1, -1, 0, 0, 0, 0 }, // ffff ffff 0000 0000
- { 1, 1, 1, 1, 1, 1, 1, 1 }, // 0101 0101 0101 0101
- { 31, 31, 31, 31, 14, 14, 14, 14 }, // 1f1f 1f1f 0e0e 0e0e
- { 1, -2, 1, -2, 1, -2, 1, -2 }, // 01fe 01fe 01fe 01fe
- { 31, -32, 31, -32, -32, 31, -32, 31 }, // 1fe0 1fe0 0e1f 0e1f
- { 1, -32, 1, -32, 1, -15, 1, -15 }, // 01e0 01e0 01f1 01f1
- { 31, -2, 31, -2, 14, -2, 14, -2 }, // 1ffe 1ffe 0efe 0efe
- { 1, 31, 1, 31, 1, 14, 1, 14 }, // 011f 011f 010e 010e
- { -32, -2, -32, -2, -15, -2, -15, -2 }, // e0fe e0fe f1fe f1fe
- };
-
- /**
- * Tests if the bytes between [offset, offset+7]
- * constitute a weak or semi-weak DES key.
- *
- * @param key The key bytes to check.
- * @param offset The offset in the byte array to start.
- * @return true If the key bytes are a weak key.
- */
- public static boolean isWeak(byte[] key, int offset)
- throws InvalidKeyException
- {
- if (key.length - offset < DES_KEY_LEN)
- {
- throw new InvalidKeyException("DES keys must be 8 bytes long");
- }
- for (int i = 0; i < WEAK_KEYS.length; i++)
- {
- if (equalsOrComplementEquals(key, offset, WEAK_KEYS[i]))
- {
- return true;
- }
- }
- return false;
- }
-
- /**
- * This method returns true if the first 8 bytes starting at
- * off
in a
equal the first 8 bytes in
- * b
, or equal the complement of the first 8 bytes
- * in b
.
- *
- * @param a The first byte array.
- * @param off The index into the first byte array.
- * @param b The second byte array.
- * @return a == b || a == ~b
- */
- private static boolean equalsOrComplementEquals(byte[] a, int off, byte[] b)
- {
- boolean result = true;
- for (int i = 0; i < DES_KEY_LEN; i++)
- {
- result &= a[off+i] == b[i];
- }
- if (result) return true;
- result = true;
- for (int i = 0; i < DES_KEY_LEN; i++)
- {
- result &= a[off+i] == (~b[i]);
- }
- return result;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return the key as a byte array. This method does not copy the byte
- * array.
- *
- * @return The key bytes.
- */
- public byte[] getKey()
- {
- return key;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DESedeKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DESedeKeySpec.java
deleted file mode 100644
index 1f6a2502..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DESedeKeySpec.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/* DESedeKeySpec.java -- Keys for triple-DES.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.InvalidKeyException;
-import java.security.spec.KeySpec;
-
-/**
- * This class is a transparent wrapper for DES-EDE (Triple-DES) keys,
- * which are arrays of 24 bytes.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class DESedeKeySpec implements KeySpec
-{
-
- // Constants.
- // ------------------------------------------------------------------------
-
- /**
- * The length of a triple-DES key, in bytes.
- */
- public static final int DES_EDE_KEY_LEN = 24;
-
- /**
- * The key bytes.
- */
- private byte[] key;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new DES-EDE key spec, copying the first 24 bytes from the
- * byte array.
- *
- * @param key The key bytes.
- * @throws java.security.InvalidKeyException If there are less than 24
- * bytes in the array.
- */
- public DESedeKeySpec(byte[] key) throws InvalidKeyException
- {
- this(key, 0);
- }
-
- /**
- * Create a new DES-EDE key spec, starting at offset
in
- * the byte array. The first 24 bytes starting at offset
- * are copied.
- *
- * @param key The key bytes.
- * @param offset The offset into the byte array at which to begin.
- * @throws java.security.InvalidKeyException If there are less than 24
- * bytes starting at offset
.
- */
- public DESedeKeySpec(byte[] key, int offset) throws InvalidKeyException
- {
- if (key.length - offset < DES_EDE_KEY_LEN)
- {
- throw new InvalidKeyException("DES-EDE keys must be 24 bytes long");
- }
- this.key = new byte[DES_EDE_KEY_LEN];
- System.arraycopy(key, offset, this.key, 0, DES_EDE_KEY_LEN);
- }
-
- // Class methods.
- // ------------------------------------------------------------------------
-
- /**
- * Returns whether or not the given key is parity adjusted;
- * i.e. every byte in the key has an odd number of "1" bits.
- *
- * @param key The key bytes, considered between [offset,
- * offset+23]
- * @param offset The offset into the byte array at which to begin.
- * @return True if all bytes have an odd number of "1" bits.
- * @throws java.security.InvalidKeyException If there are not enough
- * bytes in the array.
- */
- public static boolean isParityAdjusted(byte[] key, int offset)
- throws InvalidKeyException
- {
- if (key.length - offset < DES_EDE_KEY_LEN)
- {
- throw new InvalidKeyException("DES-EDE keys must be 24 bytes long");
- }
- boolean parity = false;
- boolean oddbits = false;
- for (int i = 0; i < DES_EDE_KEY_LEN; i++)
- {
- oddbits = false;
- for (int j = 0; j < 8; j++)
- {
- oddbits ^= (key[i+offset] & 1 << j) != 0;
- }
- parity &= oddbits;
- }
- return parity;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return the key as a byte array. This method does not copy the byte
- * array.
- *
- * @return The key bytes.
- */
- public byte[] getKey()
- {
- return key;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DHGenParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DHGenParameterSpec.java
deleted file mode 100644
index 0fc8ed58..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DHGenParameterSpec.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/* DHGenParameterSpec.java -- Diffie-Hellman parameter generator spec.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * This class represents the parameters needed for generating
- * Diffie-Hellman parameters.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see DHParameterSpec
- */
-public class DHGenParameterSpec implements AlgorithmParameterSpec
-{
-
- // Variables.
- // ------------------------------------------------------------------------
-
- /** The length of the prime, in bits. */
- private int primeSize;
-
- /** The length of the exponent, in bits. */
- private int exponentSize;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new Diffie-Hellman parameter generator spec.
- *
- * @param primeSize The size of the prime, in bits.
- * @param exponentSize The size of the exponent, in bits.
- */
- public DHGenParameterSpec(int primeSize, int exponentSize)
- {
- this.primeSize = primeSize;
- this.exponentSize = exponentSize;
- }
-
- // Intance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the size of the exponent, in bits.
- *
- * @return The exponent size.
- */
- public int getExponentSize()
- {
- return exponentSize;
- }
-
- /**
- * Get the size of the prime, in bits.
- *
- * @return The prime size.
- */
- public int getPrimeSize()
- {
- return primeSize;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DHParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DHParameterSpec.java
deleted file mode 100644
index 4db82870..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DHParameterSpec.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/* DHParameterSpec.java -- Parameters for Diffie-Hellman keys.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.math.BigInteger;
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * The base set of parameters necessary to perform Diffie-Hellman key
- * exchange. Each party in the key exchange shares these parameters.
- *
- *
Each set of parameters consists of a base generator
- * g
, a prime modulus p
, and an
- * optional length, in bits, of the private exponent.
- *
- *
See PKCS
- * #3 - Diffie-Hellman Key Agreement Standard for more information.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see javax.crypto.KeyAgreement
- */
-public class DHParameterSpec implements AlgorithmParameterSpec
-{
-
- // Variables.
- // ------------------------------------------------------------------------
-
- /** The base generator g. */
- private BigInteger g;
-
- /** The prime modulus p. */
- private BigInteger p;
-
- /** The length, in bits, of the private exponent. */
- private int l;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new set of Diffie-Hellman parameters.
- *
- * @param p The prime modulus.
- * @param g The base generator.
- */
- public DHParameterSpec(BigInteger p, BigInteger g)
- {
- this(p, g, 0);
- }
-
- /**
- * Create a new set of Diffie-Hellman parameters.
- *
- * @param p The prime modulus.
- * @param g The base generator.
- * @param l The size of the private exponent, in bits.
- */
- public DHParameterSpec(BigInteger p, BigInteger g, int l)
- {
- this.p = p;
- this.g = g;
- this.l = l;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the base generator, g.
- *
- * @return The base generator g.
- */
- public BigInteger getG()
- {
- return g;
- }
-
- /**
- * Get the length of the private exponent, in bits.
- *
- * @return The length of the private exponent, in bits, or 0 if this
- * has not been explicitly set.
- */
- public int getL()
- {
- return l;
- }
-
- /**
- * Get the prime modulus, p.
- *
- * @return The prime modulus, p.
- */
- public BigInteger getP()
- {
- return p;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DHPrivateKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DHPrivateKeySpec.java
deleted file mode 100644
index 348a1926..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DHPrivateKeySpec.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/* DHPrivateKeySpec.java -- Wrapper for Diffie-Hellman private keys.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-
-/**
- * A wrapper for Diffie-Hellman private key data.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see DHPublicKeySpec
- */
-public class DHPrivateKeySpec implements KeySpec
-{
-
- // Variables.
- // ------------------------------------------------------------------------
-
- /** The base generator. */
- private BigInteger g;
-
- /** The prime modulus. */
- private BigInteger p;
-
- /** The private exponent. */
- private BigInteger x;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new Diffie-Hellman private key spec.
- *
- * @param x The private exponent.
- * @param p The prime modulus.
- * @param g The base generator.
- */
- public DHPrivateKeySpec(BigInteger x, BigInteger p, BigInteger g)
- {
- this.x = x;
- this.p = p;
- this.g = g;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the base generator.
- *
- * @return The base generator.
- */
- public BigInteger getG()
- {
- return g;
- }
-
- /**
- * Get the prime modulus.
- *
- * @return The prime modulus.
- */
- public BigInteger getP()
- {
- return p;
- }
-
- /**
- * Get the private exponent.
- *
- * @return The private exponent.
- */
- public BigInteger getX()
- {
- return x;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/DHPublicKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/DHPublicKeySpec.java
deleted file mode 100644
index e8187278..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/DHPublicKeySpec.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/* DHPublicKeySpec.java -- Wrapper for Diffie-Hellman public keys.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.math.BigInteger;
-import java.security.spec.KeySpec;
-
-/**
- * A wrapper for Diffie-Hellman public key data.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see DHPrivateKeySpec
- */
-public class DHPublicKeySpec implements KeySpec
-{
-
- // Variables.
- // ------------------------------------------------------------------------
-
- /** The base generator. */
- private BigInteger g;
-
- /** The prime modulus. */
- private BigInteger p;
-
- /** The public value. */
- private BigInteger y;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new Diffie-Hellman public key spec.
- *
- * @param y The public value.
- * @param p The prime modulus.
- * @param g The base generator.
- */
- public DHPublicKeySpec(BigInteger y, BigInteger p, BigInteger g)
- {
- this.y = y;
- this.p = p;
- this.g = g;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the base generator.
- *
- * @return The base generator.
- */
- public BigInteger getG()
- {
- return g;
- }
-
- /**
- * Get the prime modulus.
- *
- * @return The prime modulus.
- */
- public BigInteger getP()
- {
- return p;
- }
-
- /**
- * Get the public value.
- *
- * @return The public value.
- */
- public BigInteger getY()
- {
- return y;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/IvParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/IvParameterSpec.java
deleted file mode 100644
index 3af38f58..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/IvParameterSpec.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/* IvParameterSpec.java -- A simple wrapper for initialization vectors.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * A wrapper for an initialization vector. An initialization vector is
- * necessary for any cipher in any feedback mode, e.g. CBC.
- *
- * @author Casey Marshall (csm@gnu.org)
- */
-public class IvParameterSpec implements AlgorithmParameterSpec
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The IV. */
- private byte[] iv;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new initialization vector spec from an entire byte array.
- *
- * @param iv The IV bytes.
- */
- public IvParameterSpec(byte[] iv)
- {
- this(iv, 0, iv.length);
- }
-
- /**
- * Create a new initialization vector spec from part of a byte array.
- *
- * @param iv The IV bytes.
- * @param off The offset into the IV bytes.
- * @param len The number of IV bytes.
- */
- public IvParameterSpec(byte[] iv, int off, int len)
- {
- this.iv = new byte[len];
- System.arraycopy(iv, off, this.iv, 0, len);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Returns the IV. This method does not copy the byte array.
- *
- * @return The IV.
- */
- public byte[] getIV()
- {
- return iv;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/OAEPParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/OAEPParameterSpec.java
deleted file mode 100644
index 5c2842c6..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/OAEPParameterSpec.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* OAEPParameterSpec.java -- stub file
- Copyright (C) 2007 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-public class OAEPParameterSpec
-{
- private String _mdName;
- private String _mgfName;
-
- private AlgorithmParameterSpec _mgfSpec;
-
- private PSource _pSrc;
-
- public OAEPParameterSpec (String mdName, String mgfName,
- AlgorithmParameterSpec mgfSpec, PSource pSrc)
- {
- _mdName = mdName;
- _mgfName = mgfName;
- _mgfSpec = mgfSpec;
- _pSrc = pSrc;
- }
-
- public String getDigestAlgorithm()
- {
- return _mdName;
- }
-
- public String getMGFAlgorithm()
- {
- return _mgfName;
- }
-
- public AlgorithmParameterSpec getMGFParameters()
- {
- return _mgfSpec;
- }
-
- public PSource getPSource()
- {
- return _pSrc;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/PBEKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/PBEKeySpec.java
deleted file mode 100644
index ba89c0ef..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/PBEKeySpec.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/* PBEKeySpec.java -- Wrapper for password-based keys.
- Copyright (C) 2004, 2006 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.KeySpec;
-
-/**
- * A wrapper for a password-based key, used for password-based
- * encryption (PBE).
- *
- *
Examples of password-based encryption algorithms include:
- *
- *
- * - PKCS #5
- * - Password-Based Cryptography Standard
- * - PKCS
- * #12 - Personal Information Exchange Syntax Standard
- *
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- * @see javax.crypto.SecretKeyFactory
- * @see PBEParameterSpec
- */
-public class PBEKeySpec implements KeySpec
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The iteration count. */
- private int iterationCount;
-
- /** The generated key length. */
- private int keyLength;
-
- /** The password. */
- private char[] password;
-
- /** The salt. */
- private byte[] salt;
-
- /** The password state */
- private boolean passwordValid = true;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new PBE key spec with just a password.
- *
- * A copy of the password argument is stored instead of the argument itself.
- *
- * @param password The password char array.
- */
- public PBEKeySpec(char[] password)
- {
- if (password == null)
- password = new char[0];
-
- setPassword(password.clone());
-
- // load the default values for unspecified variables.
- salt = null;
- iterationCount = 0;
- keyLength = 0;
- }
-
- /**
- * Create a PBE key spec with a password, salt, and iteration count.
- *
- * A copy of the password and salt arguments are stored instead of the
- * arguments themselves.
- *
- * @param password The password char array.
- * @param salt The salt bytes.
- * @param iterationCount The iteration count.
- * @throws NullPointerException If salt is null
- * @throws IllegalArgumentException If salt is an empty array, or
- * iterationCount is negative
- */
- public PBEKeySpec(char[] password, byte[] salt, int iterationCount)
- {
- if (password == null)
- password = new char[0];
-
- setPassword(password.clone());
-
- setSalt(salt.clone());
- setIterationCount(iterationCount);
-
- // load default values into unspecified variables.
- keyLength = 0;
- }
-
- /**
- * Create a PBE key spec with a password, salt, iteration count, and key
- * length.
- *
- * A copy of the password and salt arguments are stored instead of the
- * arguments themselves.
- *
- * @param password The password char array.
- * @param salt The salt bytes.
- * @param iterationCount The iteration count.
- * @param keyLength The generated key length.
- * @throws NullPointerException If salt is null
- * @throws IllegalArgumentException If salt is an empty array, if
- * iterationCount or keyLength is negative
- */
- public PBEKeySpec(char[] password, byte[] salt, int iterationCount,
- int keyLength)
- {
- if (password == null)
- password = new char[0];
-
- setPassword(password.clone());
-
- setSalt(salt.clone());
- setIterationCount(iterationCount);
- setKeyLength(keyLength);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Clear the password array by filling it with null characters.
- *
- * This clears the stored copy of the password, not the original char array
- * used to create the password.
- */
- public final void clearPassword()
- {
- if (password == null)
- return;
- for (int i = 0; i < password.length; i++)
- password[i] = '\u0000';
-
- // since the password is cleared, it is no longer valid
- passwordValid = false;
- }
-
- /**
- * Get the iteration count, or 0 if it has not been specified.
- *
- * @return The iteration count, or 0 if it has not been specified.
- */
- public final int getIterationCount()
- {
- return iterationCount;
- }
-
- /**
- * Get the generated key length, or 0 if it has not been specified.
- *
- * @return The key length, or 0 if it has not been specified.
- */
- public final int getKeyLength()
- {
- return keyLength;
- }
-
- /**
- * Get the password character array copy.
- *
- * This returns a copy of the password, not the password itself.
- *
- * @return a clone of the password.
- * @throws IllegalStateException If {@link #clearPassword()} has already been
- * called.
- */
- public final char[] getPassword()
- {
- if (! passwordValid)
- throw new IllegalStateException("clearPassword() has been called, the "
- + "password is no longer valid");
- return (char[]) password.clone();
- }
-
- /**
- * Get the salt bytes array copy.
- *
- * This returns a copy of the salt, not the salt itself.
- *
- * @return The salt.
- */
- public final byte[] getSalt()
- {
- if (salt != null)
- return (byte[]) salt.clone();
- return null;
- }
-
- /**
- * Set the password char array.
- *
- * A copy of the password argument is stored instead of the argument itself.
- *
- * @param password The password to be set
- */
- private void setPassword(char[] password)
- {
- if (password != null)
- this.password = (char[]) password.clone();
- else
- this.password = new char[0];
-
- passwordValid = true;
- }
-
- /**
- * Set the salt byte array.
- *
- * A copy of the salt arguments is stored instead of the argument itself.
- *
- * @param salt The salt to be set.
- * @throws NullPointerException If the salt is null.
- * @throws IllegalArgumentException If the salt is an empty array.
- */
- private void setSalt(byte[] salt)
- {
- if (salt.length == 0)
- throw new IllegalArgumentException("salt MUST NOT be an empty byte array");
-
- this.salt = (byte[]) salt.clone();
- }
-
- /**
- * Set the iterationCount.
- *
- * @param iterationCount The iteration count to be set.
- * @throws IllegalArgumentException If the iterationCount is negative.
- */
- private void setIterationCount(int iterationCount)
- {
- if (iterationCount < 0)
- throw new IllegalArgumentException("iterationCount MUST be positive");
-
- this.iterationCount = iterationCount;
- }
-
- /**
- * Set the keyLength.
- *
- * @param keyLength The keyLength to be set.
- * @throws IllegalArgumentException if the keyLength is negative.
- */
- private void setKeyLength(int keyLength)
- {
- if (keyLength < 0)
- throw new IllegalArgumentException("keyLength MUST be positive");
-
- this.keyLength = keyLength;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/PBEParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/PBEParameterSpec.java
deleted file mode 100644
index 322d9556..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/PBEParameterSpec.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/* PBEParameterSpec.java -- A wrapper for PBE parameters.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * A wrapper for the parameters used in PKCS #5 -
- * Password-Based Cryptography Standard.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class PBEParameterSpec implements AlgorithmParameterSpec
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The iteration count. */
- private int iterationCount;
-
- /** The salt. */
- private byte[] salt;
-
- // Constructor.
- // ------------------------------------------------------------------------
-
- /**
- * Creates a new password-based encryption parameter specification.
- *
- * @param salt The salt.
- * @param iterationCount The iteration count.
- */
- public PBEParameterSpec(byte[] salt, int iterationCount)
- {
- this.salt = salt;
- this.iterationCount = iterationCount;
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the iteration count.
- *
- * @return The iteration count.
- */
- public int getIterationCount()
- {
- return iterationCount;
- }
-
- /**
- * Get the salt.
- *
- * @return The salt.
- */
- public byte[] getSalt()
- {
- return salt;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/PSource.java b/openjdk/icedtea/jce/javax/crypto/spec/PSource.java
deleted file mode 100644
index f368b47d..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/PSource.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* PSource.java -- stub file
- Copyright (C) 2007 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-public class PSource
-{
- String _pSrcName;
-
- public PSource(String pSrcName)
- {
- _pSrcName = pSrcName;
- }
-
- public String getAlgorithm()
- {
- return _pSrcName;
- }
-
- public static final class PSpecified extends PSource
- {
- private byte[] _P;
-
- public PSpecified(byte[] p)
- {
- //FIXME: What should the pSrcName be here?
- super("SPECIFIED");
- _P = p;
- }
-
- public byte[] getValue()
- {
- return _P;
- }
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/RC2ParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/RC2ParameterSpec.java
deleted file mode 100644
index 33155b2b..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/RC2ParameterSpec.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/* RC2ParameterSpec.java -- Wrapper for RC2 parameters.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * A wrapper for parameters for the RC2
- * block cipher ("RC" means either "Rivest Cipher" or "Ron's Code",
- * depending upon who you ask and when).
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class RC2ParameterSpec implements AlgorithmParameterSpec
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- /** The length of an RC2 IV, in bytes. */
- private static final int RC2_IV_LENGTH = 8;
-
- /** The effective key length, in bits. */
- private int effectiveKeyBits;
-
- /** The initialization vector. */
- private byte[] iv;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create RC2 parameters without an IV.
- *
- * @param effectiveKeyBits The number of effective key bits.
- */
- public RC2ParameterSpec(int effectiveKeyBits)
- {
- this.effectiveKeyBits = effectiveKeyBits;
- }
-
- /**
- * Create RC2 parameters with an IV.
- *
- * @param effectiveKeyBits The number of effective key bits.
- * @param iv The IV; the first eight bytes of this array
- * are used.
- */
- public RC2ParameterSpec(int effectiveKeyBits, byte[] iv)
- {
- this(effectiveKeyBits, iv, 0);
- }
-
- /**
- * Create RC2 parameters with an IV.
- *
- * @param effectiveKeyBits The number of effective key bits.
- * @param iv The IV; the first eight bytes of this array
- * after offset
are used.
- * @param offset From whence to start in the array.
- */
- public RC2ParameterSpec(int effectiveKeyBits, byte[] iv, int offset)
- {
- if (iv.length - offset < RC2_IV_LENGTH)
- {
- throw new IllegalArgumentException("IV too short");
- }
- this.effectiveKeyBits = effectiveKeyBits;
- this.iv = new byte[RC2_IV_LENGTH];
- System.arraycopy(iv, offset, this.iv, 0, RC2_IV_LENGTH);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Get the number of effective key bits.
- *
- * @return The numer of effective key bits.
- */
- public int getEffectiveKeyBits()
- {
- return effectiveKeyBits;
- }
-
- /**
- * Return the initialization vector, or null
if none was
- * specified.
- *
- * @return The IV, or null.
- */
- public byte[] getIV()
- {
- return iv;
- }
-
- public boolean equals(Object o)
- {
- if (this == o) return true;
- byte[] oiv = ((RC2ParameterSpec) o).getIV();
- if (iv != oiv)
- {
- if (iv == null || oiv == null) return false;
- if (iv.length != oiv.length) return false;
- for (int i = 0; i < iv.length; i++)
- {
- if (iv[i] != oiv[i])
- {
- return false;
- }
- }
- }
- return effectiveKeyBits == ((RC2ParameterSpec) o).getEffectiveKeyBits();
- }
-
- public int hashCode()
- {
- int code = effectiveKeyBits;
- if (iv != null)
- {
- for (int i = 0; i < RC2_IV_LENGTH; i++)
- {
- code += iv[i];
- }
- }
- return code;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/RC5ParameterSpec.java b/openjdk/icedtea/jce/javax/crypto/spec/RC5ParameterSpec.java
deleted file mode 100644
index 8570c86b..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/RC5ParameterSpec.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/* RC5ParameterSpec.java -- parameters for RC5.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-/**
- * A wrapper for parameters to the RC5
- * block cipher.
- *
- * @author Casey Marshall (csm@gnu.org)
- * @since 1.4
- */
-public class RC5ParameterSpec implements AlgorithmParameterSpec
-{
-
- // Fields.
- // ------------------------------------------------------------------------
-
- /** The IV. */
- private byte[] iv;
-
- /** The number of rounds. */
- private int rounds;
-
- /** The version number. */
- private int version;
-
- /** The word size, in bits. */
- private int wordSize;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create RC5 parameters without an IV.
- *
- * @param version The version number.
- * @param rounds The number of rounds.
- * @param wordSize The size of a word, in bits.
- */
- public RC5ParameterSpec(int version, int rounds, int wordSize)
- {
- this.version = version;
- this.rounds = rounds;
- this.wordSize = wordSize;
- }
-
- /**
- * Create RC5 parameters with an IV. The bytes in iv
in
- * the range [0, 2*(wordSize/8)-1]
are used.
- *
- * @param version The version number.
- * @param rounds The number of rounds.
- * @param wordSize The size of a word, in bits.
- * @param iv The IV data.
- */
- public RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv)
- {
- this(version, rounds, wordSize, iv, 0);
- }
-
- /**
- * Create RC5 parameters with an IV. The bytes in iv
in
- * the range [off, off+2*(wordSize/8)-1]
are used.
- *
- * @param version The version number.
- * @param rounds The number of rounds.
- * @param wordSize The size of a word, in bits.
- * @param iv The IV data.
- * @param off From where in the array the IV starts.
- */
- public
- RC5ParameterSpec(int version, int rounds, int wordSize, byte[] iv, int off)
- {
- this(version, rounds, wordSize);
- int ivLength = 2 * (wordSize / 8);
- if (off < 0)
- throw new IllegalArgumentException();
- if (iv.length - off < ivLength)
- {
- throw new IllegalArgumentException("IV too short");
- }
- this.iv = new byte[ivLength];
- System.arraycopy(iv, off, this.iv, 0, ivLength);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return the initializaiton vector, or null
if none was
- * specified.
- *
- * @return The IV, or null.
- */
- public byte[] getIV()
- {
- return iv;
- }
-
- /**
- * Get the number of rounds.
- *
- * @return The number of rounds.
- */
- public int getRounds()
- {
- return rounds;
- }
-
- /**
- * Get the version number.
- *
- * @return The version number.
- */
- public int getVersion()
- {
- return version;
- }
-
- /**
- * Get the word size, in bits.
- *
- * @return The word size, in bits.
- */
- public int getWordSize()
- {
- return wordSize;
- }
-
- public boolean equals(Object o)
- {
- if (this == o) return true;
- byte[] oiv = ((RC5ParameterSpec) o).getIV();
- if (iv != oiv)
- {
- if (iv == null || oiv == null) return false;
- if (iv.length != oiv.length) return false;
- for (int i = 0; i < iv.length; i++)
- {
- if (iv[i] != oiv[i])
- {
- return false;
- }
- }
- }
- return rounds == ((RC5ParameterSpec) o).getRounds()
- && version == ((RC5ParameterSpec) o).getVersion()
- && wordSize == ((RC5ParameterSpec) o).getWordSize();
- }
-
- public int hashCode()
- {
- int code = rounds + version + wordSize;
- if (iv != null)
- {
- for (int i = 0; i < iv.length; i++)
- {
- code += iv[i];
- }
- }
- return code;
- }
-}
diff --git a/openjdk/icedtea/jce/javax/crypto/spec/SecretKeySpec.java b/openjdk/icedtea/jce/javax/crypto/spec/SecretKeySpec.java
deleted file mode 100644
index 86c4e05d..00000000
--- a/openjdk/icedtea/jce/javax/crypto/spec/SecretKeySpec.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/* SecretKeySpec.java -- Wrapper for secret keys.
- Copyright (C) 2004 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., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 javax.crypto.spec;
-
-import java.security.spec.KeySpec;
-
-import javax.crypto.SecretKey;
-
-/**
- * This is a simple wrapper around a raw byte array, for ciphers that do
- * not require any key parameters other than the bytes themselves.
- *
- *
Since this class implements {@link javax.crypto.SecretKey}, which
- * in turn extends {@link java.security.Key}, so instances of this class
- * may be passed directly to the init()
methods of {@link
- * javax.crypto.Cipher}.
- *
- * @see javax.crypto.SecretKey
- * @see javax.crypto.SecretKeyFactory
- */
-public class SecretKeySpec implements KeySpec, SecretKey
-{
-
- // Constants and fields.
- // ------------------------------------------------------------------------
-
- /** Compatible with JDK1.4. */
- private static final long serialVersionUID = 6577238317307289933L;
-
- /** The key bytes. */
- private byte[] key;
-
- /** The algorithm's name. */
- private String algorithm;
-
- // Constructors.
- // ------------------------------------------------------------------------
-
- /**
- * Create a new secret key spec from an entire byte array.
- *
- * @param key The key material.
- * @param algorithm The name of the algorithm using this key.
- */
- public SecretKeySpec(byte[] key, String algorithm)
- {
- this(key, 0, key.length, algorithm);
- }
-
- /**
- * Create a new secret key spec from part of a byte array.
- *
- * @param key The key material.
- * @param off The offset at which key material begins.
- * @param len The length of key material.
- * @param algorithm The name of the algorithm using this key.
- */
- public SecretKeySpec(byte[] key, int off, int len, String algorithm)
- {
- this.key = new byte[len];
- this.algorithm = algorithm;
- System.arraycopy(key, off, this.key, 0, len);
- }
-
- // Instance methods.
- // ------------------------------------------------------------------------
-
- /**
- * Return the name of the algorithm associated with this secret key.
- *
- * @return The algorithm's name.
- */
- public String getAlgorithm()
- {
- return algorithm;
- }
-
- /**
- * Return the key as a byte array.
- *
- * @return The key material.
- */
- public byte[] getEncoded()
- {
- return key;
- }
-
- /**
- * This key's format, which is always "RAW".
- *
- * @return "RAW"
- */
- public String getFormat()
- {
- return "RAW";
- }
-
- public boolean equals(Object o)
- {
- if (o instanceof SecretKeySpec)
- {
- byte[] okey = ((SecretKeySpec) o).getEncoded();
- if (key.length != okey.length)
- return false;
- for (int i = 0; i < key.length; i++)
- {
- if (key[i] != okey[i])
- return false;
- }
- return algorithm.equals(((SecretKeySpec) o).getAlgorithm());
- }
- else
- {
- return false;
- }
- }
-
- public int hashCode()
- {
- int code = 0;
- for (int i = 0; i < key.length; i++)
- {
- code ^= (key[i] & 0xff) << (i << 3 & 31);
- }
- return code ^ algorithm.hashCode();
- }
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/interfaces/TlsMasterSecret.java b/openjdk/icedtea/jce/sun/security/internal/interfaces/TlsMasterSecret.java
deleted file mode 100644
index 825db7d9..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/interfaces/TlsMasterSecret.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/* TlsMasterSecret.java -- stub file.
- Copyright (C) 2007 Red Hat, Inc.
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.interfaces;
-
-public interface TlsMasterSecret
-{
- public int getMajorVersion();
-
- public int getMinorVersion();
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java b/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java
deleted file mode 100644
index af579c23..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialParameterSpec.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/* TlsKeyMaterialParameterSpec.java -- parameters for TLS session key gen.
- Copyright (C) 2007 Red Hat, Inc.
- Copyright (C) 2007 Casey Marshall
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-import javax.crypto.SecretKey;
-
-public class TlsKeyMaterialParameterSpec implements AlgorithmParameterSpec
-{
- public final SecretKey masterSecret;
- public final byte major, minor;
- public final byte[] client_random;
- public final byte[] server_random;
- public final String algorithm;
- public final int keySize;
- public final int expandedKeySize;
- public final int ivSize;
- public final int hashSize;
-
- public TlsKeyMaterialParameterSpec(final SecretKey masterSecret,
- final byte major, final byte minor,
- final byte[] client_random,
- final byte[] server_random,
- final String algorithm,
- final int keySize,
- final int expandedKeySize,
- final int ivSize, final int hashSize)
- {
- super();
- this.masterSecret = masterSecret;
- this.major = major;
- this.minor = minor;
- this.client_random = (byte[]) client_random.clone();
- this.server_random = (byte[]) server_random.clone();
- this.algorithm = algorithm;
- this.keySize = keySize;
- this.expandedKeySize = expandedKeySize;
- this.ivSize = ivSize;
- this.hashSize = hashSize;
- }
-
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialSpec.java b/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialSpec.java
deleted file mode 100644
index 01c376fd..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/spec/TlsKeyMaterialSpec.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/* TlsKeyMaterialSpec.java -- TLS session keys.
- Copyright (C) 2007 Red Hat, Inc.
- Copyright (C) 2007 Casey Marshall
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.spec;
-
-import java.security.spec.KeySpec;
-
-import javax.crypto.SecretKey;
-import javax.crypto.spec.IvParameterSpec;
-
-public class TlsKeyMaterialSpec implements KeySpec, SecretKey
-{
- private static final long serialVersionUID = 0L;
-
- private final SecretKey clientCipherKey;
- private final SecretKey serverCipherKey;
- private final IvParameterSpec clientIv;
- private final IvParameterSpec serverIv;
- private final SecretKey clientMacKey;
- private final SecretKey serverMacKey;
-
- public TlsKeyMaterialSpec(SecretKey clientCipherKey,
- SecretKey serverCipherKey,
- IvParameterSpec clientIv,
- IvParameterSpec serverIv,
- SecretKey clientMacKey,
- SecretKey serverMacKey)
- {
- super();
- this.clientCipherKey = clientCipherKey;
- this.serverCipherKey = serverCipherKey;
- this.clientIv = clientIv;
- this.serverIv = serverIv;
- this.clientMacKey = clientMacKey;
- this.serverMacKey = serverMacKey;
- }
-
- public SecretKey getClientCipherKey()
- {
- return clientCipherKey;
- }
-
- public SecretKey getServerCipherKey()
- {
- return serverCipherKey;
- }
-
- public IvParameterSpec getClientIv()
- {
- return clientIv;
- }
-
- public IvParameterSpec getServerIv()
- {
- return serverIv;
- }
-
- public SecretKey getClientMacKey()
- {
- return clientMacKey;
- }
-
- public SecretKey getServerMacKey()
- {
- return serverMacKey;
- }
-
- public String getAlgorithm()
- {
- return "TLS";
- }
-
- public byte[] getEncoded()
- {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getFormat()
- {
- return "RAW";
- }
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/spec/TlsMasterSecretParameterSpec.java b/openjdk/icedtea/jce/sun/security/internal/spec/TlsMasterSecretParameterSpec.java
deleted file mode 100644
index 0c5a87b6..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/spec/TlsMasterSecretParameterSpec.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/* TlsMasterSecretParameterSpec.java -- parameters for TLS master secret gen.
- Copyright (C) 2007 Red Hat, Inc.
- Copyright (C) 2007 Casey Marshall
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-import javax.crypto.SecretKey;
-
-public class TlsMasterSecretParameterSpec implements AlgorithmParameterSpec
-{
- public final SecretKey key;
- public final byte major;
- public final byte minor;
- public final byte[] client_random;
- public final byte[] server_random;
-
- public TlsMasterSecretParameterSpec(SecretKey key, byte major, byte minor,
- byte[] client_random, byte[] server_random)
- {
- this.key = key;
- this.major = major;
- this.minor = minor;
- this.client_random = (byte[]) client_random.clone();
- this.server_random = (byte[]) server_random.clone();
- }
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/spec/TlsPrfParameterSpec.java b/openjdk/icedtea/jce/sun/security/internal/spec/TlsPrfParameterSpec.java
deleted file mode 100644
index d3978854..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/spec/TlsPrfParameterSpec.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/* TlsPrfParameterSpec.java -- TLS PRF parameters.
- Copyright (C) 2007 Red Hat, Inc.
- Copyright (C) 2007 Casey Marshall
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-import javax.crypto.SecretKey;
-
-public class TlsPrfParameterSpec implements AlgorithmParameterSpec
-{
- public final SecretKey key;
- public final String label;
- public final byte[] seed;
- public final int size;
-
- public TlsPrfParameterSpec(SecretKey key, String label, byte[] seed, int size)
- {
- this.key = key;
- this.label = label;
- this.seed = (byte[]) seed.clone();
- this.size = size;
- }
-}
diff --git a/openjdk/icedtea/jce/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java b/openjdk/icedtea/jce/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java
deleted file mode 100644
index 6ddffb8e..00000000
--- a/openjdk/icedtea/jce/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/* TlsRsaParameterSecretParameterSpec.java -- version number for RSA key ex.
- Copyright (C) 2007 Red Hat, Inc.
- Copyright (C) 2007 Casey Marshall
-
-This file is part of IcedTea.
-
-IcedTea 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, version 2.
-
-IcedTea 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 IcedTea; see the file COPYING. If not, write to
-the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
-02110-1301 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 sun.security.internal.spec;
-
-import java.security.spec.AlgorithmParameterSpec;
-
-public class TlsRsaPremasterSecretParameterSpec
- implements AlgorithmParameterSpec
-{
- private final int major;
- private final int minor;
-
- public TlsRsaPremasterSecretParameterSpec(int major, int minor)
- {
- this.major = major;
- this.minor = minor;
- }
-
- public TlsRsaPremasterSecretParameterSpec(byte arg1, byte arg2)
- {
- this.major = arg1 & 0xFF;
- this.minor = arg2 & 0xFF;
- }
-
- public int getMajorVersion()
- {
- return major;
- }
-
- public int getMinorVersion()
- {
- return minor;
- }
-}