Skip to content

Commit 3ec0629

Browse files
committed
Remove DIGEST-MD5
As mentioned in xmppo#166 (comment) DIGEST-MD5 is obsolete for a long time now.
1 parent 5fdcf18 commit 3ec0629

File tree

1 file changed

+0
-47
lines changed

1 file changed

+0
-47
lines changed

xmpp.go

-47
Original file line numberDiff line numberDiff line change
@@ -434,9 +434,6 @@ func (c *Client) init(o *Options) error {
434434
case slices.Contains(f.Mechanisms.Mechanism,
435435
"PLAIN") && tlsConnOK:
436436
mechanism = "PLAIN"
437-
case slices.Contains(f.Mechanisms.Mechanism,
438-
"DIGEST-MD5"):
439-
mechanism = "DIGEST-MD5"
440437
}
441438
if strings.HasPrefix(mechanism, "SCRAM-SHA") {
442439
if strings.HasSuffix(mechanism, "PLUS") {
@@ -641,50 +638,6 @@ func (c *Client) init(o *Options) error {
641638
base64.StdEncoding.Encode(enc, []byte(raw))
642639
fmt.Fprintf(c.conn, "<auth xmlns='%s' mechanism='PLAIN'>%s</auth>\n", nsSASL, enc)
643640
}
644-
if mechanism == "DIGEST-MD5" {
645-
// Digest-MD5 authentication
646-
fmt.Fprintf(c.stanzaWriter, "<auth xmlns='%s' mechanism='DIGEST-MD5'/>\n", nsSASL)
647-
var ch saslChallenge
648-
if err = c.p.DecodeElement(&ch, nil); err != nil {
649-
return errors.New("unmarshal <challenge>: " + err.Error())
650-
}
651-
b, err := base64.StdEncoding.DecodeString(string(ch))
652-
if err != nil {
653-
return err
654-
}
655-
tokens := map[string]string{}
656-
for _, token := range strings.Split(string(b), ",") {
657-
kv := strings.SplitN(strings.TrimSpace(token), "=", 2)
658-
if len(kv) == 2 {
659-
if kv[1][0] == '"' && kv[1][len(kv[1])-1] == '"' {
660-
kv[1] = kv[1][1 : len(kv[1])-1]
661-
}
662-
tokens[kv[0]] = kv[1]
663-
}
664-
}
665-
realm, _ := tokens["realm"]
666-
nonce, _ := tokens["nonce"]
667-
qop, _ := tokens["qop"]
668-
charset, _ := tokens["charset"]
669-
cnonceStr := cnonce()
670-
digestURI := "xmpp/" + domain
671-
nonceCount := fmt.Sprintf("%08x", 1)
672-
digest := saslDigestResponse(user, realm, o.Password, nonce, cnonceStr, "AUTHENTICATE", digestURI, nonceCount)
673-
message := "username=\"" + user + "\", realm=\"" + realm + "\", nonce=\"" + nonce + "\", cnonce=\"" + cnonceStr +
674-
"\", nc=" + nonceCount + ", qop=" + qop + ", digest-uri=\"" + digestURI + "\", response=" + digest + ", charset=" + charset
675-
676-
fmt.Fprintf(c.stanzaWriter, "<response xmlns='%s'>%s</response>\n", nsSASL, base64.StdEncoding.EncodeToString([]byte(message)))
677-
678-
var rspauth saslRspAuth
679-
if err = c.p.DecodeElement(&rspauth, nil); err != nil {
680-
return errors.New("unmarshal <challenge>: " + err.Error())
681-
}
682-
b, err = base64.StdEncoding.DecodeString(string(rspauth))
683-
if err != nil {
684-
return err
685-
}
686-
fmt.Fprintf(c.stanzaWriter, "<response xmlns='%s'/>\n", nsSASL)
687-
}
688641
}
689642
if mechanism == "" {
690643
return fmt.Errorf("PLAIN authentication is not an option: %v", f.Mechanisms.Mechanism)

0 commit comments

Comments
 (0)