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

Function encryptedKeyCandidates

encrypted_id.go:263–275  ·  view source on GitHub ↗

encryptedKeyCandidates returns the xenc:EncryptedKey elements that may hold the content key of encryptedDataEl: those beside it in encryptedEl and those in its KeyInfo, the ones whose Recipient is recipient first and otherwise in document order.

(encryptedEl, encryptedDataEl *etree.Element, recipient string)

Source from the content-addressed store, hash-verified

261// and those in its KeyInfo, the ones whose Recipient is recipient first and
262// otherwise in document order.
263func encryptedKeyCandidates(encryptedEl, encryptedDataEl *etree.Element, recipient string) []*etree.Element {
264 all := append(encryptedEl.FindElements("./EncryptedKey"), encryptedDataEl.FindElements("./KeyInfo/EncryptedKey")...)
265 matching := make([]*etree.Element, 0, len(all))
266 others := make([]*etree.Element, 0, len(all))
267 for _, el := range all {
268 if recipient != "" && el.SelectAttrValue("Recipient", "") == recipient {
269 matching = append(matching, el)
270 } else {
271 others = append(others, el)
272 }
273 }
274 return append(matching, others...)
275}
276
277// decryptElement decrypts encryptedEl, an element with an xenc:EncryptedData
278// child such as saml:EncryptedID, with the IdP's Key, if it is an

Callers 2

decryptWithKeysFunction · 0.85

Calls

no outgoing calls