MCPcopy Create free account
hub / github.com/crewjam/saml / eidEncrypt

Function eidEncrypt

encrypted_id_test.go:26–38  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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).
26func 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.
41func eidNameIDEl(nameID NameID) *etree.Element {

Calls 3

OAEPFunction · 0.92
spcovSerializeFunction · 0.85
EncryptMethod · 0.65

Tested by

no test coverage detected