Επεξεργασία

Κοινή χρήση μέσω


DSACryptoServiceProvider Class

Definition

Defines a wrapper object to access the cryptographic service provider (CSP) implementation of the DSA algorithm. This class cannot be inherited.

public ref class DSACryptoServiceProvider sealed : System::Security::Cryptography::DSA, System::Security::Cryptography::ICspAsymmetricAlgorithm
public ref class DSACryptoServiceProvider sealed : System::Security::Cryptography::DSA
public sealed class DSACryptoServiceProvider : System.Security.Cryptography.DSA, System.Security.Cryptography.ICspAsymmetricAlgorithm
public sealed class DSACryptoServiceProvider : System.Security.Cryptography.DSA
[System.Runtime.InteropServices.ComVisible(true)]
public sealed class DSACryptoServiceProvider : System.Security.Cryptography.DSA, System.Security.Cryptography.ICspAsymmetricAlgorithm
type DSACryptoServiceProvider = class
    inherit DSA
    interface ICspAsymmetricAlgorithm
type DSACryptoServiceProvider = class
    inherit DSA
[<System.Runtime.InteropServices.ComVisible(true)>]
type DSACryptoServiceProvider = class
    inherit DSA
    interface ICspAsymmetricAlgorithm
Public NotInheritable Class DSACryptoServiceProvider
Inherits DSA
Implements ICspAsymmetricAlgorithm
Public NotInheritable Class DSACryptoServiceProvider
Inherits DSA
Inheritance
DSACryptoServiceProvider
Attributes
Implements

Remarks

You can use the DSACryptoServiceProvider class to create digital signatures and protect the integrity of your data.

To use a public-key system to digitally sign a message, the sender first applies a hash function to the message to create a message digest. The sender then encrypts the message digest with the sender's private key to create the sender's personal signature. Upon receiving the message and signature, the receiver decrypts the signature using the sender's public key to recover the message digest and hashes the message using the same hash algorithm that the sender used. If the message digest that the receiver computes exactly matches the message digest received from the sender, the receiver can be sure that the message was not altered while in transit. Note that a signature can be verified by anyone, because the sender's public key is common knowledge.

Note

The creators of the DSA algorithm have withdrawn their support for it. Consider using the RSACryptoServiceProvider class instead of the DSACryptoServiceProvider class. Use DSACryptoServiceProvider only for compatibility with legacy applications and data.

This algorithm supports key lengths from 512 bits to 1024 bits in increments of 64 bits.

Constructors

DSACryptoServiceProvider()

Initializes a new instance of the DSACryptoServiceProvider class.

DSACryptoServiceProvider(CspParameters)

Initializes a new instance of the DSACryptoServiceProvider class with the specified parameters for the cryptographic service provider (CSP).

DSACryptoServiceProvider(Int32, CspParameters)

Initializes a new instance of the DSACryptoServiceProvider class with the specified key size and parameters for the cryptographic service provider (CSP).

DSACryptoServiceProvider(Int32)

Initializes a new instance of the DSACryptoServiceProvider class with the specified key size.

Fields

KeySizeValue

Represents the size, in bits, of the key modulus used by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)
LegalKeySizesValue

Specifies the key sizes that are supported by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)

Properties

CspKeyContainerInfo

Gets a CspKeyContainerInfo object that describes additional information about a cryptographic key pair.

KeyExchangeAlgorithm

Gets the name of the key exchange algorithm.

KeySize

Gets the size of the key used by the asymmetric algorithm in bits.

LegalKeySizes

Gets the key sizes that are supported by the asymmetric algorithm.

LegalKeySizes

Gets the key sizes that are supported by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)
PersistKeyInCsp

Gets or sets a value indicating whether the key should be persisted in the cryptographic service provider (CSP).

PublicOnly

Gets a value that indicates whether the DSACryptoServiceProvider object contains only a public key.

SignatureAlgorithm

Gets the name of the signature algorithm.

UseMachineKeyStore

Gets or sets a value indicating whether the key should be persisted in the computer's key store instead of the user profile store.

Methods

Clear()

Releases all resources used by the AsymmetricAlgorithm class.

(Inherited from AsymmetricAlgorithm)
CreateSignature(Byte[], DSASignatureFormat)

Creates the DSA signature for the specified hash value in the indicated format.

(Inherited from DSA)
CreateSignature(Byte[])

Creates the DSA signature for the specified data.

