如何在C#中包装对称密钥和IV

时间:2013-09-09 16:35:07

标签: c# .net cryptography tripledes

是否存在用于执行Triple DES Key Wrap的现有.NET API? 文档here

我已经生成了192位对称密钥+ 64位初始化向量(IV),总共256位。

目前,我的代码只加密对称密钥,如下所示:

        byte[] rawData = ReadFile("C:\\ReceiverTest.crt");
        X509Certificate2 x509 = new X509Certificate2();
        x509.Import(rawData);
        var receiverPublicKey = x509.PublicKey.Key.ToXmlString(false);

        RSACryptoServiceProvider receiverCipher = new RSACryptoServiceProvider();
        receiverCipher.FromXmlString(receiverPublicKey);

        // Encrypt the secret with the receiver's public key (so only they can decrypt)
        byte[] keyEncryptedBytes = receiverCipher.Encrypt(_cryptoHelper.SymmetricKey, false);             
        // Releases all resources
        receiverCipher.Clear();

        return keyEncryptedBytes;

我使用http://www.w3.org/2001/04/xmlenc#tripledes-cbc作为加密算法 签署SAML响应的算法 - http://www.w3.org/2000/09/xmldsig#rsa-sha1
加密密钥传输 - http://www.w3.org/2001/04/xmlenc#rsa-1_5

服务提供商无法解密我的摘要值,直到他们使用对称密钥包裹IV。

提前感谢您的帮助!
-Carrie

0 个答案:

没有答案