From a9a0944394a0af392d7c14cfffdb17d4efddc115 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 4 Jun 2025 09:35:37 -0700 Subject: [PATCH 1/2] delete C++ snippet refs from System.Security --- xml/System.Resources/ResXResourceReader.xml | 5 - xml/System.Resources/ResourceReader.xml | 1 - xml/System.Resources/ResourceSet.xml | 185 ++- xml/System.Resources/ResourceWriter.xml | 7 - .../InternalsVisibleToAttribute.xml | 6 +- .../ReliabilityContractAttribute.xml | 41 +- .../SerializationInfo.xml | 473 ++++---- .../DirectorySecurity.xml | 1 - .../RegistryRights.xml | 31 +- .../OpenFlags.xml | 23 +- .../PublicKey.xml | 96 +- .../StoreLocation.xml | 19 +- .../X509BasicConstraintsExtension.xml | 133 +-- .../X509Certificate.xml | 27 - .../X509Certificate2.xml | 1060 ++++++++--------- .../X509Certificate2Collection.xml | 455 ++++--- .../X509Certificate2UI.xml | 113 +- .../X509Chain.xml | 222 ++-- .../X509ChainElement.xml | 68 +- .../X509ChainElementCollection.xml | 117 +- .../X509ChainPolicy.xml | 208 ++-- .../X509ChainStatus.xml | 73 +- .../X509EnhancedKeyUsageExtension.xml | 73 +- .../X509Extension.xml | 197 ++- .../X509FindType.xml | 27 +- .../X509KeyUsageExtension.xml | 60 +- .../X509NameType.xml | 23 +- .../X509RevocationFlag.xml | 23 +- .../X509RevocationMode.xml | 27 +- .../X509SelectionFlag.xml | 23 +- .../X509Store.xml | 552 +++++---- .../X509SubjectKeyIdentifierExtension.xml | 68 +- .../X509VerificationFlags.xml | 23 +- .../CipherData.xml | 7 - .../CipherReference.xml | 5 - .../DSAKeyValue.xml | 104 +- .../DataObject.xml | 188 ++- .../EncryptedReference.xml | 116 +- .../EncryptedXml.xml | 41 - .../EncryptionMethod.xml | 132 +- .../IRelDecryptor.xml | 33 +- .../KeyInfo.xml | 168 ++- .../KeyInfoEncryptedKey.xml | 73 +- .../KeyInfoName.xml | 182 ++- .../KeyInfoX509Data.xml | 196 ++- .../RSAKeyValue.xml | 60 +- .../Reference.xml | 7 - .../Signature.xml | 204 ++-- .../SignedXml.xml | 38 - .../XmlDsigBase64Transform.xml | 183 ++- .../XmlDsigC14NTransform.xml | 221 ++-- .../XmlDsigC14NWithCommentsTransform.xml | 84 +- .../XmlDsigEnvelopedSignatureTransform.xml | 228 ++-- .../XmlDsigExcC14NTransform.xml | 174 ++- .../XmlDsigExcC14NWithCommentsTransform.xml | 49 +- .../XmlDsigXPathTransform.xml | 253 ++-- .../XmlDsigXsltTransform.xml | 221 ++-- .../XmlLicenseTransform.xml | 110 +- .../AsnEncodedData.xml | 9 - .../AsnEncodedDataCollection.xml | 240 ++-- .../AsnEncodedDataEnumerator.xml | 114 +- .../AsymmetricAlgorithm.xml | 1055 ++++++++-------- .../CryptoConfig.xml | 5 - .../CryptographicException.xml | 220 ++-- .../CspKeyContainerInfo.xml | 312 +++-- .../CspParameters.xml | 6 - xml/System.Security.Cryptography/DES.xml | 116 +- .../DESCryptoServiceProvider.xml | 182 ++- .../DSASignatureDeformatter.xml | 58 +- .../DSASignatureFormatter.xml | 68 +- .../DataProtectionScope.xml | 27 +- .../FromBase64Transform.xml | 4 - .../HMACSHA256.xml | 1 - .../HMACSHA384.xml | 1 - .../HMACSHA512.xml | 1 - .../HashAlgorithm.xml | 1 - .../KeyNumber.xml | 19 +- xml/System.Security.Cryptography/KeySizes.xml | 73 +- .../KeyedHashAlgorithm.xml | 1 - .../MaskGenerationMethod.xml | 41 +- xml/System.Security.Cryptography/Oid.xml | 123 +- .../OidCollection.xml | 251 ++-- .../OidEnumerator.xml | 114 +- .../PasswordDeriveBytes.xml | 4 - .../ProtectedData.xml | 79 +- xml/System.Security.Cryptography/RC2.xml | 2 - .../RC2CryptoServiceProvider.xml | 221 ++-- .../RNGCryptoServiceProvider.xml | 110 +- .../RSACryptoServiceProvider.xml | 19 - .../RSAOAEPKeyExchangeDeformatter.xml | 89 +- .../RSAOAEPKeyExchangeFormatter.xml | 154 ++- .../RandomNumberGenerator.xml | 158 ++- .../Rfc2898DeriveBytes.xml | 6 - .../RijndaelManaged.xml | 230 ++-- xml/System.Security.Cryptography/SHA256.xml | 1 - .../SHA256Managed.xml | 1 - xml/System.Security.Cryptography/SHA384.xml | 1 - .../SHA384Managed.xml | 1 - xml/System.Security.Cryptography/SHA512.xml | 1 - .../SHA512Managed.xml | 1 - .../SymmetricAlgorithm.xml | 2 - .../ToBase64Transform.xml | 8 - .../TripleDES.xml | 139 ++- .../AllowPartiallyTrustedCallersAttribute.xml | 127 +- xml/System.Security/ISecurityEncodable.xml | 77 +- xml/System.Security/SecureString.xml | 11 - xml/System.Security/SecurityElement.xml | 582 +++++---- 107 files changed, 6013 insertions(+), 6590 deletions(-) diff --git a/xml/System.Resources/ResXResourceReader.xml b/xml/System.Resources/ResXResourceReader.xml index 21ebbb29181..194719bfe4e 100644 --- a/xml/System.Resources/ResXResourceReader.xml +++ b/xml/System.Resources/ResXResourceReader.xml @@ -82,7 +82,6 @@ ## Examples The following example demonstrates how to use a to iterate through the resources in a .resx file. First, the `rsxr` is created for the file `items.resx`. Next, the method is used to create an to iterate through the resources and display the contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -219,7 +218,6 @@ ## Examples The following example creates a new instance of the class for the specified file, iterates through the resources of the file, and displays the contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -552,7 +550,6 @@ ## Examples The following example displays the resources of a file to the console, and then uses the method to shut down the reader and to make its resources available for other processes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/resxresourcereader.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/resxresourcereader.vb" id="Snippet1"::: @@ -845,7 +842,6 @@ ## Examples The following example uses the method to iterate through the metadata resources in an XML resource file. This code example is part of a larger example provided for the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/useresxdatanodes.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/useresxdatanodes.vb" id="Snippet4"::: @@ -982,7 +978,6 @@ ## Examples The following example enumerates and displays resource items in an XML file. Initially, is set to `false` to show both data and metadata items as they occur in the resource file. The second enumeration has the set to `true` so that resource data elements are returned as objects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResXResourceReader/Overview/useresxdatanodes.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/VB/useresxdatanodes.vb" id="Snippet2"::: diff --git a/xml/System.Resources/ResourceReader.xml b/xml/System.Resources/ResourceReader.xml index 0e46d4666de..ba681d3c935 100644 --- a/xml/System.Resources/ResourceReader.xml +++ b/xml/System.Resources/ResourceReader.xml @@ -368,7 +368,6 @@ Label11="Mobile Phone:" ## Examples The following example moves through a file's resources and displays all the key/value pairs it finds. The code then uses the method to shut down the and to release all resources used by it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceReader/Close/getenumerator.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/VB/getenumerator.vb" id="Snippet1"::: diff --git a/xml/System.Resources/ResourceSet.xml b/xml/System.Resources/ResourceSet.xml index 9b9c6ae70ad..8ecc36a0206 100644 --- a/xml/System.Resources/ResourceSet.xml +++ b/xml/System.Resources/ResourceSet.xml @@ -76,19 +76,19 @@ Stores all the resources localized for one particular culture, ignoring all other cultures, including any fallback rules. - class enumerates over an , loading every name and value, and storing them in a . A custom can be used. - - You can instantiate a object that represents the resources of a specific culture by calling the method. - + The class enumerates over an , loading every name and value, and storing them in a . A custom can be used. + + You can instantiate a object that represents the resources of a specific culture by calling the method. + > [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + ]]> @@ -240,11 +240,11 @@ The reader that will be used. Creates a new instance of the class using the specified resource reader. - . - + . + ]]> The parameter is . @@ -298,15 +298,14 @@ Resource file to read. Creates a new instance of the class using the system default that opens and reads resources from the given file. - class for a specific file, iterates through the resources used by that file, and displays their contents to the console. + class for a specific file, iterates through the resources used by that file, and displays their contents to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> The parameter is . @@ -354,25 +353,24 @@ Closes and releases any resources used by this . - after a call to this method might fail. - - can be safely called multiple times. - + after a call to this method might fail. + + can be safely called multiple times. + > [!NOTE] -> The current implementation of calls (`true`). - - - -## Examples - The following code example uses the method to release all resources used by the calling instance. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: +> The current implementation of calls (`true`). + + + +## Examples + The following code example uses the method to release all resources used by the calling instance. + :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> @@ -432,14 +430,14 @@ Disposes of the resources (other than memory) used by the current instance of . - when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. - + when you are finished using the . The method leaves the in an unusable state. After calling , you must release all references to the so the memory it was occupying can be reclaimed by garbage collection. + > [!NOTE] -> The current method is the implementation of . This implementation calls (`true`). - +> The current method is the implementation of . This implementation calls (`true`). + ]]> @@ -489,11 +487,11 @@ Indicates whether the objects contained in the current instance should be explicitly closed. Releases resources (other than memory) associated with the current instance, closing internal managed objects if requested. - @@ -645,32 +643,31 @@ Returns an that can iterate through the . An for this . - also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . - - returns the same object until either or is called. sets to the next element. - - After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . - - An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , will return the element that it is set to, even if the enumerator is already invalidated. - - You can use the property to access the value stored in the current element. Use the property to access the key of the current element. Use the property to access the value of the current element. - - The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. - - - -## Examples - The following example demonstrates how to create a `rs` for the file `items.resources`. Next, the method is used to create an for `rs`. The iterates through `rs` and displays the contents to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp" id="Snippet1"::: + also brings the enumerator back to this position. At this position, calling throws an exception. Therefore, you must call to advance the enumerator to the first element of the collection before reading the value of . + + returns the same object until either or is called. sets to the next element. + + After the end of the collection is passed, the enumerator is positioned after the last element in the collection, and calling returns `false`. If the last call to returned `false`, calling throws an exception. To set to the first element of the collection again, you can call followed by . + + An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying or deleting elements, the enumerator is irrecoverably invalidated and the next call to or throws an . If the collection is modified between and , will return the element that it is set to, even if the enumerator is already invalidated. + + You can use the property to access the value stored in the current element. Use the property to access the key of the current element. Use the property to access the value of the current element. + + The enumerator does not have exclusive access to the collection; therefore, enumerating through a collection is intrinsically not a thread-safe procedure. Even when a collection is synchronized, other threads could still modify the collection, which causes the enumerator to throw an exception. To guarantee thread safety during enumeration, you can either lock the collection during the entire enumeration or catch the exceptions resulting from changes made by other threads. + + + +## Examples + The following example demonstrates how to create a `rs` for the file `items.resources`. Next, the method is used to create an for `rs`. The iterates through `rs` and displays the contents to the console. + :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceSet/.ctor/getenumerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/VB/getenumerator.vb" id="Snippet1"::: + ]]> The resource set has been closed or disposed. @@ -739,11 +736,11 @@ Searches for a resource object with the specified name. The requested resource. - . - + . + ]]> The parameter is . @@ -805,13 +802,13 @@ Searches for a resource object with the specified name in a case-insensitive manner, if requested. The requested resource. - . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. - - For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetObject` method with `ignoreCase` set to `true`, this comparison succeeds. - + . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. + + For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetObject` method with `ignoreCase` set to `true`, this comparison succeeds. + ]]> The parameter is . @@ -941,13 +938,13 @@ Searches for a resource with the specified name in a case-insensitive manner, if requested. The value of a resource, if the value is a . - . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. - - For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetString` method with `ignoreCase` set to `true`, this comparison succeeds. - + . The advantage is that results of case-insensitive string comparisons performed by this method are the same on all computers regardless of culture. The disadvantage is that the results are not consistent with the casing rules of all cultures. + + For example, the Turkish alphabet has two versions of the character I: one with a dot and one without a dot. In Turkish, the character I (Unicode 0049) is considered the uppercase version of a different character ı (Unicode 0131). The character i (Unicode 0069) is considered the lowercase version of yet another character İ (Unicode 0130). According to these casing rules, a case-insensitive string comparison of the characters i (Unicode 0069) and I (Unicode 0049) should fail for the culture "tr-TR" (Turkish in Turkey). Using the `GetString` method with `ignoreCase` set to `true`, this comparison succeeds. + ]]> The parameter is . diff --git a/xml/System.Resources/ResourceWriter.xml b/xml/System.Resources/ResourceWriter.xml index 78382ca1492..9fa96e7f042 100644 --- a/xml/System.Resources/ResourceWriter.xml +++ b/xml/System.Resources/ResourceWriter.xml @@ -93,7 +93,6 @@ ## Examples The following example writes several strings into the myResources.resources file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb" id="Snippet1"::: @@ -162,7 +161,6 @@ ## Examples The following code example defines a new instance of the class that writes to a specified stream. The code adds resources to the writer and writes the resources to the stream. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -223,7 +221,6 @@ ## Examples The following code example defines a new instance of the class that will write to a specified file. The code adds resources to the writer and writes the resources to the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic ResourceWriter Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic ResourceWriter Example/VB/source.vb" id="Snippet1"::: @@ -555,7 +552,6 @@ ## Examples The following example uses the method to add string resources to a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -789,7 +785,6 @@ ## Examples The following example uses the method to write all resource objects in a class to the output stream. The code then shuts down the writer. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/.ctor/resourcewritercstr1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/VB/resourcewritercstr1.vb" id="Snippet1"::: @@ -853,7 +848,6 @@ ## Examples The following code example uses the method to write all resource objects in a class to the output stream. The code then shuts down the writer and make the writer's resources available for other processes. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Dispose/resourcewriterdispose.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/VB/resourcewriterdispose.vb" id="Snippet1"::: @@ -931,7 +925,6 @@ ## Examples The following code example uses the method to write all resource objects in a class to the output stream - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Resources/ResourceWriter/Generate/resourcewritergenerate.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/VB/resourcewritergenerate.vb" id="Snippet1"::: diff --git a/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml b/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml index 80ffe0fd1a3..311a9f21f8a 100644 --- a/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml +++ b/xml/System.Runtime.CompilerServices/InternalsVisibleToAttribute.xml @@ -68,9 +68,8 @@ The following example uses the @@ -170,7 +168,6 @@ The following example provides the source code for the `Friend2` assembly. Note If the following example is compiled into a strong-named assembly named `Friend1`, it can successfully call the `FileUtilities.AppendDirectorySeparator` method, even though the method is internal to the `Assembly1` assembly. Note that if you are compiling in C# from the command line, you must use the **/out** compiler switch to ensure that the name of the friend assembly is available when the compiler binds to external references. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/vb/friend1.vb" id="Snippet2"::: @@ -183,7 +180,6 @@ The following example provides the source code for the `Friend2` assembly. Note The following example provides the source code for the `Friend2` assembly. Note that if you are compiling in C# from the command line, you must use the **/out** compiler switch to ensure that the name of the friend assembly is available when the compiler binds to external references. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.CompilerServices/InternalsVisibleToAttribute/Overview/friend2.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/vb/friend2.vb" id="Snippet6"::: diff --git a/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml b/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml index 8181c8fcbfa..dada4b41779 100644 --- a/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml +++ b/xml/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute.xml @@ -53,22 +53,21 @@ Defines a contract for reliability between the author of some code, and the developers who have a dependency on that code. - attribute provides a mechanism for you to document your code, and to indicate what type of reliability guarantees you can make in the face of exceptional conditions that could potentially lead to an inconsistent state. In this context, exceptional conditions are defined as asynchronous exceptions that can be generated at run time by the common language runtime, such as aborted threads, out-of-memory situations, and stack overflows. You can apply the attribute to assemblies, types, and methods. + + Use this attribute with the enumeration to define a reliability contract by documenting the level of reliability in a particular piece of code. + + + +## Examples + The following code example demonstrates the use of the attribute to document the level of reliability of an assembly. -## Remarks - The attribute provides a mechanism for you to document your code, and to indicate what type of reliability guarantees you can make in the face of exceptional conditions that could potentially lead to an inconsistent state. In this context, exceptional conditions are defined as asynchronous exceptions that can be generated at run time by the common language runtime, such as aborted threads, out-of-memory situations, and stack overflows. You can apply the attribute to assemblies, types, and methods. - - Use this attribute with the enumeration to define a reliability contract by documenting the level of reliability in a particular piece of code. - - - -## Examples - The following code example demonstrates the use of the attribute to document the level of reliability of an assembly. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/cpp/FxCop.Reliability.ReliabilityContract.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.ConstrainedExecution/ReliabilityContractAttribute/ReliabilityContract.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/vb/FxCop.Reliability.ReliabilityContract.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CodeAnalysis/FxCop.Reliability.ReliabilityContract/vb/FxCop.Reliability.ReliabilityContract.vb" id="Snippet1"::: + ]]> @@ -117,14 +116,14 @@ One of the values. Initializes a new instance of the class with the specified guarantee and value. - constructor to create a constrained execution region and a `finally` block that is guaranteed to execute. - + constructor to create a constrained execution region and a `finally` block that is guaranteed to execute. + :::code language="csharp" source="~/snippets/csharp/System.Runtime.ConstrainedExecution/Cer/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.ConstrainedExecution/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Runtime.ConstrainedExecution/vb/program.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Runtime.Serialization/SerializationInfo.xml b/xml/System.Runtime.Serialization/SerializationInfo.xml index d98ac12df07..e89b55a361f 100644 --- a/xml/System.Runtime.Serialization/SerializationInfo.xml +++ b/xml/System.Runtime.Serialization/SerializationInfo.xml @@ -69,15 +69,15 @@ Stores all the data needed to serialize or deserialize an object. This class cannot be inherited. - method on either or populates the store with the name, type, and value of each piece of information it wants to serialize. During deserialization, the appropriate function can extract this information. - - Objects are added to the store at serialization time using the methods and extracted from the store at deserialization using the methods. - + method on either or populates the store with the name, type, and value of each piece of information it wants to serialize. During deserialization, the appropriate function can extract this information. + + Objects are added to the store at serialization time using the methods and extracted from the store at deserialization using the methods. + For more information about customizing serialization, see [Custom Serialization](/dotnet/standard/serialization/custom-serialization). - + ]]> @@ -151,11 +151,11 @@ The used during deserialization. Creates a new instance of the class. - passed as the `converter` parameter converts data from its internal representation to the form the user requested. The internal representation of the data within the depends on the formatter that created it. - + passed as the `converter` parameter converts data from its internal representation to the form the user requested. The internal representation of the data within the depends on the formatter that created it. + ]]> @@ -278,35 +278,35 @@ The Boolean value to serialize. Adds a Boolean value into the store. - to be thrown. For example: - -```csharp -void ISerializable.GetObject(SerializationInfo info, StreamingContext context) -{ - // This will not cause an exception to be thrown. - info.AddValue("ABC", true); - info.AddValue("abc", false); - // However, this will cause the SerializationException to be thrown. - info.AddValue("XYZ", true); - info.AddValue("XYZ", false); -} -``` - -```vb -Private Sub GetObjectData(ByVal info As SerializationInfo, _ -ByVal context As StreamingContext) - ' This will not cause an exception to be thrown. - info.AddValue("ABC", "upper case") - info.AddValue("abc", "lower case") - ' However, this will cause the SerializationException to be thrown. - info.AddValue("XYZ", "same case") - info.AddValue("XYZ", "same case") -End Sub -``` - + to be thrown. For example: + +```csharp +void ISerializable.GetObject(SerializationInfo info, StreamingContext context) +{ + // This will not cause an exception to be thrown. + info.AddValue("ABC", true); + info.AddValue("abc", false); + // However, this will cause the SerializationException to be thrown. + info.AddValue("XYZ", true); + info.AddValue("XYZ", false); +} +``` + +```vb +Private Sub GetObjectData(ByVal info As SerializationInfo, _ +ByVal context As StreamingContext) + ' This will not cause an exception to be thrown. + info.AddValue("ABC", "upper case") + info.AddValue("abc", "lower case") + ' However, this will cause the SerializationException to be thrown. + info.AddValue("XYZ", "same case") + info.AddValue("XYZ", "same case") +End Sub +``` + ]]> The parameter is . @@ -362,11 +362,11 @@ End Sub The byte value to serialize. Adds an 8-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -422,11 +422,11 @@ End Sub The character value to serialize. Adds a Unicode character value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -482,11 +482,11 @@ End Sub The value to serialize. Adds a value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -542,11 +542,11 @@ End Sub The decimal value to serialize. Adds a decimal value into the store. - to be thrown. - + to be thrown. + ]]> If The parameter is . @@ -602,11 +602,11 @@ End Sub The double value to serialize. Adds a double-precision floating-point value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -662,11 +662,11 @@ End Sub The value to serialize. Adds a 16-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -722,11 +722,11 @@ End Sub The value to serialize. Adds a 32-bit signed integer value into the store. - to be thrown. - + ]]> The parameter is . @@ -782,11 +782,11 @@ End Sub The Int64 value to serialize. Adds a 64-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -850,13 +850,13 @@ End Sub The value to be serialized. Any children of this object will automatically be serialized. Adds the specified object into the store, where it is associated with a specified name. - to be thrown. - + to be thrown. + ]]> @@ -919,11 +919,11 @@ End Sub The value to serialize. Adds an 8-bit signed integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -979,11 +979,11 @@ End Sub The single value to serialize. Adds a single-precision floating-point value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1045,11 +1045,11 @@ End Sub The value to serialize. Adds a 16-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1111,11 +1111,11 @@ End Sub The value to serialize. Adds a 32-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1177,11 +1177,11 @@ End Sub The value to serialize. Adds a 64-bit unsigned integer value into the store. - to be thrown. - + to be thrown. + ]]> The parameter is . @@ -1247,13 +1247,13 @@ End Sub The to associate with the current object. This parameter must always be the type of the object itself or of one of its base classes. Adds a value into the store, where is associated with and is serialized as being of . - to be thrown. - + to be thrown. + ]]> If or is . @@ -1310,18 +1310,18 @@ End Sub Gets or sets the assembly name of the type to serialize during serialization only. The full name of the assembly of the type to serialize. - is the same as the value returned by property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object. - - The assembly name contains the name of the assembly, version, culture, and some security information about the object. - - Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property. - + is the same as the value returned by property of the assembly of the containing type. This is the assembly name that the formatter uses when serializing type information for this object. + + The assembly name contains the name of the assembly, version, culture, and some security information about the object. + + Users who are changing the type being serialized (for example, to send a proxy for a particular type) will set the value of this property. + > [!CAUTION] -> Do not use this property during deserialization because the value of this property is undefined. - +> Do not use this property during deserialization because the value of this property is undefined. + ]]> The value the property is set to is . @@ -1371,16 +1371,16 @@ End Sub Gets or sets the full name of the to serialize. The full name of the type to serialize. - is the same as what would be returned by calling the on . This is the type name the formatter uses when serializing type information for this object. - - Users who are changing the type to serialize (for example, to send a proxy for a particular type) will want to set the value of this property. - + is the same as what would be returned by calling the on . This is the type name the formatter uses when serializing type information for this object. + + Users who are changing the type to serialize (for example, to send a proxy for a particular type) will want to set the value of this property. + > [!CAUTION] -> Do not use this property during deserialization because the value of this property is undefined. - +> Do not use this property during deserialization because the value of this property is undefined. + ]]> The value this property is set to is . @@ -1434,11 +1434,11 @@ End Sub Retrieves a Boolean value from the store. The Boolean value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1495,11 +1495,11 @@ End Sub Retrieves an 8-bit unsigned integer value from the store. The 8-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1556,11 +1556,11 @@ End Sub Retrieves a Unicode character value from the store. The Unicode character associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1617,11 +1617,11 @@ End Sub Retrieves a value from the store. The value associated with . - , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . - + , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . + ]]> @@ -1678,11 +1678,11 @@ End Sub Retrieves a decimal value from the store. A decimal value from the . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1739,11 +1739,11 @@ End Sub Retrieves a double-precision floating-point value from the store. The double-precision floating-point value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1797,11 +1797,11 @@ End Sub Returns a used to iterate through the name-value pairs in the store. A for parsing the name-value pairs contained in the store. - @@ -1854,11 +1854,11 @@ End Sub Retrieves a 16-bit signed integer value from the store. The 16-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -1915,11 +1915,11 @@ End Sub Retrieves a 32-bit signed integer value from the store. The 32-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + ]]> @@ -1976,11 +1976,11 @@ End Sub Retrieves a 64-bit signed integer value from the store. The 64-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2043,11 +2043,11 @@ End Sub Retrieves an 8-bit signed integer value from the store. The 8-bit signed integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2104,11 +2104,11 @@ End Sub Retrieves a single-precision floating-point value from the store. The single-precision floating-point value associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2172,11 +2172,11 @@ End Sub Retrieves a value from the store. The associated with . - , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . - + , or can be converted to a , that value is returned; otherwise, a is thrown. All conversions are done by the associated with this . + ]]> @@ -2239,11 +2239,11 @@ End Sub Retrieves a 16-bit unsigned integer value from the store. The 16-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2306,11 +2306,11 @@ End Sub Retrieves a 32-bit unsigned integer value from the store. The 32-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2373,11 +2373,11 @@ End Sub Retrieves a 64-bit unsigned integer value from the store. The 64-bit unsigned integer associated with . - is thrown. All conversions are done by the associated with this . - + is thrown. All conversions are done by the associated with this . + ]]> @@ -2449,22 +2449,21 @@ End Sub Retrieves a value from the store. The object of the specified associated with . - is of the type requested (or one of its derived classes), that value is returned directly. Otherwise, is called to convert it to the appropriate type. + is of the type requested (or one of its derived classes), that value is returned directly. Otherwise, is called to convert it to the appropriate type. + + The value returned by the method can always be safely cast to the type specified in the `type` parameter. + + + +## Examples + The following code example demonstrates the use of the method: - The value returned by the method can always be safely cast to the type specified in the `type` parameter. - - - -## Examples - The following code example demonstrates the use of the method: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Runtime.Serialization/SerializationInfo/GetValue/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_Remoting/Classic SerializationInfo.GetValue Example/VB/source.vb" id="Snippet1"::: + ]]> @@ -2702,11 +2701,11 @@ End Sub The of the object to serialize. Sets the of the object to serialize. - is responsible for setting the of the instance before passing it to . However, users who want to send proxies for their objects will need to change the type represented by this instance. Using the method is equivalent to setting both the and the . - + ]]> The parameter is . diff --git a/xml/System.Security.AccessControl/DirectorySecurity.xml b/xml/System.Security.AccessControl/DirectorySecurity.xml index 1355f88a786..928ee9b10e1 100644 --- a/xml/System.Security.AccessControl/DirectorySecurity.xml +++ b/xml/System.Security.AccessControl/DirectorySecurity.xml @@ -60,7 +60,6 @@ ## Examples The following code example uses the class to add and then remove an access control list (ACL) entry from a directory. You must supply a valid user or group account to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.IO/DirectoryInfo/GetAccessControl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/IO.DiretoryInfo.GetAccessControl-SetAccessControl/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.AccessControl/RegistryRights.xml b/xml/System.Security.AccessControl/RegistryRights.xml index 6549c403548..49f5fd7735b 100644 --- a/xml/System.Security.AccessControl/RegistryRights.xml +++ b/xml/System.Security.AccessControl/RegistryRights.xml @@ -36,24 +36,23 @@ Specifies the access control rights that can be applied to registry objects. - enumeration to specify registry access rights when you create objects. To apply access rights to a registry key, first add objects to a object, then attach the object to the key using the method, or an appropriate overload of the method. + + + +## Examples + The following code example demonstrates the use of the enumeration. The code creates a test key, allowing the current user ReadKey and Delete access rights but denying ChangePermissions and WriteKey rights. Subsequent attempts to manipulate the key succeed or fail depending on these permissions. + + Before the key is deleted, the code pauses. You can switch to the Registry Editor (Regedit.exe or Regedt32.exe) and verify that the same access rights apply when the key is accessed using the Registry Editor. + + This example works best if you use **RunAs** from the command line to run the Registry Editor and the sample code as a local user without administrator rights. For example, if you have defined a local user named TestUser, the command `runas /user:TestUser cmd` opens a command window from which you can run the Registry Editor and then the example code. -## Remarks - Use the enumeration to specify registry access rights when you create objects. To apply access rights to a registry key, first add objects to a object, then attach the object to the key using the method, or an appropriate overload of the method. - - - -## Examples - The following code example demonstrates the use of the enumeration. The code creates a test key, allowing the current user ReadKey and Delete access rights but denying ChangePermissions and WriteKey rights. Subsequent attempts to manipulate the key succeed or fail depending on these permissions. - - Before the key is deleted, the code pauses. You can switch to the Registry Editor (Regedit.exe or Regedt32.exe) and verify that the same access rights apply when the key is accessed using the Registry Editor. - - This example works best if you use **RunAs** from the command line to run the Registry Editor and the sample code as a local user without administrator rights. For example, if you have defined a local user named TestUser, the command `runas /user:TestUser cmd` opens a command window from which you can run the Registry Editor and then the example code. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RegistrySecurity101/cpp/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/Microsoft.Win32/RegistryKey/SetAccessControl/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RegistrySecurity101/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RegistrySecurity101/VB/source.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml b/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml index 1651f06366a..88f96c12f83 100644 --- a/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml +++ b/xml/System.Security.Cryptography.X509Certificates/OpenFlags.xml @@ -58,20 +58,19 @@ Specifies the way to open the X.509 certificate store. - permission to be granted. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. -## Remarks - The `ReadOnly`, `ReadWrite`, and `MaxAllowed` flags are mutually exclusive. The `OpenExistingOnly` flag is the only flag that does not require the permission to be granted. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml b/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml index 6fb9149874b..c2b4c6119c2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml +++ b/xml/System.Security.Cryptography.X509Certificates/PublicKey.xml @@ -59,25 +59,24 @@ Represents a certificate's public key information. This class cannot be inherited. - object contains the object identifier () representing the public key algorithm, the ASN-encoded parameters, and the ASN.1-encoded key value. - - - -## Examples - The following example demonstrates how to use the public key from a object to encrypt a file. It also shows how to decrypt the encrypted file using the private key for that certificate. - + object contains the object identifier () representing the public key algorithm, the ASN-encoded parameters, and the ASN.1-encoded key value. + + + +## Examples + The following example demonstrates how to use the public key from a object to encrypt a file. It also shows how to decrypt the encrypted file using the private key for that certificate. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: - - The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: + + The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -299,15 +298,14 @@ Gets the ASN.1-encoded representation of the public key value. The ASN.1-encoded representation of the public key value. - @@ -687,20 +685,19 @@ Gets an derived object or a derived object representing the public key. An object representing the public key. - and keys are supported. Call this property to obtain a certificate's public key. Repeated calls to this property will return the same key. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, and then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + and keys are supported. Call this property to obtain a certificate's public key. Repeated calls to this property will return the same key. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, and then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key algorithm is not supported. @@ -749,20 +746,19 @@ Gets an object identifier (OID) object of the public key. An object identifier (OID) object of the public key. - diff --git a/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml b/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml index 921e3f40ac3..14019b9bf23 100644 --- a/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml +++ b/xml/System.Security.Cryptography.X509Certificates/StoreLocation.xml @@ -52,22 +52,21 @@ Specifies the location of the X.509 certificate store. - constructor. - - - +This enumeration is used with the constructor. + + + ## Examples -The following example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. +The following example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes you have three certificates to add to and remove from a local store. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: -:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - +:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml index 7ad05a667ad..c2ba652b3fc 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension.xml @@ -59,20 +59,19 @@ Defines the constraints set on a certificate. This class cannot be inherited. - class to display the information. -## Remarks - This class provides properties that define the basic constraints set on a certificate. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -186,11 +184,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -293,20 +291,19 @@ if the certificate is a certificate authority (CA) certificate, otherwise, . - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -357,11 +354,11 @@ The encoded data to use to create the extension. Initializes a new instance of the class using an object. - object. - + object. + ]]> @@ -481,20 +478,19 @@ if the certificate has a restriction on the number of path levels it allows, otherwise, . - property to determine the number of levels allowed. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + property to determine the number of levels allowed. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> The extension cannot be decoded. @@ -543,20 +539,19 @@ Gets the number of levels allowed in a certificate's path. An integer indicating the number of levels allowed in a certificate's path. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml index 9017c372454..e1d9ef167db 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate.xml @@ -112,7 +112,6 @@ ## Examples The following example loads an X.509 certificate from a file, calls the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/VB/example.vb" id="Snippet1"::: @@ -257,7 +256,6 @@ ## Examples The following example loads an X.509 certificate file into an object, exports the certificate as a byte array, and then imports the byte array into another object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/VB/sample.vb" id="Snippet1"::: @@ -489,7 +487,6 @@ ## Examples The following example loads an X.509 certificate from a file, calls the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/VB/example.vb" id="Snippet1"::: @@ -1361,7 +1358,6 @@ ## Examples The following example creates an from a specified certification file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: @@ -1662,7 +1658,6 @@ ## Examples The following example compares two certificates for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Equals/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.Equals Method/VB/example.vb" id="Snippet1"::: @@ -1744,7 +1739,6 @@ ## Examples The following example compares two certificates for equality. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Equals/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.Equals Method/VB/example.vb" id="Snippet1"::: @@ -1830,7 +1824,6 @@ ## Examples The following example loads an X.509 certificate file into an object, exports the certificate as a byte array, and then imports the byte array into another object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/VB/sample.vb" id="Snippet1"::: @@ -2197,7 +2190,6 @@ ## Examples The following example uses the method to fill an array of bytes with the hash value for an X.509 certificate. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetCertHash/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetCertHash Method/VB/example.vb" id="Snippet1"::: @@ -2312,7 +2304,6 @@ ## Examples The following example uses the method to get an X.509 certificate hash value, convert it to a string, and display it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetCertHashString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/VB/example.vb" id="Snippet1"::: @@ -2422,7 +2413,6 @@ ## Examples The following example uses the method to get the effective date of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetEffectiveDateString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/VB/example.vb" id="Snippet1"::: @@ -2488,7 +2478,6 @@ ## Examples The following example uses the method to get the expiration date of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetExpirationDateString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/VB/example.vb" id="Snippet1"::: @@ -2551,7 +2540,6 @@ ## Examples The following example uses the method to get the format of a certificate and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetFormat/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetFormat Method/VB/example.vb" id="Snippet1"::: @@ -2620,7 +2608,6 @@ ## Examples The following example uses the method to return an integer representation of a certificate's hash code and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetHashCode/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetHashCode Method/VB/example.vb" id="Snippet1"::: @@ -2694,7 +2681,6 @@ ## Examples The following example uses the method to return the certificate issuer's name and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetIssuerName/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/VB/example.vb" id="Snippet1"::: @@ -2765,7 +2751,6 @@ ## Examples The following example uses the method to get a certificate's key algorithm in string format and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithm/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/VB/example.vb" id="Snippet1"::: @@ -2831,7 +2816,6 @@ ## Examples The following example uses the method to return a certificate's key algorithm parameters as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithmParameters/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/VB/example.vb" id="Snippet1"::: @@ -2897,7 +2881,6 @@ ## Examples The following example uses the method to return a certificate's key algorithm parameters in string format and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetKeyAlgorithmParametersString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/VB/example.vb" id="Snippet1"::: @@ -2972,7 +2955,6 @@ ## Examples The following example uses the method to return the name of a certificate's principal and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetName/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetName Method/VB/example.vb" id="Snippet1"::: @@ -3039,7 +3021,6 @@ This value corresponds to the contents of the `subjectPublicKey` field of the Su ## Examples The following example uses the method to return a certificate's public key as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetPublicKey/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/VB/example.vb" id="Snippet1"::: @@ -3098,7 +3079,6 @@ This value corresponds to the contents of the `subjectPublicKey` field of the Su ## Examples The following example uses the method to return a certificate's public key as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetPublicKeyString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/VB/example.vb" id="Snippet1"::: @@ -3162,7 +3142,6 @@ The output of this method is equivalent to the output of the method to return a certificate's raw data as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetRawCertData/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/VB/example.vb" id="Snippet1"::: @@ -3218,7 +3197,6 @@ The output of this method is equivalent to the output of the method to return a certificate's raw data as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetRawCertDataString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/VB/example.vb" id="Snippet1"::: @@ -3282,7 +3260,6 @@ The output of this method is equivalent to the output of the method to return a certificate's serial number as an array of bytes and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetSerialNumber/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/VB/example.vb" id="Snippet1"::: @@ -3339,7 +3316,6 @@ The output of this method is equivalent to the output of the method to return a certificate's serial number as a string and displays it to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/GetSerialNumberString/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/VB/example.vb" id="Snippet1"::: @@ -3568,7 +3544,6 @@ The output of this method is equivalent to the output of the method, and displays the results to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/Import/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/VB/sample.vb" id="Snippet1"::: @@ -4301,7 +4276,6 @@ The output of this method is equivalent to the output of the method to display the value of a certificate to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: @@ -4369,7 +4343,6 @@ The output of this method is equivalent to the output of the method to display the value of a certificate to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Certificate/CreateFromCertFile/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/X509Certificate.ToString Method/VB/example.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml index 2008746e8ba..0a601c3f209 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2.xml @@ -64,30 +64,29 @@ Represents an X.509 certificate. - class is designed to model the usage scenarios defined in specifications issued by the Internet Engineering Task Force (IETF) Public Key Infrastructure, X.509 (PKIX) working group. The most informative of these specifications is RFC 3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." - + class is designed to model the usage scenarios defined in specifications issued by the Internet Engineering Task Force (IETF) Public Key Infrastructure, X.509 (PKIX) working group. The most informative of these specifications is RFC 3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." + > [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - - - -## Examples - The following example demonstrates how to use an object to encrypt and decrypt a file. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + + + +## Examples + The following example demonstrates how to use an object to encrypt and decrypt a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: - - The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509certificate2/vb/program.vb" id="Snippet1"::: + + The following example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -156,20 +155,19 @@ Initializes a new instance of the class. - object, unlike the other constructors for this class that use certificate information from a byte array, a pointer, or a certificate file. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, unlike the other constructors for this class that use certificate information from a byte array, a pointer, or a certificate file. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -227,21 +225,21 @@ A byte array containing data from an X.509 certificate. Initializes a new instance of the class using information from a byte array. - object using certificate information from a byte array. The byte array can be binary (DER) encoded or PEM-encoded X.509 data. The byte array can also be a PKCS7 (Authenticode) signed file; the signer certificate is used to create the object. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + object using certificate information from a byte array. The byte array can be binary (DER) encoded or PEM-encoded X.509 data. The byte array can also be a PKCS7 (Authenticode) signed file; the signer certificate is used to create the object. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -294,22 +292,22 @@ A pointer to a certificate context in unmanaged code. The C structure is called . Initializes a new instance of the class using an unmanaged handle. - object using a handle for the Microsoft Cryptographic API certificate context, `PCCERT_CONTEXT`. Note that the immediate caller of this constructor requires unmanaged code permission. - + object using a handle for the Microsoft Cryptographic API certificate context, `PCCERT_CONTEXT`. Note that the immediate caller of this constructor requires unmanaged code permission. + > [!IMPORTANT] -> The constructor creates a copy of the certificate context. Do not assume that the context structure you passed to the constructor is valid; it may have been released. You can get a copy of the current `PCCERT_CONTEXT` structure from the property, but it is valid only during the lifetime of the object. - +> The constructor creates a copy of the certificate context. Do not assume that the context structure you passed to the constructor is valid; it may have been released. You can get a copy of the current `PCCERT_CONTEXT` structure from the property, but it is valid only during the lifetime of the object. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -403,19 +401,19 @@ An object. Initializes a new instance of the class using an object. - class using an object. - + class using an object. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -472,21 +470,21 @@ The name of a certificate file. Initializes a new instance of the class using a certificate file name. - object using a certificate file name. It supports binary (DER) encoding or PEM encoding. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + object using a certificate file name. It supports binary (DER) encoding or PEM encoding. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -555,24 +553,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a byte array and a password. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -639,24 +637,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a byte array and a password. - object using a byte array and a password that is needed to access the certificate data. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. - + object using a byte array and a password that is needed to access the certificate data. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -780,24 +778,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a certificate file name and a password. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -864,24 +862,24 @@ The password required to access the X.509 certificate data. Initializes a new instance of the class using a certificate file name and a password used to access the certificate. - object using a certificate file name and a password needed to access the certificate. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. - + object using a certificate file name and a password needed to access the certificate. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a key container. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -952,24 +950,24 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a byte array, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1038,24 +1036,24 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a byte array, a password, and a key storage flag. - object using a byte array, a password that is needed to access the certificate data, and a key storage flag. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a Microsoft Cryptographic API Cryptographic Service Provider (CSP). - + object using a byte array, a password that is needed to access the certificate data, and a key storage flag. It is used with PKCS12 (PFX) files that contain the certificate's private key. Calling this constructor with the correct password decrypts the private key and saves it to a Microsoft Cryptographic API Cryptographic Service Provider (CSP). + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `rawData`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1155,22 +1153,22 @@ A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - -If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + +If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1241,19 +1239,19 @@ If you create an A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password, and a key storage flag. - certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - + certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1322,24 +1320,24 @@ If you create an A bitwise combination of the enumeration values that control where and how to import the certificate. Initializes a new instance of the class using a certificate file name, a password used to access the certificate, and a key storage flag. - object using a certificate file name, a password needed to access the certificate, and a key storage flag. - + object using a certificate file name, a password needed to access the certificate, and a key storage flag. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + If you create an certificate by specifying a PKCS7 signed file store for `fileName`, the is created for the certificate that signed the store rather than for any of the certificates within the store. + ]]> - An error with the certificate occurs. For example: - -- The certificate file does not exist. - -- The certificate is invalid. - + An error with the certificate occurs. For example: + +- The certificate file does not exist. + +- The certificate is invalid. + - The certificate's password is incorrect. @@ -1393,22 +1391,21 @@ If you create an if the certificate is archived, if the certificate is not archived. - object unless the property is set to `true`. No physical archival activity occurs when the value is set or unset. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object unless the property is set to `true`. No physical archival activity occurs when the value is set or unset. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -1587,13 +1584,13 @@ The specified private key doesn't match the public key for this certificate. to enumerate PEM-encoded values and apply any custom loading behavior. - + For PEM-encoded keys without a password, use . - + ]]> @@ -1679,15 +1676,15 @@ The password specified for the private key is incorrect. ## Remarks See for additional documentation about exceptions that can be thrown. - + Password protected PEM-encoded keys are always expected to have the PEM label "ENCRYPTED PRIVATE KEY". - + PEM-encoded items that have a different label are ignored. Combined PEM-encoded certificates and keys do not require a specific order. For the certificate, the first certificate with a CERTIFICATE label is loaded. For the private key, the first private key with the label "ENCRYPTED PRIVATE KEY" is loaded. More advanced scenarios for loading certificates and private keys can leverage to enumerate PEM-encoded values and apply any custom loading behavior. - + For PEM-encoded keys without a password, use . - + ]]> @@ -1762,7 +1759,7 @@ The password specified for the private key is incorrect. ## Remarks This loads the first well-formed PEM found with a CERTIFICATE label. - + For PEM-encoded certificates with a private key, use . For PEM-encoded certificates in a file, use . @@ -1827,7 +1824,7 @@ For PEM-encoded certificates in a file, use to enumerate PEM-encoded values and apply any custom loading behavior. @@ -2027,20 +2024,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets a collection of objects. An object. - ), key identifiers (), certificate policies, revocation information (CRL Distribution Point extension), and other uses. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + ), key identifiers (), certificate policies, revocation information (CRL Distribution Point extension), and other uses. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -2095,22 +2091,21 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets or sets the associated alias for a certificate. The certificate's friendly name. - The certificate is unreadable. @@ -2180,20 +2175,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Indicates the type of certificate contained in a byte array. An object. - @@ -2296,11 +2290,11 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Indicates the type of certificate contained in a file. An object. - @@ -2559,20 +2553,19 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets the subject and issuer names from a certificate. The name of the certificate. - @@ -2688,13 +2681,13 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A byte array containing data from an X.509 certificate. Populates an object with data from a byte array. - object with its associated values. - - Since this method accepts only a byte array, it can be used only for certificate types that do not require a password, including a PEM-encoded or DER-encoded X.509 certificate or a PFX/PKCS12 certificate. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object with its associated values. + + Since this method accepts only a byte array, it can be used only for certificate types that do not require a password, including a PEM-encoded or DER-encoded X.509 certificate or a PFX/PKCS12 certificate. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + ]]> @@ -2753,13 +2746,13 @@ The certificate is encoded according to the IETF RFC 7468 "strict" The name of a certificate. Populates an object with information from a certificate file. - object with the certificate the file contains. - - This method can be used with several certificate types, including PEM-encoded or DER-encoded X.509 certificates, PFX/PKCS12 certificates, and signer certificates such as Authenticode. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object with the certificate the file contains. + + This method can be used with several certificate types, including PEM-encoded or DER-encoded X.509 certificates, PFX/PKCS12 certificates, and signer certificates such as Authenticode. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + ]]> @@ -2834,14 +2827,14 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object using data from a byte array, a password, and a key storage flag. - [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + ]]> @@ -2912,25 +2905,24 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object using data from a byte array, a password, and flags for determining how to import the private key. - object using a password for the certificate represented by the byte array. The value can be used to control where and how to import the private key. - - This method accepts a byte array and can be used for certificate types such as PEM-encoded or DER-encoded X.509 certificates or PFX/PKCS12 certificates. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. - + object using a password for the certificate represented by the byte array. The value can be used to control where and how to import the private key. + + This method accepts a byte array and can be used for certificate types such as PEM-encoded or DER-encoded X.509 certificates or PFX/PKCS12 certificates. Note that a PFX/PKCS12 certificate can contain more than one certificate. In that case, the first certificate associated with a private key is used or, if no private key is found, the first certificate is used. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -3005,11 +2997,11 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object with information from a certificate file, a password, and a key storage flag. - @@ -3080,14 +3072,14 @@ The certificate is encoded according to the IETF RFC 7468 "strict" A bitwise combination of the enumeration values that control where and how to import the certificate. Populates an object with information from a certificate file, a password, and a value. - object with information from a certificate file, a password, and an value. - + object with information from a certificate file, a password, and an value. + > [!IMPORTANT] -> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. - +> Never hard code a password within your source code. Hard-coded passwords can be retrieved from an assembly using the [Ildasm.exe (IL Disassembler)](/dotnet/framework/tools/ildasm-exe-il-disassembler), a hex editor, or by simply opening up the assembly in a text editor such as Notepad.exe. + ]]> @@ -3135,22 +3127,21 @@ The certificate is encoded according to the IETF RFC 7468 "strict" Gets the distinguished name of the certificate issuer. An object that contains the name of the certificate issuer. - method. - - The distinguished name for the certificate is a textual representation of the certificate subject or issuer. This representation consists of name attributes (for example, "CN=MyName, OU=MyOrgUnit, C=US"). - - - -## Examples - The following code example creates a command-line executable file that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + method. + + The distinguished name for the certificate is a textual representation of the certificate subject or issuer. This representation consists of name attributes (for example, "CN=MyName, OU=MyOrgUnit, C=US"). + + + +## Examples + The following code example creates a command-line executable file that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> The certificate context is invalid. @@ -3269,20 +3260,19 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the date in local time after which a certificate is no longer valid. A object that represents the expiration date for the certificate. - The certificate is unreadable. @@ -3331,20 +3321,19 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the date in local time on which a certificate becomes valid. A object that represents the effective date of the certificate. - The certificate is unreadable. @@ -3402,25 +3391,24 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets or sets the object that represents the private key associated with a certificate. An object, which is either an RSA or DSA cryptographic service provider. - or a object in .NET Core or an or a object in .NET Framework. If no private key is associated with the certificate, it returns `null`. - + or a object in .NET Core or an or a object in .NET Framework. If no private key is associated with the certificate, it returns `null`. + > [!WARNING] -> If you set this property to `null` or to another key without first deleting it, a private key file is left on the disk. - - To properly delete the private key associated with this property, set `PersistKeyInCsp` to `false`, and then call the method. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: +> If you set this property to `null` or to another key without first deleting it, a private key file is left on the disk. + + To properly delete the private key associated with this property, set `PersistKeyInCsp` to `false`, and then call the method. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key value is not an RSA or DSA key, or the key is unreadable. @@ -3474,22 +3462,21 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets a object associated with a certificate. A object. - object, which contains the object identifier () representing the public key algorithm, the ASN.1-encoded parameters, and the ASN.1-encoded key value. - - You can also obtain the key as an object by referencing the property. This property supports only RSA or DSA keys, so it returns either an or a object that represents the public key. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, which contains the object identifier () representing the public key algorithm, the ASN.1-encoded parameters, and the ASN.1-encoded key value. + + You can also obtain the key as an object by referencing the property. This property supports only RSA or DSA keys, so it returns either an or a object that represents the public key. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The key value is not an RSA or DSA key, or the key is unreadable. @@ -3538,15 +3525,14 @@ The Subject Alternative Name extension or Subject Name could not be decoded.Gets the raw X.509 public data of a certificate. The raw X.509 public data of a certificate. - @@ -3638,11 +3624,11 @@ Unlike Resets the state of an object. - @@ -3690,20 +3676,19 @@ Unlike Gets the serial number of a certificate as a big-endian hexadecimal string. The serial number of the certificate as a big-endian hexadecimal string. - @@ -3751,20 +3736,19 @@ Unlike Gets the algorithm used to create the signature of a certificate. The object identifier of the signature algorithm. - ) identifies the type of signature algorithm used by the certificate. - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + ) identifies the type of signature algorithm used by the certificate. + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -3813,20 +3797,19 @@ Unlike Gets the subject distinguished name from a certificate. An object that represents the name of the certificate subject. - The certificate context is invalid. @@ -3875,22 +3858,21 @@ Unlike Gets the thumbprint of a certificate. The thumbprint of the certificate. - . - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -3950,22 +3932,21 @@ Unlike Displays an X.509 certificate in text format. The certificate information. - object to obtain precise information about the content or use the method to obtain information about the certificate. - - This method displays the certificate in text format. - - - -## Examples - The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + object to obtain precise information about the content or use the method to obtain information about the certificate. + + This method displays the certificate in text format. + + + +## Examples + The following code example creates a command-line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -4018,22 +3999,21 @@ Unlike Displays an X.509 certificate in text format. The certificate information. - object to obtain precise information. - - This method displays the certificate in text format. If the `verbose` parameter is set to `true`, the text display includes the public key, private key, and extensions. If `verbose` is set to `false`, the text display includes those fields available from the X.509 certificate, including thumbprint, serial number, subject and issuer names, and validity date information. - - - -## Examples - The following code example creates a command line executable that takes a certificate file as an argument and prints various certificate properties to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp" id="Snippet1"::: + object to obtain precise information. + + This method displays the certificate in text format. If the `verbose` parameter is set to `true`, the text display includes the public key, private key, and extensions. If `verbose` is set to `false`, the text display includes those fields available from the X.509 certificate, including thumbprint, serial number, subject and issuer names, and validity date information. + + + +## Examples + The following code example creates a command line executable that takes a certificate file as an argument and prints various certificate properties to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Overview/certinfo.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertInfo/VB/certinfo.vb" id="Snippet1"::: + ]]> @@ -4134,22 +4114,21 @@ Unlike if the validation succeeds; if the validation fails. - object. - - Note that the default chaining engine can be overridden using the class. On Microsoft Windows Server 2003, the default engine conforms to the specification described in RFC3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." - - - -## Examples - The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object. + + Note that the default chaining engine can be overridden using the class. On Microsoft Windows Server 2003, the default engine conforms to the specification described in RFC3280, "[Certificate and Certificate Revocation List (CRL) Profile](https://go.microsoft.com/fwlink/?LinkId=45286)." + + + +## Examples + The following code example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The certificate is unreadable. @@ -4198,20 +4177,19 @@ Unlike Gets the X.509 format version of a certificate. The certificate format. - The certificate is unreadable. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml index 384ed91691a..874cfff4477 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2Collection.xml @@ -71,20 +71,19 @@ Represents a collection of objects. This class cannot be inherited. - store is opened, the result is represented by an object. If you are familiar with the unmanaged Cryptographic API constructs, you can think of an as a memory store of objects. - - - -## Examples - The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + store is opened, the result is represented by an object. If you are familiar with the unmanaged Cryptographic API constructs, you can think of an as a memory store of objects. + + + +## Examples + The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -145,20 +144,19 @@ Initializes a new instance of the class without any information. - object, which is unlike the other constructors that use certificate or collection information to create the object. - - - -## Examples - The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + object, which is unlike the other constructors that use certificate or collection information to create the object. + + + +## Examples + The following code example opens the current user's personal certificate store, selects only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -251,15 +249,14 @@ An array of objects. Initializes a new instance of the class using an array of objects. - @@ -307,15 +304,14 @@ An object. Initializes a new instance of the class using the specified certificate collection. - @@ -367,20 +363,19 @@ Adds an object to the end of the . The index at which the has been added. - object to a collection and returns the index location of the certificate. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object to a collection and returns the index location of the certificate. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -444,11 +439,11 @@ An array of objects. Adds multiple objects in an array to the object. - objects to add to an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + objects to add to an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -501,11 +496,11 @@ An object. Adds multiple objects in an object to another object. - object that you want to add to another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + object that you want to add to another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -560,13 +555,13 @@ if the contains the specified ; otherwise, . - property. That is, this method is an O(`n`) operation, where `n` is . - - This method determines equality by calling the method. - + property. That is, this method is an O(`n`) operation, where `n` is . + + This method determines equality by calling the method. + ]]> @@ -638,11 +633,11 @@ Exports X.509 certificate information into a byte array. X.509 certificate information in a byte array. - @@ -697,21 +692,21 @@ Exports X.509 certificate information into a byte array using a password. X.509 certificate information in a byte array. - types: - -- - -- - -- - -- - -- - + types: + +- + +- + +- + +- + +- + ]]> The certificate is unreadable, the content is invalid or, in the case of a certificate requiring a password, the private key could not be exported because the password provided was incorrect. @@ -942,22 +937,21 @@ Searches an object using the search criteria specified by the enumeration and the object. An object. - objects if no user interaction is needed. Use the method to allow the user to select objects. - - Note that this method can be used in a cascading or nested style, narrowing the search criteria with each call to the method. - - - -## Examples - The following code example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + objects if no user interaction is needed. Use the method to allow the user to select objects. + + Note that this method can be used in a cascading or nested style, narrowing the search criteria with each call to the method. + + + +## Examples + The following code example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -1119,11 +1113,11 @@ Returns an enumerator that can iterate through a object. An object that can iterate through the object. - @@ -1195,23 +1189,23 @@ A byte array containing data from an X.509 certificate. Imports a certificate in the form of a byte array into a object. - object. This method supports the following types: - -- - -- - -- - -- - -- - -- - + object. This method supports the following types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1313,23 +1307,23 @@ The name of the file containing the certificate information. Imports a certificate file into a object. - types: - -- - -- - -- - -- - -- - -- - + types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1399,23 +1393,23 @@ A bitwise combination of the enumeration values that control how and where the certificate is imported. Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a object. - value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. - - This method imports a certificate byte array into a collection of certificates. This method supports the following types: - -- - -- - -- - -- - -- - + value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. + + This method imports a certificate byte array into a collection of certificates. This method supports the following types: + +- + +- + +- + +- + +- + ]]> @@ -1631,27 +1625,27 @@ A bitwise combination of the enumeration values that control how and where the certificate is imported. Imports a certificate file that requires a password into a object. - value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. - - Note that a PFX/PKCS12 file can contain more than one certificate. This method imports the first certificate associated with the private key or, if no private key is found, the first certificate found. - - This method supports the following types: - -- - -- - -- - -- - -- - -- - + value can be used to control this process. Note that if you do not create a key container, the private key is not persisted. + + Note that a PFX/PKCS12 file can contain more than one certificate. This method imports the first certificate associated with the private key or, if no private key is found, the first certificate found. + + This method supports the following types: + +- + +- + +- + +- + +- + +- + ]]> @@ -1694,7 +1688,7 @@ ## Remarks PEM-encoded items with a CERTIFICATE PEM label will be imported. PEM items with other labels will be ignored. - + More advanced scenarios for loading certificates and can leverage to enumerate PEM-encoded values and apply any custom loading behavior. ]]> @@ -1800,25 +1794,25 @@ The object to insert. Inserts an object into the object at the specified index. - property already equals the capacity of the list, the capacity is doubled by automatically reallocating the internal array before the new element is inserted. - - If `index` is equal to , `certificate` is added to the end of the collection. - + property already equals the capacity of the list, the capacity is doubled by automatically reallocating the internal array before the new element is inserted. + + If `index` is equal to , `certificate` is added to the end of the collection. + ]]> - is less than zero. - - -or- - + is less than zero. + + -or- + is greater than the property. - The collection is read-only. - - -or- - + The collection is read-only. + + -or- + The collection has a fixed size. is . @@ -1871,27 +1865,26 @@ Gets or sets the element at the specified index. The element at the specified index. - - is less than zero. - - -or- - + is less than zero. + + -or- + is equal to or greater than the property. is . @@ -1943,11 +1936,11 @@ The object to be removed from the object. Removes the first occurrence of a certificate from the object. - @@ -2011,11 +2004,11 @@ An array of objects. Removes multiple objects in an array from an object. - objects to remove from an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + objects to remove from an object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> @@ -2068,11 +2061,11 @@ An object. Removes multiple objects in an object from another object. - object that you want to remove from another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. - + object that you want to remove from another object. The and methods process requests transactionally, so that if a single add or remove fails, the entire operation is aborted. + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml index cfa9d8b08ee..ba72ac354a9 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Certificate2UI.xml @@ -38,20 +38,19 @@ Displays user interface dialogs that allow you to select and view X.509 certificates. This class cannot be inherited. - class to present user interface dialogs that display detailed information about an X.509 certificate or allow users to select one or more certificates from a collection of X.509 certificates. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. -## Remarks - Use the methods of the class to present user interface dialogs that display detailed information about an X.509 certificate or allow users to select one or more certificates from a collection of X.509 certificates. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> @@ -88,11 +87,11 @@ Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain. - @@ -137,20 +136,19 @@ The X.509 certificate to display. Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain. - method displays a dialog box with detailed information about the specified X.509 certificate. The dialog box includes buttons for installing or copying the certificate. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + method displays a dialog box with detailed information about the specified X.509 certificate. The dialog box includes buttons for installing or copying the certificate. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The parameter is . @@ -199,11 +197,11 @@ A handle to the parent window to use for the display dialog. Displays a dialog box that contains the properties of an X.509 certificate and its associated certificate chain using a handle to a parent window. - method displays a dialog box with detailed information about the specified X.509 certificate. This method can be used to nest dialog boxes that display certificate information. The dialog box includes buttons for installing or copying the certificate. - + method displays a dialog box with detailed information about the specified X.509 certificate. This method can be used to nest dialog boxes that display certificate information. The dialog box includes buttons for installing or copying the certificate. + ]]> The parameter is . @@ -218,11 +216,11 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection. - method. - + method. + ]]> @@ -283,20 +281,19 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection. An object that contains the selected certificate or certificates. - method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. - - - -## Examples - The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: + method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. + + + +## Examples + The following code example demonstrates how to display user interface dialogs to select and view X.509 certificates. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> The parameter is not a valid flag. @@ -368,11 +365,11 @@ Displays a dialog box for selecting an X.509 certificate from a certificate collection using a handle to a parent window. An object that contains the selected certificate or certificates. - method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. - + method if you require users to manually select X.509 certificates using a dialog box. If no user interaction is required, use the method. + ]]> The parameter is not a valid flag. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml b/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml index 157cc396c66..7beb89f252b 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Chain.xml @@ -68,25 +68,24 @@ Represents a chain-building engine for certificates. - object has a global error status called that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain. - + object has a global error status called that should be used for certificate validation. The rules governing certificate validation are complex, and it is easy to oversimplify the validation logic by ignoring the error status of one or more of the elements involved. The global error status takes into consideration the status of each element in the chain. + > [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + When disposing , the certificates in are not disposed. You should dispose of the certificates in this collection when the certificate instances are no longer needed. + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: + ]]> @@ -151,15 +150,14 @@ Initializes a new instance of the class. - @@ -212,20 +210,19 @@ to use the machine context; to use the current user context. Initializes a new instance of the class specifying a value that indicates whether the machine context should be used. - @@ -277,11 +274,11 @@ An handle to an X.509 chain. Initializes a new instance of the class using an handle to an X.509 chain. - The parameter is . @@ -342,20 +339,19 @@ if the X.509 certificate is valid; otherwise, . - object. Certificates that meet these chain policy rules might still be invalid for specific uses with such features as Security/MIME (SMIME), Authenticode, or Secure Sockets Layer (SSL). If further processing is required to determine whether the certificate is valid for a specific policy, derive a class from and override the method so that it calls the base class `Build` method first, and then does the additional processing. - - - -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + object. Certificates that meet these chain policy rules might still be invalid for specific uses with such features as Security/MIME (SMIME), Authenticode, or Secure Sockets Layer (SSL). If further processing is required to determine whether the certificate is valid for a specific policy, derive a class from and override the method so that it calls the base class `Build` method first, and then does the additional processing. + + + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The is not a valid certificate or is . @@ -403,11 +399,11 @@ Gets a handle to an X.509 chain. An handle to an X.509 chain. - @@ -461,22 +457,21 @@ Gets a collection of objects. An object. - object is a representation of an element in the chain that was built during a call to the method. - + object is a representation of an element in the chain that was built during a call to the method. + A chain element consists of an object, an structure, and an extra information string. - - - -## Examples - The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + + + +## Examples + The following code example opens the current user's personal certificate store, allows you to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -524,20 +519,19 @@ Gets or sets the to use when building an X.509 certificate chain. The object associated with this X.509 chain. - The value being set for this property is . @@ -586,11 +580,11 @@ Gets the status of each element in an object. An array of objects. - @@ -637,11 +631,11 @@ Creates an object after querying for the mapping defined in the CryptoConfig file, and maps the chain to that mapping. An object. - @@ -655,13 +649,13 @@ Releases the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -717,13 +711,13 @@ Releases all of the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -780,13 +774,13 @@ to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by this , and optionally releases the managed resources. - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml index b02b92ca6ec..8329426c5f2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainElement.xml @@ -59,11 +59,11 @@ Represents an element of an X.509 chain. - when calling the property. - + when calling the property. + ]]> @@ -117,20 +117,19 @@ Gets the X.509 certificate at a particular chain element. An object. - @@ -184,11 +183,11 @@ Gets the error status of the current X.509 certificate in a chain. An array of objects. - objects, each consisting of an error code bit and a descriptive localized error message. - + objects, each consisting of an error code bit and a descriptive localized error message. + ]]> @@ -242,20 +241,19 @@ Gets additional error information from an unmanaged certificate chain structure. A string representing the member of the unmanaged structure in the Crypto API. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml index e285447ab58..459f5f81618 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainElementCollection.xml @@ -74,20 +74,19 @@ Represents a collection of objects. This class cannot be inherited. - property is called. - - - -## Examples - The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + property is called. + + + +## Examples + The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -193,20 +192,19 @@ Gets the number of elements in the collection. An integer representing the number of elements in the collection. - @@ -255,11 +253,11 @@ Gets an object that can be used to navigate through a collection of chain elements. An object. - class implements , which enables you to use methods such as , and to view the contents of the collection. - + class implements , which enables you to use methods such as , and to view the contents of the collection. + ]]> @@ -308,20 +306,19 @@ Gets a value indicating whether the collection of chain elements is synchronized. Always returns . - object is not thread safe. - - - -## Examples - The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + object is not thread safe. + + + +## Examples + The following code example opens the current user's personal certificate store, allows the user to select a certificate, and then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> @@ -373,11 +370,11 @@ Gets the object at the specified index. An object. - object in the collection. - + object in the collection. + ]]> @@ -430,11 +427,11 @@ Gets an object that can be used to synchronize access to an object. A pointer reference to the current object. - @@ -569,7 +566,7 @@ ## Remarks -This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. +This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. ]]> @@ -611,7 +608,7 @@ This member is an explicit interface member implementation. It can be used only ## Remarks -This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. +This member is an explicit interface member implementation. It can be used only when the instance is cast to an interface. ]]> @@ -664,11 +661,11 @@ This member is an explicit interface member implementation. It can be used only Gets an object that can be used to navigate a collection of chain elements. An object. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml index e7061ca6ef3..0a78e101a7c 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainPolicy.xml @@ -59,20 +59,19 @@ Represents the chain policy to be applied when building an X509 certificate chain. This class cannot be inherited. - object can have an property that specifies the policy to be used in the verification process. Note that only objects can construct an object. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + object can have an property that specifies the policy to be used in the verification process. Note that only objects can construct an object. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet1"::: + ]]> @@ -167,24 +166,22 @@ Gets a collection of object identifiers (OIDs) specifying which application policies or enhanced key usages (EKUs) the certificate must support. An object. - @@ -238,18 +235,17 @@ Gets a collection of object identifiers (OIDs) specifying which certificate policies the certificate must support. An object. - @@ -284,9 +280,9 @@ A new chain policy instance that has the same settings as this instance. To be added. - on an element in , have an effect on both chain policy instances. @@ -417,11 +413,11 @@ The collection is respected only when Gets an object that represents an additional collection of certificates that can be searched by the chaining engine when validating a certificate chain. An object. - @@ -469,11 +465,11 @@ The collection is respected only when Resets the members to their default values. - @@ -527,20 +523,19 @@ The collection is respected only when Gets or sets values for X509 revocation flags. An object. - enumeration. is the default value. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. is the default value. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. @@ -595,20 +590,19 @@ The collection is respected only when Gets or sets values for X509 certificate revocation mode. An object. - enumeration. is the default value. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. is the default value. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. @@ -707,11 +701,11 @@ When Gets or sets the maximum amount of time to be spent during online revocation verification or downloading the certificate revocation list (CRL). A value of means there are no limits. A object. - @@ -765,20 +759,19 @@ When Gets verification flags for the certificate. A value from the enumeration. - enumeration. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + enumeration. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> The value supplied is not a valid flag. is the default value. @@ -837,26 +830,25 @@ When Gets or sets the time for which the chain is to be validated. A object. - property. -This property is important when validating signed messages, since the signature must have been valid at the time of signing, not at the time of validation. -Every certificate in the chain must have a time no later than this property's value and a - time no earlier than this property's value. Otherwise, the flag is asserted. + property. +This property is important when validating signed messages, since the signature must have been valid at the time of signing, not at the time of validation. +Every certificate in the chain must have a time no later than this property's value and a + time no earlier than this property's value. Otherwise, the flag is asserted. On Windows, this property may also be used to determine the revocation status of a certificate. The parameterless constructor for the class sets the property to the time the constructor is called. -Calling the method replaces the value of with the current system time, +Calling the method replaces the value of with the current system time, not with the time that the object was constructed. ## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml b/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml index 79a41ab6489..7bdc8f2a52d 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509ChainStatus.xml @@ -59,20 +59,19 @@ Provides a simple structure for storing X509 chain status and error information. - property. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Remarks - This structure is used in conjunction with the property. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> @@ -134,20 +133,19 @@ Specifies the status of the X509 chain. An value. - @@ -201,20 +199,19 @@ Specifies a description of the value. A localizable string. - enumeration. - - - -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet4"::: + enumeration. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet4"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml index b74159d04f3..fc6c43a6b43 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509EnhancedKeyUsageExtension.xml @@ -59,20 +59,19 @@ Defines the collection of object identifiers (OIDs) that indicates the applications that use the key. This class cannot be inherited. - class to display the information. -## Remarks - An enhanced key usage (EKU) extension is a collection of object identifiers (OIDs) that indicate the applications that use the key. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,20 +126,19 @@ Initializes a new instance of the class. - class. After the instance has been created, you can then use the property to obtain the collection of object identifiers (OIDs) that indicate the applications that use the key. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. After the instance has been created, you can then use the property to obtain the collection of object identifiers (OIDs) that indicate the applications that use the key. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -191,11 +189,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -340,15 +338,14 @@ Gets the collection of object identifiers (OIDs) that indicate the applications that use the key. An object indicating the applications that use the key. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml b/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml index 9d389e29234..cd1a0490e44 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Extension.xml @@ -59,32 +59,31 @@ Represents an X509 extension. - class can be used to create extensions that are associated with a certificate but are not part of a certificate as issued by a certification authority (CA). + + In its most basic form, an X509 extension has an object identifier (OID), a Boolean value describing whether the extension is considered critical or not, and ASN-encoded data. Custom extensions can be registered in a file. + + The.NET Framework includes implementations of several common X509 extensions: + +- . Describes the key usages of a certificate. + +- . Describes the constraints for a certificate. + +- . Describes the enhanced key usages of a certificate. + +- . Describes the key identifier. For example, used with XMLDSIG. + + + +## Examples + The following code example demonstrates using the class. -## Remarks - X509 extensions are dynamic, extended properties that can be added to an X509 certificate and changed. The class can be used to create extensions that are associated with a certificate but are not part of a certificate as issued by a certification authority (CA). - - In its most basic form, an X509 extension has an object identifier (OID), a Boolean value describing whether the extension is considered critical or not, and ASN-encoded data. Custom extensions can be registered in a file. - - The.NET Framework includes implementations of several common X509 extensions: - -- . Describes the key usages of a certificate. - -- . Describes the constraints for a certificate. - -- . Describes the enhanced key usages of a certificate. - -- . Describes the key identifier. For example, used with XMLDSIG. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -145,20 +144,19 @@ Initializes a new instance of the class. - object, unlike the other constructors for this class that use certificate information from either a byte array, a pointer or a certificate file to create the object. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + object, unlike the other constructors for this class that use certificate information from either a byte array, a pointer or a certificate file to create the object. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -209,20 +207,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - object. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + object. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -275,20 +272,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -389,20 +385,19 @@ if the extension is critical; otherwise . Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -497,20 +492,19 @@ The to be copied. Copies the extension properties of the specified object. - and add them to the instance of the class from which this method is called. - - - -## Examples - The following code example demonstrates using the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + and add them to the instance of the class from which this method is called. + + + +## Examples + The following code example demonstrates using the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -573,20 +567,19 @@ if the extension is critical; otherwise, . - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml b/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml index d154e6a5e72..57887bf1c24 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509FindType.xml @@ -52,22 +52,21 @@ Specifies the type of value the method searches for. - identifies the type of value provided in the `findValue` parameter for the method. You can use to search an collection by subject name, thumbprint, serial number, valid date range, or other value. + + You can use a combination of `FindByTime` value types to find certificates that are valid in a given time range. The union of certificates returned using FindByTimeValid, FindByTimeNotYetValid, and FindByTimeExpired for a given time represents all certificates in the queried collection. + + + +## Examples + The following example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate information to the console. The output depends on the certificate you select. -## Remarks - identifies the type of value provided in the `findValue` parameter for the method. You can use to search an collection by subject name, thumbprint, serial number, valid date range, or other value. - - You can use a combination of `FindByTime` value types to find certificates that are valid in a given time range. The union of certificates returned using FindByTimeValid, FindByTimeNotYetValid, and FindByTimeExpired for a given time represents all certificates in the queried collection. - - - -## Examples - The following example opens the current user's personal certificate store, finds only valid certificates, allows the user to select a certificate, and then writes certificate information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml index ad2cd0c2eb3..604b9453333 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509KeyUsageExtension.xml @@ -59,20 +59,19 @@ Defines the usage of a key contained within an X.509 certificate. This class cannot be inherited. - class uses the flags in the enumeration to define or determine key usage. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class uses the flags in the enumeration to define or determine key usage. + + + +## Examples + The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -186,11 +184,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using an object and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -334,11 +332,11 @@ Gets the key usage flag associated with the certificate. One of the values. - enumeration that indicates how to use the certificate key. - + enumeration that indicates how to use the certificate key. + ]]> The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml b/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml index 5946f4619bc..b48ff4f3319 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509NameType.xml @@ -52,20 +52,19 @@ Specifies the type of name the X509 certificate contains. - . + + + +## Examples + The following example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. -## Remarks - The name type can be a simple name, an email address, a User Principal Name (UPN), a Domain Name System (DNS) name or a URL. An X509 certificate can have one or more of these names. You can obtain the name of a certificate using the method . - - - -## Examples - The following example opens the current user certificate store, selects only active certificates, then allows the user to select one or more certificates. The example then writes certificate information to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/PublicKey/Key/certselect.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CertSelect/VB/certselect.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml b/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml index e1e378051fe..581488a95f2 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509RevocationFlag.xml @@ -52,20 +52,19 @@ Specifies which X509 certificates in the chain should be checked for revocation. - diff --git a/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml b/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml index 276d4473fc6..2ed709fd374 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509RevocationMode.xml @@ -52,23 +52,22 @@ Specifies the mode used to check for X509 certificate revocation. - [!NOTE] -> Specifying an online check can result in a long delay while the certificate authority is contacted. - - +> Specifying an online check can result in a long delay while the certificate authority is contacted. + + + +## Examples + The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. -## Examples - The following example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate you select. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet3"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml b/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml index 1eaf69bfa1d..cb9f4460cf5 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509SelectionFlag.xml @@ -27,20 +27,19 @@ Specifies the type of selection requested using the method. - method. + + + +## Examples + The following code example demonstrates how to use the selection flag with the method. This code example is part of a larger example provided for the class. The larger example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. -## Remarks - This flag represents either a single or multiple certificate selection using the method. - - - -## Examples - The following code example demonstrates how to use the selection flag with the method. This code example is part of a larger example provided for the class. The larger example opens the current user's personal certificate store, allows the user to select a certificate, then writes certificate and certificate chain information to the console. The output depends on the certificate the user selects. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509Chain/Overview/x509chaintest.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509chaintest/vb/x509chaintest.vb" id="Snippet2"::: + ]]> diff --git a/xml/System.Security.Cryptography.X509Certificates/X509Store.xml b/xml/System.Security.Cryptography.X509Certificates/X509Store.xml index 93dbaa1616e..948f8fadfaf 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509Store.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509Store.xml @@ -68,40 +68,39 @@ Represents an X.509 store, which is a physical store where certificates are persisted and managed. This class cannot be inherited. - [!IMPORTANT] -> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. -> -> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. - - - -## Examples - This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. - - The second example demonstrates how you can add and remove single certificates and ranges of certificates. - - **Example 1** - - This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. - - The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - +> Starting with the .NET Framework 4.6, this type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. +> +> For apps that target the .NET Framework 4.5.2 and earlier versions, the class does not implement the interface and therefore does not have a `Dispose` method. + + + +## Examples + This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. + + The second example demonstrates how you can add and remove single certificates and ranges of certificates. + + **Example 1** + + This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. + + The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -162,20 +161,19 @@ Initializes a new instance of the class using the personal certificates store of the current user. - object using the personal X.509 certificate store for the current user. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using the personal X.509 certificate store for the current user. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -221,11 +219,11 @@ A handle to an store. Initializes a new instance of the class using an Intptr handle to an store. - The parameter is . @@ -279,20 +277,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using the personal certificate store from the specified store location value. - object, specifying the store location, which is either the location for the current user or the local computer. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object, specifying the store location, which is either the location for the current user or the local computer. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -344,20 +341,19 @@ One of the enumeration values that specifies the name of the X.509 certificate store. Initializes a new instance of the class using the specified store name from the current user's certificate stores. - . - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + . + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -411,20 +407,19 @@ The name of the certificate store. Initializes a new instance of the class using the specified store name. - object using a particular X.509 store name for the current user. To create a new store, specify a name that does not exist. A new store will be created with that name. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using a particular X.509 store name for the current user. To create a new store, specify a name that does not exist. A new store will be created with that name. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -474,20 +469,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using the specified and values. - object, specifying both the store name and the store location. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object, specifying both the store name and the store location. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -539,20 +533,19 @@ One of the enumeration values that specifies the location of the X.509 certificate store. Initializes a new instance of the class using a specified store name and store location. - object using a store name and location. To create a new store, specify a name that does not exist. A new store will be created with that name. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + object using a store name and location. To create a new store, specify a name that does not exist. A new store will be created with that name. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -690,20 +683,19 @@ The certificate to add. Adds a certificate to an X.509 certificate store. - @@ -755,20 +747,19 @@ The collection of certificates to add. Adds a collection of certificates to an X.509 certificate store. - @@ -819,35 +810,34 @@ Returns a collection of certificates located in an X.509 certificate store. A collection of certificates. - or operations performed on the store will not have any effect on the collection that is returned. This snapshot is recalculated each time the property is called, so the use of this property inside an iterative function is not recommended. - - - -## Examples - This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. - - The second example demonstrates how you can add and remove single certificates and ranges of certificates. - - **Example 1** - - This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. - - The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + or operations performed on the store will not have any effect on the collection that is returned. This snapshot is recalculated each time the property is called, so the use of this property inside an iterative function is not recommended. + + + +## Examples + This section contains two examples. The first example demonstrates how you can open standard X.509 stores and list the number of certificates in each. + + The second example demonstrates how you can add and remove single certificates and ranges of certificates. + + **Example 1** + + This example tries to open each standard store in each standard location on the current computer. It prints a summary that shows whether each store exists and, if so, the number of certificates it contains. + + The example creates an object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -893,20 +883,19 @@ Closes an X.509 certificate store. - @@ -956,13 +945,13 @@ Releases the resources used by this . - [!NOTE] -> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. - +> implements the interface starting with the .NET Framework 4.6; in previous versions of the .NET Framework, the class does not implement this interface, and therefore the `Dispose` method does not exist. + ]]> @@ -1055,35 +1044,34 @@ Gets the location of the X.509 certificate store. The location of the certificate store. - object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1142,35 +1130,34 @@ Gets the name of the X.509 certificate store. The name of the certificate store. - object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. - + object for each combination of standard name and standard location. It calls the method with the flag, which opens the physical store only if it already exists. If the physical store exists, the example uses the , , and properties to display the number of certificates in the store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/storenames1.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: - - **Example 2** - - This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/storenames1.vb" id="Snippet2"::: + + **Example 2** + + This example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1221,20 +1208,19 @@ A bitwise combination of enumeration values that specifies the way to open the X.509 certificate store. Opens an X.509 certificate store or creates a new store, depending on flag settings. - , to enumerate the certificates in the store. You can create a new store by passing a store name that does not exist to the class constructor, and then using any of the flags except . - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: + , to enumerate the certificates in the store. You can create a new store by passing a store name that does not exist to the class constructor, and then using any of the flags except . + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> The store cannot be opened as requested. @@ -1288,20 +1274,19 @@ The certificate to remove. Removes a certificate from an X.509 certificate store. - @@ -1353,24 +1338,23 @@ A range of certificates to remove. Removes a range of certificates from an X.509 certificate store. - [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - This method removes more than one certificate from an X.509 certificate store; if one certificate removal fails, the operation is reverted and no certificates are removed. - - - -## Examples - The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp" id="Snippet1"::: +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + This method removes more than one certificate from an X.509 certificate store; if one certificate removal fails, the operation is reverted and no certificates are removed. + + + +## Examples + The following code example opens an X.509 certificate store, adds and deletes certificates, and then closes the store. It assumes that you have three certificates to add to and remove from a local store. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/OpenFlags/Overview/x509store2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/x509store2/vb/x509store2.vb" id="Snippet1"::: + ]]> @@ -1419,11 +1403,11 @@ Gets an handle to an store. A handle to an store. - property to provide compatibility with the unmanaged [Microsoft Cryptographic API (CAPI)](/windows/win32/seccrypto/cryptography-reference). - + ]]> The store is not open. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml b/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml index d9a4af0a6e0..30df26d8537 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509SubjectKeyIdentifierExtension.xml @@ -59,20 +59,19 @@ Defines a string that identifies a certificate's subject key identifier (SKI). This class cannot be inherited. - class to display the information. -## Remarks - There are several ways to identify a certificate: by the hash of the certificate, by the issuer and serial number, and by the subject key identifier (SKI). The SKI provides a unique identification for the certificate's subject and is often used when working with XML digital signing. - - - -## Examples - The following code example demonstrates how to open a user's personal certificate store and display information about each certificate in the store. This example uses the class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,15 +126,14 @@ Initializes a new instance of the class. - class to display the information. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp" id="Snippet1"::: + class to display the information. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.X509Certificates/X509BasicConstraintsExtension/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/VB/sample.vb" id="Snippet1"::: + ]]> @@ -269,11 +267,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using encoded data and a value that identifies whether the extension is critical. - object. - + object. + ]]> @@ -372,11 +370,11 @@ if the extension is critical; otherwise, . Initializes a new instance of the class using a string and a value that identifies whether the extension is critical. - @@ -529,11 +527,11 @@ Gets a string that represents the subject key identifier (SKI) for a certificate. A string, encoded in hexadecimal format, that represents the subject key identifier (SKI). - The extension cannot be decoded. diff --git a/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml b/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml index c09908a35bf..5e25f6e747a 100644 --- a/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml +++ b/xml/System.Security.Cryptography.X509Certificates/X509VerificationFlags.xml @@ -58,20 +58,19 @@ Specifies conditions under which verification of certificates in the X509 chain should be conducted. - diff --git a/xml/System.Security.Cryptography.Xml/CipherData.xml b/xml/System.Security.Cryptography.Xml/CipherData.xml index 8f7b73f8f6a..a8ddb2e5492 100644 --- a/xml/System.Security.Cryptography.Xml/CipherData.xml +++ b/xml/System.Security.Cryptography.Xml/CipherData.xml @@ -53,7 +53,6 @@ ## Examples The following code example uses the class to create an `` element that contains a `` element, and then writes the XML to an XML file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet1"::: @@ -107,7 +106,6 @@ ## Examples The following code example shows how to create a new instance of the class. The entire sample can be found in the class topic. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet2"::: @@ -159,7 +157,6 @@ ## Examples The following code example shows how to create a new instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/VB/encrypteddata.vb" id="Snippet1"::: @@ -211,7 +208,6 @@ ## Examples The following code example shows how to create a new instance of the class using information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -265,7 +261,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example shows how to create a new instance of the class using information. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -320,7 +315,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example shows how to create a new instance of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/encrypteddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/VB/encrypteddata.vb" id="Snippet1"::: @@ -372,7 +366,6 @@ The `` element identifies a source that, when processed, yields ## Examples The following code example demonstrates how to create a new instance of the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/Overview/encrypteddata.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/VB/encrypteddata.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography.Xml/CipherReference.xml b/xml/System.Security.Cryptography.Xml/CipherReference.xml index 1f5273320a5..9190544977d 100644 --- a/xml/System.Security.Cryptography.Xml/CipherReference.xml +++ b/xml/System.Security.Cryptography.Xml/CipherReference.xml @@ -60,7 +60,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -122,7 +121,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -193,7 +191,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -244,7 +241,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example creates a new instance of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherData/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/cryptography.Xml.CipherReference/VB/example.vb" id="Snippet1"::: @@ -294,7 +290,6 @@ EncryptedXml exml = new EncryptedXml(doc, ev); ## Examples The following code example shows one way to use the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml b/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml index 7322895b601..d8b30f458d6 100644 --- a/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml +++ b/xml/System.Security.Cryptography.Xml/DSAKeyValue.xml @@ -39,32 +39,30 @@ Represents the private key of the element. - class represents the `` element, which contains a public key. + + Use to identify the public key that corresponds to the private key that was used to create the digital signature. + + If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. + + The class is used with XML signatures. For more information about the W3C specification, see [XML Signature Syntax and Processing Version 1.1](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to use the class in XML encryption to create a detached signature. -## Remarks - The class represents the `` element, which contains a public key. - - Use to identify the public key that corresponds to the private key that was used to create the digital signature. - - If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. - - The class is used with XML signatures. For more information about the W3C specification, see [XML Signature Syntax and Processing Version 1.1](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to use the class in XML encryption to create a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampledetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet1"::: - - The following code example demonstrates how to use the class in XML encryption to create an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet1"::: + + The following code example demonstrates how to use the class in XML encryption to create an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampleenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: + ]]> @@ -116,11 +114,11 @@ Initializes a new instance of the class with a new, randomly-generated public key. - key, this constructor uses the default implementation of as defined by the class. - + key, this constructor uses the default implementation of as defined by the class. + ]]> @@ -157,19 +155,17 @@ The instance of an implementation of the class that holds the public key. Initializes a new instance of the class with the specified public key. - class in XML encryption. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp" id="Snippet2"::: + class in XML encryption. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampledetached.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet2"::: - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/VB/exampledetached.vb" id="Snippet2"::: + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DSAKeyValue/Overview/exampleenvelope.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/VB/exampleenvelope.vb" id="Snippet2"::: + ]]> @@ -207,11 +203,11 @@ Returns the XML representation of a element. The XML representation of the element. - object. - + object. + ]]> @@ -248,11 +244,11 @@ Gets or sets the key value represented by a object. The public key represented by a object. - @@ -292,11 +288,11 @@ The XML element to load the state from. Loads a state from an XML element. - object. - + object. + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography.Xml/DataObject.xml b/xml/System.Security.Cryptography.Xml/DataObject.xml index e56c2de8074..828434122e3 100644 --- a/xml/System.Security.Cryptography.Xml/DataObject.xml +++ b/xml/System.Security.Cryptography.Xml/DataObject.xml @@ -39,28 +39,26 @@ Represents the object element of an XML signature that holds data to be signed. - class to store information or metadata directly in an XML signature. For example, you can store the signature generation date or the signer's identity. The class may or may not be covered by the XML signature. + + The class corresponds to the `` element in the World Wide Web Consortium (W3C) specification for XML Signatures. For more information about the W3C specification, see [https://www.w3.org/TR/xmldsig-core/](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. -## Remarks - Use the class to store information or metadata directly in an XML signature. For example, you can store the signature generation date or the signer's identity. The class may or may not be covered by the XML signature. - - The class corresponds to the `` element in the World Wide Web Consortium (W3C) specification for XML Signatures. For more information about the W3C specification, see [https://www.w3.org/TR/xmldsig-core/](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -102,26 +100,24 @@ Initializes a new instance of the class. - class is used with XML signatures. After you have initialized the , you can assign the and properties. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + class is used with XML signatures. After you have initialized the , you can assign the and properties. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -164,11 +160,11 @@ The data to initialize the new instance of with. Initializes a new instance of the class with the specified identification, MIME type, encoding, and data. - class is used with XML signatures. The `id` parameter refers to the name of the element that contains the data to be used. The `data` parameter refers to the XML node list that contains the `id` parameter element. - + class is used with XML signatures. The `id` parameter refers to the name of the element that contains the data to be used. The `data` parameter refers to the XML node list that contains the `id` parameter element. + ]]> The parameter is . @@ -212,26 +208,24 @@ Gets or sets the data value of the current object. The data of the current . - property. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + property. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> The value used to set the property is . @@ -270,11 +264,11 @@ Gets or sets the encoding of the current object. The type of encoding of the current object. - @@ -312,11 +306,11 @@ Returns the XML representation of the object. The XML representation of the object. - . - + . + ]]> @@ -354,26 +348,24 @@ Gets or sets the identification of the current object. The name of the element that contains data to be used. - from another location. The default value of this property is `null`, which implies that no identification is present. This property is commonly referenced by the property. - - - -## Examples - The following code example demonstrates how to generate an enveloping XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp" id="Snippet1"::: + from another location. The default value of this property is `null`, which implies that no identification is present. This property is commonly referenced by the property. + + + +## Examples + The following code example demonstrates how to generate an enveloping XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: - - The following code example demonstrates how to check an XML signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Signing/VB/source.vb" id="Snippet1"::: + + The following code example demonstrates how to check an XML signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/DataObject/Overview/source1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG Verification/VB/source.vb" id="Snippet1"::: + ]]> @@ -413,11 +405,11 @@ The XML element to load the state from. Loads a state from an XML element. - object. - + object. + ]]> The value from the XML element is . @@ -456,11 +448,11 @@ Gets or sets the MIME type of the current object. The MIME type of the current object. The default is . - . - + . + ]]> diff --git a/xml/System.Security.Cryptography.Xml/EncryptedReference.xml b/xml/System.Security.Cryptography.Xml/EncryptedReference.xml index dea608aaa7e..0e2dad8f975 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptedReference.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptedReference.xml @@ -38,20 +38,19 @@ Represents the abstract base class used in XML encryption from which the , , and classes derive. - method in the class to write the XML values to the console. - - -## Examples - The following example uses the method in the class to write the XML values to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: + ]]> @@ -92,13 +91,13 @@ Initializes a new instance of the class. - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> @@ -134,15 +133,15 @@ The Uniform Resource Identifier (URI) that points to the data to encrypt. Initializes a new instance of the class using the specified Uniform Resource Identifier (URI). - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> The parameter is . @@ -181,13 +180,13 @@ A object that describes transforms to be done on the data to encrypt. Initializes a new instance of the class using the specified Uniform Resource Identifier (URI) and transform chain. - , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. - + , , and classes derive. Unless you have a scenario where you need to create a custom reference section in XML, use one of the inherited classes. + For more information about XML encryption standards, see [XML Encryption Requirements](https://www.w3.org/TR/xml-encryption-req/). - + ]]> The parameter is . @@ -271,11 +270,11 @@ if the cache is valid; otherwise, . - @@ -312,20 +311,19 @@ Returns the XML representation of an object. An object that represents the values of the element in XML encryption. - object. - - - -## Examples - The following example uses the method in the class to write the XML values to the console. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp" id="Snippet1"::: + object. + + + +## Examples + The following example uses the method in the class to write the XML values to the console. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/CipherReference/GetXml/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/CipherReference2/VB/example.vb" id="Snippet1"::: + ]]> The property is . @@ -416,11 +414,11 @@ Gets or sets a reference type. The reference type of the encrypted data. - , , and derived classes. For example, a object sets this property value to . - + , , and derived classes. For example, a object sets this property value to . + ]]> @@ -495,11 +493,11 @@ Gets or sets the Uniform Resource Identifier (URI) of an object. The Uniform Resource Identifier (URI) of the object. - The property was set to . diff --git a/xml/System.Security.Cryptography.Xml/EncryptedXml.xml b/xml/System.Security.Cryptography.Xml/EncryptedXml.xml index 31336465823..de4c7814b28 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptedXml.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptedXml.xml @@ -64,31 +64,26 @@ ## Examples The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -109,25 +104,21 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -182,25 +173,21 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -259,13 +246,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -381,7 +366,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: @@ -484,7 +468,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -555,13 +538,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -862,13 +843,11 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -937,7 +916,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an X.509 certificate. This example creates a symmetric session key to encrypt the document and then uses the X.509 certificate to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample3.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/VB/sample.vb" id="Snippet1"::: @@ -1010,7 +988,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/AddKeyNameMapping/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/VB/sample.vb" id="Snippet1"::: @@ -1041,19 +1018,16 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1108,19 +1082,16 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using a symmetric key. This example embeds a key name in the encrypted XML document that the decrypting method uses to find the appropriate decryption key. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1184,7 +1155,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1215,7 +1185,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1328,7 +1297,6 @@ ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -1694,7 +1662,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1756,7 +1723,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -1927,7 +1893,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2014,7 +1979,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2101,7 +2065,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2149,7 +2112,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2236,7 +2198,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: @@ -2362,7 +2323,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: @@ -2566,7 +2526,6 @@ The value of the parameter is not a su ## Examples The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml b/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml index 2d1a1e84d3d..6f3f0247613 100644 --- a/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml +++ b/xml/System.Security.Cryptography.Xml/EncryptionMethod.xml @@ -38,30 +38,28 @@ Encapsulates the encryption algorithm used for XML encryption. - ` tag uses a Uniform Resource Identifier (URI) to identify the encryption algorithm that must be used to decrypt XML data. The class encapsulates the `` tag defined by the World Wide Web Consortium (W3C) [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. + + Use the class to identify the encryption algorithm associated with the element or the element. + + Use one of the URI identifiers defined by the W3C [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + + + +## Examples + The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. -## Remarks - The `` tag uses a Uniform Resource Identifier (URI) to identify the encryption algorithm that must be used to decrypt XML data. The class encapsulates the `` tag defined by the World Wide Web Consortium (W3C) [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. - - Use the class to identify the encryption algorithm associated with the element or the element. - - Use one of the URI identifiers defined by the W3C [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - - - -## Examples - The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: - - The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: + + The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: + ]]> @@ -102,11 +100,11 @@ Initializes a new instance of the class. - class without specifying the Uniform Resource Identifier (URI) of an encryption algorithm. - + class without specifying the Uniform Resource Identifier (URI) of an encryption algorithm. + ]]> @@ -143,28 +141,26 @@ The Uniform Resource Identifier (URI) that describes the algorithm represented by an instance of the class. Initializes a new instance of the class specifying an algorithm Uniform Resource Identifier (URI). - class using the URI of an encryption algorithm. - - Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - - - -## Examples - The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp" id="Snippet1"::: + class using the URI of an encryption algorithm. + + Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + + + +## Examples + The following code example demonstrates how to create a simple utility class that uses the algorithm to encrypt an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: - - The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/VB/sample.vb" id="Snippet1"::: + + The following code example demonstrates how to encrypt an XML document using a symmetric key. This example does not include any key information in the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample4.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/VB/sample.vb" id="Snippet1"::: + ]]> @@ -201,11 +197,11 @@ Returns an object that encapsulates an instance of the class. An object that encapsulates an instance of the class. - method returns a representation of the `` element. - + method returns a representation of the `` element. + ]]> @@ -242,13 +238,13 @@ Gets or sets a Uniform Resource Identifier (URI) that describes the algorithm to use for XML encryption. A Uniform Resource Identifier (URI) that describes the algorithm to use for XML encryption. - property describes the Uniform Resource Identifier (URI) of the encryption algorithm used to encrypt data associated with either the element or the element. - - Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. - + property describes the Uniform Resource Identifier (URI) of the encryption algorithm used to encrypt data associated with either the element or the element. + + Use one of the URI identifiers defined by the World Wide Web Consortium [XML Encryption Syntax and Processing](https://www.w3.org/TR/xmlenc-core/) specification. All URI identifiers are accessible as static fields of the class. + ]]> @@ -284,11 +280,11 @@ Gets or sets the algorithm key size used for XML encryption. The algorithm key size, in bits, used for XML encryption. - property describes the key size of the encryption algorithm used to encrypt data associated with either the element or the element. - + property describes the key size of the encryption algorithm used to encrypt data associated with either the element or the element. + ]]> The property was set to a value that was less than 0. @@ -328,11 +324,11 @@ An object to parse. Parses the specified object and configures the internal state of the object to match. - method configures the object to match the state of an object. - + method configures the object to match the state of an object. + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml b/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml index 7b932605d49..e09e6550607 100644 --- a/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml +++ b/xml/System.Security.Cryptography.Xml/IRelDecryptor.xml @@ -30,20 +30,19 @@ Defines methods that decrypt an XrML element. - interface with the class to decrypt an XrML `` element. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. -## Remarks - Use the interface with the class to decrypt an XrML `` element. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -87,11 +86,11 @@ Decrypts an XrML element that is contained within a object. A object that contains a decrypted element. - method decrypts an XrML `` element and returns a plaintext stream. - + method decrypts an XrML `` element and returns a plaintext stream. + ]]> diff --git a/xml/System.Security.Cryptography.Xml/KeyInfo.xml b/xml/System.Security.Cryptography.Xml/KeyInfo.xml index eb83ffbffdc..4b171ca2779 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfo.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfo.xml @@ -43,42 +43,38 @@ Represents an XML digital signature or XML encryption element. - class represents key information in XML digital signing and encryption. - - The class enables you to imbed key-related information intended to help identify the key necessary for validating or decrypting the XML document. Multiple types of key-related information can be included within a single ; each type of key-related information has an associated class derived from . - + class represents key information in XML digital signing and encryption. + + The class enables you to imbed key-related information intended to help identify the key necessary for validating or decrypting the XML document. Multiple types of key-related information can be included within a single ; each type of key-related information has an associated class derived from . + For more information about the `` element, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -111,33 +107,29 @@ Initializes a new instance of the class. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -177,33 +169,29 @@ The to add to the object. Adds a that represents a particular type of information to the object. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -287,13 +275,13 @@ Returns an enumerator of the objects in the object. An enumerator of the subelements of that can be used to iterate through the collection. - @@ -334,13 +322,13 @@ Returns an enumerator of the objects of the specified type in the object. An enumerator of the subelements of that can be used to iterate through the collection. - diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml b/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml index 79ef5ca2174..9eed0e3af9d 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoEncryptedKey.xml @@ -46,20 +46,19 @@ Wraps the class, it to be placed as a subelement of the class. - class wraps the class, which allows you to add the class as a subelement of the class. Initialize the class to an instance of the class when you need to add an encrypted session key to your encrypted XML document. + + + +## Examples + The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. -## Remarks - The class wraps the class, which allows you to add the class as a subelement of the class. Initialize the class to an instance of the class when you need to add an encrypted session key to your encrypted XML document. - - - -## Examples - The following code example demonstrates how to encrypt an XML document using an asymmetric key. This example creates a symmetric session key to encrypt the document and then uses the asymmetric key to embed an encrypted version of the session key into the XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -72,15 +71,14 @@ Initializes a new instance of the class. - @@ -112,11 +110,11 @@ Initializes a new instance of the class. - class using an instance of the class. Use the property to specify an object when you use this constructor. - + class using an instance of the class. Use the property to specify an object when you use this constructor. + ]]> @@ -152,15 +150,14 @@ An object that encapsulates an encrypted key. Initializes a new instance of the class using an object. - @@ -203,11 +200,11 @@ Gets or sets an object that encapsulates an encrypted key. An object that encapsulates an encrypted key. - class wraps the class, which allows you to add the class as a subelement of the class. Use the property to access the class contained within the class. - + class wraps the class, which allows you to add the class as a subelement of the class. Use the property to access the class contained within the class. + ]]> The property is . diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoName.xml b/xml/System.Security.Cryptography.Xml/KeyInfoName.xml index f0c193a2f0a..1be6dad14d7 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoName.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoName.xml @@ -39,40 +39,36 @@ Represents a subelement of an XMLDSIG or XML Encryption element. - ` element contains a string identifier that the party validating or decrypting an XML document uses to identify the corresponding key. For example, if you receive an encrypted or signed XML document that has a `` element value of "AsymmetricKey1", you will use a key that you and the sender have named "AsymmetricKey1" to decrypt or verify the document. Both parties must agree on a key name mapping ahead of time. Note that the actual key is not imbedded in the XML document. + + For more information about the `` element, see Section 4.4.1 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. -## Remarks - The `` element contains a string identifier that the party validating or decrypting an XML document uses to identify the corresponding key. For example, if you receive an encrypted or signed XML document that has a `` element value of "AsymmetricKey1", you will use a key that you and the sender have named "AsymmetricKey1" to decrypt or verify the document. Both parties must agree on a key name mapping ahead of time. Note that the actual key is not imbedded in the XML document. - - For more information about the `` element, see Section 4.4.1 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. - - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -114,33 +110,29 @@ Initializes a new instance of the class. - object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> @@ -177,13 +169,13 @@ The string identifier that is the value of the element. Initializes a new instance of the class by specifying the string identifier that is the value of the element. - property. - + property. + ]]> @@ -221,11 +213,11 @@ Returns an XML representation of the object. An XML representation of the object. - object returned by this method is suitable for use as a subelement of an XMLDSIG or XML Encryption `` element. - + object returned by this method is suitable for use as a subelement of an XMLDSIG or XML Encryption `` element. + ]]> @@ -265,11 +257,11 @@ The object that specifies the state of the object. Parses the input object and configures the internal state of the object to match. - method is typically used to process a `` subelement of a `` element. - + method is typically used to process a `` subelement of a `` element. + ]]> The parameter is . @@ -308,38 +300,34 @@ Gets or sets the string identifier contained within a element. The string identifier that is the value of the element. - property can contain any string; the interpretation of the string is specific to the application. White space is significant in the string value. - - - -## Examples - The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + property can contain any string; the interpretation of the string is specific to the application. White space is significant in the string value. + + + +## Examples + The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - The following code example uses the object when signing an XML document. This example saves the signature in a new file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + The following code example uses the object when signing an XML document. This example saves the signature in a new file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example embeds an encrypted key within the encrypted XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: - - The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/VB/sample.vb" id="Snippet1"::: + + The following code example uses the object when encrypting an XML document. This example maps a name to a symmetric key to identify it to the decryption method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/EncryptedXml/Overview/sample2.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml b/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml index e49f931c59d..500022e4601 100644 --- a/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml +++ b/xml/System.Security.Cryptography.Xml/KeyInfoX509Data.xml @@ -39,32 +39,30 @@ Represents an subelement of an XMLDSIG or XML Encryption element. - class represents the `` element that contains X.509v3 certificate information related to the validation or encryption key. For example, an `` element might contain an X.509 certificate whose subject public key is the validation key, or a chain of X.509 certificates that terminate in a certificate for the validating key, or other identifiers for related X.509 certificates. + + Use the class whenever you need to include X.509 certificate data in an encrypted or signed XML document. + + For more information about the `` element, see Section 4.4.4 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. The second example demonstrates how to sign an XML file using an envelope signature. + + **Example #1** -## Remarks - The class represents the `` element that contains X.509v3 certificate information related to the validation or encryption key. For example, an `` element might contain an X.509 certificate whose subject public key is the validation key, or a chain of X.509 certificates that terminate in a certificate for the validating key, or other identifiers for related X.509 certificates. - - Use the class whenever you need to include X.509 certificate data in an encrypted or signed XML document. - - For more information about the `` element, see Section 4.4.4 of the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/) or the [XML Encryption specification](https://www.w3.org/TR/xmlenc-core/), which are available on the W3C website. - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. The second example demonstrates how to sign an XML file using an envelope signature. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/Overview/examplecreatedetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/VB/examplecreatedetached.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/VB/examplecreatedetached.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/Overview/examplecreateenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/VB/examplecreateenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/VB/examplecreateenvelope.vb" id="Snippet1"::: + ]]> @@ -174,23 +172,21 @@ The object to initialize the new instance of from. Initializes a new instance of the class from the specified X.509v3 certificate. - The parameter is . @@ -235,14 +231,14 @@ One of the values that specifies how much of the certificate chain to include. Initializes a new instance of the class from the specified X.509v3 certificate. - object while signing and verifying an XML document. - + object while signing and verifying an XML document. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfoX509Data/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.KeyInfoX509Data/vb/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.KeyInfoX509Data/vb/sample.vb" id="Snippet1"::: + ]]> The parameter is . @@ -324,13 +320,13 @@ The serial number portion of the pair to add to the object. Adds the specified issuer name and serial number pair to the object. - method adds information about an issuer name and serial number pair to a list of objects that are accessible through the property. - + method adds information about an issuer name and serial number pair to a list of objects that are accessible through the property. + ]]> @@ -344,11 +340,11 @@ Adds a subject key identifier (SKI) to the object. - @@ -388,11 +384,11 @@ A byte array that represents the subject key identifier (SKI) to add to the object. Adds the specified subject key identifier (SKI) byte array to the object. - @@ -437,11 +433,11 @@ A string that represents the subject key identifier (SKI) to add to the object. Adds the specified subject key identifier (SKI) string to the object. - @@ -586,11 +582,11 @@ Returns an XML representation of the object. An XML representation of the object. - object returned by this method is suitable for use as a subelement of an XMLDSIG or XML encryption `` element. - + object returned by this method is suitable for use as a subelement of an XMLDSIG or XML encryption `` element. + ]]> @@ -628,15 +624,15 @@ Gets a list of structures that represent an issuer name and serial number pair. A list of structures that represent an issuer name and serial number pair. - property represents the `` element of an XML digital signature using a list of structures contained within. The `` element represents an issuer name and serial number pair, which identify a specific X.509v3 certificate. - - The issuer of an X.509 certificate is the name of the certification authority that issued the certificate. Certification authorities assign each certificate they issue a unique serial number. - - You can add a name and serial number pair using the method. - + property represents the `` element of an XML digital signature using a list of structures contained within. The `` element represents an issuer name and serial number pair, which identify a specific X.509v3 certificate. + + The issuer of an X.509 certificate is the name of the certification authority that issued the certificate. Certification authorities assign each certificate they issue a unique serial number. + + You can add a name and serial number pair using the method. + ]]> @@ -676,18 +672,18 @@ The object that specifies the state of the object. Parses the input object and configures the internal state of the object to match. - ` subelement of a `` element. - + ` subelement of a `` element. + ]]> The parameter is . - The parameter does not contain an <> node. - - -or- - + The parameter does not contain an <> node. + + -or- + The parameter does not contain an <> node. @@ -724,11 +720,11 @@ Gets a list of the subject key identifiers (SKIs) contained in the object. A list of the subject key identifiers (SKIs) contained in the object. - @@ -766,11 +762,11 @@ Gets a list of the subject names of the entities contained in the object. A list of the subject names of the entities contained in the object. - diff --git a/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml b/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml index 8714fb7b2f9..b5a096e6c40 100644 --- a/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml +++ b/xml/System.Security.Cryptography.Xml/RSAKeyValue.xml @@ -41,27 +41,25 @@ class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the subelement of the `` element (represented by the class) that describes an public key. The `` element contains the public key that corresponds to the private key used to digitally sign a document. A recipient of the document uses the public key to validate the XML signature. - - Use the class whenever you want to add a public key to your XML digital signature. - - If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. - - For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to generate and verify an enveloped XML signature using the object. +## Remarks + The class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the subelement of the `` element (represented by the class) that describes an public key. The `` element contains the public key that corresponds to the private key used to digitally sign a document. A recipient of the document uses the public key to validate the XML signature. + + Use the class whenever you want to add a public key to your XML digital signature. + + If a key is not explicitly supplied to the constructor, a new key pair is randomly generated. + + For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example demonstrates how to generate and verify a detached XML signature using the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example demonstrates how to generate and verify a detached XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -108,7 +106,7 @@ to hold the public key. ]]> @@ -149,16 +147,14 @@ object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: +## Examples + The following code example demonstrates how to generate and verify an enveloped XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - The following code example demonstrates how to generate and verify a detached XML signature using the object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + The following code example demonstrates how to generate and verify a detached XML signature using the object. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -241,9 +237,9 @@ Based upon [The RSAKeyValue Element](https://www.w3.org/TR/2002/REC-xmldsig-core property represents the public key to add to an XML digital signature using the `` subelement and the `` subelement of the `` element. - +## Remarks + The property represents the public key to add to an XML digital signature using the `` subelement and the `` subelement of the `` element. + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). ]]> diff --git a/xml/System.Security.Cryptography.Xml/Reference.xml b/xml/System.Security.Cryptography.Xml/Reference.xml index 6b564ff911e..8d0be3c956c 100644 --- a/xml/System.Security.Cryptography.Xml/Reference.xml +++ b/xml/System.Security.Cryptography.Xml/Reference.xml @@ -63,7 +63,6 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -113,13 +112,11 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: The following code example demonstrates how to generate and verify a detached XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -211,7 +208,6 @@ ## Examples The following code example uses the class to sign and verify an XML document using an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: @@ -268,13 +264,11 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: The following code example demonstrates how to generate and verify a detached XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: @@ -666,7 +660,6 @@ ## Examples The following code example demonstrates how to generate and verify an enveloped XML signature using the object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography.Xml/Signature.xml b/xml/System.Security.Cryptography.Xml/Signature.xml index 02c06ab7123..6edc26c53fa 100644 --- a/xml/System.Security.Cryptography.Xml/Signature.xml +++ b/xml/System.Security.Cryptography.Xml/Signature.xml @@ -39,28 +39,26 @@ Represents the element of an XML signature. - class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the root element of an XML digital signature. The , , , and properties encapsulate the subelements of the `` element. + + For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. -## Remarks - The class represents the `` element of an XML signature defined by the XML digital signature specification. The `` element is the root element of an XML digital signature. The , , , and properties encapsulate the subelements of the `` element. - - For more information about the `` element, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -94,21 +92,19 @@ Initializes a new instance of the class. - class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -149,11 +145,11 @@ The to be added to the list of objects to be signed. Adds a to the list of objects to be signed. - method adds a object to a collection that is accessible using the property. - + method adds a object to a collection that is accessible using the property. + ]]> @@ -192,10 +188,10 @@ Returns the XML representation of the . The XML representation of the . To be added. - The property is . - - -or- - + The property is . + + -or- + The property is . @@ -239,11 +235,11 @@ Gets or sets the ID of the current . The ID of the current . The default is . - property to add a string ID to the XML representation of the current element. The ID is used to reference the from another location. - + property to add a string ID to the XML representation of the current element. The ID is used to reference the from another location. + ]]> @@ -281,28 +277,26 @@ Gets or sets the of the current . The of the current . - property uses a object to represent the `` element of an XML digital signature. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + property uses a object to represent the `` element of an XML digital signature. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> @@ -354,10 +348,10 @@ Loads a state from an XML element. To be added. The parameter is . - The parameter does not contain a valid . - - -or- - + The parameter does not contain a valid . + + -or- + The parameter does not contain a valid . @@ -394,15 +388,15 @@ Gets or sets a list of objects to be signed. A list of objects to be signed. - property uses a collection of objects to represent the `` tag of an XML digital signature. - - You can also add a to this collection using the method. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - + property uses a collection of objects to represent the `` tag of an XML digital signature. + + You can also add a to this collection using the method. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + ]]> @@ -447,13 +441,13 @@ Gets or sets the value of the digital signature. A byte array that contains the value of the digital signature. - property uses a byte array to represent the `` element of an XML digital signature contained within. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - + property uses a byte array to represent the `` element of an XML digital signature contained within. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + ]]> @@ -498,28 +492,26 @@ Gets or sets the of the current . The of the current . - property uses the class to represent the `` element of an XML digital signature contained within. - - For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example uses the class with the class to sign and verify an XML document using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: + property uses the class to represent the `` element of an XML digital signature contained within. + + For more information about XML digital signatures, see the [W3C specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example uses the class with the class to sign and verify an XML document using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: - - The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: + + The following code example uses the class with the class to sign an object and verify an XML document using a detached signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/SignedXml.xml b/xml/System.Security.Cryptography.Xml/SignedXml.xml index 2295e750831..2a998b6108f 100644 --- a/xml/System.Security.Cryptography.Xml/SignedXml.xml +++ b/xml/System.Security.Cryptography.Xml/SignedXml.xml @@ -43,13 +43,11 @@ @@ -109,19 +107,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -176,19 +171,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -295,7 +287,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example computes and XML signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/AddObject/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/VB/example.vb" id="Snippet1"::: @@ -352,19 +343,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -427,19 +415,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -498,13 +483,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: @@ -564,13 +547,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigdetachedkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/VB/xmldsigdetachedkeyedhashalg.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigenvkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/VB/xmldsigenvkeyedhashalg.vb" id="Snippet1"::: @@ -705,7 +686,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignatureReturningKey/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/VB/exampleenvelope.vb" id="Snippet1"::: @@ -782,13 +762,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -852,13 +830,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigdetachedkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/VB/xmldsigdetachedkeyedhashalg.vb" id="Snippet1"::: The following code example shows how to sign and verify an entire XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/xmldsigenvkeyedhashalg.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/VB/xmldsigenvkeyedhashalg.vb" id="Snippet1"::: @@ -1103,13 +1079,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example uses the object when signing a resource represented by a Universal Resource Identifier (URI). This example saves the signature in a new file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: The following code example uses the object when signing an XML document. This example saves the signature in a new file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: @@ -1167,7 +1141,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to use the method to verify an XML document. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet3"::: @@ -1389,13 +1362,11 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example uses the property to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Reference/.ctor/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/VB/sample.vb" id="Snippet1"::: The following code example uses the property to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/Signature/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/XMLDSIG - Signature - Detached/VB/sample.vb" id="Snippet1"::: @@ -1695,19 +1666,16 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an entire XML document using an enveloped signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/exampleenvelope.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/VB/exampleenvelope.vb" id="Snippet1"::: The following code example shows how to sign and verify a Uniform Resource Identifier (URI) addressable object using a detached signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/CheckSignature/exampledetached.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/VB/exampledetached.vb" id="Snippet1"::: The following code example shows how to sign and verify a single element of an XML document using an enveloping signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/VB/sample.vb" id="Snippet1"::: @@ -1845,7 +1813,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: @@ -1901,7 +1868,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to call members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: @@ -2142,7 +2108,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: @@ -2196,7 +2161,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: @@ -2250,7 +2214,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NWithCommentsTransformUrl/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: @@ -2835,7 +2798,6 @@ The following code example shows how to sign and verify a single element of an X ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml index 47efb851fbb..8a93344fca1 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigBase64Transform.xml @@ -39,24 +39,23 @@ Represents the decoding transform as defined in Section 6.6.2 of the XMLDSIG specification. - object when you need to sign the raw data associated with the encoded content of an element. - - The Uniform Resource Identifier (URI) that describes the object is defined by the field. - - For more information about the `Base64` decoding transform, see Section 6.6.2 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - The following code example demonstrates how to use members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet2"::: + object when you need to sign the raw data associated with the encoded content of an element. + + The Uniform Resource Identifier (URI) that describes the object is defined by the field. + + For more information about the `Base64` decoding transform, see Section 6.6.2 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + The following code example demonstrates how to use members of the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet2"::: + ]]> @@ -89,15 +88,14 @@ Initializes a new instance of the class. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet1"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet1"::: + ]]> @@ -180,20 +178,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates the use of the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet7"::: + . + + + +## Examples + The following code example demonstrates the use of the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet7"::: + ]]> @@ -234,20 +231,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet8"::: + ]]> The parameter is not a object. @@ -285,20 +281,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet4"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet4"::: + ]]> @@ -338,11 +333,11 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element; this method is not supported because the object has no inner XML elements. - object has no inner XML elements. - + object has no inner XML elements. + ]]> @@ -382,20 +377,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet11"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet11"::: + ]]> The parameter is a and it is . @@ -433,20 +427,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - is the only valid output type for object. - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet5"::: + is the only valid output type for object. + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml index a9285019cab..0c8b1aa7973 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigC14NTransform.xml @@ -39,38 +39,36 @@ Represents the C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), without comments. - class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest (used to create a digital signature) using the canonical form of an XML document. A recipient can then verify the XML digital signature using the same canonical form of the XML document with the same transform. + + Use the class when you need to sign an XML document that does not contain comments. + + In most cases, a new instance of a canonicalization transform class is not required. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field and the field. + + You would only need to create a new instance of a canonicalization transform class for manually hashing an XML document or for using your own canonicalization algorithm. + + For more information about the C14N transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign non-XML data using a detached signature. Example #1 creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to call members of the class. + + **Example #1** -## Remarks - The class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest (used to create a digital signature) using the canonical form of an XML document. A recipient can then verify the XML digital signature using the same canonical form of the XML document with the same transform. - - Use the class when you need to sign an XML document that does not contain comments. - - In most cases, a new instance of a canonicalization transform class is not required. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field and the field. - - You would only need to create a new instance of a canonicalization transform class for manually hashing an XML document or for using your own canonicalization algorithm. - - For more information about the C14N transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign non-XML data using a detached signature. Example #1 creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to call members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigdetach.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/VB/xmldsigdetach.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -112,15 +110,14 @@ Initializes a new instance of the class. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet3"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet3"::: + ]]> @@ -158,15 +155,14 @@ to include comments; otherwise, . Initializes a new instance of the class with comments, if specified. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet1"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet1"::: + ]]> @@ -292,20 +288,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -346,20 +341,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet9"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet9"::: + ]]> The parameter is not a object. @@ -397,20 +391,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet5"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet5"::: + ]]> @@ -450,11 +443,11 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element; this method is not supported because this element has no inner XML elements. - object has no inner XML elements. - + object has no inner XML elements. + ]]> @@ -494,20 +487,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet12"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet12"::: + ]]> The parameter is a object and it is . @@ -545,20 +537,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp" id="Snippet6"::: + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigC14NTransformUrl/members.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/VB/members.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml index f8eb1988d24..90aa02fec8e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform.xml @@ -33,38 +33,36 @@ Represents the C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), with comments. - class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest using the canonical form of an XML document. A recipient can then verify the digital signature using the same canonical form of the XML document with the same transform. + + Use the class when you need to sign an XML document that contains comments. + + Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field. + + The URI that describes the class is defined by the field and the field. + + For more information about the C14N with comments transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. This example creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to sign an XML file using an envelope signature. This example creates a signature of an XML file and then saves the signature in new XML file. + + **Example #1** -## Remarks - The class represents the C14N XML canonicalization transform that describes the canonical form of an XML document. This transform allows a signer to create a digest using the canonical form of an XML document. A recipient can then verify the digital signature using the same canonical form of the XML document with the same transform. - - Use the class when you need to sign an XML document that contains comments. - - Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field. - - The URI that describes the class is defined by the field and the field. - - For more information about the C14N with comments transform, see Sections 6.5 and 6.6.1 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/TR/xml-c14n). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using a detached signature. This example creates a signature of `www.microsoft.com` in an XML file and then verifies the file. The second example demonstrates how to sign an XML file using an envelope signature. This example creates a signature of an XML file and then saves the signature in new XML file. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform/Overview/sampledetached.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/VB/sampledetached.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/VB/sampledetached.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigC14NWithCommentsTransform/Overview/sampleenvelope.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/VB/sampleenvelope.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/VB/sampleenvelope.vb" id="Snippet1"::: + ]]> @@ -97,23 +95,21 @@ Initializes a new instance of the class. - diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml index 04e0f1d2913..1add160367b 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigEnvelopedSignatureTransform.xml @@ -39,34 +39,32 @@ Represents the enveloped signature transform for an XML digital signature as defined by the W3C. - class removes the `` element from an XML document before the digest is computed. With this transform, you can sign and verify all elements of an XML document except the XML digital signature elements. + + Although you can create and insert a signature into an XML document, verifying the modified document using the embedded signature will fail because the document now has additional elements. This transform removes the `` element and allows you to verify the document using its original form. + + Use the class whenever you create an enveloped signature. + + For more information about the enveloped signature transform, see Section 6.6.4 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first example demonstrates how to sign an XML file using an envelope signature. The second example demonstrates how to use members of the class. + + **Example #1** -## Remarks - The class removes the `` element from an XML document before the digest is computed. With this transform, you can sign and verify all elements of an XML document except the XML digital signature elements. - - Although you can create and insert a signature into an XML document, verifying the modified document using the embedded signature will fail because the document now has additional elements. This transform removes the `` element and allows you to verify the document using its original form. - - Use the class whenever you create an enveloped signature. - - For more information about the enveloped signature transform, see Section 6.6.4 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first example demonstrates how to sign an XML file using an envelope signature. The second example demonstrates how to use members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -108,15 +106,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp" id="Snippet2"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/KeyInfo/Overview/xmldsigenv.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/VB/xmldsigenv.vb" id="Snippet2"::: + ]]> @@ -154,15 +151,14 @@ to include comments; otherwise, . Initializes a new instance of the class with comments, if specified. - constructor with a value of `true` to include comments. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet3"::: + constructor with a value of `true` to include comments. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet3"::: + ]]> @@ -245,20 +241,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet8"::: + ]]> The containing XML document is . @@ -300,20 +295,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet9"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet9"::: + ]]> The parameter is not an object. @@ -351,20 +345,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet5"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet5"::: + ]]> @@ -404,20 +397,19 @@ An to load into the current object. Parses the specified as transform-specific content of a element and configures the internal state of the current object to match the element. - , a call to this method does not change the state of the transform. - - - -## Examples - The following code example demonstrates how to call the method using the specified object to configure the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet11"::: + , a call to this method does not change the state of the transform. + + + +## Examples + The following code example demonstrates how to call the method using the specified object to configure the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -457,20 +449,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp" id="Snippet12"::: + property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigBase64TransformUrl/members.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/VB/members.vb" id="Snippet12"::: + ]]> The parameter is . @@ -509,20 +500,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - are and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp" id="Snippet6"::: + are and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigEnvelopedSignatureTransformUrl/members.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/VB/members.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml index 0afbe64e6c0..d9545b9b92e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NTransform.xml @@ -38,32 +38,31 @@ Represents the exclusive C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), without comments. - class represents the exclusive C14N XML canonicalization transform without comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. + + Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. + + Typically, you do not create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes a transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + You are required to create a new instance of a canonicalization transform class only when you want to manually hash an XML document or use your own canonicalization algorithm. + + The URI that describes the class is defined by the field. + + The URI that describes the class is defined by the field. + + For more information about the exclusive C14N transform, see the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/2001/10/xml-exc-c14n). + + + +## Examples + The following code example shows how to sign an XML document with the class using an envelope signature. -## Remarks - The class represents the exclusive C14N XML canonicalization transform without comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. - - Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. - - Typically, you do not create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes a transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - You are required to create a new instance of a canonicalization transform class only when you want to manually hash an XML document or use your own canonicalization algorithm. - - The URI that describes the class is defined by the field. - - The URI that describes the class is defined by the field. - - For more information about the exclusive C14N transform, see the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). The canonicalization algorithm is defined in the W3C [Canonical XML specification](https://www.w3.org/2001/10/xml-exc-c14n). - - - -## Examples - The following code example shows how to sign an XML document with the class using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: + ]]> @@ -171,11 +170,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying a list of namespace prefixes to canonicalize using the standard canonicalization algorithm. - @@ -215,11 +214,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying whether to include comments, and specifying a list of namespace prefixes. - @@ -374,19 +373,19 @@ Returns the output of the current object as an object of the specified type. The output of the current object as an object of the specified type. - method returns the output of the current transform after it is run on the value previously set by a call to the method. - - The type of the returned object must be one of the type objects in the property. - + method returns the output of the current transform after it is run on the value previously set by a call to the method. + + The type of the returned object must be one of the type objects in the property. + ]]> - The parameter is not a object. - - -or- - + The parameter is not a object. + + -or- + The parameter does not derive from a object. @@ -428,20 +427,19 @@ Gets or sets a string that contains namespace prefixes to canonicalize using the standard canonicalization algorithm. A string that contains namespace prefixes to canonicalize using the standard canonicalization algorithm. - property contains a white-space delimited list of namespace prefixes to canonicalize using the standard canonicalization algorithm rather than the exclusive canonicalization algorithm. To specify the default namespace, which does not have a prefix, pass the special prefix "#default". - - - -## Examples - The following code example shows how to sign an XML document with the class using an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp" id="Snippet1"::: + property contains a white-space delimited list of namespace prefixes to canonicalize using the standard canonicalization algorithm rather than the exclusive canonicalization algorithm. To specify the default namespace, which does not have a prefix, pass the special prefix "#default". + + + +## Examples + The following code example shows how to sign an XML document with the class using an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NTransformUrl/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/VB/example.vb" id="Snippet1"::: + ]]> @@ -477,13 +475,13 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - property must contain at least one element because every object must accept at least one type as valid input. - - A object typically accepts one or more of the following types as input: , , or . - + property must contain at least one element because every object must accept at least one type as valid input. + + A object typically accepts one or more of the following types as input: , , or . + ]]> @@ -522,11 +520,11 @@ An object that specifies transform-specific content for the current object. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - ` element. - + ` element. + ]]> @@ -565,21 +563,21 @@ The input to load into the current object. When overridden in a derived class, loads the specified input into the current object. - property. - + property. + ]]> - The parameter is not a object. - - -or- - - The parameter is not an object. - - -or- - + The parameter is not a object. + + -or- + + The parameter is not an object. + + -or- + The parameter is not an object. @@ -614,11 +612,11 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - property must contain at least one element because every transform must generate at least one type as output. - + property must contain at least one element because every transform must generate at least one type as output. + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml index f822414059f..af6326dd634 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigExcC14NWithCommentsTransform.xml @@ -32,28 +32,27 @@ Represents the exclusive C14N XML canonicalization transform for a digital signature as defined by the World Wide Web Consortium (W3C), with comments. - class represents the exclusive C14N XML canonicalization transform with comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. + + Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. + + Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. + + The URI that describes the class is defined by the field. + + For more information about the exclusive C14N transform, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/), which is available from the W3C website. The canonicalization algorithm is defined in the [W3C Canonical XML specification](https://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/). + + + +## Examples + The following code example shows how to sign and verify an XML document using the class. This example creates an envelope signature. -## Remarks - The class represents the exclusive C14N XML canonicalization transform with comments. This class is similar to the class, which allows a signer to create a digest using the canonical form of an XML document. However, the class excludes ancestor context from a canonicalized subdocument. - - Use the class when you need to canonicalize an XML subdocument so that it is independent from its XML context. For example, applications such as Web services that use signed XML within complex communication protocols often need to canonicalize XML in this manner. Such applications often envelop XML within various dynamically constructed elements, which can substantially change the document and cause XML signature verification to fail. The class solves this problem by excluding such ancestor context from the canonical subdocument. - - Note that you cannot directly create a new instance of a canonicalization transform class. To specify a canonicalization transform, pass the Uniform Resource Identifier (URI) that describes the transform to the property, which is accessible from the property. To acquire a reference to the canonicalization transform, use the property, which is accessible from the property. - - The URI that describes the class is defined by the field. - - For more information about the exclusive C14N transform, see the [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/), which is available from the W3C website. The canonicalization algorithm is defined in the [W3C Canonical XML specification](https://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718/). - - - -## Examples - The following code example shows how to sign and verify an XML document using the class. This example creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigExcC14NWithCommentsTransformUrl/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -127,11 +126,11 @@ The namespace prefixes to canonicalize using the standard canonicalization algorithm. Initializes a new instance of the class specifying a list of namespace prefixes to canonicalize using the standard canonicalization algorithm. - diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml index 3f55561aeaf..0d721177d4b 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigXPathTransform.xml @@ -39,33 +39,32 @@ Represents the XPath transform for a digital signature as defined by the W3C. - class allows you to address an XML document using the XPath language. This class uses an XPath expression to select the XML nodes you want to sign or encrypt while removing all others from either cryptographic operation. + + Use the class to sign or encrypt specific parts of an XML document using an XPath expression. For information on initializing the class to the value of an XPath transform string, see the method. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + For more information about the XPath transform, see Section 6.6.3 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. This example signs an XML document and saves the signature in a new XML document. The second code example demonstrates how to call members of the class. + + **Example #1** -## Remarks - The class allows you to address an XML document using the XPath language. This class uses an XPath expression to select the XML nodes you want to sign or encrypt while removing all others from either cryptographic operation. - - Use the class to sign or encrypt specific parts of an XML document using an XPath expression. For information on initializing the class to the value of an XPath transform string, see the method. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - For more information about the XPath transform, see Section 6.6.3 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. This example signs an XML document and saves the signature in a new XML document. The second code example demonstrates how to call members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - - **Example #2** - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -98,15 +97,14 @@ Initializes a new instance of the class. - class. This example creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: + class. This example creates an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -155,11 +153,11 @@ Returns the output of the current object. - method to retrieve a object that contains an XML representation of an XPath transform. - + method to retrieve a object that contains an XML representation of an XPath transform. + ]]> @@ -197,21 +195,21 @@ Returns the output of the current object. The output of the current object. - . - - Use the method to retrieve a object that contains an XML representation of an XPath transform. - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - + . + + Use the method to retrieve a object that contains an XML representation of an XPath transform. + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -252,21 +250,21 @@ Returns the output of the current object of type . The output of the current object of type . - . - - Use the method to retrieve a object that contains an XML representation of an XPath transform. - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - + . + + Use the method to retrieve a object that contains an XML representation of an XPath transform. + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet7"::: + ]]> The parameter is not an object. @@ -304,19 +302,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet4"::: + ]]> @@ -356,34 +354,33 @@ An object to load into the current object. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - method to initialize the class with an XPath transform. - - To initialize the class with an XPath transform, complete the following steps. - -1. Create a new class and set the property to the value of an XPath transform string. - -2. Call the method to create an object that represents the transform. - -3. Create a new instance of the class and pass the previously created object to the method. - - - -## Examples - The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp" id="Snippet1"::: + method to initialize the class with an XPath transform. + + To initialize the class with an XPath transform, complete the following steps. + +1. Create a new class and set the property to the value of an XPath transform string. + +2. Call the method to create an object that represents the transform. + +3. Create a new instance of the class and pass the previously created object to the method. + + + +## Examples + The following code example shows how to sign and verify an XML document using the class. This sample creates an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXPathTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/VB/sample.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter does not contain an element. @@ -422,21 +419,21 @@ The input to load into the current object. Loads the specified input into the current object. - method to initialize an object to the value of an XPath transform using an , , or object. For information about initializing an object using an XPath transform string, see the method. - - The type of the input object must be one of the types in the property. - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - + method to initialize an object to the value of an XPath transform using an , , or object. For information about initializing an object using an XPath transform string, see the method. + + The type of the input object must be one of the types in the property. + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -473,19 +470,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; the methods of the current object return only objects of one of these types. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXPathTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXPathTransform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml b/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml index e5cca544101..aefb402df9e 100644 --- a/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlDsigXsltTransform.xml @@ -43,34 +43,32 @@ Represents the XSLT transform for a digital signature as defined by the W3C. - class allows you to address an XML document using an XSLT transformation. This class uses XSLT to transform XML nodes into other XML nodes that you want to sign or encrypt. + + Use the class to sign or encrypt specific parts of an XML document using an XSLT transformation. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + For more information about the XSLT transform, see Section 6.6.5 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). + + + +## Examples + This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. The second code example demonstrates how to use members of the class. + + **Example #1** -## Remarks - The class allows you to address an XML document using an XSLT transformation. This class uses XSLT to transform XML nodes into other XML nodes that you want to sign or encrypt. - - Use the class to sign or encrypt specific parts of an XML document using an XSLT transformation. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - For more information about the XSLT transform, see Section 6.6.5 of the W3C [XMLDSIG specification](https://www.w3.org/TR/xmldsig-core/). - - - -## Examples - This section contains two code examples. The first code example shows how to sign and verify an XML document using the class with an envelope signature. The second code example demonstrates how to use members of the class. - - **Example #1** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - - **Example #2** - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + + **Example #2** + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet2"::: + ]]> @@ -112,15 +110,14 @@ Initializes a new instance of the class. - class with an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: + class with an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + ]]> @@ -238,20 +235,19 @@ Returns the output of the current object. The output of the current object. - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet8"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet8"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet8"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet8"::: + ]]> @@ -292,20 +288,19 @@ Returns the output of the current object of type . The output of the current object of type . - . - - - -## Examples - The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet7"::: + . + + + +## Examples + The following code example demonstrates how to use the method to retrieve the output of the current object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet7"::: + ]]> The parameter is not a object. @@ -343,20 +338,19 @@ Gets an array of types that are valid inputs to the method of the current object. An array of valid input types for the current object; you can pass only objects of one of these types to the method of the current object. - are , , and . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet4"::: + are , , and . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid input types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet4"::: + ]]> @@ -396,26 +390,25 @@ An object that encapsulates an XSLT style sheet to load into the current object. This style sheet is applied to the document loaded by the method. Parses the specified object as transform-specific content of a element and configures the internal state of the current object to match the element. - ` element. - - - -## Examples - The following code example shows how to sign and verify an XML document using the class with an envelope signature. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp" id="Snippet1"::: + ` element. + + + +## Examples + The following code example shows how to sign and verify an XML document using the class with an envelope signature. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/XmlDsigXsltTransform/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/VB/sample.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter does not contain an object. @@ -454,20 +447,19 @@ The input to load into the current object. Loads the specified input into the current object. - property. The valid input types to are , , and . - - - -## Examples - The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet11"::: + property. The valid input types to are , , and . + + + +## Examples + The following code example demonstrates how to call the method using the specified object as the input. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet11"::: + ]]> @@ -504,20 +496,19 @@ Gets an array of types that are possible outputs from the methods of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - is the only valid output type for . - - - -## Examples - The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp" id="Snippet5"::: + is the only valid output type for . + + + +## Examples + The following code example demonstrates how to call the property to retrieve the valid output types for the current transform. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/SignedXml/XmlDsigXsltTransformUrl/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml b/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml index f3164da70eb..e2bfff26bc5 100644 --- a/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml +++ b/xml/System.Security.Cryptography.Xml/XmlLicenseTransform.xml @@ -46,24 +46,23 @@ Represents the license transform algorithm used to normalize XrML licenses for signatures. - class represents the license transform algorithm as defined in the MPEG Rights Extension Language (MPEG REL). + + Use the class to transform XrML licenses for signatures. + + The Uniform Resource Identifier (URI) that describes the class is defined by the field. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. -## Remarks - The class represents the license transform algorithm as defined in the MPEG Rights Extension Language (MPEG REL). - - Use the class to transform XrML licenses for signatures. - - The Uniform Resource Identifier (URI) that describes the class is defined by the field. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -135,20 +134,19 @@ Gets or sets the decryptor of the current object. The decryptor of the current object. - object uses an interface to decrypt `` elements from the current `` element. - - - -## Examples - The following code example shows how to validate an XML digital signature using the interface and the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp" id="Snippet2"::: + object uses an interface to decrypt `` elements from the current `` element. + + + +## Examples + The following code example shows how to validate an XML digital signature using the interface and the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography.Xml/IRelDecryptor/Overview/sample.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/VB/sample.vb" id="Snippet2"::: + ]]> @@ -229,11 +227,11 @@ Returns the output of an object. The output of the object. - . - + . + ]]> @@ -307,11 +305,11 @@ Gets an array of types that are valid inputs to the method of the current object. An array of types that are valid inputs to the method of the current object; you can pass only objects of one of these types to the method of the current object. - class is . - + class is . + ]]> @@ -386,18 +384,18 @@ The input to load into the current object. The type of the input object must be . Loads the specified input into the current object. To be added. - The context was not set before this transform was invoked. - - -or- - - The element was not set before this transform was invoked. - - -or- - - The element was not set before this transform was invoked. - - -or- - + The context was not set before this transform was invoked. + + -or- + + The element was not set before this transform was invoked. + + -or- + + The element was not set before this transform was invoked. + + -or- + The property was not set before this transform was invoked. @@ -432,11 +430,11 @@ Gets an array of types that are valid outputs from the method of the current object. An array of valid output types for the current object; only objects of one of these types are returned from the methods of the current object. - class is . - + class is . + ]]> diff --git a/xml/System.Security.Cryptography/AsnEncodedData.xml b/xml/System.Security.Cryptography/AsnEncodedData.xml index 7fc54f4baa8..9a03018f897 100644 --- a/xml/System.Security.Cryptography/AsnEncodedData.xml +++ b/xml/System.Security.Cryptography/AsnEncodedData.xml @@ -69,7 +69,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -136,7 +135,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -272,7 +270,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -339,7 +336,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -437,7 +433,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -541,7 +536,6 @@ ## Examples The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -615,7 +609,6 @@ extension.Format(true); class. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: ]]> @@ -685,7 +678,6 @@ The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: @@ -751,7 +743,6 @@ The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml b/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml index 6b22cf06753..b805bcd1b11 100644 --- a/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml +++ b/xml/System.Security.Cryptography/AsnEncodedDataCollection.xml @@ -64,20 +64,19 @@ Represents a collection of objects. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -120,15 +119,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -223,15 +221,14 @@ Adds an object to the object. The index of the added object. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -290,20 +287,19 @@ One of the OIDs is and the OIDs do not match.The location where the copy operation starts. Copies the object into an array. - object into an array. The copying begins at the specified index location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object into an array. The copying begins at the specified index location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -353,20 +349,19 @@ One of the OIDs is and the OIDs do not match.Gets the number of objects in a collection. The number of objects. - objects the collection contains. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + objects the collection contains. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -414,20 +409,19 @@ One of the OIDs is and the OIDs do not match.Returns an object that can be used to navigate the object. An object. - class implements the interface, which allows you to move within a collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class implements the interface, which allows you to move within a collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -477,20 +471,19 @@ One of the OIDs is and the OIDs do not match. in all cases. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -541,20 +534,19 @@ One of the OIDs is and the OIDs do not match.Gets an object from the object. An object. - object from an object, if you know its location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object from an object, if you know its location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -604,15 +596,14 @@ One of the OIDs is and the OIDs do not match.The object to remove. Removes an object from the object. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -663,20 +654,19 @@ One of the OIDs is and the OIDs do not match.Gets an object that can be used to synchronize access to the object. An object used to synchronize access to the object. - is not thread safe. Derived classes can provide their own synchronized version of the using this property. The synchronizing code must perform operations on the property of the class, not directly on the class itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + is not thread safe. Derived classes can provide their own synchronized version of the using this property. The synchronizing code must perform operations on the property of the class, not directly on the class itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might be simultaneously modifying the object. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -731,18 +721,18 @@ One of the OIDs is and the OIDs do not match.The location where the copy operation starts. Copies the object into an array. - object into an array. The copying begins at the index location specified. - + object into an array. The copying begins at the index location specified. + ]]> is a multidimensional array, which is not supported by this method. -or- - + The length for is invalid. is . @@ -878,11 +868,11 @@ This member is an explicit interface member implementation. It can be used only Returns an object that can be used to navigate the object. An object that can be used to navigate the collection. - class implements the interface, which allows you to move within a collection. - + class implements the interface, which allows you to move within a collection. + ]]> diff --git a/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml b/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml index 76cb1f49681..8c093daad06 100644 --- a/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml +++ b/xml/System.Security.Cryptography/AsnEncodedDataEnumerator.xml @@ -61,20 +61,19 @@ Provides the ability to navigate through an object. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -121,24 +120,23 @@ Gets the current object in an object. The current object in the collection. - method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. - - also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. - - does not move the position of the enumerator, and consecutive calls to return the same object until is called. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. + + also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. + + does not move the position of the enumerator, and consecutive calls to return the same object until is called. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> @@ -190,24 +188,23 @@ , if the enumerator was successfully advanced to the next element; , if the enumerator has passed the end of the collection. - method moves the enumerator over the first element of the collection. Subsequent calls to advance the enumerator past subsequent elements. - - After the end of the collection is passed, calls to return `false`. - - An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to can throw an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + method moves the enumerator over the first element of the collection. Subsequent calls to advance the enumerator past subsequent elements. + + After the end of the collection is passed, calls to return `false`. + + An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to can throw an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. @@ -258,20 +255,19 @@ Sets an enumerator to its initial position. - object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid, and the next call to the method throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp" id="Snippet1"::: + object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid, and the next call to the method throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsnEncodedData/Overview/asnencodeddata.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.AsnEncodedData/VB/asnencodeddata.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml b/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml index 1c3adbd5446..9cf1043c850 100644 --- a/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml +++ b/xml/System.Security.Cryptography/AsymmetricAlgorithm.xml @@ -62,42 +62,40 @@ Represents the abstract base class from which all implementations of asymmetric algorithms must inherit. - class is an implementation of a public-key algorithm. For an in-depth discussion of public-key encryption and algorithms, see the "Public-Key Encryption" section in [Cryptographic Services](/dotnet/standard/security/cryptographic-services). For information about how to use the Strong Name tool (Sn.exe) to create key pairs, see [How to: Create a Public-Private Key Pair](/dotnet/standard/assembly/create-public-private-key-pair). - - You can use public-key systems to form digital signatures. Digital signatures are used to help to protect the integrity of data. For example, 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 matches the message digest received from the sender, the receiver can assume that the message was not altered while in transit. Note that anyone can verify a signature, because the sender's public key is common knowledge. This technique does not retain the secrecy of the message; for the message to be secret, it must also be encrypted. - - The .NET Framework provides the following classes that implement digital signature algorithms: , , (base class), and . - - The namespace provides concrete classes for and only. - - To learn how to use the RSA algorithm to encrypt and decrypt XML data, and create and verify XML digital signatures, see these articles: - -- [How to: Encrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-encrypt-xml-elements-with-asymmetric-keys) - -- [How to: Decrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-decrypt-xml-elements-with-asymmetric-keys) - -- [How to: Sign XML Documents with Digital Signatures](/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures) - -- [How to: Verify the Digital Signatures of XML Documents](/dotnet/standard/security/how-to-verify-the-digital-signatures-of-xml-documents) - - - -## Examples - The following code example demonstrates how to implement a custom asymmetric algorithm inherited from the class. An additional class is provided to demonstrate how to use the custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet2"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet2"::: - - Here's an additional class that demonstrates how to use the custom class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet3"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet3"::: - + class is an implementation of a public-key algorithm. For an in-depth discussion of public-key encryption and algorithms, see the "Public-Key Encryption" section in [Cryptographic Services](/dotnet/standard/security/cryptographic-services). For information about how to use the Strong Name tool (Sn.exe) to create key pairs, see [How to: Create a Public-Private Key Pair](/dotnet/standard/assembly/create-public-private-key-pair). + + You can use public-key systems to form digital signatures. Digital signatures are used to help to protect the integrity of data. For example, 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 matches the message digest received from the sender, the receiver can assume that the message was not altered while in transit. Note that anyone can verify a signature, because the sender's public key is common knowledge. This technique does not retain the secrecy of the message; for the message to be secret, it must also be encrypted. + +.NET provides the following classes that implement digital signature algorithms: , , (base class), and . + + The namespace provides concrete classes for and only. + + To learn how to use the RSA algorithm to encrypt and decrypt XML data, and create and verify XML digital signatures, see these articles: + +- [How to: Encrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-encrypt-xml-elements-with-asymmetric-keys) + +- [How to: Decrypt XML Elements with Asymmetric Keys](/dotnet/standard/security/how-to-decrypt-xml-elements-with-asymmetric-keys) + +- [How to: Sign XML Documents with Digital Signatures](/dotnet/standard/security/how-to-sign-xml-documents-with-digital-signatures) + +- [How to: Verify the Digital Signatures of XML Documents](/dotnet/standard/security/how-to-verify-the-digital-signatures-of-xml-documents) + + + +## Examples + The following code example demonstrates how to implement a custom asymmetric algorithm inherited from the class. An additional class is provided to demonstrate how to use the custom class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet2"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet2"::: + + Here's an additional class that demonstrates how to use the custom class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet3"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet3"::: + ]]> Cryptographic Services @@ -143,11 +141,11 @@ Initializes a new instance of the class. - and classes are the only currently supported implementations. - + and classes are the only currently supported implementations. + ]]> The implementation of the derived class is not valid. @@ -196,22 +194,21 @@ Releases all resources used by the class. - method. - - Calling `Dispose` allows the resources used by the class to be reallocated for other purposes. For more information about `Dispose`, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged). - - - -## Examples - The following code example demonstrates how to call the method to release the resources of the current `customCrypto` object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet1"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet1"::: - + method. + + Calling `Dispose` allows the resources used by the class to be reallocated for other purposes. For more information about `Dispose`, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged). + + + +## Examples + The following code example demonstrates how to call the method to release the resources of the current `customCrypto` object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -284,19 +281,18 @@ Creates a default cryptographic object used to perform the asymmetric algorithm. A new instance, unless the default settings have been changed with the <cryptoClass> element. - method in an extended class. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet11"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet11"::: - + method in an extended class. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet11"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet11"::: + ]]> .NET Core 2.0 - 3.1 and .NET 5 and later: In all cases. @@ -366,49 +362,48 @@ This method is obsolete in .NET 5 and later versions. - The asymmetric algorithm implementation to use. The following table shows the valid values for the parameter and the algorithms they map to. - - Parameter value - - Implements - - System.Security.Cryptography.AsymmetricAlgorithm - - RSA - - System.Security.Cryptography.RSA - - DSA - - System.Security.Cryptography.DSA - - ECDsa - - ECDsaCng - - System.Security.Cryptography.ECDsaCng - - ECDH - - ECDiffieHellman - - ECDiffieHellmanCng - - System.Security.Cryptography.ECDiffieHellmanCng - + The asymmetric algorithm implementation to use. The following table shows the valid values for the parameter and the algorithms they map to. + + Parameter value + + Implements + + System.Security.Cryptography.AsymmetricAlgorithm + + RSA + + System.Security.Cryptography.RSA + + DSA + + System.Security.Cryptography.DSA + + ECDsa + + ECDsaCng + + System.Security.Cryptography.ECDsaCng + + ECDH + + ECDiffieHellman + + ECDiffieHellmanCng + + System.Security.Cryptography.ECDiffieHellmanCng + Creates an instance of the specified implementation of an asymmetric algorithm. A new instance of the specified asymmetric algorithm implementation. - method in an extended class. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet12"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet12"::: - + method in an extended class. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet12"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet12"::: + ]]> Cryptographic Services @@ -468,16 +463,16 @@ This method is obsolete in .NET 5 and later versions. Releases all resources used by the current instance of the class. - . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. - - For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). - -> [!NOTE] -> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. - + . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. + + For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). + +> [!NOTE] +> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. + ]]> @@ -533,19 +528,19 @@ This method is obsolete in .NET 5 and later versions. to release both managed and unmanaged resources; to release only unmanaged resources. Releases the unmanaged resources used by the class and optionally releases the managed resources. - method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. - - When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. - + method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. + + When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. + ]]> - can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. - + can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. + For more information about and , see Cleaning Up Unmanaged Resources. Cryptographic Services @@ -597,19 +592,19 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password. A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key. - - The key could not be exported. - --or- - - indicates that should be used, which requires -based passwords. + The key could not be exported. + +-or- + + indicates that should be used, which requires -based passwords. @@ -660,11 +655,11 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password. A byte array containing the PKCS#8 EncryptedPrivateKeyInfo representation of this key. - The key could not be exported. @@ -711,12 +706,12 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a byte-based password, PEM encoded. A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo. - A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. + A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. - The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. + The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -762,24 +757,24 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 EncryptedPrivateKeyInfo format with a char-based password, PEM encoded. A string containing the PEM-encoded PKCS#8 EncryptedPrivateKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -852,21 +847,21 @@ This method is obsolete in .NET 5 and later versions. Exports the current key in the PKCS#8 PrivateKeyInfo format, PEM encoded. A string containing the PEM-encoded PKCS#8 PrivateKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -937,22 +932,22 @@ This method is obsolete in .NET 5 and later versions. Exports the public-key portion of the current key in the X.509 SubjectPublicKeyInfo format, PEM encoded. A string containing the PEM-encoded X.509 SubjectPublicKeyInfo. - - An implementation for or + An implementation for or has not been provided. The key could not be exported. @@ -1006,15 +1001,14 @@ This method is obsolete in .NET 5 and later versions. The XML string to use to reconstruct the object. When overridden in a derived class, reconstructs an object from an XML string. Otherwise, throws a . - method to parse the specified XML string to populate the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet4"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet4"::: - + method to parse the specified XML string to populate the current object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet4"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet4"::: + ]]> Cryptographic Services @@ -1060,40 +1054,40 @@ This method is obsolete in .NET 5 and later versions. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a byte-based password, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The password is incorrect. - --or- - -The contents of indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires -based passwords. - --or- - -The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The password is incorrect. + +-or- + +The contents of indicate the Key Derivation Function (KDF) to apply is the legacy PKCS#12 KDF, which requires -based passwords. + +-or- + +The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1138,35 +1132,35 @@ The algorithm-specific key import failed. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overridden in a derived class, imports the public/private keypair from a PKCS#8 EncryptedPrivateKeyInfo structure after decrypting with a char-based password, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The password is incorrect. - --or- - -The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The password is incorrect. + +-or- + +The contents of do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1206,45 +1200,45 @@ The algorithm-specific key import failed. The bytes to use as a password when decrypting the key material. When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. - - - The password is incorrect. - --or- - -The base-64 decoded contents of the PEM text from - do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The base-64 decoded contents of the PEM text from - indicate the key is for an algorithm other than the algorithm - represented by this instance. - --or- - -The base-64 decoded contents of the PEM text from - represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + + + The password is incorrect. + +-or- + +The base-64 decoded contents of the PEM text from + do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The base-64 decoded contents of the PEM text from + indicate the key is for an algorithm other than the algorithm + represented by this instance. + +-or- + +The base-64 decoded contents of the PEM text from + represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. @@ -1283,45 +1277,45 @@ The algorithm-specific key import failed. The password to use for decrypting the key material. When overridden in a derived class, imports an encrypted RFC 7468 PEM-encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. - - - The password is incorrect. - --or- - -The base-64 decoded contents of the PEM text from - do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. - --or- - -The base-64 decoded contents of the PEM text from - indicate the key is for an algorithm other than the algorithm - represented by this instance. - --or- - -The base-64 decoded contents of the PEM text from - represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + + + The password is incorrect. + +-or- + +The base-64 decoded contents of the PEM text from + do not represent an ASN.1-BER-encoded PKCS#8 EncryptedPrivateKeyInfo structure. + +-or- + +The base-64 decoded contents of the PEM text from + indicate the key is for an algorithm other than the algorithm + represented by this instance. + +-or- + +The base-64 decoded contents of the PEM text from + represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. @@ -1358,25 +1352,25 @@ The algorithm-specific key import failed. The text of the PEM key to import. When overridden in a derived class, imports an RFC 7468 textually encoded key, replacing the keys for this object. - . - + . + ]]> A derived type has not overridden this member. - does not contain a PEM-encoded key with a recognized label. - --or- - - contains multiple PEM-encoded keys with a recognized label. - --or- - - contains an encrypted PEM-encoded key. + does not contain a PEM-encoded key with a recognized label. + +-or- + + contains multiple PEM-encoded keys with a recognized label. + +-or- + + contains an encrypted PEM-encoded key. @@ -1418,29 +1412,29 @@ Because each algorithm may have algorithm-specific PEM labels, the default behav When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overriden in a derived class, imports the public/private keypair from a PKCS#8 PrivateKeyInfo structure after decryption, replacing the keys for this object. - throws a by default. - + throws a by default. + ]]> - The contents of do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The contents of do not represent an ASN.1-BER-encoded PKCS#8 PrivateKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1483,28 +1477,28 @@ The algorithm-specific key import failed. When this method returns, contains a value that indicates the number of bytes read from . This parameter is treated as uninitialized. When overriden in a derived class, imports the public key from an X.509 SubjectPublicKeyInfo structure after decryption, replacing the keys for this object. - throws a by default. + throws a by default. ]]> - The contents of do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure. - --or- - -The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. - --or- - -The contents of represent the key in a format that is not supported. - --or- - -The algorithm-specific key import failed. + The contents of do not represent an ASN.1-DER-encoded X.509 SubjectPublicKeyInfo structure. + +-or- + +The contents of indicate the key is for an algorithm other than the algorithm represented by this instance. + +-or- + +The contents of represent the key in a format that is not supported. + +-or- + +The algorithm-specific key import failed. A derived type has not overriden this member. @@ -1561,15 +1555,14 @@ The algorithm-specific key import failed. When overridden in a derived class, gets the name of the key exchange algorithm. Otherwise, throws an . The name of the key exchange algorithm. - property to return the name for the key exchange algorithm. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet6"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet6"::: - + property to return the name for the key exchange algorithm. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet6"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet6"::: + ]]> Cryptographic Services @@ -1618,20 +1611,19 @@ The algorithm-specific key import failed. 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. - property. - - - -## Examples - The following code example demonstrates how to override the property to verify that it falls within the range identified in the local `keySizes` member variable. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet9"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet9"::: - + property. + + + +## Examples + The following code example demonstrates how to override the property to verify that it falls within the range identified in the local `keySizes` member variable. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet9"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet9"::: + ]]> The key modulus size is invalid. @@ -1680,13 +1672,13 @@ The algorithm-specific key import failed. Represents the size, in bits, of the key modulus used by the asymmetric algorithm. - property. - - This field is accessed through the property. - + property. + + This field is accessed through the property. + ]]> Cryptographic Services @@ -1741,20 +1733,19 @@ The algorithm-specific key import failed. Gets the key sizes that are supported by the asymmetric algorithm. An array that contains the key sizes supported by the asymmetric algorithm. - property to retrieve the , , and properties. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp" id="Snippet10"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet10"::: - + property to retrieve the , , and properties. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet10"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet10"::: + ]]> Cryptographic Services @@ -1812,13 +1803,13 @@ The algorithm-specific key import failed. Specifies the key sizes that are supported by the asymmetric algorithm. - property. - + property. + ]]> Cryptographic Services @@ -1876,15 +1867,14 @@ The algorithm-specific key import failed. When implemented in a derived class, gets the name of the signature algorithm. Otherwise, always throws a . The name of the signature algorithm. - property to return the name of the signature algorithm. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet7"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet7"::: - + property to return the name of the signature algorithm. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet7"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet7"::: + ]]> Cryptographic Services @@ -1922,11 +1912,11 @@ The algorithm-specific key import failed. For a description of this member, see . - instance is cast to an interface. - + instance is cast to an interface. + ]]> @@ -1984,15 +1974,14 @@ This member is an explicit interface member implementation. It can be used only When overridden in a derived class, creates and returns an XML string representation of the current object. Otherwise, throws a . An XML string encoding of the current object. - method to create an XML representation of the parameters in the current object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp" id="Snippet5"::: - :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet5"::: - + method to create an XML representation of the parameters in the current object. This code example is part of a larger example provided for the class. + + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/AsymmetricAlgorithm/Overview/customcrypto.cs" id="Snippet5"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/VB/customcrypto.vb" id="Snippet5"::: + ]]> Cryptographic Services @@ -2049,21 +2038,21 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> - The key could not be exported. - --or- - - indicates that should be used, which requires -based passwords. + The key could not be exported. + +-or- + + indicates that should be used, which requires -based passwords. A derived type has not overriden this member. @@ -2120,13 +2109,13 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2179,12 +2168,12 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. + A PEM-encoded PKCS#8 EncryptedPrivateKeyInfo will begin with -----BEGIN ENCRYPTED PRIVATE KEY----- and end with -----END ENCRYPTED PRIVATE KEY-----, with the base64 encoded DER contents of the key between the PEM boundaries. - The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. + The PEM is encoded according to the IETF RFC 7468 "strict" encoding rules. - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2235,25 +2224,25 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2298,11 +2287,11 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2345,20 +2334,20 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. @@ -2403,11 +2392,11 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - throws a by default. - + throws a by default. + ]]> The key could not be exported. @@ -2450,23 +2439,23 @@ This member is an explicit interface member implementation. It can be used only if is big enough to receive the output; otherwise, . - - An implementation for + An implementation for has not been provided. The key could not be exported. diff --git a/xml/System.Security.Cryptography/CryptoConfig.xml b/xml/System.Security.Cryptography/CryptoConfig.xml index 0c7ca1c956e..b450e7387b5 100644 --- a/xml/System.Security.Cryptography/CryptoConfig.xml +++ b/xml/System.Security.Cryptography/CryptoConfig.xml @@ -115,7 +115,6 @@ ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet1"::: @@ -453,7 +452,6 @@ ## Examples The following code example demonstrates how to call the method to create a new SHA-1 provider. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet4"::: @@ -550,7 +548,6 @@ ## Examples The following code example demonstrates how to call the method to initialize a new RSA provider instance accessing the `TestContainer` key container. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet5"::: @@ -626,7 +623,6 @@ ## Examples The following code example demonstrates how to call the method to encode the specified object identifier. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet6"::: @@ -708,7 +704,6 @@ ## Examples The following code example demonstrates how to call the method to retrieve an object identifier (OID) from the string name of the SHA-1 algorithm. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptoConfig/Overview/members.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/VB/members.vb" id="Snippet3"::: diff --git a/xml/System.Security.Cryptography/CryptographicException.xml b/xml/System.Security.Cryptography/CryptographicException.xml index fa97ca92020..0bd492633e5 100644 --- a/xml/System.Security.Cryptography/CryptographicException.xml +++ b/xml/System.Security.Cryptography/CryptographicException.xml @@ -78,22 +78,21 @@ The exception that is thrown when an error occurs during a cryptographic operation. - uses the HRESULT CORSEC_E_CRYPTO, unless an alternate error code is specified. + + For a list of initial property values for an instance of , see the constructor. + + + +## Examples + The following code example demonstrates how to use members of the class. -## Remarks - uses the HRESULT CORSEC_E_CRYPTO, unless an alternate error code is specified. - - For a list of initial property values for an instance of , see the constructor. - - - -## Examples - The following code example demonstrates how to use members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet2"::: + ]]> @@ -149,25 +148,24 @@ Initializes a new instance of the class with default properties. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - - - -## Examples - The following code example demonstrates how to construct a with no parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet1"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + + + +## Examples + The following code example demonstrates how to construct a with no parameters. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet1"::: + ]]> @@ -221,27 +219,26 @@ The error code. Initializes a new instance of the class with the specified error code. - constructor accepts a system `HRESULT` error code and sets the property to a localized message that corresponds to the `HRESULT`. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The localized error message string.| - - - -## Examples - The following code example demonstrates how to construct a using an error code for an . This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet3"::: + constructor accepts a system `HRESULT` error code and sets the property to a localized message that corresponds to the `HRESULT`. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The localized error message string.| + + + +## Examples + The following code example demonstrates how to construct a using an error code for an . This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet3"::: + ]]> @@ -290,25 +287,24 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a custom error message. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet4"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a custom error message. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet4"::: + ]]> @@ -371,11 +367,11 @@ The contextual information about the source or destination. Initializes a new instance of the class with serialized data. - @@ -426,27 +422,26 @@ The exception that is the cause of the current exception. If the parameter is not , the current exception is raised in a block that handles the inner exception. Initializes a new instance of the class with a specified error message and a reference to the inner exception that is the cause of this exception. - property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. - - The following table shows the initial property values for an instance of . - -|Property|Value| -|--------------|-----------| -||The inner exception reference.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a custom error message and an inner exception. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet5"::: + property. The property returns the same value that is passed into the constructor, or `null` if the property does not supply the inner exception value to the constructor. + + The following table shows the initial property values for an instance of . + +|Property|Value| +|--------------|-----------| +||The inner exception reference.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a custom error message and an inner exception. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet5"::: + ]]> @@ -513,25 +508,24 @@ The error message that explains the reason for the exception. Initializes a new instance of the class with a specified error message in the specified format. - . - -|Property|Value| -|--------------|-----------| -||`null`.| -||The error message string.| - - - -## Examples - The following code example demonstrates how to construct a using a time format and the current date. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp" id="Snippet6"::: + . + +|Property|Value| +|--------------|-----------| +||`null`.| +||The error message string.| + + + +## Examples + The following code example demonstrates how to construct a using a time format and the current date. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CryptographicException/Overview/cryptographicexceptionmembers.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/VB/cryptographicexceptionmembers.vb" id="Snippet6"::: + ]]> diff --git a/xml/System.Security.Cryptography/CspKeyContainerInfo.xml b/xml/System.Security.Cryptography/CspKeyContainerInfo.xml index 401a5c33992..e7ea8795f50 100644 --- a/xml/System.Security.Cryptography/CspKeyContainerInfo.xml +++ b/xml/System.Security.Cryptography/CspKeyContainerInfo.xml @@ -66,22 +66,21 @@ Provides additional information about a cryptographic key pair. This class cannot be inherited. - or the , a key container will not be created until you call a method that uses the key. Some properties of the class will throw a if a key container has not been created. + + + +## Examples + The following code example creates a key container and retrieves information about that container. -## Remarks - Use this class to obtain additional information about a key pair, such as the key container name or the key number. - - In cases where a random key is generated by the or the , a key container will not be created until you call a method that uses the key. Some properties of the class will throw a if a key container has not been created. - - - -## Examples - The following code example creates a key container and retrieves information about that container. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: + ]]> @@ -134,15 +133,14 @@ A object that provides information about the key. Initializes a new instance of the class using the specified parameters. - @@ -196,15 +194,14 @@ if the key is accessible; otherwise, . - The key type is not supported. @@ -245,18 +242,18 @@ Gets a object that represents access rights and audit rules for a container. A object that represents access rights and audit rules for a container. - property to retrieve the object that manages the creation of discretionary access control lists (DACLS) and system access control lists (SACLS) for a container. - + property to retrieve the object that manages the creation of discretionary access control lists (DACLS) and system access control lists (SACLS) for a container. + ]]> The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -309,22 +306,21 @@ if the key can be exported; otherwise, . - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -377,15 +373,14 @@ if the key is a hardware key; otherwise, . - The cryptographic service provider cannot be found. @@ -434,15 +429,14 @@ Gets a key container name. The key container name. - @@ -489,24 +483,23 @@ Gets a value that describes whether an asymmetric key was created as a signature key or an exchange key. One of the values that describes whether an asymmetric key was created as a signature key or an exchange key. - property is derived from the field of the object that was used to initialize the object. - - An exchange key is an asymmetric key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. The value specifies an exchange key. This value corresponds to the `AT_KEYEXCHANGE` value used in the unmanaged Microsoft Cryptographic API (CAPI). - - A signature key is an asymmetric key pair used for authenticating (digitally signed) messages or files. The value specifies a signature key. This value corresponds to the `AT_SIGNATURE` value used in CAPI. - - - -## Examples - The following code example creates a key container and retrieves information about that container. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: + property is derived from the field of the object that was used to initialize the object. + + An exchange key is an asymmetric key pair used to encrypt session keys so that they can be safely stored and exchanged with other users. The value specifies an exchange key. This value corresponds to the `AT_KEYEXCHANGE` value used in the unmanaged Microsoft Cryptographic API (CAPI). + + A signature key is an asymmetric key pair used for authenticating (digitally signed) messages or files. The value specifies a signature key. This value corresponds to the `AT_SIGNATURE` value used in CAPI. + + + +## Examples + The following code example creates a key container and retrieves information about that container. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: + ]]> @@ -554,15 +547,14 @@ if the key is from the machine key set; otherwise, . - @@ -616,22 +608,21 @@ if the key pair is protected; otherwise, . - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. @@ -678,20 +669,19 @@ Gets the provider name of a key. The provider name. - @@ -738,20 +728,19 @@ Gets the provider type of a key. The provider type. The default is 1. - @@ -799,20 +788,19 @@ if the key container was randomly generated; otherwise, . - @@ -866,15 +854,14 @@ if the key is removable; otherwise, . - The cryptographic service provider (CSP) was not found. @@ -932,22 +919,21 @@ Gets a unique key container name. The unique key container name. - The key type is not supported. - The cryptographic service provider cannot be found. - - -or- - + The cryptographic service provider cannot be found. + + -or- + The key container was not found. diff --git a/xml/System.Security.Cryptography/CspParameters.xml b/xml/System.Security.Cryptography/CspParameters.xml index 1a5ba833efd..6e9bb6ada80 100644 --- a/xml/System.Security.Cryptography/CspParameters.xml +++ b/xml/System.Security.Cryptography/CspParameters.xml @@ -85,13 +85,11 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: The following code example uses the class to select a Smart Card Cryptographic Service Provider. It then signs and verifies data using the smart card. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.SmartCardCSP/VB/example.vb" id="Snippet1"::: @@ -161,7 +159,6 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: @@ -293,7 +290,6 @@ ## Examples The following code example uses the class to select a Smart Card Cryptographic Service Provider. It then signs and verifies data using the smart card. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/example.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.SmartCardCSP/VB/example.vb" id="Snippet1"::: @@ -618,7 +614,6 @@ ## Examples The following code example creates a key container using the class and saves the key in the container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/Overview/capikey.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/capikey/VB/capikey.vb" id="Snippet1"::: @@ -685,7 +680,6 @@ ## Examples The following code example demonstrates how to use the enumeration to specify a key type for an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/KeyNumber/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/DES.xml b/xml/System.Security.Cryptography/DES.xml index 1d5ab4cb022..27478190ef3 100644 --- a/xml/System.Security.Cryptography/DES.xml +++ b/xml/System.Security.Cryptography/DES.xml @@ -69,14 +69,14 @@ Represents the base class for the Data Encryption Standard (DES) algorithm from which all implementations must derive. - [!NOTE] > A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class instead of the class. Use only for compatibility with legacy applications and data. - + ]]> Cryptographic Services @@ -124,19 +124,19 @@ Initializes a new instance of the class. - class to the default values shown in the following table. - -|Field|Default Value| -|-----------|-------------------| -||64| -||64| -||64| - + class to the default values shown in the following table. + +|Field|Default Value| +|-----------|-------------------| +||64| +||64| +||64| + ]]> Cryptographic Services @@ -205,26 +205,24 @@ Creates an instance of a cryptographic object to perform the Data Encryption Standard () algorithm. A cryptographic object. - object that can be used for encrypting and decrypting data. - - + object that can be used for encrypting and decrypting data. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -347,13 +345,13 @@ if the key is semi-weak; otherwise, . - ) algorithm; this method checks for those semi-weak keys. - - Attempting to set a semi-weak key results in a . When is called to create a random key, a semi-weak key will never be returned. - + ) algorithm; this method checks for those semi-weak keys. + + Attempting to set a semi-weak key results in a . When is called to create a random key, a semi-weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -407,13 +405,13 @@ if the key is weak; otherwise, . - ) algorithm; this method checks for those weak keys. - - Attempting to set a weak key results in a . When is called to create a random key, a weak key will never be returned. - + ) algorithm; this method checks for those weak keys. + + Attempting to set a weak key results in a . When is called to create a random key, a weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -462,15 +460,15 @@ Gets or sets the secret key for the Data Encryption Standard () algorithm. The secret key for the algorithm. - is called to create a new random value. - - The length of the key must be equal to . - - This algorithm supports a key length of 64 bits. - + is called to create a new random value. + + The length of the key must be equal to . + + This algorithm supports a key length of 64 bits. + ]]> An attempt was made to set the key to . diff --git a/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml b/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml index 850a19db322..ad95d7ae3e6 100644 --- a/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/DESCryptoServiceProvider.xml @@ -70,23 +70,22 @@ Defines a wrapper object to access the cryptographic service provider (CSP) version of the Data Encryption Standard () algorithm. This class cannot be inherited. - [!IMPORTANT] > A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class instead of the class. Use only for compatibility with legacy applications and data. -## Examples - The following code example uses (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. +## Examples + The following code example uses (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: - - Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: + + Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. + ]]> Cryptographic Services @@ -136,17 +135,16 @@ Initializes a new instance of the class. - (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp" id="Snippet1"::: + (an implementation of ) with the specified key () and initialization vector () to encrypt a file specified by `inName`. It then outputs the encrypted result to the file specified by `outName`. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/Overview/source.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: - - Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic DES Example/VB/source.vb" id="Snippet1"::: + + Decryption can be handled in the same way; use instead of . The same key () and initialization vector () used to encrypt the file must be used to decrypt it. + ]]> The Data Encryption Standard () cryptographic service provider is not available. @@ -188,11 +186,11 @@ Creates a symmetric decryptor object with the current property and initialization vector (). A symmetric decryptor object. - overload with the same signature. - + overload with the same signature. + ]]> @@ -259,25 +257,25 @@ Creates a symmetric Data Encryption Standard () decryptor object with the specified key () and initialization vector (). A symmetric decryptor object. - overload with the same parameters. - + overload with the same parameters. + ]]> - The value of the property is . - - -or- - - The value of the property is and the value of the property is not 8. - - -or- - - An invalid key size was used. - - -or- - + The value of the property is . + + -or- + + The value of the property is and the value of the property is not 8. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -326,13 +324,13 @@ Creates a symmetric encryptor object with the current property and initialization vector (). A symmetric encryptor object. - property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . - - Use the overload with the same signature to decrypt the result of this method. - + property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . + + Use the overload with the same signature to decrypt the result of this method. + ]]> @@ -399,40 +397,38 @@ Creates a symmetric Data Encryption Standard () encryptor object with the specified key () and initialization vector (). A symmetric encryptor object. - overload with the same parameters to decrypt the result of this method. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp" id="Snippet1"::: + overload with the same parameters to decrypt the result of this method. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/CreateEncryptor/fileexample.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DESCryptoServiceProvider/CreateEncryptor/memoryexample.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> - The value of the property is . - - -or- - - The value of the property is and the value of the property is not 8. - - -or- - - An invalid key size was used. - - -or- - + The value of the property is . + + -or- + + The value of the property is and the value of the property is not 8. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -479,11 +475,11 @@ Generates a random initialization vector () to use for the algorithm. - when none is specified. - + when none is specified. + ]]> Cryptographic Services @@ -531,13 +527,13 @@ Generates a random key () to be used for the algorithm. - ) or a semi-weak key (see ). - - This algorithm supports a key length of 64 bits. - + ) or a semi-weak key (see ). + + This algorithm supports a key length of 64 bits. + ]]> Cryptographic Services diff --git a/xml/System.Security.Cryptography/DSASignatureDeformatter.xml b/xml/System.Security.Cryptography/DSASignatureDeformatter.xml index 34983570b81..47cf79eb74d 100644 --- a/xml/System.Security.Cryptography/DSASignatureDeformatter.xml +++ b/xml/System.Security.Cryptography/DSASignatureDeformatter.xml @@ -65,18 +65,17 @@ Verifies a Digital Signature Algorithm () PKCS#1 v1.5 signature. - [!IMPORTANT] -> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. - +> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. + ## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureDeformatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/VB/sample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -130,13 +129,12 @@ Initializes a new instance of the class. - Cryptographic Services @@ -234,13 +232,12 @@ The name of the hash algorithm to use for the signature deformatter. Specifies the hash algorithm for the Digital Signature Algorithm () signature deformatter. - The parameter does not map to the hash algorithm. @@ -349,20 +346,19 @@ if the signature is valid for the data; otherwise, . - - is . - - -or- - + is . + + -or- + is . The DSA key is missing. Cryptographic Services diff --git a/xml/System.Security.Cryptography/DSASignatureFormatter.xml b/xml/System.Security.Cryptography/DSASignatureFormatter.xml index acf0a614b1c..a1557d332ad 100644 --- a/xml/System.Security.Cryptography/DSASignatureFormatter.xml +++ b/xml/System.Security.Cryptography/DSASignatureFormatter.xml @@ -65,18 +65,17 @@ Creates a Digital Signature Algorithm () signature. - [!IMPORTANT] -> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp" id="Snippet1"::: +> The creators of the DSA algorithm have withdrawn their support for it. Consider using the class or the class instead of the class. Use only for compatibility with legacy applications and data. + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureFormatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -175,13 +174,12 @@ The instance of the Digital Signature Algorithm () that holds the key. Initializes a new instance of the class with the specified key. - @@ -235,26 +233,25 @@ Creates the Digital Signature Algorithm () PKCS #1 signature for the specified data. The digital signature for the specified data. - . - - - -## Examples - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp" id="Snippet1"::: + . + + + +## Examples :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DSASignatureFormatter/Overview/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/VB/sample.vb" id="Snippet1"::: + ]]> is . - The OID is . - - -or- - + The OID is . + + -or- + The DSA key is . Cryptographic Services @@ -304,13 +301,12 @@ The name of the hash algorithm to use for the signature formatter. Specifies the hash algorithm for the Digital Signature Algorithm () signature formatter. - The parameter does not map to the hash algorithm. diff --git a/xml/System.Security.Cryptography/DataProtectionScope.xml b/xml/System.Security.Cryptography/DataProtectionScope.xml index 0cafc7728db..af41c1b5820 100644 --- a/xml/System.Security.Cryptography/DataProtectionScope.xml +++ b/xml/System.Security.Cryptography/DataProtectionScope.xml @@ -33,22 +33,21 @@ Specifies the scope of the data protection to be applied by the method. - and methods to protect data through encryption. + + **Caution** The LocalMachine enumeration value allows multiple accounts to unprotect data. Use this value only when you trust every account on a computer. For most situations, you should use the CurrentUser value. + + + +## Examples + The following code example shows how to use data protection. -## Remarks - This enumeration is used with the and methods to protect data through encryption. - - **Caution** The LocalMachine enumeration value allows multiple accounts to unprotect data. Use this value only when you trust every account on a computer. For most situations, you should use the CurrentUser value. - - - -## Examples - The following code example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography/FromBase64Transform.xml b/xml/System.Security.Cryptography/FromBase64Transform.xml index 8cb4f87cc27..dcdde0d8deb 100644 --- a/xml/System.Security.Cryptography/FromBase64Transform.xml +++ b/xml/System.Security.Cryptography/FromBase64Transform.xml @@ -78,7 +78,6 @@ ## Examples The following example decodes a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -192,7 +191,6 @@ ## Examples The following example decodes a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -762,7 +760,6 @@ For more information about Dispose and Finalize, see [Cleaning Up Unmanaged Reso ## Examples The following example decrypts a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: @@ -846,7 +843,6 @@ For more information about Dispose and Finalize, see [Cleaning Up Unmanaged Reso ## Examples The following example decrypts a base 64-encoded file to an output text file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/FromBase64Transform/Overview/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/VB/class1.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA256.xml b/xml/System.Security.Cryptography/HMACSHA256.xml index 5e5d4acb8b9..50b387c30d4 100644 --- a/xml/System.Security.Cryptography/HMACSHA256.xml +++ b/xml/System.Security.Cryptography/HMACSHA256.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA256/Overview/hmacsha256.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA256/vb/hmacsha256.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA384.xml b/xml/System.Security.Cryptography/HMACSHA384.xml index 23f85773e1c..ed2e8903e11 100644 --- a/xml/System.Security.Cryptography/HMACSHA384.xml +++ b/xml/System.Security.Cryptography/HMACSHA384.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object, and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA384/Overview/hmacsha384.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA384/vb/hmacsha384.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HMACSHA512.xml b/xml/System.Security.Cryptography/HMACSHA512.xml index 2c08947e42e..b4768d235fe 100644 --- a/xml/System.Security.Cryptography/HMACSHA512.xml +++ b/xml/System.Security.Cryptography/HMACSHA512.xml @@ -83,7 +83,6 @@ ## Examples The following example shows how to sign a file by using the object and then how to verify the file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HMACSHA512/Overview/hmacsha512.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/HMACSHA512/vb/hmacsha512.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/HashAlgorithm.xml b/xml/System.Security.Cryptography/HashAlgorithm.xml index 1a687a01934..79afaf96a57 100644 --- a/xml/System.Security.Cryptography/HashAlgorithm.xml +++ b/xml/System.Security.Cryptography/HashAlgorithm.xml @@ -90,7 +90,6 @@ ## Examples The following code example computes the hash for an array. This example assumes that there is a predefined byte array `dataArray[]`. is a derived class of . - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic HashAlgorithm Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/KeyNumber.xml b/xml/System.Security.Cryptography/KeyNumber.xml index 4c18fd9db46..e6abf96cba0 100644 --- a/xml/System.Security.Cryptography/KeyNumber.xml +++ b/xml/System.Security.Cryptography/KeyNumber.xml @@ -62,18 +62,17 @@ Specifies whether to create an asymmetric signature key or an asymmetric exchange key. - property to inspect a key type or with the field to specify a key type. + +## Examples + The following code example demonstrates how to use the enumeration to specify a key type for an object. -## Remarks - Use the `KeyNumber` enumeration with the property to inspect a key type or with the field to specify a key type. - -## Examples - The following code example demonstrates how to use the enumeration to specify a key type for an object. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspParameters/KeyNumber/sample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.KeyNumber/VB/sample.vb" id="Snippet1"::: + ]]> diff --git a/xml/System.Security.Cryptography/KeySizes.xml b/xml/System.Security.Cryptography/KeySizes.xml index 39bf23e91e4..59dc9a1c4bb 100644 --- a/xml/System.Security.Cryptography/KeySizes.xml +++ b/xml/System.Security.Cryptography/KeySizes.xml @@ -58,15 +58,14 @@ Determines the set of valid key sizes for the symmetric cryptographic algorithms. - class. -## Examples - The following example shows the use of members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -119,15 +118,14 @@ The interval between valid key sizes. Initializes a new instance of the class with the specified key values. - constructor. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet2"::: + constructor. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet2"::: + ]]> @@ -175,15 +173,14 @@ Specifies the maximum key size. The maximum key size. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet4"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet4"::: + ]]> @@ -231,15 +228,14 @@ Specifies the minimum key size. The minimum key size. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet3"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet3"::: + ]]> @@ -287,15 +283,14 @@ Specifies the interval between valid key sizes. The interval between valid key sizes. - property. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp" id="Snippet5"::: + property. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeySizes/Overview/members.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/VB/members.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml b/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml index 0e2efcadbc1..9272d121ace 100644 --- a/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml +++ b/xml/System.Security.Cryptography/KeyedHashAlgorithm.xml @@ -481,7 +481,6 @@ Allows an to attempt to free resources and perfor ## Examples The following code example demonstrates how to override the property to retrieve the key used in the current object. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp" id="Snippet22"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/KeyedHashAlgorithm/Key/contosokeyedhash.cs" id="Snippet22"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/VB/contosokeyedhash.vb" id="Snippet22"::: diff --git a/xml/System.Security.Cryptography/MaskGenerationMethod.xml b/xml/System.Security.Cryptography/MaskGenerationMethod.xml index 9dc1445eb64..6ddffd6e4ea 100644 --- a/xml/System.Security.Cryptography/MaskGenerationMethod.xml +++ b/xml/System.Security.Cryptography/MaskGenerationMethod.xml @@ -61,22 +61,21 @@ Represents the abstract class from which all mask generator algorithms must derive. - compute masks that are used in key exchange algorithms such as Optimal Asymmetric Encryption Padding (OAEP). + + This class is used by implementations of key exchange algorithms only for mask generation. Application code does not use this class directly. + + + +## Examples + The following code example demonstrates how to derive from the class. -## Remarks - Derived classes of compute masks that are used in key exchange algorithms such as Optimal Asymmetric Encryption Padding (OAEP). - - This class is used by implementations of key exchange algorithms only for mask generation. Application code does not use this class directly. - - - -## Examples - The following code example demonstrates how to derive from the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/MaskGenerationMethod/Overview/maskgenerator.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/VB/maskgenerator.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/VB/maskgenerator.vb" id="Snippet1"::: + ]]> @@ -175,13 +174,13 @@ When overridden in a derived class, generates a mask with the specified length using the specified random seed. A randomly generated mask whose length is equal to the parameter. - to create and return a mask using the specified seed. This code example is part of a larger example provided for the class. - - System.Security.Cryptography.MaskGenerationMethod#3 - + to create and return a mask using the specified seed. This code example is part of a larger example provided for the class. + + System.Security.Cryptography.MaskGenerationMethod#3 + ]]> diff --git a/xml/System.Security.Cryptography/Oid.xml b/xml/System.Security.Cryptography/Oid.xml index db54717f5c5..e780746ff09 100644 --- a/xml/System.Security.Cryptography/Oid.xml +++ b/xml/System.Security.Cryptography/Oid.xml @@ -57,18 +57,17 @@ Represents a cryptographic object identifier. This class cannot be inherited. - property is set to "1.3.6.1.5.5.7.3.4", the property, which is localized, is set automatically to "Secure Email". + +## Examples + The following code example shows how to use the class. -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + ]]> @@ -126,18 +125,17 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -184,18 +182,17 @@ The object identifier information to use to create the new object identifier. Initializes a new instance of the class using the specified object. - object to a new object. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -250,18 +247,17 @@ An object identifier. Initializes a new instance of the class using a string value of an object. - object to a new object. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -317,18 +313,17 @@ The friendly name of the identifier. Initializes a new instance of the class using the specified value and friendly name. - object. Note that if the Oid value is not recognized, the `value` and `friendlyName` parameters are not verified to determine if they correspond to each other. This is because there are object identifiers that .NET does not recognize, although an application may be able to interpret them. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -376,21 +371,20 @@ Gets or sets the friendly name of the identifier. The friendly name of the identifier. - property is set to a known value, the value of the other property is updated automatically to a corresponding value. For example, if the property is set to "Secure Email", the property is set automatically to "1.3.6.1.5.5.7.3.4". In .NET 5 and later versions, this property is *init only*, meaning that its value can't be changed once it's been set. -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> .NET 5 and later: An attempt is made to set the value and the value has previously been set. @@ -553,21 +547,20 @@ In .NET 5 and later versions, this property is *init only*, meaning that its val Gets or sets the dotted number of the identifier. The dotted number of the identifier. - property is set to a known value, the value of the other property is updated automatically to a corresponding value. For example, if the property is set to "1.3.6.1.5.5.7.3.4", the property is set automatically to "Secure Email". In .NET 5 and later versions, this property is *init only*, meaning that its value can't be changed once it's been set. - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> .NET 5 and later: An attempt is made to set the value and the value has previously been set. diff --git a/xml/System.Security.Cryptography/OidCollection.xml b/xml/System.Security.Cryptography/OidCollection.xml index 512cc58f72b..a6c9eb0dd2e 100644 --- a/xml/System.Security.Cryptography/OidCollection.xml +++ b/xml/System.Security.Cryptography/OidCollection.xml @@ -64,20 +64,19 @@ Represents a collection of objects. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -120,20 +119,19 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -184,20 +182,19 @@ Adds an object to the object. The index of the added object. - object to an existing collection at the current location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object to an existing collection at the current location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -249,20 +246,19 @@ The location where the copy operation starts. Copies the object into an array. - object into an array at the specified location. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object into an array at the specified location. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -312,15 +308,14 @@ Gets the number of objects in a collection. The number of objects in a collection. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -368,20 +363,19 @@ Returns an object that can be used to navigate the object. An object. - class implements the interface, which allows you to move within a collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class implements the interface, which allows you to move within a collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -431,20 +425,19 @@ in all cases. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -505,20 +498,19 @@ Gets an object from the object. An object. - object from an object, if you know its location. You can use the property to retrieve an object if you know the value of the object's property or property. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object from an object, if you know its location. You can use the property to retrieve an object if you know the value of the object's property or property. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -576,20 +568,19 @@ Gets the first object that contains a value of the property or a value of the property that matches the specified string value from the object. An object. - object from an object if you know the value of the or property of the object. You can use the property to retrieve an object if you know its location in the collection. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object from an object if you know the value of the or property of the object. You can use the property to retrieve an object if you know its location in the collection. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -638,11 +629,11 @@ Gets an object that can be used to synchronize access to the object. An object that can be used to synchronize access to the object. - is not thread safe. Derived classes can provide their own synchronized version of the class using this property. The synchronizing code must perform operations on the property of the object, not directly on the object itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might simultaneously be modifying the object. - + is not thread safe. Derived classes can provide their own synchronized version of the class using this property. The synchronizing code must perform operations on the property of the object, not directly on the object itself. This ensures proper operation of collections that are derived from other objects. Specifically, it maintains proper synchronization with other threads that might simultaneously be modifying the object. + ]]> @@ -697,18 +688,18 @@ The location where the copy operation starts. Copies the object into an array. - object into an array at the specified location. - + object into an array at the specified location. + ]]> - cannot be a multidimensional array. - - -or- - + cannot be a multidimensional array. + + -or- + The length of is an invalid offset length. is . @@ -844,11 +835,11 @@ This member is an explicit interface member implementation. It can be used only Returns an object that can be used to navigate the object. An object that can be used to navigate the collection. - class implements the interface, which allows you to move within a collection. - + class implements the interface, which allows you to move within a collection. + ]]> diff --git a/xml/System.Security.Cryptography/OidEnumerator.xml b/xml/System.Security.Cryptography/OidEnumerator.xml index fad23c6800a..77c0338b5b0 100644 --- a/xml/System.Security.Cryptography/OidEnumerator.xml +++ b/xml/System.Security.Cryptography/OidEnumerator.xml @@ -61,20 +61,19 @@ Provides the ability to navigate through an object. This class cannot be inherited. - interface. - - - -## Examples - The following code example shows how to use the class. + interface. + + + +## Examples + The following code example shows how to use the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -121,24 +120,23 @@ Gets the current object in an object. The current object in the collection. - method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. - - also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. - - does not move the position of the enumerator, and consecutive calls to return the same object, until is called. - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + method must be called to advance the enumerator to the first element of the collection before reading the value of the property; otherwise, returns `null` or throws an exception. + + also returns `null` or throws an exception if the last call to returns `false`, which indicates that the end of the collection has been reached. + + does not move the position of the enumerator, and consecutive calls to return the same object, until is called. + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> @@ -190,24 +188,23 @@ , if the enumerator was successfully advanced to the next element; , if the enumerator has passed the end of the collection. - method moves the enumerator over the first element of the collection. Subsequent calls to advances the enumerator past subsequent items in the collection. - - After the end of the collection is passed, calls to return `false`. - - An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + method moves the enumerator over the first element of the collection. Subsequent calls to advances the enumerator past subsequent items in the collection. + + After the end of the collection is passed, calls to return `false`. + + An enumerator is valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. @@ -258,20 +255,19 @@ Sets an enumerator to its initial position. - object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to the method throws an . - - - -## Examples - The following code example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp" id="Snippet1"::: + object. An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator becomes invalid and the next call to the method throws an . + + + +## Examples + The following code example shows how to use the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Oid/Overview/cryptography.oid.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.Oid/VB/cryptography.oid.vb" id="Snippet1"::: + ]]> The collection was modified after the enumerator was created. diff --git a/xml/System.Security.Cryptography/PasswordDeriveBytes.xml b/xml/System.Security.Cryptography/PasswordDeriveBytes.xml index ff906302c94..cc4c935a6b9 100644 --- a/xml/System.Security.Cryptography/PasswordDeriveBytes.xml +++ b/xml/System.Security.Cryptography/PasswordDeriveBytes.xml @@ -79,7 +79,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -167,7 +166,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -317,7 +315,6 @@ ## Examples The following code example creates a key from a password using the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet1"::: @@ -827,7 +824,6 @@ ## Examples This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/PasswordDeriveBytes/Overview/sample.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/VB/sample.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography/ProtectedData.xml b/xml/System.Security.Cryptography/ProtectedData.xml index 1870c622968..1bdd4f7bd6b 100644 --- a/xml/System.Security.Cryptography/ProtectedData.xml +++ b/xml/System.Security.Cryptography/ProtectedData.xml @@ -44,26 +44,25 @@ Provides methods for encrypting and decrypting data. This class cannot be inherited. - [!IMPORTANT] > Because it depends on DPAPI, the `ProtectedData` class is supported on the Windows platform only. Its use on .NET Core on platforms other than Windows throws a . - -The class consists of two wrappers for the unmanaged DPAPI, and . These two methods can be used to encrypt and decrypt data such as passwords, keys, and connection strings. - -If you use these methods during impersonation, you may receive the following error: "Key not valid for use in specified state." This occurs because the DPAPI stores the key data in user profiles. If the profile is not loaded, DPAPI won't be able to perform the decryption. To prevent this error, load the profile of the user you want to impersonate before calling either method. Using DPAPI with impersonation can incur significant complication and requires careful design choices. -## Examples - The following example shows how to use data protection. +The class consists of two wrappers for the unmanaged DPAPI, and . These two methods can be used to encrypt and decrypt data such as passwords, keys, and connection strings. + +If you use these methods during impersonation, you may receive the following error: "Key not valid for use in specified state." This occurs because the DPAPI stores the key data in user profiles. If the profile is not loaded, DPAPI won't be able to perform the decryption. To prevent this error, load the profile of the user you want to impersonate before calling either method. Using DPAPI with impersonation can incur significant complication and requires careful design choices. + +## Examples + The following example shows how to use data protection. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> @@ -123,23 +122,22 @@ If you use these methods during impersonation, you may receive the following err Encrypts the data in a specified byte array and returns a byte array that contains the encrypted data. A byte array representing the encrypted data. - method. - + method. + > [!NOTE] -> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. - - - -## Examples - The following example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: +> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. + + + +## Examples + The following example shows how to use data protection. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> The parameter is . @@ -344,23 +342,22 @@ If you use these methods during impersonation, you may receive the following err Decrypts the data in a specified byte array and returns a byte array that contains the decrypted data. A byte array representing the decrypted data. - method. If the `optionalEntropy` parameter was used during encryption, it must be supplied to unencrypt the data. - + method. If the `optionalEntropy` parameter was used during encryption, it must be supplied to unencrypt the data. + > [!NOTE] -> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. - - - -## Examples - The following code example shows how to use data protection. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp" id="Snippet1"::: +> If you use this method during impersonation, you may receive the following error: "Key not valid for use in specified state." To prevent this error, load the profile of the user you want to impersonate before calling the method. + + + +## Examples + The following code example shows how to use data protection. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/DataProtectionScope/Overview/dataprotectionsample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.DataProtectionSample/vb/dataprotectionsample.vb" id="Snippet1"::: + ]]> The parameter is . diff --git a/xml/System.Security.Cryptography/RC2.xml b/xml/System.Security.Cryptography/RC2.xml index f59d8d9be8d..420e9442aa6 100644 --- a/xml/System.Security.Cryptography/RC2.xml +++ b/xml/System.Security.Cryptography/RC2.xml @@ -220,13 +220,11 @@ ## Examples The following example shows how to create and use an RC2 object to encrypt and decrypt data in a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2/Create/fileexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.File/VB/fileexample.vb" id="Snippet1"::: The following example shows how to create and use an RC2 object to encrypt and decrypt data in memory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2/Create/memoryexample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml b/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml index e2bb45200f3..4425846e58a 100644 --- a/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RC2CryptoServiceProvider.xml @@ -70,26 +70,26 @@ Defines a wrapper object to access the cryptographic service provider (CSP) implementation of the algorithm. This class cannot be inherited. - implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. - - The object is a block cipher that encrypts and decrypts data in blocks of 8 bytes. This class pads the final block of data if it is less than 8 bytes. As a result of this padding, the length of encrypted data could be greater than the original plaintext. - - Note that the object does not use salt. - + implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. + + The object is a block cipher that encrypts and decrypts data in blocks of 8 bytes. This class pads the final block of data if it is less than 8 bytes. As a result of this padding, the length of encrypted data could be greater than the original plaintext. + + Note that the object does not use salt. + > [!NOTE] -> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the algorithm and its derived classes instead of the class. Use only for compatibility with legacy applications and data. - - - -## Examples - The following code example encrypts and then decrypts a string. - +> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the algorithm and its derived classes instead of the class. Use only for compatibility with legacy applications and data. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -147,14 +147,14 @@ Initializes a new instance of the class. - The cryptographic service provider (CSP) cannot be acquired. @@ -234,33 +234,33 @@ Creates a symmetric decryptor object with the specified key () and initialization vector (). A symmetric decryptor object. - overload with the same parameters. - - - -## Examples - The following code example encrypts and then decrypts a string. - + overload with the same parameters. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> - An cipher mode was used. - - -or- - - A cipher mode with a feedback size other than 8 bits was used. - - -or- - - An invalid key size was used. - - -or- - + An cipher mode was used. + + -or- + + A cipher mode with a feedback size other than 8 bits was used. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -337,33 +337,33 @@ Creates a symmetric encryptor object with the specified key () and initialization vector (). A symmetric encryptor object. - overload with the same parameters to decrypt the result of this method. - - - -## Examples - The following code example encrypts and then decrypts a string. - + overload with the same parameters to decrypt the result of this method. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> - An cipher mode was used. - - -or- - - A cipher mode with a feedback size other than 8 bits was used. - - -or- - - An invalid key size was used. - - -or- - + An cipher mode was used. + + -or- + + A cipher mode with a feedback size other than 8 bits was used. + + -or- + + An invalid key size was used. + + -or- + The algorithm key size was not available. Cryptographic Services @@ -456,19 +456,19 @@ Generates a random initialization vector () to use for the algorithm. - when none is specified. - - - -## Examples - The following code example encrypts and then decrypts a string. - + when none is specified. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -516,21 +516,21 @@ Generates a random key () to be used for the algorithm. - implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. - - - -## Examples - The following code example encrypts and then decrypts a string. - + implementation supports key lengths from 40 bits to 128 bits in increments of 8 bits. + + + +## Examples + The following code example encrypts and then decrypts a string. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RC2CryptoServiceProvider Example/VB/class1.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -588,20 +588,19 @@ if the key should be created with an 11-byte-long, zero-value salt; otherwise, . The default is . - property allows you to interoperate with an existing application that uses an 11-byte-long, zero-value salt. For most scenarios, you should not use a salt with an key. + property allows you to interoperate with an existing application that uses an 11-byte-long, zero-value salt. For most scenarios, you should not use a salt with an key. + + + +## Examples + The following code example sets the property to `true`, and then encrypts and decrypts a value. - - -## Examples - The following code example sets the property to `true`, and then encrypts and decrypts a value. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RC2CryptoServiceProvider/UseSalt/example.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/VB/example.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/VB/example.vb" id="Snippet1"::: + ]]> Cryptographic Services diff --git a/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml b/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml index a7ab0266c81..9493543bead 100644 --- a/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RNGCryptoServiceProvider.xml @@ -70,19 +70,18 @@ Implements a cryptographic Random Number Generator (RNG) using the implementation provided by the cryptographic service provider (CSP). This class cannot be inherited. - [!IMPORTANT] -> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. - - - -## Examples - The following code example shows how to create a random number with the class. +> This type implements the interface. When you have finished using the type, you should dispose of it either directly or indirectly. To dispose of the type directly, call its method in a `try`/`catch` block. To dispose of it indirectly, use a language construct such as `using` (in C#) or `Using` (in Visual Basic). For more information, see the "Using an Object that Implements IDisposable" section in the interface topic. + + + +## Examples + The following code example shows how to create a random number with the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: @@ -146,15 +145,14 @@ Initializes a new instance of the class. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -208,11 +206,11 @@ A byte array. This value is ignored. Initializes a new instance of the class. - class. Calling this method is equivalent to calling the constructor and passing `null`. - + class. Calling this method is equivalent to calling the constructor and passing `null`. + ]]> Cryptographic Services @@ -318,11 +316,11 @@ The string input. This parameter is ignored. Initializes a new instance of the class. - class. Calling this method is equivalent to calling the constructor and passing `null`. - + class. Calling this method is equivalent to calling the constructor and passing `null`. + ]]> Cryptographic Services @@ -461,22 +459,21 @@ The array to fill with a cryptographically strong sequence of random values. Fills an array of bytes with a cryptographically strong sequence of random values. - class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp" id="Snippet1"::: + class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RNGCryptoServiceProvider/Overview/rngcsp.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RNGCSP/VB/rngcsp.vb" id="Snippet1"::: + ]]> The cryptographic service provider (CSP) cannot be acquired. @@ -622,20 +619,19 @@ The array to fill with a cryptographically strong sequence of random nonzero values. Fills an array of bytes with a cryptographically strong sequence of random nonzero values. - The cryptographic service provider (CSP) cannot be acquired. diff --git a/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml b/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml index 90c2139f0c7..ef09c633e72 100644 --- a/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml +++ b/xml/System.Security.Cryptography/RSACryptoServiceProvider.xml @@ -76,13 +76,11 @@ class to encrypt a string into an array of bytes and then decrypt the bytes back into a string. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/VB/sample.vb" id="Snippet1"::: The following code example exports the key information created using the into an object. -:::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/VB/sample.vb" id="Snippet1"::: ]]> @@ -162,7 +160,6 @@ If no key is loaded via the class to encrypt a string into an array of bytes and then decrypt the bytes back into a string. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/VB/sample.vb" id="Snippet1"::: @@ -238,7 +235,6 @@ If no key is loaded via the , generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/VB/example.vb" id="Snippet1"::: @@ -320,7 +316,6 @@ If no key is loaded via the object, generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/VB/example.vb" id="Snippet1"::: @@ -404,7 +399,6 @@ If no key is loaded via the , generates a new key, and stores it in a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/.ctor/example2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/VB/example.vb" id="Snippet1"::: @@ -489,7 +483,6 @@ If no key is loaded via the property. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/CspKeyContainerInfo/Overview/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/VB/sample.vb" id="Snippet1"::: @@ -577,7 +570,6 @@ If no key is loaded via the class; however, the class may be preferable in large data operations. The encrypted value can be saved as an `nvarchar` data type in Microsoft SQL Server. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Decrypt/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/VB/example.vb" id="Snippet1"::: @@ -860,7 +852,6 @@ If no key is loaded via the object to the value of a public key (sent by another party), generates a session key using the algorithm, and then encrypts the session key using the object. Using this scheme, the session key could be sent back to the owner of the private RSA key and the two parties could use the session key to exchange encrypted data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Encrypt/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/VB/sample.vb" id="Snippet1"::: @@ -1129,7 +1120,6 @@ If no key is loaded via the into an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/Overview/sample1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/VB/sample.vb" id="Snippet1"::: @@ -1478,7 +1468,6 @@ If no key is loaded via the object into an object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/ImportParameters/sample.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/VB/sample.vb" id="Snippet1"::: @@ -1727,7 +1716,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example creates an object and persists the key to a key container. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/PersistKeyInCsp/example.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/VB/example.vb" id="Snippet1"::: @@ -1929,7 +1917,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/VB/example.vb" id="Snippet1"::: @@ -2007,7 +1994,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example2.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/VB/example.vb" id="Snippet1"::: @@ -2097,7 +2083,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example signs and verifies data. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignData/example.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/VB/example.vb" id="Snippet1"::: @@ -2195,7 +2180,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example encrypts some data, creates a hash of the encrypted data, and then signs hash with a digital signature. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet1"::: @@ -2326,7 +2310,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following code example creates an object and sets the static property to use the machine key store instead of the user profile key store. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/UseMachineKeyStore/example2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/VB/example2.vb" id="Snippet2"::: @@ -2416,7 +2399,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following example shows how to use the method to verify a signature. This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet2"::: @@ -2509,7 +2491,6 @@ The supported RSA key sizes depend on the available cryptographic service provid ## Examples The following example shows how to use the method to verify a signature. This code example is part of a larger example provided for the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSACryptoServiceProvider/SignHash/class1.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/VB/class1.vb" id="Snippet2"::: diff --git a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml index 63d4db99db6..4c15b11062e 100644 --- a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml +++ b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter.xml @@ -65,24 +65,24 @@ Decrypts Optimal Asymmetric Encryption Padding (OAEP) key exchange data. - to create the key exchange message with the algorithm. - + to create the key exchange message with the algorithm. + > [!CAUTION] -> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. - - - -## Examples - The following example shows how to use the class to recreate an exchange key to be used to decrypt a message. - +> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. + + + +## Examples + The following example shows how to use the class to recreate an exchange key to be used to decrypt a message. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -136,11 +136,11 @@ Initializes a new instance of the class. - to establish the key before calling . - + to establish the key before calling . + ]]> Cryptographic Services @@ -245,19 +245,19 @@ Extracts secret information from the encrypted key exchange data. The secret information derived from the key exchange data. - method to recreate an exchange key from a message sender. This code example is part of a larger example provided for the class. - + method to recreate an exchange key from a message sender. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet3"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet3"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet3"::: + ]]> The key exchange data verification has failed. @@ -314,15 +314,14 @@ Gets the parameters for the Optimal Asymmetric Encryption Padding (OAEP) key exchange. An XML string containing the parameters of the OAEP key exchange operation. - property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. -## Examples - The following code example demonstrates how to call the property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet12"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet12"::: + ]]> Cryptographic Services @@ -373,11 +372,11 @@ The instance of the algorithm that holds the private key. Sets the private key to use for decrypting the secret information. - . - + . + ]]> diff --git a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml index c9dd2e26c96..be3d9c73af7 100644 --- a/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml +++ b/xml/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter.xml @@ -65,24 +65,24 @@ Creates Optimal Asymmetric Encryption Padding (OAEP) key exchange data using . - to receive the key exchange and extract the secret information from it. - + to receive the key exchange and extract the secret information from it. + > [!CAUTION] -> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. - - - -## Examples - The following example shows how to use the class to create an exchange key for a message recipient. - +> It is highly recommended that you not attempt to create your own key exchange method from the basic functionality provided, because many details of the operation must be performed carefully in order for the key exchange to be successful. + + + +## Examples + The following example shows how to use the class to create an exchange key for a message recipient. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Overview/program.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsaoaepkeyexchangedeformatter2/vb/program.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -136,11 +136,11 @@ Initializes a new instance of the class. - to set the key before calling . - + to set the key before calling . + ]]> Cryptographic Services @@ -255,11 +255,11 @@ Creates the encrypted key exchange data from the specified input data. The encrypted key exchange data to be sent to the intended recipient. - The key is missing. @@ -322,19 +322,19 @@ Creates the encrypted key exchange data from the specified input data. The encrypted key exchange data to be sent to the intended recipient. - method to create an exchange key for a message recipient. This code example is part of a larger example provided for the class - + method to create an exchange key for a message recipient. This code example is part of a larger example provided for the class + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeFormatter/CreateKeyExchange/program.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsapkcs1keyexchangeformatter2/vb/program.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.rsapkcs1keyexchangeformatter2/vb/program.vb" id="Snippet2"::: + ]]> Cryptographic Services @@ -383,15 +383,14 @@ Gets or sets the parameter used to create padding in the key exchange creation process. The parameter value. - property to an field. This code example is part of a larger example provided for the class. -## Examples - The following code example demonstrates how to set the property to an field. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet7"::: + ]]> Cryptographic Services @@ -440,15 +439,14 @@ Gets the parameters for the Optimal Asymmetric Encryption Padding (OAEP) key exchange. An XML string containing the parameters of the OAEP key exchange operation. - property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet13"::: + property to retrieve an XML representation of the parameters. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet13"::: + ]]> Cryptographic Services @@ -497,20 +495,19 @@ Gets or sets the random number generator algorithm to use in the creation of the key exchange. The instance of a random number generator algorithm to use. - property to a random number. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet6"::: + property to a random number. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet6"::: + ]]> Cryptographic Services @@ -561,20 +558,19 @@ The instance of the algorithm that holds the public key. Sets the public key to use for encrypting the key exchange data. - . - - - -## Examples - The following code example demonstrates how to use the method to set an key for decryption. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp" id="Snippet5"::: + . + + + +## Examples + The following code example demonstrates how to use the method to set an key for decryption. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RSAOAEPKeyExchangeDeformatter/Parameters/rsaencoder.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/VB/rsaencoder.vb" id="Snippet5"::: + ]]> diff --git a/xml/System.Security.Cryptography/RandomNumberGenerator.xml b/xml/System.Security.Cryptography/RandomNumberGenerator.xml index ab99bf5b532..665001cd565 100644 --- a/xml/System.Security.Cryptography/RandomNumberGenerator.xml +++ b/xml/System.Security.Cryptography/RandomNumberGenerator.xml @@ -73,14 +73,14 @@ Provides functionality for generating random values. - Cryptographic Services @@ -131,11 +131,11 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Initializes a new instance of . - . - + . + ]]> Cryptographic Services @@ -340,16 +340,16 @@ To create a random number generator, call the @System.Security.Cryptography.Rand When overridden in a derived class, releases all resources used by the current instance of the class. - . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. - - For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). - -> [!NOTE] -> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. - + . The `Dispose` method leaves the in an unusable state. After calling `Dispose`, you must release all references to the so the garbage collector can reclaim the memory that the was occupying. + + For more information, see [Cleaning Up Unmanaged Resources](/dotnet/standard/garbage-collection/unmanaged) and [Implementing a Dispose Method](/dotnet/standard/garbage-collection/implementing-dispose). + +> [!NOTE] +> Always call `Dispose` before you release your last reference to the . Otherwise, the resources it is using will not be freed until the garbage collector calls the object's `Finalize` method. + ]]> @@ -401,19 +401,19 @@ To create a random number generator, call the @System.Security.Cryptography.Rand to release both managed and unmanaged resources; to release only unmanaged resources. When overridden in a derived class, releases the unmanaged resources used by the and optionally releases the managed resources. - method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. - - When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. - + method, if it has been overridden. `Dispose()` invokes this method with the `disposing` parameter set to `true`. `Finalize` invokes this method with `disposing` set to `false`. + + When the `disposing` parameter is `true`, this method releases all resources held by any managed objects that this references. This method invokes the `Dispose()` method of each referenced object. + ]]> - can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. - + can be called multiple times by other objects. When overriding , be careful not to reference objects that have been previously disposed in an earlier call to . For more information about how to implement , see Implementing a Dispose Method. + For more information about and , see Cleaning Up Unmanaged Resources. Cryptographic Services @@ -517,18 +517,17 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The array to fill with cryptographically strong random bytes. When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of values. - Cryptographic Services @@ -695,7 +694,7 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The length of string to create. - if the hexadecimal characters should be lowercase; if they should be uppercase. + if the hexadecimal characters should be lowercase; if they should be uppercase. The default is . Creates a string filled with cryptographically random hexadecimal characters. A string populated with random hexadecimal characters. @@ -731,7 +730,7 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The buffer to receive the characters. - if the hexadecimal characters should be lowercase; if they should be uppercase. + if the hexadecimal characters should be lowercase; if they should be uppercase. The default is . Fills a buffer with cryptographically random hexadecimal characters. The behavior of this is the same as using and specifying hexadecimal characters as the choices. This implementation is optimized specifically for hexadecimal characters. @@ -774,15 +773,15 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Generates a random integer between 0 (inclusive) and a specified exclusive upper bound using a cryptographically strong random number generator. A random integer between 0 (inclusive) and (exclusive). - . - - This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. - + . + + This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. + ]]> The parameter is less than or equal to 0. @@ -827,17 +826,17 @@ To create a random number generator, call the @System.Security.Cryptography.Rand Generates a random integer between a specified inclusive lower bound and a specified exclusive upper bound using a cryptographically strong random number generator. A random integer between (inclusive) and (exclusive). - . - - This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. - - Negative values are permitted for both `fromInclusive` and `toExclusive`. - + . + + This method uses a discard-and-retry strategy to avoid the low value bias that a simple modular arithmetic operation would produce. + + Negative values are permitted for both `fromInclusive` and `toExclusive`. + ]]> The parameter is less than or equal to the parameter. @@ -1003,20 +1002,19 @@ To create a random number generator, call the @System.Security.Cryptography.Rand The array to fill with cryptographically strong random nonzero bytes. When overridden in a derived class, fills an array of bytes with a cryptographically strong random sequence of nonzero values. - Cryptographic Services diff --git a/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml b/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml index 60486010b50..4b4c7fe5db2 100644 --- a/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml +++ b/xml/System.Security.Cryptography/Rfc2898DeriveBytes.xml @@ -82,7 +82,6 @@ ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -174,7 +173,6 @@ ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -413,7 +411,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following code example uses the class to create two identical keys for the class. It then encrypts and decrypts some data using the keys. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet1"::: @@ -891,7 +888,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following example shows how to use the method to get the key for an instance of . This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet2"::: @@ -992,7 +988,6 @@ For more information about PBKDF2, see [RFC 2898](https://www.rfc-editor.org/inf ## Examples The following example shows how to use the property to display the number of iterations used in the generation of the key. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet3"::: @@ -1412,7 +1407,6 @@ The `password` is converted to bytes using the UTF8 encoding. For other encoding ## Examples The following example shows how to use the method. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/Rfc2898DeriveBytes/Overview/rfc28981.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/rfc28981/vb/rfc28981.vb" id="Snippet5"::: diff --git a/xml/System.Security.Cryptography/RijndaelManaged.xml b/xml/System.Security.Cryptography/RijndaelManaged.xml index e1d16bdcb80..e80da098c55 100644 --- a/xml/System.Security.Cryptography/RijndaelManaged.xml +++ b/xml/System.Security.Cryptography/RijndaelManaged.xml @@ -73,18 +73,17 @@ Accesses the managed version of the algorithm. This class cannot be inherited. - -compatible). In .NET Core, it is the same as AES and supports only a 128-bit block size. - + -compatible). In .NET Core, it is the same as AES and supports only a 128-bit block size. + > [!IMPORTANT] -> The class is the predecessor of the algorithm. You should use the algorithm instead of . For more information, see the entry [The Differences Between Rijndael and AES](https://learn.microsoft.com/archive/blogs/shawnfa/the-differences-between-rijndael-and-aes) in the .NET Security blog. - -## Examples - The following example demonstrates how to encrypt and decrypt sample data using the `RijndaelManaged` class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: +> The class is the predecessor of the algorithm. You should use the algorithm instead of . For more information, see the entry [The Differences Between Rijndael and AES](https://learn.microsoft.com/archive/blogs/shawnfa/the-differences-between-rijndael-and-aes) in the .NET Security blog. + +## Examples + The following example demonstrates how to encrypt and decrypt sample data using the `RijndaelManaged` class. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: @@ -131,15 +130,14 @@ Initializes a new instance of the class. - This class is not compliant with the FIPS algorithm. @@ -180,10 +178,10 @@ Gets or sets the block size, in bits, of the cryptographic operation. The block size, in bits, of the cryptographic operation. The default is 128 bits. - for more information about block size. + for more information about block size. ]]> @@ -233,11 +231,11 @@ Creates a symmetric decryptor object with the current property and initialization vector (). A symmetric decryptor object. - overload with the same signature. - + overload with the same signature. + ]]> @@ -298,28 +296,27 @@ Creates a symmetric decryptor object with the specified and initialization vector (). A symmetric decryptor object. - overload with the same signature. - - The `rgbkey` size must be 128, 192, or 256 bits. - - - -## Examples - The following code example demonstrates how to use the method to decrypt messages encoded with the same signature parameter. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: + overload with the same signature. + + The `rgbkey` size must be 128, 192, or 256 bits. + + + +## Examples + The following code example demonstrates how to use the method to decrypt messages encoded with the same signature parameter. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter is . The value of the property is not , , or . Cryptographic Services @@ -360,12 +357,12 @@ Creates a symmetric encryptor object with the current property and initialization vector (). A symmetric encryptor object. - property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . - - Use the overload with the same signature to decrypt the result of this method. + property is `null`, the method is called to create a new random . If the current property is `null`, the method is called to create a new random . + + Use the overload with the same signature to decrypt the result of this method. ]]> @@ -426,28 +423,27 @@ Creates a symmetric encryptor object with the specified and initialization vector (). A symmetric encryptor object. - overload with the same signature to decrypt the result of this method. - - The `rgbkey` size must be 128, 192, or 256 bits. - - - -## Examples - The following code examples demonstrates how to encrypt a message using the `CreateEncryptor` method. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp" id="Snippet1"::: + overload with the same signature to decrypt the result of this method. + + The `rgbkey` size must be 128, 192, or 256 bits. + + + +## Examples + The following code examples demonstrates how to encrypt a message using the `CreateEncryptor` method. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/RijndaelManaged/Overview/class1.cs" interactive="try-dotnet" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/RijndaelManaged Example/VB/class1.vb" id="Snippet1"::: + ]]> - The parameter is . - - -or- - + The parameter is . + + -or- + The parameter is . The value of the property is not , , or . Cryptographic Services @@ -574,18 +570,17 @@ Generates a random initialization vector () to be used for the algorithm. - Cryptographic Services @@ -633,18 +628,17 @@ Generates a random to be used for the algorithm. - Cryptographic Services @@ -684,10 +678,10 @@ Gets or sets the initialization vector (IV) to use for the symmetric algorithm. The initialization vector (IV) to use for the symmetric algorithm. - for more information about initialization vectors. + for more information about initialization vectors. ]]> @@ -727,10 +721,10 @@ Gets or sets the secret key used for the symmetric algorithm. The secret key used for the symmetric algorithm. - for more information about the secret key. + for more information about the secret key. ]]> @@ -770,10 +764,10 @@ Gets or sets the size, in bits, of the secret key used for the symmetric algorithm. The size, in bits, of the secret key used for the symmetric algorithm. The default is 256 bits. - @@ -813,10 +807,10 @@ Gets the key sizes, in bits, that are supported by the symmetric algorithm. The key sizes, in bits, that are supported by the symmetric algorithm. - @@ -856,10 +850,10 @@ Gets or sets the mode for operation of the symmetric algorithm. The mode for operation of the symmetric algorithm. The default is - enumeration for a description of specific modes. + enumeration for a description of specific modes. ]]> @@ -899,10 +893,10 @@ Gets or sets the padding mode used in the symmetric algorithm. The padding mode used in the symmetric algorithm. The default is . - property for more information about padding. + property for more information about padding. ]]> diff --git a/xml/System.Security.Cryptography/SHA256.xml b/xml/System.Security.Cryptography/SHA256.xml index 84b2ff59f48..b9b36ecd3be 100644 --- a/xml/System.Security.Cryptography/SHA256.xml +++ b/xml/System.Security.Cryptography/SHA256.xml @@ -72,7 +72,6 @@ ## Examples The following example calculates the SHA-256 hash for all files in a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/ComputeHash/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA256 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA256Managed.xml b/xml/System.Security.Cryptography/SHA256Managed.xml index e56f330b061..9dd8376d90f 100644 --- a/xml/System.Security.Cryptography/SHA256Managed.xml +++ b/xml/System.Security.Cryptography/SHA256Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example calculates the SHA-256 hash for all files in a directory. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA256 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/HashAlgorithm/ComputeHash/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA256 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA384.xml b/xml/System.Security.Cryptography/SHA384.xml index cf56d6e8e7e..e3fada16642 100644 --- a/xml/System.Security.Cryptography/SHA384.xml +++ b/xml/System.Security.Cryptography/SHA384.xml @@ -72,7 +72,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA384/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA384 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA384Managed.xml b/xml/System.Security.Cryptography/SHA384Managed.xml index 4e6e0fd653d..435fa142600 100644 --- a/xml/System.Security.Cryptography/SHA384Managed.xml +++ b/xml/System.Security.Cryptography/SHA384Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA384Managed Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA384Managed/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA384Managed Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA512.xml b/xml/System.Security.Cryptography/SHA512.xml index 75b97dd9458..e726e6b95c7 100644 --- a/xml/System.Security.Cryptography/SHA512.xml +++ b/xml/System.Security.Cryptography/SHA512.xml @@ -74,7 +74,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512 Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA512/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA512 Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SHA512Managed.xml b/xml/System.Security.Cryptography/SHA512Managed.xml index 79ea0ffe6df..c49f848628c 100644 --- a/xml/System.Security.Cryptography/SHA512Managed.xml +++ b/xml/System.Security.Cryptography/SHA512Managed.xml @@ -81,7 +81,6 @@ ## Examples The following example computes the hash for `data` and stores it in `result`. This example assumes that there is a predefined constant `DATA_SIZE`. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic SHA512Managed Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SHA512Managed/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic SHA512Managed Example/VB/source.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/SymmetricAlgorithm.xml b/xml/System.Security.Cryptography/SymmetricAlgorithm.xml index 6cf7153a856..8e68834d66d 100644 --- a/xml/System.Security.Cryptography/SymmetricAlgorithm.xml +++ b/xml/System.Security.Cryptography/SymmetricAlgorithm.xml @@ -78,7 +78,6 @@ ## Examples The following code example uses the class with the specified property and initialization vector () to encrypt a file specified by `inName`, and outputs the encrypted result to the file specified by `outName`. The `desKey` and `desIV` parameters to the method are 8-byte arrays. You must have the high encryption pack installed to run this example. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SymmetricAlgorithm/Overview/source.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_Classic/classic CryptoStream Example/VB/source.vb" id="Snippet1"::: @@ -654,7 +653,6 @@ We recommend that you specify the algorithm by calling the method. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/SymmetricAlgorithm/CreateEncryptor/encryptor.cs" interactive="try-dotnet" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/vb/encryptor.vb" id="Snippet1"::: diff --git a/xml/System.Security.Cryptography/ToBase64Transform.xml b/xml/System.Security.Cryptography/ToBase64Transform.xml index 805522741be..d5f4e1d9c3b 100644 --- a/xml/System.Security.Cryptography/ToBase64Transform.xml +++ b/xml/System.Security.Cryptography/ToBase64Transform.xml @@ -78,7 +78,6 @@ ## Examples The following code example demonstrates how to use members of the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet1"::: @@ -178,7 +177,6 @@ ## Examples The following code example demonstrates how to call the property to determine if the current transform can be reused. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet3"::: @@ -238,7 +236,6 @@ ## Examples The following code example demonstrates how to call the method to verify that multiple blocks can be transformed. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet4"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet4"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet4"::: @@ -301,7 +298,6 @@ ## Examples The following code example demonstrates how to call the method to free up unused resources by the current transform. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet7"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet7"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet7"::: @@ -541,7 +537,6 @@ ## Examples The following code example demonstrates how to call the property to retrieve the input block size of the current transform. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet5"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet5"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet5"::: @@ -605,7 +600,6 @@ ## Examples The following code example demonstrates how to call the property to create a new byte array with the size of the output block size. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet6"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet6"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet6"::: @@ -731,7 +725,6 @@ For more information about `Dispose` and `Finalize`, see [Cleaning Up Unmanaged ## Examples The following code example demonstrates how to call the method to iterate through `inputBytes` transforming by `blockSize`. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet8"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet8"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet8"::: @@ -807,7 +800,6 @@ For more information about `Dispose` and `Finalize`, see [Cleaning Up Unmanaged ## Examples The following code example demonstrates how to call the method to transform the final block of data. This code example is part of a larger example provided for the class. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp" id="Snippet9"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/ToBase64Transform/Overview/members.cs" id="Snippet9"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/VB/members.vb" id="Snippet9"::: diff --git a/xml/System.Security.Cryptography/TripleDES.xml b/xml/System.Security.Cryptography/TripleDES.xml index ae3b04001f5..6bc20e33421 100644 --- a/xml/System.Security.Cryptography/TripleDES.xml +++ b/xml/System.Security.Cryptography/TripleDES.xml @@ -68,28 +68,28 @@ Represents the base class for Triple Data Encryption Standard algorithms from which all implementations must derive. - uses three successive iterations of the algorithm. It can use either two or three 56-bit keys. - + uses three successive iterations of the algorithm. It can use either two or three 56-bit keys. + > [!NOTE] -> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class and its derived classes instead of the class. Use only for compatibility with legacy applications and data. - - This algorithm supports key lengths from 128 bits to 192 bits in increments of 64 bits. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. - +> A newer symmetric encryption algorithm, Advanced Encryption Standard (AES), is available. Consider using the class and its derived classes instead of the class. Use only for compatibility with legacy applications and data. + + This algorithm supports key lengths from 128 bits to 192 bits in increments of 64 bits. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: ]]> @@ -143,19 +143,19 @@ Initializes a new instance of the class. - class to the default values listed in the following table. - -|Field|Default Value| -|-----------|-------------------| -||192| -||64| -||64| - + class to the default values listed in the following table. + +|Field|Default Value| +|-----------|-------------------| +||192| +||64| +||64| + ]]> Cryptographic Services @@ -229,25 +229,24 @@ Creates an instance of a cryptographic object to perform the algorithm. An instance of a cryptographic object. - class. - - - -## Examples - The following code example shows how to create and use a object to encrypt and decrypt data in a file. + class. + + + +## Examples + The following code example shows how to create and use a object to encrypt and decrypt data in a file. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/fileexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: - - The following code example shows how to create and use a object to encrypt and decrypt data in memory. - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.File/VB/fileexample.vb" id="Snippet1"::: + + The following code example shows how to create and use a object to encrypt and decrypt data in memory. + :::code language="csharp" source="~/snippets/csharp/System.Security.Cryptography/TripleDES/Create/memoryexample.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Cryptography.3DES.Create.Memory/VB/memoryexample.vb" id="Snippet1"::: + ]]> Cryptographic Services @@ -373,13 +372,13 @@ if the key is weak; otherwise, . - . When is called to create a random key, a weak key will never be returned. - + . When is called to create a random key, a weak key will never be returned. + ]]> The size of the parameter is not valid. @@ -431,18 +430,18 @@ Gets or sets the secret key for the algorithm. The secret key for the algorithm. - An attempt was made to set the key to . - An attempt was made to set a key whose length is invalid. - - -or- - + An attempt was made to set a key whose length is invalid. + + -or- + An attempt was made to set a weak key (see ). Cryptographic Services @@ -477,9 +476,9 @@ Gets the block sizes, in bits, that are supported by the symmetric algorithm. An array that contains the block sizes supported by the algorithm. - @@ -515,9 +514,9 @@ Gets the key sizes, in bits, that are supported by the symmetric algorithm. An array that contains the key sizes supported by the algorithm. - diff --git a/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml b/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml index 589b7eaa360..7ad1a65f92f 100644 --- a/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml +++ b/xml/System.Security/AllowPartiallyTrustedCallersAttribute.xml @@ -60,37 +60,36 @@ Allows an assembly to be called by partially trusted code. Without this declaration, only fully trusted callers are able to use the assembly. This class cannot be inherited. - [!IMPORTANT] > Partially trusted code is no longer supported. This attribute has no effect in .NET Core. - + > [!NOTE] -> The .NET Framework 4 introduces new security rules that affect the behavior of the attribute (see [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2)). In the .NET Framework 4, all code defaults to security-transparent, that is, partially trusted. However, you can annotate individual types and members to assign them other transparency attributes. For this and other security changes, see [Security Changes](/dotnet/framework/security/security-changes). - - .NET Framework version 2.0 () assemblies must be strong-named to effectively use the (APTCA) attribute. .NET Framework 4 () assemblies do not have to be strong-named for the APTCA attribute to be effective, and they can contain transparent, security-critical and security-safe-critical code. For more information about applying attributes at the assembly level, see [Applying Attributes](/dotnet/standard/attributes/applying-attributes). - - By default, if a strong-named, assembly does not explicitly apply this attribute at the assembly level, it can be called only by other assemblies that are granted full trust. This restriction is enforced by placing a for `FullTrust` on every public or protected method on every publicly accessible class in the assembly. Assemblies that are intended to be called by partially trusted code can declare their intent through the use of . An example of the declaration in C# is `[assembly:AllowPartiallyTrustedCallers]`; an example in Visual Basic is ``. - +> The .NET Framework 4 introduces new security rules that affect the behavior of the attribute (see [Security-Transparent Code, Level 2](/dotnet/framework/misc/security-transparent-code-level-2)). In the .NET Framework 4, all code defaults to security-transparent, that is, partially trusted. However, you can annotate individual types and members to assign them other transparency attributes. For this and other security changes, see [Security Changes](/dotnet/framework/security/security-changes). + + .NET Framework version 2.0 () assemblies must be strong-named to effectively use the (APTCA) attribute. .NET Framework 4 () assemblies do not have to be strong-named for the APTCA attribute to be effective, and they can contain transparent, security-critical and security-safe-critical code. For more information about applying attributes at the assembly level, see [Applying Attributes](/dotnet/standard/attributes/applying-attributes). + + By default, if a strong-named, assembly does not explicitly apply this attribute at the assembly level, it can be called only by other assemblies that are granted full trust. This restriction is enforced by placing a for `FullTrust` on every public or protected method on every publicly accessible class in the assembly. Assemblies that are intended to be called by partially trusted code can declare their intent through the use of . An example of the declaration in C# is `[assembly:AllowPartiallyTrustedCallers]`; an example in Visual Basic is ``. + > [!CAUTION] -> The presence of this assembly-level attribute prevents the default behavior of placing `FullTrust` security checks, and makes the assembly callable from any other (partially or fully trusted) assembly. - - When the APTCA attribute is present, all other security checks function as intended, including any class-level or method-level declarative security attributes that are present. This attribute blocks only the implicit, fully trusted caller demand. - - This is not a declarative security attribute, but a regular attribute (it derives from , not from ). +> The presence of this assembly-level attribute prevents the default behavior of placing `FullTrust` security checks, and makes the assembly callable from any other (partially or fully trusted) assembly. + + When the APTCA attribute is present, all other security checks function as intended, including any class-level or method-level declarative security attributes that are present. This attribute blocks only the implicit, fully trusted caller demand. + + This is not a declarative security attribute, but a regular attribute (it derives from , not from ). + + For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). + + + +## Examples + The following example shows how to use the class. - For more information, see [Using Libraries from Partially Trusted Code](/dotnet/framework/misc/using-libraries-from-partially-trusted-code). - - - -## Examples - The following example shows how to use the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/AllowPartiallyTrustedCallersAttribute/Overview/AllowPartiallyTrustedCallersAttribute.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/VB/allowpartiallytrustedcallersattribute.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/VB/allowpartiallytrustedcallersattribute.vb" id="Snippet1"::: + ]]> @@ -134,16 +133,16 @@ Initializes a new instance of the class. - class. - + class. + ]]> @@ -185,35 +184,35 @@ Gets or sets the default partial trust visibility for code that is marked with the (APTCA) attribute. One of the enumeration values. The default is . - . - -- Explicit, unconditional APTCA: - - ``` - [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)] - ``` - - The assembly can always be called by partial-trust code. - -- Explicit, conditional APTCA: - - ``` - [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)] - ``` - - The assembly has been audited for partial trust, but it is not visible to partial-trust code by default. To make the assembly visible to partial-trust code, add it to the property. - + . + +- Explicit, unconditional APTCA: + + ``` + [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=VisibleToAllHosts)] + ``` + + The assembly can always be called by partial-trust code. + +- Explicit, conditional APTCA: + + ``` + [assembly: AllowPartiallyTrustedCallers(PartialTrustVisibilityLevel=NotVisibleByDefault)] + ``` + + The assembly has been audited for partial trust, but it is not visible to partial-trust code by default. To make the assembly visible to partial-trust code, add it to the property. + ]]> diff --git a/xml/System.Security/ISecurityEncodable.xml b/xml/System.Security/ISecurityEncodable.xml index f96cdbc31da..ecf245df660 100644 --- a/xml/System.Security/ISecurityEncodable.xml +++ b/xml/System.Security/ISecurityEncodable.xml @@ -76,23 +76,22 @@ Defines the methods that convert permission object state to and from XML element representation. - [!NOTE] -> You must implement this interface for any new permission object. - - - -## Examples - This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented. +> You must implement this interface for any new permission object. + + + +## Examples + This example shows how to define a permission class for use with code access security. All of the necessary permission interfaces are implemented. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet1"::: + ]]> @@ -149,20 +148,19 @@ The XML encoding to use to reconstruct the security object. Reconstructs a security object with a specified state from an XML encoding. - and methods to make the objects security-encodable. - - - -## Examples - The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet6"::: + and methods to make the objects security-encodable. + + + +## Examples + The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet6"::: + ]]> @@ -218,20 +216,19 @@ Creates an XML encoding of the security object and its current state. An XML encoding of the security object, including any state information. - and methods to make the objects security-encodable. - - - -## Examples - The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/Permission/cpp/Permission.cpp" id="Snippet7"::: + and methods to make the objects security-encodable. + + + +## Examples + The following code example demonstrates implementing the method. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/IPermission/Overview/Permission.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/Permission/vb/permission.vb" id="Snippet7"::: + ]]> diff --git a/xml/System.Security/SecureString.xml b/xml/System.Security/SecureString.xml index c18c23128b5..863bda55620 100644 --- a/xml/System.Security/SecureString.xml +++ b/xml/System.Security/SecureString.xml @@ -133,13 +133,11 @@ The following example demonstrates how to use a object. It then calls the method to add an array of characters to it. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp" id="Snippet2"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/Overview/Ctor2.cs" id="Snippet2"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/vb/ctor2.vb" id="Snippet2"::: The following example creates a object from the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp" id="Snippet3"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/Overview/Ctor3.cs" id="Snippet3"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/vb/Ctor3.vb" id="Snippet3"::: @@ -216,7 +214,6 @@ The following example demonstrates how to use a object by passing its constructor a pointer to a character array. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/.ctor/ctor1.cs" id="Snippet1"::: ]]> @@ -294,13 +291,11 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: The following example demonstrates how the and methods can be used to collect the characters in a password. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -370,7 +365,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: @@ -574,7 +568,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: @@ -774,7 +767,6 @@ The following example demonstrates how to use a and methods can be used to collect the characters in a password. After the password is collected, it is made read-only. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -851,13 +843,11 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: The following example demonstrates how the and methods can be used to collect the characters in a password. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xchar.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xChar/VB/xchar.vb" id="Snippet1"::: @@ -939,7 +929,6 @@ The following example demonstrates how to use a , , , , and methods affect the value of a object. - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp" id="Snippet1"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecureString/AppendChar/xat.cs" id="Snippet1"::: :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecureString.xAt/VB/xat.vb" id="Snippet1"::: diff --git a/xml/System.Security/SecurityElement.xml b/xml/System.Security/SecurityElement.xml index 5d13ed3573e..56268a4d8e2 100644 --- a/xml/System.Security/SecurityElement.xml +++ b/xml/System.Security/SecurityElement.xml @@ -87,37 +87,36 @@ Represents the XML object model for encoding security objects. This class cannot be inherited. - ` and ``. - - It is strongly suggested that attribute based XML representation is used to express security elements and their values. This means properties of an element are expressed as attributes and property values are expressed as attribute values. Avoid nesting text within tags. For any `text` representation a representation of type `` is usually available. Using this attribute-based XML representation increases readability and allows easy WMI portability of the resulting XML serialization. - - An attribute name must be one character or longer, and cannot be `null`. If element-based value representation is used, elements with a text string that is `null` are represented in the `` form; otherwise, text is delimited by the `` and `` tokens. Both forms can be combined with attributes, which are shown if present. - - The tags, attributes, and text of elements, if present, are always case-sensitive. The XML form contains quotations and escapes where necessary. String values that include characters invalid for use in XML result in an . These rules apply to all properties and methods. - + ` and ``. + + It is strongly suggested that attribute based XML representation is used to express security elements and their values. This means properties of an element are expressed as attributes and property values are expressed as attribute values. Avoid nesting text within tags. For any `text` representation a representation of type `` is usually available. Using this attribute-based XML representation increases readability and allows easy WMI portability of the resulting XML serialization. + + An attribute name must be one character or longer, and cannot be `null`. If element-based value representation is used, elements with a text string that is `null` are represented in the `` form; otherwise, text is delimited by the `` and `` tokens. Both forms can be combined with attributes, which are shown if present. + + The tags, attributes, and text of elements, if present, are always case-sensitive. The XML form contains quotations and escapes where necessary. String values that include characters invalid for use in XML result in an . These rules apply to all properties and methods. + > [!NOTE] -> For performance reasons, character validity is only checked when the element is encoded into XML text form, and not on every set of a property or method. Static methods allow explicit checking where needed. - - - -## Examples - The following example shows the use of members of the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet1"::: +> For performance reasons, character validity is only checked when the element is encoded into XML text form, and not on every set of a property or method. Static methods allow explicit checking where needed. + + + +## Examples + The following example shows the use of members of the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet1"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet1"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet1"::: + ]]> @@ -181,20 +180,19 @@ The tag name of an XML element. Initializes a new instance of the class with the specified tag. - to remove invalid characters from the string. - - - -## Examples - The following code shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet2"::: + to remove invalid characters from the string. + + + +## Examples + The following code shows the use of the constructor to create a new object. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet2"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet2"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet2"::: + ]]> The parameter is . @@ -260,11 +258,11 @@ The text content within the element. Initializes a new instance of the class with the specified tag and text. - The parameter is . @@ -325,29 +323,28 @@ The value of the attribute. Adds a name/value attribute to an XML element. - to remove invalid characters from the string. - - There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. - - - -## Examples - The following code shows the use of the method to add a name/value attribute to an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet4"::: + to remove invalid characters from the string. + + There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. + + + +## Examples + The following code shows the use of the method to add a name/value attribute to an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet4"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet4"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet4"::: + ]]> The parameter or parameter is . - The parameter or parameter is invalid in XML. - - -or- - + The parameter or parameter is invalid in XML. + + -or- + An attribute with the name specified by the parameter already exists. @@ -403,20 +400,19 @@ The child element to add. Adds a child element to the XML element. - method to add a child element to the XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet5"::: + method to add a child element to the XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet5"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet5"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet5"::: + ]]> The parameter is . @@ -482,24 +478,23 @@ Finds an attribute by name in an XML element. The value associated with the named attribute, or if no attribute with exists. - text -``` - - - -## Examples - The following code shows the use of the method to find an attribute by name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet13"::: + text +``` + + + +## Examples + The following code shows the use of the method to find an attribute by name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet13"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet13"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet13"::: + ]]> The parameter is . @@ -555,24 +550,23 @@ Gets or sets the attributes of an XML element as name/value pairs. The object for the attribute values of the XML element. - as a name/value pair. - - Names and values in attributes should contain only valid XML attribute characters. Use to remove invalid characters from the string. - - There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. - - - -## Examples - The following code shows the use of the property to get an attribute of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet15"::: + as a name/value pair. + + Names and values in attributes should contain only valid XML attribute characters. Use to remove invalid characters from the string. + + There is no support for quoted strings, so strings for name/value pairs should not contain quotes or other characters requiring quoting. + + + +## Examples + The following code shows the use of the property to get an attribute of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet15"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet15"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet15"::: + ]]> The name or value of the object is invalid. @@ -629,20 +623,19 @@ Gets or sets the array of child elements of the XML element. The ordered child elements of the XML element as security elements. - contains both and , will appear first. - - - -## Examples - The following code shows the use of the property to get the array of child elements of the XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet14"::: + contains both and , will appear first. + + + +## Examples + The following code shows the use of the property to get the array of child elements of the XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet14"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet14"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet14"::: + ]]> A child of the XML parent node is . @@ -703,11 +696,11 @@ Creates and returns an identical copy of the current object. A copy of the current object. - and properties. - + and properties. + ]]> @@ -774,22 +767,21 @@ if the tag, attribute names and values, child elements, and text fields in the current XML element are identical to their counterparts in the parameter; otherwise, . - method to compare two XML elements. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet22"::: + method to compare two XML elements. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet22"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet22"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet22"::: + ]]> @@ -854,12 +846,12 @@ Replaces invalid XML characters in a string with their valid XML equivalent. The input string with invalid characters replaced. - . If invalid characters are used in a without being escaped, an is thrown. - - The following table shows the invalid XML characters and their escaped equivalents. + . If invalid characters are used in a without being escaped, an is thrown. + + The following table shows the invalid XML characters and their escaped equivalents. | Invalid XML character | Replaced with | |-----------------------|---------------| @@ -867,15 +859,14 @@ | `>` | `>` | | `"` | `"` | | `'` | `'` | -| `&` | `&` | +| `&` | `&` | + +## Examples + The following code shows the use of the method to replace invalid XML characters in a string with their valid XML equivalent. This code example is part of a larger example provided for the class. -## Examples - The following code shows the use of the method to replace invalid XML characters in a string with their valid XML equivalent. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet19"::: :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet19"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet19"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet19"::: + ]]> @@ -939,13 +930,13 @@ Creates a security element from an XML-encoded string. A created from the XML. - Microsoft"` use "`Microsoft"`. - - Using single quotation marks can result in either an exception being thrown or, in some cases, the single quotation marks being treated as text in the string. - + Microsoft"` use "`Microsoft"`. + + Using single quotation marks can result in either an exception being thrown or, in some cases, the single quotation marks being treated as text in the string. + Evidence based security model is not supported on .NET Core and this method will return `null`. ]]> @@ -1017,20 +1008,19 @@ if the parameter is a valid XML attribute name; otherwise, . - method to determine whether a string is a valid attribute name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet6"::: + method to determine whether a string is a valid attribute name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet6"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet6"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet6"::: + ]]> @@ -1097,20 +1087,19 @@ if the parameter is a valid XML attribute value; otherwise, . - method to determine whether a string is a valid attribute value. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet7"::: + method to determine whether a string is a valid attribute value. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet7"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet7"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet7"::: + ]]> @@ -1177,20 +1166,19 @@ if the parameter is a valid XML tag; otherwise, . - before setting it. - - - -## Examples - The following code shows the use of the method to determine whether a string is a valid attribute tag. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet10"::: + before setting it. + + + +## Examples + The following code shows the use of the method to determine whether a string is a valid attribute tag. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet10"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet10"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet10"::: + ]]> @@ -1257,20 +1245,19 @@ if the parameter is a valid XML text element; otherwise, . - before setting it. - - - -## Examples - The following code shows the use of the method to determine whether a string is valid as XML element text. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet9"::: + before setting it. + + + +## Examples + The following code shows the use of the method to determine whether a string is valid as XML element text. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet9"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet9"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet9"::: + ]]> @@ -1335,25 +1322,24 @@ Finds a child by its tag name. The first child XML element with the specified tag value, or if no child element with exists. - `. - -``` - text1 - text2 -``` - - - -## Examples - The following code shows the use of the method to find a child by its tag name. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet17"::: + `. + +``` + text1 + text2 +``` + + + +## Examples + The following code shows the use of the method to find a child by its tag name. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet17"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet17"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet17"::: + ]]> The parameter is . @@ -1419,31 +1405,29 @@ Finds a child by its tag name and returns the contained text. The text contents of the first child element with the specified tag value. - text1 - text2 -``` - - - -## Examples - The following code shows the use of the method to find a child by its tag name and return the contained text. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet18"::: + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.security.securityelement/vb/remarks.vb" id="Snippet1"::: + + With XML as follows, `SearchForTextOfTag("second")` would return "text2". + +``` + text1 + text2 +``` + + + +## Examples + The following code shows the use of the method to find a child by its tag name and return the contained text. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet18"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet18"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet18"::: + ]]> @@ -1505,28 +1489,27 @@ Gets or sets the tag name of an XML element. The tag name of an XML element. - text -``` - - If this element has child elements, the children will replace `text`. - - Assign only valid XML tag strings to this property. Use to remove invalid characters from the string. - - - -## Examples - The following code shows the use of the property to get the tag name of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet11"::: + text +``` + + If this element has child elements, the children will replace `text`. + + Assign only valid XML tag strings to this property. Use to remove invalid characters from the string. + + + +## Examples + The following code shows the use of the property to get the tag name of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet11"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet11"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet11"::: + ]]> The tag is . @@ -1583,22 +1566,21 @@ Gets or sets the text within an XML element. The value of the text within an XML element. - to remove invalid characters from the string. - - If a contains both and , will appear first. - - - -## Examples - The following code shows the use of the property to get the text of an XML element. This code example is part of a larger example provided for the class. - - :::code language="cpp" source="~/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp" id="Snippet12"::: + to remove invalid characters from the string. + + If a contains both and , will appear first. + + + +## Examples + The following code shows the use of the property to get the text of an XML element. This code example is part of a larger example provided for the class. + :::code language="csharp" source="~/snippets/csharp/System.Security/SecurityElement/Overview/securityelementmembers.cs" id="Snippet12"::: - :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet12"::: - + :::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR/SecurityElementMembers/VB/Form1.vb" id="Snippet12"::: + ]]> The text is not valid in XML. @@ -1654,11 +1636,11 @@ Produces a string representation of an XML element and its constituent attributes, child elements, and text. The XML element and its contents. - From 16595b2ddfe4c1b900062fc4caa040f381e7d277 Mon Sep 17 00:00:00 2001 From: Genevieve Warren <24882762+gewarren@users.noreply.github.com> Date: Wed, 4 Jun 2025 14:41:41 -0700 Subject: [PATCH 2/2] delete snippet files --- .../VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp | 80 ----- .../CertSelect/CPP/certselect.cpp | 47 --- .../CipherReference2/CPP/example.cpp | 38 -- .../CPP/fileexample.cpp | 146 -------- .../CPP/asnencodeddata.cpp | 90 ----- .../CPP/fileexample.cpp | 146 -------- .../CPP/memoryexample.cpp | 170 --------- .../CPP/fileexample.cpp | 113 ------ .../CPP/memoryexample.cpp | 105 ------ .../CPP/dataprotectionsample.cpp | 82 ----- .../Cryptography.KeyNumber/cpp/sample.cpp | 20 -- .../Cryptography.Oid/CPP/cryptography.oid.cpp | 61 ---- .../cpp/sample.cpp | 100 ------ .../CPP/fileexample.cpp | 146 -------- .../CPP/memoryexample.cpp | 170 --------- .../cpp/example.cpp | 57 --- .../CPP/example.cpp | 52 --- .../CPP/example.cpp | 81 ----- .../CPP/example.cpp | 107 ------ .../CPP/example.cpp | 94 ----- .../CPP/example.cpp | 110 ------ .../CPP/example2.cpp | 77 ---- .../CPP/example.cpp | 174 --------- .../CPP/example.cpp | 104 ------ .../CPP/example.cpp | 175 --------- .../CPP/sample.cpp | 63 ---- .../CPP/Cryptography.SmartCardCSP.cpp | 38 -- .../CPP/sample.cpp | 29 -- .../CPP/sample.cpp | 28 -- .../CPP/example.cpp | 27 -- .../CPP/sample.cpp | 63 ---- .../CPP/sample.cpp | 207 ----------- .../CPP/sample.cpp | 178 ---------- .../CPP/sample.cpp | 169 --------- .../CPP/sample.cpp | 179 ---------- .../CPP/Cryptography.XML.XMLEncMapKey.cpp | 200 ----------- .../CPP/Cryptography.XML.XMLEncMapKeyX509.cpp | 133 ------- .../Cryptography.XML.XMLEncMinimalDecrypt.cpp | 135 ------- ...ptography.XML.XMLEncMinimalDecryptData.cpp | 196 ---------- .../CPP/example.cpp | 181 ---------- .../CPP/sample.cpp | 178 ---------- .../CPP/sample.cpp | 202 ----------- .../CPP/sample.cpp | 193 ---------- .../cpp/sample.cpp | 75 ---- .../HMACSHA256/CPP/hmacsha256.cpp | 134 ------- .../HMACSHA384/CPP/hmacsha384.cpp | 134 ------- .../HMACSHA512/CPP/hmacsha512.cpp | 134 ------- .../IndentedTextWriterExample/CPP/form1.cpp | 120 ------- .../cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp | 75 ---- .../RijndaelManaged Example/CPP/class1.cpp | 172 --------- .../SecureString.xAt/CPP/SecureString.xAt.cpp | 85 ----- .../CPP/SecureString.xChar.cpp | 62 ---- .../CPP/SecurityElementMembers.cpp | 290 --------------- .../CPP/example.cpp | 25 -- .../CPP/example.cpp | 18 - .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 26 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 26 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 26 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 26 -- .../CPP/example.cpp | 21 -- .../CPP/example.cpp | 27 -- .../CPP/sample.cpp | 173 --------- .../XMLDSIG Signing/CPP/source.cpp | 57 --- .../XMLDSIG Verification/CPP/source.cpp | 36 -- .../VS_Snippets_CLR/capikey/CPP/capikey.cpp | 22 -- .../cpp/encrypteddata.cpp | 61 ---- .../CPP/example.cpp | 71 ---- .../CPP/encrypteddata.cpp | 55 --- .../VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp | 96 ----- .../x509chaintest/CPP/remarks.cpp | 26 -- .../x509chaintest/CPP/x509chaintest.cpp | 73 ---- .../x509store2/CPP/x509store2.cpp | 79 ----- .../classic Array Example/CPP/source.cpp | 74 ---- .../classic Array Example/CPP/source3.cpp | 68 ---- .../CPP/source.cpp | 80 ----- .../CPP/source.cpp | 72 ---- .../CPP/source.cpp | 67 ---- .../CPP/source2.cpp | 61 ---- .../CPP/source.cpp | 46 --- .../CPP/source.cpp | 48 --- .../CPP/source.cpp | 53 --- .../CPP/source.cpp | 77 ---- .../CPP/source.cpp | 63 ---- .../CPP/source.cpp | 51 --- .../CPP/source.cpp | 68 ---- .../CPP/source.cpp | 61 ---- .../CPP/source.cpp | 61 ---- .../CPP/source.cpp | 32 -- .../CPP/source.cpp | 80 ----- .../CPP/source.cpp | 46 --- .../classic DES Example/CPP/source.cpp | 46 --- .../CPP/source.cpp | 41 --- .../classic Delegate Example/CPP/source.cpp | 63 ---- .../CPP/source.cpp | 30 -- .../CPP/class1.cpp | 153 -------- .../CPP/resxresourcereader.cpp | 30 -- .../CPP/useresxdatanodes.cpp | 112 ------ .../CPP/getenumerator.cpp | 22 -- .../CPP/getenumerator.cpp | 22 -- .../CPP/resourcewritercstr1.cpp | 24 -- .../CPP/resourcewriterdispose.cpp | 24 -- .../CPP/resourcewritergenerate.cpp | 25 -- .../AllowPartiallyTrustedCallersAttribute.cpp | 150 -------- .../cpp/customcrypto.cpp | 320 ----------------- .../cpp/customcryptoimpl.cpp | 129 ------- .../CPP/members.cpp | 71 ---- .../CPP/cryptographicexceptionmembers.cpp | 243 ------------- .../CPP/sample.cpp | 50 --- .../CPP/sample.cpp | 36 -- .../CPP/class1.cpp | 56 --- .../CPP/members.cpp | 110 ------ .../CPP/contosokeyedhash.cpp | 80 ----- .../CPP/maskgenerator.cpp | 114 ------ .../CPP/sample.cpp | 52 --- .../CPP/sample.cpp | 25 -- .../CPP/sample.cpp | 33 -- .../CPP/sample.cpp | 106 ------ .../CPP/rsaencoder.cpp | 213 ----------- .../CPP/members.cpp | 129 ------- .../CPP/xmldsigdetach.cpp | 132 ------- .../CPP/xmldsigenv.cpp | 171 --------- .../CPP/exampledetached.cpp | 132 ------- .../CPP/exampleenvelope.cpp | 174 --------- .../CPP/examplecreatedetached.cpp | 100 ------ .../CPP/examplecreateenvelope.cpp | 135 ------- .../CPP/exampleenvelope.cpp | 170 --------- .../CPP/example.cpp | 172 --------- .../CPP/exampledetached.cpp | 124 ------- .../CPP/exampleenvelope.cpp | 159 --------- .../CPP/xmldsigdetachedkeyedhashalg.cpp | 117 ------ .../CPP/xmldsigenvkeyedhashalg.cpp | 160 --------- .../CPP/sampledetached.cpp | 134 ------- .../CPP/sampleenvelope.cpp | 168 --------- .../CPP/members.cpp | 219 ------------ .../CPP/members.cpp | 334 ------------------ .../cpp/members.cpp | 290 --------------- .../CPP/members.cpp | 261 -------------- .../cpp/Ctor2.cpp | 25 -- .../cpp/Ctor3.cpp | 25 -- .../cpp/source.cpp | 37 -- .../cpp/source.cpp | 32 -- .../cpp/source.cpp | 48 --- .../cpp/source.cpp | 39 -- .../cpp/friend1.cpp | 39 -- .../cpp/friend2.cpp | 12 - .../cpp/encryptor.cpp | 54 --- .../cpp/ctor1.cpp | 23 -- .../cpp/remarks.cpp | 44 --- 159 files changed, 14547 deletions(-) delete mode 100644 snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp delete mode 100644 snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp diff --git a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp b/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp deleted file mode 100644 index d20aed62b38..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CertInfo/CPP/certinfo.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Security::Cryptography::X509Certificates; - -//Reads a file. -array^ ReadFile( String^ fileName ) -{ - FileStream^ f = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read ); - int size = (int)f->Length; - array^data = gcnew array(size); - size = f->Read( data, 0, size ); - f->Close(); - return data; -} - -[SecurityPermissionAttribute(SecurityAction::LinkDemand, Unrestricted = true)] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - //Test for correct number of arguments. - if ( args->Length < 2 ) - { - Console::WriteLine( "Usage: CertInfo " ); - return -1; - } - - try - { - System::Security::Cryptography::X509Certificates::X509Certificate2 ^ x509 = - gcnew System::Security::Cryptography::X509Certificates::X509Certificate2; - - //Create X509Certificate2 object from .cer file. - array^rawData = ReadFile( args[ 1 ] ); - - x509->Import(rawData); - - //Print to console information contained in the certificate. - Console::WriteLine( "{0}Subject: {1}{0}", Environment::NewLine, x509->Subject ); - Console::WriteLine( "{0}Issuer: {1}{0}", Environment::NewLine, x509->Issuer ); - Console::WriteLine( "{0}Version: {1}{0}", Environment::NewLine, x509->Version ); - Console::WriteLine( "{0}Valid Date: {1}{0}", Environment::NewLine, x509->NotBefore ); - Console::WriteLine( "{0}Expiry Date: {1}{0}", Environment::NewLine, x509->NotAfter ); - Console::WriteLine( "{0}Thumbprint: {1}{0}", Environment::NewLine, x509->Thumbprint ); - Console::WriteLine( "{0}Serial Number: {1}{0}", Environment::NewLine, x509->SerialNumber ); - Console::WriteLine( "{0}Friendly Name: {1}{0}", Environment::NewLine, x509->PublicKey->Oid->FriendlyName ); - Console::WriteLine( "{0}Public Key Format: {1}{0}", Environment::NewLine, x509->PublicKey->EncodedKeyValue->Format(true) ); - Console::WriteLine( "{0}Raw Data Length: {1}{0}", Environment::NewLine, x509->RawData->Length ); - Console::WriteLine( "{0}Certificate to string: {1}{0}", Environment::NewLine, x509->ToString( true ) ); - Console::WriteLine( "{0}Certificate to XML String: {1}{0}", Environment::NewLine, x509->PublicKey->Key->ToXmlString( false ) ); - - //Add the certificate to a X509Store. - X509Store ^ store = gcnew X509Store; - store->Open( OpenFlags::MaxAllowed ); - store->Add( x509 ); - store->Close(); - } - catch ( DirectoryNotFoundException^ ) - { - Console::WriteLine( "Error: The directory specified could not be found." ); - } - catch ( IOException^ ) - { - Console::WriteLine( "Error: A file in the directory could not be accessed." ); - } - catch ( NullReferenceException^ ) - { - Console::WriteLine( "File must be a .cer file. Program does not have access to that type of file." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp b/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp deleted file mode 100644 index bbe9ba49645..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CertSelect/CPP/certselect.cpp +++ /dev/null @@ -1,47 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Permissions; -using namespace System::IO; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - try - { - X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection ^ collection = dynamic_cast(store->Certificates); - X509Certificate2Collection ^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false )); - X509Certificate2Collection ^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag::MultiSelection); - Console::WriteLine( "Number of certificates: {0}{1}", scollection->Count, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum = scollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum->Current); - array^rawdata = x509->RawData; - Console::WriteLine( "Content Type: {0}{1}", X509Certificate2::GetCertContentType( rawdata ), Environment::NewLine ); - Console::WriteLine( "Friendly Name: {0}{1}", x509->FriendlyName, Environment::NewLine ); - Console::WriteLine( "Certificate Verified?: {0}{1}", x509->Verify(), Environment::NewLine ); - Console::WriteLine( "Simple Name: {0}{1}", x509->GetNameInfo( X509NameType::SimpleName, true ), Environment::NewLine ); - Console::WriteLine( "Signature Algorithm: {0}{1}", x509->SignatureAlgorithm->FriendlyName, Environment::NewLine ); - Console::WriteLine( "Private Key: {0}{1}", x509->PrivateKey->ToXmlString( false ), Environment::NewLine ); - Console::WriteLine( "Public Key: {0}{1}", x509->PublicKey->Key->ToXmlString( false ), Environment::NewLine ); - Console::WriteLine( "Certificate Archived?: {0}{1}", x509->Archived, Environment::NewLine ); - Console::WriteLine( "Length of Raw Data: {0}{1}", x509->RawData->Length, Environment::NewLine ); - x509->Reset(); - } - store->Close(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( "Information could not be written out for this certificate." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp deleted file mode 100644 index 262a32465c4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/CipherReference2/CPP/example.cpp +++ /dev/null @@ -1,38 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the GetXml method in the CipherReference class to -/// write the XML values for the CipherReference to the console. - -[STAThread] -int main() -{ - - //Create a URI string. - String^ uri = "http://www.woodgrovebank.com/document.xml"; - - // Create a Base64 transform. The input content retrieved from the - // URI should be Base64-decoded before other processing. - Transform^ base64 = gcnew XmlDsigBase64Transform; - - //Create a transform chain and add the transform to it. - TransformChain^ tc = gcnew TransformChain; - tc->Add( base64 ); - - //Create information. - CipherReference ^ reference = gcnew CipherReference( uri,tc ); - - // Write the CipherReference value to the console. - Console::WriteLine( "Cipher Reference data: {0}", reference->GetXml()->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp deleted file mode 100644 index 99c669d9f27..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.3DES.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new TripleDES object to generate a random key - // and initialization vector (IV). - { - TripleDES^ tripleDes; - - try - { - tripleDes = TripleDES::Create(); - key = tripleDes->Key; - iv = tripleDes->IV; - } - finally - { - delete tripleDes; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES encryptor from the key and IV - encryptor = tripleDes->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (tripleDes != nullptr) - delete tripleDes; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - TripleDES^ tripleDes = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new TripleDES object. - tripleDes = TripleDES::Create(); - // Create a TripleDES decryptor from the key and IV - decryptor = tripleDes->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (tripleDes != nullptr) - delete tripleDes; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp deleted file mode 100644 index 3f109c53866..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.AsnEncodedData/CPP/asnencodeddata.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; - -int main() -{ - - //The following example demonstrates the usage of the AsnEncodedData classes. - // Asn encoded data is read from the extensions of an X509 certificate. - try - { - - // Open the certificate store. - X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection^ collection = dynamic_cast(store->Certificates); - X509Certificate2Collection^ fcollection = dynamic_cast(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false )); - - // Select one or more certificates to display extensions information. - X509Certificate2Collection^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, L"Certificate Select",L"Select certificates from the following list to get extension information on that certificate",X509SelectionFlag::MultiSelection); - - // Create a new AsnEncodedDataCollection object. - AsnEncodedDataCollection^ asncoll = gcnew AsnEncodedDataCollection; - for ( int i = 0; i < scollection->Count; i++ ) - { - - // Display certificate information. - Console::ForegroundColor = ConsoleColor::Red; - Console::WriteLine( L"Certificate name: {0}", scollection[i]->GetName() ); - Console::ResetColor(); - - // Display extensions information. - System::Collections::IEnumerator^ myEnum = scollection[i]->Extensions->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Extension^ extension = safe_cast(myEnum->Current); - - // Create an AsnEncodedData object using the extensions information. - AsnEncodedData^ asndata = gcnew AsnEncodedData( extension->Oid,extension->RawData ); - Console::ForegroundColor = ConsoleColor::Green; - Console::WriteLine( L"Extension type: {0}", extension->Oid->FriendlyName ); - Console::WriteLine( L"Oid value: {0}", asndata->Oid->Value ); - Console::WriteLine( L"Raw data length: {0} {1}", asndata->RawData->Length, Environment::NewLine ); - Console::ResetColor(); - Console::WriteLine( asndata->Format(true) ); - Console::WriteLine( Environment::NewLine ); - - // Add the AsnEncodedData object to the AsnEncodedDataCollection object. - asncoll->Add( asndata ); - } - - Console::WriteLine( Environment::NewLine ); - - } - Console::ForegroundColor = ConsoleColor::Red; - Console::WriteLine( L"Number of AsnEncodedData items in the collection: {0} {1}", asncoll->Count, Environment::NewLine ); - Console::ResetColor(); - store->Close(); - - //Create an enumerator for moving through the collection. - AsnEncodedDataEnumerator^ asne = asncoll->GetEnumerator(); - - //You must execute a MoveNext() to get to the first item in the collection. - asne->MoveNext(); - - // Write out AsnEncodedData in the collection. - Console::ForegroundColor = ConsoleColor::Blue; - Console::WriteLine( L"First AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); - Console::ResetColor(); - asne->MoveNext(); - Console::ForegroundColor = ConsoleColor::DarkBlue; - Console::WriteLine( L"Second AsnEncodedData in the collection: {0}", asne->Current->Format(true) ); - Console::ResetColor(); - - //Return index in the collection to the beginning. - asne->Reset(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( L"Information could not be written out for this certificate." ); - } - - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp deleted file mode 100644 index e48f4e14aa9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new DES object to generate a random key - // and initialization vector (IV). - { - DES^ des; - - try - { - des = DES::Create(); - key = des->Key; - iv = des->IV; - } - finally - { - delete des; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new DES object. - des = DES::Create(); - // Create a DES encryptor from the key and IV - encryptor = des->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (des != nullptr) - delete des; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new DES object. - des = DES::Create(); - // Create a DES decryptor from the key and IV - decryptor = des->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (des != nullptr) - delete des; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 27a8c01000f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DES.Create.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,170 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv); -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new DES object to generate a random key - // and initialization vector (IV). - { - DES^ des; - - try - { - des = DES::Create(); - key = des->Key; - iv = des->IV; - } - finally - { - delete des; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^ encrypted = EncryptTextToMemory(original, key, iv); - - // Decrypt the buffer back to a string. - String^ decrypted = DecryptTextFromMemory(encrypted, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - - try - { - // Create a MemoryStream. - mStream = gcnew MemoryStream; - - DES^ des = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create a new DES object. - des = DES::Create(); - // Create a DES encryptor from the key and IV - encryptor = des->CreateEncryptor(key, iv); - // Create a CryptoStream using the MemoryStream and encryptor - cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - - // Disposing the CryptoStream completes the encryption and flushes the stream. - delete cStream; - - // Get an array of bytes from the MemoryStream that holds the encrypted data. - array^ ret = mStream->ToArray(); - - // Return the encrypted buffer. - return ret; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (des != nullptr) - delete des; - } - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (mStream != nullptr) - delete mStream; - } -} - -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - DES^ des = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create buffer to hold the decrypted data. - // DES-encrypted data will always be slightly bigger than the decrypted data. - array^ decrypted = gcnew array(encrypted->Length); - Int32 offset = 0; - - // Create a new MemoryStream using the provided array of encrypted data. - mStream = gcnew MemoryStream(encrypted); - // Create a new DES object. - des = DES::Create(); - // Create a DES decryptor from the key and IV - decryptor = des->CreateDecryptor(key, iv); - // Create a CryptoStream using the MemoryStream and decryptor - cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read); - - // Keep reading from the CryptoStream until it finishes (returns 0). - Int32 read = 1; - - while (read > 0) - { - read = cStream->Read(decrypted, offset, decrypted->Length - offset); - offset += read; - } - - // Convert the buffer into a string and return it. - return Encoding::UTF8->GetString(decrypted, 0, offset); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (des != nullptr) - delete des; - - if (mStream != nullptr) - delete mStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp deleted file mode 100644 index 0aeedb91f59..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.File/CPP/fileexample.cpp +++ /dev/null @@ -1,113 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -void EncryptTextToFile( String^ Data, String^ FileName, array^Key, array^IV ) -{ - try - { - - // Create or open the specified file. - FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate ); - - // Create a CryptoStream using the FileStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write ); - - // Create a StreamWriter using the CryptoStream. - StreamWriter^ sWriter = gcnew StreamWriter( cStream ); - - // Write the data to the stream - // to encrypt it. - sWriter->WriteLine( Data ); - - // Close the streams and - // close the file. - sWriter->Close(); - cStream->Close(); - fStream->Close(); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - } - catch ( UnauthorizedAccessException^ e ) - { - Console::WriteLine( "A file error occurred: {0}", e->Message ); - } - -} - -String^ DecryptTextFromFile( String^ FileName, array^Key, array^IV ) -{ - try - { - - // Create or open the specified file. - FileStream^ fStream = File::Open( FileName, FileMode::OpenOrCreate ); - - // Create a CryptoStream using the FileStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( fStream,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read ); - - // Create a StreamReader using the CryptoStream. - StreamReader^ sReader = gcnew StreamReader( cStream ); - - // Read the data from the stream - // to decrypt it. - String^ val = sReader->ReadLine(); - - // Close the streams and - // close the file. - sReader->Close(); - cStream->Close(); - fStream->Close(); - - // Return the string. - return val; - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - catch ( UnauthorizedAccessException^ e ) - { - Console::WriteLine( "A file error occurred: {0}", e->Message ); - return nullptr; - } - -} - -int main() -{ - try - { - - // Create a new DESCryptoServiceProvider object - // to generate a key and initialization vector (IV). - DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider; - - // Create a string to encrypt. - String^ sData = "Here is some data to encrypt."; - String^ FileName = "CText.txt"; - - // Encrypt text to a file using the file name, key, and IV. - EncryptTextToFile( sData, FileName, DESalg->Key, DESalg->IV ); - - // Decrypt the text from a file using the file name, key, and IV. - String^ Final = DecryptTextFromFile( FileName, DESalg->Key, DESalg->IV ); - - // Display the decrypted string to the console. - Console::WriteLine( Final ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 3fdcdbcd1dd..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DESCSP.CreateEncryptor.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,105 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -array^ EncryptTextToMemory( String^ Data, array^Key, array^IV ) -{ - try - { - - // Create a MemoryStream. - MemoryStream^ mStream = gcnew MemoryStream; - - // Create a CryptoStream using the MemoryStream - // and the passed key and initialization vector (IV). - CryptoStream^ cStream = gcnew CryptoStream( mStream,(gcnew DESCryptoServiceProvider)->CreateEncryptor( Key, IV ),CryptoStreamMode::Write ); - - // Convert the passed string to a byte array. - array^toEncrypt = (gcnew ASCIIEncoding)->GetBytes( Data ); - - // Write the byte array to the crypto stream and flush it. - cStream->Write( toEncrypt, 0, toEncrypt->Length ); - cStream->FlushFinalBlock(); - - // Get an array of bytes from the - // MemoryStream that holds the - // encrypted data. - array^ret = mStream->ToArray(); - - // Close the streams. - cStream->Close(); - mStream->Close(); - - // Return the encrypted buffer. - return ret; - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - -} - -String^ DecryptTextFromMemory( array^Data, array^Key, array^IV ) -{ - try - { - - // Create a new MemoryStream using the passed - // array of encrypted data. - MemoryStream^ msDecrypt = gcnew MemoryStream( Data ); - - // Create a CryptoStream using the MemoryStream - // and the passed key and initialization vector (IV). - CryptoStream^ csDecrypt = gcnew CryptoStream( msDecrypt,(gcnew DESCryptoServiceProvider)->CreateDecryptor( Key, IV ),CryptoStreamMode::Read ); - - // Create buffer to hold the decrypted data. - array^fromEncrypt = gcnew array(Data->Length); - - // Read the decrypted data out of the crypto stream - // and place it into the temporary buffer. - csDecrypt->Read( fromEncrypt, 0, fromEncrypt->Length ); - - //Convert the buffer into a string and return it. - return (gcnew ASCIIEncoding)->GetString( fromEncrypt ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "A Cryptographic error occurred: {0}", e->Message ); - return nullptr; - } - -} - -int main() -{ - try - { - - // Create a new DESCryptoServiceProvider object - // to generate a key and initialization vector (IV). - DESCryptoServiceProvider^ DESalg = gcnew DESCryptoServiceProvider; - - // Create a string to encrypt. - String^ sData = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^Data = EncryptTextToMemory( sData, DESalg->Key, DESalg->IV ); - - // Decrypt the buffer back to a string. - String^ Final = DecryptTextFromMemory( Data, DESalg->Key, DESalg->IV ); - - // Display the decrypted string to the console. - Console::WriteLine( Final ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp deleted file mode 100644 index 7b3ed1ec455..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.DataProtectionSample/CPP/dataprotectionsample.cpp +++ /dev/null @@ -1,82 +0,0 @@ -// -#using - -using namespace System; -using namespace System::Security::Cryptography; - -public ref class DataProtectionSample -{ -private: - - // Create byte array for additional entropy when using Protect method. - static array^s_additionalEntropy = {9,8,7,6,5}; - -public: - static void Main() - { - - // Create a simple byte array containing data to be encrypted. - array^secret = {0,1,2,3,4,1,2,3,4}; - - //Encrypt the data. - array^encryptedSecret = Protect( secret ); - Console::WriteLine( "The encrypted byte array is:" ); - PrintValues( encryptedSecret ); - - // Decrypt the data and store in a byte array. - array^originalData = Unprotect( encryptedSecret ); - Console::WriteLine( "{0}The original data is:", Environment::NewLine ); - PrintValues( originalData ); - } - - static array^ Protect( array^data ) - { - try - { - - // Encrypt the data using DataProtectionScope.CurrentUser. The result can be decrypted - // only by the same current user. - return ProtectedData::Protect( data, s_additionalEntropy, DataProtectionScope::CurrentUser ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "Data was not encrypted. An error occurred." ); - Console::WriteLine( e ); - return nullptr; - } - } - - static array^ Unprotect( array^data ) - { - try - { - - //Decrypt the data using DataProtectionScope.CurrentUser. - return ProtectedData::Unprotect( data, s_additionalEntropy, DataProtectionScope::CurrentUser ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( "Data was not decrypted. An error occurred." ); - Console::WriteLine( e ); - return nullptr; - } - } - - static void PrintValues( array^myArr ) - { - System::Collections::IEnumerator^ myEnum = myArr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - Byte i = safe_cast(myEnum->Current); - Console::Write( "\t{0}", i ); - } - - Console::WriteLine(); - } -}; - -int main() -{ - DataProtectionSample::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp deleted file mode 100644 index 8bd6a68686f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.KeyNumber/cpp/sample.cpp +++ /dev/null @@ -1,20 +0,0 @@ -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -int main() -{ - // - // Create a new CspParameters object. - CspParameters^ cspParams = gcnew CspParameters(); - - // Specify an exchange key. - cspParams->KeyNumber = (int) KeyNumber::Exchange; - - // Initialize the RSACryptoServiceProvider - // with the CspParameters object. - RSACryptoServiceProvider^ RSACSP = gcnew RSACryptoServiceProvider(cspParams); - // -}; - diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp deleted file mode 100644 index 3189ba48a53..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.Oid/CPP/cryptography.oid.cpp +++ /dev/null @@ -1,61 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - - // Assign values to strings. - String^ Value1 = "1.2.840.113549.1.1.1"; - String^ Name1 = "3DES"; - String^ Value2 = "1.3.6.1.4.1.311.20.2"; - String^ InvalidName = "This name is not a valid name"; - String^ InvalidValue = "1.1.1.1.1.1.1.1"; - - // Create new Oid objects using the specified values. - // Note that the corresponding Value or Friendly Name property is automatically added to the object. - Oid ^ o1 = gcnew Oid( Value1 ); - Oid ^ o2 = gcnew Oid( Name1 ); - - // Create a new Oid object using the specified Value and Friendly Name properties. - // Note that the two are not compared to determine if the Value is associated - // with the Friendly Name. - Oid ^ o3 = gcnew Oid( Value2,InvalidName ); - - //Create a new Oid object using the specified Value. Note that if the value - // is invalid or not known, no value is assigned to the Friendly Name property. - Oid ^ o4 = gcnew Oid( InvalidValue ); - - //Write out the property information of the Oid objects. - Console::WriteLine( "Oid1: Automatically assigned Friendly Name: {0}, {1}", o1->FriendlyName, o1->Value ); - Console::WriteLine( "Oid2: Automatically assigned Value: {0}, {1}", o2->FriendlyName, o2->Value ); - Console::WriteLine( "Oid3: Name and Value not compared: {0}, {1}", o3->FriendlyName, o3->Value ); - Console::WriteLine( "Oid4: Invalid Value used: {0}, {1} {2}", o4->FriendlyName, o4->Value, Environment::NewLine ); - - //Create an Oid collection and add several Oid objects. - OidCollection ^ oc = gcnew OidCollection; - oc->Add( o1 ); - oc->Add( o2 ); - oc->Add( o3 ); - Console::WriteLine( "Number of Oids in the collection: {0}", oc->Count ); - Console::WriteLine( "Is synchronized: {0} {1}", oc->IsSynchronized, Environment::NewLine ); - - //Create an enumerator for moving through the collection. - OidEnumerator ^ oe = oc->GetEnumerator(); - - //You must execute a MoveNext() to get to the first item in the collection. - oe->MoveNext(); - - // Write out Oids in the collection. - Console::WriteLine( "First Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value ); - oe->MoveNext(); - Console::WriteLine( "Second Oid in collection: {0},{1}", oe->Current->FriendlyName, oe->Current->Value ); - - //Return index in the collection to the beginning. - oe->Reset(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp deleted file mode 100644 index 06b5a8483db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.PasswordDerivedbytes/cpp/sample.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -// Generates a random salt value of the specified length. -array^ CreateRandomSalt(int length) -{ - // Create a buffer - array^ randomBytes; - - if (length >= 1) - { - randomBytes = gcnew array (length); - } - else - { - randomBytes = gcnew array (1); - } - - // Create a new RandomNumberGenerator. - RandomNumberGenerator^ randomNumberGenerator = - RandomNumberGenerator::Create(); - - // Fill the buffer with random bytes. - randomNumberGenerator->GetBytes(randomBytes); - - // return the bytes. - return randomBytes; -} - -// Clears the bytes in a buffer so they can't later be read from memory. -void ClearBytes(array^ buffer) -{ - // Check arguments. - if (buffer == nullptr) - { - throw gcnew ArgumentNullException("buffer"); - } - - // Set each byte in the buffer to 0. - for (int x = 0; x <= buffer->Length - 1; x++) - { - buffer[x] = 0; - } -} - -int main(array^ args) -{ - - // Get a password from the user. - Console::WriteLine("Enter a password to produce a key:"); - - // Security Note: Never hard-code a password within your - // source code. Hard-coded passwords can be retrieved - // from a compiled assembly. - array^ password = Encoding::Unicode->GetBytes(Console::ReadLine()); - - array^ randomSalt = CreateRandomSalt(7); - - // Create a TripleDESCryptoServiceProvider object. - TripleDESCryptoServiceProvider^ cryptoDESProvider = - gcnew TripleDESCryptoServiceProvider(); - - try - { - Console::WriteLine("Creating a key with PasswordDeriveBytes..."); - - // Create a PasswordDeriveBytes object and then create - // a TripleDES key from the password and salt. - PasswordDeriveBytes^ passwordDeriveBytes = gcnew PasswordDeriveBytes - (password->ToString(), randomSalt); - - // - // Create the key and set it to the Key property - // of the TripleDESCryptoServiceProvider object. - // This example uses the SHA1 algorithm. - // Due to collision problems with SHA1, Microsoft recommends SHA256 or better. - cryptoDESProvider->Key = passwordDeriveBytes->CryptDeriveKey - ("TripleDES", "SHA1", 192, cryptoDESProvider->IV); - // - Console::WriteLine("Operation complete."); - } - catch (Exception^ ex) - { - Console::WriteLine(ex->Message); - } - finally - { - // Clear the buffers - ClearBytes(password); - ClearBytes(randomSalt); - - // Clear the key. - cryptoDESProvider->Clear(); - } - - Console::ReadLine(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp deleted file mode 100644 index c6753a5be6f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.File/CPP/fileexample.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Text; - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv); -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new RC2 object to generate a random key - // and initialization vector (IV). - { - RC2^ rc2; - - try - { - rc2 = RC2::Create(); - key = rc2->Key; - iv = rc2->IV; - } - finally - { - delete rc2; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - // The name/path of the file to write. - String^ filename = "CText.enc"; - - // Encrypt the string to a file. - EncryptTextToFile(original, filename, key, iv); - - // Decrypt the file back to a string. - String^ decrypted = DecryptTextFromFile(filename, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -void EncryptTextToFile(String^ text, String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create or open the specified file. - fStream = File::Open(path, FileMode::Create); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 encryptor from the key and IV - encryptor = rc2->CreateEncryptor(key, iv); - // Create a CryptoStream using the FileStream and encryptor - cStream = gcnew CryptoStream(fStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (rc2 != nullptr) - delete rc2; - - if (fStream != nullptr) - delete fStream; - } -} - -String^ DecryptTextFromFile(String^ path, array^ key, array^ iv) -{ - FileStream^ fStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - StreamReader^ reader = nullptr; - - try - { - // Open the specified file - fStream = File::OpenRead(path); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 decryptor from the key and IV - decryptor = rc2->CreateDecryptor(key, iv); - // Create a CryptoStream using the FileStream and decryptor - cStream = gcnew CryptoStream(fStream, decryptor, CryptoStreamMode::Read); - // Create a StreamReader to turn the bytes back into text - reader = gcnew StreamReader(cStream, Encoding::UTF8); - - // Read back all of the text from the StreamReader, which receives - // the decrypted bytes from the CryptoStream, which receives the - // encrypted bytes from the FileStream. - return reader->ReadToEnd(); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (rc2 != nullptr) - delete rc2; - - if (fStream != nullptr) - delete fStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp deleted file mode 100644 index 3179ea1bfc1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2.Create.Memory/CPP/memoryexample.cpp +++ /dev/null @@ -1,170 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv); -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv); - -int main() -{ - try - { - array^ key; - array^ iv; - - // Create a new RC2 object to generate a random key - // and initialization vector (IV). - { - RC2^ rc2; - - try - { - rc2 = RC2::Create(); - key = rc2->Key; - iv = rc2->IV; - } - finally - { - delete rc2; - } - } - - // Create a string to encrypt. - String^ original = "Here is some data to encrypt."; - - // Encrypt the string to an in-memory buffer. - array^ encrypted = EncryptTextToMemory(original, key, iv); - - // Decrypt the buffer back to a string. - String^ decrypted = DecryptTextFromMemory(encrypted, key, iv); - - // Display the decrypted string to the console. - Console::WriteLine(decrypted); - } - catch (Exception^ e) - { - Console::WriteLine(e->Message); - } -} - -array^ EncryptTextToMemory(String^ text, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - - try - { - // Create a MemoryStream. - mStream = gcnew MemoryStream; - - RC2^ rc2 = nullptr; - ICryptoTransform^ encryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 encryptor from the key and IV - encryptor = rc2->CreateEncryptor(key, iv); - // Create a CryptoStream using the MemoryStream and encryptor - cStream = gcnew CryptoStream(mStream, encryptor, CryptoStreamMode::Write); - - // Convert the provided string to a byte array. - array^ toEncrypt = Encoding::UTF8->GetBytes(text); - - // Write the byte array to the crypto stream. - cStream->Write(toEncrypt, 0, toEncrypt->Length); - - // Disposing the CryptoStream completes the encryption and flushes the stream. - delete cStream; - - // Get an array of bytes from the MemoryStream that holds the encrypted data. - array^ ret = mStream->ToArray(); - - // Return the encrypted buffer. - return ret; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (encryptor != nullptr) - delete encryptor; - - if (rc2 != nullptr) - delete rc2; - } - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (mStream != nullptr) - delete mStream; - } -} - -String^ DecryptTextFromMemory(array^ encrypted, array^ key, array^ iv) -{ - MemoryStream^ mStream = nullptr; - RC2^ rc2 = nullptr; - ICryptoTransform^ decryptor = nullptr; - CryptoStream^ cStream = nullptr; - - try - { - // Create buffer to hold the decrypted data. - // RC2-encrypted data will always be slightly bigger than the decrypted data. - array^ decrypted = gcnew array(encrypted->Length); - Int32 offset = 0; - - // Create a new MemoryStream using the provided array of encrypted data. - mStream = gcnew MemoryStream(encrypted); - // Create a new RC2 object. - rc2 = RC2::Create(); - // Create an RC2 decryptor from the key and IV - decryptor = rc2->CreateDecryptor(key, iv); - // Create a CryptoStream using the MemoryStream and decryptor - cStream = gcnew CryptoStream(mStream, decryptor, CryptoStreamMode::Read); - - // Keep reading from the CryptoStream until it finishes (returns 0). - Int32 read = 1; - - while (read > 0) - { - read = cStream->Read(decrypted, offset, decrypted->Length - offset); - offset += read; - } - - // Convert the buffer into a string and return it. - return Encoding::UTF8->GetString(decrypted, 0, offset); - } - catch (CryptographicException^ e) - { - Console::WriteLine("A Cryptographic error occurred: {0}", e->Message); - throw; - } - finally - { - if (cStream != nullptr) - delete cStream; - - if (decryptor != nullptr) - delete decryptor; - - if (rc2 != nullptr) - delete rc2; - - if (mStream != nullptr) - delete mStream; - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp deleted file mode 100644 index 2c8834fcc20..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RC2CryptoServiceProvider/cpp/example.cpp +++ /dev/null @@ -1,57 +0,0 @@ -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -int main() -{ - array ^ originalBytes = - ASCIIEncoding::ASCII->GetBytes("Here is some data."); - - //Create a new RC2CryptoServiceProvider. - RC2CryptoServiceProvider^ rc2Provider = - gcnew RC2CryptoServiceProvider(); - rc2Provider->UseSalt = true; - - rc2Provider->GenerateKey(); - rc2Provider->GenerateIV(); - - //Encrypt the data. - MemoryStream^ encryptionMemoryStream = gcnew MemoryStream(); - CryptoStream^ encryptionCryptoStream = gcnew CryptoStream( - encryptionMemoryStream, rc2Provider->CreateEncryptor( - rc2Provider->Key, rc2Provider->IV), CryptoStreamMode::Write); - - //Write all data to the crypto stream and flush it. - encryptionCryptoStream->Write(originalBytes, 0, originalBytes->Length); - encryptionCryptoStream->FlushFinalBlock(); - - //Get encrypted array of bytes. - array^ encryptedBytes = encryptionMemoryStream->ToArray(); - - //Decrypt the previously encrypted message. - MemoryStream^ decryptionMemoryStream = - gcnew MemoryStream(encryptedBytes); - CryptoStream^ decryptionCryptoStream = - gcnew CryptoStream(decryptionMemoryStream, - rc2Provider->CreateDecryptor(rc2Provider->Key,rc2Provider->IV), - CryptoStreamMode::Read); - - array^ unencryptedBytes = - gcnew array(originalBytes->Length); - - //Read the data out of the crypto stream. - decryptionCryptoStream->Read(unencryptedBytes, 0, - unencryptedBytes->Length); - - //Convert the byte array back into a string. - String^ plainText = ASCIIEncoding::ASCII->GetString(unencryptedBytes); - - //Display the results. - Console::WriteLine("Unencrypted text: {0}", plainText); - - Console::ReadLine(); -} - -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp deleted file mode 100644 index 97053716b78..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.Decrypt/CPP/example.cpp +++ /dev/null @@ -1,52 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Encrypt"; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( dataString ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Display the origianl data to the console. - Console::WriteLine( "Original Data: {0}", dataString ); - - //Encrypt the byte array and specify no OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - encryptedData = RSAalg->Encrypt( dataToEncrypt, false ); - - //Display the encrypted data to the console. - Console::WriteLine( "Encrypted Data: {0}", ByteConverter->GetString( encryptedData ) ); - - //Pass the data to ENCRYPT and boolean flag specifying - //no OAEP padding. - decryptedData = RSAalg->Decrypt( encryptedData, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - } - catch ( CryptographicException^ e ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp deleted file mode 100644 index aac2730c2f0..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.PersistKey/CPP/example.cpp +++ /dev/null @@ -1,81 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. The PersistKeyInCsp property is true by - //default, allowing the key to be persisted. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Explicitly set the PersistKeyInCsp property to false - //to delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -int main() -{ - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Delete the key from the key container. - RSADeleteKeyInCSP( KeyContainerName ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp deleted file mode 100644 index cea1dc68672..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData1/CPP/example.cpp +++ /dev/null @@ -1,107 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ HashAndSignBytes( array^DataToSign, RSAParameters Key, int Index, int Length ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataToSign, Index, Length, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - - // Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Sign"; - - // Create byte arrays to hold original, encrypted, and decrypted data. - array^originalData = ByteConverter->GetBytes( dataString ); - array^signedData; - array^smallArray; - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. Start at the fifth offset - // only use data from the next 7 bytes. - signedData = HashAndSignBytes( originalData, Key, 5, 7 ); - - // The previous method only signed one segment - // of the array. Create a new array for verification - // that only holds the data that was actually signed. - // - // Initialize the array. - smallArray = gcnew array(7); - - // Copy 7 bytes starting at the 5th index to - // the new array. - Array::Copy( originalData, 5, smallArray, 0, 7 ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( smallArray, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp deleted file mode 100644 index aa2a389c449..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData2/CPP/example.cpp +++ /dev/null @@ -1,94 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ HashAndSignBytes( array^DataToSign, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataToSign, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256::Create(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - - // Create a UnicodeEncoder to convert between byte array and string. - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - String^ dataString = "Data to Sign"; - - // Create byte arrays to hold original, encrypted, and decrypted data. - array^originalData = ByteConverter->GetBytes( dataString ); - array^signedData; - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. - signedData = HashAndSignBytes( originalData, Key ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( originalData, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp deleted file mode 100644 index ac322898229..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.SignData3/CPP/example.cpp +++ /dev/null @@ -1,110 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -using namespace System::IO; -array^ HashAndSignBytes( Stream^ DataStream, RSAParameters Key ) -{ - try - { - - // Reset the current position in the stream to - // the beginning of the stream (0). RSACryptoServiceProvider - // can't verify the data unless the stream position - // is set to the starting position of the data. - DataStream->Position = 0; - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Hash and sign the data. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->SignData( DataStream, SHA256::Create() ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -bool VerifySignedHash( array^DataToVerify, array^SignedData, RSAParameters Key ) -{ - try - { - - // Create a new instance of RSACryptoServiceProvider using the - // key from RSAParameters. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - RSAalg->ImportParameters( Key ); - - // Verify the data using the signature. Pass a new instance of SHA256 - // to specify the hashing algorithm. - return RSAalg->VerifyData( DataToVerify, SHA256(), SignedData ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return false; - } - -} - -int main() -{ - try - { - ASCIIEncoding^ ByteConverter = gcnew ASCIIEncoding; - - // Create some bytes to be signed. - array^dataBytes = ByteConverter->GetBytes( "Here is some data to sign!" ); - - // Create a buffer for the memory stream. - array^buffer = gcnew array(dataBytes->Length); - - // Create a MemoryStream. - MemoryStream^ mStream = gcnew MemoryStream( buffer ); - - // Write the bytes to the stream and flush it. - mStream->Write( dataBytes, 0, dataBytes->Length ); - mStream->Flush(); - - // Create a new instance of the RSACryptoServiceProvider class - // and automatically create a new key-pair. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - // Export the key information to an RSAParameters object. - // You must pass true to export the private key for signing. - // However, you do not need to export the private key - // for verification. - RSAParameters Key = RSAalg->ExportParameters( true ); - - // Hash and sign the data. - array^signedData = HashAndSignBytes( mStream, Key ); - - // Verify the data and display the result to the - // console. - if ( VerifySignedHash( dataBytes, signedData, Key ) ) - { - Console::WriteLine( "The data was verified." ); - } - else - { - Console::WriteLine( "The data does not match the signature." ); - } - - // Close the MemoryStream. - mStream->Close(); - } - catch ( ArgumentNullException^ ) - { - Console::WriteLine( "The data was not signed or verified" ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp deleted file mode 100644 index 68adc843467..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.UseMachineKey/CPP/example2.cpp +++ /dev/null @@ -1,77 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; - -ref class RSAKeyStoreSample -{ -public: - static void Main() - { - // Set the static UseMachineKeyStore property to use the machine key - // store instead of the user profile key store. All CSP instances not - // initialized with CspParameters will use this setting. - RSACryptoServiceProvider::UseMachineKeyStore = true; - try - { - RSACryptoServiceProvider^ RSAalg; - - // This CSP instance will use the Machine Store as set above and is - // initialized with no parameters. - RSAalg = gcnew RSACryptoServiceProvider(); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - - CspParameters^ cspParams = gcnew CspParameters(); - - cspParams->KeyContainerName = "MyKeyContainer"; - - // This CSP instance will use the User Store since cspParams are used. - RSAalg = gcnew RSACryptoServiceProvider(cspParams); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - - cspParams->Flags |= CspProviderFlags::UseMachineKeyStore; - - // This CSP instance will use the Machine Store. Although cspParams are used, - // the cspParams.Flags is set to CspProviderFlags.UseMachineKeyStore. - RSAalg = gcnew RSACryptoServiceProvider(cspParams); - ShowContainerInfo(RSAalg->CspKeyContainerInfo); - RSAalg->PersistKeyInCsp = false; - delete RSAalg; - } - catch (CryptographicException^ e) - { - Console::WriteLine("Exception: {0}", e->GetType()->FullName); - Console::WriteLine(e->Message); - } - } - - static void ShowContainerInfo(CspKeyContainerInfo^ containerInfo) - { - String^ keyStore; - - Console::WriteLine(); - if (containerInfo->MachineKeyStore) - { - keyStore = "Machine Store"; - } - else - { - keyStore = "User Store"; - } - Console::WriteLine("Key Store: {0}", keyStore); - Console::WriteLine("Key Provider: {0}", containerInfo->ProviderName); - Console::WriteLine("Key Container: \"{0}\"", containerInfo->KeyContainerName); - Console::WriteLine("Generated: {0}", containerInfo->RandomlyGenerated); - Console::WriteLine("Key Nubmer: {0}", containerInfo->KeyNumber); - Console::WriteLine("Removable Key: {0}", containerInfo->Removable); - } -}; - -int main() -{ - RSAKeyStoreSample::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp deleted file mode 100644 index b99a174d918..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-csp/CPP/example.cpp +++ /dev/null @@ -1,174 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was persisted in the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Pass the data to ENCRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false ); - - //Pass the data to DECRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, KeyContainerName, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - RSADeleteKeyInCSP( KeyContainerName ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp deleted file mode 100644 index 19f120af03a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-2/CPP/example.cpp +++ /dev/null @@ -1,104 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This only needs - //toinclude the public key information. - RSAalg->ImportParameters( RSAKeyInfo ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This needs - //to include the private key information. - RSAalg->ImportParameters( RSAKeyInfo ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of RSACryptoServiceProvider to generate - //public and private key data. Pass an integer specifying a key- - //length of 2048. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048 ); - - //Display the key-legth to the console. - Console::WriteLine( "A new key pair of legth {0} was created", RSAalg->KeySize ); - - //Pass the data to ENCRYPT, the public key information - //(using RSACryptoServiceProvider.ExportParameters(false), - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, RSAalg->ExportParameters( false ), false ); - - //Pass the data to DECRYPT, the private key information - //(using RSACryptoServiceProvider.ExportParameters(true), - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, RSAalg->ExportParameters( true ), false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp deleted file mode 100644 index f1f072b4665..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RSACSP.ctor-int32-csp/CPP/example.cpp +++ /dev/null @@ -1,175 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -void RSAPersistKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of RSACryptoServiceProvider to generate - //a new key pair. Pass the CspParameters class to persist the - //key in the container. Pass an intger of 2048 to specify the - //key-size. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( 2048,cspParams ); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key with a key-size of {0} was persisted in the container, \"{1}\".", RSAalg->KeySize, ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -void RSADeleteKeyInCSP( String^ ContainerName ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the - //key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Delete the key entry in the container. - RSAalg->PersistKeyInCsp = false; - - //Call Clear to release resources and delete the key from the container. - RSAalg->Clear(); - - //Indicate that the key was persisted. - Console::WriteLine( "The RSA key was deleted from the container, \"{0}\".", ContainerName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -array^ RSAEncrypt( array^DataToEncrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Encrypt( DataToEncrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, String^ ContainerName, bool DoOAEPPadding ) -{ - try - { - - // Create a new instance of CspParameters. Pass - // 13 to specify a DSA container or 1 to specify - // an RSA container. The default is 1. - CspParameters^ cspParams = gcnew CspParameters; - - // Specify the container name using the passed variable. - cspParams->KeyContainerName = ContainerName; - - //Create a new instance of DSACryptoServiceProvider. - //Pass the CspParameters class to use the key - //from the key in the container. - RSACryptoServiceProvider^ RSAalg = gcnew RSACryptoServiceProvider( cspParams ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - return RSAalg->Decrypt( DataToDecrypt, DoOAEPPadding ); - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - String^ KeyContainerName = "MyKeyContainer"; - - //Create a new key and persist it in - //the key container. - RSAPersistKeyInCSP( KeyContainerName ); - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Pass the data to ENCRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, KeyContainerName, false ); - - //Pass the data to DECRYPT, the name of the key container, - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, KeyContainerName, false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - RSADeleteKeyInCSP( KeyContainerName ); - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp deleted file mode 100644 index 87f5955ad65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.RsaCryptoServiceProvider.CspKeyContainerInfo/CPP/sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -int main() -{ - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider; - try - { - - // Note: In cases where a random key is generated, - // a key container is not created until you call - // a method that uses the key. This example calls - // the Encrypt method before calling the - // CspKeyContainerInfo property so that a key - // container is created. - // Create some data to encrypt and display it. - String^ data = L"Here is some data to encrypt."; - Console::WriteLine( L"Data to encrypt: {0}", data ); - - // Convert the data to an array of bytes and - // encrypt it. - array^byteData = Encoding::ASCII->GetBytes( data ); - array^encData = rsa->Encrypt( byteData, false ); - - // Display the encrypted value. - Console::WriteLine( L"Encrypted Data: {0}", Encoding::ASCII->GetString( encData ) ); - Console::WriteLine(); - Console::WriteLine( L"CspKeyContainerInfo information:" ); - Console::WriteLine(); - - // Create a new CspKeyContainerInfo object. - CspKeyContainerInfo^ keyInfo = rsa->CspKeyContainerInfo; - - // Display the value of each property. - Console::WriteLine( L"Accessible property: {0}", keyInfo->Accessible ); - Console::WriteLine( L"Exportable property: {0}", keyInfo->Exportable ); - Console::WriteLine( L"HardwareDevice property: {0}", keyInfo->HardwareDevice ); - Console::WriteLine( L"KeyContainerName property: {0}", keyInfo->KeyContainerName ); - Console::WriteLine( L"KeyNumber property: {0}", keyInfo->KeyNumber ); - Console::WriteLine( L"MachineKeyStore property: {0}", keyInfo->MachineKeyStore ); - Console::WriteLine( L"Protected property: {0}", keyInfo->Protected ); - Console::WriteLine( L"ProviderName property: {0}", keyInfo->ProviderName ); - Console::WriteLine( L"ProviderType property: {0}", keyInfo->ProviderType ); - Console::WriteLine( L"RandomlyGenerated property: {0}", keyInfo->RandomlyGenerated ); - Console::WriteLine( L"Removable property: {0}", keyInfo->Removable ); - Console::WriteLine( L"UniqueKeyContainerName property: {0}", keyInfo->UniqueKeyContainerName ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e ); - } - finally - { - - // Clear the key. - rsa->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp deleted file mode 100644 index ab2873ba3a4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.SmartCardCSP/CPP/Cryptography.SmartCardCSP.cpp +++ /dev/null @@ -1,38 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - - // To idendify the Smart Card CryptoGraphic Providers on your - // computer, use the Microsoft Registry Editor (Regedit.exe). - // The available Smart Card CryptoGraphic Providers are listed - // in HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. - // Create a new CspParameters object that identifies a - // Smart Card CryptoGraphic Provider. - // The 1st parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider Types. - // The 2nd parameter comes from HKEY_LOCAL_MACHINE\Software\Microsoft\Cryptography\Defaults\Provider. - CspParameters^ csp = gcnew CspParameters( 1,L"Schlumberger Cryptographic Service Provider" ); - csp->Flags = CspProviderFlags::UseDefaultKeyContainer; - - // Initialize an RSACryptoServiceProvider object using - // the CspParameters object. - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( csp ); - - // Create some data to sign. - array^data = gcnew array{ - 0,1,2,3,4,5,6,7 - }; - Console::WriteLine( L"Data : {0}", BitConverter::ToString( data ) ); - - // Sign the data using the Smart Card CryptoGraphic Provider. - array^sig = rsa->SignData( data, L"SHA256" ); - Console::WriteLine( L"Signature : {0}", BitConverter::ToString( sig ) ); - - // Verify the data using the Smart Card CryptoGraphic Provider. - bool verified = rsa->VerifyData( data, L"SHA256", sig ); - Console::WriteLine( L"Verified : {0}", verified ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp deleted file mode 100644 index 99639f7a588..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import-Export/CPP/sample.cpp +++ /dev/null @@ -1,29 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"test.pfx"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate( Certificate ); - array^certData = cert->Export( X509ContentType::Cert ); - X509Certificate^ newCert = gcnew X509Certificate( certData ); - - // Get the value. - String^ resultsTrue = newCert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = newCert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp deleted file mode 100644 index c67a8cb4a04..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate.Import/CPP/sample.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate; - cert->Import(Certificate); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp deleted file mode 100644 index d2dab6fe3be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Certificate/CPP/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = L"Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = gcnew X509Certificate( Certificate ); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp deleted file mode 100644 index 574abf906a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.X509Certificates.X509Extensions/CPP/sample.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - try - { - X509Store^ store = gcnew X509Store( L"MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) ); - X509Certificate2Collection^ collection = dynamic_cast(store->Certificates); - for ( int i = 0; i < collection->Count; i++ ) - { - System::Collections::IEnumerator^ myEnum = collection[ i ]->Extensions->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Extension^ extension = safe_cast(myEnum->Current); - Console::WriteLine( L"{0}({1})", extension->Oid->FriendlyName, extension->Oid->Value ); - if ( extension->Oid->FriendlyName == L"Key Usage" ) - { - X509KeyUsageExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->KeyUsages ); - } - if ( extension->Oid->FriendlyName == L"Basic Constraints" ) - { - X509BasicConstraintsExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->CertificateAuthority ); - Console::WriteLine( ext->HasPathLengthConstraint ); - Console::WriteLine( ext->PathLengthConstraint ); - } - if ( extension->Oid->FriendlyName == L"Subject Key Identifier" ) - { - X509SubjectKeyIdentifierExtension^ ext = dynamic_cast(extension); - Console::WriteLine( ext->SubjectKeyIdentifier ); - } - if ( extension->Oid->FriendlyName == L"Enhanced Key Usage" ) - { - X509EnhancedKeyUsageExtension^ ext = dynamic_cast(extension); - OidCollection^ oids = ext->EnhancedKeyUsages; - System::Collections::IEnumerator^ myEnum1 = oids->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - Oid^ oid = safe_cast(myEnum1->Current); - Console::WriteLine( L"{0}({1})", oid->FriendlyName, oid->Value ); - } - } - } - - } - store->Close(); - } - catch ( CryptographicException^ ) - { - Console::WriteLine( L"Information could not be written out for this certificate." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp deleted file mode 100644 index c7f4f074317..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.MainXMLEncDecryptDataOOP/CPP/sample.cpp +++ /dev/null @@ -1,207 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -ref class TrippleDESDocumentEncryption -{ -protected: - XmlDocument^ docValue; - TripleDES^ algValue; - -public: - TrippleDESDocumentEncryption( XmlDocument^ Doc, TripleDES^ Key ) - { - if ( Doc != nullptr ) - { - docValue = Doc; - } - else - { - throw gcnew ArgumentNullException( L"Doc" ); - } - - if ( Key != nullptr ) - { - algValue = Key; - } - else - { - throw gcnew ArgumentNullException( L"Key" ); - } - } - - - property XmlDocument^ Doc - { - XmlDocument^ get() - { - return docValue; - } - - void set( XmlDocument^ value ) - { - docValue = value; - } - - } - - property TripleDES^ Alg - { - TripleDES^ get() - { - return algValue; - } - - void set( TripleDES^ value ) - { - algValue = value; - } - - } - void Clear() - { - if ( algValue != nullptr ) - { - algValue->Clear(); - } - else - { - throw gcnew Exception( L"No TripleDES key was found to clear." ); - } - } - - void Encrypt( String^ Element ) - { - - // Find the element by name and create a new - // XmlElement object. - XmlElement^ inputElement = dynamic_cast(docValue->GetElementsByTagName( Element )->Item( 0 )); - - // If the element was not found, throw an exception. - if ( inputElement == nullptr ) - { - throw gcnew Exception( L"The element was not found." ); - } - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( docValue ); - - // Encrypt the element using the symmetric key. - array^rgbOutput = exml->EncryptData( inputElement, algValue, false ); - - // Create an EncryptedData object and populate it. - EncryptedData^ ed = gcnew EncryptedData; - - // Specify the namespace URI for XML encryption elements. - ed->Type = EncryptedXml::XmlEncElementUrl; - - // Specify the namespace URI for the TrippleDES algorithm. - ed->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncTripleDESUrl ); - - // Create a CipherData element. - ed->CipherData = gcnew CipherData; - - // Set the CipherData element to the value of the encrypted XML element. - ed->CipherData->CipherValue = rgbOutput; - - // Replace the plaintext XML elemnt with an EncryptedData element. - EncryptedXml::ReplaceElement( inputElement, ed, false ); - } - - void Decrypt() - { - - // XmlElement object. - XmlElement^ encryptedElement = dynamic_cast(docValue->GetElementsByTagName( L"EncryptedData" )->Item( 0 )); - - // If the EncryptedData element was not found, throw an exception. - if ( encryptedElement == nullptr ) - { - throw gcnew Exception( L"The EncryptedData element was not found." ); - } - - - // Create an EncryptedData object and populate it. - EncryptedData^ ed = gcnew EncryptedData; - ed->LoadXml( encryptedElement ); - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml; - - // Decrypt the element using the symmetric key. - array^rgbOutput = exml->DecryptData( ed, algValue ); - - // Replace the encryptedData element with the plaintext XML elemnt. - exml->ReplaceData( encryptedElement, rgbOutput ); - } - -}; - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - - // Create a new instance of the TrippleDESDocumentEncryption object - // defined in this sample. - TrippleDESDocumentEncryption^ xmlTDES = gcnew TrippleDESDocumentEncryption( xmlDoc,tDESkey ); - try - { - - // Encrypt the "creditcard" element. - xmlTDES->Encrypt( L"creditcard" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlTDES->Doc->OuterXml ); - - // Decrypt the "creditcard" element. - xmlTDES->Decrypt(); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlTDES->Doc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - xmlTDES->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp deleted file mode 100644 index c1e61870173..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.SignVerifyEnvelope - Specify Element/CPP/sample.cpp +++ /dev/null @@ -1,178 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, array^ElementsToSign ) -{ - - // Check the arguments. - if ( FileName == nullptr ) - throw gcnew ArgumentNullException( L"FileName" ); - - if ( SignedFileName == nullptr ) - throw gcnew ArgumentNullException( L"SignedFileName" ); - - if ( Key == nullptr ) - throw gcnew ArgumentNullException( L"Key" ); - - if ( ElementsToSign == nullptr ) - throw gcnew ArgumentNullException( L"ElementsToSign" ); - - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Loop through each passed element to sign - // and create a reference. - System::Collections::IEnumerator^ myEnum = ElementsToSign->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - String^ s = safe_cast(myEnum->Current); - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = s; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - } - - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Check the arguments. - if ( Name == nullptr ) - throw gcnew ArgumentNullException( L"Name" ); - - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Specify an element to sign. - array^elements = {L"#tag1"}; - - // Sign an XML file and save the signature to a - // new file. - SignXmlFile( L"Test.xml", L"SignedExample.xml", Key, elements ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear resources associated with the - // RSA instance. - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp deleted file mode 100644 index cdae3dcaebf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.Signature - Envelope/CPP/sample.cpp +++ /dev/null @@ -1,169 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Check the arguments. - if ( FileName == nullptr ) - throw gcnew ArgumentNullException( L"FileName" ); - - if ( SignedFileName == nullptr ) - throw gcnew ArgumentNullException( L"SignedFileName" ); - - if ( Key == nullptr ) - throw gcnew ArgumentNullException( L"Key" ); - - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Get the signature object from the SignedXml object. - Signature^ XMLSignature = signedXml->Signature; - - // Create a reference to be signed. Pass "" - // to specify that all of the current XML - // document should be signed. - Reference^ reference = gcnew Reference( L"" ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the Reference object to the Signature object. - XMLSignature->SignedInfo->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - - // Add the KeyInfo object to the Reference object. - XMLSignature->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Check the arguments. - if ( Name == nullptr ) - throw gcnew ArgumentNullException( L"Name" ); - - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Sign an XML file and save the signature to a - // new file. - SignXmlFile( L"Test.xml", L"SignedExample.xml", Key ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear resources associated with the - // RSA instance. - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp deleted file mode 100644 index 97cfce97aee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncImbedKey/CPP/sample.cpp +++ /dev/null @@ -1,179 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, RSA^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // a new random symmetric key. - ////////////////////////////////////////////////// - // Create a 256 bit Aes key. - Aes^ sessionKey = Aes::Create(); - sessionKey->KeySize = 256; - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, sessionKey, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - edElement->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncAES256Url ); - - // Encrypt the session key and add it to an EncryptedKey element. - EncryptedKey^ ek = gcnew EncryptedKey; - array^encryptedKey = EncryptedXml::EncryptKey( sessionKey->Key, Alg, false ); - ek->CipherData = gcnew CipherData( encryptedKey ); - ek->EncryptionMethod = gcnew EncryptionMethod( EncryptedXml::XmlEncRSA15Url ); - - // Set the KeyInfo element to specify the - // name of the RSA key. - // Create a new KeyInfo element. - edElement->KeyInfo = gcnew KeyInfo; - - // Create a new KeyInfoName element. - KeyInfoName^ kin = gcnew KeyInfoName; - - // Specify a name for the key. - kin->Value = KeyName; - - // Add the KeyInfoName element to the - // EncryptedKey object. - ek->KeyInfo->AddClause( kin ); - - // Add the encrypted key to the - // EncryptedData object. - edElement->KeyInfo->AddClause( gcnew KeyInfoEncryptedKey( ek ) ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, RSA^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add a key-name mapping. - // This method can only decrypt documents - // that present the specified key name. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the element. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new RSA key. This key will encrypt a symmetric key, - // which will then be imbedded in the XML document. - RSA^ rsaKey = RSA::Create(); - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", rsaKey, L"rsaKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - xmlDoc->Save( L"test.xml" ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, rsaKey, L"rsaKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - xmlDoc->Save( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the RSA key. - rsaKey->Clear(); - } - - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp deleted file mode 100644 index 3856ce1b7b3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKey/CPP/Cryptography.XML.XMLEncMapKey.cpp +++ /dev/null @@ -1,200 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - // Determine what kind of algorithm is being used and - // supply the appropriate URL to the EncryptionMethod element. - String^ encryptionMethod = nullptr; - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncTripleDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - switch ( Alg->KeySize ) - { - case 128: - encryptionMethod = EncryptedXml::XmlEncAES128Url; - break; - - case 192: - encryptionMethod = EncryptedXml::XmlEncAES192Url; - break; - - case 256: - encryptionMethod = EncryptedXml::XmlEncAES256Url; - break; - } - } - else - { - - // Throw an exception if the transform is not in the previous categories - throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." ); - } - - - - edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod ); - - // Set the KeyInfo element to specify the - // name of a key. - // Create a new KeyInfo element. - edElement->KeyInfo = gcnew KeyInfo; - - // Create a new KeyInfoName element. - KeyInfoName^ kin = gcnew KeyInfoName; - - // Specify a name for the key. - kin->Value = KeyName; - - // Add the KeyInfoName element. - edElement->KeyInfo->AddClause( kin ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add a key-name mapping. - // This method can only decrypt documents - // that present the specified key name. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the element. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDESKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey, L"tDESKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - return 1; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp deleted file mode 100644 index 0ed4e81288a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMapKeyX509/CPP/Cryptography.XML.XMLEncMapKeyX509.cpp +++ /dev/null @@ -1,133 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, X509Certificate2^ Cert ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Cert == nullptr ) - throw gcnew ArgumentNullException( L"Cert" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // X.509 Certificate. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - - // Encrypt the element. - EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, Cert ); - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Decrypt the XML document. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new X509Certificate2 object by loading - // an X.509 certificate file. To use XML encryption - // with an X.509 certificate, use an X509Certificate2 - // object to encrypt, but use a certificate in a certificate - // store to decrypt. - // You can create a new test certificate file using the - // makecert.exe tool. - // Create an X509Certificate2 object for encryption. - X509Certificate2^ cert = gcnew X509Certificate2( L"test.pfx" ); - - // Put the certificate in certificate store for decryption. - X509Store^ store = gcnew X509Store( StoreLocation::CurrentUser ); - store->Open( OpenFlags::ReadWrite ); - store->Add( cert ); - store->Close(); - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", cert ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp deleted file mode 100644 index c8b0ef17967..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecrypt/CPP/Cryptography.XML.XMLEncMinimalDecrypt.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - - // Add the key mapping. - eXml->AddKeyNameMapping( KeyName, Alg ); - - // Encrypt the element. - EncryptedData^ edElement = eXml->Encrypt( elementToEncrypt, KeyName ); - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg, String^ KeyName ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - if ( KeyName == nullptr ) - throw gcnew ArgumentNullException( L"KeyName" ); - - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml( Doc ); - - // Add the key name mapping. - exml->AddKeyNameMapping( KeyName, Alg ); - - // Decrypt the XML document. - exml->DecryptDocument(); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey, L"tDesKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey, L"tDesKey" ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp deleted file mode 100644 index ae795778f31..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XMLEncMinimalDecryptData/CPP/Cryptography.XML.XMLEncMinimalDecryptData.cpp +++ /dev/null @@ -1,196 +0,0 @@ - -// -#using -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -static void Encrypt( XmlDocument^ Doc, String^ ElementToEncrypt, SymmetricAlgorithm^ Alg ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( ElementToEncrypt == nullptr ) - throw gcnew ArgumentNullException( L"ElementToEncrypt" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - //////////////////////////////////////////////// - // Find the specified element in the XmlDocument - // object and create a new XmlElemnt object. - //////////////////////////////////////////////// - XmlElement^ elementToEncrypt = dynamic_cast(Doc->GetElementsByTagName( ElementToEncrypt )->Item( 0 )); - - // Throw an XmlException if the element was not found. - if ( elementToEncrypt == nullptr ) - { - throw gcnew XmlException( L"The specified element was not found" ); - } - - - ////////////////////////////////////////////////// - // Create a new instance of the EncryptedXml class - // and use it to encrypt the XmlElement with the - // symmetric key. - ////////////////////////////////////////////////// - EncryptedXml^ eXml = gcnew EncryptedXml; - array^encryptedElement = eXml->EncryptData( elementToEncrypt, Alg, false ); - - //////////////////////////////////////////////// - // Construct an EncryptedData object and populate - // it with the desired encryption information. - //////////////////////////////////////////////// - EncryptedData^ edElement = gcnew EncryptedData; - edElement->Type = EncryptedXml::XmlEncElementUrl; - - // Create an EncryptionMethod element so that the - // receiver knows which algorithm to use for decryption. - // Determine what kind of algorithm is being used and - // supply the appropriate URL to the EncryptionMethod element. - String^ encryptionMethod = nullptr; - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncTripleDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - encryptionMethod = EncryptedXml::XmlEncDESUrl; - } - else - if ( dynamic_cast(Alg) ) - { - switch ( Alg->KeySize ) - { - case 128: - encryptionMethod = EncryptedXml::XmlEncAES128Url; - break; - - case 192: - encryptionMethod = EncryptedXml::XmlEncAES192Url; - break; - - case 256: - encryptionMethod = EncryptedXml::XmlEncAES256Url; - break; - } - } - else - { - - // Throw an exception if the transform is not in the previous categories - throw gcnew CryptographicException( L"The specified algorithm is not supported for XML Encryption." ); - } - - - - edElement->EncryptionMethod = gcnew EncryptionMethod( encryptionMethod ); - - // Add the encrypted element data to the - // EncryptedData object. - edElement->CipherData->CipherValue = encryptedElement; - - //////////////////////////////////////////////////// - // Replace the element from the original XmlDocument - // object with the EncryptedData element. - //////////////////////////////////////////////////// - EncryptedXml::ReplaceElement( elementToEncrypt, edElement, false ); -} - -static void Decrypt( XmlDocument^ Doc, SymmetricAlgorithm^ Alg ) -{ - - // Check the arguments. - if ( Doc == nullptr ) - throw gcnew ArgumentNullException( L"Doc" ); - - if ( Alg == nullptr ) - throw gcnew ArgumentNullException( L"Alg" ); - - - // Find the EncryptedData element in the XmlDocument. - XmlElement^ encryptedElement = dynamic_cast(Doc->GetElementsByTagName( L"EncryptedData" )->Item( 0 )); - - // If the EncryptedData element was not found, throw an exception. - if ( encryptedElement == nullptr ) - { - throw gcnew XmlException( L"The EncryptedData element was not found." ); - } - - - // Create an EncryptedData object and populate it. - EncryptedData^ edElement = gcnew EncryptedData; - edElement->LoadXml( encryptedElement ); - - // Create a new EncryptedXml object. - EncryptedXml^ exml = gcnew EncryptedXml; - - // Decrypt the element using the symmetric key. - array^rgbOutput = exml->DecryptData( edElement, Alg ); - - // Replace the encryptedData element with the plaintext XML element. - exml->ReplaceData( encryptedElement, rgbOutput ); -} - -int main() -{ - - // Create an XmlDocument object. - XmlDocument^ xmlDoc = gcnew XmlDocument; - - // Load an XML file into the XmlDocument object. - try - { - xmlDoc->PreserveWhitespace = true; - xmlDoc->Load( L"test.xml" ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - return 0; - } - - - // Create a new TripleDES key. - TripleDESCryptoServiceProvider^ tDESkey = gcnew TripleDESCryptoServiceProvider; - try - { - - // Encrypt the "creditcard" element. - Encrypt( xmlDoc, L"creditcard", tDESkey ); - - // Display the encrypted XML to the console. - Console::WriteLine( L"Encrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - - // Decrypt the "creditcard" element. - Decrypt( xmlDoc, tDESkey ); - - // Display the encrypted XML to the console. - Console::WriteLine(); - Console::WriteLine( L"Decrypted XML:" ); - Console::WriteLine(); - Console::WriteLine( xmlDoc->OuterXml ); - } - catch ( Exception^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - - // Clear the TripleDES key. - tDESkey->Clear(); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp deleted file mode 100644 index 2d4df6a368d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NTransform/CPP/example.cpp +++ /dev/null @@ -1,181 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Specify a canonicalization method. - signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NTransformUrl; - - // Set the InclusiveNamespacesPrefixList property. - XmlDsigExcC14NTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject); - canMethod->InclusiveNamespacesPrefixList = L"Sign"; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp deleted file mode 100644 index ce578aa7c43..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigExcC14NWithCommentsTransform/CPP/sample.cpp +++ /dev/null @@ -1,178 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Specify a canonicalization method. - signedXml->SignedInfo->CanonicalizationMethod = SignedXml::XmlDsigExcC14NWithCommentsTransformUrl; - - // Set the InclusiveNamespacesPrefixList property. - XmlDsigExcC14NWithCommentsTransform^ canMethod = dynamic_cast(signedXml->SignedInfo->CanonicalizationMethodObject); - canMethod->InclusiveNamespacesPrefixList = L"Sign"; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( dynamic_cast(doc->FirstChild) ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - //SignXmlFile("Example.xml", "SignedExample.xml", Key); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp deleted file mode 100644 index 6edd984e6b9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXPathTransform/CPP/sample.cpp +++ /dev/null @@ -1,202 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Create the XML that represents the transform. -static XmlDsigXPathTransform^ CreateXPathTransform( String^ XPathString ) -{ - - // Create a new XMLDocument object. - XmlDocument^ doc = gcnew XmlDocument; - - // Create a new XmlElement. - XmlElement^ xPathElem = doc->CreateElement( L"XPath" ); - - // Set the element text to the value - // of the XPath string. - xPathElem->InnerText = XPathString; - - // Create a new XmlDsigXPathTransform object. - XmlDsigXPathTransform^ xForm = gcnew XmlDsigXPathTransform; - - // Load the XPath XML from the element. - xForm->LoadInnerXml( xPathElem->SelectNodes( L"." ) ); - - // Return the XML that represents the transform. - return xForm; -} - - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XPathString ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Create an XmlDsigXPathTransform object using - // the helper method 'CreateXPathTransform' defined - // later in this sample. - XmlDsigXPathTransform^ XPathTransform = CreateXPathTransform( XPathString ); - - // Add the transform to the reference. - reference->AddTransform( XPathTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"TempElement", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, L"ancestor-or-self::TempElement" ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp deleted file mode 100644 index 6693cd9c0f6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlDsigXsltTransform/CPP/sample.cpp +++ /dev/null @@ -1,193 +0,0 @@ - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Create the XML that represents the transform. -static XmlDsigXsltTransform^ CreateXsltTransform( String^ xsl ) -{ - XmlDocument^ doc = gcnew XmlDocument; - doc->LoadXml( xsl ); - XmlDsigXsltTransform^ xform = gcnew XmlDsigXsltTransform; - xform->LoadInnerXml( doc->ChildNodes ); - return xform; -} - - -// Sign an XML file and save the signature in a new file. -static void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ XSLString ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Create an XmlDsigXPathTransform object using - // the helper method 'CreateXPathTransform' defined - // later in this sample. - XmlDsigXsltTransform^ XsltTransform = CreateXsltTransform( XSLString ); - - // Add the transform to the reference. - reference->AddTransform( XsltTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( dynamic_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -static Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( L"Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// Create example data to sign. -static void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, L"", L"MyXML", L"Don't_Sign" ); - - // Append the node to the document. - document->AppendChild( node ); - - // Create a new XmlNode object. - XmlNode^ subnode = document->CreateNode( XmlNodeType::Element, L"", L"ElementToTransform", L"Sign" ); - - // Add some text to the node. - subnode->InnerText = L"Here is some data to sign."; - - // Append the node to the document. - document->DocumentElement->AppendChild( subnode ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - - // Generate a signing key. - RSA^ Key = RSA::Create(); - String^ xsl = L"\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n "; - try - { - - // Create an XML file to sign. - CreateSomeXml( L"Example.xml" ); - Console::WriteLine( L"New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( L"Example.xml", L"SignedExample.xml", Key, xsl ); - Console::WriteLine( L"XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( L"Verifying signature..." ); - bool result = VerifyXmlFile( L"SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( L"The XML signature is valid." ); - } - else - { - Console::WriteLine( L"The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - finally - { - Key->Clear(); - } - - return 1; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp b/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp deleted file mode 100644 index 4477c20eac3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/Cryptography.XML.XmlLicenseTransform/cpp/sample.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -#using -#using -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -// -void CheckSignatureWithEncryptedGrant( - String^ fileName, IRelDecryptor^ decryptor) -{ - // Create a new XML document. - XmlDocument^ sourceDocument = gcnew XmlDocument(); - XmlNamespaceManager^ namespaceManager = - gcnew XmlNamespaceManager(sourceDocument->NameTable); - - // Format using white spaces. - sourceDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - sourceDocument->Load(fileName); - namespaceManager->AddNamespace("dsig", - SignedXml::XmlDsigNamespaceUrl); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = - sourceDocument->SelectNodes("//dsig:Signature", namespaceManager); - - for (int i = 0, count = nodeList->Count; i < count; i++) - { - XmlDocument^ clone = (XmlDocument^) sourceDocument->Clone(); - XmlNodeList^ signatures = - clone->SelectNodes("//dsig:Signature", namespaceManager); - - // Create a new SignedXml object and pass into it the - // XML document clone. - SignedXml^ signedDocument = gcnew SignedXml(clone); - - // Load the signature node. - signedDocument->LoadXml((XmlElement^)signatures[i]); - - // Set the context for license transform - Transform^ licenseTransform = ((Reference^)signedDocument-> - SignedInfo->References[0])->TransformChain[0]; - - if ((licenseTransform::typeid == XmlLicenseTransform::typeid) - && (decryptor != nullptr)) - { - // Decryptor is used to decrypt encryptedGrant - // elements. - ((XmlLicenseTransform^) licenseTransform)->Decryptor = decryptor; - } - - // Check the signature and display the result. - if (signedDocument->CheckSignature()) - { - Console::WriteLine("SUCCESS: " + - "CheckSignatureWithEncryptedGrant - issuer index #" + i); - } - else - { - Console::WriteLine("FAILURE: " + - "CheckSignatureWithEncryptedGrant - issuer index #" + i); - } - } -} -// - -int main() -{ -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp deleted file mode 100644 index d26844e8082..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA256/CPP/hmacsha256.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decodes the file and compares -// the source and the decoded files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA256^ myhmacsha256 = gcnew HMACSHA256( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha256->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha256->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decode the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA256^ hmacsha256 = gcnew HMACSHA256( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha256->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha256->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA256 inputfile.txt encodedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp deleted file mode 100644 index 6dfcd8a29fa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA384/CPP/hmacsha384.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decrypts the file and compares -// the source and the decrypted files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA384^ myhmacsha384 = gcnew HMACSHA384( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha384->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha384->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decrypt the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA384^ hmacsha384 = gcnew HMACSHA384( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha384->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha384->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA384 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp b/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp deleted file mode 100644 index 4f83ce4b8b5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/HMACSHA512/CPP/hmacsha512.cpp +++ /dev/null @@ -1,134 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -// Computes a keyed hash for a source file, creates a target file with the keyed hash -// prepended to the contents of the source file, then decrypts the file and compares -// the source and the decrypted files. -void EncodeFile( array^key, String^ sourceFile, String^ destFile ) -{ - - // Initialize the keyed hash object. - HMACSHA512^ myhmacsha512 = gcnew HMACSHA512( key ); - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - FileStream^ outStream = gcnew FileStream( destFile,FileMode::Create ); - - // Compute the hash of the input file. - array^hashValue = myhmacsha512->ComputeHash( inStream ); - - // Reset inStream to the beginning of the file. - inStream->Position = 0; - - // Write the computed hash value to the output file. - outStream->Write( hashValue, 0, hashValue->Length ); - - // Copy the contents of the sourceFile to the destFile. - int bytesRead; - - // read 1K at a time - array^buffer = gcnew array(1024); - do - { - - // Read from the wrapping CryptoStream. - bytesRead = inStream->Read( buffer, 0, 1024 ); - outStream->Write( buffer, 0, bytesRead ); - } - while ( bytesRead > 0 ); - - myhmacsha512->Clear(); - - // Close the streams - inStream->Close(); - outStream->Close(); - return; -} // end EncodeFile - - - -// Decrypt the encoded file and compare to original file. -bool DecodeFile( array^key, String^ sourceFile ) -{ - - // Initialize the keyed hash object. - HMACSHA512^ hmacsha512 = gcnew HMACSHA512( key ); - - // Create an array to hold the keyed hash value read from the file. - array^storedHash = gcnew array(hmacsha512->HashSize / 8); - - // Create a FileStream for the source file. - FileStream^ inStream = gcnew FileStream( sourceFile,FileMode::Open ); - - // Read in the storedHash. - inStream->Read( storedHash, 0, storedHash->Length ); - - // Compute the hash of the remaining contents of the file. - // The stream is properly positioned at the beginning of the content, - // immediately after the stored hash value. - array^computedHash = hmacsha512->ComputeHash( inStream ); - - // compare the computed hash with the stored value - bool err = false; - for ( int i = 0; i < storedHash->Length; i++ ) - { - if ( computedHash[ i ] != storedHash[ i ] ) - { - err = true; - } - } - if (err) - { - Console::WriteLine("Hash values differ! Encoded file has been tampered with!"); - return false; - } - else - { - Console::WriteLine("Hash values agree -- no tampering occurred."); - return true; - } - -} //end DecodeFile - - -int main() -{ - array^Fileargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: HMACSHA512 inputfile.txt encryptedfile.hsh\nYou must specify the two file names. Only the first file must exist.\n"; - - //If no file names are specified, write usage text. - if ( Fileargs->Length < 3 ) - { - Console::WriteLine( usageText ); - } - else - { - try - { - - // Create a random key using a random number generator. This would be the - // secret key shared by sender and receiver. - array^secretkey = gcnew array(64); - - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - - // The array is now filled with cryptographically strong random bytes. - rng->GetBytes( secretkey ); - - // Use the secret key to encode the message file. - EncodeFile( secretkey, Fileargs[ 1 ], Fileargs[ 2 ] ); - - // Take the encoded file and decode - DecodeFile( secretkey, Fileargs[ 2 ] ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "Error: File not found", e ); - } - - } -} //end main - - -// diff --git a/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp b/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp deleted file mode 100644 index 4c29bcd1705..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/IndentedTextWriterExample/CPP/form1.cpp +++ /dev/null @@ -1,120 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace System::ComponentModel; -using namespace System::IO; -using namespace System::Windows::Forms; -public ref class Form1: public System::Windows::Forms::Form -{ -private: - System::Windows::Forms::TextBox^ textBox1; - - // - String^ CreateMultilevelIndentString() - { - - // - // Creates a TextWriter to use as the base output writer. - System::IO::StringWriter^ baseTextWriter = gcnew System::IO::StringWriter; - - // Create an IndentedTextWriter and set the tab string to use - // as the indentation string for each indentation level. - System::CodeDom::Compiler::IndentedTextWriter^ indentWriter = gcnew IndentedTextWriter( baseTextWriter," " ); - - // - // - // Sets the indentation level. - indentWriter->Indent = 0; - - // - // Output test strings at stepped indentations through a recursive loop method. - WriteLevel( indentWriter, 0, 5 ); - - // Return the resulting string from the base StringWriter. - return baseTextWriter->ToString(); - } - - - // - void WriteLevel( IndentedTextWriter^ indentWriter, int level, int totalLevels ) - { - - // Output a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - - // If not yet at the highest recursion level, call this output method for the next level of indentation. - if ( level < totalLevels ) - { - - // Increase the indentation count for the next level of indented output. - indentWriter->Indent++; - - // Call the WriteLevel method to write test output for the next level of indentation. - WriteLevel( indentWriter, level + 1, totalLevels ); - - // Restores the indentation count for this level after the recursive branch method has returned. - indentWriter->Indent--; - } - else - // - // Outputs a string using the WriteLineNoTabs method. - indentWriter->WriteLineNoTabs( "This is a test phrase written with the IndentTextWriter.WriteLineNoTabs method." ); - // - // Outputs a test string with a new-line character at the end. - indentWriter->WriteLine( "This is a test phrase. Current indentation level: {0}", level ); - } - - - // - // - void button1_Click( Object^ /*sender*/, System::EventArgs^ /*e*/ ) - { - textBox1->Text = CreateMultilevelIndentString(); - } - - -public: - Form1() - { - System::Windows::Forms::Button^ button1 = gcnew System::Windows::Forms::Button; - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->SuspendLayout(); - this->textBox1->Anchor = (System::Windows::Forms::AnchorStyles)(System::Windows::Forms::AnchorStyles::Top | System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left | System::Windows::Forms::AnchorStyles::Right); - this->textBox1->Location = System::Drawing::Point( 8, 40 ); - this->textBox1->Multiline = true; - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 391, 242 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = ""; - button1->Location = System::Drawing::Point( 11, 8 ); - button1->Name = "button1"; - button1->Size = System::Drawing::Size( 229, 23 ); - button1->TabIndex = 1; - button1->Text = "Generate string using IndentedTextWriter"; - button1->Click += gcnew System::EventHandler( this, &Form1::button1_Click ); - this->AutoScaleBaseSize = System::Drawing::Size( 5, 13 ); - this->ClientSize = System::Drawing::Size( 407, 287 ); - this->Controls->Add( button1 ); - this->Controls->Add( this->textBox1 ); - this->Name = "Form1"; - this->Text = "IndentedTextWriter example"; - this->ResumeLayout( false ); - } - -}; - - -[STAThread] -int main() -{ - Application::Run( gcnew Form1 ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp b/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp deleted file mode 100644 index 743f3c8001f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/RNGCSP/cpp/rngcsp.cpp +++ /dev/null @@ -1,75 +0,0 @@ -// -//The following sample uses the Cryptography class to simulate the roll of a dice. - -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -ref class RNGCSP -{ -public: - // Main method. - static void Main() - { - const int totalRolls = 25000; - array^ results = gcnew array(6); - - // Roll the dice 25000 times and display - // the results to the console. - for (int x = 0; x < totalRolls; x++) - { - Byte roll = RollDice((Byte)results->Length); - results[roll - 1]++; - } - for (int i = 0; i < results->Length; ++i) - { - Console::WriteLine("{0}: {1} ({2:p1})", i + 1, results[i], (double)results[i] / (double)totalRolls); - } - } - - // This method simulates a roll of the dice. The input parameter is the - // number of sides of the dice. - - static Byte RollDice(Byte numberSides) - { - if (numberSides <= 0) - throw gcnew ArgumentOutOfRangeException("numberSides"); - // Create a new instance of the RNGCryptoServiceProvider. - RNGCryptoServiceProvider^ rngCsp = gcnew RNGCryptoServiceProvider(); - // Create a byte array to hold the random value. - array^ randomNumber = gcnew array(1); - do - { - // Fill the array with a random value. - rngCsp->GetBytes(randomNumber); - } - while (!IsFairRoll(randomNumber[0], numberSides)); - // Return the random number mod the number - // of sides. The possible values are zero- - // based, so we add one. - return (Byte)((randomNumber[0] % numberSides) + 1); - } - -private: - static bool IsFairRoll(Byte roll, Byte numSides) - { - // There are MaxValue / numSides full sets of numbers that can come up - // in a single byte. For instance, if we have a 6 sided die, there are - // 42 full sets of 1-6 that come up. The 43rd set is incomplete. - int fullSetsOfValues = Byte::MaxValue / numSides; - - // If the roll is within this range of fair values, then we let it continue. - // In the 6 sided die case, a roll between 0 and 251 is allowed. (We use - // < rather than <= since the = portion allows through an extra 0 value). - // 252 through 255 would provide an extra 0, 1, 2, 3 so they are not fair - // to use. - return roll < numSides * fullSetsOfValues; - } -}; - -int main() -{ - RNGCSP::Main(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp deleted file mode 100644 index cb616efc570..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/RijndaelManaged Example/CPP/class1.cpp +++ /dev/null @@ -1,172 +0,0 @@ -// -#using - -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - - -class RijndaelMemoryExample -{ -public: - static array^ encryptStringToBytes_AES(String^ plainText, array^ Key, array^ IV) - { - // Check arguments. - if (!plainText || plainText->Length <= 0) - throw gcnew ArgumentNullException("plainText"); - if (!Key || Key->Length <= 0) - throw gcnew ArgumentNullException("Key"); - if (!IV || IV->Length <= 0) - throw gcnew ArgumentNullException("IV"); - - // Declare the streams used - // to encrypt to an in memory - // array of bytes. - MemoryStream^ msEncrypt; - CryptoStream^ csEncrypt; - StreamWriter^ swEncrypt; - - // Declare the RijndaelManaged object - // used to encrypt the data. - RijndaelManaged^ aesAlg; - - try - { - // Create a RijndaelManaged object - // with the specified key and IV. - aesAlg = gcnew RijndaelManaged(); - aesAlg->Padding = PaddingMode::PKCS7; - aesAlg->Key = Key; - aesAlg->IV = IV; - - // Create an encryptor to perform the stream transform. - ICryptoTransform^ encryptor = aesAlg->CreateEncryptor(aesAlg->Key, aesAlg->IV); - - // Create the streams used for encryption. - msEncrypt = gcnew MemoryStream(); - csEncrypt = gcnew CryptoStream(msEncrypt, encryptor, CryptoStreamMode::Write); - swEncrypt = gcnew StreamWriter(csEncrypt); - - //Write all data to the stream. - swEncrypt->Write(plainText); - swEncrypt->Flush(); - csEncrypt->FlushFinalBlock(); - msEncrypt->Flush(); - } - finally - { - // Clean things up. - - // Close the streams. - if(swEncrypt) - swEncrypt->Close(); - if (csEncrypt) - csEncrypt->Close(); - - - // Clear the RijndaelManaged object. - if (aesAlg) - aesAlg->Clear(); - } - - // Return the encrypted bytes from the memory stream. - return msEncrypt->ToArray(); - } - - static String^ decryptStringFromBytes_AES(array^ cipherText, array^ Key, array^ IV) - { - // Check arguments. - if (!cipherText || cipherText->Length <= 0) - throw gcnew ArgumentNullException("cipherText"); - if (!Key || Key->Length <= 0) - throw gcnew ArgumentNullException("Key"); - if (!IV || IV->Length <= 0) - throw gcnew ArgumentNullException("IV"); - - // TDeclare the streams used - // to decrypt to an in memory - // array of bytes. - MemoryStream^ msDecrypt; - CryptoStream^ csDecrypt; - StreamReader^ srDecrypt; - - // Declare the RijndaelManaged object - // used to decrypt the data. - RijndaelManaged^ aesAlg; - - // Declare the string used to hold - // the decrypted text. - String^ plaintext; - - try - { - // Create a RijndaelManaged object - // with the specified key and IV. - aesAlg = gcnew RijndaelManaged(); - aesAlg->Padding = PaddingMode::PKCS7; - aesAlg->Key = Key; - aesAlg->IV = IV; - - // Create a decryptor to perform the stream transform. - ICryptoTransform^ decryptor = aesAlg->CreateDecryptor(aesAlg->Key, aesAlg->IV); - - // Create the streams used for decryption. - msDecrypt = gcnew MemoryStream(cipherText); - csDecrypt = gcnew CryptoStream(msDecrypt, decryptor, CryptoStreamMode::Read); - srDecrypt = gcnew StreamReader(csDecrypt); - - // Read the decrypted bytes from the decrypting stream - // and place them in a string. - plaintext = srDecrypt->ReadToEnd(); - } - finally - { - // Clean things up. - - // Close the streams. - if (srDecrypt) - srDecrypt->Close(); - if (csDecrypt) - csDecrypt->Close(); - if (msDecrypt) - msDecrypt->Close(); - - // Clear the RijndaelManaged object. - if (aesAlg) - aesAlg->Clear(); - } - - return plaintext; - } -}; - -int main() -{ - try - { - String^ original = "Here is some data to encrypt!"; - - // Create a new instance of the RijndaelManaged - // class. This generates a new key and initialization - // vector (IV). - RijndaelManaged^ myRijndael = gcnew RijndaelManaged(); - - // Encrypt the string to an array of bytes. - array^ encrypted = RijndaelMemoryExample::encryptStringToBytes_AES(original, myRijndael->Key, myRijndael->IV); - - // Decrypt the bytes to a string. - String^ roundtrip = RijndaelMemoryExample::decryptStringFromBytes_AES(encrypted, myRijndael->Key, myRijndael->IV); - - //Display the original data and the decrypted data. - Console::WriteLine("Original: {0}", original); - Console::WriteLine("Round Trip: {0}", roundtrip); - } - catch (Exception^ e) - { - Console::WriteLine("Error: {0}", e->Message); - } - - return 0; -} -// - diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp deleted file mode 100644 index bdc5fda9a9e..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecureString.xAt/CPP/SecureString.xAt.cpp +++ /dev/null @@ -1,85 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -void main() -{ - String^ msg = L" The current length of the SecureString object: {0}\n"; - SecureString ^ ss = gcnew SecureString; - - Console::WriteLine(L"1) Instantiate the SecureString object:"); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"2) Append 'a' to the value:"); - ss->AppendChar('a'); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"3) Append 'X' to the value:"); - ss->AppendChar('X'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"4) Append 'c' to the value:"); - ss->AppendChar('c'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"5) Insert 'd' at the end of the value:"); - ss->InsertAt(ss->Length, 'd'); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"6) Remove the last character ('d') from the value:"); - ss->RemoveAt(3); - Console::WriteLine(msg, ss->Length); - - Console::WriteLine(L"7) Set the second character ('X') of the value to 'b':" ); - ss->SetAt(1, 'b'); - Console::WriteLine(msg, ss->Length ); - - Console::WriteLine(L"8) Delete the value of the SecureString object:"); - ss->Clear(); - Console::WriteLine(msg, ss->Length); - - delete ss; -} - -/* -This code example produces the following results: - -This example demonstrates the effect of the AppendChar, InsertAt, -RemoveAt, SetAt, and Clear methods on the value of a SecureString -object. This example simulates the value of the object because the -actual value is encrypted. - -1) The initial value of the SecureString object: - SecureString = "" - Length = 0 - -2) AppendChar: Append 'a' to the value: - SecureString = "a" - Length = 1 - -3) AppendChar: Append 'X' to the value: - SecureString = "aX" - Length = 2 - -4) AppendChar: Append 'c' to the value: - SecureString = "aXc" - Length = 3 - -5) InsertAt: Insert 'd' at the end of the value (equivalent - to AppendChar): - SecureString = "aXcd" - Length = 4 - -6) RemoveAt: Remove the last character ('d') from the value: - SecureString = "aXc" - Length = 3 - -7) SetAt: Set the second character ('X') of the value to 'b': - SecureString = "abc" - Length = 3 - -8) Clear: Delete the value of the SecureString object: - SecureString = "" - Length = 0 -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp b/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp deleted file mode 100644 index 4a5db9f067c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecureString.xChar/CPP/SecureString.xChar.cpp +++ /dev/null @@ -1,62 +0,0 @@ - -// -using namespace System; -using namespace System::Security; - -void main() -{ - bool go = true; - ConsoleKeyInfo cki; - String^ m = L"\nEnter your password (up to 15 letters, numbers, and underscores)\n" - L"Press BACKSPACE to delete the last character entered. " + - L"\nPress Enter when done, or ESCAPE to quit:"; - SecureString ^ password = gcnew SecureString; - int top; - int left; - - // The Console.TreatControlCAsInput property prevents CTRL+C from - // ending this example. - Console::TreatControlCAsInput = true; - - Console::Clear(); - Console::WriteLine(m); - - top = Console::CursorTop; - left = Console::CursorLeft; - - do { - cki = Console::ReadKey(true); - if (cki.Key == ConsoleKey::Escape) - break; - - if (cki.Key == ConsoleKey::Backspace){ - if (password->Length > 0) { - Console::SetCursorPosition(left + password->Length - 1, top); - Console::Write(' '); - Console::SetCursorPosition(left + password->Length - 1, top); - password->RemoveAt(password->Length - 1); - } - } - else { - if ((password->Length < 15) && - (Char::IsLetterOrDigit( cki.KeyChar ) || - cki.KeyChar == '_') ) { - password->AppendChar( cki.KeyChar ); - Console::SetCursorPosition( left + password->Length - 1, top ); - Console::Write("*"); - } - } - } while (cki.Key != ConsoleKey::Enter & password->Length < 15); - - // Make the password read-only to prevent modification. - password->MakeReadOnly(); - // Dispose of the SecureString instance. - delete password; - -} -// The example displays output like the following: -// Enter your password (up to 15 letters, numbers, and underscores) -// Press BACKSPACE to delete the last character entered. -// Press Enter when done, or ESCAPE to quit: -// ************ -// diff --git a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp b/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp deleted file mode 100644 index 51ea424f825..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/SecurityElementMembers/CPP/SecurityElementMembers.cpp +++ /dev/null @@ -1,290 +0,0 @@ - -// This sample demonstrates how to use members of the SecurityElement class. -// The sample creates a SecurityElement for the root of the XML tree and -// demonstrates how to add attributes and child elements. -// -using namespace System; -using namespace System::Security; -using namespace System::Collections; -ref class SecurityElementMembers -{ -public: - - [STAThread] - int TestSecurityElementMembers() - { - // - SecurityElement^ xmlRootElement = gcnew SecurityElement( L"RootTag",L"XML security tree" ); - // - - AddAttribute( xmlRootElement, L"creationdate", DateTime::Now.ToString() ); - AddChildElement( xmlRootElement, L"destroytime", DateTime::Now.AddSeconds( 1.0 ).ToString() ); - - // - SecurityElement^ windowsRoleElement = gcnew SecurityElement( L"WindowsMembership.WindowsRole" ); - // - - // - windowsRoleElement->AddAttribute( L"version", L"1.00" ); - // - - // Add a child element and a creationdate attribute. - AddChildElement( windowsRoleElement, L"BabyElement", L"This is a child element" ); - AddAttribute( windowsRoleElement, L"creationdate", DateTime::Now.ToString() ); - - // - xmlRootElement->AddChild( windowsRoleElement ); - // - - CompareAttributes( xmlRootElement, L"creationdate" ); - ConvertToHashTable( xmlRootElement ); - DisplaySummary( xmlRootElement ); - - // Determine if the security element is too old to keep. - xmlRootElement = DestroyTree( xmlRootElement ); - if ( xmlRootElement != nullptr ) - { - // - String^ elementInXml = xmlRootElement->ToString(); - // - - Console::WriteLine( elementInXml ); - } - - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - return 1; - } - - -private: - - // Add an attribute to the specified security element. - static SecurityElement^ AddAttribute( SecurityElement^ xmlElement, String^ attributeName, String^ attributeValue ) - { - if ( xmlElement != nullptr ) - { - // Verify that the attribute name and value are valid XML formats. - // - // - if ( SecurityElement::IsValidAttributeName( attributeName ) && - SecurityElement::IsValidAttributeValue( attributeValue ) ) - // - // - { - // Add the attribute to the security element. - // - xmlElement->AddAttribute( attributeName, attributeValue ); - // - } - } - - return xmlElement; - } - - - // Add a child element to the specified security element. - static SecurityElement^ AddChildElement( SecurityElement^ parentElement, String^ tagName, String^ tagText ) - { - if ( parentElement != nullptr ) - { - // Ensure that the tag text is in valid XML format. - // - if ( !SecurityElement::IsValidText( tagText ) ) - // - { - // Replace invalid text with valid XML text - // to enforce proper XML formatting. - // - tagText = SecurityElement::Escape( tagText ); - // - } - - // Determine whether the tag is in valid XML format. - // - if ( SecurityElement::IsValidTag( tagName ) ) - // - { - // - SecurityElement^ childElement; - childElement = parentElement->SearchForChildByTag( tagName ); - // - if ( childElement != nullptr ) - { - // - String^ elementText; - elementText = parentElement->SearchForTextOfTag( tagName ); - // - if ( !elementText->Equals( tagText ) ) - { - // Add child element to the parent security element. - parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) ); - } - } - else - { - // Add child element to the parent security element. - parentElement->AddChild( gcnew SecurityElement( tagName,tagText ) ); - } - } - } - - return parentElement; - } - - - // Create and display a summary sentence - // about the specified security element. - static void DisplaySummary( SecurityElement^ xmlElement ) - { - // Retrieve tag name for the security element. - // - String^ xmlTreeName = xmlElement->Tag->ToString(); - // - // Retrieve tag text for the security element. - // - String^ xmlTreeDescription = xmlElement->Text; - // - // Retrieve value of the creationdate attribute. - // - String^ xmlCreationDate = xmlElement->Attribute(L"creationdate"); - // - // Retrieve the number of children under the security element. - // - String^ childrenCount = xmlElement->Children->Count.ToString(); - // - String^ outputMessage = String::Format( L"The security XML tree named {0}", xmlTreeName ); - outputMessage = String::Concat( outputMessage, String::Format( L"({0})", xmlTreeDescription ) ); - outputMessage = String::Concat( outputMessage, String::Format( L" was created on {0} and ", xmlCreationDate ) ); - outputMessage = String::Concat( outputMessage, String::Format( L"contains {0} child elements.", childrenCount ) ); - Console::WriteLine( outputMessage ); - } - - // Compare the first two occurrences of an attribute - // in the specified security element. - static void CompareAttributes( SecurityElement^ xmlElement, String^ attributeName ) - { - // Create a hash table containing the security element's attributes. - // - Hashtable^ attributeKeys = xmlElement->Attributes; - String^ attributeValue = attributeKeys[ attributeName ]->ToString(); - // - IEnumerator^ myEnum = xmlElement->Children->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - SecurityElement^ xmlChild = safe_cast(myEnum->Current); - if ( attributeValue->Equals( xmlChild->Attribute(attributeName) ) ) - { - // The security elements were created at the exact same time. - } - } - } - - // Convert the contents of the specified security element - // to hash codes stored in a hash table. - static void ConvertToHashTable( SecurityElement^ xmlElement ) - { - // Create a hash table to hold hash codes of the security elements. - // - Hashtable^ xmlAsHash = gcnew Hashtable; - int rootIndex = xmlElement->GetHashCode(); - xmlAsHash->Add( rootIndex, L"root" ); - // - int parentNum = 0; - IEnumerator^ myEnum1 = xmlElement->Children->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - SecurityElement^ xmlParent = safe_cast(myEnum1->Current); - parentNum++; - xmlAsHash->Add( xmlParent->GetHashCode(), String::Format( L"parent{0}", parentNum ) ); - if ( (xmlParent->Children != nullptr) && (xmlParent->Children->Count > 0) ) - { - int childNum = 0; - IEnumerator^ myEnum2 = xmlParent->Children->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - SecurityElement^ xmlChild = safe_cast(myEnum2->Current); - childNum++; - xmlAsHash->Add( xmlChild->GetHashCode(), String::Format( L"child{0}", childNum ) ); - } - } - } - } - - // Delete the specified security element if the current time is past - // the time stored in the destroytime tag. - static SecurityElement^ DestroyTree( SecurityElement^ xmlElement ) - { - SecurityElement^ localXmlElement = xmlElement; - SecurityElement^ destroyElement = localXmlElement->SearchForChildByTag( L"destroytime" ); - - // Verify that a destroytime tag exists. - // - if ( localXmlElement->SearchForChildByTag( L"destroytime" ) != nullptr ) - // - { - // Retrieve the destroytime text to get the time - // the tree can be destroyed. - // - String^ storedDestroyTime = localXmlElement->SearchForTextOfTag( L"destroytime" ); - // - DateTime destroyTime = DateTime::Parse( storedDestroyTime ); - if ( DateTime::Now > destroyTime ) - { - localXmlElement = nullptr; - Console::WriteLine( L"The XML security tree has been deleted." ); - } - } - - - // Verify that xmlElement is of type SecurityElement. - // - if ( xmlElement->GetType()->Equals( System::Security::SecurityElement::typeid ) ) - // - { - // Determine whether the localXmlElement object - // differs from xmlElement. - // - if ( xmlElement->Equals( localXmlElement ) ) - // - { - // Verify that the tags, attributes and children of the - // two security elements are identical. - // - if ( xmlElement->Equal( localXmlElement ) ) - // - { - // Return the original security element. - return xmlElement; - } - } - } - - // Return the modified security element. - return localXmlElement; - } - -}; - -int main() -{ - SecurityElementMembers^ sem = gcnew SecurityElementMembers; - sem->TestSecurityElementMembers(); -} - -// -// This sample produces the following output: -// -// The security XML tree named RootTag(XML security tree) -// was created on 2/23/2004 1:23:00 PM and contains 2 child elements. -//XML security tree -// 2/23/2004 1:23:01 PM -// -// This is a child element. -// -// -// -//This sample completed successfully; press Exit to continue. -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp deleted file mode 100644 index 9772134cfdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.Equals Method/CPP/example.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - String^ OtherCertificate = "OtherCertificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into an X509Certificate object. - X509Certificate^ certTwo = X509Certificate::CreateFromCertFile( OtherCertificate ); - - // Get the value. - bool result = cert->Equals( certTwo ); - - // Display the value to the console. - Console::WriteLine( result ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp deleted file mode 100644 index 5af220ab9f7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHash Method/CPP/example.cpp +++ /dev/null @@ -1,18 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetCertHash(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp deleted file mode 100644 index 55ab6046d0b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetCertHashString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetCertHashString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp deleted file mode 100644 index bdd5c733874..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetEffectiveDateString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetEffectiveDateString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp deleted file mode 100644 index 7c7ba844a14..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetExpirationDateString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetExpirationDateString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp deleted file mode 100644 index 478464e28d5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetFormat Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetFormat(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp deleted file mode 100644 index fbd037afed5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetHashCode Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - int results = cert->GetHashCode(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp deleted file mode 100644 index c8cc924a1df..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetIssuerName Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetIssuerName(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp deleted file mode 100644 index 6c0355deedf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithm Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetKeyAlgorithm(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp deleted file mode 100644 index 834343b8ca2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParameters Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetKeyAlgorithmParameters(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp deleted file mode 100644 index 3ebc0887b84..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetKeyAlgorithmParametersString/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetKeyAlgorithmParametersString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp deleted file mode 100644 index 14cc5940220..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetName Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetName(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp deleted file mode 100644 index e30ffdb3735..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKey Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetPublicKey(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp deleted file mode 100644 index 53861be1cdc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetPublicKeyString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetPublicKeyString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp deleted file mode 100644 index da8eae2d858..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertData Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetRawCertData(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp deleted file mode 100644 index 17f1ada058c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetRawCertDataString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetRawCertDataString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp deleted file mode 100644 index fe0562f72c8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumber Method/CPP/example.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - array^results = cert->GetSerialNumber(); - - // Display the value to the console. - System::Collections::IEnumerator^ enum0 = results->GetEnumerator(); - while ( enum0->MoveNext() ) - { - Byte b = safe_cast(enum0->Current); - Console::Write( b ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp deleted file mode 100644 index f0bcfd5314f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.GetSerialNumberString Method/CPP/example.cpp +++ /dev/null @@ -1,21 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ results = cert->GetSerialNumberString(); - - // Display the value to the console. - Console::WriteLine( results ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp deleted file mode 100644 index 311195b9c1b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/X509Certificate.ToString Method/CPP/example.cpp +++ /dev/null @@ -1,27 +0,0 @@ - -// -using namespace System; -using namespace System::Security::Cryptography::X509Certificates; -int main() -{ - - // The path to the certificate. - String^ Certificate = "Certificate.cer"; - - // Load the certificate into an X509Certificate object. - X509Certificate^ cert = X509Certificate::CreateFromCertFile( Certificate ); - - // Get the value. - String^ resultsTrue = cert->ToString( true ); - - // Display the value to the console. - Console::WriteLine( resultsTrue ); - - // Get the value. - String^ resultsFalse = cert->ToString( false ); - - // Display the value to the console. - Console::WriteLine( resultsFalse ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp deleted file mode 100644 index aa1fd739b5b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG - Signature - Detached/CPP/sample.cpp +++ /dev/null @@ -1,173 +0,0 @@ -// -// -// This example signs a URL using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - - -namespace Sample -{ - public ref class SignVerifyEnvelope - { - public: - static void Work() - { - // Generate a signing key. - RSA^ key = RSA::Create(); - - try - { - - // Sign the detached resource and save the - // signature in an XML file. - SignDetachedResource("http://www.microsoft.com", - "SignedExample.xml", key); - - Console::WriteLine("XML file signed."); - - // Verify the signature of the signed XML. - Console::WriteLine("Verifying signature..."); - - bool result = VerifyXmlFile("SignedExample.xml"); - - // Display the results of the signature verification - // to the console. - if (result) - { - Console::WriteLine("The XML signature" - " is valid."); - } - else - { - Console::WriteLine("The XML signature" - " is not valid."); - } - Console::ReadLine(); - } - - catch (CryptographicException^ ex) - { - Console::WriteLine(ex->Message); - } - finally - { - // Clear resources associated with the - // RSA instance. - key->Clear(); - } - } - - - // Sign an XML file and save the signature in a new file. - static void SignDetachedResource(String^ uri, - String^ xmlFileName, RSA^ key) - { - // Check the arguments. - if (uri->Length == 0) - { - throw gcnew ArgumentException("uri"); - } - if (xmlFileName->Length == 0) - { - throw gcnew ArgumentException("xmlFileName"); - } - if (key->KeySize == 0) - { - throw gcnew ArgumentException("key"); - } - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml(); - - // Assign the key to the SignedXml object. - signedXml->SigningKey = key; - - // Get the signature object from the SignedXml object. - Signature^ xmlSignature = signedXml->Signature; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference(); - - // Add the passed URI to the reference object. - reference->Uri = uri; - - // Add the Reference object to the Signature object. - xmlSignature->SignedInfo->AddReference(reference); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient - // find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo(); - keyInfo->AddClause( - gcnew RSAKeyValue(key)); - - // Add the KeyInfo object to the Reference object. - xmlSignature->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmlTextWriter = gcnew XmlTextWriter( - xmlFileName, gcnew UTF8Encoding(false)); - - xmlDigitalSignature->WriteTo(xmlTextWriter); - xmlTextWriter->Close(); - } - - - // Verify the signature of an XML file and return the result. - static Boolean VerifyXmlFile(String^ documentName) - { - // Check the arguments. - if (documentName->Length == 0) - { - throw gcnew ArgumentException("documentName"); - } - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument(); - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load(documentName); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml(xmlDocument); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = - xmlDocument->GetElementsByTagName("Signature"); - - // Load the signature node. - signedXml->LoadXml( - (XmlElement^) nodeList->Item(0)); - - // Check the signature and return the result. - return signedXml->CheckSignature(); - } - }; -} - - -int main() -{ - Sample::SignVerifyEnvelope::Work(); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp deleted file mode 100644 index 95b151171e8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Signing/CPP/source.cpp +++ /dev/null @@ -1,57 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -int main() -{ - - // Create example data to sign. - XmlDocument^ document = gcnew XmlDocument; - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - node->InnerText = "This is some text"; - document->AppendChild( node ); - Console::Error->WriteLine( "Data to sign:\n{0}\n", document->OuterXml ); - - // Create the SignedXml message. - SignedXml^ signedXml = gcnew SignedXml; - RSA^ key = RSA::Create(); - signedXml->SigningKey = key; - - // Create a data object to hold the data to sign. - DataObject^ dataObject = gcnew DataObject; - dataObject->Data = document->ChildNodes; - dataObject->Id = "MyObjectId"; - - // Add the data object to the signature. - signedXml->AddObject( dataObject ); - - // Create a reference to be able to package everything into the - // message. - Reference^ reference = gcnew Reference; - reference->Uri = "#MyObjectId"; - - // Add it to the message. - signedXml->AddReference( reference ); - - // Add a KeyInfo. - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( key ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature. - XmlElement^ xmlSignature = signedXml->GetXml(); - Console::WriteLine( xmlSignature->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp deleted file mode 100644 index 74689b19c1f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/XMLDSIG Verification/CPP/source.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::IO; -using namespace System::Xml; -int main() -{ - array^args = System::Environment::GetCommandLineArgs(); - Console::WriteLine( "Verifying {0}...", args[ 1 ] ); - - // Create a SignedXml. - SignedXml^ signedXml = gcnew SignedXml; - - // Load the XML. - XmlDocument^ xmlDocument = gcnew XmlDocument; - xmlDocument->PreserveWhitespace = true; - xmlDocument->Load( gcnew XmlTextReader( args[ 1 ] ) ); - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - signedXml->LoadXml( safe_cast(nodeList[ 0 ]) ); - if ( signedXml->CheckSignature() ) - { - Console::WriteLine( "Signature check OK" ); - } - else - { - Console::WriteLine( "Signature check FAILED" ); - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp b/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp deleted file mode 100644 index e3a2a599d6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/capikey/CPP/capikey.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -int main() -{ - - // creates the CspParameters object and sets the key container name used to store the RSA key pair - CspParameters^ cp = gcnew CspParameters; - cp->KeyContainerName = "MyKeyContainerName"; - - // instantiates the rsa instance accessing the key container MyKeyContainerName - RSACryptoServiceProvider^ rsa = gcnew RSACryptoServiceProvider( cp ); - - // add the below line to delete the key entry in MyKeyContainerName - // rsa.PersistKeyInCsp = false; - //writes out the current key pair used in the rsa instance - Console::WriteLine( "Key is : \n{0}", rsa->ToXmlString( true ) ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp deleted file mode 100644 index 486c6233b75..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptgraphy.Xml.EncryptedData/cpp/encrypteddata.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create a EncryptedData element -/// and write it to an XML file. -int main() -{ - // - // Create a new CipherData object. - CipherData^ cipher = gcnew CipherData(); - // Assign a byte array to be the CipherValue. This is a - // byte array representing encrypted data. - cipher->CipherValue = gcnew array(8); - // - // - // Create a new EncryptedData object. - EncryptedData^ encryptionRoot = gcnew EncryptedData(); - // - //Add an encryption method to the object. - encryptionRoot->Id = "ED"; - encryptionRoot->EncryptionMethod = gcnew EncryptionMethod( - "http://www.w3.org/2001/04/xmlenc#aes128-cbc"); - encryptionRoot->CipherData = cipher; - - //Add key information to the object. - KeyInfo^ keyDetails = gcnew KeyInfo(); - keyDetails->AddClause(gcnew KeyInfoRetrievalMethod("#EK", - "http://www.w3.org/2001/04/xmlenc#EncryptedKey")); - encryptionRoot->KeyInfo = keyDetails; - - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument(); - XmlElement^ encryptionPropertyElement = - doc->CreateElement("EncryptionProperty", - EncryptedXml::XmlEncNamespaceUrl); - EncryptionProperty^ property = gcnew EncryptionProperty( - encryptionPropertyElement); - encryptionRoot->AddProperty(property); - - // Output the resulting XML information into a file. - String^ path = "test.xml"; - try - { - File::WriteAllText(path, encryptionRoot->GetXml()->OuterXml); - } - catch (IOException^ ex) - { - Console::WriteLine("There was an error writing to {0}", path); - Console::WriteLine(ex->Message); - } - //Console.WriteLine(ed.GetXml().OuterXml); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp deleted file mode 100644 index e1fe39c2ee1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.CipherReference/CPP/example.cpp +++ /dev/null @@ -1,71 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create an encrypted data element -/// and write it to an XML file. It demonstrates the use of CipherReference. - -[STAThread] -int main() -{ - - //Create a URI string. - String^ uri = "http://www.woodgrovebank.com/document.xml"; - - // Create a Base64 transform. The input content retrieved from the - // URI should be Base64-decoded before other processing. - Transform^ base64 = gcnew XmlDsigBase64Transform; - - //Create a transform chain and add the transform to it. - TransformChain^ tc = gcnew TransformChain; - tc->Add( base64 ); - - //Create information. - CipherReference ^ reference = gcnew CipherReference( uri,tc ); - - // Create a new CipherData object using the CipherReference information. - // Note that you cannot assign both a CipherReference and a CipherValue - // to a CipherData object. - CipherData ^ cd = gcnew CipherData( reference ); - - // Create a new EncryptedData object. - EncryptedData^ ed = gcnew EncryptedData; - - //Add an encryption method to the object. - ed->Id = "ED"; - ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" ); - ed->CipherData = cd; - - //Add key information to the object. - KeyInfo^ ki = gcnew KeyInfo; - ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) ); - ed->KeyInfo = ki; - - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument; - XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl )); - EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement ); - ed->AddProperty( ep ); - - // Output the resulting XML information into a file. - try - { - String^ path = "c:\\test\\MyTest.xml"; - File::WriteAllText( path, ed->GetXml()->OuterXml ); - } - catch ( IOException^ e ) - { - Console::WriteLine( "File IO error. {0}", e ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp b/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp deleted file mode 100644 index a13819251ee..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/cryptography.Xml.EncryptedData2/CPP/encrypteddata.cpp +++ /dev/null @@ -1,55 +0,0 @@ - - -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography::Xml; -using namespace System::Xml; -using namespace System::IO; - -/// This sample used the EncryptedData class to create a EncryptedData element -/// and write it to an XML file. - -[STAThread] -int main() -{ - - // - // - // Create a new CipherData object using a byte array to represent encrypted data. - array^sampledata = gcnew array(8); - CipherData ^ cd = gcnew CipherData( sampledata ); - - // - // Create a new EncryptedData object. - EncryptedData^ ed = gcnew EncryptedData; - - //Add an encryption method to the object. - ed->Id = "ED"; - ed->EncryptionMethod = gcnew EncryptionMethod( "http://www.w3.org/2001/04/xmlenc#aes128-cbc" ); - ed->CipherData = cd; - - // - // - //Add key information to the object. - KeyInfo^ ki = gcnew KeyInfo; - ki->AddClause( gcnew KeyInfoRetrievalMethod( "#EK","http://www.w3.org/2001/04/xmlenc#EncryptedKey" ) ); - ed->KeyInfo = ki; - - // - // Create new XML document and put encrypted data into it. - XmlDocument^ doc = gcnew XmlDocument; - XmlElement^ encryptionPropertyElement = dynamic_cast(doc->CreateElement( "EncryptionProperty", EncryptedXml::XmlEncNamespaceUrl )); - EncryptionProperty ^ ep = gcnew EncryptionProperty( encryptionPropertyElement ); - ed->AddProperty( ep ); - - // Output the resulting XML information into a file. Change the path variable to point to a directory where - // the XML file should be written. - String^ path = "c:\\test\\MyTest.xml"; - File::WriteAllText( path, ed->GetXml()->OuterXml ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp b/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp deleted file mode 100644 index 0494e4ad274..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/rfc28981/CPP/rfc28981.cpp +++ /dev/null @@ -1,96 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Text; -using namespace System::Security::Cryptography; - -// Generate a key k1 with password pwd1 and salt salt1. -// Generate a key k2 with password pwd1 and salt salt1. -// Encrypt data1 with key k1 using symmetric encryption, creating edata1. -// Decrypt edata1 with key k2 using symmetric decryption, creating data2. -// data2 should equal data1. - -int main() -{ - array^passwordargs = Environment::GetCommandLineArgs(); - String^ usageText = "Usage: RFC2898 \nYou must specify the password for encryption.\n"; - - //If no file name is specified, write usage text. - if ( passwordargs->Length == 1 ) - { - Console::WriteLine( usageText ); - } - else - { - // - String^ pwd1 = passwordargs[ 1 ]; - - array^salt1 = gcnew array(8); - RandomNumberGenerator^ rng = RandomNumberGenerator::Create(); - rng->GetBytes(salt1); - //data1 can be a string or contents of a file. - String^ data1 = "Some test data"; - - // - //The default iteration count is 1000 so the two methods use the same iteration count. - int myIterations = 1000; - // - - // - try - { - // - Rfc2898DeriveBytes ^ k1 = gcnew Rfc2898DeriveBytes( pwd1,salt1,myIterations ); - Rfc2898DeriveBytes ^ k2 = gcnew Rfc2898DeriveBytes( pwd1,salt1 ); - // - - // Encrypt the data. - Aes^ encAlg = Aes::Create(); - encAlg->Key = k1->GetBytes( 16 ); - MemoryStream^ encryptionStream = gcnew MemoryStream; - CryptoStream^ encrypt = gcnew CryptoStream( encryptionStream,encAlg->CreateEncryptor(),CryptoStreamMode::Write ); - array^utfD1 = (gcnew System::Text::UTF8Encoding( false ))->GetBytes( data1 ); - // - - encrypt->Write( utfD1, 0, utfD1->Length ); - encrypt->FlushFinalBlock(); - encrypt->Close(); - array^edata1 = encryptionStream->ToArray(); - k1->Reset(); - - // Try to decrypt, thus showing it can be round-tripped. - Aes^ decAlg = Aes::Create(); - decAlg->Key = k2->GetBytes( 16 ); - decAlg->IV = encAlg->IV; - MemoryStream^ decryptionStreamBacking = gcnew MemoryStream; - CryptoStream^ decrypt = gcnew CryptoStream( decryptionStreamBacking,decAlg->CreateDecryptor(),CryptoStreamMode::Write ); - - // - decrypt->Write( edata1, 0, edata1->Length ); - decrypt->Flush(); - decrypt->Close(); - k2->Reset(); - // - - String^ data2 = (gcnew UTF8Encoding( false ))->GetString( decryptionStreamBacking->ToArray() ); - if ( !data1->Equals( data2 ) ) - { - Console::WriteLine( "Error: The two values are not equal." ); - } - else - { - Console::WriteLine( "The two values are equal." ); - Console::WriteLine( "k1 iterations: {0}", k1->IterationCount ); - Console::WriteLine( "k2 iterations: {0}", k2->IterationCount ); - } - // - } - - catch ( Exception^ e ) - { - Console::WriteLine( "Error: ", e ); - } - } -} -// diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp deleted file mode 100644 index fbbf07e7429..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/remarks.cpp +++ /dev/null @@ -1,26 +0,0 @@ - -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -int main() -{ -// - X509Chain^ ch = gcnew X509Chain(); - ch->ChainPolicy->ApplicationPolicy->Add(gcnew Oid("1.2.1.1")); -// - //Output chain information about the chain. - Console::WriteLine("Chain Information"); - ch->ChainPolicy->RevocationMode = X509RevocationMode::Online; - Console::WriteLine("Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag); - Console::WriteLine("Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode); - Console::WriteLine("Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags); - Console::WriteLine("Chain verification time: {0}", ch->ChainPolicy->VerificationTime); - Console::WriteLine("Chain status length: {0}", ch->ChainStatus->Length); - Console::WriteLine("Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count); - Console::WriteLine("Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine); -} diff --git a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp b/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp deleted file mode 100644 index 7b57914985d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509chaintest/CPP/x509chaintest.cpp +++ /dev/null @@ -1,73 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; - -int main() -{ - // - //Create new X509 store from local certificate store. - X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser ); - store->Open( static_cast(OpenFlags::OpenExistingOnly | OpenFlags::ReadWrite) ); - - //Output store information. - Console::WriteLine( "Store Information" ); - Console::WriteLine( "Number of certificates in the store: {0}", store->Certificates->Count ); - Console::WriteLine( "Store location: {0}", store->Location ); - Console::WriteLine( "Store name: {0} {1}", store->Name, Environment::NewLine ); - - //Put certificates from the store into a collection so user can select one. - X509Certificate2Collection ^ fcollection = dynamic_cast(store->Certificates); - X509Certificate2Collection ^ collection = X509Certificate2UI::SelectFromCollection(fcollection, "Select an X509 Certificate","Choose a certificate to examine.",X509SelectionFlag::SingleSelection); - X509Certificate2 ^ certificate = collection[ 0 ]; - X509Certificate2UI::DisplayCertificate(certificate); - // - - // - //Output chain information of the selected certificate. - X509Chain ^ ch = gcnew X509Chain; - ch->ChainPolicy->RevocationMode = X509RevocationMode::Online; - ch->Build( certificate ); - Console::WriteLine( "Chain Information" ); - Console::WriteLine( "Chain revocation flag: {0}", ch->ChainPolicy->RevocationFlag ); - Console::WriteLine( "Chain revocation mode: {0}", ch->ChainPolicy->RevocationMode ); - Console::WriteLine( "Chain verification flag: {0}", ch->ChainPolicy->VerificationFlags ); - Console::WriteLine( "Chain verification time: {0}", ch->ChainPolicy->VerificationTime ); - Console::WriteLine( "Chain status length: {0}", ch->ChainStatus->Length ); - Console::WriteLine( "Chain application policy count: {0}", ch->ChainPolicy->ApplicationPolicy->Count ); - Console::WriteLine( "Chain certificate policy count: {0} {1}", ch->ChainPolicy->CertificatePolicy->Count, Environment::NewLine ); - // - - // - //Output chain element information. - Console::WriteLine( "Chain Element Information" ); - Console::WriteLine( "Number of chain elements: {0}", ch->ChainElements->Count ); - Console::WriteLine( "Chain elements synchronized? {0} {1}", ch->ChainElements->IsSynchronized, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum = ch->ChainElements->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509ChainElement ^ element = safe_cast(myEnum->Current); - Console::WriteLine( "Element issuer name: {0}", element->Certificate->Issuer ); - Console::WriteLine( "Element certificate valid until: {0}", element->Certificate->NotAfter ); - Console::WriteLine( "Element certificate is valid: {0}", element->Certificate->Verify() ); - Console::WriteLine( "Element error status length: {0}", element->ChainElementStatus->Length ); - Console::WriteLine( "Element information: {0}", element->Information ); - Console::WriteLine( "Number of element extensions: {0}{1}", element->Certificate->Extensions->Count, Environment::NewLine ); - if ( ch->ChainStatus->Length > 1 ) - { - for ( int index = 0; index < element->ChainElementStatus->Length; index++ ) - { - Console::WriteLine( element->ChainElementStatus[ index ].Status ); - Console::WriteLine( element->ChainElementStatus[ index ].StatusInformation ); - } - } - } - - store->Close(); - // -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp b/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp deleted file mode 100644 index e1db565ed35..00000000000 --- a/snippets/cpp/VS_Snippets_CLR/x509store2/CPP/x509store2.cpp +++ /dev/null @@ -1,79 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::IO; -int main() -{ - - //Create new X509 store called teststore from the local certificate store. - X509Store ^ store = gcnew X509Store( "teststore",StoreLocation::CurrentUser ); - store->Open( OpenFlags::ReadWrite ); - X509Certificate2 ^ certificate = gcnew X509Certificate2; - - //Create certificates from certificate files. - //You must put in a valid path to three certificates in the following constructors. - X509Certificate2 ^ certificate1 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - X509Certificate2 ^ certificate2 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - X509Certificate2 ^ certificate5 = gcnew X509Certificate2( "c:\\mycerts\\*****.cer" ); - - //Create a collection and add two of the certificates. - X509Certificate2Collection ^ collection = gcnew X509Certificate2Collection; - collection->Add( certificate2 ); - collection->Add( certificate5 ); - - //Add certificates to the store. - store->Add( certificate1 ); - store->AddRange( collection ); - X509Certificate2Collection ^ storecollection = dynamic_cast(store->Certificates); - Console::WriteLine( "Store name: {0}", store->Name ); - Console::WriteLine( "Store location: {0}", store->Location ); - System::Collections::IEnumerator^ myEnum = storecollection->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - - - //Remove a certificate. - store->Remove( certificate1 ); - X509Certificate2Collection ^ storecollection2 = dynamic_cast(store->Certificates); - Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine ); - System::Collections::IEnumerator^ myEnum1 = storecollection2->GetEnumerator(); - while ( myEnum1->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum1->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - - - //Remove a range of certificates. - store->RemoveRange( collection ); - X509Certificate2Collection ^ storecollection3 = dynamic_cast(store->Certificates); - Console::WriteLine( "{1}Store name: {0}", store->Name, Environment::NewLine ); - if ( storecollection3->Count == 0 ) - { - Console::WriteLine( "Store contains no certificates." ); - } - else - { - System::Collections::IEnumerator^ myEnum2 = storecollection3->GetEnumerator(); - while ( myEnum2->MoveNext() ) - { - X509Certificate2 ^ x509 = safe_cast(myEnum2->Current); - Console::WriteLine( "certificate name: {0}", x509->Subject ); - } - } - - - //Close the store. - store->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp deleted file mode 100644 index bc8df83efca..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source.cpp +++ /dev/null @@ -1,74 +0,0 @@ -// -using namespace System; - -void PrintValues(array^myArr); -void PrintValues(array^myArr); -void main() -{ - // Creates and initializes a new int array and a new Object array. - array^myIntArray = { 1,2,3,4,5 }; - array^myObjArray = { 26,27,28,29,30 }; - - // Prints the initial values of both arrays. - Console::WriteLine("Initially:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); - - // Copies the first two elements from the int array to the Object array. - System::Array::Copy(myIntArray, myObjArray, 2); - - // Prints the values of the modified arrays. - Console::WriteLine("\nAfter copying the first two elements of the int array to the Object array:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); - - // Copies the last two elements from the Object array to the int array. - System::Array::Copy(myObjArray, myObjArray->GetUpperBound(0) - 1, myIntArray, myIntArray->GetUpperBound(0) - 1, 2); - - // Prints the values of the modified arrays. - Console::WriteLine("\nAfter copying the last two elements of the Object array to the int array:"); - Console::Write("int array: "); - PrintValues(myIntArray); - Console::Write("Object array:"); - PrintValues(myObjArray); -} - -void PrintValues(array^myArr) -{ - for (int i = 0; i < myArr->Length; i++) - { - Console::Write("\t{0}", myArr[i]); - - } - Console::WriteLine(); -} - -void PrintValues(array^myArr) -{ - for (int i = 0; i < myArr->Length; i++) - { - Console::Write("\t{0}", myArr[i]); - - } - Console::WriteLine(); -} - - -/* -This code produces the following output. - -Initially: -int array: 1 2 3 4 5 -Object array: 26 27 28 29 30 -After copying the first two elements of the int array to the Object array: -int array: 1 2 3 4 5 -Object array: 1 2 28 29 30 -After copying the last two elements of the Object array to the int array: -int array: 1 2 3 29 30 -Object array: 1 2 28 29 30 -*/ -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp deleted file mode 100644 index 10f90aa8ae1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array Example/CPP/source3.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// -using namespace System; -void PrintValues(Array^ myArr); -void main() -{ - // Creates and initializes a new three-dimensional Array instance of type Int32. - Array^ myArr = Array::CreateInstance( Int32::typeid, 2, 3, 4 ); - for ( int i = myArr->GetLowerBound( 0 ); i <= myArr->GetUpperBound( 0 ); i++ ) - { - for ( int j = myArr->GetLowerBound( 1 ); j <= myArr->GetUpperBound( 1 ); j++ ) - { - for ( int k = myArr->GetLowerBound( 2 ); k <= myArr->GetUpperBound( 2 ); k++ ) - myArr->SetValue( (i * 100) + (j * 10) + k, i, j, k ); - - } - } - - // Displays the properties of the Array. - Console::WriteLine( "The Array instance has {0} dimension(s) and a total of {1} elements.", myArr->Rank, myArr->Length ); - Console::WriteLine( "\tLength\tLower\tUpper" ); - for ( int i = 0; i < myArr->Rank; i++ ) - { - Console::Write( "{0}:\t{1}", i, myArr->GetLength( i ) ); - Console::WriteLine( "\t{0}\t{1}", myArr->GetLowerBound( i ), myArr->GetUpperBound( i ) ); - - } - Console::WriteLine( "The Array instance contains the following values:" ); - PrintValues( myArr ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - i++; - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The Array instance has 3 dimension(s) and a total of 24 elements. - Length Lower Upper - 0: 2 0 1 - 1: 3 0 2 - 2: 4 0 3 - The Array instance contains the following values: - 0 1 2 3 - 10 11 12 13 - 20 21 22 23 - 100 101 102 103 - 110 111 112 113 - 120 121 122 123 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp deleted file mode 100644 index 40db20d5eb6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.BinarySearch Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// -using namespace System; - -public ref class SamplesArray -{ -public: - static void Main() - { - // Creates and initializes a new Array. - Array^ myIntArray = Array::CreateInstance(Int32::typeid, 5); - - myIntArray->SetValue(8, 0); - myIntArray->SetValue(2, 1); - myIntArray->SetValue(6, 2); - myIntArray->SetValue(3, 3); - myIntArray->SetValue(7, 4); - - // Do the required sort first - Array::Sort(myIntArray); - - // Displays the values of the Array. - Console::WriteLine("The Int32 array contains the following:"); - PrintValues(myIntArray); - - // Locates a specific object that does not exist in the Array. - Object^ myObjectOdd = 1; - FindMyObject(myIntArray, myObjectOdd); - - // Locates an object that exists in the Array. - Object^ myObjectEven = 6; - FindMyObject(myIntArray, myObjectEven); - } - - static void FindMyObject(Array^ myArr, Object^ myObject) - { - int myIndex = Array::BinarySearch(myArr, myObject); - if (myIndex < 0) - { - Console::WriteLine("The object to search for ({0}) is not found. The next larger object is at index {1}.", myObject, ~myIndex); - } - else - { - Console::WriteLine("The object to search for ({0}) is at index {1}.", myObject, myIndex); - } - } - - static void PrintValues(Array^ myArr) - { - int i = 0; - int cols = myArr->GetLength(myArr->Rank - 1); - for each (Object^ o in myArr) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - Console::Write("\t{0}", o); - } - Console::WriteLine(); - } -}; - -int main() -{ - SamplesArray::Main(); -} -// This code produces the following output. -// -//The Int32 array contains the following: -// 2 3 6 7 8 -//The object to search for (1) is not found. The next larger object is at index 0 -// -//The object to search for (6) is at index 2. -// - diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp deleted file mode 100644 index 16882781c33..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Copy1 Example/CPP/source.cpp +++ /dev/null @@ -1,72 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - - // Creates and initializes a new Array instance of type Int32. - Array^ myIntArray = Array::CreateInstance( Type::GetType( "System.Int32" ), 5 ); - for ( int i = myIntArray->GetLowerBound( 0 ); i <= myIntArray->GetUpperBound( 0 ); i++ ) - myIntArray->SetValue( i + 1, i ); - - // Creates and initializes a new Array instance of type Object. - Array^ myObjArray = Array::CreateInstance( Type::GetType( "System.Object" ), 5 ); - for ( int i = myObjArray->GetLowerBound( 0 ); i <= myObjArray->GetUpperBound( 0 ); i++ ) - myObjArray->SetValue( i + 26, i ); - - // Displays the initial values of both arrays. - Console::WriteLine( "Int32 array:" ); - PrintValues( myIntArray ); - Console::WriteLine( "Object array:" ); - PrintValues( myObjArray ); - - // Copies the first element from the Int32 array to the Object array. - Array::Copy( myIntArray, myIntArray->GetLowerBound( 0 ), myObjArray, myObjArray->GetLowerBound( 0 ), 1 ); - - // Copies the last two elements from the Object array to the Int32 array. - Array::Copy( myObjArray, myObjArray->GetUpperBound( 0 ) - 1, myIntArray, myIntArray->GetUpperBound( 0 ) - 1, 2 ); - - // Displays the values of the modified arrays. - Console::WriteLine( "Int32 array - Last two elements should now be the same as Object array:" ); - PrintValues( myIntArray ); - Console::WriteLine( "Object array - First element should now be the same as Int32 array:" ); - PrintValues( myObjArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Int32 array: - 1 2 3 4 5 - Object array: - 26 27 28 29 30 - Int32 array - Last two elements should now be the same as Object array: - 1 2 3 29 30 - Object array - First element should now be the same as Int32 array: - 1 27 28 29 30 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp deleted file mode 100644 index 2caab9082ed..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source.cpp +++ /dev/null @@ -1,67 +0,0 @@ - -// -using namespace System; - -void main() -{ - // Creates and initializes two new Array instances. - Array^ mySourceArray = Array::CreateInstance(String::typeid, 6); - mySourceArray->SetValue("three", 0); - mySourceArray->SetValue("napping", 1); - mySourceArray->SetValue("cats", 2); - mySourceArray->SetValue("in", 3); - mySourceArray->SetValue("the", 4); - mySourceArray->SetValue("barn", 5); - Array^ myTargetArray = Array::CreateInstance(String::typeid, 15); - myTargetArray->SetValue("The", 0); - myTargetArray->SetValue("quick", 1); - myTargetArray->SetValue("brown", 2); - myTargetArray->SetValue("fox", 3); - myTargetArray->SetValue("jumps", 4); - myTargetArray->SetValue("over", 5); - myTargetArray->SetValue("the", 6); - myTargetArray->SetValue("lazy", 7); - myTargetArray->SetValue("dog", 8); - - // Displays the values of the Array. - Console::WriteLine( "The target Array instance contains the following (before and after copying):"); - PrintValues(myTargetArray); - - // Copies the source Array to the target Array, starting at index 6. - mySourceArray->CopyTo(myTargetArray, 6); - - // Displays the values of the Array. - PrintValues(myTargetArray); -} - -void PrintValues(Array^ myArr) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength(myArr->Rank - 1); - while (myEnumerator->MoveNext()) - { - if (i < cols) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( " {0}", myEnumerator->Current); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The target Array instance contains the following (before and after copying): - The quick brown fox jumps over the lazy dog - The quick brown fox jumps over three napping cats in the barn - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp deleted file mode 100644 index ca74d220df4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CopyTo Example/CPP/source2.cpp +++ /dev/null @@ -1,61 +0,0 @@ -// -using namespace System; - -void main() -{ - // Creates and initializes the source Array. - Array^ myArrayZero = Array::CreateInstance(String::typeid, 3); - myArrayZero->SetValue("zero", 0); - myArrayZero->SetValue("one", 1); - - // Displays the source Array. - Console::WriteLine("The array with lowbound=0 contains:"); - PrintIndexAndValues(myArrayZero); - - // Creates and initializes the target Array. - array^myArrLen = {4}; - array^myArrLow = {2}; - Array^ myArrayTwo = Array::CreateInstance(String::typeid, myArrLen, myArrLow); - myArrayTwo->SetValue("two", 2); - myArrayTwo->SetValue("three", 3); - myArrayTwo->SetValue("four", 4); - myArrayTwo->SetValue("five", 5); - - // Displays the target Array. - Console::WriteLine("The array with lowbound=2 contains:"); - PrintIndexAndValues(myArrayTwo); - - // Copy from the array with lowbound=0 to the array with lowbound=2. - myArrayZero->CopyTo(myArrayTwo, 3); - - // Displays the modified target Array. - Console::WriteLine("\nAfter copying at relative index 1:"); - PrintIndexAndValues(myArrayTwo); -} - -void PrintIndexAndValues(Array^ myArray) -{ - for (int i = myArray->GetLowerBound(0); i <= myArray->GetUpperBound(0); i++) - Console::WriteLine("\t[{0}]:\t{1}", i, myArray->GetValue(i)); -} - -/* - This code produces the following output. - - The array with lowbound=0 contains: - [0]: zero - [1]: one - [2]: - The array with lowbound=2 contains: - [2]: two - [3]: three - [4]: four - [5]: five - - After copying at relative index 1: - [2]: two - [3]: zero - [4]: one - [5]: - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp deleted file mode 100644 index 6fb07cb3bf1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a one-dimensional Array instance of type Int32. - Array^ my1DArray = Array::CreateInstance( Int32::typeid, 5 ); - for ( int i = my1DArray->GetLowerBound( 0 ); i <= my1DArray->GetUpperBound( 0 ); i++ ) - my1DArray->SetValue( i + 1, i ); - - // Displays the values of the Array. - Console::WriteLine( "The one-dimensional Array instance contains the following values:" ); - PrintValues( my1DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The one-dimensional Array instance contains the following values: - 1 2 3 4 5 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp deleted file mode 100644 index 782e95f0280..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance1 Example/CPP/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a two-dimensional Array instance of type String. - Array^ my2DArray = Array::CreateInstance( String::typeid, 2, 3 ); - for ( int i = my2DArray->GetLowerBound( 0 ); i <= my2DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my2DArray->GetLowerBound( 1 ); j <= my2DArray->GetUpperBound( 1 ); j++ ) - my2DArray->SetValue( String::Concat( "abc", i, j ), i, j ); - - // Displays the values of the Array. - Console::WriteLine( "The two-dimensional Array instance contains the following values:" ); - PrintValues( my2DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The two-dimensional Array instance contains the following values: - abc00 abc01 abc02 - abc10 abc11 abc12 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp deleted file mode 100644 index dfc52829993..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance2 Example/CPP/source.cpp +++ /dev/null @@ -1,53 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a three-dimensional Array instance of type Object. - Array^ my3DArray = Array::CreateInstance( Object::typeid, 2, 3, 4 ); - for ( int i = my3DArray->GetLowerBound( 0 ); i <= my3DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my3DArray->GetLowerBound( 1 ); j <= my3DArray->GetUpperBound( 1 ); j++ ) - for ( int k = my3DArray->GetLowerBound( 2 ); k <= my3DArray->GetUpperBound( 2 ); k++ ) - my3DArray->SetValue( String::Concat( "abc", i, j, k ), i, j, k ); - - // Displays the values of the Array. - Console::WriteLine( "The three-dimensional Array instance contains the following values:" ); - PrintValues( my3DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The three-dimensional Array instance contains the following values: - abc000 abc001 abc002 abc003 - abc010 abc011 abc012 abc013 - abc020 abc021 abc022 abc023 - abc100 abc101 abc102 abc103 - abc110 abc111 abc112 abc113 - abc120 abc121 abc122 abc123 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp deleted file mode 100644 index cf5aac93295..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance3 Example/CPP/source.cpp +++ /dev/null @@ -1,77 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a multidimensional Array instance of type String. - array^myLengthsArray = {2,3,4,5}; - Array^ my4DArray = Array::CreateInstance( String::typeid, myLengthsArray ); - for ( int i = my4DArray->GetLowerBound( 0 ); i <= my4DArray->GetUpperBound( 0 ); i++ ) - for ( int j = my4DArray->GetLowerBound( 1 ); j <= my4DArray->GetUpperBound( 1 ); j++ ) - for ( int k = my4DArray->GetLowerBound( 2 ); k <= my4DArray->GetUpperBound( 2 ); k++ ) - for ( int l = my4DArray->GetLowerBound( 3 ); l <= my4DArray->GetUpperBound( 3 ); l++ ) - { - array^myIndicesArray = {i,j,k,l}; - my4DArray->SetValue( String::Concat( Convert::ToString( i ), j, k, l ), myIndicesArray ); - - } - - // Displays the values of the Array. - Console::WriteLine( "The four-dimensional Array instance contains the following values:" ); - PrintValues( my4DArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - The four-dimensional Array instance contains the following values: - 0000 0001 0002 0003 0004 - 0010 0011 0012 0013 0014 - 0020 0021 0022 0023 0024 - 0030 0031 0032 0033 0034 - 0100 0101 0102 0103 0104 - 0110 0111 0112 0113 0114 - 0120 0121 0122 0123 0124 - 0130 0131 0132 0133 0134 - 0200 0201 0202 0203 0204 - 0210 0211 0212 0213 0214 - 0220 0221 0222 0223 0224 - 0230 0231 0232 0233 0234 - 1000 1001 1002 1003 1004 - 1010 1011 1012 1013 1014 - 1020 1021 1022 1023 1024 - 1030 1031 1032 1033 1034 - 1100 1101 1102 1103 1104 - 1110 1111 1112 1113 1114 - 1120 1121 1122 1123 1124 - 1130 1131 1132 1133 1134 - 1200 1201 1202 1203 1204 - 1210 1211 1212 1213 1214 - 1220 1221 1222 1223 1224 - 1230 1231 1232 1233 1234 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp deleted file mode 100644 index cc1ff6dbbc9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.CreateInstance4 Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - -// -using namespace System; -void PrintValues( Array^ myArr ); -void main() -{ - // Creates and initializes a multidimensional Array instance of type String. - array^myLengthsArray = {3,5}; - array^myBoundsArray = {2,3}; - Array^ myArray = Array::CreateInstance( String::typeid, myLengthsArray, myBoundsArray ); - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - for ( int j = myArray->GetLowerBound( 1 ); j <= myArray->GetUpperBound( 1 ); j++ ) - { - array^myIndicesArray = {i,j}; - myArray->SetValue( String::Concat( Convert::ToString( i ), j ), myIndicesArray ); - - } - - // Displays the lower bounds and the upper bounds of each dimension. - Console::WriteLine( "Bounds:\tLower\tUpper" ); - for ( int i = 0; i < myArray->Rank; i++ ) - Console::WriteLine( "{0}:\t{1}\t{2}", i, myArray->GetLowerBound( i ), myArray->GetUpperBound( i ) ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance contains the following values:" ); - PrintValues( myArray ); -} - -void PrintValues( Array^ myArr ) -{ - System::Collections::IEnumerator^ myEnumerator = myArr->GetEnumerator(); - int i = 0; - int cols = myArr->GetLength( myArr->Rank - 1 ); - while ( myEnumerator->MoveNext() ) - { - if ( i < cols ) - { - i++; - } - else - { - Console::WriteLine(); - i = 1; - } - - Console::Write( "\t{0}", myEnumerator->Current ); - } - - Console::WriteLine(); -} - -/* - This code produces the following output. - - Bounds: Lower Upper - 0: 2 4 - 1: 3 7 - The Array instance contains the following values: - 23 24 25 26 27 - 33 34 35 36 37 - 43 44 45 46 47 - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp deleted file mode 100644 index 18923bcbb6c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.IndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,51 +0,0 @@ - -// -using namespace System; - -void main() -{ - // Create a string array with 3 elements having the same value. - array^ strings = { "the", "quick", "brown", "fox", - "jumps", "over", "the", "lazy", "dog", - "in", "the", "barn" }; - - // Display the elements of the array. - Console::WriteLine("The array contains the following values:"); - for (int i = strings->GetLowerBound(0); i <= strings->GetUpperBound(0); i++) - Console::WriteLine(" [{0,2}]: {1}", i, strings[i]); - - // Search for the first occurrence of the duplicated value. - String^ searchString = "the"; - int index = Array::IndexOf(strings, searchString); - Console::WriteLine("The first occurrence of \"{0}\" is at index {1}.", - searchString, index); - - // Search for the first occurrence of the duplicated value in the last section of the array. - index = Array::IndexOf( strings, searchString, 4); - Console::WriteLine("The first occurrence of \"{0}\" between index 4 and the end is at index {1}.", - searchString, index); - - // Search for the first occurrence of the duplicated value in a section of the array. - int position = index + 1; - index = Array::IndexOf(strings, searchString, position, strings->GetUpperBound(0) - position + 1); - Console::WriteLine("The first occurrence of \"{0}\" between index {1} and index {2} is at index {3}.", - searchString, position, strings->GetUpperBound(0), index); -} -// The example displays the following output: -// The array contains the following values: -// [ 0]: the -// [ 1]: quick -// [ 2]: brown -// [ 3]: fox -// [ 4]: jumps -// [ 5]: over -// [ 6]: the -// [ 7]: lazy -// [ 8]: dog -// [ 9]: in -// [10]: the -// [11]: barn -// The first occurrence of "the" is at index 0. -// The first occurrence of "the" between index 4 and the end is at index 6. -// The first occurrence of "the" between index 7 and index 11 is at index 10. -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp deleted file mode 100644 index 1b8d7459315..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.LastIndexOf Example/CPP/source.cpp +++ /dev/null @@ -1,68 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); - -void main() -{ - // Creates and initializes a new Array instance with three elements of the same value. - Array^ myArray = Array::CreateInstance( String::typeid, 12 ); - myArray->SetValue( "the", 0 ); - myArray->SetValue( "quick", 1 ); - myArray->SetValue( "brown", 2 ); - myArray->SetValue( "fox", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - myArray->SetValue( "in", 9 ); - myArray->SetValue( "the", 10 ); - myArray->SetValue( "barn", 11 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Searches for the last occurrence of the duplicated value. - String^ myString = "the"; - int myIndex = Array::LastIndexOf( myArray, myString ); - Console::WriteLine( "The last occurrence of \"{0}\" is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in the first section of the Array. - myIndex = Array::LastIndexOf( myArray, myString, 8 ); - Console::WriteLine( "The last occurrence of \"{0}\" between the start and index 8 is at index {1}.", myString, myIndex ); - - // Searches for the last occurrence of the duplicated value in a section of the Array. - // Note that the start index is greater than the end index because the search is done backward. - myIndex = Array::LastIndexOf( myArray, myString, 10, 6 ); - Console::WriteLine( "The last occurrence of \"{0}\" between index 5 and index 10 is at index {1}.", myString, myIndex ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance contains the following values: - [0]: the - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - [9]: in - [10]: the - [11]: barn - The last occurrence of "the" is at index 10. - The last occurrence of "the" between the start and index 8 is at index 6. - The last occurrence of "the" between index 5 and index 10 is at index 10. - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp deleted file mode 100644 index 097d0727938..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); -void main() -{ - // Creates and initializes a new Array instance. - Array^ myArray = Array::CreateInstance( String::typeid, 9 ); - myArray->SetValue( "The", 0 ); - myArray->SetValue( "quick", 1 ); - myArray->SetValue( "brown", 2 ); - myArray->SetValue( "fox", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance initially contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Reverses the sort of the values of the Array. - Array::Reverse( myArray ); - - // Displays the values of the Array. - Console::WriteLine( "After reversing:" ); - PrintIndexAndValues( myArray ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance initially contains the following values: - [0]: The - [1]: quick - [2]: brown - [3]: fox - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - After reversing: - [0]: dog - [1]: lazy - [2]: the - [3]: over - [4]: jumps - [5]: fox - [6]: brown - [7]: quick - [8]: The - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp deleted file mode 100644 index 1f394ab0ee6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Array.Reverse1 Example/CPP/source.cpp +++ /dev/null @@ -1,61 +0,0 @@ - -// -using namespace System; -void PrintIndexAndValues( Array^ myArray ); -void main() -{ - // Creates and initializes a new Array instance. - Array^ myArray = Array::CreateInstance( String::typeid, 9 ); - myArray->SetValue( "The", 0 ); - myArray->SetValue( "QUICK", 1 ); - myArray->SetValue( "BROWN", 2 ); - myArray->SetValue( "FOX", 3 ); - myArray->SetValue( "jumps", 4 ); - myArray->SetValue( "over", 5 ); - myArray->SetValue( "the", 6 ); - myArray->SetValue( "lazy", 7 ); - myArray->SetValue( "dog", 8 ); - - // Displays the values of the Array. - Console::WriteLine( "The Array instance initially contains the following values:" ); - PrintIndexAndValues( myArray ); - - // Reverses the sort of the values of the Array. - Array::Reverse( myArray, 1, 3 ); - - // Displays the values of the Array. - Console::WriteLine( "After reversing:" ); - PrintIndexAndValues( myArray ); -} - -void PrintIndexAndValues( Array^ myArray ) -{ - for ( int i = myArray->GetLowerBound( 0 ); i <= myArray->GetUpperBound( 0 ); i++ ) - Console::WriteLine( "\t[{0}]:\t{1}", i, myArray->GetValue( i ) ); -} - -/* - This code produces the following output. - - The Array instance initially contains the following values: - [0]: The - [1]: QUICK - [2]: BROWN - [3]: FOX - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - After reversing: - [0]: The - [1]: FOX - [2]: BROWN - [3]: QUICK - [4]: jumps - [5]: over - [6]: the - [7]: lazy - [8]: dog - */ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp deleted file mode 100644 index 2aa6055f25c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic AttributeUsageAttribute.AttributeUsageAttribute Example/CPP/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ - - -#using - -using namespace System; - -// -namespace InteropServices -{ - [AttributeUsage(AttributeTargets::Method| - AttributeTargets::Field| - AttributeTargets::Property) - ] - public ref class DispIdAttribute: public Attribute - { - public: - DispIdAttribute( int value ) - { - // . . . - } - - property int Value - { - int get() - { - // . . . - return 0; - } - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp deleted file mode 100644 index b9c151ae5a8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic CompilerError Example/CPP/source.cpp +++ /dev/null @@ -1,80 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; -using namespace Microsoft::CSharp; -CodeCompileUnit^ GetCompileUnit() -{ - - // Create a compile unit to contain a CodeDOM graph. - CodeCompileUnit^ cu = gcnew CodeCompileUnit; - - // Create a namespace named TestSpace. - CodeNamespace^ cn = gcnew CodeNamespace( "TestSpace" ); - - // Declare a new type named TestClass. - CodeTypeDeclaration^ cd = gcnew CodeTypeDeclaration( "TestClass" ); - - // Declare a new member string field named TestField. - CodeMemberField^ cmf = gcnew CodeMemberField( "System.String","TestField" ); - - // Add the field to the type. - cd->Members->Add( cmf ); - - // Declare a new member method named TestMethod. - CodeMemberMethod^ cm = gcnew CodeMemberMethod; - cm->Name = "TestMethod"; - - // Declare a string variable named TestVariable. - CodeVariableDeclarationStatement^ cvd = gcnew CodeVariableDeclarationStatement( "System.String1","TestVariable" ); - cm->Statements->Add( cvd ); - - // Cast the TestField reference expression to string and assign it to the TestVariable. - CodeAssignStatement^ ca = gcnew CodeAssignStatement( gcnew CodeVariableReferenceExpression( "TestVariable" ),gcnew CodeCastExpression( "System.String2",gcnew CodeFieldReferenceExpression( gcnew CodeThisReferenceExpression,"TestField" ) ) ); - - // This code can be used to generate the following code in C#: - // TestVariable = ((string)(this.TestField)); - cm->Statements->Add( ca ); - - // Add the TestMethod member to the TestClass type. - cd->Members->Add( cm ); - - // Add the TestClass type to the namespace. - cn->Types->Add( cd ); - - // Add the TestSpace namespace to the compile unit. - cu->Namespaces->Add( cn ); - return cu; -} - -int main() -{ - - // Output some program information using Console.WriteLine. - Console::WriteLine( "This program compiles a CodeDOM program that incorrectly declares multiple data" ); - Console::WriteLine( "types to demonstrate handling compiler errors programmatically." ); - Console::WriteLine( "" ); - - // Compile the CodeCompileUnit retrieved from the GetCompileUnit() method. - //CSharpCodeProvider ^ provider = gcnew Microsoft::CSharp::CSharpCodeProvider; - CodeDomProvider ^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Initialize a CompilerParameters with the options for compilation. - array^assemblies = {"System.dll"}; - CompilerParameters^ options = gcnew CompilerParameters( assemblies,"output.exe" ); - - // Compile the CodeDOM graph and store the results in a CompilerResults. - CompilerResults^ results = provider->CompileAssemblyFromDom( options, GetCompileUnit() ); - - // Compilation produces errors. Print out each error. - Console::WriteLine( "Listing errors from compilation: " ); - Console::WriteLine( "" ); - for ( int i = 0; i < results->Errors->Count; i++ ) - Console::WriteLine( results->Errors[ i ] ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp deleted file mode 100644 index d67485dbd80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic CryptoStream Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -#using - -using namespace System; -using namespace System::IO; -using namespace System::ComponentModel; -using namespace System::Security::Cryptography; - -// -void EncryptData( String^ inName, String^ outName, array^aesKey, array^aesIV ) -{ - - //Create the file streams to handle the input and output files. - FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read ); - FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write ); - fout->SetLength( 0 ); - - //Create variables to help with read and write. - array^bin = gcnew array(100); - long rdlen = 0; //This is the total number of bytes written. - - long totlen = (long)fin->Length; //This is the total length of the input file. - - int len; //This is the number of bytes to be written at a time. - - Aes^ aes = Aes::Create(); - - CryptoStream^ encStream = gcnew CryptoStream( fout,aes->CreateEncryptor( aesKey, aesIV ),CryptoStreamMode::Write ); - Console::WriteLine( "Encrypting..." ); - - //Read from the input file, then encrypt and write to the output file. - while ( rdlen < totlen ) - { - len = fin->Read( bin, 0, 100 ); - encStream->Write( bin, 0, len ); - rdlen = rdlen + len; - Console::WriteLine( "{0} bytes processed", rdlen ); - } - - encStream->Close(); - fout->Close(); - fin->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp deleted file mode 100644 index 505973f52b6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DES Example/CPP/source.cpp +++ /dev/null @@ -1,46 +0,0 @@ - - -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Windows::Forms; -using namespace System::Security::Cryptography; - -// -void EncryptData( String^ inName, String^ outName, array^desKey, array^desIV ) -{ - - //Create the file streams to handle the input and output files. - FileStream^ fin = gcnew FileStream( inName,FileMode::Open,FileAccess::Read ); - FileStream^ fout = gcnew FileStream( outName,FileMode::OpenOrCreate,FileAccess::Write ); - fout->SetLength( 0 ); - - //Create variables to help with read and write. - array^bin = gcnew array(100); - long rdlen = 0; //This is the total number of bytes written. - - long totlen = (long)fin->Length; //This is the total length of the input file. - - int len; //This is the number of bytes to be written at a time. - - DES^ des = gcnew DESCryptoServiceProvider; - CryptoStream^ encStream = gcnew CryptoStream( fout,des->CreateEncryptor( desKey, desIV ),CryptoStreamMode::Write ); - Console::WriteLine( "Encrypting..." ); - - //Read from the input file, then encrypt and write to the output file. - while ( rdlen < totlen ) - { - len = fin->Read( bin, 0, 100 ); - encStream->Write( bin, 0, len ); - rdlen = rdlen + len; - Console::WriteLine( "{0} bytes processed", rdlen ); - } - - encStream->Close(); - fout->Close(); - fin->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp deleted file mode 100644 index 494de16ea1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic DateTime.ToString2 Example/CPP/source.cpp +++ /dev/null @@ -1,41 +0,0 @@ - -// -using namespace System; -using namespace System::Globalization; -void main() -{ - DateTime dt = DateTime::Now; - array^format = {L"d",L"D",L"f",L"F",L"g",L"G",L"m",L"r",L"s",L"t",L"T",L"u",L"U",L"y",L"dddd, MMMM dd yyyy",L"ddd, MMM d \"'\"yy",L"dddd, MMMM dd",L"M/yy",L"dd-MM-yy"}; - String^ date; - for ( int i = 0; i < format->Length; i++ ) - { - date = dt.ToString( format[ i ], DateTimeFormatInfo::InvariantInfo ); - Console::WriteLine( String::Concat( format[ i ], L" :", date ) ); - - } - - /** Output. - * - * d :08/17/2000 - * D :Thursday, August 17, 2000 - * f :Thursday, August 17, 2000 16:32 - * F :Thursday, August 17, 2000 16:32:32 - * g :08/17/2000 16:32 - * G :08/17/2000 16:32:32 - * m :August 17 - * r :Thu, 17 Aug 2000 23:32:32 GMT - * s :2000-08-17T16:32:32 - * t :16:32 - * T :16:32:32 - * u :2000-08-17 23:32:32Z - * U :Thursday, August 17, 2000 23:32:32 - * y :August, 2000 - * dddd, MMMM dd yyyy :Thursday, August 17 2000 - * ddd, MMM d "'"yy :Thu, Aug 17 '00 - * dddd, MMMM dd :Thursday, August 17 - * M/yy :8/00 - * dd-MM-yy :17-08-00 - */ -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp deleted file mode 100644 index ec2ce96c984..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Delegate Example/CPP/source.cpp +++ /dev/null @@ -1,63 +0,0 @@ - - -// -using namespace System; -delegate String^ myMethodDelegate( // Declares a delegate for a method that takes in an int and returns a String. -int myInt ); - -// Defines some methods to which the delegate can point. -ref class mySampleClass -{ -public: - - // Defines an instance method. - String^ myStringMethod( int myInt ) - { - if ( myInt > 0 ) - return ("positive"); - - if ( myInt < 0 ) - return ("negative"); - - return ("zero"); - } - - - // Defines a static method. - static String^ mySignMethod( int myInt ) - { - if ( myInt > 0 ) - return ("+"); - - if ( myInt < 0 ) - return ("-"); - - return (""); - } - -}; - -int main() -{ - - // Creates one delegate for each method. For the instance method, an - // instance (mySC) must be supplied. For the static method, only the - // method name is needed. - mySampleClass^ mySC = gcnew mySampleClass; - myMethodDelegate^ myD1 = gcnew myMethodDelegate( mySC, &mySampleClass::myStringMethod ); - myMethodDelegate^ myD2 = gcnew myMethodDelegate( mySampleClass::mySignMethod ); - - // Invokes the delegates. - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", 5, myD1( 5 ), myD2( 5 ) ); - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", -3, myD1( -3 ), myD2( -3 ) ); - Console::WriteLine( "{0} is {1}; use the sign \"{2}\".", 0, myD1( 0 ), myD2( 0 ) ); -} - -/* -This code produces the following output: - -5 is positive; use the sign "+". --3 is negative; use the sign "-". -0 is zero; use the sign "". -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp b/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp deleted file mode 100644 index f3f215111a7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_Classic/classic Enum.ToString2 Example/CPP/source.cpp +++ /dev/null @@ -1,30 +0,0 @@ - -// -using namespace System; -public ref class EnumSample -{ -public: - enum class Colors - { - Red = 1, - Blue = 2 - }; - - static void main() - { - Enum ^ myColors = Colors::Red; - Console::WriteLine( "The value of this instance is '{0}'", myColors ); - } - -}; - -int main() -{ - EnumSample::main(); -} - -/* -Output. -The value of this instance is 'Red'. -*/ -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp deleted file mode 100644 index f17fb57cbb7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/System.Security.Cryptography.RSACryptoServiceProvider ManualHash Example/CPP/class1.cpp +++ /dev/null @@ -1,153 +0,0 @@ - - -// -// This example uses the SHA1 algorithm. -// Due to collision problems with SHA1, Microsoft recommends SHA256 or better. -#using - -using namespace System; -using namespace System::Text; -using namespace System::Security::Cryptography; -ref class Sender -{ -private: - RSAParameters rsaPubParams; - RSAParameters rsaPrivateParams; - -public: - Sender() - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - - //Generate public and private key data. - rsaPrivateParams = rsaCSP->ExportParameters( true ); - rsaPubParams = rsaCSP->ExportParameters( false ); - } - - - property RSAParameters PublicParameters - { - RSAParameters get() - { - return rsaPubParams; - } - - } - - //Manually performs hash and then signs hashed value. - array^ HashAndSign( array^encrypted ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - SHA1Managed^ hash = gcnew SHA1Managed; - array^hashedData; - rsaCSP->ImportParameters( rsaPrivateParams ); - hashedData = hash->ComputeHash( encrypted ); - return rsaCSP->SignHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ) ); - } - - - //Encrypts using only the public key data. - array^ EncryptData( RSAParameters rsaParams, array^toEncrypt ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - rsaCSP->ImportParameters( rsaParams ); - return rsaCSP->Encrypt( toEncrypt, false ); - } - -}; - -ref class Receiver -{ -private: - RSAParameters rsaPubParams; - RSAParameters rsaPrivateParams; - -public: - Receiver() - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - - //Generate public and private key data. - rsaPrivateParams = rsaCSP->ExportParameters( true ); - rsaPubParams = rsaCSP->ExportParameters( false ); - } - - - property RSAParameters PublicParameters - { - RSAParameters get() - { - return rsaPubParams; - } - - } - - //Manually performs hash and then verifies hashed value. - // - bool VerifyHash( RSAParameters rsaParams, array^signedData, array^signature ) - { - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - SHA1Managed^ hash = gcnew SHA1Managed; - array^hashedData; - rsaCSP->ImportParameters( rsaParams ); - bool dataOK = rsaCSP->VerifyData(signedData, CryptoConfig::MapNameToOID("SHA1"), signature); - hashedData = hash->ComputeHash( signedData ); - return rsaCSP->VerifyHash( hashedData, CryptoConfig::MapNameToOID( "SHA1" ), signature ); - } - // - - - //Decrypt using the private key data. - void DecryptData( array^encrypted ) - { - array^fromEncrypt; - String^ roundTrip; - ASCIIEncoding^ myAscii = gcnew ASCIIEncoding; - RSACryptoServiceProvider^ rsaCSP = gcnew RSACryptoServiceProvider; - rsaCSP->ImportParameters( rsaPrivateParams ); - fromEncrypt = rsaCSP->Decrypt( encrypted, false ); - roundTrip = myAscii->GetString( fromEncrypt ); - Console::WriteLine( "RoundTrip: {0}", roundTrip ); - } - -}; - -int main() -{ - array^toEncrypt; - array^encrypted; - array^signature; - - //Choose a small amount of data to encrypt. - String^ original = "Hello"; - ASCIIEncoding^ myAscii = gcnew ASCIIEncoding; - - //Create a sender and receiver. - Sender^ mySender = gcnew Sender; - Receiver^ myReceiver = gcnew Receiver; - - //Convert the data string to a byte array. - toEncrypt = myAscii->GetBytes( original ); - - //Encrypt data using receiver's public key. - encrypted = mySender->EncryptData( myReceiver->PublicParameters, toEncrypt ); - - //Hash the encrypted data and generate a signature on the hash - // using the sender's private key. - signature = mySender->HashAndSign( encrypted ); - Console::WriteLine( "Original: {0}", original ); - - //Verify the signature is authentic using the sender's public key. - if ( myReceiver->VerifyHash( mySender->PublicParameters, encrypted, signature ) ) - { - - //Decrypt the data using the receiver's private key. - myReceiver->DecryptData( encrypted ); - } - else - { - Console::WriteLine( "Invalid signature" ); - } -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp deleted file mode 100644 index c07a0a5476f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/resxresourcereader.cpp +++ /dev/null @@ -1,30 +0,0 @@ - - -// -#using -#using - -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -void main() -{ - - // Create a ResXResourceReader for the file items.resx. - ResXResourceReader^ rsxr = gcnew ResXResourceReader( "items.resx" ); - - - // Iterate through the resources and display the contents to the console. - IEnumerator^ myEnum = rsxr->GetEnumerator(); - while ( myEnum->MoveNext() ) - { - DictionaryEntry^ d = safe_cast(myEnum->Current); - Console::WriteLine( "{0}:\t {1}", d->Key, d->Value ); - } - - - //Close the reader. - rsxr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp deleted file mode 100644 index d1d5faf2d6d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResXResourceReader Example/CPP/useresxdatanodes.cpp +++ /dev/null @@ -1,112 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::Resources; -using namespace System::ComponentModel::Design; - -namespace UseDataNodesExample -{ - public ref class Program - { - public: - static void Main() - { - Console::WriteLine("\nEnumerating as data items..."); - EnumResourceItems("Resource1.resx", false); - - Console::WriteLine("\nEnumerating as data nodes..."); - EnumResourceItems("Resource1.resx", true); - } - - static void EnumResourceItems(String^ resxFile, bool useDataNodes) - { - ResXResourceReader^ reader = gcnew ResXResourceReader(resxFile); - - reader->UseResXDataNodes = useDataNodes; - - // - // Enumerate using IEnumerable.GetEnumerator(). - Console::WriteLine("\n Default enumerator:"); - for each (DictionaryEntry entry in reader) - { - ShowResourceItem(entry, useDataNodes); - } - // - - // - // Enumerate using GetMetadataEnumerator() - IDictionaryEnumerator^ metadataEnumerator = reader->GetMetadataEnumerator(); - - Console::WriteLine("\n MetadataEnumerator:"); - while (metadataEnumerator->MoveNext()) - { - ShowResourceItem(metadataEnumerator->Entry, useDataNodes); - } - // - - // - // Enumerate using GetEnumerator() - IDictionaryEnumerator^ enumerator = reader->GetEnumerator(); - - Console::WriteLine("\n Enumerator:"); - while (enumerator->MoveNext()) - { - ShowResourceItem(enumerator->Entry, useDataNodes); - } - // - delete reader; - } - - static void ShowResourceItem(DictionaryEntry entry, bool isDataNode) - { - // Use a nullptr type resolver. - ITypeResolutionService^ typeres = nullptr; - ResXDataNode^ dnode; - - if (isDataNode) - { - // Display from node info. - dnode = (ResXDataNode^)entry.Value; - Console::WriteLine(" {0}={1}", dnode->Name, dnode->GetValue(typeres)); - } - else - { - // Display as DictionaryEntry info. - Console::WriteLine(" {0}={1}", entry.Key, entry.Value); - } - } - }; -} - -int main() -{ - UseDataNodesExample::Program::Main(); -} -// The example program will have the following output: -// -// Enumerating as data items... -// -// Default enumerator: -// DataSample=Sample DATA value -// -// MetadataEnumerator: -// MetadataSample=Sample METADATA value -// -// Enumerator: -// DataSample=Sample DATA value -// -// Enumerating as data nodes... -// -// Default enumerator: -// DataSample=Sample DATA value -// MetadataSample=Sample METADATA value -// -// MetadataEnumerator: -// -// Enumerator: -// DataSample=Sample DATA value -// MetadataSample=Sample METADATA value -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp deleted file mode 100644 index 07b62bf13b4..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceReader.GetEnumerator Example/CPP/getenumerator.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -int main() -{ - - // Create a ResourceReader for the file items.resources. - ResourceReader^ rr = gcnew ResourceReader( "items.resources" ); - - // Create an IDictionaryEnumerator* to iterate through the resources. - IDictionaryEnumerator^ id = rr->GetEnumerator(); - - // Iterate through the resources and display the contents to the console. - while ( id->MoveNext() ) - Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value ); - - rr->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp deleted file mode 100644 index 8f81922ead1..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceSet.GetEnumerator/CPP/getenumerator.cpp +++ /dev/null @@ -1,22 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::Collections; -int main() -{ - - // Create a ResourceSet for the file items.resources. - ResourceSet^ rs = gcnew ResourceSet( "items.resources" ); - - // Create an IDictionaryEnumerator* to read the data in the ResourceSet. - IDictionaryEnumerator^ id = rs->GetEnumerator(); - - // Iterate through the ResourceSet and display the contents to the console. - while ( id->MoveNext() ) - Console::WriteLine( "\n [{0}] \t {1}", id->Key, id->Value ); - - rs->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp deleted file mode 100644 index b782b33e9ef..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter Cstr1 Example/CPP/resourcewritercstr1.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Write the resources to the stream, and close it. - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp deleted file mode 100644 index f96fb6c9ed2..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Dispose Example/CPP/resourcewriterdispose.cpp +++ /dev/null @@ -1,24 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Write the resources to the stream, - // and clean up all resources associated with the writer. - // Calling Dispose is equivalent to calling Close. - writer->~IResourceWriter(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp deleted file mode 100644 index ae4c0f1b512..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Resources.ResourceWriter.Generate Example/CPP/resourcewritergenerate.cpp +++ /dev/null @@ -1,25 +0,0 @@ - -// -using namespace System; -using namespace System::Resources; -using namespace System::IO; -int main() -{ - - // Create a file stream to encapsulate items.resources. - FileStream^ fs = gcnew FileStream( "items.resources",FileMode::OpenOrCreate,FileAccess::Write ); - - // Open a resource writer to write from the stream. - IResourceWriter^ writer = gcnew ResourceWriter( fs ); - - // Add resources to the resource writer. - writer->AddResource( "String 1", "First String" ); - writer->AddResource( "String 2", "Second String" ); - writer->AddResource( "String 3", "Third String" ); - - // Generate the resources, and close the writer. - writer->Generate(); - writer->Close(); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp deleted file mode 100644 index 08370f3519c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.AllowPartiallyTrustedCallersAttribute/CPP/AllowPartiallyTrustedCallersAttribute.cpp +++ /dev/null @@ -1,150 +0,0 @@ - -//#pragma comment(linker, "/CLRUNMANAGEDCODECHECK:NO") -// -// The following HTML code can be used to call the user control in this sample. -// -// -// -// -// -//

-// -// -// To run this test control you must create a strong name key, snkey.snk, and -// a code group that gives full trust to assemblies signed with snkey.snk. -// The user control displays an OpenFileDialog box, then displays a text box containing the name of -// the file selected and a list box that displays the contents of the file. The selected file must -// contain text in order for the control to display the data properly. -// Caution This sample demonstrates the use of the Assert method. Calling Assert removes the -// requirement that all code in the call chain must be granted permission to access the specified -// resource, it can open up security vulnerabilities if used incorrectly or inappropriately. Therefore, -// it should be used with great caution. Assert should always be followed with a RevertAssert -// command to restore the security settings. -#using -#using -#using -#using - -using namespace System; -using namespace System::Collections; -using namespace System::ComponentModel; -using namespace System::Drawing; -using namespace System::Data; -using namespace System::Windows::Forms; -using namespace System::IO; -using namespace System::Security; -using namespace System::Security::Permissions; -using namespace System::Reflection; -using namespace System::Runtime::CompilerServices; - -// This strong name key is used to create a code group that gives permissions to this assembly. -// The AllowPartiallyTrustedCallersAttribute requires the assembly to be signed with a strong name key. -// This attribute is necessary since the control is called by either an intranet or Internet -// Web page that should be running under restricted permissions. -// The userControl1 displays an OpenFileDialog box, then displays a text box containing the name of -// the file selected and a list box that displays the contents of the file. The selected file must -// contain text in order for the control to display the data properly. - -[assembly:AssemblyKeyFile("snKey.snk")]; -[assembly:AssemblyVersion("1.0.0.0")]; -[assembly:AllowPartiallyTrustedCallers]; -public ref class UserControl1: public System::Windows::Forms::UserControl -{ -private: - System::Windows::Forms::TextBox^ textBox1; - System::Windows::Forms::ListBox^ listBox1; - - // Required designer variable. - System::ComponentModel::Container^ components; - -public: -// Demand the zone requirement for the calling application. -[ZoneIdentityPermission(SecurityAction::Demand, Zone = SecurityZone::Intranet)] - UserControl1() - { - - // This call is required by the Windows.Forms Form Designer. - InitializeComponent(); - - // The OpenFileDialog box should not require any special permissions. - OpenFileDialog^ fileDialog = gcnew OpenFileDialog; - if ( fileDialog->ShowDialog() == DialogResult::OK ) - { - - // Reading the name of the selected file from the OpenFileDialog box - // and reading the file requires FileIOPermission. The user control should - // have this permission granted through its code group; the Web page that calls the - // control should not have this permission. The Assert command prevents a stack walk - // that would fail because the caller does not have the required FileIOPermission. - // The use of Assert can open up security vulnerabilities if used incorrectly or - // inappropriately. Therefore, it should be used with great caution. - // The Assert command should be followed by a RevertAssert as soon as the file operation - // is completed. - (gcnew FileIOPermission( PermissionState::Unrestricted ))->Assert(); - textBox1->Text = fileDialog->FileName; - - // Display the contents of the file in the text box. - FileStream^ fsIn = gcnew FileStream( textBox1->Text,FileMode::Open,FileAccess::Read,FileShare::Read ); - StreamReader^ sr = gcnew StreamReader( fsIn ); - - // Process every line in the file - for ( String ^ Line = sr->ReadLine(); Line != nullptr; Line = sr->ReadLine() ) - { - listBox1->Items->Add( Line ); - - } - - // file operations. - FileIOPermission::RevertAssert(); - } - } - -private: - - ///

- /// Required method for Designer support - do not modify - /// the contents of this method with the code editor. - /// - void InitializeComponent() - { - this->textBox1 = gcnew System::Windows::Forms::TextBox; - this->listBox1 = gcnew System::Windows::Forms::ListBox; - this->SuspendLayout(); - - // - // textBox1 - // - this->textBox1->Location = System::Drawing::Point( 208, 112 ); - this->textBox1->Name = "textBox1"; - this->textBox1->Size = System::Drawing::Size( 320, 20 ); - this->textBox1->TabIndex = 0; - this->textBox1->Text = "textBox1"; - this->textBox1->TextChanged += gcnew System::EventHandler( this,&UserControl1::textBox1_TextChanged ); - - // - // listBox1 - // - this->listBox1->Location = System::Drawing::Point( 200, 184 ); - this->listBox1->Name = "listBox1"; - this->listBox1->Size = System::Drawing::Size( 336, 108 ); - this->listBox1->TabIndex = 1; - - // - // UserControl1 - // - this->Controls->Add( this->listBox1 ); - this->Controls->Add( this->textBox1 ); - this->Name = "UserControl1"; - this->Size = System::Drawing::Size( 592, 400 ); - this->Load += gcnew System::EventHandler( this,&UserControl1::UserControl1_Load ); - this->ResumeLayout( false ); - } - - void UserControl1_Load( Object^ /*sender*/, System::EventArgs^ /*e*/ ){} - - void textBox1_TextChanged( Object^ /*sender*/, System::EventArgs^ /*e*/ ){} - -}; - -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp deleted file mode 100644 index 5a67133635d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcrypto.cpp +++ /dev/null @@ -1,320 +0,0 @@ -// This class creates a custom crytographic object based on the asymmetric -// algorithm by extending the abstract base class AsymmetricAlgorithm. -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Text; -using namespace System::Security::Cryptography; -using namespace System::Reflection; - -[assembly: AssemblyKeyFile("CustomCrypto.snk")]; -[assembly: AssemblyVersion("1.0.0.0")]; -[assembly: CLSCompliant(true)]; -namespace Contoso -{ - // Define a CustomCrypto class that inherits from the AsymmetricAlgorithm - // class. - public ref class CustomCrypto : - public System::Security::Cryptography::AsymmetricAlgorithm - { - // Declare local member variables. - private: - CspParameters^ cryptoServiceParameters; - array^ customValidKeySizes; - - // Initialize a CustomCrypto with the default key size of 8. - public: - CustomCrypto() - { - customValidKeySizes = - gcnew array{gcnew KeySizes(8, 64, 8)}; - this->KeySize = 8; - } - - // Initialize a CustomCrypto with the specified key size. - public: - CustomCrypto(int keySize) - { - customValidKeySizes = - gcnew array{gcnew KeySizes(8, 64, 8)}; - this->KeySize = keySize; - } - - // Accessor function for keySizes member variable. - public: - property array^ LegalKeySizes - { - virtual array^ get() override - { - return (array^)customValidKeySizes->Clone(); - } - } - - // Modify the KeySizeValue property inherited from the Asymmetric - // class. Prior to setting the value, ensure it falls within the - // range identified in the local keySizes member variable. - // - public: - property int KeySize - { - virtual int get() override - { - return KeySizeValue; - } - - virtual void set(int value) override - { - for (int i = 0; i < customValidKeySizes->Length; i++) - { - if (customValidKeySizes[i]->SkipSize == 0) - { - if (customValidKeySizes[i]->MinSize == value) - { - KeySizeValue = value; - return; - } - } - else - { - for (int j = customValidKeySizes[i]->MinSize; - j <= customValidKeySizes[i]->MaxSize; - j += customValidKeySizes[i]->SkipSize) - { - if (j == value) - { - KeySizeValue = value; - return; - } - } - } - } - - // If the key does not fall within the range identified - // in the keySizes member variable, throw an exception. - throw gcnew CryptographicException("Invalid key size."); - } - } - // - - // Initialize the parameters with default values. - public: - void InitializeParameters() - { - cryptoServiceParameters = gcnew CspParameters(); - cryptoServiceParameters->ProviderName = "Contoso"; - cryptoServiceParameters->KeyContainerName = "SecurityBin1"; - cryptoServiceParameters->KeyNumber = 1; - cryptoServiceParameters->ProviderType = 2; - } - - // Parse specified xmlString for values to populate the CspParams - // - // Expected XML schema: - // - // - // - // - // - // - public: - virtual void FromXmlString(String^ xmlString) override - { - if (xmlString != nullptr) - { - XmlDocument^ document = gcnew XmlDocument(); - document->LoadXml(xmlString); - XmlNode^ firstNode = document->FirstChild; - XmlNodeList^ nodeList; - - // Assemble parameters from values in each XML element. - cryptoServiceParameters = gcnew CspParameters(); - - // KeyContainerName is optional. - nodeList = - document->GetElementsByTagName("KeyContainerName"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->KeyContainerName = - nodeList->Item(0)->InnerText; - } - - // KeyNumber is optional. - nodeList = document->GetElementsByTagName("KeyNumber"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->KeyNumber = - Int32::Parse(nodeList->Item(0)->InnerText); - } - - // ProviderName is optional. - nodeList = document->GetElementsByTagName("ProviderName"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->ProviderName = - nodeList->Item(0)->InnerText; - } - - // ProviderType is optional. - nodeList = document->GetElementsByTagName("ProviderType"); - if (nodeList->Count > 0) - { - cryptoServiceParameters->ProviderType = - Int32::Parse(nodeList->Item(0)->InnerText); - } - } - else - { - throw gcnew ArgumentNullException("xmlString"); - } - } - // - - // Create an XML string representation of the parameters in the - // current customCrypto object. - // - public: - virtual String^ ToXmlString(bool includePrivateParameters) override - { - String^ keyContainerName = ""; - String^ keyNumber = ""; - String^ providerName = ""; - String^ providerType = ""; - - if (cryptoServiceParameters != nullptr) - { - keyContainerName = - cryptoServiceParameters->KeyContainerName; - keyNumber = cryptoServiceParameters->KeyNumber.ToString(); - providerName = cryptoServiceParameters->ProviderName; - providerType = - cryptoServiceParameters->ProviderType.ToString(); - } - - StringBuilder^ sb = gcnew StringBuilder(); - sb->Append(""); - - sb->Append(""); - sb->Append(keyContainerName); - sb->Append(""); - - sb->Append(""); - sb->Append(keyNumber); - sb->Append(""); - - sb->Append(""); - sb->Append(providerName); - sb->Append(""); - - sb->Append(""); - sb->Append(providerType); - sb->Append(""); - - sb->Append(""); - return(sb->ToString()); - } - // - - // Return the name for the key exchange algorithm. - // - public: - property String^ KeyExchangeAlgorithm - { - virtual String^ get() override - { - return "RSA-PKCS1-KeyEx"; - } - } - // - - // Retrieves the name of the signature alogrithm. - // - // This example uses the SHA1 algorithm. - // Due to collision problems with SHA1, Microsoft recommends SHA256 or better. - - public: - property String^ SignatureAlgorithm - { - virtual String^ get() override - { - return "http://www.w3.org/2000/09/xmldsig#rsa-sha1"; - } - } - // - - // Required member for implementing the AsymmetricAlgorithm class. - protected: - virtual ~CustomCrypto() - { - } - - // Call the Create method using the CustomCrypto assembly name. - // - // The create function attempts to create a CustomCrypto - // object using the assembly name. This functionality requires - // modification of the machine.config file. Add the following - // section to the configuration element and modify the values - // of the cryptoClass to reflect what isinstalled - // in your machines GAC. - // - // - // - // - // - // - // - // - // - // - // - - public: - static CustomCrypto^ Create() - { - return Create("CustomCrypto"); - } - // - - // Create a CustomCrypto object by calling CrytoConfig's - // CreateFromName method and casting the type to CustomCrypto. - // - // The create function attempts to create a CustomCrypto object - // using the assembly name. This functionality requires - // modification of the machine.config file. Add the following - // section to the configuration element and modify the values - // of the cryptoClass to reflect what is installed - // in your machines GAC. - // - // - // - // - // - // - // - // - // - // - // - - public: - static CustomCrypto^ Create(String^ algorithmName) - { - return (CustomCrypto^) - CryptoConfig::CreateFromName(algorithmName); - } - // - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp deleted file mode 100644 index 0de4308d5f7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.AsymmetricAlgorithm/cpp/customcryptoimpl.cpp +++ /dev/null @@ -1,129 +0,0 @@ - -// This sample demonstrates how to implement a custom asymmetric algorithm -// inherited from the AsymmetricAlgorithm base class. -// -#using -#using - -using namespace System; -using namespace System::Xml; -using namespace System::Text; -using namespace System::Security::Cryptography; - -// Display the properties of the specified CustomCrypto object to the -// console. -static void DisplayProperties(Contoso::CustomCrypto^ customCryptoAlgorithm) -{ - // Retrieve the class description for the customCrypto object. - // - String^ classDescription = customCryptoAlgorithm->ToString(); - // - - Console::WriteLine(classDescription); - Console::WriteLine("KeyExchangeAlgorithm: {0}", - customCryptoAlgorithm->KeyExchangeAlgorithm); - Console::WriteLine("SignatureAlgorithm: {0}", - customCryptoAlgorithm->SignatureAlgorithm); - Console::WriteLine("KeySize: {0}", - customCryptoAlgorithm->KeySize); - Console::WriteLine("Parameters described in Xml format:"); - Console::WriteLine(customCryptoAlgorithm->ToXmlString(true)); - - // Display the MinSize, MaxSize, and SkipSize properties of - // each KeySize item in the local keySizes member variable. - // - array^ legalKeySizes = customCryptoAlgorithm->LegalKeySizes; - for (int i = 0; i < legalKeySizes->Length; i++) - { - Console::WriteLine( - "Keysize{0} min, max, step: {1}, {2}, {3}, ", i, - legalKeySizes[i]->MinSize, - legalKeySizes[i]->MaxSize, - legalKeySizes[i]->SkipSize); - } - // -} - -[STAThread] -int main() -{ - // Construct a CustomCrypto object and initialize its - // CspParameters. - Contoso::CustomCrypto^ customCryptoAlgorithm = gcnew Contoso::CustomCrypto(); - customCryptoAlgorithm->InitializeParameters(); - - // Display properties of the current customCrypto object. - Console::WriteLine( - "*** CustomCrypto created with default parameters:"); - DisplayProperties(customCryptoAlgorithm); - - // Release all the resources used by this instance of - // CustomCrypto. - // - customCryptoAlgorithm->Clear(); - // - - customCryptoAlgorithm = gcnew Contoso::CustomCrypto(64); - // Create new parameters and set them by using the FromXmlString - // method. - String^ parameterXml = "" + - "Contoso" + - "SecurityBin2" + - "1" + - "2" + - ""; - customCryptoAlgorithm->FromXmlString(parameterXml); - - // Display the properties of a customCrypto object created with - // custom parameters. - Console::WriteLine( - "{0}*** CustomCrypto created with custom parameters:", Environment::NewLine); - DisplayProperties(customCryptoAlgorithm); - - // Create an object by using the assembly name. - Contoso::CustomCrypto^ cryptoFromAssembly = - Contoso::CustomCrypto::Create("CustomCrypto"); - if (cryptoFromAssembly != nullptr) - { - Console::WriteLine("{0}*** Successfully created " + - "CustomCrypto from the Create method.", Environment::NewLine); - DisplayProperties(cryptoFromAssembly); - } - else - { - Console::WriteLine("Unable to create CustomCrypto from " + - "the Create method."); - } - - Console::WriteLine( - "This sample completed successfully; press Enter to exit."); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// *** CustomCrypto created with default parameters: -// Contoso.vbCustomCrypto -// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx -// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1 -// KeySize: 8 -// Parameters described in Xml format: -// SecurityBin1 -// 1Contoso -// 2 -// Keysize0 min, max, step: 8, 64, 8, -// -// *** CustomCrypto created with custom parameters: -// Contoso.vbCustomCrypto -// KeyExchangeAlgorithm: RSA-PKCS1-KeyEx -// SignatureAlgorithm: http://www.w3.org/2000/09/xmldsig#rsa-sha1 -// KeySize: 64 -// Parameters described in Xml format: -// SecurityBin2 -// 1Contoso -// 2 -// Keysize0 min, max, step: 8, 64, 8, -// Unable to create CustomCrypto from the Create method -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp deleted file mode 100644 index 49ba079bd65..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptoConfig/CPP/members.cpp +++ /dev/null @@ -1,71 +0,0 @@ -// This sample demonstrates how to use each member of the CryptoConfig class. -// -using namespace System; -using namespace System::Security::Cryptography; - -int main() -{ - // Create a CryptoConfig object to store configuration information. - // - CryptoConfig^ cryptoConfig = gcnew CryptoConfig; - // - - // Retrieve the class path for CryptoConfig. - // - String^ classDescription = cryptoConfig->ToString(); - // - - // Create a new SHA1 provider. - // - SHA1CryptoServiceProvider^ SHA1alg = - dynamic_cast( - CryptoConfig::CreateFromName( L"SHA1" )); - // - - // Create an RSAParameters with the TestContainer key container. - // - CspParameters^ parameters = gcnew CspParameters; - parameters->KeyContainerName = L"TestContainer"; - array^argsArray = gcnew array(1){ - parameters - }; - - // Instantiate the RSA provider instance accessing the TestContainer - // key container. - RSACryptoServiceProvider^ rsaProvider = - static_cast( - CryptoConfig::CreateFromName( L"RSA", argsArray )); - // - - // Use the MapNameToOID method to get an object identifier - // (OID) from the string name of the SHA1 algorithm. - // - String^ sha1Oid = CryptoConfig::MapNameToOID( L"SHA1" ); - // - - // Encode the specified object identifier. - // - array^encodedMessage = CryptoConfig::EncodeOID( sha1Oid ); - - // - // Display the results to the console. - Console::WriteLine( L"** {0} **", classDescription ); - Console::WriteLine( L"Created an RSA provider with a KeyContainerName called {0}.", - parameters->KeyContainerName ); - Console::WriteLine( L"Object identifier from the SHA1 name:{0}", - sha1Oid ); - Console::WriteLine( L"The object identifier encoded: {0}", - System::Text::Encoding::ASCII->GetString( encodedMessage ) ); - Console::WriteLine( L"This sample completed successfully; press Enter to exit." ); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// ** System.Security.Cryptography.CryptoConfig ** -// Created an RSA provider with a KeyContainerName called TestContainer. -// Object identifier from the SHA1 name:1.3.14.3.2.26 -// The object identifier encoded: HH*((*H9 -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp deleted file mode 100644 index fc83f952401..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.CryptographicException/CPP/cryptographicexceptionmembers.cpp +++ /dev/null @@ -1,243 +0,0 @@ -// This sample demonstrates how to use each member of the -// CryptographicException class. -// -using namespace System; -using namespace System::Text; -using namespace System::Security::Cryptography; -using namespace System::Runtime::Serialization; - -ref class CryptographicExceptionMembers -{ -public: - - static void Run() - { - CryptographicExceptionMembers^ testRun = gcnew CryptographicExceptionMembers; - testRun->TestConstructors(); - testRun->ShowProperties(); - Console::WriteLine( L"This sample ended successfully; " - L" press Enter to exit." ); - Console::ReadLine(); - } - -private: - // Test each public implementation of the CryptographicException - // constructors. - void TestConstructors() - { - EmptyConstructor(); - IntConstructor(); - StringConstructor(); - StringExceptionConstructor(); - StringStringConstructor(); - } - - void EmptyConstructor() - { - // Construct a CryptographicException with no parameters. - // - CryptographicException^ cryptographicException = gcnew CryptographicException; - - // - Console::WriteLine( L"Created an empty CryptographicException." ); - } - - void IntConstructor() - { - // Construct a CryptographicException using the error code for an - // unexpected operation exception. - // - int exceptionNumber = (int)0x80131431; - CryptographicException^ cryptographicException = gcnew CryptographicException( exceptionNumber ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error code: {0}", exceptionNumber ); - } - - void StringConstructor() - { - // Construct a CryptographicException using a custom error message. - // - String^ errorMessage = (L"Unexpected Operation exception."); - CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error message: {0}", errorMessage ); - } - - void StringExceptionConstructor() - { - // Construct a CryptographicException using a custom error message - // and an inner exception. - // - String^ errorMessage = (L"The current operation is not supported."); - NullReferenceException^ nullException = gcnew NullReferenceException; - CryptographicException^ cryptographicException = gcnew CryptographicException( errorMessage,nullException ); - // - - Console::WriteLine( L"Created a CryptographicException with the " - L"following error message: {0} and the inner exception of {1}", errorMessage, nullException ); - } - - void StringStringConstructor() - { - // Create a CryptographicException using a time format and a the - // current date. - // - String^ dateFormat = L"{0:t}"; - String^ timeStamp = (DateTime::Now.ToString()); - CryptographicException^ cryptographicException = gcnew CryptographicException( dateFormat,timeStamp ); - // - - Console::WriteLine( L"Created a CryptographicException with ({0}) as the format and ({1}) as the message.", dateFormat, timeStamp ); - } - - // Construct an invalid DSACryptoServiceProvider to throw a - // CryptographicException for introspection. - void ShowProperties() - { - try - { - // Create a DSACryptoServiceProvider with invalid provider type - // code to throw a CryptographicException exception. - CspParameters^ cspParams = gcnew CspParameters( 44 ); - DSACryptoServiceProvider^ DSAalg = gcnew DSACryptoServiceProvider( cspParams ); - } - catch ( CryptographicException^ ex ) - { - // Retrieve the link to the help file for the exception. - // - String^ helpLink = ex->HelpLink; - // - - // Retrieve the exception that caused the current - // CryptographicException exception. - // - System::Exception^ innerException = ex->InnerException; - // - - String^ innerExceptionMessage = L""; - if ( innerException != nullptr ) - { - innerExceptionMessage = innerException->ToString(); - } - - // Retrieve the message that describes the exception. - // - String^ message = ex->Message; - // - - // Retrieve the name of the application that caused the exception. - // - String^ exceptionSource = ex->Source; - // - - // Retrieve the call stack at the time the exception occurred. - // - String^ stackTrace = ex->StackTrace; - // - - // Retrieve the method that threw the exception. - // - System::Reflection::MethodBase^ targetSite = ex->TargetSite; - // - - String^ siteName = targetSite->Name; - - // Retrieve the entire exception as a single string. - // - String^ entireException = ex->ToString(); - // - - // GetObjectData - setSerializationInfo( &ex ); - - // Get the root exception that caused the current - // CryptographicException exception. - // - System::Exception^ baseException = ex->GetBaseException(); - // - - String^ baseExceptionMessage = L""; - if ( baseException != nullptr ) - { - baseExceptionMessage = baseException->Message; - } - Console::WriteLine( L"Caught an expected exception:" ); - Console::WriteLine( entireException ); - Console::WriteLine( L"\n" ); - Console::WriteLine( L"Properties of the exception are as follows:" ); - Console::WriteLine( L"Message: {0}", message ); - Console::WriteLine( L"Source: {0}", exceptionSource ); - Console::WriteLine( L"Stack trace: {0}", stackTrace ); - Console::WriteLine( L"Help link: {0}", helpLink ); - Console::WriteLine( L"Target site's name: {0}", siteName ); - Console::WriteLine( L"Base exception message: {0}", baseExceptionMessage ); - Console::WriteLine( L"Inner exception message: {0}", innerExceptionMessage ); - } - - } - - void setSerializationInfo( interior_ptr ex ) - { - // Insert information about the exception into a serialized object. - // - FormatterConverter^ formatConverter = gcnew FormatterConverter; - SerializationInfo^ serializationInfo = gcnew SerializationInfo( ( *ex)->GetType(),formatConverter ); - StreamingContext streamingContext = StreamingContext(StreamingContextStates::All); - ( *ex)->GetObjectData( serializationInfo, streamingContext ); - // - } - -}; - -void main() -{ - CryptographicExceptionMembers::Run(); -} - -// -// This sample produces the following output: -// -// Created an empty CryptographicException. -// Created a CryptographicException with the following error code: -2146233295 -// Created a CryptographicException with the following error message: -// Unexpected Operation exception. -// Created a CryptographicException with the following error message: The -// current operation is not supported. and the inner exception of -// System.NullReferenceException: Object reference not set to an instance of -// an object. -// Created a CryptographicException with ({0:t}) as the format and (2/24/2004 -// 2:13:15 PM) as the message. -// Caught an expected exception: -// System.Security.Cryptography.CryptographicException: CryptoAPI -// cryptographic service provider (CSP) for this implementation could not be -// acquired. -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor(Int32 -// dwKeySize, CspParameters parameters) -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// CspParametersparameters) -// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\ -// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109 -// -// -// Properties of the exception are as follows: -// Message: CryptoAPI cryptographic service provider (CSP) for this -// implementation could not be acquired. -// Source: mscorlib -// Stack trace: -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// Int32 dwKeySize, CspParameters parameters) -// at System.Security.Cryptography.DSACryptoServiceProvider..ctor( -// CspParameters parameters) -// at CryptographicExceptionMembers.ShowProperties() in c:\inetpub\ -// vssolutions\test\testbuild\consoleapplication1\class1.cs:line 109 -// Help link: -// Target site's name: .ctor -// Base exception message: CryptoAPI cryptographic service provider (CSP) for -// this implementation could not be acquired. -// Inner exception message: -// This sample ended successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp deleted file mode 100644 index 463fd5703f5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureDeformatter/CPP/sample.cpp +++ /dev/null @@ -1,50 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //Create a new instance of DSA. - DSA^ DSA = DSA::Create(); - - //The hash to sign. - array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135}; - - //Create an DSASignatureFormatter object and pass it the - //DSA instance to transfer the key information. - DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA ); - - //Set the hash algorithm to SHA1. - DSAFormatter->SetHashAlgorithm( "SHA1" ); - - //Create a signature for HashValue and return it. - array^SignedHash = DSAFormatter->CreateSignature( Hash ); - - //Create an DSASignatureDeformatter object and pass it the - //DSA instance to transfer the key information. - DSASignatureDeformatter^ DSADeformatter = gcnew DSASignatureDeformatter( DSA ); - - //Verify the hash and display the results to the console. - if ( DSADeformatter->VerifySignature( Hash, SignedHash ) ) - { - Console::WriteLine( "The signature was verified." ); - } - else - { - Console::WriteLine( "The signature was not verified." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp deleted file mode 100644 index bc448969175..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.DSASignatureFormatter/CPP/sample.cpp +++ /dev/null @@ -1,36 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //Create a new instance of DSA. - DSA^ DSA = DSA::Create(); - - //The hash to sign. - array^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197,213,134,130,135}; - - //Create an DSASignatureFormatter Object* and pass it the - //DSA instance to transfer the key information. - DSASignatureFormatter^ DSAFormatter = gcnew DSASignatureFormatter( DSA ); - - //Set the hash algorithm to SHA1. - DSAFormatter->SetHashAlgorithm( "SHA1" ); - - //Create a signature for HashValue and return it. - array^SignedHash = DSAFormatter->CreateSignature( Hash ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp deleted file mode 100644 index 2d3ec8ddc55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.FromBase64Transform Example/CPP/class1.cpp +++ /dev/null @@ -1,56 +0,0 @@ - -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; -class MyMainClass -{ -public: - static void DecodeFromFile( String^ inFileName, String^ outFileName ) - { - FromBase64Transform^ myTransform = gcnew FromBase64Transform( FromBase64TransformMode::IgnoreWhiteSpaces ); - array^myOutputBytes = gcnew array(myTransform->OutputBlockSize); - - //Open the input and output files. - FileStream^ myInputFile = gcnew FileStream( inFileName,FileMode::Open,FileAccess::Read ); - FileStream^ myOutputFile = gcnew FileStream( outFileName,FileMode::Create,FileAccess::Write ); - - //Retrieve the file contents into a Byte array. - array^myInputBytes = gcnew array(myInputFile->Length); - myInputFile->Read( myInputBytes, 0, myInputBytes->Length ); - - //Transform the data in chunks the size of InputBlockSize. - int i = 0; - while ( myInputBytes->Length - i > 4 ) - { - myTransform->TransformBlock( myInputBytes, i, 4, myOutputBytes, 0 ); - - /*myTransform->InputBlockSize*/ - i += 4; - - /*myTransform->InputBlockSize*/ - myOutputFile->Write( myOutputBytes, 0, myTransform->OutputBlockSize ); - } - - - //Transform the final block of data. - myOutputBytes = myTransform->TransformFinalBlock( myInputBytes, i, myInputBytes->Length - i ); - myOutputFile->Write( myOutputBytes, 0, myOutputBytes->Length ); - - //Free up any used resources. - myTransform->Clear(); - myInputFile->Close(); - myOutputFile->Close(); - } - -}; - -int main() -{ - MyMainClass * m = new MyMainClass; - - //Insert your file names into this method call. - m->DecodeFromFile( "c:\\encoded.txt", "c:\\roundtrip.txt" ); -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp deleted file mode 100644 index 7ac5fae23ff..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeySizes/CPP/members.cpp +++ /dev/null @@ -1,110 +0,0 @@ -// This sample demonstrates how to use each member of the KeySizes class. -// - -using namespace System; -using namespace System::Security::Cryptography; - -namespace CryptographySample -{ - ref class KeySizesMembers - { - public: - static void Work() - { - // Initializes a new instance of the KeySizes class - // with the specified key values. - // - int minSize = 64; - int maxSize = 1024; - int skipSize = 64; - KeySizes^ keySizes = - gcnew KeySizes(minSize, maxSize, skipSize); - // - - // Show the values of the keys. - ShowKeys(gcnew array(1) {keySizes}, - "Custom Keys"); - - // Create a new symmetric algorithm and display its - // key values. - Aes^ aes = Aes::Create(); - ShowKeys(aes->LegalKeySizes, aes->ToString()); - Console::WriteLine("aes.blocksize:{0}", - aes->BlockSize); - - // Create a new RSA algorithm and display its key values. - RSA^ rsa = RSA::Create(); - ShowKeys(rsa->LegalKeySizes, rsa->ToString()); - Console::WriteLine("RSA KeySize =" - " {0}", - rsa->KeySize); - - Console::WriteLine("This sample completed successfully; " - "press Enter to exit."); - Console::ReadLine(); - } - - private: - // Display specified KeySize properties to the console. - static void ShowKeys(array ^ keySizes, - String^ objectName) - { - // Retrieve the first KeySizes in the array. - KeySizes^ firstKeySize = keySizes[0]; - - // Retrieve the minimum key size in bits. - // - int minKeySize = firstKeySize->MinSize; - // - - // Retrieve the maximum key size in bits. - // - int maxKeySize = firstKeySize->MaxSize; - // - - // Retrieve the interval between valid key size in bits. - // - int skipKeySize = firstKeySize->SkipSize; - // - - Console::Write("\n KeySizes retrieved from the "); - Console::WriteLine("{0} object.", objectName); - Console::WriteLine("Minimum key size bits: {0}", - minKeySize); - Console::WriteLine("Maximum key size bits: {0}", - maxKeySize); - Console::WriteLine("Interval between key size bits: {0}", - skipKeySize); - } - }; -} - -using namespace CryptographySample; - -int main() -{ - KeySizesMembers::Work(); -} -// -// This sample produces the following output: -// -// KeySizes retrieved from the Custom Keys object. -// Minimum key size bits: 64 -// Maximum key size bits: 1024 -// Interval between key size bits: 64 -// -// KeySizes retrieved from the -// System.Security.Cryptography.Aes object. -// Minimum key size bits: 128 -// Maximum key size bits: 256 -// Interval between key size bits: 64 -// aes.blocksize:128 -// -// KeySizes retrieved from the -// System.Security.Cryptography.RSA object. -// Minimum key size bits: 512 -// Maximum key size bits: 16384 -// Interval between key size bits: 64 -// RSA KeySize = 2048 -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp deleted file mode 100644 index d25c4d73ac5..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.KeyedHashAlgorithm/CPP/contosokeyedhash.cpp +++ /dev/null @@ -1,80 +0,0 @@ -// This sample demonstrates how to extend the KeyedHashAlgorithm class. -// -using namespace System; -using namespace System::Security::Cryptography; - -namespace Contoso -{ - public ref class ContosoKeyedHash: public KeyedHashAlgorithm - { - private: - KeyedHashAlgorithm^ keyedCrypto; - - public: - ContosoKeyedHash( array^ rgbKey ) - { - Init( L"System.Security.Cryptography.KeyedHashAlgorithm", rgbKey ); - } - - ContosoKeyedHash( String^ keyedHashName, array^ rgbKey ) - { - Init( keyedHashName, rgbKey ); - } - - void Init( String^ keyedHashName, array^ rgbKey ) - { - // Make sure we know which algorithm to use - if ( rgbKey != nullptr ) - { - KeyValue = rgbKey; - HashSizeValue = 160; - - // Create a KeyedHashAlgorithm encryptor - if ( keyedHashName == nullptr ) - { - - // - keyedCrypto = KeyedHashAlgorithm::Create(); - // - } - else - { - // - keyedCrypto = KeyedHashAlgorithm::Create( keyedHashName ); - // - } - } - else - { - throw gcnew ArgumentNullException( L"rgbKey" ); - } - } - - // Override abstract methods from the HashAlgorithm class. - virtual void Initialize() override {} - - property array^ Key - { - // - virtual array^ get() override - { - return dynamic_cast^>(keyedCrypto->Key->Clone()); - } - - virtual void set( array^value ) override - { - keyedCrypto->Key = dynamic_cast^>(value->Clone()); - } - } - // - - protected: - virtual void HashCore( array^ , int /*ibStart*/, int /*cbSize*/ ) override {} - - virtual array^ HashFinal() override - { - return gcnew array(0); - } - }; -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp deleted file mode 100644 index 3c77ea0c947..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.MaskGenerationMethod/CPP/maskgenerator.cpp +++ /dev/null @@ -1,114 +0,0 @@ -// This sample demonstrates how to derive from -// the MaskGenerationMethod class. -// -#using - -using namespace System; -using namespace System::Security::Cryptography; - -namespace Contoso -{ - // - ref class MaskGenerator: MaskGenerationMethod - { - private: - String^ hashNameValue; - - public: - // Initialize a mask to encrypt using the SHA256 algorithm. - MaskGenerator() - { - hashNameValue = "SHA256"; - } - - // - // Create a mask with the specified seed. - // - virtual array^ GenerateMask(array^ seed, int maskLength) override - { - HashAlgorithm^ hash; - array^ rgbCounter = gcnew array(4); - array^ targetRgb = gcnew array(maskLength); - UInt32 counter = 0; - for (int inc = 0; inc < targetRgb->Length; ) - { - ConvertIntToByteArray(counter++, rgbCounter); - hash = (HashAlgorithm^)CryptoConfig::CreateFromName( - hashNameValue); - array^ temp = gcnew array( - 4 + seed->Length); - Buffer::BlockCopy(rgbCounter, 0, temp, 0, 4); - Buffer::BlockCopy(seed, 0, temp, 4, seed->Length); - hash->ComputeHash(temp); - if (targetRgb->Length - inc > hash->HashSize / 8) - { - Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc, - hash->Hash->Length); - } - else - { - Buffer::BlockCopy(hash->Hash, 0, targetRgb, inc, - targetRgb->Length - inc); - } - - inc += hash->Hash->Length; - } - return targetRgb; - } - - private: - // - // Convert the specified integer to the byte array. - void ConvertIntToByteArray(UInt32 source, - array^ targetBytes) - { - UInt32 remainder; - int inc = 0; - - // Clear the array prior to filling it. - Array::Clear(targetBytes, 0, targetBytes->Length); - while (source > 0) - { - remainder = source % 256; - targetBytes[ 3 - inc ] = (Byte)remainder; - source = (source - remainder) / 256; - inc++; - } - } - }; - - // This class demonstrates how to create the MaskGenerator class - // and call its GenerateMask member. - ref class MaskGeneratorImpl - { - public: - void static Work() - { - array^ seed = gcnew array(4){ - 0x01,0x02,0x03,0x04}; - int length = 16; - MaskGenerator^ maskGenerator = gcnew MaskGenerator; - array^ mask = maskGenerator->GenerateMask(seed, - length); - Console::WriteLine("Generated the following mask:"); - Console::WriteLine(System::Text::Encoding:: - ASCII::get()->GetString(mask)); - Console::WriteLine("This sample completed successfully;" - " press Enter to exit."); - Console::ReadLine(); - } - }; -} - -void main() -{ - Contoso::MaskGeneratorImpl::Work(); -} - -// -// This sample produces the following output: -// -// Generated the following mask: -// ?"TFd(?~OtO? -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp deleted file mode 100644 index 18a61d351be..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.Encrypt/CPP/sample.cpp +++ /dev/null @@ -1,52 +0,0 @@ - - -// -#using - -using namespace System; -using namespace System::Security::Cryptography; -int main() -{ - try - { - - //initialze the Byte arrays to the public key information. - array^PublicKey = {214,46,220,83,160,73,40,39,201,155,19,202,3,11,191,178,56,74,90,36,248,103,18,144,170,163,145,87,54,61,34,220,222,207,137,149,173,14,92,120,206,222,158,28,40,24,30,16,175,108,128,35,230,118,40,121,113,125,216,130,11,24,90,48,194,240,105,44,76,34,57,249,228,125,80,38,9,136,29,117,207,139,168,181,85,137,126,10,126,242,120,247,121,8,100,12,201,171,38,226,193,180,190,117,177,87,143,242,213,11,44,180,113,93,106,99,179,68,175,211,164,116,64,148,226,254,172,147}; - array^Exponent = {1,0,1}; - - //Values to store encrypted symmetric keys. - array^EncryptedSymmetricKey; - array^EncryptedSymmetricIV; - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Create a new instance of RSAParameters. - RSAParameters RSAKeyInfo; - - //Set RSAKeyInfo to the public key values. - RSAKeyInfo.Modulus = PublicKey; - RSAKeyInfo.Exponent = Exponent; - - //Import key parameters into RSA. - RSA->ImportParameters( RSAKeyInfo ); - - //Create a new instance of the Aes class. - Aes^ aes = Aes::Create(); - - //Encrypt the symmetric key and IV. - EncryptedSymmetricKey = RSA->Encrypt( aes->Key, false ); - EncryptedSymmetricIV = RSA->Encrypt( aes->IV, false ); - Console::WriteLine( "Aes Key and IV have been encrypted with RSACryptoServiceProvider." ); - } - catch ( CryptographicException^ e ) - { - - //Catch and display a CryptographicException - //to the console. - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp deleted file mode 100644 index 92218fec226..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ExportParameters/CPP/sample.cpp +++ /dev/null @@ -1,25 +0,0 @@ -#using - -using namespace System; -using namespace System::Security::Cryptography; -void main() -{ - // - try - { - //Create a new RSACryptoServiceProvider Object*. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Export the key information to an RSAParameters object. - //Pass false to export the public key information or pass - //true to export public and private key information. - RSAParameters RSAParams = RSA->ExportParameters( false ); - } - catch ( CryptographicException^ e ) - { - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp deleted file mode 100644 index a5bf383b029..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider.ImportParameters/CPP/sample.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#using - -using namespace System; -using namespace System::Security::Cryptography; - -int main() -{ - // - try - { - //Create a new RSACryptoServiceProvider object. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Export the key information to an RSAParameters object. - //Pass false to export the public key information or pass - //true to export public and private key information. - RSAParameters RSAParams = RSA->ExportParameters( false ); - - //Create another RSACryptoServiceProvider object. - RSACryptoServiceProvider^ RSA2 = gcnew RSACryptoServiceProvider; - - //Import the key information from the other - //RSACryptoServiceProvider object. - RSA2->ImportParameters( RSAParams ); - } - catch ( CryptographicException^ e ) - { - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( e->Message ); - } - // -} diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp deleted file mode 100644 index 9f6ac45281c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSACryptoServiceProvider/CPP/sample.cpp +++ /dev/null @@ -1,106 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; -array^ RSAEncrypt( array^DataToEncrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This only needs - //toinclude the public key information. - RSA->ImportParameters( RSAKeyInfo ); - - //Encrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - - array^encryptedData = RSA->Encrypt( DataToEncrypt, DoOAEPPadding ); - delete RSA; - return encryptedData; - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - return nullptr; - } - -} - -array^ RSADecrypt( array^DataToDecrypt, RSAParameters RSAKeyInfo, bool DoOAEPPadding ) -{ - try - { - - //Create a new instance of RSACryptoServiceProvider. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Import the RSA Key information. This needs - //to include the private key information. - RSA->ImportParameters( RSAKeyInfo ); - - //Decrypt the passed byte array and specify OAEP padding. - //OAEP padding is only available on Microsoft Windows XP or - //later. - - array^decryptedData = RSA->Decrypt( DataToDecrypt, DoOAEPPadding ); - delete RSA; - return decryptedData; - } - //Catch and display a CryptographicException - //to the console. - catch ( CryptographicException^ e ) - { - Console::WriteLine( e ); - return nullptr; - } - -} - -int main() -{ - try - { - - //Create a UnicodeEncoder to convert between byte array and string. - UnicodeEncoding^ ByteConverter = gcnew UnicodeEncoding; - - //Create byte arrays to hold original, encrypted, and decrypted data. - array^dataToEncrypt = ByteConverter->GetBytes( "Data to Encrypt" ); - array^encryptedData; - array^decryptedData; - - //Create a new instance of RSACryptoServiceProvider to generate - //public and private key data. - RSACryptoServiceProvider^ RSA = gcnew RSACryptoServiceProvider; - - //Pass the data to ENCRYPT, the public key information - //(using RSACryptoServiceProvider.ExportParameters(false), - //and a boolean flag specifying no OAEP padding. - encryptedData = RSAEncrypt( dataToEncrypt, RSA->ExportParameters( false ), false ); - - //Pass the data to DECRYPT, the private key information - //(using RSACryptoServiceProvider.ExportParameters(true), - //and a boolean flag specifying no OAEP padding. - decryptedData = RSADecrypt( encryptedData, RSA->ExportParameters( true ), false ); - - //Display the decrypted plaintext to the console. - Console::WriteLine( "Decrypted plaintext: {0}", ByteConverter->GetString( decryptedData ) ); - delete RSA; - } - catch ( ArgumentNullException^ ) - { - - //Catch this exception in case the encryption did - //not succeed. - Console::WriteLine( "Encryption failed." ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp deleted file mode 100644 index cb8ce0d69c9..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.RSAOAEPKeyExchangeDeformatter/CPP/rsaencoder.cpp +++ /dev/null @@ -1,213 +0,0 @@ -// This sample demonstrates how to encode and decode a string using -// the RSAOAEPKeyExchangeFormatter and RSAOAEPKeyExchangeDeformatter classes. -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -ref class RSAEncoder -{ -private: - // Use a member variable to hold the RSA key for encoding and decoding. - RSA^ rsaKey; - -public: - [STAThread] - static void Main() - { - String^ message = L"A phrase to be encoded."; - RSAEncoder^ rsaEncoder = gcnew RSAEncoder; - rsaEncoder->InitializeKey( RSA::Create() ); - Console::WriteLine( L"Encoding the following message:" ); - Console::WriteLine( message ); - array^encodedMessage = rsaEncoder->EncodeMessage( message ); - Console::WriteLine( L"Resulting message encoded:" ); - Console::WriteLine( Encoding::ASCII->GetString( encodedMessage ) ); - String^ decodedMessage = rsaEncoder->DecodeMessage( encodedMessage ); - Console::WriteLine( L"Resulting message decoded:" ); - Console::WriteLine( decodedMessage ); - - // Construct a formatter to demonstrate how to set each property. - rsaEncoder->ConstructFormatter(); - - // Construct a deformatter to demonstrate how to set each property. - rsaEncoder->ConstructDeformatter(); - Console::WriteLine( L"This sample completed successfully, " - L" press enter to continue." ); - Console::ReadLine(); - } - - -private: - // Initialize an rsaKey member variable with the specified RSA key. - void InitializeKey( RSA^ key ) - { - rsaKey = key; - } - - // Use the RSAOAEPKeyExchangeDeformatter class to decode the - // specified message. - array^ EncodeMessage( String^ message ) - { - array^encodedMessage = nullptr; - try - { - - // Construct a formatter with the specified RSA key. - // - RSAOAEPKeyExchangeFormatter^ keyEncryptor = - gcnew RSAOAEPKeyExchangeFormatter( rsaKey ); - // - - // Convert the message to bytes to create the encrypted data. - // - array^byteMessage = Encoding::ASCII->GetBytes( message ); - encodedMessage = keyEncryptor->CreateKeyExchange( byteMessage ); - // - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught:{0}", ex ); - } - - return encodedMessage; - } - - // Use the RSAOAEPKeyExchangeDeformatter class to decode the - // specified message. - String^ DecodeMessage( array^encodedMessage ) - { - String^ decodedMessage = nullptr; - try - { - // Construct a deformatter with the specified RSA key. - // - RSAOAEPKeyExchangeDeformatter^ keyDecryptor = - gcnew RSAOAEPKeyExchangeDeformatter( rsaKey ); - // - - // Decrypt the encoded message. - // - array^decodedBytes = keyDecryptor->DecryptKeyExchange( encodedMessage ); - // - - // Retrieve a string representation of the decoded message. - decodedMessage = Encoding::ASCII->GetString( decodedBytes ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught:{0}", ex ); - } - - return decodedMessage; - } - - - // Create an RSAOAEPKeyExchangeFormatter object with a new RSA key. - // Display its properties to the console. - void ConstructFormatter() - { - // Construct an empty Optimal Asymmetric Encryption Padding (OAEP) - // key exchange. - // - RSAOAEPKeyExchangeFormatter^ rsaFormatter = gcnew RSAOAEPKeyExchangeFormatter; - // - - // Create an RSA and set it into the specified - // RSAOAEPKeyExchangeFormatter. - // - RSA^ key = RSA::Create(); - rsaFormatter->SetKey( key ); - // - - // Create a random number using the RNGCryptoServiceProvider provider. - // - RandomNumberGenerator^ ring = RandomNumberGenerator::Create(); - rsaFormatter->Rng = ring; - // - - // Export InverseQ and set it into the RSAOAEPKeyExchangeFormatter. - // - rsaFormatter->Parameter = key->ExportParameters( true ).InverseQ; - // - - Console::WriteLine(); - Console::WriteLine( L"**{0}**", rsaFormatter ); - Console::Write( L"The following random number was generated using the " ); - Console::WriteLine( L"class:" ); - Console::WriteLine( rsaFormatter->Rng ); - Console::WriteLine(); - Console::Write( L"The RSA formatter contains the following InverseQ" ); - Console::WriteLine( L" parameter:" ); - Console::WriteLine( Encoding::ASCII->GetString( rsaFormatter->Parameter ) ); - Console::WriteLine(); - - // - String^ xmlParameters = rsaFormatter->Parameters; - // - - Console::WriteLine( L"The RSA formatter has the following parameters:" ); - Console::WriteLine( xmlParameters ); - } - - // Create an RSAOAEPKeyExchangeDeformatter object with a new RSA key. - // Display its properties to the console. - void ConstructDeformatter() - { - // Construct an empty OAEP key exchange. - // - RSAOAEPKeyExchangeDeformatter^ rsaDeformatter = - gcnew RSAOAEPKeyExchangeDeformatter; - // - - // Create an RSAKey and set it into the specified - // RSAOAEPKeyExchangeFormatter. - // - RSA^ key = RSA::Create(); - rsaDeformatter->SetKey( key ); - // - - Console::WriteLine(); - Console::WriteLine( L"**{0}**", rsaDeformatter ); - - // - String^ xmlParameters = rsaDeformatter->Parameters; - // - - Console::WriteLine(); - Console::WriteLine( L"The RSA deformatter has the following " ); - Console::WriteLine( L"parameters:{0}", xmlParameters ); - } -}; - -int main() -{ - RSAEncoder::Main(); -} - -// -// This sample produces the following output: -// -// Encoding the following message: -// A phrase to be encoded. -// Resulting message encoded: %?}T:v??xu?eD)YucItjwu¦ALH HB,Uj??2xq?.?s45 -// ?f?L2?=X?CPzWx???"q5?6&N"AE,Z+T?(]S?_7~,?G{?VV!:S?df? -// Resulting message decoded: -// A phrase to be encoded. -// -// **System.Security.Cryptography.RSAOAEPKeyExchangeFormatter** -// The following random number was generated using the class: -// System.Security.Cryptography.RNGCryptoServiceProvider -// -// The RSA formatter contains the following InverseQ parameter: -// 3MM??]D#?mBq_;:ws^1?ko??,_ ??A[hyWcP$?`v.>@?^!dU%\?H0N'??Ca?Ns -// -// The RSA formatter has the following parameters: -// -// -// **System.Security.Cryptography.RSAOAEPKeyExchangeDeformatter** -// -// The RSA deformatter has the following -// parameters: -// This sample completed successfully, press enter to continue. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp deleted file mode 100644 index 1cf5a6c9d9b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.ToBase64Transform/CPP/members.cpp +++ /dev/null @@ -1,129 +0,0 @@ -// This sample demonstrates how to use each member of the ToBase64Transform -// class. The file named members.cs is read in and written out as a -// transformed file named members.enc. -// -using namespace System; -using namespace System::IO; -using namespace System::Security::Cryptography; - -ref class Members -{ -public: - [STAThread] - static void Main() - { - String^ appPath = (String::Concat( - System::IO::Directory::GetCurrentDirectory(), L"\\" )); - - // Insert your file names into this method call. - EncodeFromFile( String::Concat( appPath, L"members.cpp" ), - String::Concat( appPath, L"members.enc" ) ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - // Read in the specified source file and write out an encoded target file. - static void EncodeFromFile( String^ sourceFile, String^ targetFile ) - { - // Verify members.cpp exists at the specified directory. - if ( !File::Exists( sourceFile ) ) - { - Console::Write( L"Unable to locate source file located at " ); - Console::WriteLine( L"{0}.", sourceFile ); - Console::Write( L"Please correct the path and run the " ); - Console::WriteLine( L"sample again." ); - return; - } - - // Retrieve the input and output file streams. - FileStream^ inputFileStream = gcnew FileStream( - sourceFile,FileMode::Open,FileAccess::Read ); - FileStream^ outputFileStream = gcnew FileStream( - targetFile,FileMode::Create,FileAccess::Write ); - - // Create a new ToBase64Transform object to convert to base 64. - // - ToBase64Transform^ base64Transform = gcnew ToBase64Transform; - // - - // Create a new byte array with the size of the output block size. - // - array^outputBytes = gcnew array( - base64Transform->OutputBlockSize); - // - - // Retrieve the file contents into a byte array. - array^inputBytes = gcnew array(inputFileStream->Length); - inputFileStream->Read( inputBytes, 0, inputBytes->Length ); - - // Verify that multiple blocks can not be transformed. - // - if ( !base64Transform->CanTransformMultipleBlocks ) - // - { - // Initializie the offset size. - int inputOffset = 0; - - // Iterate through inputBytes transforming by blockSize. - // - // - int inputBlockSize = base64Transform->InputBlockSize; - // - while ( inputBytes->Length - inputOffset > inputBlockSize ) - { - base64Transform->TransformBlock( - inputBytes, - inputOffset, - inputBytes->Length - inputOffset, - outputBytes, - 0 ); - - inputOffset += base64Transform->InputBlockSize; - outputFileStream->Write( - outputBytes, - 0, - base64Transform->OutputBlockSize ); - } - // - - // Transform the final block of data. - // - outputBytes = base64Transform->TransformFinalBlock( - inputBytes, - inputOffset, - inputBytes->Length - inputOffset ); - // - outputFileStream->Write( outputBytes, 0, outputBytes->Length ); - Console::WriteLine( L"Created encoded file at {0}", targetFile ); - } - - // Determine if the current transform can be reused. - // - if ( !base64Transform->CanReuseTransform ) - // - { - // Free up any used resources. - // - base64Transform->Clear(); - // - } - - // Close file streams. - inputFileStream->Close(); - outputFileStream->Close(); - } -}; - -int main() -{ - Members::Main(); -} - -// -// This sample produces the following output: -// -// Created encoded file at C:\ConsoleApplication1\\membersvcs.enc -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp deleted file mode 100644 index 080c61111a3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigDetached/CPP/xmldsigdetach.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp deleted file mode 100644 index 780d8fbafbf..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML-XMLDsigEnvelope/CPP/xmldsigenv.cpp +++ /dev/null @@ -1,171 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp deleted file mode 100644 index d4942102cf3..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Detached/CPP/exampledetached.cpp +++ /dev/null @@ -1,132 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, DSA^ DSAKey ) -{ - - // Create a SignedXml Object*. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the DSA key to the SignedXml object. - signedXml->SigningKey = DSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the S"Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a DSA signing key. - DSA^ DSAKey = DSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, DSAKey ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 20276a9a84d..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.DSAKeyValue_Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,174 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, DSA^ DSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the DSA key to the SignedXml document. - signedXml->SigningKey = DSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add a transformation to the reference. - Transform^ trns = gcnew XmlDsigC14NTransform; - reference->AddTransform( trns ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a DSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew DSAKeyValue( safe_cast(DSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a DSA signing key. - DSA^ DSAKey = DSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", DSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp deleted file mode 100644 index aca4a856e3f..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Detached/CPP/examplecreatedetached.cpp +++ /dev/null @@ -1,100 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key, String^ Certificate ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// - -[STAThread] -int main() -{ - array^args = Environment::GetCommandLineArgs(); - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - - // The name of the X509 certificate - String^ Certificate = "microsoft.cer"; - try - { - - // Generate a signing key. This key should match the certificate. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resource and save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key, Certificate ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp deleted file mode 100644 index 31aee98e1a6..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.KeyInfoX509Data_Envelope/CPP/examplecreateenvelope.cpp +++ /dev/null @@ -1,135 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key, String^ Certificate ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - String^ Certificate = "microsoft.cer"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key, Certificate ); - Console::WriteLine( "XML file signed." ); - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 43ae77e2392..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXML_CheckReturnValue_Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,170 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the RSA key to the SignedXml document. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add a RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a RSA signing key. - RSA^ RSAKey = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp deleted file mode 100644 index 8d9b7b1fc42..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml-AddObject-AddReference/CPP/example.cpp +++ /dev/null @@ -1,172 +0,0 @@ - - -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ RSAKey ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the RSA key to the SignedXml document. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add a transformation to the reference. - Transform^ trns = gcnew XmlDsigC14NTransform; - reference->AddTransform( trns ); - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue to the KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate an RSA signing key. - RSA^ RSAKey = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", RSAKey ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp deleted file mode 100644 index fa1867d2679..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Detached/CPP/exampledetached.cpp +++ /dev/null @@ -1,124 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. This method does not -// save the public key within the XML file. This file cannot be verified unless -// the verifying code has the key with which it was signed. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file against an asymmetric -// algorithm and return the result. -static Boolean VerifyDetachedSignature( String^ XmlSigFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passedXML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( dynamic_cast(nodeList[ 0 ]) ); - - // Check the signature against the passed asymmetric key - // and return the result. - return signedXml->CheckSignature( Key ); -} - -int main() -{ - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML Signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file against the key. - bool result = VerifyDetachedSignature( XmlFileName, Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp deleted file mode 100644 index 270360c4f71..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-AsymetricAlg-Envelope/CPP/exampleenvelope.cpp +++ /dev/null @@ -1,159 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. This method does not -// save the public key within the XML file. This file cannot be verified unless -// the verifying code has the key with which it was signed. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file against an asymmetric -// algorithm and return the result. -Boolean VerifyXmlFile( String^ Name, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - - -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument Object*. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "signedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml", Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp deleted file mode 100644 index 979040a9f1c..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Detached/CPP/xmldsigdetachedkeyedhashalg.cpp +++ /dev/null @@ -1,117 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature( Key ); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passedXML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXml object and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - -int main() -{ - try - { - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmlsig.xml"; - - // Generate a signing key. - HMACSHA256^ Key = gcnew HMACSHA256; - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName, Key ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp deleted file mode 100644 index 5ea1b276c55..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.SignedXml.ComputeSig-Check-KeyedHash-Envelope/CPP/xmldsigenvkeyedhashalg.cpp +++ /dev/null @@ -1,160 +0,0 @@ - - -// -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::X509Certificates; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using its name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXML object. - signedXml->AddReference( reference ); - - // Compute the signature. - signedXml->ComputeSignature( Key ); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name, KeyedHashAlgorithm^ Key ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXMl object and pass it - // the XMl document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the "Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature( Key ); -} - - -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument object. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode object. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the filename specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -int main() -{ - try - { - - // Generate a signing key. - HMACSHA256^ Key = gcnew HMACSHA256; - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying Signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml", Key ); - - // Display the results of the signature verification to \ - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - - return 0; -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp deleted file mode 100644 index 24b3bee5ff8..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Detached/CPP/sampledetached.cpp +++ /dev/null @@ -1,134 +0,0 @@ - - -// -// -// This example signs a file specified by a URI -// using a detached signature. It then verifies -// the signed XML. -// -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignDetachedResource( String^ URIString, String^ XmlSigFileName, RSA^ RSAKey ) -{ - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml; - - // Assign the key to the SignedXml object. - signedXml->SigningKey = RSAKey; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - - // Add the passed URI to the reference object. - reference->Uri = URIString; - - // Add a transformation if the URI is an XML file. - if ( URIString->EndsWith( "xml" ) ) - { - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(RSAKey) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement object. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Save the signed XML document to a file specified - // using the passed string. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( XmlSigFileName,gcnew UTF8Encoding( false ) ); - xmlDigitalSignature->WriteTo( xmltw ); - xmltw->Close(); - } -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyDetachedSignature( String^ XmlSigFileName ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Load the passed XML file into the document. - xmlDocument->Load( XmlSigFileName ); - - // Create a new SignedXMl object. - SignedXml^ signedXml = gcnew SignedXml; - - // Find the S"Signature" node and create a new - // XmlNodeList object. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -int main() -{ - - // The URI to sign. - String^ resourceToSign = "http://www.microsoft.com"; - - // The name of the file to which to save the XML signature. - String^ XmlFileName = "xmldsig.xml"; - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - Console::WriteLine( "Signing: {0}", resourceToSign ); - - // Sign the detached resourceand save the signature in an XML file. - SignDetachedResource( resourceToSign, XmlFileName, Key ); - Console::WriteLine( "XML signature was successfully computed and saved to {0}.", XmlFileName ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - - //Verify the XML signature in the XML file. - bool result = VerifyDetachedSignature( XmlFileName ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp deleted file mode 100644 index 19f81fd3bec..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.XML.XmlDsigC14NWithCommentsTransform_Envelope/CPP/sampleenvelope.cpp +++ /dev/null @@ -1,168 +0,0 @@ - - -// -// This example signs an XML file using an -// envelope signature. It then verifies the -// signed XML. -#using -#using - -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; -using namespace System::Xml; - -// -// Sign an XML file and save the signature in a new file. -void SignXmlFile( String^ FileName, String^ SignedFileName, RSA^ Key ) -{ - - // Create a new XML document. - XmlDocument^ doc = gcnew XmlDocument; - - // Format the document to ignore white spaces. - doc->PreserveWhitespace = false; - - // Load the passed XML file using it's name. - doc->Load( gcnew XmlTextReader( FileName ) ); - - // Create a SignedXml Object*. - SignedXml^ signedXml = gcnew SignedXml( doc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = ""; - - // Add an enveloped transformation to the reference. - XmlDsigEnvelopedSignatureTransform^ env = gcnew XmlDsigEnvelopedSignatureTransform; - reference->AddTransform( env ); - - // Add the reference to the SignedXml Object*. - signedXml->AddReference( reference ); - - // Add an RSAKeyValue KeyInfo (optional; helps recipient find key to validate). - KeyInfo^ keyInfo = gcnew KeyInfo; - keyInfo->AddClause( gcnew RSAKeyValue( safe_cast(Key) ) ); - signedXml->KeyInfo = keyInfo; - - // Compute the signature. - signedXml->ComputeSignature(); - - // Get the XML representation of the signature and save - // it to an XmlElement Object*. - XmlElement^ xmlDigitalSignature = signedXml->GetXml(); - - // Append the element to the XML document. - doc->DocumentElement->AppendChild( doc->ImportNode( xmlDigitalSignature, true ) ); - if ( (doc->FirstChild)->GetType() == XmlDeclaration::typeid ) - { - doc->RemoveChild( doc->FirstChild ); - } - - - // Save the signed XML document to a file specified - // using the passed String*. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( SignedFileName,gcnew UTF8Encoding( false ) ); - doc->WriteTo( xmltw ); - xmltw->Close(); -} - - -// -// -// Verify the signature of an XML file and return the result. -Boolean VerifyXmlFile( String^ Name ) -{ - - // Create a new XML document. - XmlDocument^ xmlDocument = gcnew XmlDocument; - - // Format using white spaces. - xmlDocument->PreserveWhitespace = true; - - // Load the passed XML file into the document. - xmlDocument->Load( Name ); - - // Create a new SignedXml Object* and pass it - // the XML document class. - SignedXml^ signedXml = gcnew SignedXml( xmlDocument ); - - // Find the S"Signature" node and create a new - // XmlNodeList Object*. - XmlNodeList^ nodeList = xmlDocument->GetElementsByTagName( "Signature" ); - - // Load the signature node. - signedXml->LoadXml( safe_cast(nodeList->Item( 0 )) ); - - // Check the signature and return the result. - return signedXml->CheckSignature(); -} - - -// -// Create example data to sign. -void CreateSomeXml( String^ FileName ) -{ - - // Create a new XmlDocument Object*. - XmlDocument^ document = gcnew XmlDocument; - - // Create a new XmlNode Object*. - XmlNode^ node = document->CreateNode( XmlNodeType::Element, "", "MyElement", "samples" ); - - // Add some text to the node. - node->InnerText = "Example text to be signed."; - - // Append the node to the document. - document->AppendChild( node ); - - // Save the XML document to the file name specified. - XmlTextWriter^ xmltw = gcnew XmlTextWriter( FileName,gcnew UTF8Encoding( false ) ); - document->WriteTo( xmltw ); - xmltw->Close(); -} - -void main() -{ - try - { - - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create an XML file to sign. - CreateSomeXml( "Example.xml" ); - Console::WriteLine( "New XML file created." ); - - // Sign the XML that was just created and save it in a - // new file. - SignXmlFile( "Example.xml", "SignedExample.xml", Key ); - Console::WriteLine( "XML file signed." ); - - // Verify the signature of the signed XML. - Console::WriteLine( "Verifying signature..." ); - bool result = VerifyXmlFile( "SignedExample.xml" ); - - // Display the results of the signature verification to - // the console. - if ( result ) - { - Console::WriteLine( "The XML signature is valid." ); - } - else - { - Console::WriteLine( "The XML signature is not valid." ); - } - } - catch ( CryptographicException^ e ) - { - Console::WriteLine( e->Message ); - } - -} - -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp deleted file mode 100644 index 35c00691bbc..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigBase64Transform/CPP/members.cpp +++ /dev/null @@ -1,219 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; - -namespace CryptographyXmlDsigBase64Transform -{ - ref class Example - { - public: - static void Produce() - { - - // Encrypt an XML message - EncryptXML(LoadXMLDoc()); - - // Using XmlDsigBase64Transform resolving a Uri. - Uri^ baseUri = gcnew Uri("http://www.microsoft.com"); - String^ relativeUri = "msdn"; - Uri^ absoluteUri = ResolveUris(baseUri, relativeUri); - Console::WriteLine("This sample completed successfully; " - "press Enter to exit."); - Console::ReadLine(); - } - - - private: - - // Encrypt the text in the specified XmlDocument. - static void EncryptXML(XmlDocument^ xmlDoc) - { - - // - XmlDsigBase64Transform^ xmlTransform = - gcnew XmlDsigBase64Transform; - // - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigBase64TransformUrl; - // - // Retrieve the XML representation of the current - // transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - Console::WriteLine("Xml representation of the " - "current transform: "); - Console::WriteLine(xmlInTransform->OuterXml); - - // Retrieve the valid input types for the current - // transform. - // - array^ validInTypes = xmlTransform->InputTypes; - // - // Verify the xmlTransform can accept the XMLDocument - // as an input type. - for each (Type^ validInType in validInTypes) - { - if (validInType == xmlDoc->GetType()) - { - - // Demonstrate loading the entire Xml Document. - // - xmlTransform->LoadInput(xmlDoc); - // - // This transform is created for demonstration - // purposes. - XmlDsigBase64Transform^ secondTransform = - gcnew XmlDsigBase64Transform; - // - String^ classDescription = - secondTransform->ToString(); - // - // This call does not perform as expected. - // LoadInnerXml is overridden by the - // XmlDsigBase64Transform class, but is - // stubbed out. - // - secondTransform->LoadInnerXml( - xmlDoc->SelectNodes("//.")); - // - break; - } - - } - - // - array^ validOutTypes = xmlTransform->OutputTypes; - // - for each (Type^ validOutType in validOutTypes) - { - if (validOutType == Stream::typeid) - { - try - { - - // - Type^ streamType = Stream::typeid; - CryptoStream^ outputStream = - (CryptoStream^)(xmlTransform->GetOutput( - streamType)); - // - // Read the CryptoStream into a stream reader. - StreamReader^ streamReader = - gcnew StreamReader(outputStream); - - // Read the stream into a string. - String^ outputMessage = - streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and - // after encryption. - Console::WriteLine("Encoding the following " - "message: {0}", xmlDoc->InnerText); - Console::WriteLine("Message encoded: {0}", - outputMessage); - } - catch (CryptographicException^ ex) - { - Console::WriteLine("Cryptographic exception " - "caught: {0}", ex); - } - - break; - } - else - { - - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - - } - } - - - // Create an XML document with Element and Text nodes. - static XmlDocument^ LoadXMLDoc() - { - XmlDocument^ xmlDoc = gcnew XmlDocument; - XmlNode^ mainNode = - xmlDoc->CreateNode(XmlNodeType::Element, - "ContosoMessages", "http://www.contoso.com"); - XmlNode^ textNode = xmlDoc->CreateTextNode("Some text " - "to encode."); - mainNode->AppendChild(textNode); - xmlDoc->AppendChild(mainNode); - Console::WriteLine("Created the following XML Document " - "for transformation: "); - Console::WriteLine(xmlDoc->InnerXml); - return xmlDoc; - } - - - // Resolve the specified base and relative Uri's. - static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri) - { - - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - XmlDsigBase64Transform^ xmlTransform = - gcnew XmlDsigBase64Transform; - xmlTransform->Resolver = xmlResolver; - // - Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri, - relativeUri); - if (absoluteUri != nullptr) - { - Console::WriteLine("Resolved the base Uri and " - "relative Uri to the following:"); - Console::WriteLine(absoluteUri); - } - else - { - Console::WriteLine("Unable to resolve the base " - "Uri and relative Uri"); - } - - return absoluteUri; - } - - }; - -} - -int main() -{ - CryptographyXmlDsigBase64Transform::Example::Produce(); -} - -// -// This sample produces the following output: -// -// Created the following XML Document for transformation: -// Some text to encode. -// -// Xml representation of the current transform: -// -// Encoding the following message: Some text to encode. -// Message encoded: Jmr^ -// Resolved the base Uri and relative Uri to the following: -// http://www.microsoft.com/msdn -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp deleted file mode 100644 index 9c590aba971..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigC14NTransform/CPP/members.cpp +++ /dev/null @@ -1,334 +0,0 @@ -// -#using -#using -#using -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; - -ref class Class1 -{ -private: - static String^ Certificate = L"..\\..\\my509.cer"; - -public: - [STAThread] - static void Main() - { - // Encrypt an XML message - XmlDocument^ productsXml = LoadProducts(); - ShowTransformProperties( productsXml ); - SignDocument( productsXml ); - ShowTransformProperties( productsXml ); - - // Use XmlDsigC14NTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" ); - String^ relativeUri = L"xml"; - Uri^ absoluteUri = ResolveUris( baseUri, relativeUri ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - - -private: - // Encrypt the text in the specified XmlDocument. - static void ShowTransformProperties( XmlDocument^ xmlDoc ) - { - // - XmlDsigC14NTransform^ xmlTransform = - gcnew XmlDsigC14NTransform( true ); - // - - // Ensure the transform is using the appropriate algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigExcC14NTransformUrl; - // - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - - Console::WriteLine( L"\nXml representation of the current transform: " ); - Console::WriteLine( xmlInTransform->OuterXml ); - - // Retrieve the valid input types for the current transform. - // - array^validInTypes = xmlTransform->InputTypes; - // - - // Verify the xmlTransform can accept the XMLDocument as an - // input type. - for ( int i = 0; i < validInTypes->Length; i++ ) - { - if ( validInTypes[ i ] == xmlDoc->GetType() ) - { - // Load the document into the transfrom. - // - xmlTransform->LoadInput( xmlDoc ); - // - - // - XmlDsigC14NTransform^ secondTransform = gcnew XmlDsigC14NTransform; - // - - // - String^ classDescription = secondTransform->ToString(); - // - - // This call does not perform as expected. - // This transform does not contain inner XML elements - // - secondTransform->LoadInnerXml( xmlDoc->SelectNodes( L"//." ) ); - // - - break; - } - } - - // - array^validOutTypes = xmlTransform->OutputTypes; - // - - for ( int i = 0; i < validOutTypes->Length; i++ ) - { - if ( validOutTypes[ i ] == System::IO::Stream::typeid ) - { - try - { - - // - Type^ streamType = System::IO::Stream::typeid; - MemoryStream^ outputStream = static_cast( - xmlTransform->GetOutput( streamType )); - // - - // Read the CryptoStream into a stream reader. - StreamReader^ streamReader = - gcnew StreamReader( outputStream ); - - // Read the stream into a string. - String^ outputMessage = streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine( L"Encoding the following xml: {0}", - xmlDoc->OuterXml ); - Console::WriteLine( L"Message encoded: {0}", outputMessage ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Unexpected exception caught: {0}", ex ); - } - - break; - } - else - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. - static XmlDocument^ LoadProducts() - { - XmlDocument^ xmlDoc = gcnew XmlDocument; - String^ contosoProducts = L""; - contosoProducts = String::Concat( contosoProducts, - L"123"); - contosoProducts = String::Concat( contosoProducts, - L"Router"); - contosoProducts = String::Concat( contosoProducts, - L"456"); - contosoProducts = String::Concat( contosoProducts, - L"Keyboard"); - - // Include a comment to test the comments feature of the transform. - contosoProducts = String::Concat( contosoProducts, - L"" ); - - // Include the CDATA tag to test the transform results. - contosoProducts = String::Concat( contosoProducts, - L"" ); - contosoProducts = String::Concat( contosoProducts, - L"" ); - - xmlDoc->LoadXml( contosoProducts ); - return xmlDoc; - } - - // Create a signature and add it to the specified document. - static void SignDocument( XmlDocument^ xmlDoc ) - { - // Generate a signing key. - RSA^ Key = RSA::Create(); - - // Create a SignedXml object. - SignedXml^ signedXml = gcnew SignedXml( xmlDoc ); - - // Add the key to the SignedXml document. - signedXml->SigningKey = Key; - - // Create a reference to be signed. - Reference^ reference = gcnew Reference; - reference->Uri = L""; - - // Add an enveloped transformation to the reference. - reference->AddTransform( gcnew XmlDsigC14NTransform ); - - // Add the reference to the SignedXml object. - signedXml->AddReference( reference ); - try - { - // Create a new KeyInfo object. - KeyInfo^ keyInfo = gcnew KeyInfo; - - // Load the X509 certificate. - X509Certificate^ MSCert = - X509Certificate::CreateFromCertFile( Certificate ); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - keyInfo->AddClause( gcnew KeyInfoX509Data( MSCert ) ); - - // Add the KeyInfo object to the SignedXml object. - signedXml->KeyInfo = keyInfo; - } - catch ( FileNotFoundException^ ) - { - Console::WriteLine( L"Unable to locate the following file: {0}", - Certificate ); - } - catch ( CryptographicException^ ex ) - { - Console::WriteLine( L"Unexpected exception caught while creating " - L"the certificate:{0}", ex ); - } - - // Compute the signature. - signedXml->ComputeSignature(); - - // Add the signature branch to the original tree so it is enveloped. - xmlDoc->DocumentElement->AppendChild( signedXml->GetXml() ); - } - - // Resolve the specified base and relative Uri's . - static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri ) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - XmlDsigC14NTransform^ xmlTransform = gcnew XmlDsigC14NTransform; - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri ); - if ( absoluteUri != nullptr ) - { - Console::WriteLine( - L"\nResolved the base Uri and relative Uri to the following:" ); - Console::WriteLine( absoluteUri ); - } - else - { - Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" ); - } - - return absoluteUri; - } -}; - -int main() -{ - Class1::Main(); -} - -// -// This sample produces the following output: -// -// Xml representation of the current transform: -// -// Encoding the following xml: 123Rou -// ter456Keyboard -// Message encoded: 123Rou -// ter456Keyboard'http:\\www.contoso.com\partner.asp?h1=en&h2=cr' -// Xml representation of the current transform: -// -// Encoding the following xml: 123Rou -// ter456Keyboard -// BFN2s0/NA2NGgb/R0mvfnNM0Ito= -// vSfZUG5xHuNxzOSEbQjN -// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+ -// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0 -// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG -// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM -// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ -// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH -// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ -// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl -// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5 -// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu -// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ -// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4= -// -// Message encoded: 123Router456Keyboard

'http:\\ww -// w.contoso.com\partner.asp?h1=en&h2=cr'BFN2s0/NA2NGgb/R0mvfnNM0Ito= -// vSfZUG5xHuNxzOSEbQjN -// dtEt1D+O7I1LTJ13RrwLaJSfQPrdT/s8IeaA+idw2f2WGuGrdqMJUddpE4GxfK61HmPQ6S7lBG+ -// +ND+YaUYf2AtTRs3SnToXQQrARa/pHVjsKxYHR/9tjy6maHBwxjgjFQABvYZu0gZHYRuXvvfxv0 -// 8=MIICCzCCAXSgAwIBAgIQ5eVQY8pRZ5xBF2WLkYPjijANBgkqhkiG -// 9w0BAQQFADAbMRkwFwYDVQQDExBHcmVnc0NlcnRpZmljYXRlMB4XDTAzMDkxNzIzMzU0N1oXDTM -// 5MTIzMTIzNTk1OVowGzEZMBcGA1UEAxMQR3JlZ3NDZXJ0aWZpY2F0ZTCBnzANBgkqhkiG9w0BAQ -// EFAAOBjQAwgYkCgYEAmFJ4v7rS3BYTXgVW9PgBFfTYAcB/m9mOFCmUrrChcBpoEtu/tSESlNfEH -// pECIdqg9vUrCNSkY08HRn3ueNeBSnSpssWd8/XoOboWLh1nd+79Y5uZd1WOJI4s0XM0MegZgCoJ -// cEEhpxCd/HOPIQvEsbpN/DuFiovZLo+Ek3hHoxMCAwEAAaNQME4wTAYDVR0BBEUwQ4AQaCb19dl -// yf/zSxPVYQZY9AKEdMBsxGTAXBgNVBAMTEEdyZWdzQ2VydGlmaWNhdGWCEOXlUGPKUWecQRdli5 -// GD44owDQYJKoZIhvcNAQEEBQADgYEAZuZaFDGDJogh7FuT0hfaMAVlRONv6wWVBJVV++eUo38Xu -// RfJ5nNJ0UnhiV2sEtLobYBPEIrNhuk8skdU0AHgx4ILiA4rR96ifWwxtrFQF+h+DL2ZB7xhwcOJ -// +Pa7IC4wIaEp/oBmmX+JHSzfQt6/If4ohwikfxfljKMyIcMlwl4=
-// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -//
diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp deleted file mode 100644 index bf4107ed47b..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform/cpp/members.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// -#using -#using -#using - -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Security::Cryptography::X509Certificates; - -public ref class EnvelopedSignatureSample -{ -private: - static String^ Certificate = "..\\..\\my509.cer"; - - // Encrypt the text in the specified XmlDocument. -public: - static void ShowTransformProperties(XmlDocument^ xmlDoc) - { - // - XmlDsigEnvelopedSignatureTransform^ xmlTransform = - gcnew XmlDsigEnvelopedSignatureTransform(); - // - - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = - SignedXml::XmlDsigEnvelopedSignatureTransformUrl; - // - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - - Console::WriteLine("\nXml representation of the current transform: "); - Console::WriteLine(xmlInTransform->OuterXml); - - // Retrieve the valid input types for the current transform. - // - array^ validInTypes = xmlTransform->InputTypes; - // - - // Verify the xmlTransform can accept the XMLDocument as an - // input type. - for (int i = 0; i < validInTypes->Length; i++) - { - if (validInTypes[i] == xmlDoc->GetType()) - { - // Load the document into the transfrom. - // - xmlTransform->LoadInput(xmlDoc); - // - - // - bool IncludeComments = true; - // This transform is created for demonstration purposes. - XmlDsigEnvelopedSignatureTransform^ secondTransform = - gcnew XmlDsigEnvelopedSignatureTransform(IncludeComments); - // - - // - String^ classDescription = secondTransform->ToString(); - // - - // This call does not perform as expected. - // - // An enveloped signature has no inner XML elements - secondTransform->LoadInnerXml(xmlDoc->SelectNodes("//.")); - // - - break; - } - } - - // - array^ validOutTypes = xmlTransform->OutputTypes; - // - - for (int i = validOutTypes->Length-1; i >= 0; i--) - { - if (validOutTypes[i] == System::Xml::XmlDocument::typeid) - { - // - Type^ xmlDocumentType = System::Xml::XmlDocument::typeid; - XmlDocument^ xmlDocumentOutput = (XmlDocument^) - xmlTransform->GetOutput(xmlDocumentType); - // - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine("Result of the GetOutput method call" + - " from the current transform: " + - xmlDocumentOutput->OuterXml); - - break; - } - else if (validOutTypes[i] == System::Xml::XmlNodeList::typeid) - { - Type^ xmlNodeListType = System::Xml::XmlNodeList::typeid; - XmlNodeList^ xmlNodes = (XmlNodeList^) - xmlTransform->GetOutput(xmlNodeListType); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine("Encoding the following message: " + - xmlDoc->InnerText); - - Console::WriteLine("Nodes of the XmlNodeList retrieved " + - "from GetOutput:"); - for (int j = 0; j < xmlNodes->Count; j++) - { - Console::WriteLine("Node " + j + - " has the following name: " + - xmlNodes->Item(j)->Name + - " and the following InnerXml: " + - xmlNodes->Item(j)->InnerXml); - } - - break; - } - else - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. -public: - static XmlDocument^ LoadProducts() - { - XmlDocument^ xmlDoc = gcnew XmlDocument(); - - String^ contosoProducts = "" + - "123Router" + - "" + - "456Keyboard" + - "" + - "789Monitor" + - "" + - ""; - - xmlDoc->LoadXml(contosoProducts); - return xmlDoc; - } - - // Create a signature and add it to the specified document. -public: - static void SignDocument(XmlDocument^ xmlDoc) - { - // Generate a signing key. - RSA^ key = RSA::Create(); - - // Create a SignedXml object. - SignedXml^ signedDocument = gcnew SignedXml(xmlDoc); - - // Add the key to the SignedXml document. - signedDocument->SigningKey = key; - - // Create a reference to be signed. - Reference^ referenceToBeSigned = gcnew Reference(); - referenceToBeSigned->Uri = ""; - - // Add an enveloped transformation to the reference. - referenceToBeSigned->AddTransform( - gcnew XmlDsigEnvelopedSignatureTransform()); - - // Add the reference to the SignedXml object. - signedDocument->AddReference(referenceToBeSigned); - - if(File::Exists(Certificate)) - { - // Create a new KeyInfo object. - KeyInfo^ info = gcnew KeyInfo(); - - // Load the X509 certificate. - X509Certificate^ certFromFile = - X509Certificate::CreateFromCertFile(Certificate); - - // Load the certificate into a KeyInfoX509Data object - // and add it to the KeyInfo object. - info->AddClause(gcnew KeyInfoX509Data(certFromFile)); - - // Add the KeyInfo object to the SignedXml object. - signedDocument->KeyInfo = info; - } - else - { - Console::WriteLine("Unable to locate the following file: " + - Certificate); - } - - // Compute the signature. - signedDocument->ComputeSignature(); - - // Add the signature branch to the original tree so it is enveloped. - xmlDoc->DocumentElement->AppendChild(signedDocument->GetXml()); - } - - // Resolve the specified base and relative Uri's . -public: - static Uri^ ResolveUris(Uri^ baseUri, String^ relativeUri) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver(); - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - - XmlDsigEnvelopedSignatureTransform^ xmlTransform = - gcnew XmlDsigEnvelopedSignatureTransform(); - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri(baseUri, relativeUri); - - if (absoluteUri != nullptr) - { - Console::WriteLine( - "\nResolved the base Uri and relative Uri to the following:"); - Console::WriteLine(absoluteUri->ToString()); - } - else - { - Console::WriteLine( - "Unable to resolve the base Uri and relative Uri"); - } - return absoluteUri; - } -}; - -[STAThread] -int main() -{ - // Encrypt an XML message - XmlDocument^ productsXml = EnvelopedSignatureSample::LoadProducts(); - EnvelopedSignatureSample::ShowTransformProperties(productsXml); - - EnvelopedSignatureSample::SignDocument(productsXml); - EnvelopedSignatureSample::ShowTransformProperties(productsXml); - - // Use XmlDsigEnvelopedSignatureTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri("http://www.contoso.com"); - String^ relativeUri = "xml"; - Uri^ absoluteUri = - EnvelopedSignatureSample::ResolveUris(baseUri, relativeUri); - - Console::WriteLine("This sample completed successfully; " + - "press Enter to exit."); - Console::ReadLine(); -} - -// -// This sample produces the following output: -// -// Xml representation of the current transform: -// -// Result of the GetOutput method call from the current transform: -// 123Router -// 456Keyboard789 -// Monitor -// Unable to load the following file: ..\\my509.cer -// -// Xml representation of the current transform: -// -// Result of the GetOutput method call from the current transform: -// 123Router -// 456Keyboard789 -// Monitor -// -// KvPW6HUiIUMEDS0YSoT -// gpo2JPbA=c/njCGDru/a -// WAmWG83I+mWO040xOzxvmNx0b0o8ZyPc9j5VwApdAt103OGBtB1H6EkOvt7Ekw+PVuUo8m5LzLP -// yaTxUDMbb2kZZ5itSkGD4rmMUMUMuzrkAoquJZjxeOydBJ2CMehV2rE3RMPLIwRX176DZVy5JKU -// 6Cb7PR2Rpw= -// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp deleted file mode 100644 index 5a53f0d8e0a..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.Cryptography.Xml.XmlDsigXsltTransform/CPP/members.cpp +++ /dev/null @@ -1,261 +0,0 @@ -// -#using -#using -#using -using namespace System; -using namespace System::IO; -using namespace System::Xml; -using namespace System::Security::Cryptography; -using namespace System::Security::Cryptography::Xml; -using namespace System::Text; - -ref class Class1 -{ -public: - [STAThread] - static void Main() - { - XmlDocument^ productsXml = LoadProducts(); - XmlNodeList^ xsltNodeList = GetXsltAsNodeList(); - TransformDoc( productsXml, xsltNodeList ); - - // Use XmlDsigXsltTransform to resolve a Uri. - Uri^ baseUri = gcnew Uri( L"http://www.contoso.com" ); - String^ relativeUri = L"xml"; - Uri^ absoluteUri = ResolveUris( baseUri, relativeUri ); - Console::WriteLine( L"This sample completed successfully; " - L"press Enter to exit." ); - Console::ReadLine(); - } - -private: - static void TransformDoc( XmlDocument^ xmlDoc, XmlNodeList^ xsltNodeList ) - { - try - { - // Construct a new XmlDsigXsltTransform. - // - XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform; - // - - // Load the Xslt tranform as a node list. - // - xmlTransform->LoadInnerXml( xsltNodeList ); - // - - // Load the Xml document to perform the tranform on. - // - XmlNamespaceManager^ namespaceManager; - namespaceManager = gcnew XmlNamespaceManager( xmlDoc->NameTable ); - XmlNodeList^ productsNodeList; - productsNodeList = xmlDoc->SelectNodes( L"//.", namespaceManager ); - xmlTransform->LoadInput( productsNodeList ); - // - - // Retrieve the output from the transform. - // - Stream^ outputStream = (Stream^)xmlTransform->GetOutput( - System::IO::Stream::typeid ); - // - - // Read the output stream into a stream reader. - StreamReader^ streamReader = gcnew StreamReader( outputStream ); - - // Read the stream into a string. - String^ outputMessage = streamReader->ReadToEnd(); - - // Close the streams. - outputStream->Close(); - streamReader->Close(); - - // Display to the console the Xml before and after - // encryption. - Console::WriteLine( L"\nResult of transformation: {0}", outputMessage ); - ShowTransformProperties( xmlTransform ); - } - catch ( Exception^ ex ) - { - Console::WriteLine( L"Caught exception in TransformDoc method: {0}", ex ); - } - } - - static XmlNodeList^ GetXsltAsNodeList() - { - String^ transformXml = L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"
ProductIdName
" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"" ); - transformXml = String::Concat( transformXml, - L"
" ); - Console::WriteLine( L"\nCreated the following Xslt tranform:" ); - Console::WriteLine( transformXml ); - XmlDocument^ xmlDoc = gcnew XmlDocument; - xmlDoc->LoadXml( transformXml ); - return xmlDoc->GetElementsByTagName( L"xsl:transform" ); - } - - // Encrypt the text in the specified XmlDocument. - static void ShowTransformProperties( XmlDsigXsltTransform^ xmlTransform ) - { - // - String^ classDescription = xmlTransform->ToString(); - // - Console::WriteLine( L"\n** Summary for {0} **", classDescription ); - - // Retrieve the XML representation of the current transform. - // - XmlElement^ xmlInTransform = xmlTransform->GetXml(); - // - Console::WriteLine( L"Xml representation of the current transform:\n{0}", - xmlInTransform->OuterXml ); - - // Ensure the transform is using the proper algorithm. - // - xmlTransform->Algorithm = SignedXml::XmlDsigXsltTransformUrl; - // - Console::WriteLine( L"Algorithm used: {0}", classDescription ); - - // Retrieve the valid input types for the current transform. - // - array^validInTypes = xmlTransform->InputTypes; - // - Console::WriteLine( L"Transform accepts the following inputs:" ); - for ( int i = 0; i < validInTypes->Length; i++ ) - { - Console::WriteLine( L"\t{0}", validInTypes[ i ] ); - - } - - // - array^validOutTypes = xmlTransform->OutputTypes; - // - Console::WriteLine( L"Transform outputs in the following types:" ); - for ( int i = validOutTypes->Length - 1; i >= 0; i-- ) - { - Console::WriteLine( L"\t {0}", validOutTypes[ i ] ); - if ( validOutTypes[ i ] == Object::typeid ) - { - // - Object^ outputObject = xmlTransform->GetOutput(); - // - } - } - } - - // Create an XML document describing various products. - static XmlDocument^ LoadProducts() - { - String^ contosoProducts = L""; - contosoProducts = String::Concat( contosoProducts, - L"" ); - contosoProducts = String::Concat( contosoProducts, - L"1" ); - contosoProducts = String::Concat( contosoProducts, - L"Widgets" ); - contosoProducts = String::Concat( contosoProducts, - L"2" ); - contosoProducts = String::Concat( contosoProducts, - L"Gadgits" ); - contosoProducts = String::Concat( contosoProducts, - L"" ); - Console::WriteLine( - L"\nCreated the following Xml document for tranformation:" ); - Console::WriteLine( contosoProducts ); - XmlDocument^ xmlDoc = gcnew XmlDocument; - xmlDoc->LoadXml( contosoProducts ); - return xmlDoc; - } - - // Resolve the specified base and relative Uri's . - static Uri^ ResolveUris( Uri^ baseUri, String^ relativeUri ) - { - // - XmlUrlResolver^ xmlResolver = gcnew XmlUrlResolver; - xmlResolver->Credentials = - System::Net::CredentialCache::DefaultCredentials; - - XmlDsigXsltTransform^ xmlTransform = gcnew XmlDsigXsltTransform; - xmlTransform->Resolver = xmlResolver; - // - - Uri^ absoluteUri = xmlResolver->ResolveUri( baseUri, relativeUri ); - if ( absoluteUri != nullptr ) - { - Console::WriteLine( - L"\nResolved the base Uri and relative Uri to the following:" ); - Console::WriteLine( absoluteUri ); - } - else - { - Console::WriteLine( L"Unable to resolve the base Uri and relative Uri" ); - } - - return absoluteUri; - } -}; - -int main() -{ - Class1::Main(); -} - -// -// This sample produces the following output: -// -// Created the following Xml document for tranformation: -// 1Widgets2Gadgits -// -// Created the following Xslt tranform: -//
ProductIdName
-// -// Result of transformation:
ProductIdName
1Widgets
2Gadgits
-// -// ** Summary for System.Security.Cryptography.Xml.XmlDsigXsltTransform ** -// Xml representation of the current transform: -// -// Algorithm used: System.Security.Cryptography.Xml.XmlDsigXsltTransform -// Transform accepts the following inputs: -// System.IO.Stream -// System.Xml.XmlDocument -// System.Xml.XmlNodeList -// Transform outputs in the following types: -// System.IO.Stream -// -// Resolved the base Uri and relative Uri to the following: -// http://www.contoso.com/xml -// This sample completed successfully; press Enter to exit. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp deleted file mode 100644 index 6f27c73ab00..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor2.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - // Define the string value to assign to a new secure string. - Char chars[4] = { 't', 'e', 's', 't' }; - // Instantiate the secure string. - SecureString^ testString = gcnew SecureString(); - // Assign the character array to the secure string. - for each (Char ch in chars) - { - testString->AppendChar(ch); - } - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 4 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp deleted file mode 100644 index 103271ae878..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.Security.SecureString.Ctor/cpp/Ctor3.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - // Define the string value to be assigned to the secure string. - String^ initString = "TestString"; - // Instantiate the secure string. - SecureString^ testString = gcnew SecureString(); - // Assign the character array to the secure string. - for each (Char ch in initString) - { - testString->AppendChar(ch); - } - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 10 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp deleted file mode 100644 index 2b795397fac..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributeargument/cpp/source.cpp +++ /dev/null @@ -1,37 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Use attributes to mark the class as serializable and obsolete. - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration("System.Serializable"); - class1->CustomAttributes->Add(codeAttrDecl); - - CodeAttributeArgument^ codeAttr = - gcnew CodeAttributeArgument( gcnew CodePrimitiveExpression("This class is obsolete.")); - codeAttrDecl = gcnew CodeAttributeDeclaration("System.Obsolete", codeAttr); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.Serializable()] -//[System.Obsolete("This class is obsolete.")] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp deleted file mode 100644 index 5523f2c37c7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codeattributedeclaration/cpp/source.cpp +++ /dev/null @@ -1,32 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new code attribute - CodeAttributeDeclaration^ codeAttrDecl = gcnew CodeAttributeDeclaration( - "System.CLSCompliantAttribute", - gcnew CodeAttributeArgument(gcnew CodePrimitiveExpression(false))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//[System.CLSCompliantAttribute(false)] -//public class Class1 { -//} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp deleted file mode 100644 index 4db196685db..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.codemethodreferenceexpression/cpp/source.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declares a type constructor that calls a method. - CodeConstructor^ constructor1 = gcnew CodeConstructor(); - constructor1->Attributes = MemberAttributes::Public; - class1->Members->Add(constructor1); - - // Creates a method reference for dict.Init. - CodeMethodReferenceExpression^ methodRef1 = - gcnew CodeMethodReferenceExpression( - gcnew CodeVariableReferenceExpression("dict"), - "Init", - gcnew array { - gcnew CodeTypeReference("System.Decimal"), - gcnew CodeTypeReference("System.Int32")}); - - // Invokes the dict.Init method from the constructor. - CodeMethodInvokeExpression^ invoke1 = - gcnew CodeMethodInvokeExpression(methodRef1, gcnew array {}); - constructor1->Statements->Add(invoke1); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -//public class Class1 { -// -// public Class1() { -// dict.Init(); -// } -// } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp deleted file mode 100644 index dcd7661e4aa..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.codedom.compiler.generatedcodeattribute/cpp/source.cpp +++ /dev/null @@ -1,39 +0,0 @@ -// -#using -#using - -using namespace System; -using namespace System::CodeDom; -using namespace System::CodeDom::Compiler; - -int main() -{ - // Declare a new type called Class1. - CodeTypeDeclaration^ class1 = gcnew CodeTypeDeclaration("Class1"); - - // Declare a new generated code attribute - GeneratedCodeAttribute^ generatedCodeAttribute = - gcnew GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0"); - - // Use the generated code attribute members in the attribute declaration - CodeAttributeDeclaration^ codeAttrDecl = - gcnew CodeAttributeDeclaration(generatedCodeAttribute->GetType()->Name, - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Tool)), - gcnew CodeAttributeArgument( - gcnew CodePrimitiveExpression(generatedCodeAttribute->Version))); - class1->CustomAttributes->Add(codeAttrDecl); - - // Create a C# code provider - CodeDomProvider^ provider = CodeDomProvider::CreateProvider("CSharp"); - - // Generate code and send the output to the console - provider->GenerateCodeFromType(class1, Console::Out, gcnew CodeGeneratorOptions()); -} - -// The CPP code generator produces the following source code for the preceeding example code: -// -// [GeneratedCodeAttribute("SampleCodeGenerator", "2.0.0.0")] -// public class Class1 { -// } -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp deleted file mode 100644 index 64c01acb0e7..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend1.cpp +++ /dev/null @@ -1,39 +0,0 @@ -using namespace System; - -ref class FileUtilities -{ - public: - static String^ AppendDirectorySeparator(String^ dir) - { - if (!dir->Trim()->EndsWith(System::IO::Path::DirectorySeparatorChar.ToString())) - return dir->Trim() + System::IO::Path::DirectorySeparatorChar; - else - return dir; - } -}; - - -// -// -// The assembly that exposes its internal types to this assembly should be -// named Assembly1.dll. -// -// The public key of this assembly should correspond to the public key -// specified in the class constructor of the InternalsVisibleTo attribute in the -// Assembly1 assembly. -// -#using as_friend - -using namespace System; - -void main() -{ - String^ dir = L"C:\\Program Files"; - dir = FileUtilities::AppendDirectorySeparator(dir); - Console::WriteLine(dir); -} -// The example displays the following output: -// C:\Program Files\ -// - - diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp deleted file mode 100644 index d98516de040..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.runtime.compilerservices.internalsvisibletoattribute/cpp/friend2.cpp +++ /dev/null @@ -1,12 +0,0 @@ -// -#using as_friend - -using namespace System; -using namespace Utilities::StringUtilities; - -void main() -{ - String^ s = "The Sign of the Four"; - Console::WriteLine(StringLib::IsFirstLetterUpperCase(s)); -} -// \ No newline at end of file diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp deleted file mode 100644 index 9bb50f4bd80..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.cryptography.symmetricalgorithm/cpp/encryptor.cpp +++ /dev/null @@ -1,54 +0,0 @@ -// -using namespace System; -using namespace System::Security::Cryptography; -using namespace System::Text; - -class EncryptorExample -{ -public: - static void Main() - { - TripleDESCryptoServiceProvider^ tdesCSP = gcnew TripleDESCryptoServiceProvider(); - - tdesCSP->GenerateKey(); - tdesCSP->GenerateIV(); - String^ quote = - "Things may come to those who wait, but only the " + - "things left by those who hustle. -- Abraham Lincoln"; - array^ encQuote = EncryptString(tdesCSP, quote); - - Console::WriteLine("Encrypted Quote:\n"); - Console::WriteLine(Convert::ToBase64String(encQuote)); - - Console::WriteLine("\nDecrypted Quote:\n"); - Console::WriteLine(DecryptBytes(tdesCSP, encQuote)); - } - - // -public: - static array^ EncryptString(SymmetricAlgorithm^ symAlg, String^ inString) - { - array^ inBlock = UnicodeEncoding::Unicode->GetBytes(inString); - ICryptoTransform^ xfrm = symAlg->CreateEncryptor(); - array^ outBlock = xfrm->TransformFinalBlock(inBlock, 0, inBlock->Length); - - return outBlock; - } - // - - // - static String^ DecryptBytes(SymmetricAlgorithm^ symAlg, array^ inBytes) - { - ICryptoTransform^ xfrm = symAlg->CreateDecryptor(); - array^ outBlock = xfrm->TransformFinalBlock(inBytes, 0, inBytes->Length); - - return UnicodeEncoding::Unicode->GetString(outBlock); - } - // -}; - -int main() -{ - EncryptorExample::Main(); -} -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp deleted file mode 100644 index 80d78080d26..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.securestring.ctor2/cpp/ctor1.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// -using namespace System; -using namespace System::Security; - -int main(array ^args) -{ - SecureString^ testString; - // Define the string value to assign to a new secure string. - Char chars[4] = { 't', 'e', 's', 't' }; - // Instantiate a new secure string. - Char* pChars = &chars[0]; - - testString = gcnew SecureString(pChars, sizeof(chars)/sizeof(chars[0])); - - // Display secure string length. - Console::WriteLine("The length of the string is {0} characters.", - testString->Length); - delete testString; - return 0; -} -// The example displays the following output: -// The length of the string is 4 characters. -// diff --git a/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp b/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp deleted file mode 100644 index 7ff6cd67159..00000000000 --- a/snippets/cpp/VS_Snippets_CLR_System/system.security.securityelement/cpp/remarks.cpp +++ /dev/null @@ -1,44 +0,0 @@ - -using namespace System; -using namespace System::Security; - - -public ref class SecurityElementTest -{ -private: - SecurityElement^ xmlRootElement; - -public: - SecurityElementTest() - { - xmlRootElement = gcnew SecurityElement("thetag", " "); - - xmlRootElement->AddAttribute("a", "123"); - xmlRootElement->AddAttribute("b", "456"); - xmlRootElement->AddAttribute("c", "789"); - - xmlRootElement->AddChild(gcnew SecurityElement("first", "text1")); - xmlRootElement->AddChild(gcnew SecurityElement("second", "text2")); - } - - // - String^ SearchForTextOfTag(String^ tag) - { - SecurityElement^ element = this->SearchForChildByTag(tag); - return element->Text; - } - // - -private: - SecurityElement^ SearchForChildByTag(String^ tag) - { - return xmlRootElement->SearchForChildByTag(tag); - } -}; - -int main() -{ - SecurityElementTest^ seTest = gcnew SecurityElementTest(); - - Console::WriteLine("Found the text for : " + seTest->SearchForTextOfTag("second")); -}
ProductIdName