Skip to content

Commit

Permalink
#194: Properly default EncryptionMethod/DigestMethod when not present.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Kress authored and crewjam committed May 7, 2019
1 parent 724cb1c commit d288d9a
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions xmlenc/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d288d9a

Please sign in to comment.