| 68 | } |
| 69 | |
| 70 | func getCiphertext(encryptedKey *etree.Element) ([]byte, error) { |
| 71 | ciphertextEl := encryptedKey.FindElement("./CipherData/CipherValue") |
| 72 | if ciphertextEl == nil { |
| 73 | return nil, fmt.Errorf("cannot find CipherData element containing a CipherValue element") |
| 74 | } |
| 75 | ciphertext, err := base64.StdEncoding.DecodeString(strings.TrimSpace(ciphertextEl.Text())) |
| 76 | if err != nil { |
| 77 | return nil, err |
| 78 | } |
| 79 | return ciphertext, nil |
| 80 | } |
| 81 | |
| 82 | func validateRSAKeyIfPresent(key interface{}, encryptedKey *etree.Element) (*rsa.PrivateKey, error) { |
| 83 | rsaKey, ok := key.(*rsa.PrivateKey) |