RSA

class RSA constructor(val publicKey: CryptoPublicKey.RSA, val privateKey: BigInteger, val prime1: BigInteger, val prime2: BigInteger, val prime1exponent: BigInteger, val prime2exponent: BigInteger, val crtCoefficient: BigInteger, val otherPrimeInfos: List<CryptoPrivateKey.RSA.PrimeInfo>?, val attributes: List<Asn1Element>? = null) : CryptoPrivateKey.Impl, CryptoPrivateKey.WithPublicKey<CryptoPublicKey.RSA> (source)

PKCS#1 RSA Private key representation as per RFC 8017 augmented with optional attributes. Attributes are never PKCS#1 encoded, but are relevant when PKCS#8-encoding a private key.

Constructors

Link copied to clipboard
constructor(publicKey: CryptoPublicKey.RSA, privateKey: BigInteger, prime1: BigInteger, prime2: BigInteger, prime1exponent: BigInteger, prime2exponent: BigInteger, crtCoefficient: BigInteger, otherPrimeInfos: List<CryptoPrivateKey.RSA.PrimeInfo>?, attributes: List<Asn1Element>? = null)

Types

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
data class PrimeInfo(val prime: BigInteger, val exponent: BigInteger, val coefficient: BigInteger) : Asn1Encodable<Asn1Sequence>

OtherPrimeInfos as per PKCS#1

Properties

Link copied to clipboard

Encodes this private key into a PKCS#1-encoded private key

Link copied to clipboard

Encodes this private key into a PKCS#8-encoded private key. This is the default.

Link copied to clipboard
open override val attributes: List<Asn1Element>?

optional attributes relevant when PKCS#8-encoding a private key

Link copied to clipboard
open override val canonicalPEMBoundary: String

Encapsulation boundary string. Will be automatically fenced.

Link copied to clipboard
val crtCoefficient: BigInteger

qInv: the factors' CRT coefficient (q^(-1) mod p)

Link copied to clipboard
open override val oid: ObjectIdentifier
Link copied to clipboard

information about additional prime factors: triples (r_i, d_i, t_i) of prime factor, exponent, coefficient

Link copied to clipboard
val prime1: BigInteger

p: the first prime factor

Link copied to clipboard
val prime1exponent: BigInteger

dP: the first factor's CRT exponent

Link copied to clipboard
val prime2: BigInteger

q: the second prime factor

Link copied to clipboard
val prime2exponent: BigInteger

dQ: the second factor's CRT exponent

Link copied to clipboard
val privateKey: BigInteger

d: the private key such that d*e = 1 mod phi(n)

Link copied to clipboard
open override val publicKey: CryptoPublicKey.RSA

The CryptoPublicKey.RSA (n,e) matching this private key

Functions

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open fun encodeToDerSafe(): KmmResult<ByteArray>
Link copied to clipboard
fun PemEncodable<*>.encodeToPEM(): KmmResult<String>

Encodes this PemEncodable into a PEM-encoded string

Link copied to clipboard
open override fun encodeToTlv(): Asn1Sequence

PKCS#8 encoding of a private key:

Link copied to clipboard
Link copied to clipboard
open fun encodeToTlvSafe(): KmmResult<Asn1Sequence>
Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun CryptoPrivateKey.WithPublicKey<*>.toSecKey(): KmmResult<SecKeyRef>

Converts this privateKey into a SecKeyRef, making it usable on iOS

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open infix fun withImplicitTag(tagValue: ULong): Asn1Element