[kaffe] CVS kaffe (robilad): Replaced Security with implementation from GNU Classpath

Kaffe CVS cvs-commits at kaffe.org
Sat Sep 25 09:44:46 PDT 2004


PatchSet 5218 
Date: 2004/09/25 16:39:54
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
Replaced Security with implementation from GNU Classpath

2004-09-25  Dalibor Topic  <robilad at kaffe.org>

        * libraries/clib/native/System.c:
        Added gnu.classpath.vm.shortname.

        * libraries/clib/security/java.security:
        Added GNU Classpath provider.

        * libraries/javalib/Makefile.am,
        libraries/javalib/Makefile.in,
        libraries/javalib/all.files:
        Regenerated.

        * libraries/javalib/gnu/java/io/Base64InputStream.java,
        libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java,
        libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java,
        libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java,
        libraries/javalib/gnu/java/security/provider/DSAParameters.java,
        libraries/javalib/gnu/java/security/provider/DSASignature.java,
        libraries/javalib/gnu/java/security/provider/DefaultPolicy.java,
        libraries/javalib/gnu/java/security/provider/Gnu.java,
        libraries/javalib/gnu/java/security/provider/GnuDSAPrivateKey.java,
        libraries/javalib/gnu/java/security/provider/GnuDSAPublicKey.java,
        libraries/javalib/gnu/java/security/provider/MD5.java,
        libraries/javalib/gnu/java/security/provider/SHA.java,
        libraries/javalib/gnu/java/security/provider/X509CertificateFactory.java,
        libraries/javalib/gnu/java/security/util/Prime.java,
        libraries/javalib/gnu/java/security/x509/X500DistinguishedName.java,
        libraries/javalib/gnu/java/security/x509/X509CRL.java,
        libraries/javalib/gnu/java/security/x509/X509CRLEntry.java,
        libraries/javalib/gnu/java/security/x509/X509Certificate.java:
        New files taken from GNU Classpath.

        * libraries/javalib/java/security/Security.java:
        Replaced by implementation from GNU Classpath.

Members: 
	ChangeLog:1.2773->1.2774 
	libraries/clib/native/System.c:1.56->1.57 
	libraries/clib/security/java.security:1.4->1.5 
	libraries/javalib/Makefile.am:1.236->1.237 
	libraries/javalib/Makefile.in:1.316->1.317 
	libraries/javalib/all.files:1.24->1.25 
	libraries/javalib/gnu/java/io/Base64InputStream.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DSAParameters.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DSASignature.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/DefaultPolicy.java:1.2->1.3 
	libraries/javalib/gnu/java/security/provider/Gnu.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/GnuDSAPrivateKey.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/GnuDSAPublicKey.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/MD5.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/SHA.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/provider/X509CertificateFactory.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/util/Prime.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/x509/X500DistinguishedName.java:1.2->1.3 
	libraries/javalib/gnu/java/security/x509/X509CRL.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/x509/X509CRLEntry.java:INITIAL->1.1 
	libraries/javalib/gnu/java/security/x509/X509Certificate.java:INITIAL->1.1 
	libraries/javalib/java/security/Security.java:1.14->1.15 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2773 kaffe/ChangeLog:1.2774
--- kaffe/ChangeLog:1.2773	Fri Sep 24 19:06:41 2004
+++ kaffe/ChangeLog	Sat Sep 25 16:39:54 2004
@@ -1,3 +1,39 @@
+2004-09-25  Dalibor Topic  <robilad at kaffe.org>
+
+	* libraries/clib/native/System.c:
+	Added gnu.classpath.vm.shortname.
+
+	* libraries/clib/security/java.security:
+	Added GNU Classpath provider.
+
+	* libraries/javalib/Makefile.am,
+	libraries/javalib/Makefile.in,
+	libraries/javalib/all.files:
+	Regenerated.
+
+	* libraries/javalib/gnu/java/io/Base64InputStream.java,
+	libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java,
+	libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java,
+	libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java,
+	libraries/javalib/gnu/java/security/provider/DSAParameters.java,
+	libraries/javalib/gnu/java/security/provider/DSASignature.java,
+	libraries/javalib/gnu/java/security/provider/DefaultPolicy.java,
+	libraries/javalib/gnu/java/security/provider/Gnu.java,
+	libraries/javalib/gnu/java/security/provider/GnuDSAPrivateKey.java,
+	libraries/javalib/gnu/java/security/provider/GnuDSAPublicKey.java,
+	libraries/javalib/gnu/java/security/provider/MD5.java,
+	libraries/javalib/gnu/java/security/provider/SHA.java,
+	libraries/javalib/gnu/java/security/provider/X509CertificateFactory.java,
+	libraries/javalib/gnu/java/security/util/Prime.java,
+	libraries/javalib/gnu/java/security/x509/X500DistinguishedName.java,
+	libraries/javalib/gnu/java/security/x509/X509CRL.java,
+	libraries/javalib/gnu/java/security/x509/X509CRLEntry.java,
+	libraries/javalib/gnu/java/security/x509/X509Certificate.java:
+	New files taken from GNU Classpath.
+
+	* libraries/javalib/java/security/Security.java:
+	Replaced by implementation from GNU Classpath.
+
 2004-09-23  Dalibor Topic  <robilad at kaffe.org>
 
 	* libraries/javalib/java/security/AlgorithmParameterGenerator.java:
