Add generateKeyPair() test

bzip2
Graham 5 years ago
parent 0f767c86eb
commit e64dbe1a0e
  1. 11
      common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt

@ -10,6 +10,17 @@ import kotlin.test.assertEquals
object RsaTest { object RsaTest {
private const val ALLOW_UNSAFE_MOD = "org.bouncycastle.rsa.allow_unsafe_mod" 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 @Test
fun testEncrypt() { fun testEncrypt() {
// from https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Example // from https://en.wikipedia.org/wiki/RSA_(cryptosystem)#Example

Loading…
Cancel
Save