forked from I2P_Developers/i2p.i2p
KeysAndCert: Change hashcode to prevent possible collisions
caused by apps with zeroed pubkey
This commit is contained in:
@ -130,17 +130,19 @@ public class KeysAndCert extends DataStructureImpl {
|
|||||||
&& DataHelper.eq(_certificate, ident._certificate);
|
&& DataHelper.eq(_certificate, ident._certificate);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** the public key has enough randomness in it to use it by itself for speed */
|
/** the signing key has enough randomness in it to use it by itself for speed */
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
if (_publicKey == null)
|
// don't use public key, some app devs thinking of using
|
||||||
|
// an all-zeros or leading-zeros public key for destinations
|
||||||
|
if (_signingKey == null)
|
||||||
return 0;
|
return 0;
|
||||||
return _publicKey.hashCode();
|
return _signingKey.hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder buf = new StringBuilder(64);
|
StringBuilder buf = new StringBuilder(256);
|
||||||
buf.append('[').append(getClass().getSimpleName()).append(": ");
|
buf.append('[').append(getClass().getSimpleName()).append(": ");
|
||||||
buf.append("\n\tHash: ").append(getHash().toBase64());
|
buf.append("\n\tHash: ").append(getHash().toBase64());
|
||||||
buf.append("\n\tCertificate: ").append(_certificate);
|
buf.append("\n\tCertificate: ").append(_certificate);
|
||||||
|
Reference in New Issue
Block a user