I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit df43e72a authored by zzz's avatar zzz
Browse files

PRNG: Drop unused exception and interface

parent 326e2c63
No related branches found
No related tags found
No related merge requests found
...@@ -95,7 +95,7 @@ import net.i2p.crypto.SHA256Generator; ...@@ -95,7 +95,7 @@ import net.i2p.crypto.SHA256Generator;
* *
* NOTE: As of 0.8.8, uses the java.security.MessageDigest instead of GNU Sha256Standalone * NOTE: As of 0.8.8, uses the java.security.MessageDigest instead of GNU Sha256Standalone
*/ */
public class FortunaStandalone extends BasePRNGStandalone implements Serializable, RandomEventListenerStandalone public class FortunaStandalone extends BasePRNGStandalone implements Serializable
{ {
private static final long serialVersionUID = 0xFACADE; private static final long serialVersionUID = 0xFACADE;
...@@ -191,19 +191,6 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl ...@@ -191,19 +191,6 @@ public class FortunaStandalone extends BasePRNGStandalone implements Serializabl
pool = (pool + 1) % NUM_POOLS; pool = (pool + 1) % NUM_POOLS;
} }
public void addRandomEvent(RandomEventStandalone event)
{
if (event.getPoolNumber() < 0 || event.getPoolNumber() >= pools.length)
throw new IllegalArgumentException("pool number out of range: "
+ event.getPoolNumber());
pools[event.getPoolNumber()].update(event.getSourceNumber());
pools[event.getPoolNumber()].update((byte) event.getData().length);
byte data[] = event.getData();
pools[event.getPoolNumber()].update(data, 0, data.length); //event.getData());
if (event.getPoolNumber() == 0)
pool0Count += event.getData().length;
}
// Reading and writing this object is equivalent to storing and retrieving // Reading and writing this object is equivalent to storing and retrieving
// the seed. // the seed.
......
...@@ -114,10 +114,9 @@ public interface IRandomStandalone extends Cloneable { ...@@ -114,10 +114,9 @@ public interface IRandomStandalone extends Cloneable {
* *
* @return the next 8 bits of random data generated from this instance. * @return the next 8 bits of random data generated from this instance.
* @throws IllegalStateException if the instance is not yet initialised. * @throws IllegalStateException if the instance is not yet initialised.
* @throws LimitReachedExceptionStandalone this instance has reached its
* theoretical limit for generating non-repetitive pseudo-random data. * theoretical limit for generating non-repetitive pseudo-random data.
*/ */
byte nextByte() throws IllegalStateException, LimitReachedExceptionStandalone; byte nextByte() throws IllegalStateException;
/** /**
* <p>Fills the designated byte array, starting from byte at index * <p>Fills the designated byte array, starting from byte at index
...@@ -131,11 +130,10 @@ public interface IRandomStandalone extends Cloneable { ...@@ -131,11 +130,10 @@ public interface IRandomStandalone extends Cloneable {
* @param length the maximum number of required random bytes. This method * @param length the maximum number of required random bytes. This method
* does nothing if this parameter is less than <code>1</code>. * does nothing if this parameter is less than <code>1</code>.
* @throws IllegalStateException if the instance is not yet initialised. * @throws IllegalStateException if the instance is not yet initialised.
* @throws LimitReachedExceptionStandalone this instance has reached its
* theoretical limit for generating non-repetitive pseudo-random data. * theoretical limit for generating non-repetitive pseudo-random data.
*/ */
void nextBytes(byte[] out, int offset, int length) void nextBytes(byte[] out, int offset, int length)
throws IllegalStateException, LimitReachedExceptionStandalone; throws IllegalStateException;
/** /**
* <p>Supplement, or possibly replace, the random state of this PRNG with * <p>Supplement, or possibly replace, the random state of this PRNG with
......
package gnu.crypto.prng;
// ----------------------------------------------------------------------------
// $Id: LimitReachedExceptionStandalone.java,v 1.1 2005/10/22 13:10:00 jrandom Exp $
//
// Copyright (C) 2001, 2002, Free Software Foundation, Inc.
//
// This file is part of GNU Crypto.
//
// GNU Crypto 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 Crypto 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 this program; 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.
// ----------------------------------------------------------------------------
/**
* A checked exception that indicates that a pseudo random number generated has
* reached its theoretical limit in generating random bytes.
*
* @version $Revision: 1.1 $
*/
public class LimitReachedExceptionStandalone extends Exception {
// Constants and variables
// -------------------------------------------------------------------------
// Constructor(s)
// -------------------------------------------------------------------------
public LimitReachedExceptionStandalone() {
super();
}
public LimitReachedExceptionStandalone(String msg) {
super(msg);
}
// Class methods
// -------------------------------------------------------------------------
// Instant methods
// -------------------------------------------------------------------------
}
/* RandomEventListenerStandalone.java -- event listener
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Crypto.
GNU Crypto 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 Crypto 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 this program; 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.crypto.prng;
import java.util.EventListener;
/**
* An interface for entropy accumulators that will be notified of random
* events.
*/
public interface RandomEventListenerStandalone extends EventListener
{
void addRandomEvent(RandomEventStandalone event);
}
/* RandomEventStandalone.java -- a random event.
Copyright (C) 2004 Free Software Foundation, Inc.
This file is part of GNU Crypto.
GNU Crypto 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 Crypto 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 this program; 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.crypto.prng;
import java.util.EventObject;
/**
* An interface for entropy accumulators that will be notified of random
* events.
*/
public class RandomEventStandalone extends EventObject
{
private final byte sourceNumber;
private final byte poolNumber;
private final byte[] data;
public RandomEventStandalone(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 = data.clone();
}
public byte getSourceNumber()
{
return sourceNumber;
}
public byte getPoolNumber()
{
return poolNumber;
}
public byte[] getData()
{
return data;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment