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, and update existing, ECDH API documentation. (#3542)
* Add missing, and update existing, ECDH API documentation.
* Apply feedback
* suggestions by carlossanlop
* avoid CI edits/loc issues
* avoid CI edits
* rollback link change
* fix broken links
* fix one more broken link
* fix more links
* Fix hashtag ctor
* Fix xrefs
<summary>Derives bytes that can be used as a key using a hash function .</summary>
265
+
<summary>Performs key derivation using a specified hash algorithm.</summary>
266
266
</Docs>
267
267
</MemberGroup>
268
268
<MemberMemberName="DeriveKeyFromHash">
@@ -294,9 +294,9 @@
294
294
</Parameters>
295
295
<Docs>
296
296
<paramname="otherPartyPublicKey">The other party's public key.</param>
297
-
<paramname="hashAlgorithm">The hash algorithm to use to derive the key material.</param>
298
-
<summary>Derives bytes that can be used as a key using a hash function, given another party's public key and hash algorithm's name.</summary>
299
-
<returns>The key material from the key exchange with the other party's public key.</returns>
297
+
<paramname="hashAlgorithm">The hash algorithm to use to derive the key material.</param>
298
+
<summary>Performs key derivation using a specified hash algorithm.</summary>
299
+
<returns>The hash of the shared secret.</returns>
300
300
<remarks>
301
301
<formattype="text/markdown"><![CDATA[
302
302
@@ -306,7 +306,19 @@
306
306
]]></format>
307
307
</remarks>
308
308
<exceptioncref="T:System.ArgumentException">
309
-
<paramrefname="otherPartyPublicKey" /> is over a different curve than this key.</exception>
309
+
The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.
310
+
311
+
-or-
312
+
313
+
The <paramrefname="hashAlgorithm"/> parameter does not specify a hash.
314
+
</exception>
315
+
<exceptioncref="T:System.ArgumentNullException">
316
+
<paramrefname="otherPartyPublicKey" /> is <seelangword="null"/>.</exception>
317
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
318
+
319
+
-or-
320
+
321
+
This instance represents only a public key.</exception>
310
322
</Docs>
311
323
</Member>
312
324
<MemberMemberName="DeriveKeyFromHash">
@@ -340,15 +352,37 @@
340
352
</Parameters>
341
353
<Docs>
342
354
<paramname="otherPartyPublicKey">The other party's public key.</param>
343
-
<paramname="hashAlgorithm">The hash algorithm to use to derive the key material.</param>
355
+
<paramname="hashAlgorithm">The hash algorithm to use to derive the key material.</param>
344
356
<paramname="secretPrepend">A value to prepend to the derived secret before hashing.</param>
345
357
<paramname="secretAppend">A value to append to the derived secret before hashing.</param>
346
-
<summary>When implemented in a derived class, derives bytes that can be used as a key using a hash function, given another party's public key, hash algorithm's name, a prepend value and an append value.</summary>
347
-
<returns>The key material from the key exchange with the other party's public key.</returns>
348
-
<remarks>To be added.</remarks>
358
+
<summary>When implemented in a derived class, performs key derivation using a specified hash algorithm with optional prepended or appended data.</summary>
359
+
<returns>The hash of the shared secret after prepending or appending data as requested.</returns>
360
+
<remarks>
361
+
<formattype="text/markdown"><![CDATA[
362
+
363
+
## Remarks
364
+
365
+
This method internally performs the Elliptic Curve Diffie-Hellman key agreement to produce the shared secret (`z`).
366
+
The return value from this method is the result of `HASH(secretPrepend || z || secretAppend)` using the specified hash algorithm, where `||` signifies concatenation.
367
+
368
+
If the value of `secretPrepend` or `secretAppend` is `null`, they are treated as empty arrays.
369
+
370
+
]]></format>
371
+
</remarks>
349
372
<exceptioncref="T:System.NotImplementedException">A derived class must override this method.</exception>
350
-
<exceptioncref="T:System.ArgumentException">
351
-
<paramrefname="otherPartyPublicKey" /> is over a different curve than this key.</exception>
373
+
<exceptioncref="T:System.ArgumentException">The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.
374
+
375
+
-or-
376
+
377
+
The <paramrefname="hashAlgorithm"/> parameter does not specify a hash.
378
+
</exception>
379
+
<exceptioncref="T:System.ArgumentNullException">
380
+
<paramrefname="otherPartyPublicKey" /> is <seelangword="null"/>.</exception>
381
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
382
+
383
+
-or-
384
+
385
+
This instance represents only a public key.</exception>
352
386
</Docs>
353
387
</Member>
354
388
<MemberGroupMemberName="DeriveKeyFromHmac">
@@ -357,7 +391,7 @@
357
391
<AssemblyVersion>4.0.0.0</AssemblyVersion>
358
392
</AssemblyInfo>
359
393
<Docs>
360
-
<summary>Derives bytes that can be used as a key using a Hash-based Message Authentication Code (HMAC).</summary>
394
+
<summary>Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm.</summary>
361
395
</Docs>
362
396
</MemberGroup>
363
397
<MemberMemberName="DeriveKeyFromHmac">
@@ -392,8 +426,8 @@
392
426
<paramname="otherPartyPublicKey">The other party's public key.</param>
393
427
<paramname="hashAlgorithm">The hash algorithm to use to derive the key material.</param>
394
428
<paramname="hmacKey">The key for the HMAC.</param>
395
-
<summary>Derives bytes that can be used as a key using a Hash-based Message Authentication Code (HMAC).</summary>
396
-
<returns>The key material from the key exchange with the other party's public key.</returns>
429
+
<summary>Performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm.</summary>
430
+
<returns>The HMAC of the shared secret.</returns>
397
431
<remarks>
398
432
<formattype="text/markdown"><![CDATA[
399
433
@@ -402,8 +436,19 @@
402
436
403
437
]]></format>
404
438
</remarks>
405
-
<exceptioncref="T:System.ArgumentException">
406
-
<paramrefname="otherPartyPublicKey" /> is over a different curve than this key.</exception>
439
+
<exceptioncref="T:System.ArgumentException">The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.
440
+
441
+
-or-
442
+
443
+
The <paramrefname="hashAlgorithm"/> parameter does not specify a hash.
444
+
</exception>
445
+
<exceptioncref="T:System.ArgumentNullException">
446
+
<paramrefname="otherPartyPublicKey" /> is <seelangword="null"/>.</exception>
447
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
448
+
449
+
-or-
450
+
451
+
This instance represents only a public key.</exception>
407
452
</Docs>
408
453
</Member>
409
454
<MemberMemberName="DeriveKeyFromHmac">
@@ -442,12 +487,35 @@
442
487
<paramname="hmacKey">The key for the HMAC.</param>
443
488
<paramname="secretPrepend">A value to prepend to the derived secret before hashing.</param>
444
489
<paramname="secretAppend">A value to append to the derived secret before hashing.</param>
445
-
<summary>When implemented in a derived class, derives bytes that can be used as a key using a Hash-based Message Authentication Code (HMAC).</summary>
446
-
<returns>The key material from the key exchange with the other party's public key.</returns>
447
-
<remarks>To be added.</remarks>
490
+
<summary>When implemented in a derived class, performs key derivation using a specified HMAC (Hash-based Message Authentication Code) algorithm with optional prepended or appended data.</summary>
491
+
<returns>The HMAC of the shared secret after prepending or appending data as requested.</returns>
492
+
<remarks>
493
+
<formattype="text/markdown"><![CDATA[
494
+
495
+
## Remarks
496
+
497
+
This method internally performs the Elliptic Curve Diffie-Hellman key agreement to produce the shared secret (`z`).
498
+
499
+
When `hmacKey` is `null`, the return value from this method is the result of `HMAC-HASH(z, secretPrepend || z || secretAppend)` using the specified HMAC algorithm, where `||` signifies concatenation. Otherwise, the return value from this method is the result of `HMAC-HASH(hmacKey, secretPrepend || z || secretAppend)`.
500
+
501
+
If the value of `secretPrepend` or `secretAppend` is `null`, they are treated as empty arrays.
502
+
503
+
]]></format>
504
+
</remarks>
448
505
<exceptioncref="T:System.NotImplementedException">A derived class must override this method.</exception>
449
-
<exceptioncref="T:System.ArgumentException">
450
-
<paramrefname="otherPartyPublicKey" /> is over a different curve than this key.</exception>
506
+
<exceptioncref="T:System.ArgumentException">The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.
507
+
508
+
-or-
509
+
510
+
The <paramrefname="hashAlgorithm"/> parameter does not specify a hash.
511
+
</exception>
512
+
<exceptioncref="T:System.ArgumentNullException">
513
+
<paramrefname="otherPartyPublicKey" /> is <seelangword="null"/>.</exception>
514
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
515
+
516
+
-or-
517
+
518
+
This instance represents only a public key.</exception>
451
519
</Docs>
452
520
</Member>
453
521
<MemberMemberName="DeriveKeyMaterial">
@@ -483,16 +551,28 @@
483
551
</Parameters>
484
552
<Docs>
485
553
<paramname="otherPartyPublicKey">The other party's public key.</param>
486
-
<summary>Derives bytes that can be used as a key, given another party's public key.</summary>
487
-
<returns>The key material from the key exchange with the other party's public key.</returns>
554
+
<summary>When implemented in a derived class, performs a key derivation on the shared secret.</summary>
555
+
<returns>The result of the key derivation function, using the shared secret as an input.</returns>
488
556
<remarks>
489
557
<formattype="text/markdown"><![CDATA[
490
558
491
-
## Remarks
492
-
For more information about public keys, see the <xref:System.Security.Cryptography.ECDiffieHellmanPublicKey> class.
493
-
559
+
## Remarks
560
+
561
+
The default behavior of this method is equivalent to calling <xref:System.Security.Cryptography.ECDiffieHellman.DeriveKeyFromHash%2A> specifying SHA-256 as the hash algorithm with no prepend or append values.
562
+
Some implementations allow the behavior of this method to be changed,
563
+
and callers are advised to call whichever method explicitly says it performs the key derivation they need.
564
+
494
565
]]></format>
495
566
</remarks>
567
+
<exceptioncref="T:System.ArgumentException">
568
+
The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.</exception>
569
+
<exceptioncref="T:System.ArgumentNullException">
570
+
<paramrefname="otherPartyPublicKey" /> is <seelangword="null"/>.</exception>
571
+
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
572
+
573
+
-or-
574
+
575
+
This instance represents only a public key.</exception>
496
576
</Docs>
497
577
</Member>
498
578
<MemberMemberName="DeriveKeyTls">
@@ -527,16 +607,37 @@
527
607
<paramname="otherPartyPublicKey">The other party's public key.</param>
<summary>When implemented in a derived class, derives bytes that can be used as a key using a Transport Layer Security (TLS) Pseudo-Random Function (PRF) derivation algorithm.</summary>
531
-
<returns>The key material from the key exchange with the other party's public key.</returns>
532
-
<remarks>To be added.</remarks>
610
+
<summary>When implemented in a derived class, performs key derivation using the TLS (Transport Layer Security) 1.1 PRF (Pseudo-Random Function).</summary>
611
+
<returns>The first 48 bytes from the TLS 1.1 PRF, using the shared secret as the key.</returns>
612
+
<remarks>
613
+
<formattype="text/markdown"><.
623
+
624
+
]]></format>
625
+
</remarks>
533
626
<exceptioncref="T:System.NotImplementedException">A derived class must override this method.</exception>
534
627
<exceptioncref="T:System.ArgumentException">
535
-
<paramrefname="otherPartyPublicKey" /> is over a different curve than this key.</exception>
628
+
The curve used by <paramrefname="otherPartyPublicKey" /> has a different size than the curve from this key.</exception>
536
629
<exceptioncref="T:System.ArgumentNullException">
537
-
<paramrefname="prfLabel" /> or <paramrefname="prfSeed" /> is <seelangword="null" />.</exception>
630
+
<paramrefname="otherPartyPublicKey"/>, <paramrefname="prfLabel" /> or <paramrefname="prfSeed" /> is <seelangword="null" />.</exception>
<paramrefname="prfSeed" /> is not exactly 64 bytes in length.</exception>
632
+
<paramrefname="prfSeed" /> is not exactly 64 bytes in length.
633
+
634
+
-or-
635
+
636
+
The curve used by <paramrefname="otherPartyPublicKey" /> is different than the curve from this key.
637
+
638
+
-or-
639
+
640
+
This instance represents only a public key.</exception>
540
641
</Docs>
541
642
</Member>
542
643
<MemberMemberName="ExportECPrivateKey">
@@ -757,8 +858,10 @@
757
858
<formattype="text/markdown"><![CDATA[
758
859
759
860
## Remarks
760
-
This method only supports the binary (BER/CER/DER) encoding of ECPrivateKey.
761
-
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
861
+
862
+
This method only supports the binary (BER/CER/DER) encoding of ECPrivateKey.
863
+
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
864
+
762
865
]]></format>
763
866
</remarks>
764
867
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The contents of <paramrefname="source" /> do not represent an ASN.1-BER-encoded PKCS#8 ECPrivateKey structure.
@@ -803,11 +906,13 @@ The key import failed.
803
906
<remarks>
804
907
<formattype="text/markdown"><![CDATA[
805
908
806
-
## Remarks
909
+
## Remarks
910
+
807
911
The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by the EncryptedPrivateKeyInfo contents.
808
912
This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).
809
913
This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo.
810
914
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
915
+
811
916
]]></format>
812
917
</remarks>
813
918
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The password is incorrect.
@@ -830,8 +935,7 @@ The contents of <paramref name="source" /> represent the key in a format that is
830
935
831
936
-or-
832
937
833
-
The algorithm-specific key import failed.
834
-
</exception>
938
+
The algorithm-specific key import failed.</exception>
@@ -872,6 +976,7 @@ The algorithm-specific key import failed.
872
976
When the contents of `source` indicate an algorithm that uses PBKDF1 (Password-Based Key Derivation Function 1) or PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.
873
977
This method only supports the binary (BER/CER/DER) encoding of EncryptedPrivateKeyInfo.
874
978
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
979
+
875
980
]]></format>
876
981
</remarks>
877
982
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The password is incorrect.
@@ -890,8 +995,7 @@ The contents of <paramref name="source" /> represent the key in a format that is
890
995
891
996
-or-
892
997
893
-
The algorithm-specific key import failed.
894
-
</exception>
998
+
The algorithm-specific key import failed.</exception>
895
999
</Docs>
896
1000
</Member>
897
1001
<MemberMemberName="ImportParameters">
@@ -973,6 +1077,7 @@ The algorithm-specific key import failed.
973
1077
## Remarks
974
1078
This method only supports the binary (BER/CER/DER) encoding of PrivateKeyInfo.
975
1079
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
1080
+
976
1081
]]></format>
977
1082
</remarks>
978
1083
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The contents of <paramrefname="source" /> do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo structure.
@@ -987,8 +1092,7 @@ The contents of <paramref name="source" /> represent the key in a format that is
987
1092
988
1093
-or-
989
1094
990
-
The algorithm-specific key import failed.
991
-
</exception>
1095
+
The algorithm-specific key import failed.</exception>
992
1096
</Docs>
993
1097
</Member>
994
1098
<MemberMemberName="ImportSubjectPublicKeyInfo">
@@ -1026,6 +1130,7 @@ The algorithm-specific key import failed.
1026
1130
## Remarks
1027
1131
This method only supports the binary (DER) encoding of SubjectPublicKeyInfo.
1028
1132
If the value is Base64-encoded or in the PEM text format, the caller must Base64-decode the contents before calling this method.
1133
+
1029
1134
]]></format>
1030
1135
</remarks>
1031
1136
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The contents of <paramrefname="source" /> do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure.
@@ -1040,8 +1145,7 @@ The contents of <paramref name="source" /> represent the key in a format that is
1040
1145
1041
1146
-or-
1042
1147
1043
-
The algorithm-specific key import failed.
1044
-
</exception>
1148
+
The algorithm-specific key import failed.</exception>
1045
1149
</Docs>
1046
1150
</Member>
1047
1151
<MemberMemberName="KeyExchangeAlgorithm">
@@ -1263,14 +1367,14 @@ The algorithm-specific key import failed.
1263
1367
## Remarks
1264
1368
The password bytes are passed directly into the Key Derivation Function (KDF) used by the algorithm indicated by `pbeParameters`.
1265
1369
This enables compatibility with other systems which use a text encoding other than UTF-8 when processing passwords with PBKDF2 (Password-Based Key Derivation Function 2).
1370
+
1266
1371
]]></format>
1267
1372
</remarks>
1268
1373
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The key could not be exported.
1269
1374
1270
1375
-or-
1271
1376
1272
-
<paramrefname="pbeParameters" /> indicates that <seecref="F:System.Security.Cryptography.PbeEncryptionAlgorithm.TripleDes3KeyPkcs12" /> should be used, which requires <seecref="T:System.Char" />-based passwords.
1273
-
</exception>
1377
+
<paramrefname="pbeParameters" /> indicates that <seecref="F:System.Security.Cryptography.PbeEncryptionAlgorithm.TripleDes3KeyPkcs12" /> should be used, which requires <seecref="T:System.Char" />-based passwords.</exception>
@@ -1313,6 +1417,7 @@ The algorithm-specific key import failed.
1313
1417
1314
1418
## Remarks
1315
1419
When `pbeParameters` indicates an algorithm that uses PBKDF2 (Password-Based Key Derivation Function 2), the password is converted to bytes via the UTF-8 encoding.
1420
+
1316
1421
]]></format>
1317
1422
</remarks>
1318
1423
<exceptioncref="T:System.Security.Cryptography.CryptographicException">The key could not be exported.</exception>
0 commit comments