<PackageReference Include="Microsoft.Bcl.Cryptography" Version="11.0.0-preview.7.26381.103" />

System.Security.Cryptography.X25519DiffieHellman

public abstract class X25519DiffieHellman : IDisposable
Represents an X25519 Diffie-Hellman key.
public const int PrivateKeySizeInBytes = 32

The size of the private key, in bytes.

public const int PublicKeySizeInBytes = 32

The size of the public key, in bytes.

public const int SecretAgreementSizeInBytes = 32

The size of the secret agreement, in bytes.

public static bool IsSupported { get; }

Gets a value that indicates whether the algorithm is supported on the current platform.

protected X25519DiffieHellman()

Generates a new X25519 Diffie-Hellman key.

public static X25519DiffieHellman ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, ReadOnlySpan<byte> source)

Imports an X25519 Diffie-Hellman private key from a PKCS#8 EncryptedPrivateKeyInfo structure.

Imports an X25519 Diffie-Hellman private key from a PKCS#8 EncryptedPrivateKeyInfo structure.

public static X25519DiffieHellman ImportEncryptedPkcs8PrivateKey(string password, byte[] source)

Imports an X25519 Diffie-Hellman private key from a PKCS#8 EncryptedPrivateKeyInfo structure.

public static X25519DiffieHellman ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<char> password)

Imports an X25519 Diffie-Hellman key from an encrypted RFC 7468 PEM-encoded string.

public static X25519DiffieHellman ImportFromEncryptedPem(ReadOnlySpan<char> source, ReadOnlySpan<byte> passwordBytes)

Imports an X25519 Diffie-Hellman key from an encrypted RFC 7468 PEM-encoded string.

public static X25519DiffieHellman ImportFromEncryptedPem(string source, string password)

public static X25519DiffieHellman ImportFromEncryptedPem(string source, byte[] passwordBytes)

public static X25519DiffieHellman ImportFromPem(ReadOnlySpan<char> source)

Imports an X25519 Diffie-Hellman key from an RFC 7468 PEM-encoded string.

public static X25519DiffieHellman ImportFromPem(string source)

Imports an X25519 Diffie-Hellman private key from a PKCS#8 PrivateKeyInfo structure.

public static X25519DiffieHellman ImportPkcs8PrivateKey(byte[] source)

public static X25519DiffieHellman ImportPrivateKey(byte[] source)

Imports an X25519 Diffie-Hellman key from a private key.

Imports an X25519 Diffie-Hellman key from a private key.

public static X25519DiffieHellman ImportPublicKey(byte[] source)

Imports an X25519 Diffie-Hellman key from a public key.

public static X25519DiffieHellman ImportPublicKey(ReadOnlySpan<byte> source)

Imports an X25519 Diffie-Hellman key from a public key.

Imports an X25519 Diffie-Hellman key from an X.509 SubjectPublicKeyInfo structure.

public static X25519DiffieHellman ImportSubjectPublicKeyInfo(byte[] source)

Derives a raw secret agreement with the other party's key.

public byte[] DeriveRawSecretAgreement(byte[] otherPartyPublicKey)

Derives a raw secret agreement with the other party's public key.

public void DeriveRawSecretAgreement(X25519DiffieHellman otherParty, Span<byte> destination)

Derives a raw secret agreement with the other party's key, writing it into the provided buffer.

public void DeriveRawSecretAgreement(ReadOnlySpan<byte> otherPartyPublicKey, Span<byte> destination)

Derives a raw secret agreement with the other party's public key, writing it into the provided buffer.

protected abstract void DeriveRawSecretAgreementCore(X25519DiffieHellman otherParty, Span<byte> destination)

When overridden in a derived class, derives a raw secret agreement with the other party's key, writing it into the provided buffer.

protected abstract void DeriveRawSecretAgreementCore(ReadOnlySpan<byte> otherPartyPublicKey, Span<byte> destination)

When overridden in a derived class, derives a raw secret agreement with the other party's public key, writing it into the provided buffer.

public void Dispose()

Releases all resources used by the X25519DiffieHellman class.

protected virtual void Dispose(bool disposing)

Called by the Dispose() and Finalize() methods to release the managed and unmanaged resources used by the current instance of the X25519DiffieHellman class.

public byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters)

Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

public byte[] ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters)

Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

public byte[] ExportEncryptedPkcs8PrivateKey(string password, PbeParameters pbeParameters)

Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a string password.

public string ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters)

Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo format, using a byte-based password.

public string ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<char> password, PbeParameters pbeParameters)

Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo format, using a char-based password.

public string ExportEncryptedPkcs8PrivateKeyPem(string password, PbeParameters pbeParameters)

Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo format, using a string password.

public byte[] ExportPkcs8PrivateKey()

Exports the current key in the PKCS#8 PrivateKeyInfo format.

public string ExportPkcs8PrivateKeyPem()

Exports the current key in a PEM-encoded representation of the PKCS#8 PrivateKeyInfo format.

public byte[] ExportPrivateKey()

Exports the private key.

public void ExportPrivateKey(Span<byte> destination)

Exports the private key into the provided buffer.

protected abstract void ExportPrivateKeyCore(Span<byte> destination)

When overridden in a derived class, exports the private key into the provided buffer.

public byte[] ExportPublicKey()

Exports the public key.

public void ExportPublicKey(Span<byte> destination)

Exports the public key into the provided buffer.

protected abstract void ExportPublicKeyCore(Span<byte> destination)

When overridden in a derived class, exports the public key into the provided buffer.

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

Exports the public-key portion of the current key in a PEM-encoded representation of the X.509 SubjectPublicKeyInfo format.

public bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<byte> passwordBytes, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

public bool TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<char> password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

public bool TryExportEncryptedPkcs8PrivateKey(string password, PbeParameters pbeParameters, Span<byte> destination, out int bytesWritten)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a string password.

public bool TryExportPkcs8PrivateKey(Span<byte> destination, out int bytesWritten)

Attempts to export the current key in the PKCS#8 PrivateKeyInfo format into the provided buffer.

protected abstract bool TryExportPkcs8PrivateKeyCore(Span<byte> destination, out int bytesWritten)

When overridden in a derived class, attempts to export the current key in the PKCS#8 PrivateKeyInfo format into the provided buffer.

public bool TryExportSubjectPublicKeyInfo(Span<byte> destination, out int bytesWritten)

Attempts to export the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format into the provided buffer.