]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: mech-scram: Add support for SCRAM-SHA-256.
authorStephan Bosch <stephan.bosch@dovecot.fi>
Mon, 7 Jan 2019 19:03:16 +0000 (20:03 +0100)
committertimo.sirainen <timo.sirainen@open-xchange.com>
Wed, 4 Dec 2019 14:33:31 +0000 (14:33 +0000)
src/auth/mech-scram.c
src/auth/mech.c

index b10eac7e5e8a532d4427e15649834d04444348f9..35fedc91ab653dbf10e1dad66a7812f519a9028c 100644 (file)
@@ -14,6 +14,7 @@
 #include "buffer.h"
 #include "hmac.h"
 #include "sha1.h"
+#include "sha2.h"
 #include "randgen.h"
 #include "safe-memset.h"
 #include "str.h"
@@ -419,6 +420,11 @@ static struct auth_request *mech_scram_sha1_auth_new(void)
        return mech_scram_auth_new(&hash_method_sha1, "SCRAM-SHA-1");
 }
 
+static struct auth_request *mech_scram_sha256_auth_new(void)
+{
+       return mech_scram_auth_new(&hash_method_sha256, "SCRAM-SHA-256");
+}
+
 const struct mech_module mech_scram_sha1 = {
        "SCRAM-SHA-1",
 
@@ -430,3 +436,15 @@ const struct mech_module mech_scram_sha1 = {
        mech_scram_auth_continue,
        mech_generic_auth_free
 };
+
+const struct mech_module mech_scram_sha256 = {
+       "SCRAM-SHA-256",
+
+       .flags = MECH_SEC_MUTUAL_AUTH,
+       .passdb_need = MECH_PASSDB_NEED_LOOKUP_CREDENTIALS,
+
+       mech_scram_sha256_auth_new,
+       mech_generic_auth_initial,
+       mech_scram_auth_continue,
+       mech_generic_auth_free
+};
index 202c9d3509df17e5425d06b03d9f9fb90f698971..d12c0db2d7c90810bc475be09362cd32d9370d6f 100644 (file)
@@ -74,6 +74,7 @@ extern const struct mech_module mech_external;
 extern const struct mech_module mech_ntlm;
 extern const struct mech_module mech_otp;
 extern const struct mech_module mech_scram_sha1;
+extern const struct mech_module mech_scram_sha256;
 extern const struct mech_module mech_skey;
 extern const struct mech_module mech_rpa;
 extern const struct mech_module mech_anonymous;
@@ -211,6 +212,7 @@ void mech_init(const struct auth_settings *set)
        }
        mech_register_module(&mech_otp);
        mech_register_module(&mech_scram_sha1);
+       mech_register_module(&mech_scram_sha256);
        mech_register_module(&mech_skey);
        mech_register_module(&mech_rpa);
        mech_register_module(&mech_anonymous);
@@ -240,6 +242,7 @@ void mech_deinit(const struct auth_settings *set)
        }
        mech_unregister_module(&mech_otp);
        mech_unregister_module(&mech_scram_sha1);
+       mech_unregister_module(&mech_scram_sha256);
        mech_unregister_module(&mech_skey);
        mech_unregister_module(&mech_rpa);
        mech_unregister_module(&mech_anonymous);