Changeset 50450ec for core


Ignore:
Timestamp:
Feb 10, 2017 4:43:25 PM (5 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
7370804
Parents:
44c0d93 (diff), 2d8f0c2 (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 bd037c8b542fe0f6125aa16fb3bff5d257b4e955)

to branch 'i2p.i2p.str4d.ui' (head 9bd4080121d8ef662d6a2e4dfe7fae1079b32646)

Location:
core
Files:
51 edited

Legend:

Unmodified
Added
Removed
  • core/c/jbigi/download_gmp.sh

    r44c0d93 r50450ec  
    11#!/bin/sh
    22
    3 export GMP_VER=6.0.0
    4 export GMP_TARVER=${GMP_VER}a
     3export GMP_VER=6.1.2
     4export GMP_TARVER=${GMP_VER}
    55export GMP_DIR="gmp-$GMP_VER"
    66export GMP_TAR="gmp-$GMP_TARVER.tar.bz2"
  • core/java/src/gnu/crypto/prng/IRandomStandalone.java

    r44c0d93 r50450ec  
    105105    * @param attributes a set of name-value pairs that describe the desired
    106106    * future instance behaviour.
    107     * @exception IllegalArgumentException if at least one of the defined name/
     107    * @throws IllegalArgumentException if at least one of the defined name/
    108108    * value pairs contains invalid data.
    109109    */
     
    114114     *
    115115     * @return the next 8 bits of random data generated from this instance.
    116      * @exception IllegalStateException if the instance is not yet initialised.
    117      * @exception LimLimitReachedExceptionStandalone this instance has reached its
     116     * @throws IllegalStateException if the instance is not yet initialised.
     117     * @throws LimitReachedExceptionStandalone this instance has reached its
    118118     * theoretical limit for generating non-repetitive pseudo-random data.
    119119     */
     
    131131     * @param length the maximum number of required random bytes. This method
    132132     * does nothing if this parameter is less than <code>1</code>.
    133      * @exception IllegalStateException if the instance is not yet initialised.
    134      * @exception LimitLimitReachedExceptionStandalonehis instance has reached its
     133     * @throws IllegalStateException if the instance is not yet initialised.
     134     * @throws LimitReachedExceptionStandalone this instance has reached its
    135135     * theoretical limit for generating non-repetitive pseudo-random data.
    136136     */
     
    173173    * @param offset The offset from whence to begin reading random bytes.
    174174    * @param length The number of random bytes to add.
    175     * @exception IndexOutOfBoundsException If <i>offset</i>, <i>length</i>,
     175    * @throws IndexOutOfBoundsException If <i>offset</i>, <i>length</i>,
    176176    * or <i>offset</i>+<i>length</i> is out of bounds.
    177177    */
  • core/java/src/gnu/getopt/Getopt.java

    r44c0d93 r50450ec  
    337337  *     }
    338338  * //
    339   * for (int i = g.getOptind(); i < argv.length ; i++)
     339  * for (int i = g.getOptind(); i &lt; argv.length ; i++)
    340340  *   System.out.println("Non option argv element: " + argv[i] + "\n");
    341341  * </pre>
  • core/java/src/gnu/getopt/LongOpt.java

    r44c0d93 r50450ec  
    118118  * @param val The value to return for this long option, or the equivalent single letter option to emulate if flag is null.
    119119  *
    120   * @exception IllegalArgumentException If the has_arg param is not one of NO_ARGUMENT, REQUIRED_ARGUMENT or OPTIONAL_ARGUMENT.
     120  * @throws IllegalArgumentException If the has_arg param is not one of NO_ARGUMENT, REQUIRED_ARGUMENT or OPTIONAL_ARGUMENT.
    121121  */
    122122public
  • core/java/src/net/i2p/client/I2PClient.java

    r44c0d93 r50450ec  
    4848
    4949    /**
    50      * For router->client payloads.
     50     * For router-&gt;client payloads.
    5151     *
    5252     * If false, the router will send the MessageStatus,
  • core/java/src/net/i2p/client/I2PSession.java

    r44c0d93 r50450ec  
    7474     *
    7575     * Like sendMessage above, except the key used and the tags sent are exposed to the
    76      * application.  <p />
     76     * application.  <p>
    7777     *
    7878     * If some application layer message delivery confirmation is used,
     
    332332     *
    333333     *<pre>
    334      *  if (name.length() == 60 && name.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
     334     *  if (name.length() == 60 &amp;&amp; name.toLowerCase(Locale.US).endsWith(".b32.i2p")) {
    335335     *      if (session != null)
    336336     *          return session.lookup(Hash.create(Base32.decode(name.toLowerCase(Locale.US).substring(0, 52))));
  • core/java/src/net/i2p/client/datagram/I2PDatagramDissector.java

    r44c0d93 r50450ec  
    3232
    3333    private static final int DGRAM_BUFSIZE = 32768;
     34    private static final int MIN_DGRAM_SIZE = 387 + 40;
    3435
    3536    private final DSAEngine dsaEng = DSAEngine.getInstance();
     
    6970     */
    7071    public void loadI2PDatagram(byte[] dgram) throws DataFormatException {
    71         ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
    7272        // set invalid(very important!)
    7373        this.valid = false;
     74        if (dgram.length < MIN_DGRAM_SIZE)
     75            throw new DataFormatException("repliable datagram too small: " + dgram.length);
     76
     77        ByteArrayInputStream dgStream = new ByteArrayInputStream(dgram);
    7478       
    7579        try {
     
    97101            }
    98102        } catch (IOException e) {
    99             Log log = I2PAppContext.getGlobalContext().logManager().getLog(I2PDatagramDissector.class);
    100             log.error("Error loading datagram", e);
     103            // let the application do the logging
     104            //Log log = I2PAppContext.getGlobalContext().logManager().getLog(I2PDatagramDissector.class);
     105            //log.error("Error loading datagram", e);
    101106            throw new DataFormatException("Error loading datagram", e);
    102107        //} catch(AssertionError e) {
  • core/java/src/net/i2p/client/impl/I2PClientMessageHandlerMap.java

    r44c0d93 r50450ec  
    2828 */
    2929class I2PClientMessageHandlerMap {
    30     /** map of message type id --> I2CPMessageHandler */
     30    /** map of message type id --&gt; I2CPMessageHandler */
    3131    protected I2CPMessageHandler _handlers[];
    3232
  • core/java/src/net/i2p/client/impl/I2PSessionImpl.java

    r44c0d93 r50450ec  
    125125    /** class that generates new messages */
    126126    protected final I2CPMessageProducer _producer;
    127     /** map of Long --> MessagePayloadMessage */
     127    /** map of Long --&gt; MessagePayloadMessage */
    128128    protected Map<Long, MessagePayloadMessage> _availableMessages;
    129129
  • core/java/src/net/i2p/client/impl/I2PSessionMuxedImpl.java

    r44c0d93 r50450ec  
    3535 *
    3636 * Compatibility:
    37  *    old streaming -> new streaming: sends proto anything, rcvs proto anything
    38  *    new streaming -> old streaming: sends PROTO_STREAMING, ignores rcvd proto
    39  *    old datagram -> new datagram: sends proto anything, rcvs proto anything
    40  *    new datagram -> old datagram: sends PROTO_DATAGRAM, ignores rcvd proto
     37 *    old streaming -&gt; new streaming: sends proto anything, rcvs proto anything
     38 *    new streaming -&gt; old streaming: sends PROTO_STREAMING, ignores rcvd proto
     39 *    old datagram -&gt; new datagram: sends proto anything, rcvs proto anything
     40 *    new datagram -&gt; old datagram: sends PROTO_DATAGRAM, ignores rcvd proto
    4141 *    In all the above cases, streaming and datagram receive traffic for the other
    4242 *    protocol, same as before.
    4343 *
    44  *    old datagram -> new muxed: doesn't work because the old sends proto 0 but the udp side
     44 *    old datagram -&gt; new muxed: doesn't work because the old sends proto 0 but the udp side
    4545 *                               of the mux registers with PROTO_DATAGRAM, so the datagrams
    4646 *                               go to the streaming side, same as before.
    47  *    old streaming -> new muxed: works
     47 *    old streaming -&gt; new muxed: works
    4848 *
    4949 * Typical Usage:
     
    422422     *  No, we couldn't put any protocol byte in front of everything and
    423423     *  keep backward compatibility. But there are several bytes that
    424      *  are unused AND unchecked in the gzip header in releases <= 0.7.
     424     *  are unused AND unchecked in the gzip header in releases &lt;= 0.7.
    425425     *  So let's use 5 of them for a protocol and two 2-byte ports.
    426426     *
  • core/java/src/net/i2p/client/naming/NamingService.java

    r44c0d93 r50450ec  
    535535     *
    536536     *  @param hostname must be {52 chars}.b32.i2p
    537      *  @param timeout in seconds; <= 0 means use router default
     537     *  @param timeout in seconds; &lt;= 0 means use router default
    538538     *  @return dest or null
    539539     *  @since 0.8.7
     
    547547     *  This implementation returns null.
    548548     *
    549      *  @param timeout in seconds; <= 0 means use router default
     549     *  @param timeout in seconds; &lt;= 0 means use router default
    550550     *  @return dest or null
    551551     *  @since 0.8.7
  • core/java/src/net/i2p/crypto/CryptixRijndael_Algorithm.java

    r44c0d93 r50450ec  
    372372     *
    373373     * @param k The 128/192/256-bit user-key to use.
    374      * @exception  InvalidKeyException  If the key is invalid.
     374     * @throws  InvalidKeyException  If the key is invalid.
    375375     */
    376376    public static final Object makeKey(byte[] k) throws InvalidKeyException {
     
    551551     * @param k          The 128/192/256-bit user-key to use.
    552552     * @param blockSize  The block size in bytes of this Rijndael.
    553      * @exception  InvalidKeyException  If the key is invalid.
     553     * @throws  InvalidKeyException  If the key is invalid.
    554554     */
    555555    public static final/* synchronized */Object makeKey(byte[] k, int blockSize) throws InvalidKeyException {
  • core/java/src/net/i2p/crypto/CryptoCheck.java

    r44c0d93 r50450ec  
    66
    77/**
    8  * Moved from CryptixAESEngine and net.i2p.router.tasks.CryptoChecker
     8 * Moved from CryptixAESEngine and net.i2p.router.tasks.CryptoChecker.
     9 * This class does not do any logging. See CryptoChecker for the logging.
    910 *
    1011 * @since 0.9.23
     
    2930            } catch (GeneralSecurityException gse) {
    3031            }
     32        } catch (ExceptionInInitializerError eiie) {
     33            // Java 9 b134 bug
     34            // > java -jar build/i2p.jar cryptocheck
     35            // Exception in thread "main" java.lang.ExceptionInInitializerError
     36            //  at javax.crypto.JceSecurityManager.<clinit>(java.base@9-Ubuntu/JceSecurityManager.java:65)
     37            //  at javax.crypto.Cipher.getConfiguredPermission(java.base@9-Ubuntu/Cipher.java:2595)
     38            //  at javax.crypto.Cipher.getMaxAllowedKeyLength(java.base@9-Ubuntu/Cipher.java:2619)
     39            //  at net.i2p.crypto.CryptoCheck.<clinit>(CryptoCheck.java:19)
     40            //  at java.lang.Class.forName0(java.base@9-Ubuntu/Native Method)
     41            //  at java.lang.Class.forName(java.base@9-Ubuntu/Class.java:374)
     42            //  at net.i2p.util.CommandLine.exec(CommandLine.java:66)
     43            //  at net.i2p.util.CommandLine.main(CommandLine.java:51)
     44            // Caused by: java.lang.SecurityException: Can not initialize cryptographic mechanism
     45            //  at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:91)
     46            //  ... 8 more
     47            // Caused by: java.lang.NullPointerException
     48            //  at sun.nio.fs.UnixPath.normalizeAndCheck(java.base@9-Ubuntu/UnixPath.java:75)
     49            //  at sun.nio.fs.UnixPath.<init>(java.base@9-Ubuntu/UnixPath.java:69)
     50            //  at sun.nio.fs.UnixFileSystem.getPath(java.base@9-Ubuntu/UnixFileSystem.java:280)
     51            //  at java.nio.file.Paths.get(java.base@9-Ubuntu/Paths.java:84)
     52            //  at javax.crypto.JceSecurity.setupJurisdictionPolicies(java.base@9-Ubuntu/JceSecurity.java:254)
     53            //  at javax.crypto.JceSecurity.access$000(java.base@9-Ubuntu/JceSecurity.java:49)
     54            //  at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:82)
     55            //  at javax.crypto.JceSecurity$1.run(java.base@9-Ubuntu/JceSecurity.java:79)
     56            //  at java.security.AccessController.doPrivileged(java.base@9-Ubuntu/Native Method)
     57            //  at javax.crypto.JceSecurity.<clinit>(java.base@9-Ubuntu/JceSecurity.java:78)
     58            //  ... 8 more
    3159        }
    3260        _isUnlimited = unlimited;
  • core/java/src/net/i2p/crypto/ElGamalAESEngine.java

    r44c0d93 r50450ec  
    430430     * In the router, we always use garlic messages. A garlic message with a single
    431431     * clove and zero data is about 84 bytes, so that's 123 bytes minimum. So any paddingSize
    432      * <= 128 is a no-op as every message will be at least 128 bytes
     432     * &lt;= 128 is a no-op as every message will be at least 128 bytes
    433433     * (Streaming, if used, adds more overhead).
    434434     *
    435435     * Outside the router, with a client using its own message format, the minimum size
    436      * is 48, so any paddingSize <= 48 is a no-op.
     436     * is 48, so any paddingSize &lt;= 48 is a no-op.
    437437     *
    438438     * Not included in the minimum is a 32-byte session tag for an existing session,
  • core/java/src/net/i2p/crypto/SHA1.java

    r44c0d93 r50450ec  
    2929 * <p>The FIPS PUB 180-2 standard specifies four secure hash algorithms (SHA-1,
    3030 * SHA-256, SHA-384 and SHA-512) for computing a condensed representation of
    31  * electronic data (message).  When a message of any length < 2^^64 bits (for
    32  * SHA-1 and SHA-256) or < 2^^128 bits (for SHA-384 and SHA-512) is input to
     31 * electronic data (message).  When a message of any length &lt; 2^^64 bits (for
     32 * SHA-1 and SHA-256) or &lt; 2^^128 bits (for SHA-384 and SHA-512) is input to
    3333 * an algorithm, the result is an output called a message digest.  The message
    3434 * digests range in length from 160 to 512 bits, depending on the algorithm.
     
    6363 *   <li> Bruce Schneier, "Section 18.7 Secure Hash Algorithm (SHA)",
    6464 *      <cite>Applied Cryptography, 2nd edition</cite>, <br>
    65  *      John Wiley & Sons, 1996</li>
     65 *      John Wiley &amp; Sons, 1996</li>
    6666 * </ol>
    6767 */
  • core/java/src/net/i2p/crypto/eddsa/EdDSAEngine.java

    r44c0d93 r50450ec  
    436436
    437437    /**
    438      * @deprecated replaced with <a href="#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
     438     * @deprecated replaced with <a href="#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">this</a>
    439439     */
    440440    @Override
  • core/java/src/net/i2p/crypto/eddsa/math/GroupElement.java

    r44c0d93 r50450ec  
    3434     * <li>PRECOMP: Precomputed representation (y+x, y-x, 2dxy).
    3535     * <li>CACHED: Cached representation (Y+X, Y-X, Z, 2dT)
     36     * </ul>
    3637     */
    3738    public enum Representation {
     
    221222     * <li>Set x := β.
    222223     * <li>If sign(x) != bit 255 of s then negate x.
     224     * </ul>
    223225     *
    224226     * @param curve The curve.
     
    861863     * <p>
    862864     * Preconditions: (TODO: Check this applies here)
    863      *   a[31] <= 127
     865     *   a[31] &lt;= 127
    864866     * @param a = a[0]+256*a[1]+...+256^31 a[31]
    865867     * @return the GroupElement
  • core/java/src/net/i2p/crypto/eddsa/math/ed25519/Ed25519FieldElement.java

    r44c0d93 r50450ec  
    5959     * <p><ul>
    6060     * <li>|h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
     61     * </ul>
    6162     *
    6263     * @param val The field element to add.
     
    8788     * <p><ul>
    8889     * <li>|h| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
     90     * </ul>
    8991     *
    9092     * @param val The field element to subtract.
     
    112114     * <p><ul>
    113115     * <li>|h| bounded by 1.1*2^25,1.1*2^24,1.1*2^25,1.1*2^24,etc.
     116     * </ul>
    114117     *
    115118     * @return The field element (-1) * this.
  • core/java/src/net/i2p/crypto/eddsa/math/ed25519/Ed25519LittleEndianEncoding.java

    r44c0d93 r50450ec  
    1919     * <p><ul>
    2020     * <li>p = 2^255 - 19
    21      * <li>h = h0 + 2^25 * h1 + 2^(26+25) * h2 + ... + 2^230 * h9 where 0 <= |hi| < 2^27 for all i=0,...,9.
    22      * <li>h congruent r modulo p, i.e. h = r + q * p for some suitable 0 <= r < p and an integer q.
     21     * <li>h = h0 + 2^25 * h1 + 2^(26+25) * h2 + ... + 2^230 * h9 where 0 &lt;= |hi| &lt; 2^27 for all i=0,...,9.
     22     * <li>h congruent r modulo p, i.e. h = r + q * p for some suitable 0 &lt;= r &lt; p and an integer q.
    2323     * </ul><p>
    2424     * Then q = [2^-255 * (h + 19 * 2^-25 * h9 + 1/2)] where [x] = floor(x).
     
    2727     * <p>
    2828     * We begin with some very raw estimation for the bounds of some expressions:
    29      * <pre>|h| < 2^230 * 2^30 = 2^260 ==> |r + q * p| < 2^260 ==> |q| < 2^10.
    30      * ==> -1/4 <= a := 19^2 * 2^-255 * q < 1/4.
    31      * |h - 2^230 * h9| = |h0 + ... + 2^204 * h8| < 2^204 * 2^30 = 2^234.
    32      * ==> -1/4 <= b := 19 * 2^-255 * (h - 2^230 * h9) < 1/4</pre>
    33      * Therefore 0 < 1/2 - a - b < 1.
     29     * <pre>|h| &lt; 2^230 * 2^30 = 2^260 ==&gt; |r + q * p| &lt; 2^260 ==&gt; |q| &lt; 2^10.
     30     * ==&gt; -1/4 &lt;= a := 19^2 * 2^-255 * q &lt; 1/4.
     31     * |h - 2^230 * h9| = |h0 + ... + 2^204 * h8| &lt; 2^204 * 2^30 = 2^234.
     32     * ==&gt; -1/4 &lt;= b := 19 * 2^-255 * (h - 2^230 * h9) &lt; 1/4</pre>
     33     * Therefore 0 &lt; 1/2 - a - b &lt; 1.
    3434     * <p>
    3535     * Set x := r + 19 * 2^-255 * r + 1/2 - a - b then
    36      * 0 <= x < 255 - 20 + 19 + 1 = 2^255 ==> 0 <= 2^-255 * x < 1. Since q is an integer we have
     36     * 0 &lt;= x &lt; 255 - 20 + 19 + 1 = 2^255 ==&gt; 0 &lt;= 2^-255 * x &lt; 1. Since q is an integer we have
    3737     *
    3838     * <pre>[q + 2^-255 * x] = q        (1)</pre>
     
    214214     * <p><ul>
    215215     * <li>|x| bounded by 1.1*2^26,1.1*2^25,1.1*2^26,1.1*2^25,etc.
     216     * </ul>
    216217     *
    217218     * @return true if x is in {1,3,5,...,q-2}, false otherwise.
  • core/java/src/net/i2p/crypto/elgamal/ElGamalSigEngine.java

    r44c0d93 r50450ec  
    148148
    149149    /**
    150      * @deprecated replaced with <a href="#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">
     150     * @deprecated replaced with <a href="#engineSetParameter(java.security.spec.AlgorithmParameterSpec)">this</a>
    151151     */
    152152    @Override
  • core/java/src/net/i2p/data/Certificate.java

    r44c0d93 r50450ec  
    117117
    118118    /**
    119      *  @throws IllegalArgumentException if type < 0
     119     *  @throws IllegalArgumentException if type &lt; 0
    120120     */
    121121    public Certificate(int type, byte[] payload) {
     
    132132
    133133    /**
    134      *  @throws IllegalArgumentException if type < 0
     134     *  @throws IllegalArgumentException if type &lt; 0
    135135     *  @throws IllegalStateException if already set
    136136     */
  • core/java/src/net/i2p/data/DataHelper.java

    r44c0d93 r50450ec  
    737737     * @param numBytes 1-8
    738738     * @return non-negative
    739      * @throws AIOOBE
     739     * @throws ArrayIndexOutOfBoundsException
    740740     * @throws IllegalArgumentException if negative (only possible if numBytes = 8)
    741741     */
     
    761761     * @param numBytes 1-8
    762762     * @return non-negative
    763      * @throws AIOOBE
     763     * @throws ArrayIndexOutOfBoundsException
    764764     * @throws IllegalArgumentException if negative (only possible if numBytes = 8)
    765765     * @since 0.8.12
     
    10071007    /**
    10081008     * Helper util to compare two objects, including null handling.
    1009      * <p />
     1009     * <p>
    10101010     *
    10111011     * This treats (null == null) as true, and (null == (!null)) as false.
     
    10221022    /**
    10231023     * Run a deep comparison across the two collections. 
    1024      * <p />
     1024     * <p>
    10251025     *
    10261026     * This treats (null == null) as true, (null == (!null)) as false, and then
    1027      * comparing each element via eq(object, object). <p />
     1027     * comparing each element via eq(object, object). <p>
    10281028     *
    10291029     * If the size of the collections are not equal, the comparison returns false.
     
    10441044
    10451045    /**
    1046      * Run a comparison on the byte arrays, byte by byte.  <p />
     1046     * Run a comparison on the byte arrays, byte by byte.  <p>
    10471047     *
    10481048     * This treats (null == null) as true, (null == (!null)) as false,
     
    16281628    /**
    16291629     *  Compress the data and return a new GZIP compressed byte array.
    1630      *  @throws IllegalArgumentException if size is over 40KB
     1630     *  @throws IllegalArgumentException if input size is over 40KB
    16311631     */
    16321632    public static byte[] compress(byte orig[]) {
  • core/java/src/net/i2p/data/Hash.java

    r44c0d93 r50450ec  
    4848    /**
    4949     * Pull from cache or return new
    50      * @throws AIOOBE if not enough bytes
     50     * @throws ArrayIndexOutOfBoundsException if not enough bytes
    5151     * @since 0.8.3
    5252     */
  • core/java/src/net/i2p/data/PrivateKeyFile.java

    r44c0d93 r50450ec  
    254254   
    255255    /**
    256      *  @param padding null OK, must be non-null if spubkey length < 128
     256     *  @param padding null OK, must be non-null if spubkey length &lt; 128
    257257     *  @throws IllegalArgumentException on mismatch of spubkey and spk types
    258258     *  @since 0.9.16
  • core/java/src/net/i2p/data/PublicKey.java

    r44c0d93 r50450ec  
    3030     * Deprecated - used only by deprecated Destination.readBytes(data, off)
    3131     *
    32      * @throws AIOOBE if not enough bytes, FIXME should throw DataFormatException
     32     * @throws ArrayIndexOutOfBoundsException if not enough bytes, FIXME should throw DataFormatException
    3333     * @since 0.8.3
    3434     */
  • core/java/src/net/i2p/data/SDSCache.java

    r44c0d93 r50450ec  
    2626 *  <pre>
    2727
    28     private static final SDSCache<Foo> _cache = new SDSCache(Foo.class, LENGTH, 1024);
     28    private static final SDSCache&lt;Foo&gt; _cache = new SDSCache(Foo.class, LENGTH, 1024);
    2929
    3030    public static Foo create(byte[] data) {
     
    114114     *          makes a new object and returns it
    115115     *  @throws IllegalArgumentException if data is not the correct number of bytes
    116      *  @throws NPE
     116     *  @throws NullPointerException
    117117     */
    118118    public V get(byte[] data) {
     
    156156     *  @return the cached value if available, otherwise
    157157     *          makes a new object and returns it
    158      *  @throws AIOOBE if not enough bytes
    159      *  @throws NPE
     158     *  @throws ArrayIndexOutOfBoundsException if not enough bytes
     159     *  @throws NullPointerException
    160160     */
    161161    public V get(byte[] b, int off) {
  • core/java/src/net/i2p/data/SigningPublicKey.java

    r44c0d93 r50450ec  
    4141     * Deprecated - used only by deprecated Destination.readBytes(data, off)
    4242     *
    43      * @throws AIOOBE if not enough bytes, FIXME should throw DataFormatException
     43     * @throws ArrayIndexOutOfBoundsException if not enough bytes, FIXME should throw DataFormatException
    4444     * @since 0.8.3
    4545     */
     
    151151     *  if any
    152152     *
    153      *  @return leading padding length > 0 or null if no padding or type is unknown
     153     *  @return leading padding length &gt; 0 or null if no padding or type is unknown
    154154     *  @throws IllegalArgumentException if this is already typed to a different type
    155155     *  @since 0.9.12
  • core/java/src/net/i2p/data/i2cp/I2CPMessageImpl.java

    r44c0d93 r50450ec  
    2929
    3030    /**
    31      * Validate the type and size of the message, and then read the message into the data structures.  <p />
     31     * Validate the type and size of the message, and then read the message into the data structures.  <p>
    3232     *
    3333     * @throws IOException
  • core/java/src/net/i2p/data/i2cp/RequestVariableLeaseSetMessage.java

    r44c0d93 r50450ec  
    4545     *
    4646     *  @param clientVersion may be null
    47      *  @return version != null and version >= 0.9.7
     47     *  @return version != null and version &gt;= 0.9.7
    4848     */
    4949    public static boolean isSupported(String clientVersion) {
  • core/java/src/net/i2p/kademlia/KBucketImpl.java

    r44c0d93 r50450ec  
    3535 *  Per-key last-seen-time, failures, etc. must be tracked elsewhere.
    3636 *
    37  *  If this bucket is full (i.e. begin == end && size == max)
     37 *  If this bucket is full (i.e. begin == end &amp;&amp; size == max)
    3838 *  then add() will call KBucketTrimmer.trim() do
    3939 *  (possibly) remove older entries, and indicate whether
  • core/java/src/net/i2p/kademlia/KBucketSet.java

    r44c0d93 r50450ec  
    7373     * @param us the local identity (typically a SHA1Hash or Hash)
    7474     *           The class must have a zero-argument constructor.
    75      * @param max the Kademlia value "k", the max per bucket, k >= 4
     75     * @param max the Kademlia value "k", the max per bucket, k &gt;= 4
    7676     * @param b the Kademlia value "b", split buckets an extra 2**(b-1) times,
    77      *           b > 0, use 1 for bittorrent, Kademlia paper recommends 5
     77     *           b &gt; 0, use 1 for bittorrent, Kademlia paper recommends 5
    7878     */
    7979    public KBucketSet(I2PAppContext context, T us, int max, int b) {
     
    169169    /**
    170170     *  No lock required.
    171      *  FIXME will split the closest buckets too far if B > 1 and K < 2**B
     171     *  FIXME will split the closest buckets too far if B &gt; 1 and K &lt; 2**B
    172172     *  Won't ever really happen and if it does it still works.
    173173     */
     
    626626    /**
    627627     *  Make a new SimpleDataStrucure from the data
    628      *  @param data size <= SDS length, else throws IAE
     628     *  @param data size &lt;= SDS length, else throws IAE
    629629     *              Can be 1 bigger if top byte is zero
    630630     */
  • core/java/src/net/i2p/stat/Rate.java

    r44c0d93 r50450ec  
    139139    /**
    140140     * Create a new rate and load its state from the properties, taking data
    141      * from the data points underneath the given prefix.  <p />
     141     * from the data points underneath the given prefix.  <p>
    142142     * (e.g. prefix = "profile.dbIntroduction.60m", this will load the associated data points such
    143143     * as "profile.dbIntroduction.60m.lifetimeEventCount").  The data can be exported
  • core/java/src/net/i2p/stat/RateAverages.java

    r44c0d93 r50450ec  
    3939     * @since 0.9.4
    4040     * @return one of several things:
    41      * if there are any events (current or last) => weighted average
     41     * if there are any events (current or last) =&gt; weighted average
    4242     * otherwise if the useLifetime parameter to Rate.computeAverages was:
    43      * true => the lifetime average value
    44      * false => zero
     43     * true =&gt; the lifetime average value
     44     * false =&gt; zero
    4545     */
    4646    public double getAverage() {
  • core/java/src/net/i2p/util/Addresses.java

    r44c0d93 r50450ec  
    5757        // not as good as using a Java DBus implementation to talk to NetworkManager...
    5858        return !getAddresses(true, false, false).isEmpty();
     59    }
     60
     61    /**
     62     *  Do we have any non-loop, non-wildcard IPv6 address at all?
     63     *  @since 0.9.29
     64     */
     65    public static boolean isConnectedIPv6() {
     66        // not as good as using a Java DBus implementation to talk to NetworkManager...
     67        for (String ip : getAddresses(false, true)) {
     68            if (ip.contains(":"))
     69                return true;
     70        }
     71        return false;
    5972    }
    6073
     
    600613            System.out.println(buf.toString());
    601614        }
    602         System.out.println("\nIs connected? " + isConnected());
     615        System.out.println("\nIs connected? " + isConnected() +
     616                           "\nHas IPv6?     " + isConnectedIPv6());
    603617    }
    604618}
  • core/java/src/net/i2p/util/EepGet.java

    r44c0d93 r50450ec  
    608608     * Blocking fetch.
    609609     *
    610      * @param fetchHeaderTimeout <= 0 for none (proxy will timeout if none, none isn't recommended if no proxy)
    611      * @param totalTimeout <= 0 for default none
    612      * @param inactivityTimeout <= 0 for default 60 sec
     610     * @param fetchHeaderTimeout &lt;= 0 for none (proxy will timeout if none, none isn't recommended if no proxy)
     611     * @param totalTimeout &lt;= 0 for default none
     612     * @param inactivityTimeout &lt;= 0 for default 60 sec
    613613     */
    614614    public boolean fetch(long fetchHeaderTimeout, long totalTimeout, long inactivityTimeout) {
  • core/java/src/net/i2p/util/EventDispatcher.java

    r44c0d93 r50450ec  
    1414/**
    1515 * Event dispatching interface.  It allows objects to receive and
    16  * notify data events (basically String->Object associations) and
     16 * notify data events (basically String-&gt;Object associations) and
    1717 * create notification chains.  To ease the usage of this interface,
    1818 * you could define an EventDispatcherImpl attribute called
  • core/java/src/net/i2p/util/InternalServerSocket.java

    r44c0d93 r50450ec  
    3232
    3333    /**
    34      *  @param port > 0
     34     *  @param port &gt; 0
    3535     */
    3636    public InternalServerSocket(int port) throws IOException {
     
    8888     *  This is how the client connects.
    8989     *
    90      *  @param port > 0
     90     *  @param port &gt; 0
    9191     */
    9292    static void internalConnect(int port, InternalSocket clientSock) throws IOException {
  • core/java/src/net/i2p/util/InternalSocket.java

    r44c0d93 r50450ec  
    2727    /**
    2828     *  client side
    29      *  @param port > 0
     29     *  @param port &gt; 0
    3030     */
    3131    public InternalSocket(int port) throws IOException {
     
    3737    /**
    3838     *  Convenience method to return either a Socket or an InternalSocket
    39      *  @param port > 0
     39     *  @param port &gt; 0
    4040     */
    4141    public static Socket getSocket(String host, int port) throws IOException {
  • core/java/src/net/i2p/util/Log.java

    r44c0d93 r50450ec  
    207207   
    208208    /**
    209      * logs a loop when closing a resource with level INFO
     209     * logs a loop when closing a resource with level DEBUG
    210210     * This method is for debugging purposes only and
    211      * as such subject to change or removal w/o notice.
     211     * is subject to change or removal w/o notice.
     212     * NOT a supported API.
    212213     * @param desc vararg description
    213214     * @since 0.9.8
    214215     */
    215216    public void logCloseLoop(Object... desc) {
    216         logCloseLoop(Log.INFO, desc);
     217        logCloseLoop(Log.DEBUG, desc);
    217218    }
    218219   
     
    220221     * Logs a close loop when closing a resource
    221222     * This method is for debugging purposes only and
    222      * as such subject to change or removal w/o notice.
     223     * is subject to change or removal w/o notice.
     224     * NOT a supported API.
    223225     * @param desc vararg description of the resource
    224226     * @param level level at which to log
  • core/java/src/net/i2p/util/ObjectCounter.java

    r44c0d93 r50450ec  
    4545
    4646    /**
    47      *  @return set of objects with counts > 0
     47     *  @return set of objects with counts &gt; 0
    4848     */
    4949    public Set<K> objects() {
  • core/java/src/net/i2p/util/PortMapper.java

    r44c0d93 r50450ec  
    5151    /**
    5252     *  Add the service
    53      *  @param port > 0
     53     *  @param port &gt; 0
    5454     *  @return success, false if already registered
    5555     */
     
    6060    /**
    6161     *  Add the service
    62      *  @param port > 0
     62     *  @param port &gt; 0
    6363     *  @return success, false if already registered
    6464     *  @since 0.9.21
  • core/java/src/net/i2p/util/ReusableGZIPInputStream.java

    r44c0d93 r50450ec  
    6464        byte b[] = "hi, how are you today?".getBytes();
    6565        try {
    66             ByteArrayOutputStream baos = new ByteArrayOutputStream(64);
    67             GZIPOutputStream o = new GZIPOutputStream(baos);
     66            java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(64);
     67            ResettableGZIPOutputStream o = new ResettableGZIPOutputStream(baos);
    6868            o.write(b);
    6969            o.finish();
     
    7272           
    7373            ReusableGZIPInputStream in = ReusableGZIPInputStream.acquire();
    74             in.initialize(new ByteArrayInputStream(compressed));
     74            in.initialize(new java.io.ByteArrayInputStream(compressed));
    7575            byte rv[] = new byte[128];
    7676            int read = in.read(rv);
    77             if (!DataHelper.eq(rv, 0, b, 0, b.length))
     77            if (!net.i2p.data.DataHelper.eq(rv, 0, b, 0, b.length))
    7878                throw new RuntimeException("foo, read=" + read);
    7979            else
     
    8585    private static boolean test(int size) {
    8686        byte b[] = new byte[size];
    87         new java.util.Random().nextBytes(b);
     87        RandomSource.getInstance().nextBytes(b);
    8888        try {
    89             ByteArrayOutputStream baos = new ByteArrayOutputStream(size);
    90             GZIPOutputStream o = new GZIPOutputStream(baos);
     89            java.io.ByteArrayOutputStream baos = new java.io.ByteArrayOutputStream(size);
     90            ResettableGZIPOutputStream o = new ResettableGZIPOutputStream(baos);
    9191            o.write(b);
    9292            o.finish();
     
    9595           
    9696            ReusableGZIPInputStream in = ReusableGZIPInputStream.acquire();
    97             in.initialize(new ByteArrayInputStream(compressed));
    98             ByteArrayOutputStream baos2 = new ByteArrayOutputStream(size);
     97            in.initialize(new java.io.ByteArrayInputStream(compressed));
     98            java.io.ByteArrayOutputStream baos2 = new java.io.ByteArrayOutputStream(size);
    9999            byte rbuf[] = new byte[128];
    100100            try {
     
    105105                    baos2.write(rbuf, 0, read);
    106106                }
    107             } catch (IOException ioe) {
     107            } catch (java.io.IOException ioe) {
    108108                ioe.printStackTrace();
    109                 long crcVal = in.getCurrentCRCVal();
     109                //long crcVal = in.getCurrentCRCVal();
    110110                //try { in.verifyFooter(); } catch (IOException ioee) {
    111111                //    ioee.printStackTrace();
     
    121121                throw new RuntimeException("read length: " + rv.length + " expected: " + b.length);
    122122           
    123             if (!DataHelper.eq(rv, 0, b, 0, b.length)) {
     123            if (!net.i2p.data.DataHelper.eq(rv, 0, b, 0, b.length)) {
    124124                throw new RuntimeException("foo, read=" + rv.length);
    125125            } else {
    126                 System.out.println("match, w00t");
     126                System.out.println("match, w00t @ " + size);
    127127                return true;
    128128            }
  • core/java/src/net/i2p/util/ReusableGZIPOutputStream.java

    r44c0d93 r50450ec  
    9090            for (int i = 0; i < 2; i++)
    9191                test();
    92             for (int i = 500; i < 64*1024; i++) {
     92            for (int i = 0; i < 64*1024; i++) {
    9393                if (!test(i)) break;
    9494            }
     
    107107            ReusableGZIPOutputStream.release(o);
    108108           
    109             GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(compressed));
     109            ResettableGZIPInputStream in = new ResettableGZIPInputStream(new java.io.ByteArrayInputStream(compressed));
    110110            byte rv[] = new byte[128];
    111111            int read = in.read(rv);
     
    119119    private static boolean test(int size) {
    120120        byte b[] = new byte[size];
    121         new java.util.Random().nextBytes(b);
     121        RandomSource.getInstance().nextBytes(b);
    122122        try {
    123123            ReusableGZIPOutputStream o = ReusableGZIPOutputStream.acquire();
     
    128128            ReusableGZIPOutputStream.release(o);
    129129           
    130             GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(compressed));
    131             ByteArrayOutputStream baos2 = new ByteArrayOutputStream(256*1024);
     130            ResettableGZIPInputStream in = new ResettableGZIPInputStream(new java.io.ByteArrayInputStream(compressed));
     131            ByteArrayOutputStream baos2 = new ByteArrayOutputStream(size);
    132132            byte rbuf[] = new byte[128];
    133133            while (true) {
  • core/java/src/net/i2p/util/SSLEepGet.java

    r44c0d93 r50450ec  
    272272            _stm = new SavingTrustManager(defaultTrustManager);
    273273            sslc.init(null, new TrustManager[] {_stm}, null);
     274        /****
    274275            if (_log.shouldLog(Log.DEBUG)) {
    275276                SSLEngine eng = sslc.createSSLEngine();
     
    316317                }
    317318            }
     319          ****/
    318320            return sslc;
    319321        } catch (GeneralSecurityException gse) {
    320322            _log.error("Key Store update error", gse);
     323        } catch (ExceptionInInitializerError eiie) {
     324            // java 9 b134 see ../crypto/CryptoCheck for example
     325            // Catching this may be pointless, fetch still fails
     326            _log.error("SSL context error - Java 9 bug?", eiie);
    321327        }
    322328        return null;
  • core/java/src/net/i2p/util/SimpleTimer2.java

    r44c0d93 r50450ec  
    209209     *
    210210     * valid transitions:
    211      * {IDLE,CANCELLED,RUNNING} -> SCHEDULED [ -> SCHEDULED ]* -> RUNNING -> {IDLE,CANCELLED,SCHEDULED}
    212      * {IDLE,CANCELLED,RUNNING} -> SCHEDULED [ -> SCHEDULED ]* -> CANCELLED
     211     * {IDLE,CANCELLED,RUNNING} -&gt; SCHEDULED [ -&gt; SCHEDULED ]* -&gt; RUNNING -&gt; {IDLE,CANCELLED,SCHEDULED}
     212     * {IDLE,CANCELLED,RUNNING} -&gt; SCHEDULED [ -&gt; SCHEDULED ]* -&gt; CANCELLED
    213213     *
    214214     * anything else is invalid.
     
    232232     *
    233233     * Other porting:
    234      *   SimpleTimer.getInstance().addEvent(new foo(), timeout) => new foo(SimpleTimer2.getInstance(), timeout)
    235      *   SimpleTimer.getInstance().addEvent(this, timeout) => schedule(timeout)
    236      *   SimpleTimer.getInstance().addEvent(foo, timeout) => foo.reschedule(timeout)
    237      *   SimpleTimer.getInstance().removeEvent(foo) => foo.cancel()
     234     *   SimpleTimer.getInstance().addEvent(new foo(), timeout) =&gt; new foo(SimpleTimer2.getInstance(), timeout)
     235     *   SimpleTimer.getInstance().addEvent(this, timeout) =&gt; schedule(timeout)
     236     *   SimpleTimer.getInstance().addEvent(foo, timeout) =&gt; foo.reschedule(timeout)
     237     *   SimpleTimer.getInstance().removeEvent(foo) =&gt; foo.cancel()
    238238     *
    239239     * There's no global locking, but for scheduling, we synchronize on this
  • core/java/src/net/i2p/util/SystemVersion.java

    r44c0d93 r50450ec  
    2121     */
    2222    public static final String DAEMON_USER = "i2psvc";
     23    public static final String GENTOO_USER = "i2p";
    2324
    2425    private static final boolean _isWin = System.getProperty("os.name").startsWith("Win");
     
    6465        _isOpenJDK = runtime != null && runtime.contains("OpenJDK");
    6566        _isLinuxService = !_isWin && !_isMac && !_isAndroid &&
    66                           DAEMON_USER.equals(System.getProperty("user.name"));
     67                          (DAEMON_USER.equals(System.getProperty("user.name")) ||
     68                           (_isGentoo && GENTOO_USER.equals(System.getProperty("user.name"))));
    6769
    6870        int sdk = 0;
     
    150152
    151153    /**
    152      *  Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") >= 0
     154     *  Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.6") &gt;= 0
    153155     *  as it handles Android also, where java.version = "0".
    154156     *
     
    160162
    161163    /**
    162      *  Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.7") >= 0
     164     *  Better than (new VersionComparator()).compare(System.getProperty("java.version"), "1.7") &gt;= 0
    163165     *  as it handles Android also, where java.version = "0".
    164166     *
     
    194196     * http://mark.koli.ch/2009/10/reliably-checking-os-bitness-32-or-64-bit-on-windows-with-a-tiny-c-app.html
    195197     * sun.arch.data.model not on all JVMs
    196      * sun.arch.data.model == 64 => 64 bit processor
    197      * sun.arch.data.model == 32 => A 32 bit JVM but could be either 32 or 64 bit processor or libs
     198     * sun.arch.data.model == 64 =&gt; 64 bit processor
     199     * sun.arch.data.model == 32 =&gt; A 32 bit JVM but could be either 32 or 64 bit processor or libs
    198200     * os.arch contains "64" could be 32 or 64 bit libs
    199201     */
  • core/java/src/net/i2p/util/Translate.java

    r44c0d93 r50450ec  
    6868     *  @param s string to be translated containing {0}
    6969     *    The {0} will be replaced by the parameter.
    70      *    Single quotes must be doubled, i.e. ' -> '' in the string.
     70     *    Single quotes must be doubled, i.e. ' -&gt; '' in the string.
    7171     *  @param o parameter, not translated.
    7272     *    To translate parameter also, use _t("foo {0} bar", _t("baz"))
  • core/java/src/net/i2p/util/ZipFileComment.java

    r44c0d93 r50450ec  
    3838     *          The string is decoded with UTF-8
    3939     *
    40      *  @throws IOE if no valid end-of-central-directory record found
     40     *  @throws IOException if no valid end-of-central-directory record found
    4141     */
    4242    public static String getComment(File file, int max) throws IOException {
     
    5454     *          The string is decoded with UTF-8
    5555     *
    56      *  @throws IOE if no valid end-of-central-directory record found
     56     *  @throws IOException if no valid end-of-central-directory record found
    5757     */
    5858    public static String getComment(File file, int max, int skip) throws IOException {
  • core/java/src/net/metanotion/io/block/BlockFile.java

    r44c0d93 r50450ec  
    338338         *  Go to any page but the superblock.
    339339         *  Page 1 is the superblock, must use file.seek(0) to get there.
    340          *  @param page >= 2
     340         *  @param page &gt;= 2
    341341         */
    342342        public static void pageSeek(RandomAccessInterface file, int page) throws IOException {
  • core/java/src/net/metanotion/io/block/index/BSkipList.java

    r44c0d93 r50450ec  
    222222****/
    223223
     224        /** find */
    224225        @Override
    225226        public SkipIterator<K, V> find(K key) {
  • core/java/src/org/bouncycastle/oldcrypto/Mac.java

    r44c0d93 r50450ec  
    3939     *
    4040     * @param key the key required by the MAC.
    41      * @exception IllegalArgumentException if the params argument is
     41     * @throws IllegalArgumentException if the params argument is
    4242     * inappropriate.
    4343     */
     
    6363     *
    6464     * @param in the byte to be processed.
    65      * @exception IllegalStateException if the MAC is not initialised.
     65     * @throws IllegalStateException if the MAC is not initialised.
    6666     */
    6767    public void update(byte in)
     
    7272     * @param inOff the index in the array the data begins at.
    7373     * @param len the length of the input starting at inOff.
    74      * @exception IllegalStateException if the MAC is not initialised.
     74     * @throws IllegalStateException if the MAC is not initialised.
    7575     */
    7676    public void update(byte[] in, int inOff, int len)
     
    8585     * @param out the array the MAC is to be output to.
    8686     * @param outOff the offset into the out buffer the output is to start at.
    87      * @exception IllegalStateException if the MAC is not initialised.
     87     * @throws IllegalStateException if the MAC is not initialised.
    8888     */
    8989    public int doFinal(byte[] out, int outOff)
Note: See TracChangeset for help on using the changeset viewer.