DSA DSA DSA DSA Class

定义

表示所有数字签名算法 (DSA) 的实现都必须从中继承的抽象基类。Represents the abstract base class from which all implementations of the Digital Signature Algorithm (DSA) must inherit.

public ref class DSA abstract : System::Security::Cryptography::AsymmetricAlgorithm
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class DSA : System.Security.Cryptography.AsymmetricAlgorithm
type DSA = class
    inherit AsymmetricAlgorithm
Public MustInherit Class DSA
Inherits AsymmetricAlgorithm
继承
派生
属性

注解

可以使用DSA类和派生类创建数字签名,以帮助保护数据的完整性。You can use the DSA class and derived classes to create digital signatures that help protect the integrity of your data. DSACryptoServiceProvider提供此类的实现。The DSACryptoServiceProvider provides an implementation of this class.

若要使用公钥系统对消息进行数字签名,则发送方首先将哈希函数应用于消息,以创建消息摘要。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 assume 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.

重要

较新的非对称算法可用。Newer asymmetric algorithms are available. 请考虑使用RSAECDsa或类而不是DSA类。Consider using the RSA class or the ECDsa class instead of the DSA class. DSA仅用于与旧版应用程序和数据兼容。Use DSA only for compatibility with legacy applications and data.

存在两种不同版本的 DSA 算法。Two different versions of the DSA algorithm exist. FIPS 186-2 中所述的原始格式要求使用 SHA-1 作为哈希算法,并支持从512位到1024位的密钥长度(以64位为增量)。The original form, described in FIPS 186-2, requires the use of SHA-1 as the hash algorithm and supports key lengths from 512 bits to 1024 bits in increments of 64 bits. FIPS 186-3 中描述了算法的更新版本,该版本允许使用 SHA-2 系列哈希算法并添加了对2048位密钥和3072位密钥的支持。An updated version of the algorithm was described in FIPS 186-3, which enabled the use of the SHA-2 family of hash algorithms and added support for 2048 bit keys and 3072 bit keys. 并非该类型的所有派生实现都支持对 DSA 进行 FIPS 186-3 增强。Not all derived implementations of this type support the FIPS 186-3 enhancements to DSA. 可以通过LegalKeySizes属性检测支持。Support can be detected via the LegalKeySizes property.

构造函数

DSA() DSA() DSA() DSA()

初始化 DSA 类的新实例。Initializes a new instance of the DSA class.

方法

Clear() Clear() Clear() Clear()

释放 AsymmetricAlgorithm 类使用的所有资源。Releases all resources used by the AsymmetricAlgorithm class.

(Inherited from AsymmetricAlgorithm)
Create() Create() Create() Create()

创建用于执行不对称算法的默认加密对象。Creates the default cryptographic object used to perform the asymmetric algorithm.

Create(DSAParameters) Create(DSAParameters) Create(DSAParameters) Create(DSAParameters)

创建具有指定 DSA 密钥参数的新临时 DSA 密钥。Creates a new ephemeral DSA key with the specified DSA key parameters.

Create(Int32) Create(Int32) Create(Int32) Create(Int32)

创建具有指定密钥大小的新临时 DSA 密钥。Creates a new ephemeral DSA key with the specified key size.

Create(String) Create(String) Create(String) Create(String)

创建用于执行不对称算法的指定加密对象。Creates the specified cryptographic object used to perform the asymmetric algorithm.

CreateSignature(Byte[]) CreateSignature(Byte[]) CreateSignature(Byte[]) CreateSignature(Byte[])

当在派生类中重写时,创建指定数据的 DSA 签名。When overridden in a derived class, creates the DSA signature for the specified data.

Dispose() Dispose() Dispose() Dispose()

释放 AsymmetricAlgorithm 类的当前实例所使用的所有资源。Releases all resources used by the current instance of the AsymmetricAlgorithm class.

(Inherited from AsymmetricAlgorithm)
Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

释放 AsymmetricAlgorithm 类使用的非托管资源,并可以选择释放托管资源。Releases the unmanaged resources used by the AsymmetricAlgorithm class and optionally releases the managed resources.

(Inherited from AsymmetricAlgorithm)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(Inherited from Object)
ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters) ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters) ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters) ExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters)

使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式导出当前密钥。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password.

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

