Signed-off-by: Graham <gpe@openrs2.dev>
@ -59,7 +59,7 @@ object Rsa {
* The maximum output length of RSA encryption is the key size plus one, so
* the maximum key size supported by the client is 126 bytes - or 1008 bits.
*/
const val KEY_LENGTH = 1008
const val CLIENT_KEY_LENGTH = 1008
// 1 in 2^80
private const val CERTAINTY = 80
@ -10,7 +10,7 @@ class RsaKeyProvider : Provider<RSAPrivateCrtKeyParameters> {
return if (Files.exists(PRIVATE_PATH)) {
Rsa.readPrivateKey(PRIVATE_PATH)
} else {
val (public, private) = Rsa.generateKeyPair(Rsa.KEY_LENGTH)
val (public, private) = Rsa.generateKeyPair(Rsa.CLIENT_KEY_LENGTH)
Rsa.writePublicKey(PUBLIC_PATH, public)
Rsa.writePrivateKey(PRIVATE_PATH, private)
private
@ -46,7 +46,7 @@ object RsaTest {
@Test
fun testGenerateKeyPair() {
val expectedPlaintext = BigInteger("1337")
val ciphertext = Rsa.encrypt(expectedPlaintext, public)