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

Method decryptElement

encrypted_id.go:281–295  ·  view source on GitHub ↗

decryptElement decrypts encryptedEl, an element with an xenc:EncryptedData child such as saml:EncryptedID, with the IdP's Key, if it is an *rsa.PrivateKey, then with each of DecryptionKeys, and returns the root element of the plaintext.

(encryptedEl *etree.Element)

Source from the content-addressed store, hash-verified

279// *rsa.PrivateKey, then with each of DecryptionKeys, and returns the root
280// element of the plaintext.
281func (idp *IdentityProvider) decryptElement(encryptedEl *etree.Element) (*etree.Element, error) {
282 keys := make([]namedDecryptionKey, 0, 1+len(idp.DecryptionKeys))
283 if key, ok := idp.Key.(*rsa.PrivateKey); ok && key != nil {
284 keys = append(keys, namedDecryptionKey{"Key", key})
285 }
286 for i, key := range idp.DecryptionKeys {
287 if key != nil {
288 keys = append(keys, namedDecryptionKey{fmt.Sprintf("DecryptionKeys[%d]", i), key})
289 }
290 }
291 if len(keys) == 0 {
292 return nil, errors.New("the IdentityProvider has no decryption key: Key is not an *rsa.PrivateKey and DecryptionKeys is empty")
293 }
294 return decryptWithKeys(encryptedEl, keys, idp.MetadataURL.String())
295}

Calls 3

decryptWithKeysFunction · 0.85
StringMethod · 0.80
NewMethod · 0.65