SignatureDescription Class
Contains information about the properties of a digital signature.
Assembly: mscorlib (in mscorlib.dll)
System.Security.Cryptography::SignatureDescription
System.Deployment.Internal.CodeSigning::RSAPKCS1SHA256SignatureDescription
System.Deployment.Internal.CodeSigning::RSAPKCS1SHA256SignatureDescription
| Name | Description | |
|---|---|---|
![]() | SignatureDescription() | Initializes a new instance of the SignatureDescription class. |
![]() | SignatureDescription(SecurityElement^) | Initializes a new instance of the SignatureDescription class from the specified SecurityElement. |
| Name | Description | |
|---|---|---|
![]() | DeformatterAlgorithm | Gets or sets the deformatter algorithm for the signature description. |
![]() | DigestAlgorithm | Gets or sets the digest algorithm for the signature description. |
![]() | FormatterAlgorithm | Gets or sets the formatter algorithm for the signature description. |
![]() | KeyAlgorithm | Gets or sets the key algorithm for the signature description. |
| Name | Description | |
|---|---|---|
![]() | CreateDeformatter(AsymmetricAlgorithm^) | Creates an AsymmetricSignatureDeformatter instance with the specified key using the DeformatterAlgorithm property. |
![]() | CreateDigest() | Creates a HashAlgorithm instance using the DigestAlgorithm property. |
![]() | CreateFormatter(AsymmetricAlgorithm^) | Creates an AsymmetricSignatureFormatter instance with the specified key using the FormatterAlgorithm property. |
![]() | Equals(Object^) | Determines whether the specified object is equal to the current object.(Inherited from Object.) |
![]() | Finalize() | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.) |
![]() | GetHashCode() | Serves as the default hash function. (Inherited from Object.) |
![]() | GetType() | |
![]() | MemberwiseClone() | |
![]() | ToString() | Returns a string that represents the current object.(Inherited from Object.) |
The following code example demonstrates how to use members of the SignatureDescription class.
using namespace System; using namespace System::Security; using namespace System::Security::Cryptography; ref class SignatureDescriptionImpl { public: [STAThread] static void Main() { // Create a digital signature based on RSA encryption. SignatureDescription^ rsaSignature = CreateRSAPKCS1Signature(); ShowProperties( rsaSignature ); // Create a digital signature based on DSA encryption. SignatureDescription^ dsaSignature = CreateDSASignature(); ShowProperties( dsaSignature ); // Create a HashAlgorithm using the digest algorithm of the signature. HashAlgorithm^ hashAlgorithm = dsaSignature->CreateDigest(); Console::WriteLine( L"\nHash algorithm for the DigestAlgorithm property:" L" {0}", hashAlgorithm ); // Create an AsymmetricSignatureFormatter instance using the DSA key. DSA^ dsa = DSA::Create(); AsymmetricSignatureFormatter^ asymmetricFormatter = CreateDSAFormatter( dsa ); // Create an AsymmetricSignatureDeformatter instance using the // DSA key. AsymmetricSignatureDeformatter^ asymmetricDeformatter = CreateDSADeformatter( dsa ); Console::WriteLine( L"This sample completed successfully; " L"press Enter to exit." ); Console::ReadLine(); } private: // Create a SignatureDescription for RSA encryption. static SignatureDescription^ CreateRSAPKCS1Signature() { SignatureDescription^ signatureDescription = gcnew SignatureDescription; // Set the key algorithm property for RSA encryption. signatureDescription->KeyAlgorithm = L"System.Security.Cryptography.RSACryptoServiceProvider"; // Set the digest algorithm for RSA encryption using the // SHA1 provider. signatureDescription->DigestAlgorithm = L"System.Security.Cryptography.SHA1CryptoServiceProvider"; // Set the formatter algorithm with the RSAPKCS1 formatter. signatureDescription->FormatterAlgorithm = L"System.Security.Cryptography.RSAPKCS1SignatureFormatter"; // Set the formatter algorithm with the RSAPKCS1 deformatter. signatureDescription->DeformatterAlgorithm = L"System.Security.Cryptography.RSAPKCS1SignatureDeformatter"; return signatureDescription; } // Create a SignatureDescription using a constructed SecurityElement for // DSA encryption. static SignatureDescription^ CreateDSASignature() { SecurityElement^ securityElement = gcnew SecurityElement( L"DSASignature" ); // Create new security elements for the four algorithms. securityElement->AddChild( gcnew SecurityElement( L"Key",L"System.Security.Cryptography.DSACryptoServiceProvider" ) ); securityElement->AddChild( gcnew SecurityElement( L"Digest",L"System.Security.Cryptography.SHA1CryptoServiceProvider" ) ); securityElement->AddChild( gcnew SecurityElement( L"Formatter",L"System.Security.Cryptography.DSASignatureFormatter" ) ); securityElement->AddChild( gcnew SecurityElement( L"Deformatter",L"System.Security.Cryptography.DSASignatureDeformatter" ) ); SignatureDescription^ signatureDescription = gcnew SignatureDescription( securityElement ); return signatureDescription; } // Create a signature formatter for DSA encryption. static AsymmetricSignatureFormatter^ CreateDSAFormatter( DSA^ dsa ) { // Create a DSA signature formatter for encryption. SignatureDescription^ signatureDescription = gcnew SignatureDescription; signatureDescription->FormatterAlgorithm = L"System.Security.Cryptography.DSASignatureFormatter"; AsymmetricSignatureFormatter^ asymmetricFormatter = signatureDescription->CreateFormatter( dsa ); Console::WriteLine( L"\nCreated formatter : {0}", asymmetricFormatter ); return asymmetricFormatter; } // Create a signature deformatter for DSA decryption. static AsymmetricSignatureDeformatter^ CreateDSADeformatter( DSA^ dsa ) { // Create a DSA signature deformatter to verify the signature. SignatureDescription^ signatureDescription = gcnew SignatureDescription; signatureDescription->DeformatterAlgorithm = L"System.Security.Cryptography.DSASignatureDeformatter"; AsymmetricSignatureDeformatter^ asymmetricDeformatter = signatureDescription->CreateDeformatter( dsa ); Console::WriteLine( L"\nCreated deformatter : {0}", asymmetricDeformatter ); return asymmetricDeformatter; } // Display to the console the properties of the specified // SignatureDescription. static void ShowProperties( SignatureDescription^ signatureDescription ) { // Retrieve the class path for the specified SignatureDescription. String^ classDescription = signatureDescription->ToString(); String^ deformatterAlgorithm = signatureDescription->DeformatterAlgorithm; String^ formatterAlgorithm = signatureDescription->FormatterAlgorithm; String^ digestAlgorithm = signatureDescription->DigestAlgorithm; String^ keyAlgorithm = signatureDescription->KeyAlgorithm; Console::WriteLine( L"\n** {0} **", classDescription ); Console::WriteLine( L"DeformatterAlgorithm : {0}", deformatterAlgorithm ); Console::WriteLine( L"FormatterAlgorithm : {0}", formatterAlgorithm ); Console::WriteLine( L"DigestAlgorithm : {0}", digestAlgorithm ); Console::WriteLine( L"KeyAlgorithm : {0}", keyAlgorithm ); } }; int main() { SignatureDescriptionImpl::Main(); } // // This sample produces the following output: // // ** System.Security.Cryptography.SignatureDescription ** // DeformatterAlgorithm : System.Security.Cryptography. // RSAPKCS1SignatureDeformatter // // FormatterAlgorithm : System.Security.Cryptography. // RSAPKCS1SignatureFormatter // DigestAlgorithm : System.Security.Cryptography.SHA1CryptoServiceProvider // KeyAlgorithm : System.Security.Cryptography.RSACryptoServiceProvider // // ** System.Security.Cryptography.SignatureDescription ** // DeformatterAlgorithm : System.Security.Cryptography.DSASignatureDeformatter // FormatterAlgorithm : System.Security.Cryptography.DSASignatureFormatter // DigestAlgorithm : System.Security.Cryptography.SHA1CryptoServiceProvider // KeyAlgorithm : System.Security.Cryptography.DSACryptoServiceProvider // // Hash algorithm for the DigestAlgorithm property: // System.Security.Cryptography.SH // A1CryptoServiceProvider // // Created formatter : System.Security.Cryptography.DSASignatureFormatter // // Created deformatter : System.Security.Cryptography.DSASignatureDeformatter // This sample completed successfully; press Enter to exit.
Available since 1.1
Any public static ( Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.