Index: kaffe/libraries/clib/native/System.c
diff -u kaffe/libraries/clib/native/System.c:1.56 kaffe/libraries/clib/native/System.c:1.57
--- kaffe/libraries/clib/native/System.c:1.56	Sun Sep 19 23:54:59 2004
+++ kaffe/libraries/clib/native/System.c	Sat Sep 25 16:39:56 2004
@@ -254,6 +254,8 @@
 	 * sun.boot.class.path  Bootclasspath
 	 * kaffe.library.path   Search path for kaffe's native libraries
 	 * gnu.cpu.endian	Specify the native endian-ness.
+         * gnu.classpath.vm.shortname
+         *                      Alias for java.vm.name.
 	 *
 	 */
 
@@ -286,6 +288,7 @@
 	setProperty(p, "java.specification.vendor", kaffe_specification_vendor);
 	setProperty(p, "java.specification.name", kaffe_specification_name);
 	setProperty(p, "java.class.version", kaffe_class_version);
+        setProperty(p, "gnu.classpath.vm.shortname", kaffe_vm_name);
 
 	/* Undocumented properties used by some applications */
 	setProperty(p, "java.runtime.name", kaffe_vm_name);
Index: kaffe/libraries/clib/security/java.security
diff -u kaffe/libraries/clib/security/java.security:1.4 kaffe/libraries/clib/security/java.security:1.5
--- kaffe/libraries/clib/security/java.security:1.4	Sun Jul 25 22:46:14 2004
+++ kaffe/libraries/clib/security/java.security	Sat Sep 25 16:39:56 2004
@@ -1,10 +1,9 @@
 #
 # Security configuration file for Kaffe
 #
-# You'll need to have kaffe configured to use 
-# GNU Crypto for the GNU Crypto provider 
-# to be picked up.
 
 security.provider.1=gnu.crypto.jce.GnuCrypto
 security.provider.2=org.metastatic.jessie.provider.Jessie
 security.provider.3=kaffe.security.provider.Kaffe
+security.provider.4=gnu.java.security.provider.Gnu
+
Index: kaffe/libraries/javalib/Makefile.am
diff -u kaffe/libraries/javalib/Makefile.am:1.236 kaffe/libraries/javalib/Makefile.am:1.237
--- kaffe/libraries/javalib/Makefile.am:1.236	Thu Sep 23 00:21:58 2004
+++ kaffe/libraries/javalib/Makefile.am	Sat Sep 25 16:39:56 2004
@@ -142,6 +142,7 @@
 	$(gnu_java_security_action_SRCS) \
 	$(gnu_java_security_der_SRCS) \
 	$(gnu_java_security_provider_SRCS) \
+	$(gnu_java_security_util_SRCS) \
 	$(gnu_java_security_x509_SRCS) \
 	$(gnu_java_text_SRCS) \
 	$(gnu_java_util_SRCS) \
@@ -984,6 +985,7 @@
 	gnu/java/beans/editors/StringEditor.java
 gnu_java_io_SRCS = \
 	gnu/java/io/ASN1ParsingException.java \
+	gnu/java/io/Base64InputStream.java \
 	gnu/java/io/ClassLoaderObjectInputStream.java \
 	gnu/java/io/EncodingManager.java \
 	gnu/java/io/NullOutputStream.java \
