AsymmetricKeyExchangeDeformatter.DecryptKeyExchange(Byte[]) Metoda

Definice

Při přepsání v odvozené třídě extrahuje tajné informace z šifrovaných dat výměny klíčů.

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()

Parametry

rgb
Byte[]

Data výměny klíčů, vekterýchch

Návraty

Byte[]

Tajné informace odvozené z dat výměny klíčů.

Příklady

Následující příklad kódu ukazuje, jak přepsat metodu DecryptKeyExchange pro vytvoření šifrované výměny klíčů pro zadaná vstupní data. Tento příklad kódu je součástí většího příkladu poskytnutého AsymmetricKeyExchangeDeformatter pro třídu.

// 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

Poznámky

Před voláním implementace této metody je nutné zadat klíč.

Platí pro

Viz také