eidEncrypt encrypts el, serialized on its own, to cert and wraps it in a saml:EncryptedID, as an IdP does (saml-core §2.2.4).
(t *testing.T, cert *x509.Certificate, el *etree.Element)
| 24 | // eidEncrypt encrypts el, serialized on its own, to cert and wraps it in a |
| 25 | // saml:EncryptedID, as an IdP does (saml-core §2.2.4). |
| 26 | func eidEncrypt(t *testing.T, cert *x509.Certificate, el *etree.Element) *etree.Element { |
| 27 | t.Helper() |
| 28 | encryptor := xmlenc.OAEP() |
| 29 | encryptor.BlockCipher = xmlenc.AES128CBC |
| 30 | encryptor.DigestMethod = &xmlenc.SHA1 |
| 31 | encryptedDataEl, err := encryptor.Encrypt(cert, spcovSerialize(t, el), nil) |
| 32 | assert.NilError(t, err) |
| 33 | encryptedDataEl.CreateAttr("Type", "http://www.w3.org/2001/04/xmlenc#Element") |
| 34 | encryptedIDEl := etree.NewElement("saml:EncryptedID") |
| 35 | encryptedIDEl.CreateAttr("xmlns:saml", "urn:oasis:names:tc:SAML:2.0:assertion") |
| 36 | encryptedIDEl.AddChild(encryptedDataEl) |
| 37 | return encryptedIDEl |
| 38 | } |
| 39 | |
| 40 | // eidNameIDEl returns nameID as a standalone saml:NameID element. |
| 41 | func eidNameIDEl(nameID NameID) *etree.Element { |
no test coverage detected