Sync libgcj with GNU Classpath 0.98.

2009-02-13  Andrew John Hughes  <ahughes@redhat.com>

	Import GNU Classpath (classpath-0_98-release).

	* Makefile.am: Add natVMSecureRandom.cc.
	* Makefile.in: Regenerated.
	* classpath/ChangeLog,
	* classpath/Makefile.am: Merged.
	* classpath/Makefile.in: Regenerated.
	* classpath/NEWS: Merged.
	* classpath/config.guess,
	* classpath/config.sub,
	* classpath/configure: Regenerated.
	* classpath/configure.ac: Merged.
	* classpath/gnu/java/awt/peer/gtk/CairoGraphics2D.java,
	* classpath/gnu/java/security/jce/prng/SecureRandomAdapter.java,
	* classpath/gnu/javax/crypto/jce/prng/ARCFourRandomSpi.java,
	* classpath/gnu/javax/crypto/jce/prng/CSPRNGSpi.java,
	* classpath/gnu/javax/crypto/jce/prng/FortunaImpl.java,
	* classpath/gnu/javax/crypto/jce/prng/ICMRandomSpi.java,
	* classpath/gnu/javax/crypto/jce/prng/UMacRandomSpi.java,
	* classpath/gnu/javax/crypto/prng/ICMGenerator.java,
	* classpath/gnu/xml/stream/XMLParser.java,
	* classpath/java/security/SecureRandom.java,
	* classpath/native/jni/native-lib/cpproc.c,
	* classpath/native/plugin/gcjwebplugin.cc,
	* classpath/tools/gnu/classpath/tools/gjdoc/Main.java: Merged.
	* configure: Regenerated.
	* configure.ac: Add symlink for natVMSecureRandomPosix.cc to natVMSecureRandom.cc
	* gnu/classpath/Configuration.java: Change version to 0.98.
	* gnu/java/security/jce/prng/SecureRandomAdapter.h: Regenerated.
	* gnu/java/security/jce/prng/VMSecureRandom.h: Generated.
	* gnu/java/security/jce/prng/VMSecureRandom.java: Added native implementation.
	* gnu/java/security/jce/prng/natVMSecureRandomPosix.cc: Wrapper around /dev/random.
	* gnu/javax/crypto/jce/prng/CSPRNGSpi.h,
	* gnu/javax/crypto/jce/prng/FortunaImpl.h,
	* java/security/SecureRandom.h: Regenerated.
	* java/security/VMSecureRandom$Spinner.h,
	* java/security/VMSecureRandom.h,
	* java/security/VMSecureRandom.java: Removed.
	* sources.am: Move VMSecureRandom to gnu.java.security.jce.prng.

