Encryption in combination with SAML is achieved via XML-encryption. This paragraph provides an explanation of encrypted elements as well as elements encrypted to multiple recipients.

Encrypted elements

Any element that will be encrypted has to conform to the following:

Multiple recipients

SAML and XML-encryption allow for multiple recipients of the same encrypted element. The construct for this is specified in more detail in errata E43 of SAML 2.0 errata 05. In case of multiple recipients:

EncryptedID

An <EncryptedID> MUST contain a SAML <NameID> after decryption, with the following properties:

EncryptedAttribute

An <EncryptedAttribute> MUST contain a SAML <Attribute> after decryption, with the following properties:

Examples

Below two examples are given, with encryption and after decryption. the EncryptedID example is for a single recipient, the EncryptedAttribute example is for multiple recipients. The same construct for single / multiple recipient can be used in the other encrypted element types.

 <saml2:EncryptedID xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
     xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
     xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <xenc:EncryptedData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
        Id="_cd52e15a16e2a0aa751725ce76a6b866" Type="http://www.w3.org/2001/04/xmlenc#Element">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
        <ds:KeyInfo>
            <ds:RetrievalMethod Type="http://www.w3.org/2001/04/xmlenc#EncryptedKey"
                URI="#_15531f77a9f1e0b5e0cce442aa31bbd4" />
        </ds:KeyInfo>
        <xenc:CipherData>
            <xenc:CipherValue>AZkW3hbBaQkxs...</xenc:CipherValue>
        </xenc:CipherData>
    </xenc:EncryptedData>
    <xenc:EncryptedKey Id="_15531f77a9f1e0b5e0cce442aa31bbd4"
        Recipient="urn:etoegang:...">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        </xenc:EncryptionMethod>
        <ds:KeyInfo>
            <ds:KeyName>...</ds:KeyName>
        </ds:KeyInfo>
        <xenc:CipherData>
            <xenc:CipherValue>yRy923JJlgAi2MTgx1qohLiDBgi...</xenc:CipherValue>
        </xenc:CipherData>
        <xenc:ReferenceList>
            <xenc:DataReference URI="#_cd52e15a16e2a0aa751725ce76a6b866" />
        </xenc:ReferenceList>
    </xenc:EncryptedKey>
</saml2:EncryptedID>

<saml2:NameID xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:2.0:nameid-format:persistent" NameQualifier="urn:etoegang:1.9:EntityConcernedID:BSN">999999047</saml2:NameID>
 <saml2:EncryptedAttribute xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
    xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
    xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
    <xenc:EncryptedData Id="_3c63798db8a16b54ade207ea0df28ad4" Type="http://www.w3.org/2001/04/xmlenc#Element">
        <xenc:EncryptionMethod xmlns:xenc="http://www.w3.org/2001/04/xmlenc#"
            Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
        <ds:KeyInfo>
            <ds:KeyName>_dd0d7a0215f94ea81b170a2e65834ce8</ds:KeyName>
        </ds:KeyInfo>
        <xenc:CipherData>
            <xenc:CipherValue>5efOYLEoY1PD2145...</xenc:CipherValue>
        </xenc:CipherData>
    </xenc:EncryptedData>
    <xenc:EncryptedKey Id="_fd73ad54daf1ca14a4aac30ea850340a" Recipient="urn:etoegang:...">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        </xenc:EncryptionMethod>
        <ds:KeyInfo>
            <ds:KeyName>...</ds:KeyName>
        </ds:KeyInfo>
        <xenc:CipherData>
            <xenc:CipherValue>H5nzimm7fAZuzdnZ...</xenc:CipherValue>
        </xenc:CipherData>
        <xenc:ReferenceList>
            <xenc:DataReference URI="#_3c63798db8a16b54ade207ea0df28ad4" />
        </xenc:ReferenceList>
        <xenc:CarriedKeyName>_dd0d7a0215f94ea81b170a2e65834ce8</xenc:CarriedKeyName>
    </xenc:EncryptedKey>
    <xenc:EncryptedKey Id="_e152fcf0772b8921f09ec0c1a45f1fa4" Recipient="urn:etoegang:...">
        <xenc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
        </xenc:EncryptionMethod>
        <ds:KeyInfo>
            <ds:KeyName>...</ds:KeyName>
        </ds:KeyInfo>
        <xenc:CipherData xmlns:xenc="http://www.w3.org/2001/04/xmlenc#">
            <xenc:CipherValue>xyH8nQscJYAaYwJopGaLPk...</xenc:CipherValue>
        </xenc:CipherData>
        <xenc:ReferenceList>
            <xenc:DataReference URI="#_3c63798db8a16b54ade207ea0df28ad4" />
        </xenc:ReferenceList>
        <xenc:CarriedKeyName>_dd0d7a0215f94ea81b170a2e65834ce8</xenc:CarriedKeyName>
    </xenc:EncryptedKey>
</saml2:EncryptedAttribute>
<saml2:Attribute xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" xmlns:attrext="urn:oasis:names:tc:SAML:attributes:ext" Name="urn:etoegang:attribute:18OrOlder" attrext:OriginalIssuer="urn:etoegang:1.9:attribute-sourceid:NLWID" attrext:LastModified="2015-03-31T12:00:00Z">
    <saml2:AttributeValue>false</saml2:AttributeValue>
</saml2:Attribute>