XML 暗号化
Extensible Markup Language (XML) 暗号化は、World Wide Web (WWW) Consortium (W3C) が 2002 年に開発した仕様で、この中には、データを暗号化するステップ、暗号化されたデータを暗号化解除するステップ、XML 暗号化されたデータを表す構文、データの暗号化解除に使用される情報、および暗号化アルゴリズム (Triple Data Encryption Standard (DES)、Advanced Encryption Standard (AES)、および Rivest-Shamir-Adleman algorithm (RSA) など) のリストが含まれています。
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> エレメントは、適用された暗号化アルゴリズムを記述します (この例では 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 メッセージ・サンプル:
<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 仕様に基づくデジタル署名により実現されます。
共通データに対して暗号化とデジタル署名を組み合わせると、 暗号化がぜい弱になります。