XML 暗号化
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> エレメントは受信側の共通秘密鍵または公開鍵のいずれかによって暗号化されているとします。
例 4: SOAP バージョン 1.1 メッセージのサンプル:
<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-ENV:Envelope
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 バージョン 1.2 では encodingStyle をサポートしていないため、例は次のように変わります。
<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 バージョン 1.2 では encodingStyle をサポートしていないため、例は次のように変わります。
<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 仕様に基づくデジタル署名により実現されます。
共通データに対して暗号化とデジタル署名を組み合わせると、 暗号化がぜい弱になります。
対称暗号化と非対称暗号化
XML 暗号化の場合、アプリケーション・サーバーは、以下の 2 つのタイプの暗号化をサポートしています。
- 対称暗号化
IBM® WebSphere® Application Server バージョン 6.1 Feature Pack for Web Services を含む、WebSphere Application Server バージョン 7 よりも前のリリースのアプリケーション・サーバーでは、SOAP メッセージ外で共有鍵を参照する場合に、デフォルトで KeyName 参照が使用されていました。 しかし、Web Services Security (WS-Security) バージョン 1.1 標準では、KeyName 参照の使用を推奨していません。KeyName はセキュリティー・ポリシーでサポートされていないため、アプリケーション・サーバーではサポートされません。
Web Services Secure Conversation (WS-SecureConversation) 標準は、クライアントとサービスの間での共有鍵の交換方法、およびメッセージ内の共有鍵の参照方法を定義しています。 『Kerberos トークン・プロファイル』で説明されている、Web Services Security での Kerberos の使用は、対称暗号化を実行するための Kerberos セッション鍵、またはセッション鍵から得られた鍵の使用方法も定義しています。そのため、WS-SecureConversation または Kerberos を使用することにより対称暗号化を使用することができます。WebSphere Application Server は、WS-SecureConversation の使用時の DerivedKeyToken をサポートしています。Kerberos を使用している場合、WebSphere Application Server は、DerivedKeyToken の使用も Kerberos セッション鍵の使用も直接サポートしています。
- 非対称暗号化
非対象暗号化のために、XML 暗号化では鍵ラッピングの概念を導入しています。 SOAP 本体のコンテンツなどのデータは、処理中に動的に生成される共有鍵によって暗号化されます。 次に、生成された共有鍵が受信側の公開鍵によって暗号化されます。 WebSphere Application Server では非対称暗号化として X509Token をサポートしています。