0

Algorithm暗号化された XMLの要素の属性を解析し、データの復号化に使用するEncryptionMethod正しいAsymmetricAlgorithm/を識別できる組み込みの .NET API はありますか?SymmetricAlgorithm

以下は、復号化する暗号化された XML スニペットの例です。

<xenc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
  xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
  <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes128-cbc"/>
  <xenc:CipherData>
    <xenc:CipherValue>fWDq0kmaii...U9Tng==</xenc:CipherValue>
  </xenc:CipherData>
</xenc:EncryptedData>

私は .NET クラスを使用してきましたが、属性で見つかった URI を解析して適切なものを選択するのSystem.Security.Cryptography.Xml.EncryptedDataに役立つサブプロパティまたはメソッドが表示されませんでした(この場合は、ofおよびof を使用)。AlgorithmSymmetricAlgorithmSystem.Security.Cryptography.RijndaelManagedCipherModeCBCBlockSize128

暗号化された XML の解析から、必要なAsymmmetricAlgorithm/を正しく識別して構成できる組み込みの .NET API メソッドはありますか?SymmetricAlgorithm

4

1 に答える 1

1

Using Reflector on the System.Security.Cryptography.Xml.EncryptedXml class, I found reference to a method named CreateFromName on the System.Security.Cryptography.CryptoConfig class. It is almost everything I was looking for. Given a URI for any SymmetricAlgorithm, it will construct and configure (see my comment below) the algorithm for you. However, it does not work for any URIs indicating an AsymmetricAlgorithm used for key transport.

One thing I've found is that for many people's needs, the EncryptedXml class can likely do the decrypting of the document for you, so that this step of constructing your own algorithm objects by parsing the URI would be unnecessary. I believe my particular use case may be exceptional, but at least I can now use the same helper class that EncryptedXml is using (at least in the case of SymmetricAlgorithm used for block encryption/decryption).

于 2013-03-07T20:23:22.570 に答える