Skip to main content
Skip table of contents

SAML encryption

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:

  • The element MUST be encrypted using applicable encryption algorithms, as defined in Encryption.

  • A new, cryptographically sound randomly generated symmetric key MUST be used per encrypted element.

  • The @Recipient of the resulting <EncryptedKey> MUST be set to the EntityID of the recipient.

  • XML contents in the encrypted element MUST have all namespace definitions.

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:

  • each EncryptedKey MUST have a CarriedKeyName equal to the KeyName used in the KeyInfo of the EncryptedData.

  • each EncryptedKey SHOULD have a ReferenceList, refering back to the data encrypted with the symmetric key contained.

  • Upon decryption, elements without an EncryptedKey intended for the decrypting recipient MAY be ignored and EncryptedKeys for other recipients of encrypted elements SHOULD be ignored.

  • Upon decryption a recipient MUST be able to select the appropriate EncryptedKey based on recipient EntityID in 'Recipient' and a 'KeyName' that corresponds with the appropriate recipient PKI-certificate in the NetwerkMetadata or ServiceCatalog.

EncryptedID

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

  • The Format attribute MUST be set to 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent'.

  • The NameQualifier attribute MUST be populated with the full name of the type of identifying attribute (e.g. 'urn:etoegang:EntityConcernedID:KvKnr').

    • For Intern pseudoniem identifiers, the NameQualifier MUST contain the OIN format of the EntityID (KvK number) of the "Authenticatiedienst".

    • For other Identificerende kenmerken, the NameQualifier MUST contain the identifing attribute's name, in URI format. For instance for a BSN the value is 'urn:etoegang:1.9:EntityConcernedID:BSN' and for a Specific pseudonym the value is 'urn:etoegang:1.9:EntityConcernedID:Pseudo'.

  • The attributes SPNameQualifier and SPProvidedID MUST NOT be used.

  • In case more than one certificate is listed for encryption for the recipient, the pseudonym MUST be encrypted for each certificate. This will result in multiple EncryptedKeys, see above.

EncryptedAttribute

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

  • The @Name attribute MUST be present.

  • One <AttributeValue> per value of the attribute MUST be used.

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.

Example EncryptedID
XML
 <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>

Example NameID after decryption
XML
<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>
Example EncryptedAttribute - multiple recipients
XML
 <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>
Example Attribute after decryption
XML
<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>

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.