diff --git a/common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt b/common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt index 9f2e7232..24093549 100644 --- a/common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt +++ b/common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt @@ -10,6 +10,17 @@ import kotlin.test.assertEquals object RsaTest { private const val ALLOW_UNSAFE_MOD = "org.bouncycastle.rsa.allow_unsafe_mod" + @Test + fun testGenerateKeyPair() { + val (public, private) = Rsa.generateKeyPair() + + val expectedPlaintext = BigInteger("1337") + val ciphertext = Rsa.encrypt(expectedPlaintext, public) + val actualPlaintext = Rsa.decrypt(ciphertext, private) + + assertEquals(expectedPlaintext, actualPlaintext) + } + @Test fun testEncrypt() { // from https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Example