XML 暗号化は、World Wide Web (WWW) Consortium (W3C) が 2002 年に開発した仕様で、 この中には、データを暗号化するステップ、暗号化されたデータを暗号化解除するステップ、 暗号化されたデータを表す 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) によって開発が進められています。 この仕様では、メッセージ保全性、メッセージ機密性、および単一メッセージ認証による保護品質を実現するための SOAP メッセージングの強化について説明しています。メッセージ機密性は、XML 暗号化に基づく暗号化により実現されます。
WSS-Core 仕様では、SOAP メッセージの本文ブロック、ヘッダー・ブロック、そのサブストラクチャー、 および添付ファイルの任意の組み合わせの暗号化がサポートされます。 この仕様では、SOAP メッセージのパーツを暗号化する際に、 セキュリティー・ヘッダー・ブロックから暗号化メッセージのパーツへの参照を、 このメッセージの前に付加することも必要になります。 この参照は、受信側にとってメッセージのどの暗号化パーツを暗号化解除するかを識別するための手掛かりとなります。
参照の XML 構文は、暗号化されている情報と暗号化の方法によって異なります。 例えば、例 4 の <CreditCard> エレメントは受信側の共通秘密鍵または公開鍵のいずれかによって暗号化されているとします。
<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 バージョン 1.1 メッセージ
<SOAP-ENV:Envelope 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>
<SOAP-ENV:Envelope 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>
<SOAP-ENV:Envelope 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 仕様に基づくディジタル・シグニチャーにより実現されます。
共通データに対して暗号化とデジタル・シグニチャーを組み合わせると、 暗号化がぜい弱になります。