XML 加密

“可扩展标记语言”(XML) 加密是万维网 (WWW) 协会 (W3C) 在 2002 年开发的规范,包含加密数据的步骤、解密已加密数据的步骤、表示已加密的 XML 数据的语法、用来对数据进行解密的信息以及加密算法列表,例如,三重数据加密标准 (DES)、高级加密标准 (AES) 和 Rivest-Shamir-Adleman 算法 (RSA)。

要点: V5.x 与 V6 及更高版本的应用程序之间存在重要差别。这些信息仅支持与 WebSphere® Application Server V6.0.x 及更高版本配合使用的 V5.x 应用程序。这些信息不适用于 V6 及更高版本应用程序。

You can apply XML encryption to an XML element, XML element content, and arbitrary data, including an XML document. For example, suppose that you need to encrypt the <CreditCard> element shown in the example 1.

示例 1:样本 XML 文档

<PaymentInfo xmlns='http://example.org/paymentv2'>
  <Name>John Smith</Name>
  <CreditCard Limit='5,000' Currency='USD'>
    <Number>4019 2445 0277 5567</Number>
    <Issuer>Example Bank</Issuer>
    <Expiration>04/02</Expiration>
  </CreditCard>
</PaymentInfo>

示例 2:带公共密钥的 XML 文档:

示例 2 显示加密后的 XML 文档。<EncryptedData> 元素表示已加密的 <CreditCard> 元素。<EncryptionMethod> 元素描述应用的加密算法(在此示例中为三重 DES)。<KeyInfo> 元素包含检索解密密钥(在此示例中为 <KeyName> 元素)所需的信息。<CipherValue> 元素包含通过对 <CreditCard> 元素进行序列化和加密获得的密文。

<PaymentInfo xmlns='http://example.org/paymentv2'>
  <Name>John Smith</Name>
  <EncryptedData Type='http://www.w3.org/2001/04/xmlenc#Element'
     xmlns='http://www.w3.org/2001/04/xmlenc#'>
    <EncryptionMethod
       Algorithm='http://www.w3.org/2001/04/xmlenc#tripledes-cbc'/>
       <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
         <KeyName>John Smith</KeyName>
       </KeyInfo>
       <CipherData>
         <CipherValue>ydUNqHkMrD...</CipherValue>
       </CipherData>
  </EncryptedData>
</PaymentInfo>

示例 3:使用接收方的公用密钥加密的 XML 文档:

在示例 2 中,假定发送方和接收方都具有公共密钥。如果接收方具有公用和专用密钥对(这是最有可能的情况),那么可以按示例 3 中所示对 <CreditCard> 元素进行加密。<EncryptedData> 元素与示例 2 中找到的 <EncryptedData> 元素相同。但是 <KeyInfo> 元素包含 EncryptedKey。

<PaymentInfo xmlns='http://example.org/paymentv2'>
  <Name>John Smith</Name>
  <EncryptedData Type='http://www.w3.org/2001/04/xmlenc#Element'
    xmlns='http://www.w3.org/2001/04/xmlenc#'>
    <EncryptionMethod
      Algorithm='http://www.w3.org/2001/04/xmlenc#tripledes-cbc'/>
    <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
      <EncryptedKey xmlns='http://www.w3.org/2001/04/xmlenc#'>
        <EncryptionMethod
          Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-1_5'/>
        <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
          <KeyName>Sally Doe</KeyName>
        </KeyInfo>
        <CipherData>
          <CipherValue>yMTEyOTA1M...</CipherValue>
        </CipherData>
      </EncryptedKey>
    </KeyInfo>
    <CipherData>
      <CipherValue>ydUNqHkMrD...</CipherValue>
    </CipherData>
  </EncryptedData>
</PaymentInfo>

以 WSS-Core 加密 XML:

WSS-Core 规范是由“结构化信息标准促进组织”(OASIS) 制定的规范。此规范描述了对 SOAP 消息传递的增强,这些增强旨在通过消息完整性、消息机密性和单个消息认证来提供保护质量。消息机密性由基于 XML 加密的加密实现。