CreateSignatureCore(ReadOnlySpan<Byte>, DSASignatureFormat)

Creates the DSA signature for the specified hash value in the indicated format.

(Inherited from DSA)
Dispose()

Releases all resources used by the current instance of the AsymmetricAlgorithm class.

(Inherited from AsymmetricAlgorithm)
Dispose(Boolean)

Releases the unmanaged resources used by the AsymmetricAlgorithm class and optionally releases the managed resources.

(Inherited from AsymmetricAlgorithm)
Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExportCspBlob(Boolean)

Exports a blob containing the key information associated with a DSACryptoServiceProvider object.

ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

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

(Inherited from AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters)

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

(Inherited from AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters)

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

(Inherited from AsymmetricAlgorithm)
ExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters)

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

(Inherited from AsymmetricAlgorithm)
ExportParameters(Boolean)

Exports the DSAParameters.

ExportPkcs8PrivateKey()

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

(Inherited from AsymmetricAlgorithm)
ExportPkcs8PrivateKeyPem()

Exports the current key in the PKCS#8 PrivateKeyInfo format, PEM encoded.

(Inherited from AsymmetricAlgorithm)
ExportSubjectPublicKeyInfo()

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

(Inherited from AsymmetricAlgorithm)
ExportSubjectPublicKeyInfoPem()

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

(Inherited from AsymmetricAlgorithm)
Finalize()

Frees all resources associated with this instance.

FromXmlString(String)

Reconstructs a DSA object from an XML string.

(Inherited from DSA)
GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetMaxSignatureSize(DSASignatureFormat)

Gets the largest size, in bytes, for a signature produced by this key in the indicated format.

(Inherited from DSA)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName)

When overridden in a derived class, computes the hash value of a specified portion of a byte array by using a specified hashing algorithm.

(Inherited from DSA)
HashData(Stream, HashAlgorithmName)

When overridden in a derived class, computes the hash value of a specified binary stream by using a specified hashing algorithm.

(Inherited from DSA)
ImportCspBlob(Byte[])

Imports a blob that represents DSA key information.

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, Int32)

Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object.

(Inherited from DSA)
ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

(Inherited from DSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Byte>)

Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(Inherited from DSA)
ImportFromEncryptedPem(ReadOnlySpan<Char>, ReadOnlySpan<Char>)

Imports an encrypted RFC 7468 PEM-encoded private key, replacing the keys for this object.

(Inherited from DSA)
ImportFromPem(ReadOnlySpan<Char>)

Imports an RFC 7468 PEM-encoded key, replacing the keys for this object.

(Inherited from DSA)
ImportParameters(DSAParameters)

Imports the specified DSAParameters.

ImportPkcs8PrivateKey(ReadOnlySpan<Byte>, Int32)

Imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

(Inherited from DSA)
ImportSubjectPublicKeyInfo(ReadOnlySpan<Byte>, Int32)

Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

(Inherited from DSA)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SignData(Byte[], HashAlgorithmName, DSASignatureFormat)

Computes the hash value of the specified data and signs it using the specified signature format.

(Inherited from DSA)
SignData(Byte[], HashAlgorithmName)

Computes the hash value of the specified byte array using the specified hash algorithm and signs the resulting hash value.

(Inherited from DSA)
SignData(Byte[], Int32, Int32, HashAlgorithmName, DSASignatureFormat)

Computes the hash value of the specified data and signs it using the specified signature format.

(Inherited from DSA)
SignData(Byte[], Int32, Int32, HashAlgorithmName)

Computes the hash value of a portion of the specified byte array using the specified hash algorithm and signs the resulting hash value.

(Inherited from DSA)
SignData(Byte[], Int32, Int32)

Signs a byte array from the specified start point to the specified end point.

SignData(Byte[])

Computes the hash value of the specified byte array and signs the resulting hash value.

SignData(Stream, HashAlgorithmName, DSASignatureFormat)

Computes the hash value of the specified data and signs it using the specified signature format.

(Inherited from DSA)
SignData(Stream, HashAlgorithmName)

Computes the hash value of the specified stream using the specified hash algorithm and signs the resulting hash value.

(Inherited from DSA)
SignData(Stream)

Computes the hash value of the specified input stream and signs the resulting hash value.

