XML 暗号化

XML 暗号化は、2002 年に World Wide Web (WWW) Consortium (W3C) によって開発された仕様で、 データを暗号化するステップ、暗号化したデータを暗号化解除するステップ、暗号されたデータを表わす XML 構文、 データを暗号化解除するのに使用する情報、Triple-DES、AES、および RSA などの暗号化アルゴリズムのリストを含みます。

XML 暗号化は XML 要素、XML 要素コンテンツ、および XML 文書を含む任意のデータに適用できます。 例えば、例 1 で示すように、CreditCard 要素を暗号化する必要があるとします。

例 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 要素は適用された暗号化アルゴリズムを示し、この例では Triple-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 では、送信側と受信側が共通の秘密鍵を持っています。 受信側が公開鍵と秘密鍵のペアを持っている場合 (このような場合が多い)、CreditCard 要素は例 3 に示すように暗号化することができます。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 仕様は現在、Organization for the Advancement of Structured Information Standards (OASIS) によって開発されています。この仕様には、Simple Object Access Protocol (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>

結果の SOAP メッセージを例 5 と 6 に示します。 これらの例で、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-Signature 仕様に基づくデジタル・シグニチャーによって実現されています。

共通データに対する暗号化とデジタル・シグニチャーの組み合わせると、暗号がぜい弱になります。


フィードバック