Big findbugs cleanup
This commit is contained in:
@ -164,7 +164,7 @@ public class CPUID {
|
||||
public boolean IsC3Compatible() { return false; }
|
||||
}
|
||||
protected static class VIAC3Impl extends CPUIDCPUInfo implements CPUInfo {
|
||||
public boolean isC3Compatible() { return true; }
|
||||
public boolean IsC3Compatible() { return true; }
|
||||
public String getCPUModelString() { return "VIA C3"; }
|
||||
}
|
||||
protected static class AMDInfoImpl extends CPUIDCPUInfo implements AMDCPUInfo
|
||||
|
@ -150,10 +150,10 @@ public class AsyncFortunaStandalone extends FortunaStandalone implements Runnabl
|
||||
lastReseed = System.currentTimeMillis();
|
||||
}
|
||||
generator.nextBytes(buf);
|
||||
long now = System.currentTimeMillis();
|
||||
long diff = now-lastRefill;
|
||||
lastRefill = now;
|
||||
long refillTime = now-start;
|
||||
//long now = System.currentTimeMillis();
|
||||
//long diff = now-lastRefill;
|
||||
//lastRefill = now;
|
||||
//long refillTime = now-start;
|
||||
//System.out.println("Refilling " + (++refillCount) + " after " + diff + " for the PRNG took " + refillTime);
|
||||
}
|
||||
|
||||
|
@ -48,9 +48,8 @@ class I2PClientImpl implements I2PClient {
|
||||
public Destination createDestination(OutputStream destKeyStream, Certificate cert) throws I2PException, IOException {
|
||||
Destination d = new Destination();
|
||||
d.setCertificate(cert);
|
||||
PublicKey publicKey = new PublicKey();
|
||||
Object keypair[] = KeyGenerator.getInstance().generatePKIKeypair();
|
||||
publicKey = (PublicKey) keypair[0];
|
||||
PublicKey publicKey = (PublicKey) keypair[0];
|
||||
PrivateKey privateKey = (PrivateKey) keypair[1];
|
||||
Object signingKeys[] = KeyGenerator.getInstance().generateSigningKeypair();
|
||||
SigningPublicKey signingPubKey = (SigningPublicKey) signingKeys[0];
|
||||
@ -80,4 +79,4 @@ class I2PClientImpl implements I2PClient {
|
||||
public I2PSession createSession(I2PAppContext context, InputStream destKeyStream, Properties options) throws I2PSessionException {
|
||||
return new I2PSessionImpl2(context, destKeyStream, options); // thread safe
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +408,7 @@ abstract class I2PSessionImpl implements I2PSession, I2CPMessageReader.I2CPMessa
|
||||
public void available(long msgId, int size) {
|
||||
synchronized (AvailabilityNotifier.this) {
|
||||
_pendingIds.add(new Long(msgId));
|
||||
_pendingSizes.add(new Integer(size));
|
||||
_pendingSizes.add(Integer.valueOf(size));
|
||||
AvailabilityNotifier.this.notifyAll();
|
||||
}
|
||||
}
|
||||
|
@ -220,10 +220,10 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
if (actuallyWait)
|
||||
state.waitFor(MessageStatusMessage.STATUS_SEND_ACCEPTED,
|
||||
_context.clock().now() + getTimeout());
|
||||
long afterWaitFor = _context.clock().now();
|
||||
long inRemovingSync = 0;
|
||||
//long afterWaitFor = _context.clock().now();
|
||||
//long inRemovingSync = 0;
|
||||
synchronized (_sendingStates) {
|
||||
inRemovingSync = _context.clock().now();
|
||||
//inRemovingSync = _context.clock().now();
|
||||
_sendingStates.remove(state);
|
||||
}
|
||||
long afterRemovingSync = _context.clock().now();
|
||||
@ -352,4 +352,4 @@ class I2PSessionImpl2 extends I2PSessionImpl {
|
||||
_sendingStates.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ class MessagePayloadMessageHandler extends HandlerImpl {
|
||||
try {
|
||||
MessagePayloadMessage msg = (MessagePayloadMessage) message;
|
||||
long id = msg.getMessageId();
|
||||
Payload payload = decryptPayload(msg, session);
|
||||
decryptPayload(msg, session);
|
||||
session.addNewMessage(msg);
|
||||
|
||||
ReceiveMessageEndMessage m = new ReceiveMessageEndMessage();
|
||||
@ -68,4 +68,4 @@ class MessagePayloadMessageHandler extends HandlerImpl {
|
||||
payload.setUnencryptedData(data);
|
||||
return payload;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class MessageState {
|
||||
|
||||
public void receive(int status) {
|
||||
synchronized (_receivedStatus) {
|
||||
_receivedStatus.add(new Integer(status));
|
||||
_receivedStatus.add(Integer.valueOf(status));
|
||||
_receivedStatus.notifyAll();
|
||||
}
|
||||
}
|
||||
@ -275,4 +275,4 @@ class MessageState {
|
||||
_receivedStatus.notifyAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ public class ElGamalAESEngine {
|
||||
System.arraycopy(elgEncr, 0, rv, 0, elgEncr.length);
|
||||
System.arraycopy(aesEncr, 0, rv, elgEncr.length, aesEncr.length);
|
||||
//_log.debug("Return length: " + rv.length);
|
||||
long finish = _context.clock().now();
|
||||
//long finish = _context.clock().now();
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("after the elgEngine.encrypt took a total of " + (finish - after) + "ms");
|
||||
return rv;
|
||||
|
@ -102,25 +102,25 @@ public class ElGamalEngine {
|
||||
System.arraycopy(hash.getData(), 0, d2, 1, Hash.HASH_LENGTH);
|
||||
System.arraycopy(data, 0, d2, 1+Hash.HASH_LENGTH, data.length);
|
||||
|
||||
long t0 = _context.clock().now();
|
||||
//long t0 = _context.clock().now();
|
||||
BigInteger m = new NativeBigInteger(1, d2);
|
||||
long t1 = _context.clock().now();
|
||||
//long t1 = _context.clock().now();
|
||||
if (m.compareTo(CryptoConstants.elgp) >= 0)
|
||||
throw new IllegalArgumentException("ARGH. Data cannot be larger than the ElGamal prime. FIXME");
|
||||
long t2 = _context.clock().now();
|
||||
//long t2 = _context.clock().now();
|
||||
BigInteger aalpha = new NativeBigInteger(1, publicKey.getData());
|
||||
long t3 = _context.clock().now();
|
||||
//long t3 = _context.clock().now();
|
||||
BigInteger yk[] = getNextYK();
|
||||
BigInteger k = yk[1];
|
||||
BigInteger y = yk[0];
|
||||
|
||||
long t7 = _context.clock().now();
|
||||
//long t7 = _context.clock().now();
|
||||
BigInteger d = aalpha.modPow(k, CryptoConstants.elgp);
|
||||
long t8 = _context.clock().now();
|
||||
//long t8 = _context.clock().now();
|
||||
d = d.multiply(m);
|
||||
long t9 = _context.clock().now();
|
||||
//long t9 = _context.clock().now();
|
||||
d = d.mod(CryptoConstants.elgp);
|
||||
long t10 = _context.clock().now();
|
||||
//long t10 = _context.clock().now();
|
||||
|
||||
byte[] ybytes = y.toByteArray();
|
||||
byte[] dbytes = d.toByteArray();
|
||||
@ -273,4 +273,4 @@ public class ElGamalEngine {
|
||||
+ " average decryption time: " + (dTime / numRuns) + " average key generation time: "
|
||||
+ (gTime / numRuns));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,13 +47,13 @@ public class Base64 {
|
||||
return (source != null ? encode(source.getBytes()) : "");
|
||||
}
|
||||
public static String encode(byte[] source) {
|
||||
return (source != null ? encode(source, 0, (source != null ? source.length : 0)) : "");
|
||||
return (source != null ? encode(source, 0, source.length) : "");
|
||||
}
|
||||
public static String encode(byte[] source, int off, int len) {
|
||||
return (source != null ? encode(source, off, len, false) : "");
|
||||
}
|
||||
public static String encode(byte[] source, boolean useStandardAlphabet) {
|
||||
return (source != null ? encode(source, 0, (source != null ? source.length : 0), useStandardAlphabet) : "");
|
||||
return (source != null ? encode(source, 0, source.length, useStandardAlphabet) : "");
|
||||
}
|
||||
public static String encode(byte[] source, int off, int len, boolean useStandardAlphabet) {
|
||||
return (source != null ? safeEncode(source, off, len, useStandardAlphabet) : "");
|
||||
@ -241,9 +241,11 @@ public class Base64 {
|
||||
* @return four byte array in Base64 notation.
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static byte[] encode3to4(byte[] threeBytes) {
|
||||
return encode3to4(threeBytes, 3);
|
||||
} // end encodeToBytes
|
||||
******/
|
||||
|
||||
/**
|
||||
* Encodes up to the first three bytes of array <var>threeBytes</var>
|
||||
@ -379,9 +381,11 @@ public class Base64 {
|
||||
* @param source The data to convert
|
||||
* @since 1.4
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeBytes(byte[] source) {
|
||||
return encodeBytes(source, false); // don't add newlines
|
||||
} // end encodeBytes
|
||||
******/
|
||||
|
||||
/**
|
||||
* Same as encodeBytes, except uses a filesystem / URL friendly set of characters,
|
||||
@ -435,9 +439,11 @@ public class Base64 {
|
||||
* @param len Length of data to convert
|
||||
* @since 1.4
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeBytes(byte[] source, int off, int len) {
|
||||
return encodeBytes(source, off, len, true);
|
||||
} // end encodeBytes
|
||||
******/
|
||||
|
||||
private static String encodeBytes(byte[] source, int off, int len, boolean breakLines) {
|
||||
StringBuffer buf = new StringBuffer( (len*4)/3 );
|
||||
@ -455,7 +461,7 @@ public class Base64 {
|
||||
* @since 1.4
|
||||
*/
|
||||
private static void encodeBytes(byte[] source, int off, int len, boolean breakLines, StringBuffer out, byte alpha[]) {
|
||||
int len43 = len * 4 / 3;
|
||||
//int len43 = len * 4 / 3;
|
||||
//byte[] outBuff = new byte[(len43) // Main 4:3
|
||||
// + ((len % 3) > 0 ? 4 : 0) // Account for padding
|
||||
// + (breakLines ? (len43 / MAX_LINE_LENGTH) : 0)]; // New lines
|
||||
@ -494,9 +500,11 @@ public class Base64 {
|
||||
* @return the encoded string
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static String encodeString(String s) {
|
||||
return encodeString(s, true);
|
||||
} // end encodeString
|
||||
******/
|
||||
|
||||
/**
|
||||
* Encodes a string in Base64 notation with line breaks
|
||||
@ -525,6 +533,7 @@ public class Base64 {
|
||||
* @return array with decoded values
|
||||
* @since 1.3
|
||||
*/
|
||||
/***** unused
|
||||
private static byte[] decode4to3(byte[] fourBytes) {
|
||||
byte[] outBuff1 = new byte[3];
|
||||
int count = decode4to3(fourBytes, 0, outBuff1, 0);
|
||||
@ -535,6 +544,7 @@ public class Base64 {
|
||||
|
||||
return outBuff2;
|
||||
}
|
||||
******/
|
||||
|
||||
/**
|
||||
* Decodes four bytes from array <var>source</var>
|
||||
|
@ -671,8 +671,6 @@ public class DataHelper {
|
||||
|
||||
public final static byte[] xor(byte lhs[], byte rhs[]) {
|
||||
if ((lhs == null) || (rhs == null) || (lhs.length != rhs.length)) return null;
|
||||
byte rv[] = new byte[lhs.length];
|
||||
|
||||
byte diff[] = new byte[lhs.length];
|
||||
xor(lhs, 0, rhs, 0, diff, 0, lhs.length);
|
||||
return diff;
|
||||
@ -821,9 +819,8 @@ public class DataHelper {
|
||||
DataStructure struct = (DataStructure) iter.next();
|
||||
tm.put(struct.calculateHash().toString(), struct);
|
||||
}
|
||||
for (Iterator iter = tm.keySet().iterator(); iter.hasNext();) {
|
||||
Object k = iter.next();
|
||||
rv.add(tm.get(k));
|
||||
for (Iterator iter = tm.values().iterator(); iter.hasNext();) {
|
||||
rv.add(iter.next());
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
@ -224,6 +224,8 @@ public class LeaseSet extends DataStructureImpl {
|
||||
}
|
||||
|
||||
private byte[] getBytes() {
|
||||
if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null))
|
||||
return null;
|
||||
int len = PublicKey.KEYSIZE_BYTES // dest
|
||||
+ SigningPublicKey.KEYSIZE_BYTES // dest
|
||||
+ 4 // cert
|
||||
@ -233,9 +235,6 @@ public class LeaseSet extends DataStructureImpl {
|
||||
+ _leases.size() * 44; // leases
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(len);
|
||||
try {
|
||||
if ((_destination == null) || (_encryptionKey == null) || (_signingKey == null) || (_leases == null))
|
||||
return null;
|
||||
|
||||
_destination.writeBytes(out);
|
||||
_encryptionKey.writeBytes(out);
|
||||
_signingKey.writeBytes(out);
|
||||
|
@ -76,7 +76,7 @@ public class Frequency {
|
||||
long duration = now() - _start;
|
||||
if ((duration <= 0) || (_count <= 0)) return 0;
|
||||
|
||||
return duration / _count;
|
||||
return duration / (double) _count;
|
||||
}
|
||||
}
|
||||
|
||||
@ -167,4 +167,4 @@ public class Frequency {
|
||||
private final static long now() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -113,8 +113,8 @@ public class NtpClient {
|
||||
// Process response
|
||||
NtpMessage msg = new NtpMessage(packet.getData());
|
||||
|
||||
double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
|
||||
(msg.receiveTimestamp-msg.transmitTimestamp);
|
||||
//double roundTripDelay = (destinationTimestamp-msg.originateTimestamp) -
|
||||
// (msg.receiveTimestamp-msg.transmitTimestamp);
|
||||
double localClockOffset = ((msg.receiveTimestamp - msg.originateTimestamp) +
|
||||
(msg.transmitTimestamp - destinationTimestamp)) / 2;
|
||||
socket.close();
|
||||
|
@ -24,7 +24,7 @@ public final class ByteCache {
|
||||
* @param size how large should the objects cached be?
|
||||
*/
|
||||
public static ByteCache getInstance(int cacheSize, int size) {
|
||||
Integer sz = new Integer(size);
|
||||
Integer sz = Integer.valueOf(size);
|
||||
ByteCache cache = null;
|
||||
synchronized (_caches) {
|
||||
if (!_caches.containsKey(sz))
|
||||
|
@ -508,8 +508,6 @@ public class EepGet {
|
||||
_actualURL = "http://" + url.getHost() + ":" + url.getPort() + "/" + _redirectLocation;
|
||||
if ( (_actualURL.indexOf('?') < 0) && (query.length() > 0) )
|
||||
_actualURL = _actualURL + "?" + query;
|
||||
else
|
||||
_actualURL = _actualURL;
|
||||
}
|
||||
} catch (MalformedURLException mue) {
|
||||
throw new IOException("Redirected from an invalid URL");
|
||||
@ -772,7 +770,7 @@ public class EepGet {
|
||||
_log.warn("ERR: status "+ line);
|
||||
return -1;
|
||||
}
|
||||
String protocol = tok.nextToken(); // ignored
|
||||
tok.nextToken(); // ignored (protocol)
|
||||
if (!tok.hasMoreTokens()) {
|
||||
if (_log.shouldLog(Log.WARN))
|
||||
_log.warn("ERR: status "+ line);
|
||||
@ -874,7 +872,7 @@ public class EepGet {
|
||||
|
||||
timeout.setSocket(_proxy);
|
||||
|
||||
_proxyOut.write(DataHelper.getUTF8(req.toString()));
|
||||
_proxyOut.write(DataHelper.getUTF8(req));
|
||||
_proxyOut.flush();
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
|
@ -162,7 +162,7 @@ public class EepPost {
|
||||
}
|
||||
|
||||
private void sendFile(OutputStream out, String separator, String field, File file) throws IOException {
|
||||
long len = file.length();
|
||||
//long len = file.length();
|
||||
out.write(("--" + separator + CRLF).getBytes());
|
||||
out.write(("Content-Disposition: form-data; name=\"" + field + "\"; filename=\"" + file.getName() + "\"" + CRLF).getBytes());
|
||||
//out.write(("Content-length: " + len + "\n").getBytes());
|
||||
|
Reference in New Issue
Block a user