SignDataCore(ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Computes the hash value of the specified data and signs it using the specified signature format.

(Inherited from DSA)
SignDataCore(Stream, HashAlgorithmName, DSASignatureFormat)

Computes the hash value of the specified data and signs it using the specified signature format.

(Inherited from DSA)
SignHash(Byte[], String)

Computes the signature for the specified hash value by encrypting it with the private key.

ToString()

Returns a string that represents the current object.

(Inherited from Object)
ToXmlString(Boolean)

Creates and returns an XML string representation of the current DSA object.

(Inherited from DSA)
TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, DSASignatureFormat, Int32)

Attempts to create the DSA signature for the specified hash value in the indicated format and place it into the provided buffer.

(Inherited from DSA)
TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32)

Attempts to create the DSA signature for the specified hash into the provided buffer.

(Inherited from DSA)
TryCreateSignatureCore(ReadOnlySpan<Byte>, Span<Byte>, DSASignatureFormat, Int32)

Attempts to create the DSA signature for the specified hash value in the indicated format and place it into the provided buffer.

(Inherited from DSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

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

(Inherited from DSA)
TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, PbeParameters, Span<Byte>, Int32)

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

(Inherited from DSA)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Byte>, PbeParameters, Span<Char>, Int32)

Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password, PEM encoded.

(Inherited from AsymmetricAlgorithm)
TryExportEncryptedPkcs8PrivateKeyPem(ReadOnlySpan<Char>, PbeParameters, Span<Char>, Int32)

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

(Inherited from AsymmetricAlgorithm)
TryExportPkcs8PrivateKey(Span<Byte>, Int32)

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

(Inherited from DSA)
TryExportPkcs8PrivateKeyPem(Span<Char>, Int32)

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

(Inherited from AsymmetricAlgorithm)
TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

Attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

(Inherited from DSA)
TryExportSubjectPublicKeyInfoPem(Span<Char>, Int32)

Attempts to export the current key in the PEM-encoded X.509 SubjectPublicKeyInfo format into a provided buffer.

(Inherited from AsymmetricAlgorithm)
TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

Attempts to compute the hash value of the provided data into a provided buffer.

(Inherited from DSA)
TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, DSASignatureFormat, Int32)

Attempts to create the DSA signature for the specified data in the indicated format and place it into the provided buffer.

(Inherited from DSA)
TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

Attempts to create the DSA signature for the specified data into the provided buffer.

(Inherited from DSA)
TrySignDataCore(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, DSASignatureFormat, Int32)

Attempts to create the DSA signature for the specified data in the indicated format and place it into the provided buffer.

(Inherited from DSA)
VerifyData(Byte[], Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyData(Byte[], Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the specified data using the specified hash algorithm and comparing it to the provided signature.

(Inherited from DSA)
VerifyData(Byte[], Byte[])

Verifies the specified signature data by comparing it to the signature computed for the specified data.

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the data in a portion of a byte array using the specified hash algorithm and comparing it to the provided signature.

(Inherited from DSA)
VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the data in a byte span using the specified hash algorithm and comparing it to the provided signature.

(Inherited from DSA)
VerifyData(Stream, Byte[], HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyData(Stream, Byte[], HashAlgorithmName)

Verifies that a digital signature is valid by calculating the hash value of the specified stream using the specified hash algorithm and comparing it to the provided signature.

(Inherited from DSA)
VerifyDataCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyDataCore(Stream, ReadOnlySpan<Byte>, HashAlgorithmName, DSASignatureFormat)

Verifies that a digital signature is valid for the provided data.

(Inherited from DSA)
VerifyHash(Byte[], String, Byte[])

Verifies the specified signature data by comparing it to the signature computed for the specified hash value.

VerifySignature(Byte[], Byte[], DSASignatureFormat)

Verifies that a digital signature is valid for the provided hash.

(Inherited from DSA)
VerifySignature(Byte[], Byte[])

Verifies the DSA signature for the specified data.

VerifySignature(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, DSASignatureFormat)

Verifies that a digital signature is valid for the provided hash.

(Inherited from DSA)
VerifySignature(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>)

Verifies that a digital signature is valid for a provided data hash.

(Inherited from DSA)
VerifySignatureCore(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, DSASignatureFormat)

Verifies that a digital signature is valid for the provided hash.

(Inherited from DSA)

Explicit Interface Implementations

IDisposable.Dispose()

This API supports the product infrastructure and is not intended to be used directly from your code.

For a description of this member, see Dispose().

(Inherited from AsymmetricAlgorithm)

Applies to

See also