diff --git a/common/src/main/java/dev/openrs2/common/crypto/Rsa.kt b/common/src/main/java/dev/openrs2/common/crypto/Rsa.kt index 1737baef..d42cdc17 100644 --- a/common/src/main/java/dev/openrs2/common/crypto/Rsa.kt +++ b/common/src/main/java/dev/openrs2/common/crypto/Rsa.kt @@ -1,6 +1,7 @@ package dev.openrs2.common.crypto import io.netty.buffer.ByteBuf +import io.netty.buffer.ByteBufUtil import io.netty.buffer.Unpooled import org.bouncycastle.asn1.DERNull import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers @@ -28,14 +29,7 @@ val RSAPrivateCrtKeyParameters.publicKey get() = RSAKeyParameters(false, modulus, publicExponent) private fun ByteBuf.toBigInteger(): BigInteger { - val bytes: ByteArray - if (hasArray() && arrayOffset() == 0 && readerIndex() == 0 && readableBytes() == array().size) { - bytes = array() - } else { - bytes = ByteArray(readableBytes()) - getBytes(readerIndex(), bytes) - } - + val bytes = ByteBufUtil.getBytes(this, readerIndex(), readableBytes(), false) return BigInteger(bytes) }