forked from I2P_Developers/i2p.i2p
Core: misc. minor changes
This commit is contained in:
@@ -128,10 +128,12 @@ public final class HMAC256Generator extends HMACGenerator {
|
||||
*
|
||||
*/
|
||||
/****
|
||||
private static final int LENGTH = 33;
|
||||
|
||||
public static void main(String args[]) {
|
||||
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||
byte[] rand = new byte[32];
|
||||
byte[] data = new byte[1500];
|
||||
byte[] data = new byte[LENGTH];
|
||||
Key keyObj = new SecretKeySpec(rand, "HmacSHA256");
|
||||
SessionKey key = new SessionKey(rand);
|
||||
|
||||
|
@@ -211,4 +211,25 @@ public final class SipHashInline {
|
||||
// }
|
||||
return v0 ^ v1 ^ v2 ^ v3;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test vectors from https://www.131002.net/siphash/siphash.pdf
|
||||
*/
|
||||
/****
|
||||
public static void main(String[] args) {
|
||||
long k0 = 0x0706050403020100L;
|
||||
long k1 = 0x0f0e0d0c0b0a0908L;
|
||||
byte[] data = new byte[15];
|
||||
for (int i = 0; i < data.length; i++) {
|
||||
data[i] = (byte) i;
|
||||
}
|
||||
long result = hash24(k0, k1, data);
|
||||
long expect = 0xa129ca6149be45e5L;
|
||||
if (result == expect)
|
||||
System.out.println("PASS");
|
||||
else
|
||||
System.out.println("FAIL expect " + Long.toString(expect, 16) +
|
||||
" got " + Long.toString(result, 16));
|
||||
}
|
||||
****/
|
||||
}
|
||||
|
@@ -94,7 +94,9 @@ public class DataHelper {
|
||||
"family", "family.key", "family.sig",
|
||||
// BlockfileNamingService
|
||||
"version", "created", "upgraded", "lists",
|
||||
"a", "m", "s", "v"
|
||||
"a", "m", "s", "v", "notes",
|
||||
// NTCP2 RouterAddress options
|
||||
"i"
|
||||
};
|
||||
_propertiesKeyCache = new HashMap<String, String>(keys.length);
|
||||
for (int i = 0; i < keys.length; i++) {
|
||||
@@ -670,7 +672,7 @@ public class DataHelper {
|
||||
}
|
||||
|
||||
if (rv < 0)
|
||||
throw new DataFormatException("fromLong got a negative? " + rv + " numBytes=" + numBytes);
|
||||
throw new DataFormatException("readLong got a negative? " + rv + " numBytes=" + numBytes);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
@@ -27,6 +27,7 @@ public class HexDump {
|
||||
|
||||
private static final int FORMAT_OFFSET_PADDING = 8;
|
||||
private static final int FORMAT_BYTES_PER_ROW = 16;
|
||||
private static final int OUTPUT_BYTES_PER_ROW = 79;
|
||||
private static final byte[] HEXCHARS = DataHelper.getASCII("0123456789abcdef");
|
||||
|
||||
/**
|
||||
@@ -35,14 +36,7 @@ public class HexDump {
|
||||
* @param data Data to be dumped
|
||||
*/
|
||||
public static String dump(byte[] data) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
|
||||
try {
|
||||
dump(data, 0, data.length, out);
|
||||
return out.toString("ISO-8859-1");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("no 8859?", e);
|
||||
}
|
||||
return dump(data, 0, data.length);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -53,7 +47,8 @@ public class HexDump {
|
||||
* @param len Number of bytes of <code>data</code> to be dumped
|
||||
*/
|
||||
public static String dump(byte[] data, int off, int len) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
int outlen = OUTPUT_BYTES_PER_ROW * (len + FORMAT_BYTES_PER_ROW - 1) / FORMAT_BYTES_PER_ROW;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream(outlen);
|
||||
|
||||
try {
|
||||
dump(data, off, len, out);
|
||||
|
@@ -144,6 +144,7 @@ public class I2PSSLSocketFactory {
|
||||
/**
|
||||
* We exclude everything that Java 8 disables by default, plus some others.
|
||||
* ref: http://docs.oracle.com/javase/8/docs/technotes/guides/security/SunProviders.html
|
||||
* See also: https://developer.android.com/reference/javax/net/ssl/SSLSocket.html
|
||||
* Unmodifiable.
|
||||
* Public for RouterConsoleRunner.
|
||||
* @since 0.9.16
|
||||
|
@@ -340,12 +340,12 @@ public abstract class SystemVersion {
|
||||
System.out.println("GNU : " + isGNU());
|
||||
System.out.println("Linux Svc: " + isLinuxService());
|
||||
System.out.println("Mac : " + isMac());
|
||||
System.out.println("Max mem : " + getMaxMemory());
|
||||
System.out.println("OpenJDK : " + isOpenJDK());
|
||||
System.out.println("Slow : " + isSlow());
|
||||
System.out.println("Windows : " + isWindows());
|
||||
System.out.println("Wrapper : " + hasWrapper());
|
||||
System.out.println("x86 : " + isX86());
|
||||
System.out.println("Max mem : " + getMaxMemory());
|
||||
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user