Table of Contents

Class ECPublicKey

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

Represents an Elliptic Curve (EC) public key.

public class ECPublicKey : PublicKey, IPublicKey, IKeyBase
Inheritance
object
ECPublicKey
Implements
Extension Methods

Remarks

This class encapsulates EC public key parameters and provides cryptographic operations for NIST elliptic curves and provides factory methods for creating instances from EC parameters or DER-encoded data.

Constructors

ECPublicKey(ECDsa)

Initializes a new instance of the ECPublicKey class.

protected ECPublicKey(ECDsa ecdsa)

Parameters

ecdsa ECDsa

ECPublicKey(ECParameters)

Initializes a new instance of the ECPublicKey class. It is a wrapper for the System.Security.Cryptography.ECParameters class.

protected ECPublicKey(ECParameters parameters)

Parameters

parameters ECParameters

Remarks

This constructor is used to create an instance from a System.Security.Cryptography.ECParameters object. It will deep copy the parameters from the System.Security.Cryptography.ECParameters object.

Exceptions

ArgumentException

Thrown when the parameters contain private key data (D value).

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 Elliptic Curve parameters associated with this instance.

public ECParameters Parameters { get; }

Property Value

ECParameters

An System.Security.Cryptography.ECParameters structure containing the curve parameters, key, and other cryptographic elements needed for EC operations.

PublicPoint

Gets the bytes representing the public key coordinates.

public ReadOnlyMemory<byte> PublicPoint { get; }

Property Value

ReadOnlyMemory<byte>

A System.ReadOnlyMemory<T> containing the public key bytes with the format 0x04 || X || Y.

Methods

CreateFromParameters(ECParameters)

Creates an instance of ECPublicKey from the given parameters.

public static ECPublicKey CreateFromParameters(ECParameters parameters)

Parameters

parameters ECParameters

The parameters to create the key from.

Returns

ECPublicKey

An instance of ECPublicKey.

CreateFromSubjectPublicKeyInfo(ReadOnlyMemory<byte>)

Creates an instance of ECPublicKey from a DER-encoded SubjectPublicKeyInfo.

public static ECPublicKey CreateFromSubjectPublicKeyInfo(ReadOnlyMemory<byte> subjectPublicKeyInfo)

Parameters

subjectPublicKeyInfo ReadOnlyMemory<byte>

The DER-encoded SubjectPublicKeyInfo.

Returns

ECPublicKey

An instance of IPublicKey.

Exceptions

CryptographicException

Thrown if the subjectPublicKeyInfo is invalid.

CreateFromValue(ReadOnlyMemory<byte>, KeyType)

Creates an instance of ECPublicKey from the given publicPoint and keyType.

public static ECPublicKey CreateFromValue(ReadOnlyMemory<byte> publicPoint, KeyType keyType)

Parameters

publicPoint ReadOnlyMemory<byte>

The raw public key data, formatted as an compressed point.

keyType KeyType

The type of key this is.

Returns

ECPublicKey

An instance of ECPublicKey.

Exceptions

ArgumentException

Thrown if the key type is not a valid EC key.

ExportSubjectPublicKeyInfo()

Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.

public override byte[] ExportSubjectPublicKeyInfo()

Returns

byte[]

A byte array containing the X.509 SubjectPublicKeyInfo representation of the public-key portion of this key