Class PrivateKey
- Namespace
- Yubico.YubiKey.Cryptography
- Assembly
- Yubico.YubiKey.dll
Abstract base class for private key implementations.
public abstract class PrivateKey : IPrivateKey, IKeyBase
- Inheritance
-
objectPrivateKey
- Implements
- Derived
- Extension Methods
Remarks
This class implements the standard .NET disposal pattern to ensure secure cleanup of sensitive cryptographic material and provides disposal state checking for derived classes.
Concrete implementations include ECPrivateKey, RSAPrivateKey and Curve25519PrivateKey, each providing algorithm-specific key handling and cryptographic operations.
Properties
KeyType
Gets the type of the cryptographic key.
public abstract KeyType KeyType { get; }
Property Value
Methods
Clear()
Clears the buffers containing private key data.
public abstract void Clear()
Dispose()
Clears the private key data and disposes the object
public void Dispose()
ExportPkcs8PrivateKey()
Exports the current key in the PKCS#8 PrivateKeyInfo format.
public abstract byte[] ExportPkcs8PrivateKey()
Returns
- byte[]
A byte array containing the PKCS#8 PrivateKeyInfo representation of this key.
ThrowIfDisposed()
Throws an System.ObjectDisposedException if this instance has been disposed.
protected void ThrowIfDisposed()
Remarks
This method should be called at the beginning of all public methods and properties in derived classes to prevent operations on disposed cryptographic key material. The exception message includes the concrete type name for debugging purposes.
Exceptions
- ObjectDisposedException
Thrown when this method is called after the object has been disposed.