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)
| 55 | // If the data are encrypted with PKCS1v15 or RSA-OAEP-MGF1P then key should |
| 56 | // be a *rsa.PrivateKey. |
| 57 | func 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 | |
| 70 | func getCiphertext(encryptedKey *etree.Element) ([]byte, error) { |
| 71 | ciphertextEl := encryptedKey.FindElement("./CipherData/CipherValue") |