@@ -1245,10 +1247,26 @@
 	gnu/java/security/der/DERValue.java \
 	gnu/java/security/der/DERWriter.java
 gnu_java_security_provider_SRCS = \
+	gnu/java/security/provider/DSAKeyFactory.java \
+	gnu/java/security/provider/DSAKeyPairGenerator.java \
+	gnu/java/security/provider/DSAParameterGenerator.java \
+	gnu/java/security/provider/DSAParameters.java \
+	gnu/java/security/provider/DSASignature.java \
 	gnu/java/security/provider/DefaultPolicy.java \
-	gnu/java/security/provider/SHA1PRNG.java
+	gnu/java/security/provider/Gnu.java \
+	gnu/java/security/provider/GnuDSAPrivateKey.java \
+	gnu/java/security/provider/GnuDSAPublicKey.java \
+	gnu/java/security/provider/MD5.java \
+	gnu/java/security/provider/SHA.java \
+	gnu/java/security/provider/SHA1PRNG.java \
+	gnu/java/security/provider/X509CertificateFactory.java
+gnu_java_security_util_SRCS = \
+	gnu/java/security/util/Prime.java
 gnu_java_security_x509_SRCS = \
-	gnu/java/security/x509/X500DistinguishedName.java
+	gnu/java/security/x509/X500DistinguishedName.java \
+	gnu/java/security/x509/X509CRL.java \
+	gnu/java/security/x509/X509CRLEntry.java \
+	gnu/java/security/x509/X509Certificate.java
 gnu_java_text_SRCS = \
 	gnu/java/text/AttributedFormatBuffer.java \
 	gnu/java/text/BaseBreakIterator.java \
Index: kaffe/libraries/javalib/Makefile.in
diff -u kaffe/libraries/javalib/Makefile.in:1.316 kaffe/libraries/javalib/Makefile.in:1.317
--- kaffe/libraries/javalib/Makefile.in:1.316	Thu Sep 23 00:21:59 2004
+++ kaffe/libraries/javalib/Makefile.in	Sat Sep 25 16:39:57 2004
@@ -483,6 +483,7 @@
 	$(gnu_java_security_action_SRCS) \
 	$(gnu_java_security_der_SRCS) \
 	$(gnu_java_security_provider_SRCS) \
+	$(gnu_java_security_util_SRCS) \
 	$(gnu_java_security_x509_SRCS) \
 	$(gnu_java_text_SRCS) \
 	$(gnu_java_util_SRCS) \
@@ -1391,6 +1392,7 @@
 
 gnu_java_io_SRCS = \
 	gnu/java/io/ASN1ParsingException.java \
+	gnu/java/io/Base64InputStream.java \
 	gnu/java/io/ClassLoaderObjectInputStream.java \
 	gnu/java/io/EncodingManager.java \
 	gnu/java/io/NullOutputStream.java \
@@ -1674,11 +1676,28 @@
 	gnu/java/security/der/DERWriter.java
 
 gnu_java_security_provider_SRCS = \
+	gnu/java/security/provider/DSAKeyFactory.java \
+	gnu/java/security/provider/DSAKeyPairGenerator.java \
+	gnu/java/security/provider/DSAParameterGenerator.java \
+	gnu/java/security/provider/DSAParameters.java \
+	gnu/java/security/provider/DSASignature.java \
 	gnu/java/security/provider/DefaultPolicy.java \
-	gnu/java/security/provider/SHA1PRNG.java
+	gnu/java/security/provider/Gnu.java \
+	gnu/java/security/provider/GnuDSAPrivateKey.java \
+	gnu/java/security/provider/GnuDSAPublicKey.java \
+	gnu/java/security/provider/MD5.java \
+	gnu/java/security/provider/SHA.java \
+	gnu/java/security/provider/SHA1PRNG.java \
+	gnu/java/security/provider/X509CertificateFactory.java
+
+gnu_java_security_util_SRCS = \
+	gnu/java/security/util/Prime.java
 
 gnu_java_security_x509_SRCS = \
-	gnu/java/security/x509/X500DistinguishedName.java
+	gnu/java/security/x509/X500DistinguishedName.java \
+	gnu/java/security/x509/X509CRL.java \
+	gnu/java/security/x509/X509CRLEntry.java \
+	gnu/java/security/x509/X509Certificate.java
 
 gnu_java_text_SRCS = \
 	gnu/java/text/AttributedFormatBuffer.java \
