You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add missing documentation for DSA, and update some existing docs. (#2794)
* Add missing documentation for DSA, and update some existing docs.
* (Attempt to) Fix some xrefs
* Apply suggestions from code review
Co-Authored-By: Ron Petrusha <ronpet@microsoft.com>
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.
43
43
44
-
Newer asymmetric algorithms are available. Consider using the <xref:System.Security.Cryptography.RSA> class, the <xref:System.Security.Cryptography.ECDsa> class, or the <xref:System.Security.Cryptography.ECDiffieHellman> class instead of the <xref:System.Security.Cryptography.DSA> class. Use <xref:System.Security.Cryptography.DSA> only for compatibility with legacy applications and data.
45
-
46
-
This algorithm supports key lengths from 512 bits to 1024 bits in increments of 64 bits.
44
+
> [!IMPORTANT]
45
+
> Newer asymmetric algorithms are available. Consider using the <xref:System.Security.Cryptography.RSA> class or the <xref:System.Security.Cryptography.ECDsa> class instead of the <xref:System.Security.Cryptography.DSA> class. Use <xref:System.Security.Cryptography.DSA> only for compatibility with legacy applications and data.
47
46
47
+
Two different versions of the DSA algorithm exist.
48
+
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.
49
+
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.
50
+
Not all derived implementations of this type support the FIPS 186-3 enhancements to DSA. Support can be detected via the <xref:System.Security.Cryptography.AsymmetricAlgorithm.LegalKeySizes> property.
<paramname="destination">The byte span to receive the signature.</param>
854
+
<paramname="bytesWritten">When this method returns, contains a value that indicates the number of bytes written to <paramrefname="destination"/>.</param>
855
+
<summary>Attempts to create the DSA signature for the specified hash into the provided buffer.</summary>
856
+
<returns><seelangword="true"/> if <paramrefname="destination"/> is large enough to receive the result; otherwise, <seelangword="false"/>.</returns>
857
+
<remarks>
858
+
<formattype="text/markdown"><![CDATA[
859
+
860
+
## Remarks
861
+
The default implementation of this method is to call <xref:System.Security.Cryptography.DSA.CreateSignature(System.Byte[])> and copy the result to `destination`.
862
+
Derived types should override this method to avoid the intermediate array creation.
863
+
]]></format>
864
+
</remarks>
865
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">This instance represents only a public key.
866
+
867
+
-or-
868
+
869
+
The implementation type only supports legacy DSA (FIPS 186-2), and <paramrefname="hash" /> is not a 20-byte value.
870
+
871
+
-or-
872
+
873
+
Creating the signature otherwise failed.</exception>
<paramname="destination">The byte span to receive the hash value.</param>
1045
+
<paramname="hashAlgorithm">The name of the hash algorithm to use.</param>
1046
+
<paramname="bytesWritten">When this method returns, contains a value that indicates the number of bytes written to <paramrefname="destination"/>.</param>
1047
+
<summary>Attempts to compute the hash value of the provided data into a provided buffer.</summary>
1048
+
<returns><seelangword="true"/> if <paramrefname="destination"/> is large enough to receive the result; otherwise, <seelangword="false"/>.</returns>
1049
+
<remarks>
1050
+
<formattype="text/markdown"><![CDATA[
1051
+
1052
+
## Remarks
1053
+
The default implementation of this method is to call <xref:System.Security.Cryptography.DSA.HashData(System.Byte[], System.Int32, System.Int32, System.Security.Cryptography.HashAlgorithmName)> and copy the result to `destination`.
1054
+
Derived types should override this method to avoid the intermediate array creation.
<paramname="data">The data to hash and sign.</param>
1089
+
<paramname="destination">The byte span to receive the signature.</param>
1090
+
<paramname="hashAlgorithm">The name of the hash algorithm to use.</param>
1091
+
<paramname="bytesWritten">When this method returns, contains a value that indicates the number of bytes written to <paramrefname="destination"/>.</param>
1092
+
<summary>Attempts to create the DSA signature for the specified data into the provided buffer.</summary>
1093
+
<returns><seelangword="true"/> if <paramrefname="destination"/> is large enough to receive the result; otherwise, <seelangword="false"/>.</returns>
1067
1094
<remarks>To be added.</remarks>
1068
1095
</Docs>
1069
1096
</Member>
@@ -1121,6 +1148,11 @@
1121
1148
-or-
1122
1149
1123
1150
<paramrefname="signature" /> is <seelangword="null" />.</exception>
1151
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.
1152
+
1153
+
-or-
1154
+
1155
+
Verifying the signature otherwise failed.</exception>
1124
1156
<exceptioncref="T:System.ArgumentException">
1125
1157
<paramrefname="hashAlgorithm" />.<seecref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <seelangword="null" /> or <seecref="F:System.String.Empty" />.</exception>
1126
1158
</Docs>
@@ -1171,6 +1203,11 @@
1171
1203
<paramrefname="signature" /> is <seelangword="null" />.</exception>
1172
1204
<exceptioncref="T:System.ArgumentException">
1173
1205
<paramrefname="hashAlgorithm" />.<seecref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <seelangword="null" /> or <seecref="F:System.String.Empty" />.</exception>
1206
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.
1207
+
1208
+
-or-
1209
+
1210
+
Verifying the signature otherwise failed.</exception>
<paramname="signature">The signature to be verified.</param>
1243
+
<paramname="hashAlgorithm">The hash algorithm used to create the hash value of the data.</param>
1244
+
<summary>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.</summary>
1245
+
<returns><seelangword="true" /> if the digital signature is valid; otherwise, <seelangword="false" />.</returns>
1209
1246
<remarks>To be added.</remarks>
1247
+
<exceptioncref="T:System.ArgumentException">
1248
+
<paramrefname="hashAlgorithm" />.<seecref="P:System.Security.Cryptography.HashAlgorithmName.Name" /> is <seelangword="null" /> or <seecref="F:System.String.Empty" />.</exception>
1249
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.
1250
+
1251
+
-or-
1252
+
1253
+
Verifying the signature otherwise failed.</exception>
1210
1254
</Docs>
1211
1255
</Member>
1212
1256
<MemberMemberName="VerifyData">
@@ -1269,6 +1313,11 @@
1269
1313
-or-
1270
1314
1271
1315
<paramrefname="offset" /> + <paramrefname="count" /> - 1 results in an index that is beyond the upper bound of <paramrefname="data" />.</exception>
1316
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash algorithm is not SHA-1.
1317
+
1318
+
-or-
1319
+
1320
+
Verifying the signature otherwise failed.</exception>
1272
1321
</Docs>
1273
1322
</Member>
1274
1323
<MemberMemberName="VerifySignature">
@@ -1310,6 +1359,11 @@
1310
1359
<returns>
1311
1360
<seelangword="true" /> if <paramrefname="rgbSignature" /> matches the signature computed using the specified hash algorithm and key on <paramrefname="rgbHash" />; otherwise, <seelangword="false" />.</returns>
1312
1361
<remarks>To be added.</remarks>
1362
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash value is not 20 bytes long.
1363
+
1364
+
-or-
1365
+
1366
+
Verifying the signature otherwise failed.</exception>
<paramname="hash">The data hash to verify.</param>
1398
+
<paramname="signature">The signature to be verify.</param>
1399
+
<summary>Verifies that a digital signature is valid for a provided data hash.</summary>
1400
+
<returns><seelangword="true" /> if the digital signature is valid for the hash; otherwise, <seelangword="false" />.</returns>
1401
+
<remarks>
1402
+
<formattype="text/markdown"><![CDATA[
1403
+
1404
+
## Remarks
1405
+
The default implementation of this method calls <xref:System.Security.Cryptography.DSA.VerifySignature(System.Byte[], System.Byte[])> after copying the spans to arrays.
1406
+
Derived types should override this method to avoid the intermediate array creation.
1407
+
]]></format>
1408
+
</remarks>
1409
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The implementation type only supports legacy DSA (FIPS 186-2), and the hash value is not 20 bytes long.
1410
+
1411
+
-or-
1412
+
1413
+
Verifying the signature otherwise failed.</exception>
0 commit comments