AsymmetricKeyExchangeDeformatter.DecryptKeyExchange(Byte[]) 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
在派生类中重写时,从加密的密钥交换数据中提取机密信息。
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
注解
在调用此方法的实现之前,必须指定一个键。