From d41b68438df2c9e1c391d084264a9952dcf616f3 Mon Sep 17 00:00:00 2001 From: dev <dev@welterde.de> Date: Sat, 8 Nov 2008 23:14:47 +0000 Subject: [PATCH] and another bunch --- .../src/net/i2p/crypto/AESInputStream.java | 27 ++++++++++++------- .../src/net/i2p/crypto/AESOutputStream.java | 15 +++++++---- .../src/net/i2p/crypto/CryptixAESEngine.java | 12 ++++++--- .../net/i2p/crypto/DHSessionKeyBuilder.java | 3 ++- .../src/net/i2p/crypto/DummyDSAEngine.java | 4 ++- .../net/i2p/crypto/DummyElGamalEngine.java | 2 ++ .../i2p/crypto/DummyPooledRandomSource.java | 10 +++++++ .../src/net/i2p/crypto/HMAC256Generator.java | 4 +++ core/java/src/net/i2p/crypto/SHA1.java | 6 +++++ .../crypto/TransientSessionKeyManager.java | 16 +++++++++-- core/java/src/net/i2p/data/Address.java | 7 ++++- core/java/src/net/i2p/data/ByteArray.java | 10 ++++--- core/java/src/net/i2p/data/Certificate.java | 13 +++++---- .../src/net/i2p/data/DataStructureImpl.java | 11 ++++---- core/java/src/net/i2p/data/Destination.java | 16 +++++++---- core/java/src/net/i2p/data/Hash.java | 14 +++++++--- core/java/src/net/i2p/data/Lease.java | 15 +++++++---- core/java/src/net/i2p/data/LeaseSet.java | 15 +++++++---- core/java/src/net/i2p/data/Payload.java | 15 +++++++---- core/java/src/net/i2p/data/PrivateKey.java | 15 +++++++---- core/java/src/net/i2p/data/PublicKey.java | 15 +++++++---- core/java/src/net/i2p/data/RouterAddress.java | 15 +++++++---- .../java/src/net/i2p/data/RouterIdentity.java | 18 ++++++++----- core/java/src/net/i2p/data/RouterInfo.java | 15 +++++++---- core/java/src/net/i2p/data/SessionKey.java | 13 ++++++--- core/java/src/net/i2p/data/SessionTag.java | 3 ++- core/java/src/net/i2p/data/Signature.java | 13 ++++++--- .../src/net/i2p/data/SigningPrivateKey.java | 7 ++++- .../src/net/i2p/data/SigningPublicKey.java | 5 ++++ core/java/src/net/i2p/data/TunnelId.java | 5 ++++ .../src/net/i2p/data/VerifiedDestination.java | 1 + 31 files changed, 245 insertions(+), 95 deletions(-) diff --git a/core/java/src/net/i2p/crypto/AESInputStream.java b/core/java/src/net/i2p/crypto/AESInputStream.java index f4ec8533d6..58325649e9 100644 --- a/core/java/src/net/i2p/crypto/AESInputStream.java +++ b/core/java/src/net/i2p/crypto/AESInputStream.java @@ -69,7 +69,8 @@ public class AESInputStream extends FilterInputStream { _cumulativePaddingStripped = 0; _eofFound = false; } - + + @Override public int read() throws IOException { while ((!_eofFound) && (_decryptedSize <= 0)) { refill(); @@ -87,11 +88,13 @@ public class AESInputStream extends FilterInputStream { + "/" + _cumulativeRead + "... impossible"); } } - + + @Override public int read(byte dest[]) throws IOException { return read(dest, 0, dest.length); } - + + @Override public int read(byte dest[], int off, int len) throws IOException { for (int i = 0; i < len; i++) { int val = read(); @@ -120,7 +123,8 @@ public class AESInputStream extends FilterInputStream { _log.debug("Read the full buffer of size " + len); return len; } - + + @Override public long skip(long numBytes) throws IOException { for (long l = 0; l < numBytes; l++) { int val = read(); @@ -128,11 +132,13 @@ public class AESInputStream extends FilterInputStream { } return numBytes; } - + + @Override public int available() throws IOException { return _decryptedSize; } - + + @Override public void close() throws IOException { in.close(); if (_log.shouldLog(Log.DEBUG)) @@ -140,14 +146,17 @@ public class AESInputStream extends FilterInputStream { + _cumulativePrepared + "/" + _cumulativePaddingStripped + "] remaining [" + _decryptedSize + " ready, " + _writesSinceDecrypt + " still encrypted]"); } - + + @Override public void mark(int readLimit) { // nop } - + + @Override public void reset() throws IOException { throw new IOException("Reset not supported"); } - + + @Override public boolean markSupported() { return false; } diff --git a/core/java/src/net/i2p/crypto/AESOutputStream.java b/core/java/src/net/i2p/crypto/AESOutputStream.java index 3deea7f496..a8a6395624 100644 --- a/core/java/src/net/i2p/crypto/AESOutputStream.java +++ b/core/java/src/net/i2p/crypto/AESOutputStream.java @@ -62,25 +62,29 @@ public class AESOutputStream extends FilterOutputStream { _writeBlock = new byte[BLOCK_SIZE]; _writesSinceCommit = 0; } - + + @Override public void write(int val) throws IOException { _cumulativeProvided++; _unencryptedBuf[_writesSinceCommit++] = (byte)(val & 0xFF); if (_writesSinceCommit == _unencryptedBuf.length) doFlush(); } - + + @Override public void write(byte src[]) throws IOException { write(src, 0, src.length); } - + + @Override public void write(byte src[], int off, int len) throws IOException { // i'm too lazy to unroll this into the partial writes (dealing with // wrapping around the buffer size) for (int i = 0; i < len; i++) write(src[i+off]); } - + + @Override public void close() throws IOException { flush(); out.close(); @@ -88,7 +92,8 @@ public class AESOutputStream extends FilterOutputStream { _log.debug("Cumulative bytes provided to this stream / written out / padded: " + _cumulativeProvided + "/" + _cumulativeWritten + "/" + _cumulativePadding); } - + + @Override public void flush() throws IOException { doFlush(); out.flush(); diff --git a/core/java/src/net/i2p/crypto/CryptixAESEngine.java b/core/java/src/net/i2p/crypto/CryptixAESEngine.java index 626869c315..b2d92bc063 100644 --- a/core/java/src/net/i2p/crypto/CryptixAESEngine.java +++ b/core/java/src/net/i2p/crypto/CryptixAESEngine.java @@ -40,11 +40,13 @@ public class CryptixAESEngine extends AESEngine { _log = context.logManager().getLog(CryptixAESEngine.class); _cache = new CryptixAESKeyCache(); } - + + @Override public void encrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int length) { encrypt(payload, payloadIndex, out, outIndex, sessionKey, iv, 0, length); } + @Override public void encrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) { if ( (payload == null) || (out == null) || (sessionKey == null) || (iv == null) ) throw new NullPointerException("invalid args to aes"); @@ -72,10 +74,12 @@ public class CryptixAESEngine extends AESEngine { encryptBlock(out, outIndex + x * 16, sessionKey, out, outIndex + x * 16); } } - + + @Override public void decrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int length) { decrypt(payload, payloadIndex, out, outIndex, sessionKey, iv, 0, length); } + @Override public void decrypt(byte payload[], int payloadIndex, byte out[], int outIndex, SessionKey sessionKey, byte iv[], int ivOffset, int length) { if ((iv== null) || (payload == null) || (payload.length <= 0) || (sessionKey == null) ) throw new IllegalArgumentException("bad setup"); @@ -121,7 +125,8 @@ public class CryptixAESEngine extends AESEngine { _prevCache.release(prevA); _prevCache.release(curA); } - + + @Override public final void encryptBlock(byte payload[], int inIndex, SessionKey sessionKey, byte out[], int outIndex) { if (sessionKey.getPreparedKey() == null) { try { @@ -140,6 +145,7 @@ public class CryptixAESEngine extends AESEngine { * @param payload encrypted data * @param sessionKey private session key */ + @Override public final void decryptBlock(byte payload[], int inIndex, SessionKey sessionKey, byte rv[], int outIndex) { if ( (payload == null) || (rv == null) ) throw new IllegalArgumentException("null block args [payload=" + payload + " rv="+rv); diff --git a/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java b/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java index d00f3d1aa7..bba9c93f8a 100644 --- a/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java +++ b/core/java/src/net/i2p/crypto/DHSessionKeyBuilder.java @@ -484,7 +484,8 @@ public class DHSessionKeyBuilder { _minSize = minSize; _maxSize = maxSize; } - + + @Override public void run() { while (true) { diff --git a/core/java/src/net/i2p/crypto/DummyDSAEngine.java b/core/java/src/net/i2p/crypto/DummyDSAEngine.java index 0140b23352..3a35a96298 100644 --- a/core/java/src/net/i2p/crypto/DummyDSAEngine.java +++ b/core/java/src/net/i2p/crypto/DummyDSAEngine.java @@ -14,10 +14,12 @@ public class DummyDSAEngine extends DSAEngine { super(context); } + @Override public boolean verifySignature(Signature signature, byte signedData[], SigningPublicKey verifyingKey) { return true; } - + + @Override public Signature sign(byte data[], SigningPrivateKey signingKey) { Signature sig = new Signature(); sig.setData(Signature.FAKE_SIGNATURE); diff --git a/core/java/src/net/i2p/crypto/DummyElGamalEngine.java b/core/java/src/net/i2p/crypto/DummyElGamalEngine.java index 2b2f5a9ece..9354d05c1c 100644 --- a/core/java/src/net/i2p/crypto/DummyElGamalEngine.java +++ b/core/java/src/net/i2p/crypto/DummyElGamalEngine.java @@ -46,6 +46,7 @@ public class DummyElGamalEngine extends ElGamalEngine { * @param publicKey public key encrypt to * @param data data to encrypt */ + @Override public byte[] encrypt(byte data[], PublicKey publicKey) { if ((data == null) || (data.length >= 223)) throw new IllegalArgumentException("Data to encrypt must be < 223 bytes at the moment"); @@ -72,6 +73,7 @@ public class DummyElGamalEngine extends ElGamalEngine { * @param privateKey private key to decrypt with * @return unencrypted data */ + @Override public byte[] decrypt(byte encrypted[], PrivateKey privateKey) { if ((encrypted == null) || (encrypted.length > 514)) throw new IllegalArgumentException("Data to decrypt must be <= 514 bytes at the moment"); diff --git a/core/java/src/net/i2p/crypto/DummyPooledRandomSource.java b/core/java/src/net/i2p/crypto/DummyPooledRandomSource.java index a29d923a5f..cd57fcb2f8 100644 --- a/core/java/src/net/i2p/crypto/DummyPooledRandomSource.java +++ b/core/java/src/net/i2p/crypto/DummyPooledRandomSource.java @@ -14,6 +14,7 @@ public class DummyPooledRandomSource extends PooledRandomSource { super(context); } + @Override protected void initializePool(I2PAppContext context) { _pool = new RandomSource[POOL_SIZE]; for (int i = 0; i < POOL_SIZE; i++) { @@ -40,6 +41,7 @@ public class DummyPooledRandomSource extends PooledRandomSource { * thats what it has been used for. * */ + @Override public int nextInt(int n) { if (n == 0) return 0; int val = _prng.nextInt(n); @@ -52,6 +54,7 @@ public class DummyPooledRandomSource extends PooledRandomSource { * Like the modified nextInt, nextLong(n) returns a random number from 0 through n, * including 0, excluding n. */ + @Override public long nextLong(long n) { long v = _prng.nextLong(); if (v < 0) v = 0 - v; @@ -63,36 +66,43 @@ public class DummyPooledRandomSource extends PooledRandomSource { * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public boolean nextBoolean() { return _prng.nextBoolean(); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public void nextBytes(byte buf[]) { _prng.nextBytes(buf); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public double nextDouble() { return _prng.nextDouble(); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public float nextFloat() { return _prng.nextFloat(); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public double nextGaussian() { return _prng.nextGaussian(); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public int nextInt() { return _prng.nextInt(); } /** * override as synchronized, for those JVMs that don't always pull via * nextBytes (cough ibm) */ + @Override public long nextLong() { return _prng.nextLong(); } } } diff --git a/core/java/src/net/i2p/crypto/HMAC256Generator.java b/core/java/src/net/i2p/crypto/HMAC256Generator.java index 9ad2b55a75..25e2c2fcd2 100644 --- a/core/java/src/net/i2p/crypto/HMAC256Generator.java +++ b/core/java/src/net/i2p/crypto/HMAC256Generator.java @@ -18,6 +18,7 @@ import org.bouncycastle.crypto.macs.HMac; public class HMAC256Generator extends HMACGenerator { public HMAC256Generator(I2PAppContext context) { super(context); } + @Override protected HMac acquire() { synchronized (_available) { if (_available.size() > 0) @@ -30,8 +31,11 @@ public class HMAC256Generator extends HMACGenerator { } private class Sha256ForMAC extends Sha256Standalone implements Digest { + @Override public String getAlgorithmName() { return "sha256 for hmac"; } + @Override public int getDigestSize() { return 32; } + @Override public int doFinal(byte[] out, int outOff) { byte rv[] = digest(); System.arraycopy(rv, 0, out, outOff, rv.length); diff --git a/core/java/src/net/i2p/crypto/SHA1.java b/core/java/src/net/i2p/crypto/SHA1.java index 66956ed092..d8a0ac1c20 100644 --- a/core/java/src/net/i2p/crypto/SHA1.java +++ b/core/java/src/net/i2p/crypto/SHA1.java @@ -97,6 +97,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { /** * Clones this object. */ + @Override public Object clone() throws CloneNotSupportedException { SHA1 that = (SHA1)super.clone(); that.pad = (byte[])this.pad.clone(); @@ -113,6 +114,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { * <code>java.security.MessageDigestSpi</code>. * @return the digest length in bytes. */ + @Override public int engineGetDigestLength() { return HASH_LENGTH; } @@ -123,6 +125,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { * Overrides the protected abstract method of * <code>java.security.MessageDigestSpi</code>. */ + @Override protected void engineReset() { int i = 60; do { @@ -179,6 +182,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { * @param offset the offset to start from in the array of bytes. * @param len the number of bytes to use, starting at offset. */ + @Override public void engineUpdate(byte[] input, int offset, int len) { if (offset >= 0 && len >= 0 && offset + len <= input.length) { bytes += len; @@ -234,6 +238,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { * java.security.MessageDigestSpi. * @return the length of the digest stored in the output buffer. */ + @Override public byte[] engineDigest() { try { final byte hashvalue[] = new byte[HASH_LENGTH]; @@ -264,6 +269,7 @@ public final class SHA1 extends MessageDigest implements Cloneable { * length. * @return the length of the digest stored in the output buffer. */ + @Override public int engineDigest(byte[] hashvalue, int offset, final int len) throws DigestException { if (len >= HASH_LENGTH) { diff --git a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java index fbe0448b46..7063275743 100644 --- a/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java +++ b/core/java/src/net/i2p/crypto/TransientSessionKeyManager.java @@ -75,6 +75,7 @@ class TransientSessionKeyManager extends SessionKeyManager { private TransientSessionKeyManager() { this(null); } private class CleanupEvent implements SimpleTimer.TimedEvent { + @Override public void timeReached() { long beforeExpire = _context.clock().now(); int expired = aggressiveExpire(); @@ -130,6 +131,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * or null if a new session key should be generated. * */ + @Override public SessionKey getCurrentKey(PublicKey target) { OutboundSession sess = getSession(target); if (sess == null) return null; @@ -151,6 +153,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * when to expire that key begin with this call. * */ + @Override public void createSession(PublicKey target, SessionKey key) { OutboundSession sess = new OutboundSession(target); sess.setCurrentKey(key); @@ -164,6 +167,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * NOT be used) * */ + @Override public SessionTag consumeNextAvailableTag(PublicKey target, SessionKey key) { OutboundSession sess = getSession(target); if (sess == null) { @@ -187,6 +191,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * have been confirmed and are available * */ + @Override public int getAvailableTags(PublicKey target, SessionKey key) { OutboundSession sess = getSession(target); if (sess == null) { return 0; } @@ -200,6 +205,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * Determine how long the available tags will be available for before expiring, in * milliseconds */ + @Override public long getAvailableTimeLeft(PublicKey target, SessionKey key) { OutboundSession sess = getSession(target); if (sess == null) { return 0; } @@ -219,6 +225,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * method after receiving an ack to a message delivering them) * */ + @Override public void tagsDelivered(PublicKey target, SessionKey key, Set sessionTags) { if (_log.shouldLog(Log.DEBUG)) { //_log.debug("Tags delivered to set " + set + " on session " + sess); @@ -241,6 +248,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * from corrupted tag sets and crashes * */ + @Override public void failTags(PublicKey target) { removeSession(target); } @@ -249,6 +257,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * Accept the given tags and associate them with the given key for decryption * */ + @Override public void tagsReceived(SessionKey key, Set sessionTags) { int overage = 0; TagSet tagSet = new TagSet(sessionTags, key, _context.clock().now()); @@ -360,6 +369,7 @@ class TransientSessionKeyManager extends SessionKeyManager { * matches * */ + @Override public SessionKey consumeTag(SessionTag tag) { if (false) aggressiveExpire(); synchronized (_inboundTagSets) { @@ -711,7 +721,8 @@ class TransientSessionKeyManager extends SessionKeyManager { } public Exception getCreatedBy() { return _createdBy; } - + + @Override public int hashCode() { long rv = 0; if (_key != null) rv = rv * 7 + _key.hashCode(); @@ -719,7 +730,8 @@ class TransientSessionKeyManager extends SessionKeyManager { // no need to hashCode the tags, key + date should be enough return (int) rv; } - + + @Override public boolean equals(Object o) { if ((o == null) || !(o instanceof TagSet)) return false; TagSet ts = (TagSet) o; diff --git a/core/java/src/net/i2p/data/Address.java b/core/java/src/net/i2p/data/Address.java index 9d0358a820..347e60e710 100644 --- a/core/java/src/net/i2p/data/Address.java +++ b/core/java/src/net/i2p/data/Address.java @@ -42,13 +42,15 @@ public class Address extends DataStructureImpl { } } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _hostname = DataHelper.readString(in); _destination = new Destination(); _destination.readBytes(in); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_hostname == null) || (_destination == null)) @@ -57,6 +59,7 @@ public class Address extends DataStructureImpl { _destination.writeBytes(out); } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof Address)) return false; Address addr = (Address) obj; @@ -64,11 +67,13 @@ public class Address extends DataStructureImpl { && DataHelper.eq(_destination, addr.getDestination()); } + @Override public int hashCode() { return DataHelper.hashCode(getHostname()) + DataHelper.hashCode(getDestination()); } + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[Address: "); diff --git a/core/java/src/net/i2p/data/ByteArray.java b/core/java/src/net/i2p/data/ByteArray.java index 90bcc43ecb..8b64547cea 100644 --- a/core/java/src/net/i2p/data/ByteArray.java +++ b/core/java/src/net/i2p/data/ByteArray.java @@ -53,7 +53,8 @@ public class ByteArray implements Serializable, Comparable { public void setValid(int valid) { _valid = valid; } public int getOffset() { return _offset; } public void setOffset(int offset) { _offset = offset; } - + + @Override public final boolean equals(Object o) { if (o == null) return false; if (o instanceof ByteArray) { @@ -73,15 +74,18 @@ public class ByteArray implements Serializable, Comparable { return (llen == rlen) && DataHelper.eq(lhs, loff, rhs, roff, llen); } + @Override public final int compareTo(Object obj) { if (obj.getClass() != getClass()) throw new ClassCastException("invalid object: " + obj); return DataHelper.compareTo(_data, ((ByteArray)obj).getData()); } - + + @Override public final int hashCode() { return DataHelper.hashCode(getData()); } - + + @Override public String toString() { return super.toString() + "/" + DataHelper.toString(getData(), 32) + "." + _valid; } diff --git a/core/java/src/net/i2p/data/Certificate.java b/core/java/src/net/i2p/data/Certificate.java index 4932139fc2..9ba259f7fb 100644 --- a/core/java/src/net/i2p/data/Certificate.java +++ b/core/java/src/net/i2p/data/Certificate.java @@ -66,7 +66,8 @@ public class Certificate extends DataStructureImpl { public void setPayload(byte[] payload) { _payload = payload; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _type = (int) DataHelper.readLong(in, 1); int length = (int) DataHelper.readLong(in, 2); @@ -78,7 +79,8 @@ public class Certificate extends DataStructureImpl { + ")"); } } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_type < 0) throw new DataFormatException("Invalid certificate type: " + _type); //if ((_type != 0) && (_payload == null)) throw new DataFormatException("Payload is required for non null type"); @@ -134,17 +136,18 @@ public class Certificate extends DataStructureImpl { public int size() { return 1 + 2 + (_payload != null ? _payload.length : 0); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof Certificate)) return false; Certificate cert = (Certificate) object; return getCertificateType() == cert.getCertificateType() && DataHelper.eq(getPayload(), cert.getPayload()); } - + @Override public int hashCode() { return getCertificateType() + DataHelper.hashCode(getPayload()); } - + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[Certificate: type: "); diff --git a/core/java/src/net/i2p/data/DataStructureImpl.java b/core/java/src/net/i2p/data/DataStructureImpl.java index fe7fe9b732..9d8f0d4dcb 100644 --- a/core/java/src/net/i2p/data/DataStructureImpl.java +++ b/core/java/src/net/i2p/data/DataStructureImpl.java @@ -24,7 +24,8 @@ import net.i2p.util.Log; */ public abstract class DataStructureImpl implements DataStructure { private final static Log _log = new Log(DataStructureImpl.class); - + + @Override public String toBase64() { byte data[] = toByteArray(); if (data == null) @@ -32,19 +33,19 @@ public abstract class DataStructureImpl implements DataStructure { return Base64.encode(data); } - + @Override public void fromBase64(String data) throws DataFormatException { if (data == null) throw new DataFormatException("Null data passed in"); byte bytes[] = Base64.decode(data); fromByteArray(bytes); } - + @Override public Hash calculateHash() { byte data[] = toByteArray(); if (data != null) return SHA256Generator.getInstance().calculateHash(data); return null; } - + @Override public byte[] toByteArray() { try { ByteArrayOutputStream baos = new ByteArrayOutputStream(512); @@ -58,7 +59,7 @@ public abstract class DataStructureImpl implements DataStructure { return null; } } - + @Override public void fromByteArray(byte data[]) throws DataFormatException { if (data == null) throw new DataFormatException("Null data passed in"); try { diff --git a/core/java/src/net/i2p/data/Destination.java b/core/java/src/net/i2p/data/Destination.java index 30589e2116..7a34428969 100644 --- a/core/java/src/net/i2p/data/Destination.java +++ b/core/java/src/net/i2p/data/Destination.java @@ -71,7 +71,8 @@ public class Destination extends DataStructureImpl { _signingKey = key; __calculatedHash = null; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _publicKey = new PublicKey(); _publicKey.readBytes(in); @@ -81,7 +82,8 @@ public class Destination extends DataStructureImpl { _certificate.readBytes(in); __calculatedHash = null; } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_certificate == null) || (_publicKey == null) || (_signingKey == null)) throw new DataFormatException("Not enough data to format the destination"); @@ -128,6 +130,7 @@ public class Destination extends DataStructureImpl { return PublicKey.KEYSIZE_BYTES + SigningPublicKey.KEYSIZE_BYTES + _certificate.size(); } + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof Destination)) return false; Destination dst = (Destination) object; @@ -135,12 +138,14 @@ public class Destination extends DataStructureImpl { && DataHelper.eq(getSigningPublicKey(), dst.getSigningPublicKey()) && DataHelper.eq(getPublicKey(), dst.getPublicKey()); } - + + @Override public int hashCode() { return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey()) + DataHelper.hashCode(getPublicKey()); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(128); buf.append("[Destination: "); @@ -151,7 +156,8 @@ public class Destination extends DataStructureImpl { buf.append("]"); return buf.toString(); } - + + @Override public Hash calculateHash() { if (__calculatedHash == null) __calculatedHash = super.calculateHash(); return __calculatedHash; diff --git a/core/java/src/net/i2p/data/Hash.java b/core/java/src/net/i2p/data/Hash.java index 2eeb9f0eb5..54c6f192a6 100644 --- a/core/java/src/net/i2p/data/Hash.java +++ b/core/java/src/net/i2p/data/Hash.java @@ -127,6 +127,7 @@ public class Hash extends DataStructureImpl { _xorCache = null; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[HASH_LENGTH]; _stringified = null; @@ -134,22 +135,26 @@ public class Hash extends DataStructureImpl { int read = read(in, _data); if (read != HASH_LENGTH) throw new DataFormatException("Not enough bytes to read the hash"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the hash to write out"); if (_data.length != HASH_LENGTH) throw new DataFormatException("Invalid size of data in the private key"); out.write(_data); } - + + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof Hash)) return false; return DataHelper.eq(_data, ((Hash) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } - + + @Override public String toString() { if (_stringified == null) { StringBuffer buf = new StringBuffer(64); @@ -165,6 +170,7 @@ public class Hash extends DataStructureImpl { return _stringified; } + @Override public String toBase64() { if (_base64ed == null) { _base64ed = super.toBase64(); diff --git a/core/java/src/net/i2p/data/Lease.java b/core/java/src/net/i2p/data/Lease.java index 7bbd3eab48..c51e121128 100644 --- a/core/java/src/net/i2p/data/Lease.java +++ b/core/java/src/net/i2p/data/Lease.java @@ -111,7 +111,8 @@ public class Lease extends DataStructureImpl { if (_end == null) return true; return _end.getTime() < Clock.getInstance().now() - fudgeFactor; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _gateway = new Hash(); _gateway.readBytes(in); @@ -119,7 +120,8 @@ public class Lease extends DataStructureImpl { _tunnelId.readBytes(in); _end = DataHelper.readDate(in); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_gateway == null) || (_tunnelId == null)) throw new DataFormatException("Not enough data to write out a Lease"); @@ -128,7 +130,8 @@ public class Lease extends DataStructureImpl { _tunnelId.writeBytes(out); DataHelper.writeDate(out, _end); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof Lease)) return false; Lease lse = (Lease) object; @@ -137,12 +140,14 @@ public class Lease extends DataStructureImpl { && DataHelper.eq(getGateway(), lse.getGateway()); } - + + @Override public int hashCode() { return DataHelper.hashCode(getEndDate()) + DataHelper.hashCode(getGateway()) + DataHelper.hashCode(getTunnelId()); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(128); buf.append("[Lease: "); diff --git a/core/java/src/net/i2p/data/LeaseSet.java b/core/java/src/net/i2p/data/LeaseSet.java index 411f5deb90..3dd9647522 100644 --- a/core/java/src/net/i2p/data/LeaseSet.java +++ b/core/java/src/net/i2p/data/LeaseSet.java @@ -252,7 +252,8 @@ public class LeaseSet extends DataStructureImpl { byte rv[] = out.toByteArray(); return rv; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _destination = new Destination(); _destination.readBytes(in); @@ -273,7 +274,8 @@ public class LeaseSet extends DataStructureImpl { _signature = new Signature(); _signature.readBytes(in); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null) || (_signature == null)) throw new DataFormatException("Not enough data to write out a LeaseSet"); @@ -299,7 +301,8 @@ public class LeaseSet extends DataStructureImpl { + 1 + _leases.size() * (Hash.HASH_LENGTH + 4 + 8); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof LeaseSet)) return false; LeaseSet ls = (LeaseSet) object; @@ -310,14 +313,16 @@ public class LeaseSet extends DataStructureImpl { && DataHelper.eq(getDestination(), ls.getDestination()); } - + + @Override public int hashCode() { return DataHelper.hashCode(getEncryptionKey()) + //(int)_version + DataHelper.hashCode(_leases) + DataHelper.hashCode(getSignature()) + DataHelper.hashCode(getSigningKey()) + DataHelper.hashCode(getDestination()); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(128); buf.append("[LeaseSet: "); diff --git a/core/java/src/net/i2p/data/Payload.java b/core/java/src/net/i2p/data/Payload.java index 2b77614d1a..5df8423831 100644 --- a/core/java/src/net/i2p/data/Payload.java +++ b/core/java/src/net/i2p/data/Payload.java @@ -66,7 +66,8 @@ public class Payload extends DataStructureImpl { else return 0; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { int size = (int) DataHelper.readLong(in, 4); if (size < 0) throw new DataFormatException("payload size out of range (" + size + ")"); @@ -76,7 +77,8 @@ public class Payload extends DataStructureImpl { if (_log.shouldLog(Log.DEBUG)) _log.debug("read payload: " + read + " bytes"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_encryptedData == null) throw new DataFormatException("Not yet encrypted. Please set the encrypted data"); DataHelper.writeLong(out, 4, _encryptedData.length); @@ -91,18 +93,21 @@ public class Payload extends DataStructureImpl { System.arraycopy(_encryptedData, 0, target, offset, _encryptedData.length); return 4 + _encryptedData.length; } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof Payload)) return false; Payload p = (Payload) object; return DataHelper.eq(getUnencryptedData(), p.getUnencryptedData()) && DataHelper.eq(getEncryptedData(), p.getEncryptedData()); } - + + @Override public int hashCode() { return DataHelper.hashCode(getUnencryptedData()); } - + + @Override public String toString() { if (true) return "[Payload]"; StringBuffer buf = new StringBuffer(128); diff --git a/core/java/src/net/i2p/data/PrivateKey.java b/core/java/src/net/i2p/data/PrivateKey.java index 23ba1d673f..ca1b95ce2a 100644 --- a/core/java/src/net/i2p/data/PrivateKey.java +++ b/core/java/src/net/i2p/data/PrivateKey.java @@ -50,29 +50,34 @@ public class PrivateKey extends DataStructureImpl { public void setData(byte[] data) { _data = data; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[KEYSIZE_BYTES]; int read = read(in, _data); if (read != KEYSIZE_BYTES) throw new DataFormatException("Not enough bytes to read the private key"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the private key to write out"); if (_data.length != KEYSIZE_BYTES) throw new DataFormatException("Invalid size of data in the private key [" + _data.length + "]"); out.write(_data); } - + + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof PrivateKey)) return false; return DataHelper.eq(_data, ((PrivateKey) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[PrivateKey: "); diff --git a/core/java/src/net/i2p/data/PublicKey.java b/core/java/src/net/i2p/data/PublicKey.java index 2f271ac5f1..f2a9a8a5c8 100644 --- a/core/java/src/net/i2p/data/PublicKey.java +++ b/core/java/src/net/i2p/data/PublicKey.java @@ -53,28 +53,33 @@ public class PublicKey extends DataStructureImpl { public void setData(byte[] data) { _data = data; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[KEYSIZE_BYTES]; int read = read(in, _data); if (read != KEYSIZE_BYTES) throw new DataFormatException("Not enough bytes to read the public key"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the public key to write out"); if (_data.length != KEYSIZE_BYTES) throw new DataFormatException("Invalid size of data in the public key"); out.write(_data); } - + + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof PublicKey)) return false; return DataHelper.eq(_data, ((PublicKey) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[PublicKey: "); diff --git a/core/java/src/net/i2p/data/RouterAddress.java b/core/java/src/net/i2p/data/RouterAddress.java index a0a69f98b1..277aa0c297 100644 --- a/core/java/src/net/i2p/data/RouterAddress.java +++ b/core/java/src/net/i2p/data/RouterAddress.java @@ -104,14 +104,16 @@ public class RouterAddress extends DataStructureImpl { public void setOptions(Properties options) { _options = options; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _cost = (int) DataHelper.readLong(in, 1); _expiration = DataHelper.readDate(in); _transportStyle = DataHelper.readString(in); _options = DataHelper.readProperties(in); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_cost < 0) || (_transportStyle == null) || (_options == null)) throw new DataFormatException("Not enough data to write a router address"); @@ -120,7 +122,8 @@ public class RouterAddress extends DataStructureImpl { DataHelper.writeString(out, _transportStyle); DataHelper.writeProperties(out, _options); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof RouterAddress)) return false; RouterAddress addr = (RouterAddress) object; @@ -128,12 +131,14 @@ public class RouterAddress extends DataStructureImpl { && DataHelper.eq(getOptions(), addr.getOptions()) && DataHelper.eq(getTransportStyle(), addr.getTransportStyle()); } - + + @Override public int hashCode() { return getCost() + DataHelper.hashCode(getTransportStyle()) + DataHelper.hashCode(getExpiration()) + DataHelper.hashCode(getOptions()); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[RouterAddress: "); diff --git a/core/java/src/net/i2p/data/RouterIdentity.java b/core/java/src/net/i2p/data/RouterIdentity.java index f0cba6c62d..a004e7f763 100644 --- a/core/java/src/net/i2p/data/RouterIdentity.java +++ b/core/java/src/net/i2p/data/RouterIdentity.java @@ -73,7 +73,8 @@ public class RouterIdentity extends DataStructureImpl { public boolean isHidden() { return (_certificate != null) && (_certificate.getCertificateType() == Certificate.CERTIFICATE_TYPE_HIDDEN); } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _publicKey = new PublicKey(); _publicKey.readBytes(in); @@ -83,7 +84,8 @@ public class RouterIdentity extends DataStructureImpl { _certificate.readBytes(in); __calculatedHash = null; } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if ((_certificate == null) || (_publicKey == null) || (_signingKey == null)) throw new DataFormatException("Not enough data to format the router identity"); @@ -91,7 +93,8 @@ public class RouterIdentity extends DataStructureImpl { _signingKey.writeBytes(out); _certificate.writeBytes(out); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof RouterIdentity)) return false; RouterIdentity ident = (RouterIdentity) object; @@ -99,12 +102,14 @@ public class RouterIdentity extends DataStructureImpl { && DataHelper.eq(getSigningPublicKey(), ident.getSigningPublicKey()) && DataHelper.eq(getPublicKey(), ident.getPublicKey()); } - + + @Override public int hashCode() { return DataHelper.hashCode(getCertificate()) + DataHelper.hashCode(getSigningPublicKey()) + DataHelper.hashCode(getPublicKey()); } - + + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[RouterIdentity: "); @@ -115,7 +120,8 @@ public class RouterIdentity extends DataStructureImpl { buf.append("]"); return buf.toString(); } - + + @Override public Hash calculateHash() { return getHash(); } diff --git a/core/java/src/net/i2p/data/RouterInfo.java b/core/java/src/net/i2p/data/RouterInfo.java index a0793c7522..028cb9aa10 100644 --- a/core/java/src/net/i2p/data/RouterInfo.java +++ b/core/java/src/net/i2p/data/RouterInfo.java @@ -486,7 +486,8 @@ public class RouterInfo extends DataStructureImpl { } } } - + + @Override public synchronized void readBytes(InputStream in) throws DataFormatException, IOException { _identity = new RouterIdentity(); _identity.readBytes(in); @@ -515,7 +516,8 @@ public class RouterInfo extends DataStructureImpl { //_log.debug("Read routerInfo: " + toString()); } - + + @Override public synchronized void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_identity == null) throw new DataFormatException("Missing identity"); if (_published < 0) throw new DataFormatException("Invalid published date: " + _published); @@ -530,7 +532,8 @@ public class RouterInfo extends DataStructureImpl { //_log.debug("Writing routerInfo [len=" + data.length + "]: " + toString()); out.write(data); } - + + @Override public boolean equals(Object object) { if ((object == null) || !(object instanceof RouterInfo)) return false; RouterInfo info = (RouterInfo) object; @@ -541,7 +544,8 @@ public class RouterInfo extends DataStructureImpl { && DataHelper.eq(_options, info.getOptions()) && DataHelper.eq(_peers, info.getPeers()); } - + + @Override public int hashCode() { if (!_hashCodeInitialized) { _hashCode = DataHelper.hashCode(_identity) + (int) getPublished(); @@ -549,7 +553,8 @@ public class RouterInfo extends DataStructureImpl { } return _hashCode; } - + + @Override public String toString() { if (_stringified != null) return _stringified; StringBuffer buf = new StringBuffer(5*1024); diff --git a/core/java/src/net/i2p/data/SessionKey.java b/core/java/src/net/i2p/data/SessionKey.java index bf68528d49..25059217af 100644 --- a/core/java/src/net/i2p/data/SessionKey.java +++ b/core/java/src/net/i2p/data/SessionKey.java @@ -57,28 +57,33 @@ public class SessionKey extends DataStructureImpl { */ public Object getPreparedKey() { return _preparedKey; } public void setPreparedKey(Object obj) { _preparedKey = obj; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[KEYSIZE_BYTES]; int read = read(in, _data); if (read != KEYSIZE_BYTES) throw new DataFormatException("Not enough bytes to read the session key"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the session key to write out"); if (_data.length != KEYSIZE_BYTES) throw new DataFormatException("Invalid size of data in the private key"); out.write(_data); } - + + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof SessionKey)) return false; return DataHelper.eq(_data, ((SessionKey) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } + @Override public String toString() { if (true) return super.toString(); StringBuffer buf = new StringBuffer(64); diff --git a/core/java/src/net/i2p/data/SessionTag.java b/core/java/src/net/i2p/data/SessionTag.java index fb0886a198..54826e7e3f 100644 --- a/core/java/src/net/i2p/data/SessionTag.java +++ b/core/java/src/net/i2p/data/SessionTag.java @@ -35,7 +35,8 @@ public class SessionTag extends ByteArray { super(); setData(val); } - + + @Override public void setData(byte val[]) throws IllegalArgumentException { if (val == null) throw new NullPointerException("SessionTags cannot be null"); diff --git a/core/java/src/net/i2p/data/Signature.java b/core/java/src/net/i2p/data/Signature.java index 39e2c4dcc5..f86f8c2260 100644 --- a/core/java/src/net/i2p/data/Signature.java +++ b/core/java/src/net/i2p/data/Signature.java @@ -43,28 +43,33 @@ public class Signature extends DataStructureImpl { public void setData(byte[] data) { _data = data; } - + + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[SIGNATURE_BYTES]; int read = read(in, _data); if (read != SIGNATURE_BYTES) throw new DataFormatException("Not enough bytes to read the signature"); } - + + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the signature to write out"); if (_data.length != SIGNATURE_BYTES) throw new DataFormatException("Invalid size of data in the private key"); out.write(_data); } - + + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof Signature)) return false; return DataHelper.eq(_data, ((Signature) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[Signature: "); diff --git a/core/java/src/net/i2p/data/SigningPrivateKey.java b/core/java/src/net/i2p/data/SigningPrivateKey.java index 2035c7b0a7..8a684fabe3 100644 --- a/core/java/src/net/i2p/data/SigningPrivateKey.java +++ b/core/java/src/net/i2p/data/SigningPrivateKey.java @@ -50,27 +50,32 @@ public class SigningPrivateKey extends DataStructureImpl { _data = data; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[KEYSIZE_BYTES]; int read = read(in, _data); if (read != KEYSIZE_BYTES) throw new DataFormatException("Not enough bytes to read the private key"); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the private key to write out"); if (_data.length != KEYSIZE_BYTES) throw new DataFormatException("Invalid size of data in the private key"); out.write(_data); } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof SigningPrivateKey)) return false; return DataHelper.eq(_data, ((SigningPrivateKey) obj)._data); } - + + @Override public int hashCode() { return DataHelper.hashCode(_data); } + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[SigningPrivateKey: "); diff --git a/core/java/src/net/i2p/data/SigningPublicKey.java b/core/java/src/net/i2p/data/SigningPublicKey.java index b938eb06ee..e4d43f7637 100644 --- a/core/java/src/net/i2p/data/SigningPublicKey.java +++ b/core/java/src/net/i2p/data/SigningPublicKey.java @@ -49,27 +49,32 @@ public class SigningPublicKey extends DataStructureImpl { _data = data; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _data = new byte[KEYSIZE_BYTES]; int read = read(in, _data); if (read != KEYSIZE_BYTES) throw new DataFormatException("Not enough bytes to read the public key"); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_data == null) throw new DataFormatException("No data in the public key to write out"); if (_data.length != KEYSIZE_BYTES) throw new DataFormatException("Invalid size of data in the public key"); out.write(_data); } + @Override public boolean equals(Object obj) { if ((obj == null) || !(obj instanceof SigningPublicKey)) return false; return DataHelper.eq(_data, ((SigningPublicKey) obj)._data); } + @Override public int hashCode() { return DataHelper.hashCode(_data); } + @Override public String toString() { StringBuffer buf = new StringBuffer(64); buf.append("[SigningPublicKey: "); diff --git a/core/java/src/net/i2p/data/TunnelId.java b/core/java/src/net/i2p/data/TunnelId.java index 8066a24103..d70369a507 100644 --- a/core/java/src/net/i2p/data/TunnelId.java +++ b/core/java/src/net/i2p/data/TunnelId.java @@ -68,10 +68,12 @@ public class TunnelId extends DataStructureImpl { public int getType() { return _type; } public void setType(int type) { _type = type; } + @Override public void readBytes(InputStream in) throws DataFormatException, IOException { _tunnelId = DataHelper.readLong(in, 4); } + @Override public void writeBytes(OutputStream out) throws DataFormatException, IOException { if (_tunnelId < 0) throw new DataFormatException("Invalid tunnel ID: " + _tunnelId); DataHelper.writeLong(out, 4, _tunnelId); @@ -82,15 +84,18 @@ public class TunnelId extends DataStructureImpl { return 4; } + @Override public boolean equals(Object obj) { if ( (obj == null) || !(obj instanceof TunnelId)) return false; return getTunnelId() == ((TunnelId)obj).getTunnelId(); } + @Override public int hashCode() { return (int)getTunnelId(); } + @Override public String toString() { return String.valueOf(getTunnelId()); } } diff --git a/core/java/src/net/i2p/data/VerifiedDestination.java b/core/java/src/net/i2p/data/VerifiedDestination.java index 4e90b8cdff..888d6a2112 100644 --- a/core/java/src/net/i2p/data/VerifiedDestination.java +++ b/core/java/src/net/i2p/data/VerifiedDestination.java @@ -153,6 +153,7 @@ public class VerifiedDestination extends Destination { return false; } + @Override public String toString() { StringBuffer buf = new StringBuffer(128); buf.append(super.toString()); -- GitLab