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

定義

派生クラスでオーバーライドされると、暗号化されたキー交換データからシークレット情報を抽出します。

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[]

キーは、シークレット情報が非表示になっているデータを交換します。

返品

Byte[]

キー交換データから派生したシークレット情報。

次のコード例では、 DecryptKeyExchange メソッドをオーバーライドして、指定した入力データの暗号化されたキー交換を作成する方法を示します。 このコード例は、 AsymmetricKeyExchangeDeformatter クラスに提供されるより大きな例の一部です。

// Create the encrypted key exchange data from the specified input
// data. This method uses the RSA class 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 RSA rsa)
        {
            decryptedBytes = rsa.Decrypt(rgbData, RSAEncryptionPadding.OaepSHA1);
        }
        // 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 RSA class 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 RSA) Then
            Dim rsa As RSA
            rsa = CType(rsaKey, RSA)

            decryptedBytes = rsa.Decrypt(rgbData, RSAEncryptionPadding.OaepSHA1)
        End If

        ' Add custom decryption logic here.

    Else
        Throw New CryptographicUnexpectedOperationException(
            "Cryptography_MissingKey")
    End If

    Return decryptedBytes
End Function

注釈

このメソッドの実装を呼び出す前に、キーを指定する必要があります。

適用対象

こちらもご覧ください