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

Function Decrypt

xmlenc/decrypt.go:57–68  ·  view source on GitHub ↗

Decrypt decrypts the encrypted data using the provided key. If the data are encrypted using AES or 3DEC, then the key should be a []byte. If the data are encrypted with PKCS1v15 or RSA-OAEP-MGF1P then key should be a *rsa.PrivateKey.

(key interface{}, ciphertextEl *etree.Element)

Source from the content-addressed store, hash-verified

55// If the data are encrypted with PKCS1v15 or RSA-OAEP-MGF1P then key should
56// be a *rsa.PrivateKey.
57func Decrypt(key interface{}, ciphertextEl *etree.Element) ([]byte, error) {
58 encryptionMethodEl := ciphertextEl.FindElement("./EncryptionMethod")
59 if encryptionMethodEl == nil {
60 return nil, ErrCannotFindRequiredElement("EncryptionMethod")
61 }
62 algorithm := encryptionMethodEl.SelectAttrValue("Algorithm", "")
63 decrypter, ok := decrypters[algorithm]
64 if !ok {
65 return nil, ErrAlgorithmNotImplemented(algorithm)
66 }
67 return decrypter.Decrypt(key, ciphertextEl)
68}
69
70func getCiphertext(encryptedKey *etree.Element) ([]byte, error) {
71 ciphertextEl := encryptedKey.FindElement("./CipherData/CipherValue")

Callers 7

decryptElementMethod · 0.92
TestIDPMarshalAssertionFunction · 0.92
FuzzFunction · 0.85
TestCanDecryptFunction · 0.85
DecryptMethod · 0.85
DecryptMethod · 0.85

Calls 3

DecryptMethod · 0.65

Tested by 3

TestIDPMarshalAssertionFunction · 0.74
TestCanDecryptFunction · 0.68