RSAPKCS1SignatureFormatter クラス

定義

RSA PKCS #1 バージョン 1.5 の署名を作成します。

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

次の例では、PKCS #1 バージョン 1.5 署名を作成する方法を示します。

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);
            }
        }
        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 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)
            End Using

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

End Class

注釈

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

アルゴリズムを使用してデジタル署名を検証するために使用 RSAPKCS1SignatureDeformatter します RSA

コンストラクター

RSAPKCS1SignatureFormatter()

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

RSAPKCS1SignatureFormatter(AsymmetricAlgorithm)

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

メソッド

CreateSignature(Byte[])

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

CreateSignature(HashAlgorithm)

指定されたハッシュ値から署名を作成します。

(継承元 AsymmetricSignatureFormatter)
Equals(Object)

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

(継承元 Object)
GetHashCode()

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

(継承元 Object)
GetType()

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

(継承元 Object)
MemberwiseClone()

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

(継承元 Object)
SetHashAlgorithm(String)

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

SetKey(AsymmetricAlgorithm)

署名の作成に使用する秘密キーを設定します。

ToString()

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

(継承元 Object)

適用対象

こちらもご覧ください