DSACryptoServiceProvider.VerifyHash メソッド
アセンブリ: mscorlib (mscorlib.dll 内)

Public Function VerifyHash ( _ rgbHash As Byte(), _ str As String, _ rgbSignature As Byte() _ ) As Boolean
Dim instance As DSACryptoServiceProvider Dim rgbHash As Byte() Dim str As String Dim rgbSignature As Byte() Dim returnValue As Boolean returnValue = instance.VerifyHash(rgbHash, str, rgbSignature)
public: bool VerifyHash ( array<unsigned char>^ rgbHash, String^ str, array<unsigned char>^ rgbSignature )
戻り値
検証の結果、署名が有効な場合は true。それ以外の場合は false。


このメソッドは、SignHash によって生成された DSA デジタル署名を検証します。
str パラメータが null 参照 (Visual Basic では Nothing) の場合は、既定のハッシュ アルゴリズム (SHA1) が使用されます。有効なハッシュ アルゴリズムは SHA1 と MD5 です。

DSACryptoServiceProvider クラスを使用してデータに署名してそのデータを検証するコード例を次に示します。
Imports System Imports System.Security.Cryptography _ Class DSACSPSample Shared Sub Main() Try 'Create a new instance of DSACryptoServiceProvider to generate 'a new key pair. Dim DSA As New DSACryptoServiceProvider() 'The hash to sign. Dim Hash As Byte() = {59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135} 'Use the MapNameToOID method to get an OID 'for the SHA1 algorithm. Dim OID As String = CryptoConfig.MapNameToOID("SHA1") 'The value to hold the signed hash. Dim SignedHashValue As Byte() = DSASignHash(Hash, DSA.ExportParameters(True), OID) 'Verify the hash and display the results. If DSAVerifyHash(Hash, SignedHashValue, DSA.ExportParameters(False), OID) Then Console.WriteLine("The hash value was verified.") Else Console.WriteLine("The hash value was not verified.") End If Catch e As ArgumentNullException Console.WriteLine(e.Message) End Try End Sub Public Shared Function DSASignHash(ByVal HashToSign() As Byte, ByVal DSAKeyInfo As DSAParameters, ByVal HashOID As String) As Byte() Try 'Create a new instance of DSACryptoServiceProvider. Dim DSA As New DSACryptoServiceProvider() 'Import the key information. DSA.ImportParameters(DSAKeyInfo) 'Sign the hash and return it. Return DSA.SignHash(HashToSign, HashOID) Catch e As CryptographicException Console.WriteLine(e) Return Nothing End Try End Function Public Shared Function DSAVerifyHash(ByVal Hash() As Byte, ByVal SignedHash() As Byte, ByVal DSAKeyInfo As DSAParameters, ByVal HashOID As String) As Boolean Try 'Create a new instance of DSACryptoServiceProvider. Dim DSA As New DSACryptoServiceProvider() 'Import the key information. DSA.ImportParameters(DSAKeyInfo) 'Verify the signature and return the result. Return DSA.VerifyHash(Hash, HashOID, SignedHash) Catch e As CryptographicException Console.WriteLine(e.Message) Return False End Try End Function End Class
using System; using System.Security.Cryptography; class DSACSPSample { static void Main() { try { //Create a new instance of DSACryptoServiceProvider to generate //a new key pair. DSACryptoServiceProvider DSA = new DSACryptoServiceProvider(); //The hash to sign. byte[] Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100,197 ,213,134,130,135}; //Use the MapNameToOID method to get an OID //for the SHA1 algorithm. string OID = CryptoConfig.MapNameToOID("SHA1"); //The value to hold the signed hash. byte[] SignedHashValue = DSASignHash(Hash, DSA.ExportParameters(true), OID); //Verify the hash and display the results. if(DSAVerifyHash(Hash, SignedHashValue, DSA.ExportParameters(false), OID)) { Console.WriteLine("The hash value was verified."); } else { Console.WriteLine("The hash value was not verified."); } } catch(ArgumentNullException e) { Console.WriteLine(e.Message); } } public static byte[] DSASignHash(byte[] HashToSign, DSAParameters DSAKeyInfo, string HashOID) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider DSA = new DSACryptoServiceProvider(); //Import the key information. DSA.ImportParameters(DSAKeyInfo); //Sign the hash and return it. return DSA.SignHash(HashToSign, HashOID); } catch(CryptographicException e) { Console.WriteLine(e); return null; } } public static bool DSAVerifyHash(byte[] Hash, byte[] SignedHash, DSAParameters DSAKeyInfo, string HashOID) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider DSA = new DSACryptoServiceProvider(); //Import the key information. DSA.ImportParameters(DSAKeyInfo); //Verify the signature and return the result. return DSA.VerifyHash(Hash, HashOID, SignedHash); } catch(CryptographicException e) { Console.WriteLine(e.Message); return false; } } }
#using <System.dll> using namespace System; using namespace System::Security::Cryptography; array<Byte>^ DSASignHash( array<Byte>^HashToSign, DSAParameters DSAKeyInfo, String^ HashOID ) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider^ DSA = gcnew DSACryptoServiceProvider; //Import the key information. DSA->ImportParameters( DSAKeyInfo ); //Sign the hash and return it. return DSA->SignHash( HashToSign, HashOID ); } catch ( CryptographicException^ e ) { Console::WriteLine( e ); return nullptr; } } bool DSAVerifyHash( array<Byte>^Hash, array<Byte>^SignedHash, DSAParameters DSAKeyInfo, String^ HashOID ) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider^ DSA = gcnew DSACryptoServiceProvider; //Import the key information. DSA->ImportParameters( DSAKeyInfo ); //Verify the signature and return the result. return DSA->VerifyHash( Hash, HashOID, SignedHash ); } catch ( CryptographicException^ e ) { Console::WriteLine( e->Message ); return false; } } int main() { try { //Create a new instance of DSACryptoServiceProvider to generate //a new key pair. DSACryptoServiceProvider^ DSA = gcnew DSACryptoServiceProvider; //The hash to sign. array<Byte>^Hash = {59,4,248,102,77,97,142,201,210,12,224,93,25,41,100 ,197,213,134,130,135}; //Use the MapNameToOID method to get an OID //for the SHA1 algorithm. String^ OID = CryptoConfig::MapNameToOID( "SHA1" ); //The value to hold the signed hash. array<Byte>^SignedHashValue = DSASignHash( Hash, DSA->ExportParameters( true ), OID ); //Verify the hash and display the results. if ( DSAVerifyHash( Hash, SignedHashValue, DSA->ExportParameters( false ), OID ) ) { Console::WriteLine( "The hash value was verified." ); } else { Console::WriteLine( "The hash value was not verified." ); } } catch ( ArgumentNullException^ e ) { Console::WriteLine( e->Message ); } }
import System .* ; import System.Security.Cryptography .* ; class DSACSPSample { public static void main(String[] args) { try { // Create a new instance of DSACryptoServiceProvider to generate // a new key pair. DSACryptoServiceProvider dsa = new DSACryptoServiceProvider(); // The hash to sign. ubyte hash[] = {59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135}; // Use the MapNameToOID method to get an oid // for the SHA1 algorithm. String oid = CryptoConfig.MapNameToOID("SHA1"); // The value to hold the signed hash. ubyte signedHashValue[] = DSASignHash(hash, dsa.ExportParameters(true), oid); // Verify the hash and display the results. if (DSAVerifyHash(hash, signedHashValue, dsa.ExportParameters(false), oid)) { Console.WriteLine("The hash value was verified."); } else { Console.WriteLine("The hash value was not verified."); } } catch(ArgumentNullException e) { Console.WriteLine(e.get_Message()); } } //main public static ubyte[] DSASignHash(ubyte hashToSign[], DSAParameters dsaKeyInfo, String hashOid) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider dsa = new DSACryptoServiceProvider(); //Import the key information. dsa.ImportParameters(dsaKeyInfo); //Sign the hash and return it. return dsa.SignHash(hashToSign, hashOid) ; } catch(CryptographicException e) { Console.WriteLine(e); return null; } } //DSASignHash public static boolean DSAVerifyHash(ubyte hash[], ubyte signedHash[], DSAParameters dsaKeyInfo, String hashOid) { try { //Create a new instance of DSACryptoServiceProvider. DSACryptoServiceProvider dsa = new DSACryptoServiceProvider(); //Import the key information. dsa.ImportParameters(dsaKeyInfo); //Verify the signature and return the result. return dsa.VerifyHash(hash, hashOid, signedHash) ; } catch (CryptographicException e) { Console.WriteLine(e.get_Message()); return false ; } } //DSAVerifyHash } //DSACSPSample

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


Weblioに収録されているすべての辞書からDSACryptoServiceProvider.VerifyHash メソッドを検索する場合は、下記のリンクをクリックしてください。

- DSACryptoServiceProvider.VerifyHash メソッドのページへのリンク