AsymmetricKeyExchangeDeformatter.DecryptKeyExchange(Byte[]) メソッド

定義

派生クラスでオーバーライドされると、暗号化されたキー交換データから機密情報を抽出します。When overridden in a derived class, extracts secret information from the encrypted key exchange data.

public:
 abstract cli::array <System::Byte> ^ DecryptKeyExchange(cli::array <System::Byte> ^ rgb);
public abstract byte[] DecryptKeyExchange (byte[] rgb);
abstract member DecryptKeyExchange : byte[] -> byte[]
Public MustOverride Function DecryptKeyExchange (rgb As Byte()) As Byte()

パラメーター

rgb
Byte[]

機密情報が非表示にされるキー交換データ。The key exchange data within which the secret information is hidden.

戻り値

Byte[]

キー交換データから派生する機密情報。The secret information derived from the key exchange data.

次のコード例は、DecryptKeyExchange メソッドをオーバーライドして、指定された入力データの暗号化キー交換を作成する方法を示しています。The following code example demonstrates how to override the DecryptKeyExchange method to create an encrypted key exchange for the specified input data. このコード例は、AsymmetricKeyExchangeDeformatter クラス用に用意されている大規模な例の一部です。This code example is part of a larger example provided for the AsymmetricKeyExchangeDeformatter class.

// Create the encrypted key exchange data from the specified input
// data. This method uses the RSACryptoServiceProvider only. To
// support additional providers or provide custom decryption logic,
// add logic to this member.
public override byte[] DecryptKeyExchange(byte[] rgbData) {
    byte[] decryptedBytes = null;

    if (rsaKey != null)
    {
        if (rsaKey is RSACryptoServiceProvider)
        {
            RSACryptoServiceProvider serviceProvder =
                (RSACryptoServiceProvider)rsaKey;

            decryptedBytes = serviceProvder.Decrypt(rgbData, true);
        }
        // Add custom decryption logic here.
    }
    else
    {
        throw new CryptographicUnexpectedOperationException(
            "Cryptography_MissingKey");
    }

    return decryptedBytes;
}
' Create the encrypted key exchange data from the specified input
' data. This method uses the RSACryptoServiceProvider only. To
' support additional providers or provide custom decryption logic,
' add logic to this member.
Public Overrides Function DecryptKeyExchange(
    ByVal rgbData() As Byte) As Byte()

    Dim decryptedBytes() As Byte

    If (Not rsaKey Is Nothing) Then
        If (TypeOf (rsaKey) Is RSACryptoServiceProvider) Then
            Dim rsaProvider As RSACryptoServiceProvider
            rsaProvider = CType(rsaKey, RSACryptoServiceProvider)

            decryptedBytes = rsaProvider.Decrypt(rgbData, True)
        End If

        ' Add custom decryption logic here.

    Else
        Throw New CryptographicUnexpectedOperationException(
            "Cryptography_MissingKey")
    End If

    Return decryptedBytes
End Function

注釈

このメソッドの実装を呼び出す前に、キーを指定する必要があります。You must specify a key before calling an implementation of this method.

適用対象

こちらもご覧ください