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 rsa = (RSA)rsaKey;

            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

注解

在调用此方法的实现之前,必须指定密钥。

适用于

另请参阅