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:
jrandom
2005-07-19 21:00:25 +00:00
committed by zzz
parent 0f8ede85ca
commit 843d5b625a
29 changed files with 355 additions and 174 deletions

View File

@@ -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);

View File

@@ -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;
}
/**