forked from I2P_Developers/i2p.i2p
propagate from branch 'i2p.i2p' (head 3002b47d5d20180f84fb6a4f161823bc751989be)
to branch 'i2p.i2p.unittests' (head 97dc8de19916c3d0c7ec42790800c1e23f9ce9e8)
This commit is contained in:
@@ -24,7 +24,6 @@ public class CryptoTestSuite {
|
||||
suite.addTestSuite(AESInputStreamTest.class);
|
||||
suite.addTestSuite(CryptixAESEngineTest.class);
|
||||
suite.addTestSuite(CryptixRijndael_AlgorithmTest.class);
|
||||
suite.addTestSuite(DHSessionKeyBuilderTest.class);
|
||||
suite.addTestSuite(DSATest.class);
|
||||
suite.addTestSuite(ElGamalTest.class);
|
||||
suite.addTestSuite(HMACSHA256Test.class);
|
||||
@@ -35,4 +34,4 @@ public class CryptoTestSuite {
|
||||
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,49 +0,0 @@
|
||||
package net.i2p.crypto;
|
||||
|
||||
/*
|
||||
* 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.math.BigInteger;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.SessionKey;
|
||||
import net.i2p.util.RandomSource;
|
||||
|
||||
public class DHSessionKeyBuilderTest extends TestCase {
|
||||
public void testDHSessionKeyBuilder(){
|
||||
I2PAppContext ctx = new I2PAppContext();
|
||||
for (int i = 0; i < 5; i++) {
|
||||
DHSessionKeyBuilder builder1 = new DHSessionKeyBuilder();
|
||||
DHSessionKeyBuilder builder2 = new DHSessionKeyBuilder();
|
||||
BigInteger pub1 = builder1.getMyPublicValue();
|
||||
BigInteger pub2 = builder2.getMyPublicValue();
|
||||
try {
|
||||
builder2.setPeerPublicValue(pub1);
|
||||
builder1.setPeerPublicValue(pub2);
|
||||
} catch (DHSessionKeyBuilder.InvalidPublicParameterException ippe) {
|
||||
assertTrue(ippe.getMessage(), true);
|
||||
}
|
||||
SessionKey key1 = builder1.getSessionKey();
|
||||
SessionKey key2 = builder2.getSessionKey();
|
||||
|
||||
assertEquals(key1, key2);
|
||||
|
||||
byte iv[] = new byte[16];
|
||||
RandomSource.getInstance().nextBytes(iv);
|
||||
String origVal = "1234567890123456"; // 16 bytes max using AESEngine
|
||||
byte enc[] = new byte[16];
|
||||
byte dec[] = new byte[16];
|
||||
ctx.aes().encrypt(origVal.getBytes(), 0, enc, 0, key1, iv, 16);
|
||||
ctx.aes().decrypt(enc, 0, dec, 0, key2, iv, 16);
|
||||
String tranVal = new String(dec);
|
||||
assertEquals(origVal, tranVal);
|
||||
}
|
||||
}
|
||||
}
|
@@ -372,8 +372,10 @@ public class ElGamalTest extends TestCase{
|
||||
|
||||
public void testYKGen(){
|
||||
RandomSource.getInstance().nextBoolean();
|
||||
I2PAppContext context = new I2PAppContext();
|
||||
YKGenerator ykgen = new YKGenerator(context);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
YKGenerator.getNextYK();
|
||||
ykgen.getNextYK();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user