diff options
Diffstat (limited to 'src/backend/taler-merchant-httpd.c')
-rw-r--r-- | src/backend/taler-merchant-httpd.c | 47 |
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. * |