Rename KEY_LENGTH to CLIENT_KEY_LENGTH

Signed-off-by: Graham <gpe@openrs2.dev>
bzip2
Graham 5 years ago
parent 2fa55b3ce1
commit cf132cb2dd
  1. 2
      common/src/main/java/dev/openrs2/common/crypto/Rsa.kt
  2. 2
      common/src/main/java/dev/openrs2/common/crypto/RsaKeyProvider.kt
  3. 2
      common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt

@ -59,7 +59,7 @@ object Rsa {
* The maximum output length of RSA encryption is the key size plus one, so * 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. * 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 // 1 in 2^80
private const val CERTAINTY = 80 private const val CERTAINTY = 80

@ -10,7 +10,7 @@ class RsaKeyProvider : Provider<RSAPrivateCrtKeyParameters> {
return if (Files.exists(PRIVATE_PATH)) { return if (Files.exists(PRIVATE_PATH)) {
Rsa.readPrivateKey(PRIVATE_PATH) Rsa.readPrivateKey(PRIVATE_PATH)
} else { } else {
val (public, private) = Rsa.generateKeyPair(Rsa.KEY_LENGTH) val (public, private) = Rsa.generateKeyPair(Rsa.CLIENT_KEY_LENGTH)
Rsa.writePublicKey(PUBLIC_PATH, public) Rsa.writePublicKey(PUBLIC_PATH, public)
Rsa.writePrivateKey(PRIVATE_PATH, private) Rsa.writePrivateKey(PRIVATE_PATH, private)
private private

@ -46,7 +46,7 @@ object RsaTest {
@Test @Test
fun testGenerateKeyPair() { fun testGenerateKeyPair() {
val (public, private) = Rsa.generateKeyPair(Rsa.KEY_LENGTH) val (public, private) = Rsa.generateKeyPair(Rsa.CLIENT_KEY_LENGTH)
val expectedPlaintext = BigInteger("1337") val expectedPlaintext = BigInteger("1337")
val ciphertext = Rsa.encrypt(expectedPlaintext, public) val ciphertext = Rsa.encrypt(expectedPlaintext, public)

Loading…
Cancel
Save