使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式导出当前密钥。Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password.

(Inherited from AsymmetricAlgorithm)
ExportParameters(Boolean) ExportParameters(Boolean) ExportParameters(Boolean) ExportParameters(Boolean)

当在派生类中重写时,导出 DSAParametersWhen overridden in a derived class, exports the DSAParameters.

ExportPkcs8PrivateKey() ExportPkcs8PrivateKey() ExportPkcs8PrivateKey() ExportPkcs8PrivateKey()

以 PKCS#8 PrivateKeyInfo 格式导出当前密钥。Exports the current key in the PKCS#8 PrivateKeyInfo format.

(Inherited from AsymmetricAlgorithm)
ExportSubjectPublicKeyInfo() ExportSubjectPublicKeyInfo() ExportSubjectPublicKeyInfo() ExportSubjectPublicKeyInfo()

以 X.509 SubjectPublicKeyInfo 格式导出当前密钥的公钥部分。Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format.

(Inherited from AsymmetricAlgorithm)
FromXmlString(String) FromXmlString(String) FromXmlString(String) FromXmlString(String)

通过 XML 字符串重新构造 DSA 对象。Reconstructs a DSA object from an XML string.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

作为默认哈希函数。Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
HashData(Byte[], Int32, Int32, HashAlgorithmName) HashData(Byte[], Int32, Int32, HashAlgorithmName) HashData(Byte[], Int32, Int32, HashAlgorithmName) 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.

HashData(Stream, HashAlgorithmName) HashData(Stream, HashAlgorithmName) HashData(Stream, HashAlgorithmName) HashData(Stream, HashAlgorithmName)

在派生类中被重写时,使用指定的哈希算法计算指定的二进制流的哈希值。When overridden in a derived class, computes the hash value of a specified binary stream by using a specified hashing algorithm.

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

使用基于字节的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。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<Char>, ReadOnlySpan<Byte>, Int32) ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32) ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32) ImportEncryptedPkcs8PrivateKey(ReadOnlySpan<Char>, ReadOnlySpan<Byte>, Int32)

使用基于字符的密码解密之后,从 PKCS#8 EncryptedPrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object.

ImportParameters(DSAParameters) ImportParameters(DSAParameters) ImportParameters(DSAParameters) ImportParameters(DSAParameters)

当在派生类中重写时,导入指定的 DSAParametersWhen overridden in a derived class, imports the specified DSAParameters.

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

解密后,从 PKCS#8 PrivateKeyInfo 结构中导入公/私钥对,以替换此对象的密钥。Imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object.

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

解密后,从 X.509 SubjectPublicKeyInfo 结构中导入公钥,以替换此对象的密钥。Imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

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

使用指定的哈希算法计算指定字节数组的哈希值,并对生成的哈希值进行签名。Computes the hash value of the specified byte array using the specified hash algorithm and signs the resulting hash value.

SignData(Byte[], Int32, Int32, HashAlgorithmName) SignData(Byte[], Int32, Int32, HashAlgorithmName) SignData(Byte[], Int32, Int32, HashAlgorithmName) 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.

SignData(Stream, HashAlgorithmName) SignData(Stream, HashAlgorithmName) SignData(Stream, HashAlgorithmName) SignData(Stream, HashAlgorithmName)

使用指定的哈希算法计算指定流的哈希值,并对生成的哈希值进行签名。Computes the hash value of the specified stream using the specified hash algorithm and signs the resulting hash value.

ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)
ToXmlString(Boolean) ToXmlString(Boolean) ToXmlString(Boolean) ToXmlString(Boolean)

创建并返回当前 DSA 对象的 XML 字符串表示形式。Creates and returns an XML string representation of the current DSA object.

TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32) TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32) TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32) TryCreateSignature(ReadOnlySpan<Byte>, Span<Byte>, Int32)

尝试将指定哈希的 DSA 签名创建到所提供的缓冲区中。Attempts to create the DSA signature for the specified hash into the provided buffer.

TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32) TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32) TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32) TryExportEncryptedPkcs8PrivateKey(ReadOnlySpan<Byte>, PbeParameters, Span<Byte>, Int32)

尝试使用基于字节的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a byte-based password.

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

