|
|
@ -24,6 +24,9 @@ import java.math.BigInteger |
|
|
|
import java.nio.file.Files |
|
|
|
import java.nio.file.Files |
|
|
|
import java.nio.file.Path |
|
|
|
import java.nio.file.Path |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val RSAPrivateCrtKeyParameters.publicKey |
|
|
|
|
|
|
|
get() = RSAKeyParameters(false, modulus, publicExponent) |
|
|
|
|
|
|
|
|
|
|
|
private fun ByteBuf.toBigInteger(): BigInteger { |
|
|
|
private fun ByteBuf.toBigInteger(): BigInteger { |
|
|
|
val bytes: ByteArray |
|
|
|
val bytes: ByteArray |
|
|
|
if (hasArray() && arrayOffset() == 0 && readerIndex() == 0 && readableBytes() == array().size) { |
|
|
|
if (hasArray() && arrayOffset() == 0 && readerIndex() == 0 && readableBytes() == array().size) { |
|
|
@ -67,9 +70,6 @@ object Rsa { |
|
|
|
// 1 in 2^80 |
|
|
|
// 1 in 2^80 |
|
|
|
private const val CERTAINTY = 80 |
|
|
|
private const val CERTAINTY = 80 |
|
|
|
|
|
|
|
|
|
|
|
val RSAPrivateCrtKeyParameters.publicKey |
|
|
|
|
|
|
|
get() = RSAKeyParameters(false, modulus, publicExponent) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun generateKeyPair(): Pair<RSAKeyParameters, RSAPrivateCrtKeyParameters> { |
|
|
|
fun generateKeyPair(): Pair<RSAKeyParameters, RSAPrivateCrtKeyParameters> { |
|
|
|
val generator = RSAKeyPairGenerator() |
|
|
|
val generator = RSAKeyPairGenerator() |
|
|
|
generator.init(RSAKeyGenerationParameters(F4, secureRandom, KEY_LENGTH, CERTAINTY)) |
|
|
|
generator.init(RSAKeyGenerationParameters(F4, secureRandom, KEY_LENGTH, CERTAINTY)) |
|
|
|