Changeset 6238381


Ignore:
Timestamp:
Aug 9, 2009 2:34:21 PM (11 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
ccd67d6
Parents:
69fdfb0 (diff), 2e5caac (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

propagate from branch 'i2p.i2p' (head 6ab0f64b9f4992591ed989f8d89a859fc3ceaeaf)

to branch 'i2p.i2p.zzz.android' (head e02886e19d254dac40a7f775e102e60560efe5e5)

Files:
10 added
5 edited
1 moved

Legend:

Unmodified
Added
Removed
  • apps/routerconsole/java/src/net/i2p/router/web/ContextHelper.java

    r69fdfb0 r6238381  
    66import net.i2p.router.RouterContext;
    77
    8 class ContextHelper {
     8public class ContextHelper {
    99    public static RouterContext getContext(String contextId) {
    1010        List contexts = RouterContext.listContexts();
  • core/java/src/gnu/crypto/prng/AsyncFortunaStandalone.java

    r69fdfb0 r6238381  
    1313 */
    1414public class AsyncFortunaStandalone extends FortunaStandalone implements Runnable {
    15     private static final int BUFFERS = 16;
     15    private static final int DEFAULT_BUFFERS = 16;
    1616    private static final int BUFSIZE = 256*1024;
    17     private final byte asyncBuffers[][] = new byte[BUFFERS][BUFSIZE];
    18     private final int status[] = new int[BUFFERS];
     17    private int _bufferCount;
     18    private final byte asyncBuffers[][];
     19    private final int status[];
    1920    private int nextBuf = 0;
    2021    private I2PAppContext _context;
     
    2829    public AsyncFortunaStandalone(I2PAppContext context) {
    2930        super();
    30         for (int i = 0; i < BUFFERS; i++)
     31        _bufferCount = context.getProperty("router.prng.buffers", DEFAULT_BUFFERS);
     32        asyncBuffers = new byte[_bufferCount][BUFSIZE];
     33        status = new int[_bufferCount];
     34        for (int i = 0; i < _bufferCount; i++)
    3135            status[i] = STATUS_NEED_FILL;
    3236        _context = context;
     
    8185            int prev=nextBuf-1;
    8286            if (prev<0)
    83                 prev = BUFFERS-1;
     87                prev = _bufferCount-1;
    8488            if (status[prev] == STATUS_LIVE)
    8589                status[prev] = STATUS_NEED_FILL;
    8690            nextBuf++;
    87             if (nextBuf >= BUFFERS)
     91            if (nextBuf >= _bufferCount)
    8892                nextBuf = 0;
    8993            asyncBuffers.notify();
     
    96100            try {
    97101                synchronized (asyncBuffers) {
    98                     for (int i = 0; i < BUFFERS; i++) {
     102                    for (int i = 0; i < _bufferCount; i++) {
    99103                        if (status[i] == STATUS_NEED_FILL) {
    100104                            status[i] = STATUS_FILLING;
  • core/java/src/net/i2p/crypto/HMAC256Generator.java

    r69fdfb0 r6238381  
    88
    99import org.bouncycastle.crypto.Digest;
    10 import org.bouncycastle.crypto.macs.HMac;
     10import org.bouncycastle.crypto.Mac;
     11import org.bouncycastle.crypto.macs.I2PHMac;
    1112
    1213/**
     
    2021   
    2122    @Override
    22     protected HMac acquire() {
     23    protected I2PHMac acquire() {
    2324        synchronized (_available) {
    2425            if (_available.size() > 0)
    25                 return (HMac)_available.remove(0);
     26                return (I2PHMac)_available.remove(0);
    2627        }
    2728        // the HMAC is hardcoded to use SHA256 digest size
    2829        // for backwards compatability.  next time we have a backwards
    2930        // incompatible change, we should update this by removing ", 32"
    30         return new HMac(new Sha256ForMAC());
     31        return new I2PHMac(new Sha256ForMAC());
    3132    }
    3233   
  • core/java/src/net/i2p/crypto/HMACGenerator.java

    r69fdfb0 r6238381  
    1111
    1212import org.bouncycastle.crypto.digests.MD5Digest;
    13 import org.bouncycastle.crypto.macs.HMac;
     13import org.bouncycastle.crypto.Mac;
     14import org.bouncycastle.crypto.macs.I2PHMac;
    1415
    1516/**
     
    5051            throw new NullPointerException("Null arguments for HMAC");
    5152       
    52         HMac mac = acquire();
     53        I2PHMac mac = acquire();
    5354        mac.init(key.getData());
    5455        mac.update(data, offset, length);
     
    7475            throw new NullPointerException("Null arguments for HMAC");
    7576       
    76         HMac mac = acquire();
     77        I2PHMac mac = acquire();
    7778        mac.init(key.getData());
    7879        mac.update(curData, curOffset, curLength);
     
    8788    }
    8889   
    89     protected HMac acquire() {
     90    protected I2PHMac acquire() {
    9091        synchronized (_available) {
    9192            if (_available.size() > 0)
    92                 return (HMac)_available.remove(0);
     93                return (I2PHMac)_available.remove(0);
    9394        }
    9495        // the HMAC is hardcoded to use SHA256 digest size
    9596        // for backwards compatability.  next time we have a backwards
    9697        // incompatible change, we should update this by removing ", 32"
    97         return new HMac(new MD5Digest(), 32);
     98        return new I2PHMac(new MD5Digest(), 32);
    9899    }
    99     private void release(HMac mac) {
     100    private void release(Mac mac) {
    100101        synchronized (_available) {
    101102            if (_available.size() < 64)
  • core/java/src/net/i2p/util/DecayingBloomFilter.java

    r69fdfb0 r6238381  
    3131    private DecayEvent _decayEvent;
    3232   
     33    private static final int DEFAULT_M = 23;
    3334    private static final boolean ALWAYS_MISS = false;
    3435   
     
    4546        _log = context.logManager().getLog(DecayingBloomFilter.class);
    4647        _entryBytes = entryBytes;
    47         _current = new BloomSHA1(23, 11); //new BloomSHA1(23, 11);
    48         _previous = new BloomSHA1(23, 11); //new BloomSHA1(23, 11);
     48        // this is instantiated in four different places, they may have different
     49        // requirements, but for now use this as a gross method of memory reduction.
     50        // m == 23 => 2MB each BloomSHA1 (8MB total)
     51        int m = context.getProperty("router.decayingBloomFilterM", DEFAULT_M);
     52        _current = new BloomSHA1(m, 11); //new BloomSHA1(23, 11);
     53        _previous = new BloomSHA1(m, 11); //new BloomSHA1(23, 11);
    4954        _durationMs = durationMs;
    5055        int numExtenders = (32+ (entryBytes-1))/entryBytes - 1;
  • core/java/src/org/bouncycastle/crypto/macs/I2PHMac.java

    r69fdfb0 r6238381  
    4343 * domain in 2005.
    4444 *
     45 * This is renamed from HMac because the constructor HMac(digest, sz) does not exist
     46 * in the standard bouncycastle library, thus it conflicts in JVMs that contain the
     47 * standard library (Android).
     48 *
    4549 */
    46 public class HMac
     50public class I2PHMac
    4751implements Mac
    4852{
     
    5761    private byte[] outputPad = new byte[BLOCK_LENGTH];
    5862
    59     public HMac(
     63    public I2PHMac(
    6064        Digest digest)
    6165    {
    6266        this(digest, digest.getDigestSize());
    6367    }
    64     public HMac(
     68    public I2PHMac(
    6569        Digest digest, int sz)
    6670    {
Note: See TracChangeset for help on using the changeset viewer.