尝试使用基于字符的密码以 PKCS#8 EncryptedPrivateKeyInfo 格式将当前密钥导入所提供的缓冲区。Attempts to export the current key in the PKCS#8 EncryptedPrivateKeyInfo format into a provided buffer, using a char-based password.

TryExportPkcs8PrivateKey(Span<Byte>, Int32) TryExportPkcs8PrivateKey(Span<Byte>, Int32) TryExportPkcs8PrivateKey(Span<Byte>, Int32) TryExportPkcs8PrivateKey(Span<Byte>, Int32)

尝试以 PKCS#8 PrivateKeyInfo 格式将当前密钥导出到所提供的缓冲区。Attempts to export the current key in the PKCS#8 PrivateKeyInfo format into a provided buffer.

TryExportSubjectPublicKeyInfo(Span<Byte>, Int32) TryExportSubjectPublicKeyInfo(Span<Byte>, Int32) TryExportSubjectPublicKeyInfo(Span<Byte>, Int32) TryExportSubjectPublicKeyInfo(Span<Byte>, Int32)

尝试以 X.509 SubjectPublicKeyInfo 格式将当前密钥导出到所提供的缓冲区。Attempts to export the current key in the X.509 SubjectPublicKeyInfo format into a provided buffer.

TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TryHashData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

尝试将所提供数据的哈希值计算到所提供的缓冲区中。Attempts to compute the hash value of the provided data into a provided buffer.

TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32) TrySignData(ReadOnlySpan<Byte>, Span<Byte>, HashAlgorithmName, Int32)

尝试将指定数据的 DSA 签名创建到所提供的缓冲区中。Attempts to create the DSA signature for the specified data into the provided buffer.

VerifyData(Byte[], Byte[], HashAlgorithmName) VerifyData(Byte[], Byte[], HashAlgorithmName) VerifyData(Byte[], Byte[], HashAlgorithmName) 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.

VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName) VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName) VerifyData(Byte[], Int32, Int32, Byte[], HashAlgorithmName) 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.

VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName) VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName) VerifyData(ReadOnlySpan<Byte>, ReadOnlySpan<Byte>, HashAlgorithmName) 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.

VerifyData(Stream, Byte[], HashAlgorithmName) VerifyData(Stream, Byte[], HashAlgorithmName) VerifyData(Stream, Byte[], HashAlgorithmName) 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.

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

当在派生类中重写时,验证指定数据的 DSA 签名。When overridden in a derived class, verifies the DSA signature for the specified data.

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

验证数字签名对于所提供的数据哈希是否有效。Verifies that a digital signature is valid for a provided data hash.

属性

KeyExchangeAlgorithm KeyExchangeAlgorithm KeyExchangeAlgorithm KeyExchangeAlgorithm

当在派生类中重写时,请获取密钥交换算法的名称。When overridden in a derived class, gets the name of the key exchange algorithm. 否则,将引发 NotImplementedExceptionOtherwise, throws an NotImplementedException.

(Inherited from AsymmetricAlgorithm)
KeySize KeySize KeySize KeySize

获取或设置非对称算法所用密钥模块的大小(以位为单位)。Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)
LegalKeySizes LegalKeySizes LegalKeySizes LegalKeySizes

获取非对称算法支持的密钥大小。Gets the key sizes that are supported by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)
SignatureAlgorithm SignatureAlgorithm SignatureAlgorithm SignatureAlgorithm

当在派生类中实现时,请获取签名算法的名称。When implemented in a derived class, gets the name of the signature algorithm. 否则,将始终引发 NotImplementedExceptionOtherwise, always throws a NotImplementedException.

(Inherited from AsymmetricAlgorithm)

字段

KeySizeValue KeySizeValue KeySizeValue KeySizeValue

表示非对称算法所用密钥模块的大小(以位为单位)。Represents the size, in bits, of the key modulus used by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)
LegalKeySizesValue LegalKeySizesValue LegalKeySizesValue LegalKeySizesValue

指定非对称算法支持的密钥大小。Specifies the key sizes that are supported by the asymmetric algorithm.

(Inherited from AsymmetricAlgorithm)

显式界面实现

IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose() IDisposable.Dispose()

有关此成员的说明,请参见 Dispose()For a description of this member, see Dispose().

(Inherited from AsymmetricAlgorithm)

适用于

另请参阅