forked from I2P_Developers/i2p.i2p
merge of '9a6aaa59a51ac9c26f4a1a1a1db90feb17819a22'
and 'b5f4c5514ac1fbd9f7b61180c7874ddcac422c11'
This commit is contained in:
@@ -22,7 +22,7 @@ public class AES256Test extends TestCase{
|
|||||||
private byte[] iv;
|
private byte[] iv;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
_context = new I2PAppContext();
|
_context = I2PAppContext.getGlobalContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiple(){
|
public void testMultiple(){
|
||||||
@@ -73,4 +73,4 @@ public class AES256Test extends TestCase{
|
|||||||
ctx.aes().decrypt(se, 0, sd, 0, key, iv, se.length);
|
ctx.aes().decrypt(se, 0, sd, 0, key, iv, se.length);
|
||||||
assertTrue(DataHelper.eq(sd, sbuf));
|
assertTrue(DataHelper.eq(sd, sbuf));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,11 +20,11 @@ public class DSATest extends TestCase{
|
|||||||
private I2PAppContext _context;
|
private I2PAppContext _context;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
_context = new I2PAppContext();
|
_context = I2PAppContext.getGlobalContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiple(){
|
public void testMultiple(){
|
||||||
for(int i = 0; i < 100; i++){
|
for(int i = 0; i < 25; i++){
|
||||||
byte[] message = new byte[256];
|
byte[] message = new byte[256];
|
||||||
_context.random().nextBytes(message);
|
_context.random().nextBytes(message);
|
||||||
|
|
||||||
@@ -41,4 +41,4 @@ public class DSATest extends TestCase{
|
|||||||
assertTrue(DSAEngine.getInstance().verifySignature(s, new ByteArrayInputStream(message), pubkey));
|
assertTrue(DSAEngine.getInstance().verifySignature(s, new ByteArrayInputStream(message), pubkey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -125,7 +125,7 @@ public class ElGamalTest extends TestCase{
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
_context = new I2PAppContext();
|
_context = I2PAppContext.getGlobalContext();
|
||||||
Object o = YKGenerator.class;
|
Object o = YKGenerator.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -331,7 +331,7 @@ public class ElGamalTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testElGamalAESEngine() throws Exception{
|
public void testElGamalAESEngine() throws Exception{
|
||||||
I2PAppContext ctx = new I2PAppContext();
|
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||||
ElGamalAESEngine e = new ElGamalAESEngine(ctx);
|
ElGamalAESEngine e = new ElGamalAESEngine(ctx);
|
||||||
Object kp[] = ctx.keyGenerator().generatePKIKeypair();
|
Object kp[] = ctx.keyGenerator().generatePKIKeypair();
|
||||||
PublicKey pubKey = (PublicKey)kp[0];
|
PublicKey pubKey = (PublicKey)kp[0];
|
||||||
@@ -352,9 +352,9 @@ public class ElGamalTest extends TestCase{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testElGamalEngine(){
|
public void testElGamalEngine(){
|
||||||
int numRuns = 100;
|
int numRuns = 10;
|
||||||
RandomSource.getInstance().nextBoolean();
|
RandomSource.getInstance().nextBoolean();
|
||||||
I2PAppContext context = new I2PAppContext();
|
I2PAppContext context = I2PAppContext.getGlobalContext();
|
||||||
|
|
||||||
for (int i = 0; i < numRuns; i++) {
|
for (int i = 0; i < numRuns; i++) {
|
||||||
Object pair[] = KeyGenerator.getInstance().generatePKIKeypair();
|
Object pair[] = KeyGenerator.getInstance().generatePKIKeypair();
|
||||||
@@ -372,7 +372,7 @@ public class ElGamalTest extends TestCase{
|
|||||||
|
|
||||||
public void testYKGen(){
|
public void testYKGen(){
|
||||||
RandomSource.getInstance().nextBoolean();
|
RandomSource.getInstance().nextBoolean();
|
||||||
I2PAppContext context = new I2PAppContext();
|
I2PAppContext context = I2PAppContext.getGlobalContext();
|
||||||
YKGenerator ykgen = new YKGenerator(context);
|
YKGenerator ykgen = new YKGenerator(context);
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < 5; i++) {
|
||||||
ykgen.getNextYK();
|
ykgen.getNextYK();
|
||||||
|
@@ -16,12 +16,12 @@ public class HMACSHA256Test extends TestCase{
|
|||||||
private I2PAppContext _context;
|
private I2PAppContext _context;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
_context = new I2PAppContext();
|
_context = I2PAppContext.getGlobalContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiple(){
|
public void testMultiple(){
|
||||||
int size = 1;
|
int size = 1;
|
||||||
for(int i = 0; i < 24; i++){
|
for(int i = 0; i < 16; i++){
|
||||||
SessionKey key = _context.keyGenerator().generateSessionKey();
|
SessionKey key = _context.keyGenerator().generateSessionKey();
|
||||||
|
|
||||||
byte[] message = new byte[size];
|
byte[] message = new byte[size];
|
||||||
@@ -31,4 +31,4 @@ public class HMACSHA256Test extends TestCase{
|
|||||||
_context.hmac().calculate(key, message);
|
_context.hmac().calculate(key, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ public class KeyGeneratorTest extends TestCase{
|
|||||||
byte src[] = new byte[200];
|
byte src[] = new byte[200];
|
||||||
RandomSource.getInstance().nextBytes(src);
|
RandomSource.getInstance().nextBytes(src);
|
||||||
|
|
||||||
I2PAppContext ctx = new I2PAppContext();
|
I2PAppContext ctx = I2PAppContext.getGlobalContext();
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Object keys[] = KeyGenerator.getInstance().generatePKIKeypair();
|
Object keys[] = KeyGenerator.getInstance().generatePKIKeypair();
|
||||||
byte ctext[] = ctx.elGamalEngine().encrypt(src, (PublicKey) keys[0]);
|
byte ctext[] = ctx.elGamalEngine().encrypt(src, (PublicKey) keys[0]);
|
||||||
@@ -46,4 +46,4 @@ public class KeyGeneratorTest extends TestCase{
|
|||||||
KeyGenerator.getInstance().generateSessionKey();
|
KeyGenerator.getInstance().generateSessionKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -70,8 +70,8 @@ public class SHA1HashTest extends TestCase{
|
|||||||
"cb0082c8 f197d260 991ba6a4 60e76e20 2bad27b3");
|
"cb0082c8 f197d260 991ba6a4 60e76e20 2bad27b3");
|
||||||
|
|
||||||
{
|
{
|
||||||
final int RETRIES = 10;
|
final int RETRIES = 4;
|
||||||
final int ITERATIONS = 2000;
|
final int ITERATIONS = 200;
|
||||||
final int BLOCKSIZE = 65536;
|
final int BLOCKSIZE = 65536;
|
||||||
byte[] input = new byte[BLOCKSIZE];
|
byte[] input = new byte[BLOCKSIZE];
|
||||||
for (int i = BLOCKSIZE; --i >= 0; )
|
for (int i = BLOCKSIZE; --i >= 0; )
|
||||||
|
@@ -19,12 +19,12 @@ public class SHA256Test extends TestCase{
|
|||||||
private I2PAppContext _context;
|
private I2PAppContext _context;
|
||||||
|
|
||||||
protected void setUp() {
|
protected void setUp() {
|
||||||
_context = new I2PAppContext();
|
_context = I2PAppContext.getGlobalContext();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testMultiple(){
|
public void testMultiple(){
|
||||||
int size = 1;
|
int size = 1;
|
||||||
for(int i = 0; i < 24; i++){
|
for(int i = 0; i < 16; i++){
|
||||||
byte[] message = new byte[size];
|
byte[] message = new byte[size];
|
||||||
size*=2;
|
size*=2;
|
||||||
_context.random().nextBytes(message);
|
_context.random().nextBytes(message);
|
||||||
|
@@ -25,7 +25,7 @@ import net.i2p.data.SessionTag;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SessionEncryptionTest extends TestCase{
|
public class SessionEncryptionTest extends TestCase{
|
||||||
private static I2PAppContext _context = new I2PAppContext();
|
private static I2PAppContext _context = I2PAppContext.getGlobalContext();
|
||||||
|
|
||||||
protected void setUp(){
|
protected void setUp(){
|
||||||
_context = new I2PAppContext();
|
_context = new I2PAppContext();
|
||||||
|
@@ -1,58 +0,0 @@
|
|||||||
package net.i2p.data.i2np;
|
|
||||||
/*
|
|
||||||
* free (adj.): unencumbered; not under the control of others
|
|
||||||
* Written by jrandom in 2003 and released into the public domain
|
|
||||||
* with no warranty of any kind, either expressed or implied.
|
|
||||||
* It probably won't make your computer catch on fire, or eat
|
|
||||||
* your children, but it might. Use at your own risk.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
|
|
||||||
import junit.framework.TestCase;
|
|
||||||
import net.i2p.data.DataFormatException;
|
|
||||||
import net.i2p.router.RouterContext;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Test harness for loading / storing I2NP DatabaseStore message objects
|
|
||||||
*
|
|
||||||
* @author jrandom
|
|
||||||
*/
|
|
||||||
public class I2NPMessageReaderTest extends TestCase implements I2NPMessageReader.I2NPMessageEventListener{
|
|
||||||
|
|
||||||
public void setUp(){}
|
|
||||||
|
|
||||||
public void testI2NPMessageReader() throws IOException, DataFormatException{
|
|
||||||
InputStream data = getData();
|
|
||||||
test(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
private InputStream getData() throws IOException, DataFormatException{
|
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
|
||||||
DatabaseStoreMessage msg = (DatabaseStoreMessage)new DatabaseStoreMessageTest().createDataStructure();
|
|
||||||
msg.writeBytes(baos);
|
|
||||||
msg.writeBytes(baos);
|
|
||||||
msg.writeBytes(baos);
|
|
||||||
msg.writeBytes(baos);
|
|
||||||
return new ByteArrayInputStream(baos.toByteArray());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void test(InputStream in) {
|
|
||||||
I2NPMessageReader reader = new I2NPMessageReader(new RouterContext(null), in, this);
|
|
||||||
reader.startReading();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void disconnected(I2NPMessageReader reader) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void messageReceived(I2NPMessageReader reader, I2NPMessage message, long msToRead, int size) {
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readError(I2NPMessageReader reader, Exception error) {
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Reference in New Issue
Block a user