Early Preview

This is currently very much a preview. Please feel free to try things out, but don't be upset if anything is not yet working. Feedback is welcome over on our GitHub Dicussions page.

class System.​Security.​Cryptography.​CompositeMLDsa

Assembly: System.Security.Cryptography

Inheritance: object → CompositeMLDsa

Implemented Interfaces

Represents a Composite ML-DSA key.

Properties

Algorithm
Gets the specific Composite ML-DSA algorithm for this key.
public static bool
IsSupported
Gets a value indicating whether the current platform supports Composite ML-DSA.

Methods

public void
Dispose​()
Releases all resources used by the <see cref="T:System.Security.Cryptography.CompositeMLDsa" /> class.
protected void
Dispose​(bool disposing)
<para>Called by the <see cref="M:System.Security.Cryptography.CompositeMLDsa.Dispose" /> method to release the managed and unmanaged resources used by the current instance of the <see cref="T:System.Security.Cryptography.CompositeMLDsa" /> class.</para>
disposing <para> <see langword="true" /> to release managed and unmanaged resources; <see langword="false" /> to release only unmanaged resources.</para>
public byte[]
ExportCompositeMLDsaPrivateKey​()
Exports the private-key portion of the current key.
Returns The Composite ML-DSA private key.
public int
ExportCompositeMLDsaPrivateKey​(Span<​byte> destination)
Exports the private-key portion of the current key into the provided buffer.
Returns The number of bytes written to the <paramref name="destination" /> buffer.
destination The buffer to receive the Composite ML-DSA private key value.
protected int
ExportCompositeMLDsaPrivateKeyCore​(Span<​byte> destination)
When overridden in a derived class, exports the private key portion of the current key.
Returns The number of bytes written to the <paramref name="destination" /> buffer.
destination The buffer to receive the private key value.
public byte[]
ExportCompositeMLDsaPublicKey​()
Exports the public-key portion of the current key.
Returns The Composite ML-DSA public key.
public int
ExportCompositeMLDsaPublicKey​(Span<​byte> destination)
Exports the public-key portion of the current key into the provided buffer.
Returns The number of bytes written to the <paramref name="destination" /> buffer.
destination The buffer to receive the Composite ML-DSA public key value.
protected int
ExportCompositeMLDsaPublicKeyCore​(Span<​byte> destination)
When overridden in a derived class, exports the public key portion of the current key.
Returns The number of bytes written to the <paramref name="destination" /> buffer.
destination The buffer to receive the public key value.
public byte[]
ExportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​byte> passwordBytes, PbeParameters pbeParameters)
Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.
Returns A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of the this key.
passwordBytes The bytes to use as a password when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public byte[]
ExportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​char> password, PbeParameters pbeParameters)
Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.
Returns A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of the this key.
password The password to use when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public byte[]
ExportEncryptedPkcs8PrivateKey​(string password, PbeParameters pbeParameters)
Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.
Returns A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of the this key.
password The password to use when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public string
ExportEncryptedPkcs8PrivateKeyPem​(ReadOnlySpan<​byte> passwordBytes, PbeParameters pbeParameters)
<para>Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo representation of this key, using a byte-based password.</para>
Returns A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo.
passwordBytes The bytes to use as a password when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public string
ExportEncryptedPkcs8PrivateKeyPem​(ReadOnlySpan<​char> password, PbeParameters pbeParameters)
<para>Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo representation of this key, using a char-based password.</para>
Returns A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo.
password The password to use when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public string
ExportEncryptedPkcs8PrivateKeyPem​(string password, PbeParameters pbeParameters)
<p>Exports the current key in a PEM-encoded representation of the PKCS#8 EncryptedPrivateKeyInfo representation of this key, using a char-based password.</p>
Returns A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo.
password The password to use when encrypting the key material.
pbeParameters The password-based encryption (PBE) parameters to use when encrypting the key material.
public byte[]
ExportPkcs8PrivateKey​()
Exports the current key in the PKCS#8 PrivateKeyInfo format.
Returns A byte array containing the PKCS#8 PrivateKeyInfo representation of the this key.
public string
ExportPkcs8PrivateKeyPem​()
Exports the current key in a PEM-encoded representation of the PKCS#8 PrivateKeyInfo format.
Returns <para>A string containing the PEM-encoded representation of the PKCS#8 PrivateKeyInfo representation of the public-key portion of this key.</para>
public byte[]
ExportSubjectPublicKeyInfo​()
Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.
Returns A byte array containing the X.509 SubjectPublicKeyInfo representation of the public-key portion of this key.
public string
ExportSubjectPublicKeyInfoPem​()
<para>Exports the public-key portion of the current key in a PEM-encoded representation of the X.509 SubjectPublicKeyInfo format.</para>
Returns <para>A string containing the PEM-encoded representation of the X.509 SubjectPublicKeyInfo representation of the public-key portion of this key.</para>
public static CompositeMLDsa
GenerateKey​(CompositeMLDsaAlgorithm algorithm)
Generates a new Composite ML-DSA key.
Returns The generated key.
algorithm An algorithm identifying what kind of Composite ML-DSA key to generate.
public static CompositeMLDsa
ImportCompositeMLDsaPrivateKey​(CompositeMLDsaAlgorithm algorithm, byte[] source)
Imports a Composite ML-DSA private key.
Returns The imported key.
algorithm The specific Composite ML-DSA algorithm for this key.
source The bytes of the public key.
public static CompositeMLDsa
ImportCompositeMLDsaPrivateKey​(CompositeMLDsaAlgorithm algorithm, ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA private key.
Returns The imported key.
algorithm The specific Composite ML-DSA algorithm for this key.
source The bytes of the public key.
public static CompositeMLDsa
ImportCompositeMLDsaPublicKey​(CompositeMLDsaAlgorithm algorithm, byte[] source)
Imports a Composite ML-DSA public key.
Returns The imported key.
algorithm The specific Composite ML-DSA algorithm for this key.
source The bytes of the public key.
public static CompositeMLDsa
ImportCompositeMLDsaPublicKey​(CompositeMLDsaAlgorithm algorithm, ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA public key.
Returns The imported key.
algorithm The specific Composite ML-DSA algorithm for this key.
source The bytes of the public key.
public static CompositeMLDsa
ImportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​byte> passwordBytes, ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA private key from a PKCS#8 EncryptedPrivateKeyInfo structure.
Returns The imported key.
passwordBytes The bytes to use as a password when decrypting the key material.
source The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.
public static CompositeMLDsa
ImportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​char> password, ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA private key from a PKCS#8 EncryptedPrivateKeyInfo structure.
Returns The imported key.
password The password to use when decrypting the key material.
source The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.
public static CompositeMLDsa
ImportEncryptedPkcs8PrivateKey​(string password, byte[] source)
Imports a Composite ML-DSA private key from a PKCS#8 EncryptedPrivateKeyInfo structure.
Returns The imported key.
password The password to use when decrypting the key material.
source The bytes of a PKCS#8 EncryptedPrivateKeyInfo structure in the ASN.1-BER encoding.
public static CompositeMLDsa
ImportFromEncryptedPem​(ReadOnlySpan<​char> source, ReadOnlySpan<​byte> passwordBytes)
Imports a Composite ML-DSA key from an encrypted RFC 7468 PEM-encoded string.
source The PEM text of the encrypted key to import.
passwordBytes The bytes to use as a password when decrypting the key material.
public static CompositeMLDsa
ImportFromEncryptedPem​(ReadOnlySpan<​char> source, ReadOnlySpan<​char> password)
Imports a Composite ML-DSA key from an encrypted RFC 7468 PEM-encoded string.
source The PEM text of the encrypted key to import.
password The password to use for decrypting the key material.
public static CompositeMLDsa
ImportFromEncryptedPem​(string source, byte[] passwordBytes)
Imports a Composite ML-DSA key from an encrypted RFC 7468 PEM-encoded string.
source The PEM text of the encrypted key to import.
passwordBytes The bytes to use as a password when decrypting the key material.
public static CompositeMLDsa
ImportFromEncryptedPem​(string source, string password)
Imports a Composite ML-DSA key from an encrypted RFC 7468 PEM-encoded string.
source The PEM text of the encrypted key to import.
password The password to use for decrypting the key material.
public static CompositeMLDsa
ImportFromPem​(ReadOnlySpan<​char> source)
Imports a Composite ML-DSA key from an RFC 7468 PEM-encoded string.
Returns The imported Composite ML-DSA key.
source The text of the PEM key to import.
public static CompositeMLDsa
ImportFromPem​(string source)
Imports a Composite ML-DSA key from an RFC 7468 PEM-encoded string.
Returns The imported Composite ML-DSA key.
source The text of the PEM key to import.
public static CompositeMLDsa
ImportPkcs8PrivateKey​(byte[] source)
Imports a Composite ML-DSA private key from a PKCS#8 PrivateKeyInfo structure.
Returns The imported key.
source The bytes of a PKCS#8 PrivateKeyInfo structure in the ASN.1-BER encoding.
public static CompositeMLDsa
ImportPkcs8PrivateKey​(ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA private key from a PKCS#8 PrivateKeyInfo structure.
Returns The imported key.
source The bytes of a PKCS#8 PrivateKeyInfo structure in the ASN.1-BER encoding.
public static CompositeMLDsa
ImportSubjectPublicKeyInfo​(byte[] source)
Imports a Composite ML-DSA public key from an X.509 SubjectPublicKeyInfo structure.
Returns The imported key.
source The bytes of an X.509 SubjectPublicKeyInfo structure in the ASN.1-DER encoding.
public static CompositeMLDsa
ImportSubjectPublicKeyInfo​(ReadOnlySpan<​byte> source)
Imports a Composite ML-DSA public key from an X.509 SubjectPublicKeyInfo structure.
Returns The imported key.
source The bytes of an X.509 SubjectPublicKeyInfo structure in the ASN.1-DER encoding.
public static bool
IsAlgorithmSupported​(CompositeMLDsaAlgorithm algorithm)
Determines whether the specified algorithm is supported by the current platform.
Returns <see langword="true" /> if the algorithm is supported; otherwise, <see langword="false" /> .
algorithm The <see cref="T:System.Security.Cryptography.CompositeMLDsaAlgorithm" /> to check for support.
public byte[]
SignData​(byte[] data, byte[] context = null)
Signs the specified data.
Returns The Composite ML-DSA signature of the specified data.
data The data to sign.
context <para>An optional context-specific value to limit the scope of the signature.</para> <para>The default value is <see langword="null" />.</para>
public int
SignData​(ReadOnlySpan<​byte> data, Span<​byte> destination, ReadOnlySpan<​byte> context = null)
Signs the specified data, writing the signature into the provided buffer.
Returns The number of bytes written to the <paramref name="destination" /> buffer.
data The data to sign.
destination The buffer to receive the signature. Its length must be at least <see cref="P:System.Security.Cryptography.CompositeMLDsaAlgorithm.MaxSignatureSizeInBytes" /> .
context <para>An optional context-specific value to limit the scope of the signature.</para> <para>The default value is an empty buffer.</para>
protected int
SignDataCore​(ReadOnlySpan<​byte> data, ReadOnlySpan<​byte> context, Span<​byte> destination)
<para>When overridden in a derived class, computes the signature of the specified data and context, writing it into the provided buffer.</para>
Returns The number of bytes written to the <paramref name="destination" /> buffer.
data The data to sign.
context The signature context.
destination The buffer to receive the signature, whose length will be exactly <see cref="P:System.Security.Cryptography.CompositeMLDsaAlgorithm.MaxSignatureSizeInBytes" /> .
public bool
TryExportCompositeMLDsaPrivateKey​(Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportCompositeMLDsaPublicKey​(Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​byte> passwordBytes, PbeParameters pbeParameters, Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportEncryptedPkcs8PrivateKey​(ReadOnlySpan<​char> password, PbeParameters pbeParameters, Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportEncryptedPkcs8PrivateKey​(string password, PbeParameters pbeParameters, Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportPkcs8PrivateKey​(Span<​byte> destination, Int32& bytesWritten)
protected bool
TryExportPkcs8PrivateKeyCore​(Span<​byte> destination, Int32& bytesWritten)
public bool
TryExportSubjectPublicKeyInfo​(Span<​byte> destination, Int32& bytesWritten)
public bool
VerifyData​(byte[] data, byte[] signature, byte[] context = null)
Verifies that the specified signature is valid for this key and the provided data.
Returns <see langword="true" /> if the signature validates the data; otherwise, <see langword="false" /> .
data The data to verify.
signature The signature to verify.
context <para>The context value which was provided during signing.</para> <para>The default value is <see langword="null" />.</para>
public bool
VerifyData​(ReadOnlySpan<​byte> data, ReadOnlySpan<​byte> signature, ReadOnlySpan<​byte> context = null)
Verifies that the specified signature is valid for this key and the provided data.
Returns <see langword="true" /> if the signature validates the data; otherwise, <see langword="false" /> .
data The data to verify.
signature The signature to verify.
context <para>The context value which was provided during signing.</para> <para>The default value is an empty buffer.</para>
protected bool
VerifyDataCore​(ReadOnlySpan<​byte> data, ReadOnlySpan<​byte> context, ReadOnlySpan<​byte> signature)
When overridden in a derived class, verifies the signature of the specified data and context.
Returns <see langword="true" /> if the signature validates the data; otherwise, <see langword="false" /> .
data The data to verify.
context The signature context.
signature The signature to verify.
public bool
Equals​(object obj)
Inherited from object
protected void
Finalize​()
Inherited from object
public int
GetHashCode​()
Inherited from object
public Type
GetType​()
Inherited from object
protected object
MemberwiseClone​()
Inherited from object
public string
ToString​()
Inherited from object