DH UnitTest

This commit is contained in:
Marcin Kostrzewski 2020-11-16 12:22:08 +01:00
parent 4def149519
commit f2cea164ae

View File

@ -0,0 +1,23 @@
package Main;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class DHExchangeTest {
@Test
void KeyMatchAfterExchangeTest(){
DHExchange alice = new DHExchange(2048, true);
DHExchange bob = new DHExchange(2048, false);
alice.createKeyPar();
try {
bob.createKeyParFromPublicKey(alice.getThisPublicKeyEncoded());
} catch (Exception e) {
e.printStackTrace();
}
alice.onRecievePubKey(bob.getThisPublicKeyEncoded());
assertEquals(bob.getSecretKey(), alice.getSecretKey());
}
}