forked from I2P_Developers/i2p.i2p
2005-07-19 jrandom
* Further preparation for removing I2CP crypto
* Added some validation to the DH key agreement (thanks $anon)
* Validate tunnel data message expirations (though not really a problem,
since tunnels expire)
* Minor PRNG threading cleanup
This commit is contained in:
@@ -85,11 +85,15 @@ public final class ByteCache {
|
||||
*
|
||||
*/
|
||||
public final void release(ByteArray entry) {
|
||||
release(entry, true);
|
||||
}
|
||||
public final void release(ByteArray entry, boolean shouldZero) {
|
||||
if (_cache) {
|
||||
if ( (entry == null) || (entry.getData() == null) )
|
||||
return;
|
||||
|
||||
Arrays.fill(entry.getData(), (byte)0x0);
|
||||
if (shouldZero)
|
||||
Arrays.fill(entry.getData(), (byte)0x0);
|
||||
synchronized (_available) {
|
||||
if (_available.size() < _maxCached)
|
||||
_available.add(entry);
|
||||
|
||||
@@ -61,9 +61,14 @@ public class PooledRandomSource extends RandomSource {
|
||||
}
|
||||
|
||||
private final RandomSource pickPRNG() {
|
||||
int i = _nextPool % POOL_SIZE;
|
||||
_nextPool = (++_nextPool) % POOL_SIZE;
|
||||
return _pool[i];
|
||||
// how much more explicit can we get?
|
||||
int cur = _nextPool;
|
||||
cur = cur % POOL_SIZE;
|
||||
RandomSource rv = _pool[cur];
|
||||
cur++;
|
||||
cur = cur % POOL_SIZE;
|
||||
_nextPool = cur;
|
||||
return rv;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user