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)
| 261 | // and those in its KeyInfo, the ones whose Recipient is recipient first and |
| 262 | // otherwise in document order. |
| 263 | func 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 |
no outgoing calls