Changeset 2878a648


Ignore:
Timestamp:
Aug 7, 2014 5:05:25 PM (6 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
79fe799
Parents:
9655e79
Message:

KeysAndCert?: Change hashcode to prevent possible collisions
caused by apps with zeroed pubkey

File:
1 edited

Legend:

Unmodified
Added
Removed
  • core/java/src/net/i2p/data/KeysAndCert.java

    r9655e79 r2878a648  
    131131    }
    132132   
    133     /** the public key has enough randomness in it to use it by itself for speed */
     133    /** the signing key has enough randomness in it to use it by itself for speed */
    134134    @Override
    135135    public int hashCode() {
    136         if (_publicKey == null)
     136        // don't use public key, some app devs thinking of using
     137        // an all-zeros or leading-zeros public key for destinations
     138        if (_signingKey == null)
    137139            return 0;
    138         return _publicKey.hashCode();
     140        return _signingKey.hashCode();
    139141    }
    140142   
    141143    @Override
    142144    public String toString() {
    143         StringBuilder buf = new StringBuilder(64);
     145        StringBuilder buf = new StringBuilder(256);
    144146        buf.append('[').append(getClass().getSimpleName()).append(": ");
    145147        buf.append("\n\tHash: ").append(getHash().toBase64());
Note: See TracChangeset for help on using the changeset viewer.