WSS-Core 规范支持对主体块、头块、它们的子结构以及 SOAP 消息附件的任意组合进行加密。此规范还要求,当您对 SOAP 消息的某些部分进行加密时,您将安全性头块中的引用添加到该消息的已加密部分前面。该引用可以是供接收方标识要对消息的哪些已加密部分进行解密的线索。

该引用的 XML 语法随已加密信息以及加密方式的不同而不同。例如,假定使用常见密钥或接收方的公共密钥对示例 4 中的 <CreditCard> 元素进行加密。

示例 4:样本 SOAP 消息:

<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
  xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP-ENV:Body>
    <PaymentInfo xmlns='http://example.org/paymentv2'>
      <Name>John Smith</Name>
      <CreditCard Limit='5,000' Currency='USD'>
        <Number>4019 2445 0277 5567</Number>
        <Issuer>Example Bank</Issuer>
        <Expiration>04/02</Expiration>
      </CreditCard>
    </PaymentInfo>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

示例 5 和 6 中显示产生的 SOAP 消息。在这些示例中,<ReferenceList> 和 <EncryptedKey> 元素分别用作引用。

示例 5:使用公共密钥加密的 SOAP 消息:

<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
  xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP-ENV:Header>
    <Security SOAP-ENV:mustUnderstand='1'
      xmlns='http://schemas.xmlsoap.org/ws/2003/06/secext'>
      <ReferenceList xmlns='http://www.w3.org/2001/04/xmlenc#'>
        <DataReference URI='#ed1'/>
      </ReferenceList>
    </Security>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <PaymentInfo xmlns='http://example.org/paymentv2'>
      <Name>John Smith</Name>
      <EncryptedData Id='ed1'
        Type='http://www.w3.org/2001/04/xmlenc#Element'
        xmlns='http://www.w3.org/2001/04/xmlenc#'>
        <EncryptionMethod
          Algorithm='http://www.w3.org/2001/04/xmlenc#tripledes-cbc'/>
        <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
          <KeyName>John Smith</KeyName>
        </KeyInfo>
        <CipherData>
          <CipherValue>ydUNqHkMrD...</CipherValue>
        </CipherData>
      </EncryptedData>
    </PaymentInfo>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

示例 6:使用接收方的公用密钥加密 SOAP 消息:

<SOAP-ENV:Envelope
  SOAP-ENV:encodingStyle='http://schemas.xmlsoap.org/soap/encoding/'
  xmlns:SOAP-ENV='http://schemas.xmlsoap.org/soap/envelope/'>
  <SOAP-ENV:Header>
    <Security SOAP-ENV:mustUnderstand='1'
      xmlns='http://schemas.xmlsoap.org/ws/2003/06/secext'>
      <EncryptedKey xmlns='http://www.w3.org/2001/04/xmlenc#'>
        <EncryptionMethod
          Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-1_5'/>
        <KeyInfo xmlns='http://www.w3.org/2000/09/xmldsig#'>
          <KeyName>Sally Doe</KeyName>
        </KeyInfo>
        <CipherData>
          <CipherValue>yMTEyOTA1M...</CipherValue>
        </CipherData>
        <ReferenceList>
          <DataReference URI='#ed1'/>
        </ReferenceList>
      </EncryptedKey>
    </Security>
  </SOAP-ENV:Header>
  <SOAP-ENV:Body>
    <PaymentInfo xmlns='http://example.org/paymentv2'>
      <Name>John Smith</Name>
      <EncryptedData Id='ed1'
        Type='http://www.w3.org/2001/04/xmlenc#Element'
        xmlns='http://www.w3.org/2001/04/xmlenc#'>
        <EncryptionMethod
          Algorithm='http://www.w3.org/2001/04/xmlenc#tripledes-cbc'/>
        <CipherData>
          <CipherValue>ydUNqHkMrD...</CipherValue>
        </CipherData>
      </EncryptedData>
    </PaymentInfo>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

与数字签名的关系:

WSS-Core 规范还提供消息完整性,这由基于 XML 签名规范的数字签名来实现。

对公共数据的加密与数字签名的组合会暴露加密弱点。


指示主题类型的图标 概念主题



时间戳记图标 最近一次更新时间: last_date
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-nd-mp&topic=cwbs_encrypt
文件名:cwbs_encrypt.html