Return RSAPrivateCrtKeyParameters from readPrivateKey

bzip2
Graham 5 years ago
parent c8af2288c6
commit 0bb0d1a5b6
  1. 2
      common/src/main/java/dev/openrs2/common/crypto/Rsa.kt
  2. 2
      common/src/test/java/dev/openrs2/common/crypto/RsaTest.kt

@ -145,7 +145,7 @@ object Rsa {
return writeSinglePemObject(path, PUBLIC_KEY, spki.encoded)
}
fun readPrivateKey(path: Path): RSAKeyParameters {
fun readPrivateKey(path: Path): RSAPrivateCrtKeyParameters {
val der = readSinglePemObject(path, PRIVATE_KEY)
val pki = PrivateKeyInfo.getInstance(der)

@ -150,7 +150,7 @@ object RsaTest {
try {
Files.write(file, PRIVATE_KEY_PEM)
val key = allowUnsafeMod { Rsa.readPrivateKey(file) } as RSAPrivateCrtKeyParameters
val key = allowUnsafeMod { Rsa.readPrivateKey(file) }
assertTrue(key.isPrivate)
assertEquals(PRIVATE_KEY_CRT.modulus, key.modulus)
assertEquals(PRIVATE_KEY_CRT.exponent, key.exponent)

Loading…
Cancel
Save