Xml Spring saml:为什么在saml响应中,密钥信息可以被加密?
据我所知,如果idp想要加密saml响应断言。Idp将使用SP提供的加密公钥对其进行加密,SP将使用私钥对其进行解密 但这是我从国内流离失所者那里得到的SAML反应的一部分Xml Spring saml:为什么在saml响应中,密钥信息可以被加密?,xml,encryption,saml,saml-2.0,spring-saml,Xml,Encryption,Saml,Saml 2.0,Spring Saml,据我所知,如果idp想要加密saml响应断言。Idp将使用SP提供的加密公钥对其进行加密,SP将使用私钥对其进行解密 但这是我从国内流离失所者那里得到的SAML反应的一部分 <EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion"> <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Type="http://www.
<EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#" Type="http://www.w3.org/2001/04/xmlenc#Element">
<xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
</e:EncryptionMethod>
<KeyInfo>
<ds:X509Data xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
<ds:X509IssuerSerial>
<ds:X509IssuerName>...</ds:X509IssuerName>
<ds:X509SerialNumber>1142467415</ds:X509SerialNumber>
</ds:X509IssuerSerial>
</ds:X509Data>
</KeyInfo>
<e:CipherData>
<e:CipherValue>...</e:CipherValue>
</e:CipherData>
</e:EncryptedKey>
</KeyInfo>
<xenc:CipherData>...</xenc:CipherData>
</xenc:EncryptedData>
</EncryptedAssertion>
...
1142467415
...
...
在查看源代码之后,SP的加密公钥(而不是用于en/解密断言)用于en/解密另一个密钥,该密钥用于en/解密断言(因此涉及2个密钥对,而不仅仅是1个)
我查看org.opensaml.xml.encryption.Decrypter的源代码
如果设置了字段解析器,则将使用decryptUsingResolvedKey()进行解密。这是我认为应该一直使用的
如果设置了字段encKeyResolver,则将使用decryptUsingResolvedEncryptedKey()
有两件事让我困惑:
我想我知道为什么,之所以要用两个键是为了提高速度 公钥/私钥(RSA等)用于加密/解密AES密钥,AES密钥用于加密/解密实际消息 因为AES比RSA快得多,而且AES比实际消息短得多。这样做将比仅仅使用RSA密钥加密/解密实际消息更快 安全性仍然受到保护,因为您需要AES密钥来读取消息,并且需要RSA密钥来读取AES密钥 这就是所谓的,几乎是普遍的。