Table of Contents

Interface IEcdhPrimitives

Namespace
Yubico.Core.Cryptography
Assembly
Yubico.Core.dll

An interface exposing ECDH primitive operations.

public interface IEcdhPrimitives

Methods

ComputeSharedSecret(ECParameters, ReadOnlySpan<byte>)

Computes a shared secret by producing the ECDH shared point without running it through a KDF. Only the X-coordinate is returned.

byte[] ComputeSharedSecret(ECParameters publicKey, ReadOnlySpan<byte> privateValue)

Parameters

publicKey ECParameters

The other party's public key.

privateValue ReadOnlySpan<byte>

Your private key value that was generated based on the same curve as the other party's public key.

Returns

byte[]

The X-coordinate of the computed shared point.

Remarks

This function calculates the shared point - the result of the scalar-multiplication of the peer's publicKey and the local privateValue. Only the X coordinate of the shared point is returned.

GenerateKeyPair(ECCurve)

Generates a elliptic curve public/private keypair that can be used for ECDH operations.

ECParameters GenerateKeyPair(ECCurve curve)

Parameters

curve ECCurve

The elliptic curve that the keypair should be generated on.

Returns

ECParameters

An ECParameters structure representing the Curve, the public point Q, and the private key D.

Remarks

As of SDK 1.5.0, only the named curves `ECCurve.NamedCurves.nistP256`, `ECCurve.NamedCurves.nistP384`, and `ECCurve.NamedCurves.nistP521` are required to be supported.

Callers of this function should take care when handling this structure. Since it will contain the private key value in `D`, it is recommended that `CryptographicOperations.ZeroMemory` be called as soon as the key is no longer needed.