From-SVN: r144434
This commit is contained in:
Andrew John Hughes
2009-02-25 21:40:28 +00:00
parent a16b68bb66
commit dc6a0b2d94
66 changed files with 612 additions and 249 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ public final class Configuration
* It is set according to the value of 'version' in the configure[.in] file
* and used to set the System property gnu.classpath.version.
*/
public static final String CLASSPATH_VERSION = "0.98-pre";
public static final String CLASSPATH_VERSION = "0.98";
/**
* The value of DEBUG is substituted according to whether the
@@ -39,12 +39,17 @@ class gnu::java::security::jce::prng::SecureRandomAdapter : public ::java::secur
public: // actually protected
SecureRandomAdapter(::java::lang::String *);
public:
static JArray< jbyte > * getSeed(jint);
virtual JArray< jbyte > * engineGenerateSeed(jint);
virtual void engineNextBytes(JArray< jbyte > *);
virtual void engineSetSeed(JArray< jbyte > *);
private:
::gnu::java::security::prng::MDGenerator * __attribute__((aligned(__alignof__( ::java::security::SecureRandomSpi)))) adaptee;
jboolean __attribute__((aligned(__alignof__( ::java::security::SecureRandomSpi)))) isSeeded;
::gnu::java::security::prng::MDGenerator * adaptee;
::java::lang::String * mdName;
static ::java::util::logging::Logger * logger;
static ::java::lang::String * SECURERANDOM_SOURCE;
static ::java::lang::String * JAVA_SECURITY_EGD;
public:
static ::java::lang::Class class$;
};
@@ -0,0 +1,43 @@
// DO NOT EDIT THIS FILE - it is machine generated -*- c++ -*-
#ifndef __gnu_java_security_jce_prng_VMSecureRandom__
#define __gnu_java_security_jce_prng_VMSecureRandom__
#pragma interface
#include <java/lang/Object.h>
#include <gcj/array.h>
extern "Java"
{
namespace gnu
{
namespace java
{
namespace security
{
namespace jce
{
namespace prng
{
class VMSecureRandom;
}
}
}
}
}
}
class gnu::java::security::jce::prng::VMSecureRandom : public ::java::lang::Object
{
public: // actually package-private
VMSecureRandom();
static jint generateSeed(JArray< jbyte > *, jint, jint);
static jint natGenerateSeed(JArray< jbyte > *, jint, jint);
public:
static ::java::lang::Class class$;
};
#endif // __gnu_java_security_jce_prng_VMSecureRandom__
@@ -0,0 +1,78 @@
/* VMSecureRandom.java -- random seed generator.
Copyright (C) 2006, 2009 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;
/**
* VM-specific methods for generating real (or almost real) random
* seeds. VM implementors should write a version of this class that
* reads random bytes from some system source.
*/
final class VMSecureRandom
{
/**
* <p>
* Generate a random seed. Implementations are free to generate
* fewer random bytes than are requested, and leave the remaining
* bytes of the destination buffer as zeros. Implementations SHOULD,
* however, make a best-effort attempt to satisfy the request.
* </p>
* <p>
* The GCJ implementation uses a native method to read bytes from
* a system random source (e.g. /dev/random).
* </p>
*
* @param buffer The destination buffer.
* @param offset The offset in the buffer to start putting bytes.
* @param length The number of random bytes to generate.
* @return the number of bytes generated.
*/
static int generateSeed(byte[] buffer, int offset, int length)
{
if (length < 0)
throw new IllegalArgumentException("length must be nonnegative");
if (offset < 0 || offset + length > buffer.length)
throw new IndexOutOfBoundsException();
return natGenerateSeed(buffer, offset, length);
}
static native int natGenerateSeed(byte[] buffer, int offset, int length);
}
@@ -0,0 +1,54 @@
// natVMSecureRandomPosix.cc - Native part of VMSecureRandom class for POSIX.
/* Copyright (C) 2009 Free Software Foundation
This file is part of libgcj.
This software is copyrighted work licensed under the terms of the
Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
details. */
#include <config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <gcj/cni.h>
#include <java/lang/InternalError.h>
#include <gnu/java/security/jce/prng/VMSecureRandom.h>
jint
gnu::java::security::jce::prng::VMSecureRandom::natGenerateSeed(jbyteArray byte_array, jint offset, jint length)
{
int a, fd;
jbyte *bytes = elements (byte_array);
ssize_t count;
for (a = 0; a < offset; ++a)
bytes++;
fd = open ("/dev/random", O_RDONLY);
if (fd == -1)
{
jstring oserr = JvNewStringLatin1 (strerror (errno));
throw new ::java::lang::InternalError
(JvNewStringLatin1 ("Error opening /dev/random: ")->concat(oserr));
}
count = read (fd, bytes, length);
close (fd);
if (count == -1)
{
jstring oserr = JvNewStringLatin1 (strerror (errno));
throw new ::java::lang::InternalError
(JvNewStringLatin1 ("Error reading /dev/random: ")->concat(oserr));
}
return count;
}
@@ -50,6 +50,7 @@ public: // actually protected
virtual void engineSetSeed(JArray< jbyte > *);
private:
::gnu::java::security::prng::IRandom * __attribute__((aligned(__alignof__( ::java::security::SecureRandomSpi)))) adaptee;
jboolean virgin;
public:
static ::java::lang::Class class$;
};
@@ -43,7 +43,8 @@ public: // actually protected
void engineNextBytes(JArray< jbyte > *);
JArray< jbyte > * engineGenerateSeed(jint);
private:
::gnu::javax::crypto::prng::Fortuna * __attribute__((aligned(__alignof__( ::java::security::SecureRandomSpi)))) adaptee;
jboolean __attribute__((aligned(__alignof__( ::java::security::SecureRandomSpi)))) virgin;
::gnu::javax::crypto::prng::Fortuna * adaptee;
public:
static ::java::lang::Class class$;
};