I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 2878a648 authored by zzz's avatar zzz
Browse files

KeysAndCert: Change hashcode to prevent possible collisions

caused by apps with zeroed pubkey
parent 9655e79d
No related branches found
No related tags found
No related merge requests found
...@@ -130,17 +130,19 @@ public class KeysAndCert extends DataStructureImpl { ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment