summaryrefslogtreecommitdiff
path: root/src/util/util.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-01-27 16:09:25 +0100
committerChristian Grothoff <christian@grothoff.org>2023-01-27 16:09:25 +0100
commit59716ffdc48ad71a0f047f7e68f04b64d449d408 (patch)
tree8f913d7c24140df6ea6c2b46e389ffdf4363f618 /src/util/util.c
parentd79c23aaabb5dc1c9073555d574bea01b75668cd (diff)
downloadexchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.tar.gz
exchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.tar.bz2
exchange-59716ffdc48ad71a0f047f7e68f04b64d449d408.zip
add logic to store attributes
Diffstat (limited to 'src/util/util.c')
-rw-r--r--src/util/util.c52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/util/util.c b/src/util/util.c
index 5321b31ed..96d791912 100644
--- a/src/util/util.c
+++ b/src/util/util.c
@@ -1,6 +1,6 @@
/*
This file is part of TALER
- Copyright (C) 2014-2020 Taler Systems SA
+ Copyright (C) 2014-2023 Taler Systems SA
TALER is free software; you can redistribute it and/or modify it under the
terms of the GNU General Public License as published by the Free Software
@@ -19,9 +19,12 @@
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
* @author Florian Dold
* @author Benedikt Mueller
+ * @author Christian Grothoff
*/
#include "platform.h"
#include "taler_util.h"
+#include "taler_attributes.h"
+#include <gnunet/gnunet_json_lib.h>
const char *
@@ -243,4 +246,51 @@ strchrnul (const char *s,
#endif
+void
+TALER_CRYPTO_attributes_to_kyc_prox (
+ const json_t *attr,
+ struct GNUNET_ShortHashCode *kyc_prox)
+{
+ const char *name = NULL;
+ const char *birthdate = NULL;
+ struct GNUNET_JSON_Specification spec[] = {
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string (TALER_ATTRIBUTE_FULL_NAME,
+ &name),
+ NULL),
+ GNUNET_JSON_spec_mark_optional (
+ GNUNET_JSON_spec_string (TALER_ATTRIBUTE_BIRTHDATE,
+ &birthdate),
+ NULL),
+ GNUNET_JSON_spec_end ()
+ };
+
+ if (GNUNET_OK !=
+ GNUNET_JSON_parse (attr,
+ spec,
+ NULL, NULL))
+ {
+ GNUNET_break (0);
+ memset (kyc_prox,
+ 0,
+ sizeof (*kyc_prox));
+ return;
+ }
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (
+ kyc_prox,
+ sizeof (*kyc_prox),
+ name,
+ (NULL == name)
+ ? 0
+ : strlen (name),
+ birthdate,
+ (NULL == birthdate)
+ ? 0
+ : strlen (birthdate),
+ NULL,
+ 0));
+}
+
+
/* end of util.c */