Class Curve25519PrivateKey
- Namespace
- Yubico.YubiKey.Cryptography
- Assembly
- Yubico.YubiKey.dll
Represents a Curve25519 private key.
public sealed class Curve25519PrivateKey : PrivateKey, IPrivateKey, IKeyBase
- Inheritance
-
objectCurve25519PrivateKey
- Implements
- Inherited Members
- Extension Methods
Remarks
This sealed class encapsulates Curve25519 private key data and supports both Ed25519 and X25519 cryptographic operations. It also provides factory methods for creating instances from private key values 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
PrivateKey
Gets the bytes representing the private scalar value.
public ReadOnlyMemory<byte> PrivateKey { get; }
Property Value
- ReadOnlyMemory<byte>
A System.ReadOnlyMemory<T> containing the private scalar value.
Methods
Clear()
Clears the private key.
public override void Clear()
Remarks
This method securely zeroes out the private key data.
CreateFromPkcs8(ReadOnlyMemory<byte>)
Creates an instance of Curve25519PrivateKey from a PKCS#8 ASN.1 DER-encoded private key.
public static Curve25519PrivateKey CreateFromPkcs8(ReadOnlyMemory<byte> pkcs8EncodedKey)
Parameters
pkcs8EncodedKey
ReadOnlyMemory<byte>The ASN.1 DER-encoded private key.
Returns
- Curve25519PrivateKey
A new instance of Curve25519PrivateKey.
Exceptions
- ArgumentException
Thrown if the algorithm OID is not X25519 or Ed25519.
- CryptographicException
Thrown if privateKey does not match expected format.
CreateFromValue(ReadOnlyMemory<byte>, KeyType)
Creates an instance of Curve25519PrivateKey from the given
privateKey
and keyType
.
public static Curve25519PrivateKey CreateFromValue(ReadOnlyMemory<byte> privateKey, KeyType keyType)
Parameters
privateKey
ReadOnlyMemory<byte>The raw private key data. This is copied internally.
keyType
KeyTypeThe type of key this is.
Returns
- Curve25519PrivateKey
An instance of Curve25519PrivateKey.
Exceptions
- CryptographicException
Thrown if privateKey does not match expected format.
ExportPkcs8PrivateKey()
Exports the current key in the PKCS#8 PrivateKeyInfo format.
public override byte[] ExportPkcs8PrivateKey()
Returns
- byte[]
A byte array containing the PKCS#8 PrivateKeyInfo representation of this key.