From 79243c52b33f34a960cac37c5a3d8a1be8b459d2 Mon Sep 17 00:00:00 2001 From: Jeremy Barton Date: Mon, 25 Nov 2019 09:33:05 -0800 Subject: [PATCH 1/3] Add missing, and update existing, ECDsa API documentation --- xml/System.Security.Cryptography/ECDsa.xml | 98 ++++---- xml/System.Security.Cryptography/ECDsaCng.xml | 121 +++++++--- .../ECDsaOpenSsl.xml | 228 +++++++++++++----- 3 files changed, 307 insertions(+), 140 deletions(-) diff --git a/xml/System.Security.Cryptography/ECDsa.xml b/xml/System.Security.Cryptography/ECDsa.xml index bac7a70150a..cafee736dd6 100644 --- a/xml/System.Security.Cryptography/ECDsa.xml +++ b/xml/System.Security.Cryptography/ECDsa.xml @@ -461,8 +461,8 @@ - The curve to use. - When overridden in a derived class, generates a new public/private key pair for the specified curve. + The curve to use to generate the key. + When overridden in a derived class, generates a new ephemeral public/private key pair for the specified curve, replacing the current key. To be added. A derived class must override this method. @@ -1158,7 +1158,7 @@ The algorithm-specific key import failed. The hash value of the data that is being signed. Generates a digital signature for the specified hash value. - A digital signature that consists of the given hash value encrypted with the private key. + A digital signature for the specified hash value. To be added. The parameter is . @@ -1432,13 +1432,22 @@ The algorithm-specific key import failed. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. + The data to be hashed. + The buffer to receive the hash value. + The algorithm to use to hash the data. + When this method returns, the total number of bytes written into . This parameter is treated as uninitialized. + Attempts to compute the hash value of the specified read-only span of bytes into the provided destination by using the specified hashing algorithm. + if is not long enough to receive the hash value. + + and copy the result to `destination`. +Derived types should override this method to avoid the intermediate array creation. + + ]]> + @@ -1470,12 +1479,12 @@ The algorithm-specific key import failed. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. + The data to be signed. + The buffer to receive the signature. + The algorithm to use to hash the data for signing. + When this method returns, the total number of bytes written into . This parameter is treated as uninitialized. + Attempts to compute the ECDSA digital signature for the specified read-only span of bytes into the provided destination by using the specified hashing algorithm and the current key. + if is not long enough to receive the signature. To be added. @@ -1507,11 +1516,11 @@ The algorithm-specific key import failed. - To be added. - To be added. - To be added. - To be added. - To be added. + The hash value of the data that is being signed. + The buffer to receive the signature. + When this method returns, the total number of bytes written into . This parameter is treated as uninitialized. + Attempts to compute the ECDSA digital signature for the specified read-only span of bytes representing a data hash into the provided destination by using the current key. + if is not long enough to receive the signature. To be added. @@ -1523,7 +1532,7 @@ The algorithm-specific key import failed. 4.3.0.0 - Verifies that a digital signature is valid. + Verifies that a digital signature is appropriate for the current key and provided data with a specified hash algorithm. @@ -1563,7 +1572,7 @@ The algorithm-specific key import failed. The signed data. The signature data to be verified. The hash algorithm used to create the hash value of the data. - 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. + Verifies that a digital signature is appropriate for the current key and provided data with a specified hash algorithm. if the signature is valid; otherwise, . To be added. @@ -1614,7 +1623,7 @@ The algorithm-specific key import failed. The signed data. The signature data to be verified. The hash algorithm used to create the hash value of the data. - 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. + Verifies that a digital signature is appropriate for the current key and provided data with a specified hash algorithm. if the signature is valid; otherwise, . To be added. @@ -1656,12 +1665,14 @@ The algorithm-specific key import failed. - To be added. - To be added. - To be added. - To be added. - To be added. + The signed data. + The signature to be verified. + The hash algorithm used to create the hash value of the data. + Verifies that a digital signature is appropriate for the current key and provided data with a specified hash algorithm. + if the signature is valid; otherwise, . To be added. + + . is or . @@ -1705,7 +1716,7 @@ The algorithm-specific key import failed. The number of bytes to hash. The signature data to be verified. The hash algorithm used to create the hash value of the data. - 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. + Verifies that a digital signature is appropriate for the current key and provided portion of data with a specified hash algorithm. if the signature is valid; otherwise, . To be added. @@ -1763,19 +1774,13 @@ The algorithm-specific key import failed. - The hash value of a block of data. - The digital signature to be verified. - Verifies a digital signature against the specified hash value. + The hash value of the data to be verified. + The digital signature of the data to be verified against the hash value. + Verifies that a digital signature is appropriate for the current key and provided data hash. - if the hash value equals the decrypted signature; otherwise, . - - - + if the signature is valid; otherwise, . + To be added. + or is . @@ -1805,10 +1810,11 @@ The algorithm-specific key import failed. - To be added. - To be added. - To be added. - To be added. + The hash value of the data to be verified. + The digital signature of the data to be verified against the hash value. + Verifies that a digital signature is appropriate for the current key and provided data hash. + + if the signature is valid; otherwise, . To be added. diff --git a/xml/System.Security.Cryptography/ECDsaCng.xml b/xml/System.Security.Cryptography/ECDsaCng.xml index ed699c5afc6..d65bd7b1f55 100644 --- a/xml/System.Security.Cryptography/ECDsaCng.xml +++ b/xml/System.Security.Cryptography/ECDsaCng.xml @@ -32,7 +32,8 @@ abstract base class. +This class should only be used directly when doing platform interop with the Windows CNG library. +When platform interop is not needed, you should use the factory methods instead of a specific derived implementation. @@ -92,11 +93,15 @@ property to 521 and when a key is needed the saved size is used to identify the target curve. +If a key is loaded via the method, or other key import method, the key size from this constructor has no meaning. ]]> Cryptography Next Generation (CNG) classes are not supported on this system. + @@ -134,18 +139,23 @@ The size of the key. Valid key sizes are 256, 384, and 521 bits. - Initializes a new instance of the class with a random key pair, using the specified key size. + Initializes a new instance of the class with a specified target key size. property to the provided value and when a key is needed the saved size is used to identify the target curve. +If a key is loaded via the method, or other key import method, the key size from this constructor has no meaning. + ]]> Cryptography Next Generation (CNG) classes are not supported on this system. specifies an invalid length. + @@ -271,8 +281,9 @@ - To be added. - To be added. + + to release managed and unmanaged resources; to release only unmanaged resources. + Releases the resources used by the current instance of the class. To be added. @@ -467,7 +478,7 @@ The curve to use to generate the key. - Generates a key to use for the ECDsaCng algorithm. + Generates a new ephemeral public/private key pair for the specified curve, replacing the current key. To be added. does not validate. @@ -551,10 +562,10 @@ - To be added. - To be added. - To be added. - To be added. + The binary stream to hash. + The algorithm to use to hash the data. + Computes the hash value of the specified binary stream by using the specified hashing algorithm. + The hashed data. To be added. @@ -591,12 +602,12 @@ - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. + The data to be hashed. + The index of the first byte in to be hashed. + The number of bytes to hash. + The algorithm to use to hash the data. + Computes the hash value of the specified portion of a byte array by using the specified hashing algorithm. + The hashed data. To be added. @@ -708,9 +719,23 @@ System.Int32 - To be added. - To be added. - To be added. + Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm. + The size, in bits, of the key modulus used by the asymmetric algorithm. + + method. + +]]> + + + is not permitted by . + @@ -739,9 +764,25 @@ System.Security.Cryptography.KeySizes[] - To be added. - To be added. - To be added. + Gets the key sizes, in bits, that are supported by the property setter. + An array that contains the key sizes supported by the property setter. + + + + @@ -1078,13 +1119,12 @@ - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. + The data to be hashed. + The buffer to receive the hash value. + The algorithm to use to hash the data. + When this method returns, the total number of bytes written into . This parameter is treated as uninitialized. + Attempts to compute the hash value of the specified read-only span of bytes into the provided destination by using the specified hashing algorithm. + if is not long enough to receive the hash value. @@ -1112,11 +1152,11 @@ - To be added. - To be added. - To be added. - To be added. - To be added. + The hash value of the data that is being signed. + The buffer to receive the signature. + When this method returns, the total number of bytes written into . This parameter is treated as uninitialized. + Attempts to compute the ECDSA digital signature for the specified read-only span of bytes representing a data hash into the provided destination by using the current key. + if is not long enough to receive the signature. To be added. @@ -1333,7 +1373,7 @@ The hash value of the data to be verified. The digital signature of the data to be verified against the hash value. - Verifies the specified digital signature against a specified hash value. + Verifies that a digital signature is appropriate for the current key and provided data hash. if the signature is valid; otherwise, . To be added. @@ -1364,10 +1404,11 @@ - To be added. - To be added. - To be added. - To be added. + The hash value of the data to be verified. + The digital signature of the data to be verified against the hash value. + Verifies that a digital signature is appropriate for the current key and provided data hash. + + if the signature is valid; otherwise, . To be added. diff --git a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml index 74ea92639b5..68c0b79bc7d 100644 --- a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml +++ b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml @@ -17,8 +17,16 @@ - To be added. - To be added. + Provides an implementation of the Elliptic Curve Digital Signature Algorithm (ECDSA) backed by OpenSSL. + + factory methods instead of a specific derived implementation. + + ]]> + @@ -37,8 +45,20 @@ - To be added. - To be added. + Initializes a new instance of the class. + + property to 521 and when a key is needed the saved size is used to identify the target curve. +If a key is loaded via the method, or other key import method, the key size from this constructor has no meaning. + + + ]]> + + @@ -60,9 +80,23 @@ - To be added. - To be added. - To be added. + The size of the key. Valid key sizes are 256, 384, and 521 bits. + Initializes a new instance of the class with a specified target key size. + + property to the provided value and when a key is needed the saved size is used to identify the target curve. +If a key is loaded via the method, or other key import method, the key size from this constructor has no meaning. + + + ]]> + + + specifies an invalid length. + @@ -84,9 +118,23 @@ - To be added. - To be added. - To be added. + The OpenSSL EC_KEY* value to use as the key. + Initializes a new instance of the class from an existing OpenSSL key represented as an EC_KEY*. + + [!IMPORTANT] +> OpenSSL supports multiple library versions being loaded within the same process. +> Before calling this constructor verify your pointer value came from the same version of OpenSSL that this class uses, see for more information. + + ]]> + + + is . + + is not a valid EC_KEY*. + @@ -108,9 +156,12 @@ - To be added. - To be added. + The curve used to generate an ephemeral public/private key pair. + Initializes a new instance of the class and generates a new key on the specified curve. To be added. + + does not validate. + @@ -132,9 +183,26 @@ - To be added. - To be added. - To be added. + The OpenSSL EVP_PKEY* value to use as the key, represented as a . + Initializes a new instance of the class from an existing OpenSSL key represented as an EVP_PKEY*. + + [!IMPORTANT] +> OpenSSL supports multiple library versions being loaded within the same process. +> Before calling this constructor, verify your pointer value came from the same version of OpenSSL that this class uses. +> For more information, see . + + ]]> + + + represents an invalid handle. + + is . + + does not represent a elliptic curve (EC) key. + @@ -159,8 +227,9 @@ - To be added. - To be added. + + to release managed and unmanaged resources; to release only unmanaged resources. + Releases the resources used by the current instance of the class. To be added. @@ -184,9 +253,17 @@ - To be added. - To be added. - To be added. + Gets a representation of the cryptographic key. + A representation of the cryptographic key. + + object with its own lifetime. +The objects returned by this method can safely be used even after this instance has been disposed. + +]]> + @@ -211,10 +288,12 @@ - To be added. - To be added. - To be added. + + to include private parameters; otherwise, . + Exports the key and explicit curve parameters used by the Elliptic curve cryptography (ECC) object into an object. + The key and explicit curve parameters used by the ECC object. To be added. + An error occurred while obtaining the curve values. @@ -239,10 +318,12 @@ - To be added. - To be added. - To be added. + + to include private parameters; otherwise, . + Exports the key used by the Elliptic curve cryptography (ECC) object into an object. If the key was created as a named curve, the field contains named curve parameters; otherwise, it contains explicit parameters. + The key and named curve parameters used by the ECC object. To be added. + An error occurred while obtaining the curve values. @@ -267,8 +348,8 @@ - To be added. - To be added. + The curve to use to generate the key. + Generates a new ephemeral public/private key pair for the specified curve, replacing the current key. To be added. @@ -295,10 +376,10 @@ - To be added. - To be added. - To be added. - To be added. + The binary stream to hash. + The algorithm to use to hash the data. + Computes the hash value of the specified binary stream by using the specified hashing algorithm. + The hashed data. To be added. @@ -327,12 +408,12 @@ - To be added. - To be added. - To be added. - To be added. - To be added. - To be added. + The data to be hashed. + The index of the first byte in to be hashed. + The number of bytes to hash. + The algorithm to use to hash the data. + Computes the hash value of the specified portion of a byte array by using the specified hashing algorithm. + The hashed data. To be added. @@ -358,9 +439,18 @@ - To be added. - To be added. - To be added. + The curve parameters. + Replaces the current key for this instance with one using the specified key parameters. + + , only a public key is imported. If `parameters` also contains , a full key pair is imported. The field specifies the type of the curve to import. + + ]]> + + + does not contain valid values. @@ -382,9 +472,23 @@ System.Int32 - To be added. - To be added. - To be added. + Gets or sets the size, in bits, of the key modulus used by the asymmetric algorithm. + The size, in bits, of the key modulus used by the asymmetric algorithm. + + method. + +]]> + + + is not permitted by . + @@ -406,9 +510,22 @@ System.Security.Cryptography.KeySizes[] - To be added. - To be added. - To be added. + Gets the key sizes, in bits, that are supported by the property setter. + An array that contains the key sizes supported by the property setter. + + + + @@ -433,10 +550,11 @@ - To be added. - To be added. - To be added. + The hash value of the data that is being signed. + Generates a digital signature for the specified hash value. + A digital signature for the specified hash value. To be added. + The parameter is . @@ -462,11 +580,13 @@ - To be added. - To be added. - To be added. - To be added. + The hash value of the data to be verified. + The digital signature of the data to be verified against the hash value. + Verifies that a digital signature is appropriate for the current key and provided data hash. + + if the signature is valid; otherwise, . To be added. + or is . From f6e3ccf5c41af822e1adbbdfa4e234436fe33f60 Mon Sep 17 00:00:00 2001 From: Jeremy Barton Date: Tue, 26 Nov 2019 07:46:29 -0800 Subject: [PATCH 2/3] Address feedback --- xml/System.Security.Cryptography/ECDsa.xml | 2 +- xml/System.Security.Cryptography/ECDsaCng.xml | 4 ++-- xml/System.Security.Cryptography/ECDsaOpenSsl.xml | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xml/System.Security.Cryptography/ECDsa.xml b/xml/System.Security.Cryptography/ECDsa.xml index cafee736dd6..9ca4224c25f 100644 --- a/xml/System.Security.Cryptography/ECDsa.xml +++ b/xml/System.Security.Cryptography/ECDsa.xml @@ -1443,7 +1443,7 @@ The algorithm-specific key import failed. ## Remarks -The default implementation of this method is to call and copy the result to `destination`. +The default implementation of this method is to call and copy the result to `destination`. Derived types should override this method to avoid the intermediate array creation. ]]> diff --git a/xml/System.Security.Cryptography/ECDsaCng.xml b/xml/System.Security.Cryptography/ECDsaCng.xml index d65bd7b1f55..85ed8b79600 100644 --- a/xml/System.Security.Cryptography/ECDsaCng.xml +++ b/xml/System.Security.Cryptography/ECDsaCng.xml @@ -155,7 +155,7 @@ If a key is loaded via the Cryptography Next Generation (CNG) classes are not supported on this system. specifies an invalid length. - + @@ -773,7 +773,7 @@ Because key sizes do not uniquely identify elliptic curves, the use of the prope In Elliptic Curve Cryptography (ECC) the key size is not the only input into the key generation process, it is derived from the curve parameters for a specific elliptic curve. -This property reports only three sizes for LegalKeySizes: 256, 384, and 521 bits. +This property reports only three legal key sizes: 256, 384, and 521 bits. When the key size is used alone as a basis for key generation, the supported sizes map to the named curves secp256r1 (aka NIST P-256), secp384r1 (aka NIST P-384), and secp521r1 (aka NIST P-521). diff --git a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml index 68c0b79bc7d..c32e4b716a8 100644 --- a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml +++ b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml @@ -58,7 +58,7 @@ If a key is loaded via the - + @@ -96,7 +96,7 @@ If a key is loaded via the specifies an invalid length. - + @@ -519,7 +519,7 @@ Because key sizes do not uniquely identify elliptic curves, the use of the prope In Elliptic Curve Cryptography (ECC) the key size is not the only input into the key generation process, it is derived from the curve parameters for a specific elliptic curve. -This property reports only three sizes for LegalKeySizes: 256, 384, and 521 bits. +This property reports only three legal key sizes: 256, 384, and 521 bits. When the key size is used alone as a basis for key generation, the supported sizes map to the named curves secp256r1 (aka NIST P-256), secp384r1 (aka NIST P-384), and secp521r1 (aka NIST P-521). From a394c1f48cf2f7f2cff8fade38ce32ccccaf5c7d Mon Sep 17 00:00:00 2001 From: Jeremy Barton Date: Tue, 26 Nov 2019 08:30:20 -0800 Subject: [PATCH 3/3] Fix another warning --- xml/System.Security.Cryptography/ECDsaOpenSsl.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml index c32e4b716a8..3e5fa7401ce 100644 --- a/xml/System.Security.Cryptography/ECDsaOpenSsl.xml +++ b/xml/System.Security.Cryptography/ECDsaOpenSsl.xml @@ -58,7 +58,7 @@ If a key is loaded via the - +