Index: kaffe/libraries/javalib/all.files
diff -u kaffe/libraries/javalib/all.files:1.24 kaffe/libraries/javalib/all.files:1.25
--- kaffe/libraries/javalib/all.files:1.24	Thu Sep 23 00:22:01 2004
+++ kaffe/libraries/javalib/all.files	Sat Sep 25 16:39:58 2004
@@ -602,6 +602,7 @@
 gnu/java/beans/editors/NativeShortEditor.java
 gnu/java/beans/editors/StringEditor.java
 gnu/java/io/ASN1ParsingException.java
+gnu/java/io/Base64InputStream.java
 gnu/java/io/ClassLoaderObjectInputStream.java
 gnu/java/io/EncodingManager.java
 gnu/java/io/NullOutputStream.java
@@ -841,9 +842,24 @@
 gnu/java/security/der/DERReader.java
 gnu/java/security/der/DERValue.java
 gnu/java/security/der/DERWriter.java
+gnu/java/security/provider/DSAKeyFactory.java
+gnu/java/security/provider/DSAKeyPairGenerator.java
+gnu/java/security/provider/DSAParameterGenerator.java
+gnu/java/security/provider/DSAParameters.java
+gnu/java/security/provider/DSASignature.java
 gnu/java/security/provider/DefaultPolicy.java
+gnu/java/security/provider/Gnu.java
+gnu/java/security/provider/GnuDSAPrivateKey.java
+gnu/java/security/provider/GnuDSAPublicKey.java
+gnu/java/security/provider/MD5.java
+gnu/java/security/provider/SHA.java
 gnu/java/security/provider/SHA1PRNG.java
+gnu/java/security/provider/X509CertificateFactory.java
+gnu/java/security/util/Prime.java
 gnu/java/security/x509/X500DistinguishedName.java
