]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
auth: password-scheme-scram - Move Hi() to auth-scram.c.
authorStephan Bosch <stephan.bosch@open-xchange.com>
Mon, 26 Sep 2022 20:16:35 +0000 (22:16 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 27 Jan 2023 09:34:54 +0000 (09:34 +0000)
src/auth/auth-scram.c [new file with mode: 0644]
src/auth/password-scheme-scram.c

diff --git a/src/auth/auth-scram.c b/src/auth/auth-scram.c
new file mode 100644 (file)
index 0000000..abdcb3a
--- /dev/null
@@ -0,0 +1,26 @@
+static void
+Hi(const struct hash_method *hmethod, const unsigned char *str, size_t str_size,
+   const unsigned char *salt, size_t salt_size, unsigned int i,
+   unsigned char *result)
+{
+       struct hmac_context ctx;
+       unsigned char U[hmethod->digest_size];
+       unsigned int j, k;
+
+       /* Calculate U1 */
+       hmac_init(&ctx, str, str_size, hmethod);
+       hmac_update(&ctx, salt, salt_size);
+       hmac_update(&ctx, "\0\0\0\1", 4);
+       hmac_final(&ctx, U);
+
+       memcpy(result, U, hmethod->digest_size);
+
+       /* Calculate U2 to Ui and Hi */
+       for (j = 2; j <= i; j++) {
+               hmac_init(&ctx, str, str_size, hmethod);
+               hmac_update(&ctx, U, sizeof(U));
+               hmac_final(&ctx, U);
+               for (k = 0; k < hmethod->digest_size; k++)
+                       result[k] ^= U[k];
+       }
+}
index ada19b644de314c2574af96ab303b60bec189a15..bb584563862d0e3bfddfd67b59d9a9486a92e277 100644 (file)
 
 #define SCRAM_DEFAULT_ITERATE_COUNT 4096
 
-static void
-Hi(const struct hash_method *hmethod, const unsigned char *str, size_t str_size,
-   const unsigned char *salt, size_t salt_size, unsigned int i,
-   unsigned char *result)
-{
-       struct hmac_context ctx;
-       unsigned char U[hmethod->digest_size];
-       unsigned int j, k;
-
-       /* Calculate U1 */
-       hmac_init(&ctx, str, str_size, hmethod);
-       hmac_update(&ctx, salt, salt_size);
-       hmac_update(&ctx, "\0\0\0\1", 4);
-       hmac_final(&ctx, U);
-
-       memcpy(result, U, hmethod->digest_size);
-
-       /* Calculate U2 to Ui and Hi */
-       for (j = 2; j <= i; j++) {
-               hmac_init(&ctx, str, str_size, hmethod);
-               hmac_update(&ctx, U, sizeof(U));
-               hmac_final(&ctx, U);
-               for (k = 0; k < hmethod->digest_size; k++)
-                       result[k] ^= U[k];
-       }
-}
+#include "auth-scram.c"
 
 int scram_scheme_parse(const struct hash_method *hmethod, const char *name,
                       const unsigned char *credentials, size_t size,