add SCRAM-SHA-256 and SCRAM-SHA-512 support
This commit is contained in:
committed by
Dmitry Podgorny
parent
fc064bc883
commit
771d5865ae
11
src/auth.c
11
src/auth.c
@@ -250,6 +250,10 @@ static int _handle_features(xmpp_conn_t *const conn,
|
||||
conn->sasl_support |= SASL_MASK_DIGESTMD5;
|
||||
else if (strcasecmp(text, "SCRAM-SHA-1") == 0)
|
||||
conn->sasl_support |= SASL_MASK_SCRAMSHA1;
|
||||
else if (strcasecmp(text, "SCRAM-SHA-256") == 0)
|
||||
conn->sasl_support |= SASL_MASK_SCRAMSHA256;
|
||||
else if (strcasecmp(text, "SCRAM-SHA-512") == 0)
|
||||
conn->sasl_support |= SASL_MASK_SCRAMSHA512;
|
||||
else if (strcasecmp(text, "ANONYMOUS") == 0)
|
||||
conn->sasl_support |= SASL_MASK_ANONYMOUS;
|
||||
|
||||
@@ -644,7 +648,12 @@ static void _auth(xmpp_conn_t *const conn)
|
||||
xmpp_disconnect(conn);
|
||||
} else if (conn->sasl_support & SASL_MASK_SCRAM) {
|
||||
scram_ctx = xmpp_alloc(conn->ctx, sizeof(*scram_ctx));
|
||||
scram_ctx->alg = &scram_sha1;
|
||||
if (conn->sasl_support & SASL_MASK_SCRAMSHA512)
|
||||
scram_ctx->alg = &scram_sha512;
|
||||
else if (conn->sasl_support & SASL_MASK_SCRAMSHA256)
|
||||
scram_ctx->alg = &scram_sha256;
|
||||
else if (conn->sasl_support & SASL_MASK_SCRAMSHA1)
|
||||
scram_ctx->alg = &scram_sha1;
|
||||
auth = _make_sasl_auth(conn, scram_ctx->alg->scram_name);
|
||||
if (!auth) {
|
||||
disconnect_mem_error(conn);
|
||||
|
||||
Reference in New Issue
Block a user