自1977年以來,使用最為廣泛的加密算法是數據加密標準(Data Encryption Standard,DES)。但是事實表明,由于近幾年計算能力的極大提高,DES可以在一天之內被攻破。所以2001年,聯邦政府引入了一個新的標準:高級加密標準(Advanced Encryption Standard,AES)。DES和AES使用的都是對稱密鑰加密算法。顧名思義,其加密和解密是使用同一個密碼塊進行的。在一個客戶-服務器環境中,如何創建、分發用于加密和解密消息的密鑰并對其達成協議是首要的問題。
xml-Encryption指定EncryptedKey機制,使用RSA——一種公鑰加密體制——來加密密鑰。我們需要記住,在非對稱加密中,我們使用公鑰來加密,而使用私鑰來解密。所以,密鑰由消息發送方創建,并使用接收方的公鑰進行加密。然后用于加密的密鑰會包含在消息中。接收方根據KeyInfo元素得出解密密鑰(私鑰)。
讓我們來具體看一下由WebLogic Server 9.0所生成的示例消息:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<wsse:Security
xmlns:wsse="…/oasis-200401-wss-wssecurity-secext-1.0.xsd"
soapenv:mustUnderstand="1">
<ns1:EncryptedKey Id="encrypt"
xmlns:ns1="http://www.w3.org/2001/04/xmlenc#">
<ns1:EncryptionMethod Algorithm="…#rsa-1_5"/>
<ns2:KeyInfo xmlns:ns2="…/xmldsig#">
<wsse:SecurityTokenReference wsu:Id="Dk8Xm"
xmlns:wsu="…/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:wsse="…/oasis-200401-wss-wssecurity-secext1.0.xsd">
<ns2:X509Data>
<ns2:X509IssuerSerial>
<ns2:X509IssuerName>CN=CertGenCAB…C=US</ns2:X509IssuerName>
<ns2:X509SerialNumber>-</ns2:X509SerialNumber>
</ns2:X509IssuerSerial>
</ns2:X509Data>
</wsse:SecurityTokenReference>
</ns2:KeyInfo>
<ns1:CipherData>
<ns1:CipherValue>aSMjPEHitl/2doflGwDQ==</ns1:CipherValue>
</ns1:CipherData>
<ns1:ReferenceList>
<ns1:DataReference URI="#Dk8Zw31"/>
</ns1:ReferenceList>
</ns1:EncryptedKey>
</wsse:Security>
</soapenv:Header>
<soapenv:Body>
<ns1:EncryptedData Id=" Dk8Zw31" Type="…#Content"
MimeType="text/xml" Encoding="UTF-8" xmlns:ns1="…/xmlenc#">
<ns1:EncryptionMethod Algorithm="…#tripledescbc"/>
<ns1:CipherData>
<ns1:CipherValue>2HIkjvUdSL9qpqhP</ns1:CipherValue>
</ns1:CipherData>
</ns1:EncryptedData>
</soapenv:Body>
</soapenv:Envelope>
SecurityTokenReference元素指定接收方的X509證書的X509IssuerSerial。接收方應該能夠從密鑰庫查找相應的私鑰來執行解密操作。除了X509IssuerSerial,X509證書的Subject Key Identifier (SKID)也可以用來描述用于加密的密鑰。
<wsse:SecurityTokenReference>
<wsse:KeyIdentifier
ValueType="...#X509SubjectKeyIdentifier">
Xeg55vRyK3ZhAEhEf+YT0z986L0=
</wsse:KeyIdentifier>
</wsse:SecurityTokenReference>
假如X509證書中包含SKID,WebLogic Server 9.0就總會在SecurityTokenReference中生成KeyIdentifier。而假如X509證書中沒有SKID,那么就會在SecurityTokenReference中使用X509IssuerSerial。
新聞熱點
疑難解答