Decrypt implements Decryptor. `key` must be an *rsa.PrivateKey.
(key interface{}, ciphertextEl *etree.Element)
| 94 | |
| 95 | // Decrypt implements Decryptor. `key` must be an *rsa.PrivateKey. |
| 96 | func (e RSA) Decrypt(key interface{}, ciphertextEl *etree.Element) ([]byte, error) { |
| 97 | rsaKey, err := validateRSAKeyIfPresent(key, ciphertextEl) |
| 98 | if err != nil { |
| 99 | return nil, err |
| 100 | } |
| 101 | |
| 102 | ciphertext, err := getCiphertext(ciphertextEl) |
| 103 | if err != nil { |
| 104 | return nil, err |
| 105 | } |
| 106 | |
| 107 | { |
| 108 | digestMethodEl := ciphertextEl.FindElement("./EncryptionMethod/DigestMethod") |
| 109 | if digestMethodEl == nil { |
| 110 | e.DigestMethod = SHA1 |
| 111 | } else { |
| 112 | hashAlgorithmStr := digestMethodEl.SelectAttrValue("Algorithm", "") |
| 113 | digestMethod, ok := digestMethods[hashAlgorithmStr] |
| 114 | if !ok { |
| 115 | return nil, ErrAlgorithmNotImplemented(hashAlgorithmStr) |
| 116 | } |
| 117 | e.DigestMethod = digestMethod |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | return e.keyDecrypter(e, rsaKey, ciphertext) |
| 122 | } |
| 123 | |
| 124 | // OAEP returns a version of RSA that implements RSA in OAEP-MGF1P mode. By default |
| 125 | // the block cipher used is AES-256 CBC and the digest method is SHA-256. You can |
nothing calls this directly
no test coverage detected