XML 암호화
XML 암호화는 W3C(World Wide Web Consortium)가 2002년에 개발한 스펙으로, 데이터 암호화 단계, 암호화된 데이터를 복호화하는 단계, 암호화된 데이터를 표현하기 위한 XML 구문, 데이터를 복호화하는 데 사용되는 정보 및 세 개의 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> 요소는 이 예제에서 삼중 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 스펙은 OASIS(Organization for the Advancement of Structured Information Standards)에서 개발했습니다. 스펙에서는 메시지 무결성, 메시지 기밀성, 단일 메시지 인증을 통해 보안 품질을 제공하는 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-서명 스펙을 기반으로 하는 디지털 서명으로 구현되는 메시지 무결성을 제공합니다.
공통 데이터를 통한 암호화 및 디지털 서명의 조합은 암호화의 취약점이 있습니다.
대칭 대 비대칭 암호화
XML 암호화의 경우, 애플리케이션 서버는 두 개 유형의 암호화를 지원합니다.
- 대칭 암호화
웹 서비스용 IBM® WebSphere® Application Server 버전 6.1 기능팩을 포함하는 WebSphere Application Server 버전 7 이전의 Application Server 릴리스에서는 기본적으로 KeyName 참조가 SOAP 메시지 외부의 공유 키를 참조하는 데 사용되었습니다. 그렇지만 웹 서비스 보안(WS-Security) 버전 1.1 표준은 KeyName 참조 사용을 권장하지 않습니다. KeyName이 보안 정책에서 지원되지 않으므로 Application Server에서 지원되지 않습니다.
웹 서비스 보안 통신(WS-SecureConversation) 표준은 클라이언트와 서비스 사이에서 공유 키를 교환하는 방법과 메시지에서 공유 키를 참조하는 방법을 정의합니다. Kerberos 토큰 프로파일에 설명된 대로 웹 서비스 보안이 포함된 Kerberos 사용에서는 Kerberos 세션 키 또는 세션 키에서 파생된 키를 사용하여 대칭 암호화를 수행하는 방법을 정의할 수도 있습니다. 따라서 WS-SecureConversation 또는 Kerberos를 통해 대칭 암호화를 사용할 수 있습니다. WebSphere Application Server는 WS-SecureConversation 사용 시 DerivedKeyToken을 지원합니다. Kerberos 사용 시 WebSphere Application Server는 DerivedKeyToken 사용 및 직접적인 Kerberos 세션 키 사용을 모두 지원합니다.
- 비대칭 암호화
비대칭 암호화의 경우 XML 암호화는 키 랩핑 아이디어를 도입합니다. SOAP 본문 요소의 컨텐츠와 같은 데이터는 처리 중에 동적으로 생성된 공유 키로 암호화됩니다. 그런 다음, 생성된 공유 키는 수신자의 공용 키를 사용하여 암호화됩니다. WebSphere Application Server는 비대칭 암호화에 대해 X509Token을 지원합니다.