diff --git a/xmlenc/pubkey.go b/xmlenc/pubkey.go index 7ccdd6c6..3aee4e80 100644 --- a/xmlenc/pubkey.go +++ b/xmlenc/pubkey.go @@ -107,14 +107,15 @@ func (e RSA) Decrypt(key interface{}, ciphertextEl *etree.Element) ([]byte, erro { digestMethodEl := ciphertextEl.FindElement("./EncryptionMethod/DigestMethod") if digestMethodEl == nil { - return nil, fmt.Errorf("cannot find required DigestMethod element") + e.DigestMethod = SHA1 + } else { + hashAlgorithmStr := digestMethodEl.SelectAttrValue("Algorithm", "") + digestMethod, ok := digestMethods[hashAlgorithmStr] + if !ok { + return nil, ErrAlgorithmNotImplemented(hashAlgorithmStr) + } + e.DigestMethod = digestMethod } - hashAlgorithmStr := digestMethodEl.SelectAttrValue("Algorithm", "") - digestMethod, ok := digestMethods[hashAlgorithmStr] - if !ok { - return nil, ErrAlgorithmNotImplemented(hashAlgorithmStr) - } - e.DigestMethod = digestMethod } return e.keyDecrypter(e, rsaKey, ciphertext)