Table of Contents

Class RSAPrivateKey

Namespace
Yubico.YubiKey.Cryptography
Assembly
Yubico.YubiKey.dll

Represents the parameters for an RSA private key.

public sealed class RSAPrivateKey : PrivateKey, IPrivateKey, IKeyBase
Inheritance
object
RSAPrivateKey
Implements
Inherited Members
Extension Methods

Remarks

This class encapsulates the parameters specific to RSA private keys and provides factory methods for creating instances from RSA parameters or DER-encoded data.

Properties

KeyDefinition

Gets the key definition associated with this RSA private key.

public KeyDefinition KeyDefinition { get; }

Property Value

KeyDefinition

A KeyDefinition object that describes the key's properties, including its type and length.

KeyType

Gets the type of the cryptographic key.

public override KeyType KeyType { get; }

Property Value

KeyType

A KeyType value indicating the type of the key.

Parameters

Gets the RSA cryptographic parameters required for the private key operations.

public RSAParameters Parameters { get; }

Property Value

RSAParameters

A structure containing RSA parameters, including Modulus, Exponent, D, P, Q, DP, DQ, and InverseQ values.

Remarks

This property provides access to the fundamental mathematical components needed for RSA private key operations. The parameters are used in cryptographic operations such as decryption and digital signature creation.

Methods

Clear()

Securely clears the RSA private key by zeroing out all parameters.

public override void Clear()

CreateFromParameters(RSAParameters)

Creates a new instance of RSAPrivateKey from the given parameters.

public static RSAPrivateKey CreateFromParameters(RSAParameters parameters)

Parameters

parameters RSAParameters

The RSA parameters containing the private key data.

Returns

RSAPrivateKey

A new instance of RSAPrivateKey.

CreateFromPkcs8(ReadOnlyMemory<byte>)

Creates a new instance of RSAPrivateKey from a DER-encoded PKCS#8 private key.

public static RSAPrivateKey CreateFromPkcs8(ReadOnlyMemory<byte> encodedKey)

Parameters

encodedKey ReadOnlyMemory<byte>

The DER-encoded PKCS#8 private key.

Returns

RSAPrivateKey

A new instance of RSAPrivateKey.

Exceptions

CryptographicException

Thrown if the private key is invalid.

NotSupportedException

When the RSA key length is not supported.

ExportPkcs8PrivateKey()

Exports the RSA private key in PKCS#8 DER encoded format.

public override byte[] ExportPkcs8PrivateKey()

Returns

byte[]

A byte array containing the DER encoded private key.