forked from I2P_Developers/i2p.i2p
Replaces instances of getBytes() in router classes
This commit is contained in:
@ -10,6 +10,7 @@ import java.util.Queue;
|
|||||||
import java.util.TimeZone;
|
import java.util.TimeZone;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.Hash;
|
import net.i2p.data.Hash;
|
||||||
import net.i2p.data.TunnelId;
|
import net.i2p.data.TunnelId;
|
||||||
import net.i2p.data.i2np.I2NPMessage;
|
import net.i2p.data.i2np.I2NPMessage;
|
||||||
@ -40,7 +41,7 @@ public class MessageHistory {
|
|||||||
//private SubmitMessageHistoryJob _submitMessageHistoryJob;
|
//private SubmitMessageHistoryJob _submitMessageHistoryJob;
|
||||||
private volatile boolean _firstPass;
|
private volatile boolean _firstPass;
|
||||||
|
|
||||||
private final static byte[] NL = System.getProperty("line.separator").getBytes();
|
private final static byte[] NL = DataHelper.getUTF8(System.getProperty("line.separator"));
|
||||||
private final static int FLUSH_SIZE = 1000; // write out at least once every 1000 entries
|
private final static int FLUSH_SIZE = 1000; // write out at least once every 1000 entries
|
||||||
|
|
||||||
/** config property determining whether we want to debug with the message history - default false */
|
/** config property determining whether we want to debug with the message history - default false */
|
||||||
@ -636,7 +637,7 @@ public class MessageHistory {
|
|||||||
fos = new SecureFileOutputStream(f, true);
|
fos = new SecureFileOutputStream(f, true);
|
||||||
String entry;
|
String entry;
|
||||||
while ((entry = _unwrittenEntries.poll()) != null) {
|
while ((entry = _unwrittenEntries.poll()) != null) {
|
||||||
fos.write(entry.getBytes());
|
fos.write(DataHelper.getUTF8(entry));
|
||||||
fos.write(NL);
|
fos.write(NL);
|
||||||
}
|
}
|
||||||
} catch (IOException ioe) {
|
} catch (IOException ioe) {
|
||||||
|
@ -46,7 +46,7 @@ public class SessionEncryptionTest extends TestCase{
|
|||||||
SessionKeyManager skm = new TransientSessionKeyManager(_context);
|
SessionKeyManager skm = new TransientSessionKeyManager(_context);
|
||||||
SessionKey curKey = skm.createSession(pubKey);
|
SessionKey curKey = skm.createSession(pubKey);
|
||||||
|
|
||||||
byte[] msg = "msg 1".getBytes();
|
byte[] msg = DataHelper.getASCII("msg 1");
|
||||||
|
|
||||||
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
|
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
|
||||||
byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
|
byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
|
||||||
@ -60,7 +60,7 @@ public class SessionEncryptionTest extends TestCase{
|
|||||||
SessionKeyManager skm = new TransientSessionKeyManager(_context);
|
SessionKeyManager skm = new TransientSessionKeyManager(_context);
|
||||||
SessionKey curKey = skm.createSession(pubKey);
|
SessionKey curKey = skm.createSession(pubKey);
|
||||||
|
|
||||||
byte[] msg = "msg 2".getBytes();
|
byte[] msg = DataHelper.getASCII("msg 2");
|
||||||
|
|
||||||
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
|
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, 64);
|
||||||
byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
|
byte dmsg[] = _context.elGamalAESEngine().decrypt(emsg, privKey, skm);
|
||||||
@ -95,11 +95,11 @@ public class SessionEncryptionTest extends TestCase{
|
|||||||
secondTags.add(tag3);
|
secondTags.add(tag3);
|
||||||
secondTags.add(tag4);
|
secondTags.add(tag4);
|
||||||
|
|
||||||
byte[] msg1 = "msg 1".getBytes();
|
byte[] msg1 = DataHelper.getASCII("msg 1");
|
||||||
byte[] msg2 = "msg 2".getBytes();
|
byte[] msg2 = DataHelper.getASCII("msg 2");
|
||||||
byte[] msg3 = "msg 3".getBytes();
|
byte[] msg3 = DataHelper.getASCII("msg 3");
|
||||||
byte[] msg4 = "msg 4".getBytes();
|
byte[] msg4 = DataHelper.getASCII("msg 4");
|
||||||
byte[] msg5 = "msg 5".getBytes();
|
byte[] msg5 = DataHelper.getASCII("msg 5");
|
||||||
|
|
||||||
byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
|
byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
|
||||||
|
|
||||||
@ -195,11 +195,11 @@ public class SessionEncryptionTest extends TestCase{
|
|||||||
secondTags.add(tag3);
|
secondTags.add(tag3);
|
||||||
secondTags.add(tag4);
|
secondTags.add(tag4);
|
||||||
|
|
||||||
byte[] msg1 = "msg 1".getBytes();
|
byte[] msg1 = DataHelper.getASCII("msg 1");
|
||||||
byte[] msg2 = "msg 2".getBytes();
|
byte[] msg2 = DataHelper.getASCII("msg 2");
|
||||||
byte[] msg3 = "msg 3".getBytes();
|
byte[] msg3 = DataHelper.getASCII("msg 3");
|
||||||
byte[] msg4 = "msg 4".getBytes();
|
byte[] msg4 = DataHelper.getASCII("msg 4");
|
||||||
byte[] msg5 = "msg 5".getBytes();
|
byte[] msg5 = DataHelper.getASCII("msg 5");
|
||||||
|
|
||||||
byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
|
byte emsg1[] = _context.elGamalAESEngine().encrypt(msg1, pubKey, curKey, firstTags, 64);
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ public class SessionEncryptionTest extends TestCase{
|
|||||||
if (i % 50 == 0)
|
if (i % 50 == 0)
|
||||||
nextKey = KeyGenerator.getInstance().generateSessionKey();
|
nextKey = KeyGenerator.getInstance().generateSessionKey();
|
||||||
|
|
||||||
byte[] msg = ("msg " + i).getBytes();
|
byte[] msg = DataHelper.getASCII("msg " + i);
|
||||||
|
|
||||||
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, tags, curTag, nextKey, 64);
|
byte emsg[] = _context.elGamalAESEngine().encrypt(msg, pubKey, curKey, tags, curTag, nextKey, 64);
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import java.math.BigInteger;
|
|||||||
|
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
import net.i2p.I2PAppContext;
|
import net.i2p.I2PAppContext;
|
||||||
|
import net.i2p.data.DataHelper;
|
||||||
import net.i2p.data.SessionKey;
|
import net.i2p.data.SessionKey;
|
||||||
import net.i2p.util.RandomSource;
|
import net.i2p.util.RandomSource;
|
||||||
|
|
||||||
@ -40,7 +41,7 @@ public class DHSessionKeyBuilderTest extends TestCase {
|
|||||||
String origVal = "1234567890123456"; // 16 bytes max using AESEngine
|
String origVal = "1234567890123456"; // 16 bytes max using AESEngine
|
||||||
byte enc[] = new byte[16];
|
byte enc[] = new byte[16];
|
||||||
byte dec[] = new byte[16];
|
byte dec[] = new byte[16];
|
||||||
ctx.aes().encrypt(origVal.getBytes(), 0, enc, 0, key1, iv, 16);
|
ctx.aes().encrypt(DataHelper.getASCII(origVal), 0, enc, 0, key1, iv, 16);
|
||||||
ctx.aes().decrypt(enc, 0, dec, 0, key2, iv, 16);
|
ctx.aes().decrypt(enc, 0, dec, 0, key2, iv, 16);
|
||||||
String tranVal = new String(dec);
|
String tranVal = new String(dec);
|
||||||
assertEquals(origVal, tranVal);
|
assertEquals(origVal, tranVal);
|
||||||
|
Reference in New Issue
Block a user