decipherRsa

fun ByteBuf.decipherRsa(exp: BigInteger, mod: BigInteger, size: Int, preferNative: Boolean = true): ByteBuf

Deciphers a slice from this buffer using RSA encryption/decryption.

Return

a slice of this buffer using this buffer's allocator that is the result of running the modPow operation on the slice.

Parameters

exp

the exponent to apply to this block of data

mod

the modulo to run against the result of that

size

the number of bytes to read from this buffer for the RSA block

preferNative

whether to prefer a native, faster library for RSA. This library shows ~4.7x performance improvements, but is not supported on all platforms. Any failure to use it will turn off native support and fall back to the Java variant for the rest of the applications runtime.

Throws

mod ≤ 0 or the exponent is negative and base is not relatively prime to mod.