use of net.i2p.crypto.DSAEngine in project i2p.i2p by i2p.
the class DatagramTest method testBadagram.
public void testBadagram() throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
I2PClient client = I2PClientFactory.createClient();
Destination d = client.createDestination(out);
I2PSession session = client.createSession(new ByteArrayInputStream(out.toByteArray()), null);
DSAEngine dsaEng = DSAEngine.getInstance();
ByteArrayOutputStream dout = new ByteArrayOutputStream();
d.writeBytes(dout);
dsaEng.sign(Hash.FAKE_HASH.toByteArray(), session.getPrivateKey()).writeBytes(dout);
dout.write(DataHelper.getASCII("blah"));
byte[] data = dout.toByteArray();
I2PDatagramDissector dd = new I2PDatagramDissector();
dd.loadI2PDatagram(data);
boolean error = false;
try {
dd.getPayload();
} catch (I2PInvalidDatagramException i2pide) {
error = true;
}
assertTrue(error);
error = false;
try {
dd.getSender();
} catch (I2PInvalidDatagramException i2pide) {
error = true;
}
assertTrue(error);
error = false;
try {
dd.getHash();
} catch (I2PInvalidDatagramException i2pide) {
error = true;
}
assertTrue(error);
}
Aggregations