+gnu/java/security/x509/X509CRL.java
+gnu/java/security/x509/X509CRLEntry.java
+gnu/java/security/x509/X509Certificate.java
 gnu/java/text/AttributedFormatBuffer.java
 gnu/java/text/BaseBreakIterator.java
 gnu/java/text/CharacterBreakIterator.java
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/io/Base64InputStream.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/io/Base64InputStream.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/io/Base64InputStream.java	Sat Sep 25 16:44:45 2004
@@ -0,0 +1,190 @@
+/* Base64InputStream.java -- base-64 input stream.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.io;
+
+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 at 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;
+  }
+
+  // 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;
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyFactory.java	Sat Sep 25 16:44:46 2004
@@ -0,0 +1,134 @@
+/* DSAKeyFactory.java -- DSA key factory.
+   Copyright (C) 2003 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+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;
+
+/**
+ * DSA key factory.
+ *
+ * @author Casey Marshall (rsdio at metastatic.org)
+ */
+public class DSAKeyFactory extends KeyFactorySpi
+{
+
+  // Constructor.
+  // ------------------------------------------------------------------------
+
+  public DSAKeyFactory()
+  {
+    super();
+  }
+
+  // Instance methods.
+  // ------------------------------------------------------------------------
+
+  protected PrivateKey engineGeneratePrivate(KeySpec keySpec)
+    throws InvalidKeySpecException
+  {
+    if (!(keySpec instanceof DSAPrivateKeySpec))
+      throw new InvalidKeySpecException();
+    return new GnuDSAPrivateKey(
+      ((DSAPrivateKeySpec) keySpec).getX(),
+      ((DSAPrivateKeySpec) keySpec).getP(),
+      ((DSAPrivateKeySpec) keySpec).getQ(),
+      ((DSAPrivateKeySpec) keySpec).getG());
+  }
+
+  protected PublicKey engineGeneratePublic(KeySpec keySpec)
+    throws InvalidKeySpecException
+  {
+    if (!(keySpec instanceof DSAPublicKeySpec))
+      throw new InvalidKeySpecException();
+    return new GnuDSAPublicKey(
+      ((DSAPublicKeySpec) keySpec).getY(),
+      ((DSAPublicKeySpec) keySpec).getP(),
+      ((DSAPublicKeySpec) keySpec).getQ(),
+      ((DSAPublicKeySpec) keySpec).getG());
+  }
+
+  protected KeySpec engineGetKeySpec(Key key, Class keySpec)
+    throws InvalidKeySpecException
+  {
+    if ((key instanceof DSAPublicKey) &&
+         keySpec.isAssignableFrom(DSAPublicKeySpec.class))
+      {
+        return new DSAPublicKeySpec(((DSAPublicKey) key).getY(),
+          ((DSAPublicKey) key).getParams().getP(),
+          ((DSAPublicKey) key).getParams().getQ(),
+          ((DSAPublicKey) key).getParams().getG());
+      }
+    if ((key instanceof DSAPrivateKey) &&
+         keySpec.isAssignableFrom(DSAPrivateKeySpec.class))
+      {
+        return new DSAPrivateKeySpec(((DSAPrivateKey) key).getX(),
+          ((DSAPrivateKey) key).getParams().getP(),
+          ((DSAPrivateKey) key).getParams().getQ(),
+          ((DSAPrivateKey) key).getParams().getG());
+      }
+    throw new InvalidKeySpecException();
+  }
+
+  protected Key engineTranslateKey(Key key) throws InvalidKeyException
+  {
+    if ((key instanceof GnuDSAPublicKey) || (key instanceof GnuDSAPrivateKey))
+      return key;
+    if (key instanceof DSAPublicKey)
+      return new GnuDSAPublicKey(((DSAPublicKey) key).getY(),
+        ((DSAPublicKey) key).getParams().getP(),
+        ((DSAPublicKey) key).getParams().getQ(),
+        ((DSAPublicKey) key).getParams().getG());
+    if (key instanceof DSAPrivateKey)
+      return new GnuDSAPrivateKey(((DSAPrivateKey) key).getX(),
+        ((DSAPrivateKey) key).getParams().getP(),
+        ((DSAPrivateKey) key).getParams().getQ(),
+        ((DSAPrivateKey) key).getParams().getG());
+    throw new InvalidKeyException();
+  } 
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/security/provider/DSAKeyPairGenerator.java	Sat Sep 25 16:44:46 2004
@@ -0,0 +1,171 @@
+/* GnuDSAKeyPairGenerator.java --- Gnu DSA Key Pair Generator
+   Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+import java.math.BigInteger;
+import java.security.AlgorithmParameterGenerator;
+import java.security.AlgorithmParameters;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.InvalidParameterException;
+import java.security.KeyPair;
+import java.security.KeyPairGeneratorSpi;
+import java.security.SecureRandom;
+import java.security.interfaces.DSAParams;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.DSAParameterSpec;
+import java.util.Random;
+
+public class DSAKeyPairGenerator extends KeyPairGeneratorSpi 
+	implements java.security.interfaces.DSAKeyPairGenerator
+{
+int keysize;
+SecureRandom random;
+private BigInteger q = null; // the small prime
+private BigInteger p = null; // the big prime
+private BigInteger g = null;
+
+DSAKeyPairGenerator()
+{
+	keysize = 1024;
+}
+
+public void initialize(int keysize, SecureRandom random)
+{
+	//if( ((keysize % 64) != 0) || (keysize < 512) || (keysize > 1024) )
+        //        throw new InvalidAlgorithmParameterException("Invalid key size");
+
+	this.keysize = keysize;
+	this.random = random;
+}
+
+public void initialize(AlgorithmParameterSpec params,
+                       SecureRandom random)
+                throws InvalidAlgorithmParameterException
+{
+	if( !( params instanceof DSAParameterSpec ) )
+		throw new InvalidAlgorithmParameterException("Must be DSAParameterSpec");
+
+	DSAParameterSpec dsaparameterspec = (DSAParameterSpec)params;
+	p = dsaparameterspec.getP();
+	q = dsaparameterspec.getQ();
+	g = dsaparameterspec.getG();
+	this.random = random;
+}
+
+public void initialize(DSAParams params, SecureRandom random) 
+	throws InvalidParameterException
+{
+	if(params.getP() != null) 
+		p = params.getP();
+	else
+		throw new InvalidParameterException();
+
+	if(params.getQ() != null) 
+		q = params.getQ();
+	else
+		throw new InvalidParameterException();
+	
+	if(params.getG() != null) 
+		g = params.getG();
+	else
+		throw new InvalidParameterException();
+	
+	this.random = random;
+}
+
+public void initialize(int modlen, boolean genParams, SecureRandom random) 
+	throws InvalidParameterException
+{
+	if( ((modlen % 64) != 0) || (modlen < 512) || (modlen > 1024) )
+                throw new InvalidParameterException();
+
+	if( (genParams == false) && (modlen != 512) && (modlen != 768) && (modlen != 1024)  )
+		throw new InvalidParameterException();
+	this.keysize = modlen;
+	this.random = random;
+	p = null;
+	q = null;
+	g = null;
+}
+
+public KeyPair generateKeyPair()
+{
+	if( getDefaults() == false) {
+		try {
+			AlgorithmParameterGenerator apgDSA = AlgorithmParameterGenerator.getInstance("DSA");
+			AlgorithmParameters apDSA = apgDSA.generateParameters();
+			DSAParameterSpec dsaparameterspec = (DSAParameterSpec)apDSA.getParameterSpec( DSAParameterSpec.class );
+			p = dsaparameterspec.getP();
+			q = dsaparameterspec.getQ();
+			g = dsaparameterspec.getG();
+		} catch ( Exception e ) {
+			return null;
+		}
+	}
+
+	BigInteger x = new BigInteger( 159, new Random() );
+
+	BigInteger y = g.modPow( x, p );
+
+	return new KeyPair( new GnuDSAPublicKey(y,p,q,g), new GnuDSAPrivateKey(x,p,q,g));
+	//return new KeyPair( public, private );
+}
+
+//These constants are Sun's Constants copied from the 
+//Cryptography Specification
+private boolean getDefaults()
+{
+	if( keysize == 512) {
+		p = new BigInteger("fca682ce8e12caba26efccf7110e526db078b05edecbcd1eb4a208f3ae1617ae01f35b91a47e6df63413c5e12ed0899bcd132acd50d99151bdc43ee737592e17", 16);
+		q = new BigInteger("962eddcc369cba8ebb260ee6b6a126d9346e38c5", 16);
+		g = new BigInteger("678471b27a9cf44ee91a49c5147db1a9aaf244f05a434d6486931d2d14271b9e35030b71fd73da179069b32e2935630e1c2062354d0da20a6c416e50be794ca4", 16);
+		return true;
+	} else if( keysize == 768) {
+		p = new BigInteger("e9e642599d355f37c97ffd3567120b8e25c9cd43e927b3a9670fbec5d890141922d2c3b3ad2480093799869d1e846aab49fab0ad26d2ce6a22219d470bce7d777d4a21fbe9c270b57f607002f3cef8393694cf45ee3688c11a8c56ab127a3daf", 16);
+		q = new BigInteger("9cdbd84c9f1ac2f38d0f80f42ab952e7338bf511", 16);
+		g = new BigInteger("30470ad5a005fb14ce2d9dcd87e38bc7d1b1c5facbaecbe95f190aa7a31d23c4dbbcbe06174544401a5b2c020965d8c2bd2171d3668445771f74ba084d2029d83c1c158547f3a9f1a2715be23d51ae4d3e5a1f6a7064f316933a346d3f529252", 16);
+	} else if( keysize == 512) {
+		p = new BigInteger("fd7f53811d75122952df4a9c2eece4e7f611b7523cef4400c31e3f80b6512669455d402251fb593d8d58fabfc5f5ba30f6cb9b556cd7813b801d346ff26660b76b9950a5a49f9fe8047b1022c24fbba9d7feb7c61bf83b57e7c6a8a6150f04fb83f6d3c51ec3023554135a169132f675f3ae2b61d72aeff22203199dd14801c7", 16);
+		q = new BigInteger("9760508f15230bccb292b982a2eb840bf0581cf5", 16);
+		g = new BigInteger("f7e1a085d69b3ddecbbcab5c36b857b97994afbbfa3aea82f9574c0b3d0782675159578ebad4594fe67107108180b449167123e84c281613b7cf09328cc8a6e13c167a8b547c8d28e0a3ae1e2bb3a675916ea37f0bfa213562f1fb627a01243bcca4f1bea8519089a883dfe15ae59f06928b665e807b552564014c3bfecf492a", 16);
+	}
+	return false;
+}
+
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/security/provider/DSAParameterGenerator.java	Sat Sep 25 16:44:46 2004
@@ -0,0 +1,128 @@
+/* DSAParameterGenerator.java --- DSA Parameter Generator Implementation
+   Copyright (C) 1999 Free Software Foundation, Inc.
+
+This file is part of GNU Classpath.
+
+GNU Classpath is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+ 
+GNU Classpath is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU Classpath; see the file COPYING.  If not, write to the
+Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+import java.math.BigInteger;
+import java.security.AlgorithmParameters;
+import java.security.AlgorithmParameterGeneratorSpi;
+import java.security.InvalidAlgorithmParameterException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.security.spec.AlgorithmParameterSpec;
+import java.security.spec.DSAParameterSpec;
+import java.security.spec.InvalidParameterSpecException;
+import java.util.Random;
+
+import gnu.java.security.util.Prime;
+
+public class DSAParameterGenerator extends AlgorithmParameterGeneratorSpi
+{
+  private int size;
+  private SecureRandom random = null;
+
+  public DSAParameterGenerator()
+  {
+    size = 1024;
+  }
+
+  public void engineInit(int size, SecureRandom random)
+  {
+    if( (size < 512) || (size > 1024) || ( (size % 64) != 0) )
+      //throw new InvalidAlgorithmParameterException("Invalid Size");
+      return;
+    this.size = size;
+    this.random = random;
+  }
+
+  public void engineInit(AlgorithmParameterSpec genParamSpec, SecureRandom random)
+    throws InvalidAlgorithmParameterException
+  {
+    if( !( genParamSpec instanceof DSAParameterSpec ) )
+      throw new InvalidAlgorithmParameterException("Must be DSAParameterSpec");
+
+    DSAParameterSpec dsaparameterspec = (DSAParameterSpec)genParamSpec;
+    int tmp = dsaparameterspec.getP().bitLength();
+
+    if( (tmp < 512) || (tmp > 1024) || ( (tmp % 64) != 0) )
+      throw new InvalidAlgorithmParameterException("Invalid Size");
+
+    this.random = random;
+  }
+
+  //For more information see IEEE P1363 A.16.1 (10/05/98 Draft)
+  public AlgorithmParameters engineGenerateParameters()
+  {
+    DSAParameterSpec dsaparameterspec;
+
+    int L = size;
+    BigInteger r, p, k, h, g;
+
+    //q 2^159 < q < 2^160
+    r = Prime.generateRandomPrime( 159, 160, BigInteger.valueOf(1));
+
+    // 2^(L-1) < p < 2^L
+    p = Prime.generateRandomPrime( r, BigInteger.valueOf(1), L - 1, L, BigInteger.valueOf(1));
+
+    k = p.subtract( BigInteger.valueOf(1) );
+    k = k.divide( r );
+
+    Random rand = new Random();
+    h = BigInteger.valueOf(1);
+
+    for(;;) {
+      h = h.add(BigInteger.valueOf( 1 ) );
+
+      g = h.modPow(k, p);
+
+      if( g.compareTo( BigInteger.valueOf(1) ) != 1 )
+	break;
+    }
+
+    try {
+      dsaparameterspec = new DSAParameterSpec(p, r, g);
+      AlgorithmParameters ap = AlgorithmParameters.getInstance("DSA");
+      ap.init( dsaparameterspec );
+      return ap;
+    } catch ( NoSuchAlgorithmException nsae ) {
+      return null;
+    } catch ( InvalidParameterSpecException ipse) {
+      return null;
+    }
+  }
+}
===================================================================
Checking out kaffe/libraries/javalib/gnu/java/security/provider/DSAParameters.java
RCS:  /home/cvs/kaffe/kaffe/libraries/javalib/gnu/java/security/provider/DSAParameters.java,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/libraries/javalib/gnu/java/security/provider/DSAParameters.java	Sat Sep 25 16:44:46 2004
@@ -0,0 +1,160 @@
+/* DSAParameters.java --- DSA Parameters Implementation
+   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., 59 Temple Place, Suite 330, Boston, MA
+02111-1307 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library.  Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module.  An independent module is a module which is not derived from
+or based on this library.  If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so.  If you do not wish to do so, delete this
+exception statement from your version. */
+
+
+package gnu.java.security.provider;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+
+import java.math.BigInteger;
+
+import java.security.AlgorithmParametersSpi;

*** Patch too long, truncated ***




More information about the kaffe mailing list