summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2021-01-31 13:12:04 +0100
committerChristian Grothoff <christian@grothoff.org>2021-01-31 13:12:04 +0100
commit83f0cd871092dcd547eee18c2b67ec10ac1828ff (patch)
treeb0a9fe84a727fbe55c630a7fa4c3e09c2f8497b2 /src/backend/taler-merchant-httpd.c
parent9dded1aec4e5e62dce29ac86bc486112c7bff60d (diff)
downloadmerchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.tar.gz
merchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.tar.bz2
merchant-83f0cd871092dcd547eee18c2b67ec10ac1828ff.zip
implement import of auth_token into merchant DB when configuring instances (#6731)
Diffstat (limited to 'src/backend/taler-merchant-httpd.c')
-rw-r--r--src/backend/taler-merchant-httpd.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c
index bf1c4db3..6e6318d2 100644
--- a/src/backend/taler-merchant-httpd.c
+++ b/src/backend/taler-merchant-httpd.c
@@ -172,6 +172,53 @@ struct ResumeData
};
+int
+TMH_check_auth (const char *token,
+ const struct GNUNET_ShortHashCode *salt,
+ const struct GNUNET_HashCode *hash)
+{
+ struct GNUNET_HashCode val;
+
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (&val,
+ sizeof (val),
+ salt,
+ sizeof (*salt),
+ token,
+ strlen (token),
+ "merchant-instance-auth",
+ strlen ("merchant-instance-auth"),
+ NULL,
+ 0));
+ return (0 == GNUNET_memcmp (&val,
+ hash))
+ ? GNUNET_OK
+ : GNUNET_SYSERR;
+}
+
+
+void
+TMH_compute_auth (const char *token,
+ struct GNUNET_ShortHashCode *salt,
+ struct GNUNET_HashCode *hash)
+{
+ GNUNET_CRYPTO_random_block (GNUNET_CRYPTO_QUALITY_NONCE,
+ salt,
+ sizeof (*salt));
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (hash,
+ sizeof (*hash),
+ salt,
+ sizeof (*salt),
+ token,
+ strlen (token),
+ "merchant-instance-auth",
+ strlen ("merchant-instance-auth"),
+ NULL,
+ 0));
+}
+
+
/**
* Decrement reference counter of @a mi, and free if it hits zero.
*