RSAPKCS1SignatureDeformatter クラス

定義

RSA PKCS #1 バージョン 1.5 署名を検証します。

public ref class RSAPKCS1SignatureDeformatter : System::Security::Cryptography::AsymmetricSignatureDeformatter
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public class RSAPKCS1SignatureDeformatter : System.Security.Cryptography.AsymmetricSignatureDeformatter
public class RSAPKCS1SignatureDeformatter : System.Security.Cryptography.AsymmetricSignatureDeformatter
[System.Runtime.InteropServices.ComVisible(true)]
public class RSAPKCS1SignatureDeformatter : System.Security.Cryptography.AsymmetricSignatureDeformatter
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
type RSAPKCS1SignatureDeformatter = class
    inherit AsymmetricSignatureDeformatter
type RSAPKCS1SignatureDeformatter = class
    inherit AsymmetricSignatureDeformatter
[<System.Runtime.InteropServices.ComVisible(true)>]
type RSAPKCS1SignatureDeformatter = class
    inherit AsymmetricSignatureDeformatter
Public Class RSAPKCS1SignatureDeformatter
Inherits AsymmetricSignatureDeformatter
継承
RSAPKCS1SignatureDeformatter
属性

次の例では、メソッドを使用 VerifySignature して署名を確認する方法を示します。

using System;
using System.Security.Cryptography;

class RSASample
{

    static void Main()
    {
        try
        {
            //Create a new instance of RSA.
            using (RSA rsa = RSA.Create())
            {
                //The hash to sign.
                byte[] hash;
                using (SHA256 sha256 = SHA256.Create())
                {
                    byte[] data = new byte[] { 59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135 };
                    hash = sha256.ComputeHash(data);
                }

                //Create an RSASignatureFormatter object and pass it the 
                //RSA instance to transfer the key information.
                RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(rsa);

                //Set the hash algorithm to SHA256.
                RSAFormatter.SetHashAlgorithm("SHA256");

                //Create a signature for HashValue and return it.
                byte[] signedHash = RSAFormatter.CreateSignature(hash);
                //Create an RSAPKCS1SignatureDeformatter object and pass it the  
                //RSA instance to transfer the key information.
                RSAPKCS1SignatureDeformatter RSADeformatter = new RSAPKCS1SignatureDeformatter(rsa);
                RSADeformatter.SetHashAlgorithm("SHA256");
                //Verify the hash and display the results to the console. 
                if (RSADeformatter.VerifySignature(hash, signedHash))
                {
                    Console.WriteLine("The signature was verified.");
                }
                else
                {
                    Console.WriteLine("The signature was not verified.");
                }
            }
        }
        catch (CryptographicException e)
        {
            Console.WriteLine(e.Message);
        }
    }
}
Imports System.Security.Cryptography

Friend Class RSASample

    Shared Sub Main()
        Try
            'Create a new instance of RSA.
            Using rsa As RSA = RSA.Create()
                'The hash to sign.
                Dim hash() As Byte
                Using sha256 As SHA256 = SHA256.Create()
                    Dim data() As Byte = { 59, 4, 248, 102, 77, 97, 142, 201, 210, 12, 224, 93, 25, 41, 100, 197, 213, 134, 130, 135 }
                    hash = sha256.ComputeHash(data)
                End Using

                'Create an RSASignatureFormatter object and pass it the 
                'RSA instance to transfer the key information.
                Dim RSAFormatter As New RSAPKCS1SignatureFormatter(rsa)

                'Set the hash algorithm to SHA256.
                RSAFormatter.SetHashAlgorithm("SHA256")

                'Create a signature for HashValue and return it.
                Dim signedHash() As Byte = RSAFormatter.CreateSignature(hash)
                'Create an RSAPKCS1SignatureDeformatter object and pass it the  
                'RSA instance to transfer the key information.
                Dim RSADeformatter As New RSAPKCS1SignatureDeformatter(rsa)
                RSADeformatter.SetHashAlgorithm("SHA256")
                'Verify the hash and display the results to the console. 
                If RSADeformatter.VerifySignature(hash, signedHash) Then
                    Console.WriteLine("The signature was verified.")
                Else
                    Console.WriteLine("The signature was not verified.")
                End If
            End Using

        Catch e As CryptographicException
            Console.WriteLine(e.Message)
        End Try
    End Sub

End Class

注釈

このクラスは、アルゴリズムで作成されたデジタル署名を検証するために使用されます RSA

アルゴリズムを使用してデジタル署名を作成するために使用 RSAPKCS1SignatureFormatter します RSA

コンストラクター

RSAPKCS1SignatureDeformatter()

RSAPKCS1SignatureDeformatter クラスの新しいインスタンスを初期化します。

RSAPKCS1SignatureDeformatter(AsymmetricAlgorithm)

指定したキーで、RSAPKCS1SignatureDeformatter クラスの新しいインスタンスを初期化します。

メソッド

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
SetHashAlgorithm(String)

署名の検証に使用するハッシュ アルゴリズムを設定します。

SetKey(AsymmetricAlgorithm)

署名の検証に使用する公開キーを設定します。

ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)
VerifySignature(Byte[], Byte[])

指定されたデータの RSA PKCS #1 署名を検証します。

VerifySignature(HashAlgorithm, Byte[])

指定したハッシュ値から署名を検証します。

(継承元 AsymmetricSignatureDeformatter)

適用対象

こちらもご覧ください